#ifndef TTrigger_hxx_seen #define TTrigger_hxx_seen #include #include #include #include "IDigit.hxx" #include "IHandle.hxx" #include "ITriggerContainer.hxx" namespace COMET { /// Base class for all exceptions associated with the ITrigger classes. OA_EXCEPTION(ETrigger, EoaCore); /// An exception that should be thrown when the user requests information /// from the digit that is not available. OA_EXCEPTION(EInvalidTriggerRequest, ETrigger); // The base class class ITrigger; // The writable version of ITrigger class IWritableTrigger; // A handle to reference a ITrigger object that may or may not be available. // class ITriggerProxy; class IDigit; } /// An base class for trigger. class COMET::ITrigger : public TObject { public: /// Contributing channel Ids typedef std::set< COMET::IChannelId > ChannelIdContainer; /// Status of this trigger signal at each channelId enum TriggerStatus { kIgnored = 0, ///< Never checked (default) kChecked = 1, ///< Only checked (recommended to set at least this value for each IChannelId) kMissed = 2, ///< Checked, but missed due to dead time, or some reasons kNoData = 3, ///< Accepted, but no digit data coming to this channel kReadout = 4 ///< Accepted, and readout }; /// Map of the trigger status for each IChannelId typedef std::map< COMET::IChannelId, TriggerStatus > TriggerStatusMap; /// Container of the digit created by this trigger /** Not IDigitContainer because this doesn't have ownerships (const IDigit*) but just connection to it. */ typedef std::vector< const COMET::IDigit* > DigitContainer; /// ITriggers combined into this trigger typedef std::vector< const COMET::ITrigger* > CombinedTriggers; protected: /// Identifier Int_t fTriggerId; /// Timing tick where this trigger was generated (must be in the fundamental clocking) Int_t fTriggerTick; /// ChannelIds contributing to this trigger ChannelIdContainer fChannelIds; /// Trigger status for every triggered IChannelId TriggerStatusMap fTriggerStatuses; /// IDigits contributing to this trigger DigitContainer fDigits; /// ITriggers combined into this trigger /** When multiple triggers are generated at the same timing tick from different channels, they are possibly combined into single trigger, They however should be saved separately for evaluating each trigger. */ CombinedTriggers fCombinedTriggers; public: /// Constructor ITrigger(); /// Destructor virtual ~ITrigger(); /// Print the digit information. virtual void ls(Option_t* opt = "") const; /// @name Get methods //@{ Int_t GetTriggerId() const {return fTriggerId;} Int_t GetTriggerTick() const {return fTriggerTick;} TriggerStatus GetTriggerStatus(const COMET::IChannelId& chanId) const; const ChannelIdContainer& GetChannelIds() const {return fChannelIds;} const TriggerStatusMap& GetTriggerStatuses() const {return fTriggerStatuses;} const DigitContainer& GetDigits() const {return fDigits;} const CombinedTriggers& GetCombinedTriggers() const {return fCombinedTriggers;} //@} /// Return the number of the 'independent' triggers contributed to this trigger signal Int_t GetMultiplicity() const; ClassDef(ITrigger, 1); }; /// A writable version of COMET::ITrigger class COMET::IWritableTrigger : public COMET::ITrigger { public: IWritableTrigger (); /// Construct a trigger for a particular trigger timing tick /** fTriggerId is initialized -1 (default), it should be assigned by the trigger manager with SetTriggerId() */ explicit IWritableTrigger(const Int_t triggerTick); virtual ~IWritableTrigger(); /// Set trigger identifier void SetTriggerId(const Int_t triggerId) {fTriggerId = triggerId;} /// Set trigger timing tick void SetTriggerTick(const Int_t triggerTick) {fTriggerTick = triggerTick;} /// Add contributing channel void AddChannelId(const COMET::IChannelId& chanId) {fChannelIds.insert(chanId);} /// Add contributing channel void AddChannelIds(const ChannelIdContainer& chanIds); /// Set trigger status at the given IChannelId void SetTriggerStatus(const COMET::IChannelId& chanId, const TriggerStatus status) {fTriggerStatuses[chanId] = status;} /// Add a set of trigger statuses void AddTriggerStatuses(const TriggerStatusMap& triggerStatuses); /// Add a digit with raw pointer void AddDigit(const COMET::IDigit* digit){ fDigits.push_back(digit); } /// Add a set of digits void AddDigits(const DigitContainer& digits); /// Add a unique (not duplicated) digit with raw pointer, this takes longer time than AddDigit(). void AddUniqueDigit(const COMET::IDigit* digit); /// Add a set of unique (not duplicated) digits, this takes longer time than AddDigits(). void AddUniqueDigits(const DigitContainer& digits); /// Add a trigger to the combined triggers. void AddCombinedTrigger(const COMET::ITrigger* trigger) { fCombinedTriggers.push_back(trigger); } /// Add a trigger to the combined triggers. void AddCombinedTriggers(const CombinedTriggers& triggers); ClassDef(IWritableTrigger, 1); }; #endif