//////////////////////////////////////////////////////////////////// /// \class RAT::DS::TrigHeader /// /// \brief Data Structure: Event-level trigger information /// /// \author Gabriel Orebi Gann /// /// REVISION HISTORY: /// 2013/11/18 : A. Mastbaum - copied from TRIGInfo, expanded abbrev. names\n /// 2014-03-26 : P G Jones - refactor in line with dsreview \n /// /// \details This structure holds trigger information on an event-level /// basis. /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_TrigHeader__ #define __RAT_DS_TrigHeader__ #include #include #include #include namespace RAT { namespace DS { class TrigHeader : public TObject { public: /// Raised when an unavailable trigger ID is requested from the threshold or /// offset array. class TriggerNotFoundException : public std::runtime_error{ public: TriggerNotFoundException(const std::string& what_) : std::runtime_error(what_) {} }; /// Set all the values to 0 TrigHeader() : TObject(), trigMask(0), pulserRate(0), MTC_CSR(0), lockoutWidth(0), prescaleFrequency(0) {} /// Set the mask of enabled triggers. /// /// @param[in] mask to set void SetTrigMask(const UInt_t mask) { trigMask = mask; } /// Get the mask of enabled triggers. /// /// @return the mask UInt_t GetTrigMask() const { return trigMask; } /// Set the MTC/D pulser rate. /// /// @param[in] rate of the pulser void SetPulserRate(const UInt_t rate) { pulserRate = rate; } /// Get the MTC/D pulser rate. /// /// @return the pulser rate UInt_t GetPulserRate() const { return pulserRate; } /// Set the contents of the MTC/D Control/Status register. /// /// @param[in] contents of the MTC/D CS register void SetMTC_CSR(const UInt_t contents) { MTC_CSR = contents; } /// Get the contents of the MTC/D Control/Status register. /// /// @return the contents UInt_t GetMTC_CSR() const { return MTC_CSR; } /// Set the width of the trigger lockout window. /// /// @param[in] width of the lockout void SetLockoutWidth(const UInt_t width) { lockoutWidth = width; } /// Get the width of the trigger lockout window. /// /// @return the width UInt_t GetLockoutWidth() const { return lockoutWidth; } /// Set the frequency of the prescale trigger. /// /// @param[in] frequency value void SetPrescaleFrequency(const UInt_t frequency) { prescaleFrequency = frequency; } /// Get the frequency of the prescale trigger. /// /// @return the prescale trigger frequency. UInt_t GetPrescaleFrequency() const { return prescaleFrequency; } /// Set the threshold for the given trigger ID. /// /// @param[in] bit or id of the trigger /// @param[in] threshold value for the trigger void SetTriggerThreshold(const UShort_t bit, const UShort_t threshold) { thresholds[bit] = threshold; } /// Get the threshold for the given trigger ID. /// /// @param[in] i bit or id of the trigger /// @return threshold value for the trigger /// @throws TriggerNotFoundException if the requested ID is not set inline UShort_t GetTriggerThreshold(const UShort_t i) const; /// Set the zero offset for the given trigger bit /// /// @param[in] bit or id of the trigger /// @param[in] offset value for the trigger void SetTrigZeroOffset(const UShort_t bit, const UShort_t offset) { offsets[bit] = offset; } /// Get the zero offset for the given trigger ID. /// /// @param[in] bit or id of the trigger /// @return offset value for the trigger /// @throws TriggerNotFoundException if the requested ID is not set inline UShort_t GetTriggerZeroOffset(const UShort_t bit) const; // This ROOT macro adds dictionary methods to this class. // The number should be incremented whenever this class's members are changed. // It assumes this class has no virtual methods, use ClassDef if change this. ClassDefNV(TrigHeader, 1); protected: std::map thresholds; ///< MTC/A+ thresholds in DAC counts, keyed on trigger bit std::map offsets; ///< MTC/A+ zero-threshold offsets in DAC counts, keyed on trigger bit UInt_t trigMask; ///< Mask of enabled triggers UInt_t pulserRate; ///< Rate of MTC/D pulser UInt_t MTC_CSR; ///< MTC/D Control/Status register UInt_t lockoutWidth; ///< Width of the lockout window UInt_t prescaleFrequency; ///< Frequency of the prescale trigger }; inline UShort_t TrigHeader::GetTriggerThreshold(const UShort_t bit) const { if( thresholds.count( bit ) == 1 ) return thresholds.at(bit); else throw TriggerNotFoundException(dformat("No threshold for trigger ID %u\n", bit)); } inline UShort_t TrigHeader::GetTriggerZeroOffset(const UShort_t bit) const { if( offsets.count( bit ) == 1 ) return offsets.at(bit); else throw TriggerNotFoundException(dformat("No offset for trigger ID %u\n", bit)); } } // namespace DS } // namespace RAT #endif // __RAT_DS_TrigHeader__