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