1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: TriggerEngine.hh 2967 2011-07-14 15:23:29Z fenu $ |
---|
3 | // M. Pallavicini created Oct, 24 2003 |
---|
4 | // Base class for any triggering algorythm |
---|
5 | // It acts as a visitor (friend class) of MacroCellData |
---|
6 | // |
---|
7 | |
---|
8 | #ifndef __TRIGGERENGINE_HH_ |
---|
9 | #define __TRIGGERENGINE_HH_ |
---|
10 | |
---|
11 | #include <map> |
---|
12 | #include "euso.hh" |
---|
13 | #include "EsafConfigurable.hh" |
---|
14 | #include "EsafMsgSource.hh" |
---|
15 | #include "Etypes.hh" |
---|
16 | |
---|
17 | class MacroCellData; |
---|
18 | |
---|
19 | class TriggerEngine : public EsafConfigurable, public EsafMsgSource { |
---|
20 | public: |
---|
21 | |
---|
22 | // ctor |
---|
23 | TriggerEngine(const string& name, ETriggerTypeIdentifier); |
---|
24 | |
---|
25 | // dtor |
---|
26 | virtual ~TriggerEngine(); |
---|
27 | |
---|
28 | // factory method for engines |
---|
29 | static map<ETriggerTypeIdentifier,TriggerEngine*> &GetEngines( ETriggerTypeIdentifier ); |
---|
30 | |
---|
31 | // return engine name |
---|
32 | inline const string& GetName() const { return fName; } |
---|
33 | |
---|
34 | // simulate trigger |
---|
35 | virtual void Simulate( MacroCellData* ) = 0; |
---|
36 | |
---|
37 | // true if we got a trigger |
---|
38 | inline Bool_t HasTriggered() const { return fHasTriggered; } |
---|
39 | |
---|
40 | // get trigger word (bitfield for all trigger engines) |
---|
41 | static Int_t GetTriggerWord() {return fTriggerWord;} |
---|
42 | |
---|
43 | // reset trigger word |
---|
44 | static void ResetTriggerWord() {fTriggerWord=0; fTrgWords.clear();} |
---|
45 | |
---|
46 | //get trgwords |
---|
47 | static const map<Int_t, Int_t>& GetTrgWords() {return fTrgWords;} |
---|
48 | |
---|
49 | // get gtu at which trigger occurred |
---|
50 | inline Int_t GetGtuTrigger() const { return fGtuTrigger;} |
---|
51 | |
---|
52 | EsafConfigClass(Electronics,TriggerEngine); |
---|
53 | |
---|
54 | protected: |
---|
55 | // set trigger flag reserved to child classes |
---|
56 | inline void SetTrigger() { fHasTriggered = kTRUE; fTriggerWord |= (Int_t)GetTriggerId(); } |
---|
57 | void SetTrigger(Int_t word); |
---|
58 | |
---|
59 | // get trigger id reserved to child classes |
---|
60 | inline Int_t GetTriggerId() const { return fTrgId;} |
---|
61 | |
---|
62 | // set gtu trigger |
---|
63 | inline void SetGtuTrigger(Int_t gtu) { fGtuTrigger = gtu; } |
---|
64 | |
---|
65 | inline void SetGtuTriggerCCB(Int_t gtu) { fGtuTriggerCCB = gtu; } |
---|
66 | inline Int_t GetGtuTriggerCCB() { return fGtuTriggerCCB; } |
---|
67 | |
---|
68 | private: |
---|
69 | // name of this engine |
---|
70 | string fName; |
---|
71 | |
---|
72 | // trigger id for this engine |
---|
73 | ETriggerTypeIdentifier fTrgId; |
---|
74 | |
---|
75 | // true if triggered occurred |
---|
76 | Bool_t fHasTriggered; |
---|
77 | |
---|
78 | // gtu at which trigger occurred |
---|
79 | Int_t fGtuTrigger,fGtuTriggerCCB; |
---|
80 | |
---|
81 | // factory method for trigger engines |
---|
82 | // right now designed to provide the same trigger structure for all |
---|
83 | // macrocells |
---|
84 | static map<ETriggerTypeIdentifier,TriggerEngine*> *fEngines; |
---|
85 | |
---|
86 | // trigger word is the same for all engines |
---|
87 | // bit field of ETriggerTypeIdentifier |
---|
88 | static Int_t fTriggerWord; |
---|
89 | |
---|
90 | //trigger word map for triggers with multiple config running in parallel |
---|
91 | static map<Int_t, Int_t> fTrgWords; |
---|
92 | |
---|
93 | ClassDef(TriggerEngine,0) |
---|
94 | }; |
---|
95 | |
---|
96 | #endif /* __TRIGGERENGINE_HH_ */ |
---|
97 | |
---|