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