StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerData2012.h
1 /***************************************************************************
2  *
3  * $Id: StTriggerData2012.h,v 2.3 2012/04/30 15:19:12 ullrich Exp $
4  *
5  * Author: Akio Ogawa, Nov 2011
6  ***************************************************************************
7  *
8  * Description: Concrete implementation of StTriggerData for 2012.
9  *
10  ***************************************************************************
11  *
12  * $Log: StTriggerData2012.h,v $
13  * Revision 2.3 2012/04/30 15:19:12 ullrich
14  * Added access function for l2sum (Akio)
15  *
16  * Revision 2.2 2012/02/01 17:00:07 ullrich
17  * Fixed bug concerning seg failt when MIX DSM not in run and added new arg to MtdVpdTacDiff()
18  *
19  * Revision 2.1 2011/11/04 19:21:26 ullrich
20  * Initial Revision.
21  *
22  *
23  **************************************************************************/
24 #ifndef StTriggerData2012_hh
25 #define StTriggerData2012_hh
26 
27 #include "StTriggerData.h"
28 #include "StDaqLib/TRG/trgStructures2012.h"
29 
31 
32 public:
34  StTriggerData2012(const TriggerDataBlk2012* data, int run);
35  StTriggerData2012(const TriggerDataBlk2012* data, int run, int bs, int dbg=0);
37 
38  void readData() {readData(0,0);}
39  void readData(const TriggerDataBlk2012* data, int bs);
40  void dump() const; //dump data into text
41 
42  // Versison and data type information
43  unsigned int version() const;
44  unsigned int numberOfPreXing() const;
45  unsigned int numberOfPostXing() const;
46 
47  // Generic trigger informations
48  unsigned int eventNumber() const;
49  unsigned int token() const;
50  unsigned int triggerWord() const;
51  unsigned int actionWord() const;
52  unsigned short busyStatus() const;
53  unsigned short dsmInput() const;
54  unsigned short trgToken() const;
55  unsigned short dsmAddress() const;
56  unsigned short mAddBits() const;
57  unsigned short bcData(int channel) const;
58 
59  // L2 offsets
60  int L2ResultsOffset(StL2AlgorithmId id) const;
61  bool isL2Triggered(StL2TriggerResultType id) const;
62  unsigned long long l2sum() const;
63 
64  // Bunch and spin bits
65  unsigned int bunchCounterHigh() const;
66  unsigned int bunchCounterLow() const;
67  unsigned int bunchId48Bit() const;
68  unsigned int bunchId7Bit() const;
69  unsigned int spinBit() const;
70  unsigned int spinBitYellowFilled() const;
71  unsigned int spinBitYellowUp() const;
72  unsigned int spinBitYellowDown() const;
73  unsigned int spinBitYellowUnpol() const;
74  unsigned int spinBitBlueFilled() const;
75  unsigned int spinBitBlueUp() const;
76  unsigned int spinBitBlueDown() const;
77  unsigned int spinBitBlueUnpol() const;
78 
79  // High Level Trigger info
80  unsigned short tcuBits() const;
81  unsigned short lastDSM(int address) const;
82  unsigned short bemcLayer1DSM(int channel, int prepost=0) const;
83  unsigned short eemcLayer1DSM(int channel, int prepost=0) const;
84  unsigned short emcLayer2DSM(int channel) const;
85  unsigned short tpcMaskDSM(int channel) const;
86  unsigned short fpdLayer1DSMRaw(StBeamDirection eastwest, int channel, int prepost=0) const;
87  // unsigned short fpdLayer1DSM(StBeamDirection eastwest, int module, int board, int prepost=0) const;
88  unsigned short fpdLayer2DSMRaw(int channel) const;
89  // unsigned short fpdLayer2DSM(StBeamDirection eastwest, int module) const;
90 
91  // CTB
92  // unsigned short ctbRaw(int address, int prepost=0) const;
93  // unsigned short ctb(int pmt, int prepost=0) const;
94  // unsigned short ctbTraySlat(int tray, int slat, int prepost=0) const;
95  // unsigned short ctbSum(int prepost=0) const;
96 
97  // BBC
98  unsigned short bbcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
99  unsigned short bbcTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
100  unsigned short bbcADCSum(StBeamDirection eastwest, int prepost=0) const;
101  unsigned short bbcADCSumLargeTile(StBeamDirection eastwest, int prepost=0) const;
102  unsigned short bbcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
103  unsigned short bbcTimeDifference() const;
104  unsigned short bbcEarliestTDCLarge(StBeamDirection eastwest, int prepost=0) const;
105  unsigned short bbcTimeDifferenceLarge() const;
106 
107  // FPD
108  unsigned short fpd(StBeamDirection eastwest, int module, int pmt, int prepost=0) const;
109  unsigned short fpdSum(StBeamDirection eastwest, int module) const;
110 
111  // FMS
112  unsigned short nQTdata(int prepost=0) const;
113  unsigned int* QTdata(int prepost=0) const;
114  unsigned short fmsADC(int crt, int adr, int ch, int prepost=0) const;
115  unsigned short fmsTDC(int crt, int adr, int ch, int prepost=0) const;
116 
117  //ZDC
118  bool zdcPresent(int prepost=0) const;
119  unsigned short zdcAtChannel(int channel, int prepost=0) const;
120  unsigned short zdcAtAddress(int address, int prepost=0) const;
121  unsigned short zdcUnAttenuated(StBeamDirection eastwest, int prepost=0) const;
122  unsigned short zdcAttenuated(StBeamDirection eastwest, int prepost=0) const;
123  unsigned short zdcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
124  unsigned short zdcTDC(StBeamDirection eastwest, int prepost=0) const;
125  unsigned short zdcPmtTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
126  unsigned short zdcHardwareSum(int prepost=0) const;
127  //ZDC DSM L1
128  unsigned short zdcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
129  bool zdcSumADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
130  bool zdcFrontADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
131  bool zdcBackADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
132  unsigned short zdcTruncatedSum(StBeamDirection eastwest, int prepost=0) const;
133  //ZDC DSM L2
134  bool zdcSumADCaboveThresholdL2(StBeamDirection eastwest) const;
135  bool zdcFrontADCaboveThresholdL2(StBeamDirection eastwest) const;
136  bool zdcBackADCaboveThresholdL2(StBeamDirection eastwest) const;
137  unsigned short zdcTimeDifference() const;
138  //ZDC Last DSM
139  bool zdcSumADCaboveThresholdL3(StBeamDirection eastwest) const;
140  bool zdcFrontADCaboveThresholdL3(StBeamDirection eastwest) const;
141  bool zdcBackADCaboveThresholdL3(StBeamDirection eastwest) const;
142  bool zdcTimeDifferenceInWindow() const;
143 
144  //ZDCSMD
145  bool zdcSMDPresent(int prepost=0) const;
146  unsigned short zdcSMD(StBeamDirection eastwest, int verthori, int strip, int prepost=0) const;
147  unsigned short zdcSMDHighestStrip(StBeamDirection eastwest, int verthori, int prepost=0) const;
148 
149  // EMC
150  unsigned char bemcHighTower(int patch_id, int prepost=0) const;
151  unsigned char bemcJetPatch (int patch_id, int prepost=0) const;
152  unsigned char eemcHighTower(int patch_id, int prepost=0) const;
153  unsigned char eemcJetPatch (int patch_id, int prepost=0) const;
154  unsigned char bemcHighestTowerADC(int prepost=0) const;
155  unsigned char eemcHighestTowerADC(int prepost=0) const;
156 
157  // VPD
158  unsigned short vpdADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
159  unsigned short vpdTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
160  unsigned short vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
161  unsigned short vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
162  unsigned short vpdEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
163  unsigned short vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost=0) const;
164  unsigned short vpdTimeDifference() const;
165 
166  //MTD
167  unsigned short mtdAtAddress(int address, int prepost=0) const;
168  unsigned short mtdAdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
169  unsigned short mtdTdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
170  unsigned char mtdDsmAtCh(int ch, int prepost=0) const;
171  bool mtdDsmHit(int pmt, int prepost=0) const;
172  unsigned short mtdgemAtAddress(int address, int prepost=0) const;
173  unsigned short mtdVpdTacDiff() const;
174 
175  //TOF
176  unsigned short tofAtAddress(int address, int prepost=0) const;
177  unsigned short tofTrayMultiplicity(int tray, int prepost=0) const;
178  unsigned short tofMultiplicity(int prepost=0) const;
179 
180  //PP2PP
181  unsigned short pp2ppADC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
182  unsigned short pp2ppTAC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
183  unsigned long pp2ppDSM(int prepost=0) const;
184 
185  // Experts only
186  char* getTriggerStructure();
187  TriggerDataBlk2012* getTriggerStructure2012();
188  int getRawSize() const;
189 
190  unsigned char* getDsm0_BEMCE(int prepost=0) const;
191  unsigned char* getDsm0_BEMCW(int prepost=0) const;
192  unsigned short* getDsm1_BEMC(int prepost=0) const;
193  unsigned char* getDsm0_EEMC(int prepost=0) const;
194  unsigned short* getDsm1_EEMC(int prepost=0) const;
195  unsigned short* getDsm2_EMC() const;
196 
197  unsigned short* getDsm3() const;
198  unsigned char* getDsm_FMS(int prepost=0) const;
199  //unsigned char* getDsm01_FMS(int prepost=0) const;
200  //unsigned char* getDsm02_FMS(int prepost=0) const;
201  unsigned short* getDsm1_FMS(int prepost=0) const;
202  unsigned short* getDsm2_FMS() const;
203  unsigned int l2ResultLength() const;
204  const unsigned int* l2Result() const;
205 
206  // StFmsHitMaker only!!!
207  void killFMS();
208 
209 protected:
210  TriggerDataBlk2012 *mData;
211 
212  EvtDescData2012* EvtDesc;
213  L1_DSM_Data2012* L1_DSM;
214  TrgSumData2012* TrgSum;
215  BELayerBlock2012* mBC1[11];
216  QTBlock2012* mMXQ[11];
217  MIXBlock2012* mMIX[11];
218  BWestBlock2012* mBCW[11];
219  BEastBlock2012* mBCE[11];
220  QTBlock2012* mFEQ[11];
221  BBCBlock2012* mBBC[11];
222  QTBlock2012* mBBQ[11];
223  FMSBlock2012* mFMS[11];
224  QTBlock2012* mQT1[11];
225  QTBlock2012* mQT2[11];
226  QTBlock2012* mQT3[11];
227  QTBlock2012* mQT4[11];
228  unsigned short mxq[11][16][32],feq[11][16][32],bbq[11][16][32],qt1[11][16][32],qt2[11][16][32],qt3[11][16][32],qt4[11][16][32];
229  unsigned char tmxq[11][16][32],tfeq[11][16][32],tbbq[11][16][32],tqt1[11][16][32],tqt2[11][16][32],tqt3[11][16][32],tqt4[11][16][32];
230 
231  void swapOfflen(TrgOfflen2012* offlen);
232  void swapDataBlk(TriggerDataBlk2012* TrgData);
233  void swapEvtDesc(EvtDescData2012* EvtDesc);
234  void swapL1_DSM(L1_DSM_Data2012* L1_DSM);
235  void swapTrgSum(TrgSumData2012* TrgSum);
236  void swapRawDetOfflen(TrgOfflen2012* offlen);
237  void swapRawDet(DataBlock2012* data, int name, int hlength, int bs);
238 
239  ClassDef(StTriggerData2012,1)
240 };
241 
242 inline void StTriggerData2012::swapOfflen(TrgOfflen2012* offlen)
243 {
244  swapI((unsigned int*)&offlen->offset);
245  swapI((unsigned int*)&offlen->length);
246 }
247 
248 inline void StTriggerData2012::swapDataBlk(TriggerDataBlk2012 *TrgData)
249 {
250  swapI((unsigned int*)&TrgData->FormatVersion);
251  swapI((unsigned int*)&TrgData->totalTriggerLength);
252  swapI((unsigned int*)&TrgData->eventNumber);
253  swapOfflen(&TrgData->EventDesc_ofl);
254  swapOfflen(&TrgData->L1_DSM_ofl);
255  swapOfflen(&TrgData->Summary_ofl);
256  swapIn((unsigned int*)TrgData->PrePostList,10);
257 }
258 
259 inline void StTriggerData2012::swapEvtDesc(EvtDescData2012* EvtDesc)
260 {
261  swapIn((unsigned int*)&EvtDesc->length,3);
262  swapSCC((unsigned int*)&EvtDesc->actionWdDetectorBitMask);
263  swapSSn((unsigned int*)&EvtDesc->TrgToken,12);
264 }
265 
266 inline void StTriggerData2012::swapL1_DSM(L1_DSM_Data2012* L1_DSM)
267 {
268  swapI((unsigned int*)&L1_DSM->length);
269  swapSSn((unsigned int*)L1_DSM->TOF,16+8*7);
270 }
271 
272 inline void StTriggerData2012::swapTrgSum(TrgSumData2012* TrgSum)
273 {
274  swapIn((unsigned int*)&TrgSum->length,1+2+2+32+64+64);
275 }
276 
277 inline void StTriggerData2012::swapRawDetOfflen(TrgOfflen2012* offlen)
278 {
279  int i;
280  for (i=0; i<y12MAX_OFFLEN; i++) {
281  swapOfflen(&offlen[i]);
282  if (mDebug>0) printf("Offlen id=%2d offset=%d length=%d\n", i, offlen[i].offset, offlen[i].length);
283  }
284 }
285 
286 #endif