StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcTriggerSimu.h
1 // -*- mode: C++ -*-
2 //
3 // Pibero Djawotho <pibero@comp.tamu.edu>
4 // Texas A&M University Cyclotron Institute
5 // 12 Jan 2009
6 //
7 
8 #ifndef ST_EMC_TRIGGER_SIMU_H
9 #define ST_EMC_TRIGGER_SIMU_H
10 
11 class StBemcTriggerSimu;
12 class StEemcTriggerSimu;
13 struct DSMLayer_EM201_2009;
14 struct DSMLayer_LD301_2009;
15 struct TriggerDefinition;
16 class TCU;
17 
18 #include <set>
19 
20 using namespace std;
21 
22 #include "StTriggerUtilities/StVirtualTriggerSimu.h"
23 #include "StTriggerUtilities/StTriggerSimuResult.h"
24 
26 public:
28  virtual ~StEmcTriggerSimu();
29 
30  bool isTrigger(int trigId);
31  set<int> triggerIds() const;
32  StTriggerSimuDecision triggerDecision(int trigId);
33 
34  // 16-bit output of EM201 DSM
35  int EM201output() const;
36 
37  // Access to individual bits of EM201 DSM ouput
38  // See http://www.star.bnl.gov/public/trg/run2009/emc_recabling.pdf
39  int BHT() const; // (Bit 0:3) Barrel HT bits (4 bits)
40  int EHT() const; // (Bit 4:5) Endcap HT bits (2 bits)
41  int JP1() const; // (Bit 6) JP1, unified over the BEMC+EEMC (1 bit)
42  int JP2() const; // (Bit 7) JP2, unified over the BEMC+EEMC (1 bit)
43  int BJP1() const; // (Bit 8) BJP1 for the 18 BEMC-only patches (1 bit)
44  int BJP2() const; // (Bit 9) BJP2 for the 18 BEMC-only patches (1 bit)
45  int EJP1() const; // (Bit 10) EJP1 for the 6 EEMC-only patches (1 bit)
46  int EJP2() const; // (Bit 11) EJP2 for the 6 EEMC-only patches (1 bit)
47  int AJP() const; // (Bit 12) AJP for BEMC and EEMC but NOT the boundary (1 bit)
48  int BAJP() const; // (Bit 13) BAJP for the BEMC-only patches (1 bit)
49  int EAJP() const; // (Bit 14) EAJP for the EEMC-only patches (1 bit)
50  int JP0() const; // (Bit 15) JP0, unified over the BEMC+EEMC
51 
52  int BHT0() const;
53  int BHT1() const;
54  int BHT2() const;
55  int BHT3() const;
56 
57  int EHT0() const;
58  int EHT1() const;
59 
60  // 2013 change
61  int EEMCdijet() const; // Bit 9
62  int JP1dijet() const; // Bit 11
63  int JP0dijet() const; //Bit 12
64  int DAQ10k() const; // Bit 14
65  // 2014 change
66  int BHT4() const {return btest(EM201output(), 4);} // Bit 4
67  int BHTUPC() const {return btest(EM201output(), 5);} //Bit 5
68  int BTP() const {return btest(EM201output(), 6);} //Bit 6
69  int BHTTP() const {return btest(EM201output(), 7);} //Bit 7
70  int BTPtopo() const {return btest(EM201output(), 8);} //Bit 8
71  int BHTTPtopo() const {return btest(EM201output(), 9);} //Bit 9
72  int BHT4topo() const {return btest(EM201output(), 10);} //Bit 10
73  int EHT0_2014() const {return btest(EM201output(), 13);} //Bit 13
74  int EHT1_2014() const {return btest(EM201output(), 14); } //Bit 14
75  int DAQ10k_2014() const { return btest(EM201output(), 15); }//Bit 15
76  //2015 change
77  int HTTP() const {return btest(EM201output(), 3);} //Bit 3
78  int EB2B() const {return btest(EM201output(), 14);} //Bit 14
79  //2017 change
80  int BHT1_2017() const {return btest(EM201output(), 0);}
81  int BHT2_2017() const {return btest(EM201output(), 1);}
82  int BHT3_2017() const {return btest(EM201output(), 2);}
83  int BJP1_2017() const {return btest(EM201output(), 6);}
84  int BJP2_2017() const {return btest(EM201output(), 7);}
85  int JP0_2017() const {return btest(EM201output(), 8);}
86  int JP1_2017() const {return btest(EM201output(), 9);}
87  int JP2_2017() const {return btest(EM201output(), 10);}
88  int EJP1_2017() const {return btest(EM201output(), 11);}
89  int EJP2_2017() const {return btest(EM201output(), 12);}
90 
91  void setHeadMaker(StMaker*) { /* dummy */ }
92 
93  void InitRun(int runNumber);
94  void Make();
95 
96  void setBemc(StBemcTriggerSimu* bemc);
97  void setEemc(StEemcTriggerSimu* eemc);
98 
99  DSMLayer_EM201_2009* get2009_DSMLayer2_Result();
100  DSMLayer_LD301_2009* get2009_DSMLayer3_Result();
101 
102  // void defineTrigger(const TriggerDefinition& trigdef);
103  void defineTrigger(TriggerDefinition& trigdef);
104 
105  void defineTrigger(int triggerIndex, const char* name, int triggerId, unsigned int onbits, unsigned int offbits, unsigned int onbits1, unsigned int onbits2, unsigned int onbits3, unsigned int offbits1, unsigned int offbits2, unsigned int offbits3);
106 
107  int overlapJetPatchTh(int i) const;
108  void getOverlapJetPatchAdc(int i, int& jp, int& adc) const;
109  int overlapJetPatchAdc(int jp) const;
110 
111 private:
112  // returns value of bit from x at position pos
113  int btest(int x, int pos) const { return x >> pos & 1; }
114 
115  // returns n bits from x starting at position pos
116  int getbits(int x, int pos, int n) const { return x >> pos & ~(~0 << n); }
117 
118  // OR x with value starting at position pos
119  void setbits(int& x, int pos, int value) const { x |= value << pos; }
120 
121  TDatime mDBTime;
122  StBemcTriggerSimu* mBemc;
123  StEemcTriggerSimu* mEemc;
124  DSMLayer_EM201_2009* mEM201;
125  DSMLayer_LD301_2009* mLD301;
126  TCU* mTcu;
127 
128  ClassDef(StEmcTriggerSimu,0);
129 };
130 
131 inline DSMLayer_EM201_2009* StEmcTriggerSimu::get2009_DSMLayer2_Result() { return mEM201; }
132 inline DSMLayer_LD301_2009* StEmcTriggerSimu::get2009_DSMLayer3_Result() { return mLD301; }
133 
134 inline int StEmcTriggerSimu::BHT() const { return getbits(EM201output(),0,4); }
135 inline int StEmcTriggerSimu::EHT() const { return getbits(EM201output(),4,2); }
136 inline int StEmcTriggerSimu::JP1() const { return btest(EM201output(),6); }
137 inline int StEmcTriggerSimu::JP2() const { return btest(EM201output(),7); }
138 inline int StEmcTriggerSimu::BJP1() const { return btest(EM201output(),8); }
139 inline int StEmcTriggerSimu::BJP2() const { return btest(EM201output(),9); }
140 inline int StEmcTriggerSimu::EJP1() const { return btest(EM201output(),10); }
141 inline int StEmcTriggerSimu::EJP2() const { return btest(EM201output(),11); }
142 inline int StEmcTriggerSimu::AJP() const { return btest(EM201output(),12); }
143 inline int StEmcTriggerSimu::BAJP() const { return btest(EM201output(),13); }
144 inline int StEmcTriggerSimu::EAJP() const { return btest(EM201output(),14); }
145 inline int StEmcTriggerSimu::JP0() const { return btest(EM201output(),15); }
146 
147 inline int StEmcTriggerSimu::BHT0() const { return btest(EM201output(),0); }
148 inline int StEmcTriggerSimu::BHT1() const { return btest(EM201output(),1); }
149 inline int StEmcTriggerSimu::BHT2() const { return btest(EM201output(),2); }
150 inline int StEmcTriggerSimu::BHT3() const { return btest(EM201output(),3); }
151 
152 inline int StEmcTriggerSimu::EHT0() const { return btest(EM201output(),4); }
153 inline int StEmcTriggerSimu::EHT1() const { return btest(EM201output(),5); }
154 
155 // 2013 change
156 inline int StEmcTriggerSimu::EEMCdijet() const { return btest(EM201output(),9); }
157 inline int StEmcTriggerSimu::JP1dijet() const { return btest(EM201output(),11); }
158 inline int StEmcTriggerSimu::JP0dijet() const { return btest(EM201output(),12); }
159 inline int StEmcTriggerSimu::DAQ10k() const { return btest(EM201output(),14); }
160 
161 #endif // ST_EMC_TRIGGER_SIMU_H
Definition: TCU.hh:18