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