StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerData2019.h
1 /***************************************************************************
2  *
3  * $Id: StTriggerData2019.h,v 2.2 2019/06/25 15:50:16 ullrich Exp $
4  *
5  * Author: Akio Ogawa, October 13, 2017
6  ***************************************************************************
7  *
8  * Description: Concrete implementation of StTriggerData for 2019.
9  *
10  ***************************************************************************
11  *
12  * $Log: StTriggerData2019.h,v $
13  * Revision 2.2 2019/06/25 15:50:16 ullrich
14  * Improved QT board error reports/handling. Added EPD access functions. (Akio)
15  *
16  * Revision 2.1 2019/01/07 15:49:06 ullrich
17  * Initial Revision.
18  *
19  *
20  **************************************************************************/
21 #ifndef StTriggerData2019_hh
22 #define StTriggerData2019_hh
23 
24 #include "StTriggerData.h"
25 #include "StDaqLib/TRG/trgStructures2019.h"
26 
28 
29 public:
31  StTriggerData2019(const TriggerDataBlk2019* data, int run);
32  StTriggerData2019(const TriggerDataBlk2019* data, int run, int bs, int dbg=0);
34 
35  void readData() {readData(0,0);}
36  void readData(const TriggerDataBlk2019* data, int bs);
37  void dump() const; //dump data into text
38  void blindRunInfo();
39 
40  // Versison and data type information
41  unsigned int version() const;
42  unsigned int numberOfPreXing() const;
43  unsigned int numberOfPostXing() const;
44 
45  // Generic trigger informations
46  unsigned int eventNumber() const;
47  unsigned int token() const;
48  unsigned int triggerWord() const;
49  unsigned int actionWord() const;
50  unsigned short busyStatus() const;
51  unsigned short dsmInput() const;
52  unsigned short trgToken() const;
53  unsigned short dsmAddress() const;
54  unsigned short mAddBits() const;
55  unsigned short bcData(int channel) const;
56 
57  unsigned short getTrgDetMask() const;
58  unsigned int getTrgCrateMask() const;
59 
60  // L2 offsets
61  int L2ResultsOffset(StL2AlgorithmId id) const;
62  bool isL2Triggered(StL2TriggerResultType id) const;
63  unsigned long long l2sum() const;
64 
65  // Bunch and spin bits
66  unsigned int tcuCounter() const;
67  unsigned int rccCounter(int crate) const;
68  unsigned long long bunchCounter() const;
69  unsigned int bunchCounterHigh() const;
70  unsigned int bunchCounterLow() const;
71  unsigned int bunchId48Bit() const;
72  unsigned int bunchId7Bit() const;
73  unsigned int revTick1() const;
74  unsigned int revTick2() const;
75  unsigned int revTick3() const;
76  unsigned int spinBit() const;
77  unsigned int spinBitYellowFilled() const;
78  unsigned int spinBitYellowUp() const;
79  unsigned int spinBitYellowDown() const;
80  unsigned int spinBitYellowUnpol() const;
81  unsigned int spinBitBlueFilled() const;
82  unsigned int spinBitBlueUp() const;
83  unsigned int spinBitBlueDown() const;
84  unsigned int spinBitBlueUnpol() const;
85 
86  // High Level Trigger info
87  unsigned short tcuBits() const;
88  unsigned short lastDSM(int address) const;
89  unsigned short vertexDSM(int channel) const;
90  unsigned short bemcLayer1DSM(int channel, int prepost=0) const;
91  unsigned short eemcLayer1DSM(int channel, int prepost=0) const;
92  unsigned short emcLayer2DSM(int channel) const;
93  unsigned short tpcMaskDSM(int channel) const;
94  unsigned short fpdLayer1DSMRaw(StBeamDirection eastwest, int channel, int prepost=0) const;
95  // unsigned short fpdLayer1DSM(StBeamDirection eastwest, int module, int board, int prepost=0) const;
96  unsigned short fpdLayer2DSMRaw(int channel) const;
97  // unsigned short fpdLayer2DSM(StBeamDirection eastwest, int module) const;
98 
99  // CTB
100  // unsigned short ctbRaw(int address, int prepost=0) const;
101  // unsigned short ctb(int pmt, int prepost=0) const;
102  // unsigned short ctbTraySlat(int tray, int slat, int prepost=0) const;
103  // unsigned short ctbSum(int prepost=0) const;
104 
105  // BBC
106  unsigned short bbcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
107  unsigned short bbcTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
108  unsigned short bbcTDC5bit(StBeamDirection eastwest, int pmt, int prepost=0) const;
109  unsigned short bbcADCSum(StBeamDirection eastwest, int prepost=0) const;
110  unsigned short bbcADCSumLargeTile(StBeamDirection eastwest, int prepost=0) const;
111  unsigned short bbcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
112  unsigned short bbcTimeDifference() const;
113  unsigned short bbcTacSum() const;
114  unsigned short bbcEarliestTDCLarge(StBeamDirection eastwest, int prepost=0) const;
115  unsigned short bbcTimeDifferenceLarge() const;
116  unsigned short bbcBB101(int ch, int prepost=0) const;
117  unsigned short bbcBB102(int ch, int prepost=0) const;
118 
119  // FPD
120  unsigned short fpd(StBeamDirection eastwest, int module, int pmt, int prepost=0) const;
121  unsigned short fpdSum(StBeamDirection eastwest, int module) const;
122 
123  // FMS
124  unsigned short nQTdata(int prepost=0) const;
125  unsigned int* QTdata(int prepost=0) const;
126  unsigned short fmsADC(int crt, int adr, int ch, int prepost=0) const;
127  unsigned short fmsTDC(int crt, int adr, int ch, int prepost=0) const;
128 
129  //EPD
130  unsigned short epdEarliestTDC(StBeamDirection eastwest, int prepost) const;
131  unsigned short epdTimeDifference() const;
132  bool epdHitLayer2(StBeamDirection eastwest) const;
133  unsigned short epdLayer1(int ch, int prepost=0) const;
134  unsigned short epdLayer1a(int ch, int prepost=0) const;
135  unsigned short epdLayer1b(int ch, int prepost=0) const;
136  unsigned short epdLayer0t(int ch, int prepost=0) const;
137  unsigned short epdLayer0a(int ch, int prepost=0) const;
138  unsigned char epdLayer0h(int ch, int prepost=0) const;
139  unsigned short epdADC(int crt, int adr, int ch, int prepost=0) const;
140  unsigned short epdTDC(int crt, int adr, int ch, int prepost=0) const;
141  unsigned short epdNHits(StBeamDirection eastwest, int prepost=0) const;
142  unsigned short epdNHitsQT(int crate, int qt, int mult12, int prepost=0) const;
143  unsigned short epdLayer0aMult(int ch, int prepost=0) const;
144  unsigned short epdLayer0hMult(int ch, int mult12, int prepost=0) const;
145  unsigned short epdLayer1bMult(StBeamDirection eastwest, int ring, int prepost=0) const;
146  unsigned short epdMultTotal(int prepost=0) const;
147  unsigned short epdMultDiff(int prepost=0) const;
148 
149  //ZDC
150  bool zdcPresent(int prepost=0) const;
151  unsigned short zdcAtChannel(int channel, int prepost=0) const;
152  unsigned short zdcAtAddress(int address, int prepost=0) const;
153  unsigned short zdcUnAttenuated(StBeamDirection eastwest, int prepost=0) const;
154  unsigned short zdcAttenuated(StBeamDirection eastwest, int prepost=0) const;
155  unsigned short zdcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
156  unsigned short zdcTDC(StBeamDirection eastwest, int prepost=0) const;
157  unsigned short zdcPmtTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
158  unsigned short zdcHardwareSum(int prepost=0) const;
159  //ZDC DSM L1
160  unsigned short zdcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
161  bool zdcSumADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
162  bool zdcFrontADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
163  bool zdcBackADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
164  unsigned short zdcTruncatedSum(StBeamDirection eastwest, int prepost=0) const;
165  //ZDC DSM L2
166  bool zdcSumADCaboveThresholdL2(StBeamDirection eastwest) const;
167  bool zdcFrontADCaboveThresholdL2(StBeamDirection eastwest) const;
168  bool zdcBackADCaboveThresholdL2(StBeamDirection eastwest) const;
169  unsigned short zdcTimeDifference() const;
170  //ZDC Last DSM
171  bool zdcSumADCaboveThresholdL3(StBeamDirection eastwest) const;
172  bool zdcFrontADCaboveThresholdL3(StBeamDirection eastwest) const;
173  bool zdcBackADCaboveThresholdL3(StBeamDirection eastwest) const;
174  bool zdcTimeDifferenceInWindow() const;
175 
176  //ZDCSMD
177  bool zdcSMDPresent(int prepost=0) const;
178  unsigned short zdcSMD(StBeamDirection eastwest, int verthori, int strip, int prepost=0) const;
179  unsigned short zdcSMDHighestStrip(StBeamDirection eastwest, int verthori, int prepost=0) const;
180 
181  // EMC
182  unsigned char bemcHighTower(int patch_id, int prepost=0) const;
183  unsigned char bemcJetPatch (int patch_id, int prepost=0) const;
184  unsigned char eemcHighTower(int patch_id, int prepost=0) const;
185  unsigned char eemcJetPatch (int patch_id, int prepost=0) const;
186  unsigned char bemcHighestTowerADC(int prepost=0) const;
187  unsigned char eemcHighestTowerADC(int prepost=0) const;
188 
189  // VPD
190  unsigned short vpdADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
191  unsigned short vpdTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
192  unsigned short vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
193  unsigned short vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
194  unsigned short vpdEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
195  unsigned short vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost=0) const;
196  float vpdMeanTimeDifference(int prepost=0) const;
197  unsigned short vpdADCSum(StBeamDirection eastwest, int prepost=0) const;
198  unsigned short bbcVP101(int ch, int prepost = 0) const;
199 
200  //MXQ crate
201  unsigned short mxqAtSlotAddress(int address, int prepost=0, int slot=0) const;
202 
203  //MTD
204  unsigned short mtdQtAtCh(int qtid, int address, int prepost) const;
205  unsigned short mtdAtAddress(int address, int prepost=0) const;
206  unsigned short mtdgemAtAddress(int address, int prepost=0) const;
207  unsigned short mtd3AtAddress(int address, int prepost=0) const;
208  unsigned short mtdAdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
209  unsigned short mtdTdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
210  unsigned char mtdDsmAtCh(int ch, int prepost=0) const;
211  bool mtdDsmHit(int pmt, int prepost=0) const;
212  unsigned short mtdVpdTacDiff() const;
213  unsigned short mtd4AtAddress(int address, int prepost=0) const;
214 
215  //TOF
216  unsigned short tofAtAddress(int address, int prepost=0) const;
217  unsigned short tofTrayMultiplicity(int tray, int prepost=0) const;
218  unsigned short tofMultiplicity(int prepost=0) const;
219  unsigned short dsmTF201Ch(int ch) const;
220 
221  //PP2PP
222  unsigned short pp2ppADC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
223  unsigned short pp2ppTAC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
224  unsigned long pp2ppDSM(int prepost=0) const;
225 
226  // Experts only
227  char* getTriggerStructure();
228  TriggerDataBlk2019* getTriggerStructure2019();
229  int getRawSize() const;
230 
231  unsigned char* getDsm0_BEMCE(int prepost=0) const;
232  unsigned char* getDsm0_BEMCW(int prepost=0) const;
233  unsigned short* getDsm1_BEMC(int prepost=0) const;
234  unsigned char* getDsm0_EEMC(int prepost=0) const;
235  unsigned short* getDsm1_EEMC(int prepost=0) const;
236  unsigned short* getDsm2_EMC() const;
237 
238  unsigned short* getDsm3() const;
239  unsigned char* getDsm_FMS(int prepost=0) const;
240  //unsigned char* getDsm01_FMS(int prepost=0) const;
241  //unsigned char* getDsm02_FMS(int prepost=0) const;
242  unsigned short* getDsm1_FMS(int prepost=0) const;
243  unsigned short* getDsm2_FMS() const;
244  unsigned int l2ResultLength() const;
245  const unsigned int* l2Result() const;
246 
247  // StFmsHitMaker only!!!
248  void killFMS();
249 
250 protected:
251  TriggerDataBlk2019 *mData;
252 
253  EvtDescData2019* EvtDesc;
254  L1_DSM_Data2019* L1_DSM;
255  TrgSumData2019* TrgSum;
256  BELayerBlock2019* mBC1[11];
257  QTBlock2019* mMXQ[11];
258  MIXBlock2019* mMIX[11];
259  BWestBlock2019* mBCW[11];
260  BEastBlock2019* mBCE[11];
261  QTBlock2019* mEQ3[11];
262  BBCBlock2019* mBBC[11];
263  QTBlock2019* mBBQ[11];
264  FMSBlock2019* mFMS[11];
265  QTBlock2019* mQT1[11];
266  QTBlock2019* mQT2[11];
267  QTBlock2019* mQT3[11];
268  QTBlock2019* mQT4[11];
269  QTBlock2019* mEQ1[11];
270  QTBlock2019* mEQ2[11];
271  unsigned short mxq[11][16][32],eq3[11][16][32],bbq[11][16][32],qt1[11][16][32],qt2[11][16][32],qt3[11][16][32],qt4[11][16][32],
272  eq1[11][16][32],eq2[11][16][32];
273  unsigned char tmxq[11][16][32],teq3[11][16][32],tbbq[11][16][32],tqt1[11][16][32],tqt2[11][16][32],tqt3[11][16][32],tqt4[11][16][32],
274  teq1[11][16][32],teq2[11][16][32];
275 
276 
277  void swapOfflen(TrgOfflen2019* offlen);
278  void swapDataBlk(TriggerDataBlk2019* TrgData);
279  void swapEvtDesc(EvtDescData2019* EvtDesc);
280  void swapL1_DSM(L1_DSM_Data2019* L1_DSM);
281  void swapTrgSum(TrgSumData2019* TrgSum);
282  void swapRawDetOfflen(TrgOfflen2019* offlen);
283  void swapRawDet(DataBlock2019* data, int name, int hlength, int bs);
284 
285  ClassDef(StTriggerData2019,1)
286 };
287 
288 inline void StTriggerData2019::swapOfflen(TrgOfflen2019* offlen)
289 {
290  swapI((unsigned int*)&offlen->offset);
291  swapI((unsigned int*)&offlen->length);
292 }
293 
294 inline void StTriggerData2019::swapDataBlk(TriggerDataBlk2019 *TrgData)
295 {
296  swapI((unsigned int*)&TrgData->FormatVersion);
297  swapI((unsigned int*)&TrgData->totalTriggerLength);
298  swapI((unsigned int*)&TrgData->eventNumber);
299  swapOfflen(&TrgData->EventDesc_ofl);
300  swapOfflen(&TrgData->L1_DSM_ofl);
301  swapOfflen(&TrgData->Summary_ofl);
302  swapIn((unsigned int*)TrgData->PrePostList,10);
303 }
304 
305 inline void StTriggerData2019::swapEvtDesc(EvtDescData2019* EvtDesc)
306 {
307  swapIn((unsigned int*)&EvtDesc->length,3);
308  swapSCC((unsigned int*)&EvtDesc->actionWdDetectorBitMask);
309  swapSSn((unsigned int*)&EvtDesc->TrgToken,12);
310 }
311 
312 inline void StTriggerData2019::swapL1_DSM(L1_DSM_Data2019* L1_DSM)
313 {
314  swapI((unsigned int*)&L1_DSM->length);
315  swapSSn((unsigned int*)L1_DSM->TOF,16+8*7);
316 }
317 
318 inline void StTriggerData2019::swapTrgSum(TrgSumData2019* TrgSum)
319 {
320  swapIn((unsigned int*)&TrgSum->length,1+2+2+32+64+64);
321 }
322 
323 inline void StTriggerData2019::swapRawDetOfflen(TrgOfflen2019* offlen)
324 {
325  int i;
326  for (i=0; i<y19MAX_OFFLEN; i++) {
327  swapOfflen(&offlen[i]);
328  if (mDebug>0) printf("Offlen id=%2d offset=%d length=%d\n", i, offlen[i].offset, offlen[i].length);
329  }
330 }
331 
332 #endif