StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerData2009.h
1  /***************************************************************************
2  *
3  * $Id: StTriggerData2009.h,v 2.19 2012/04/30 15:19:11 ullrich Exp $
4  *
5  * Author: Akio Ogawa, Jan 2009
6  ***************************************************************************
7  *
8  * Description: Concrete implementation of StTriggerData for 2009.
9  *
10  ***************************************************************************
11  *
12  * $Log: StTriggerData2009.h,v $
13  * Revision 2.19 2012/04/30 15:19:11 ullrich
14  * Added access function for l2sum (Akio)
15  *
16  * Revision 2.18 2011/02/15 18:56:09 ullrich
17  * New access fct for ZDCSMD, new ZDCSMD map, spinBit() modified.
18  *
19  * Revision 2.17 2011/01/18 23:06:07 ullrich
20  * New function mtdgemAtAddress added. vpdADC, vpdTDC, vpdADCHighThr, vpdTDCHighThr, vpdEarliestTDC, and vpdEarliestTDCHighThr updated.
21  *
22  * Revision 2.16 2010/06/01 22:27:30 ullrich
23  * Reduce print-out for case when muDst is read.
24  *
25  * Revision 2.15 2010/04/07 14:43:00 ullrich
26  * Added streamer and added new access function for BBC large tile earliest TAC and difference
27  *
28  * Revision 2.14 2010/01/13 17:55:47 ullrich
29  * Better mErrorFlags, abort, and debug flag handling, updated MTD DSM access function for run10, clean up compiler warning messages.
30  *
31  * Revision 2.13 2010/01/08 22:44:37 ullrich
32  * Updates needed to add StFmsCollection and related classes.
33  *
34  * Revision 2.12 2009/08/24 22:39:13 ullrich
35  * Flag corruption in new member mErrorFlag.
36  *
37  * Revision 2.11 2009/08/14 15:06:10 ullrich
38  * Added checks of trigger data banks.
39  *
40  * Revision 2.10 2009/06/16 15:44:26 ullrich
41  * Added fmsADC() method.
42  *
43  * Revision 2.9 2009/05/15 18:16:15 ullrich
44  * Updates for pp2pp and ToF.
45  *
46  * Revision 2.8 2009/05/05 20:53:16 ullrich
47  * Updates for MTD.
48  *
49  * Revision 2.7 2009/03/19 02:46:01 ullrich
50  * Add 2nd argument (pre/post) to vpdEarliestTDC().
51  *
52  * Revision 2.6 2009/03/04 02:01:30 ullrich
53  * New access functions for ZDC DSM layer-1 and layer-2 data.
54  *
55  * Revision 2.5 2009/02/23 22:31:09 ullrich
56  * Fixed problem when running over 2009 data (solution by Pibero) and new VPD access functions.
57  *
58  * Revision 2.4 2009/02/13 23:04:50 ullrich
59  * Updates necessary for use in Online QA (P) plots.
60  *
61  * Revision 2.3 2009/02/11 23:33:55 jeromel
62  * Modifications by Akio to support getDsm0_BEMCE and getDsm0_BEMCW as well as
63  * getDsm1_BEMC. However, use of const=0 impose implementation (was not done
64  * in years < 2009). Added methods with return 0.
65  *
66  * Revision 2.2 2009/01/20 18:10:15 ullrich
67  * Bug fix and new ZDC access functions.
68  *
69  * Revision 2.1 2009/01/14 17:56:14 ullrich
70  * Initial Revision.
71  *
72  *
73  **************************************************************************/
74 #ifndef StTriggerData2009_hh
75 #define StTriggerData2009_hh
76 
77 #include "StTriggerData.h"
78 #include "StDaqLib/TRG/trgStructures2009.h"
79 
81 public:
83  StTriggerData2009(const TriggerDataBlk2009* data, int run);
84  StTriggerData2009(const TriggerDataBlk2009* data, int run, int bs, int dbg=0);
86 
87  void readData() {readData(0,0);}
88  void readData(const TriggerDataBlk2009* data, int bs);
89  void dump() const; //dump data into text
90 
91  // Versison and data type information
92  unsigned int version() const;
93  unsigned int numberOfPreXing() const;
94  unsigned int numberOfPostXing() const;
95 
96  // Generic trigger informations
97  unsigned int eventNumber() const;
98  unsigned int token() const;
99  unsigned int triggerWord() const;
100  unsigned int actionWord() const;
101  unsigned short busyStatus() const;
102  unsigned short dsmInput() const;
103  unsigned short trgToken() const;
104  unsigned short dsmAddress() const;
105  unsigned short mAddBits() const;
106  unsigned short bcData(int channel) const;
107 
108  // L2 offsets
109  int L2ResultsOffset(StL2AlgorithmId id) const;
110  bool isL2Triggered(StL2TriggerResultType id) const;
111  unsigned long long l2sum() const;
112 
113  // Bunch and spin bits
114  unsigned int bunchCounterHigh() const;
115  unsigned int bunchCounterLow() const;
116  unsigned int bunchId48Bit() const;
117  unsigned int bunchId7Bit() const;
118  unsigned int spinBit() const;
119  unsigned int spinBitYellowFilled() const;
120  unsigned int spinBitYellowUp() const;
121  unsigned int spinBitYellowDown() const;
122  unsigned int spinBitYellowUnpol() const;
123  unsigned int spinBitBlueFilled() const;
124  unsigned int spinBitBlueUp() const;
125  unsigned int spinBitBlueDown() const;
126  unsigned int spinBitBlueUnpol() const;
127 
128  // High Level Trigger info
129  unsigned short tcuBits() const;
130  unsigned short lastDSM(int address) const;
131  unsigned short bemcLayer1DSM(int channel, int prepost=0) const;
132  unsigned short eemcLayer1DSM(int channel, int prepost=0) const;
133  unsigned short emcLayer2DSM(int channel) const;
134  unsigned short fpdLayer1DSMRaw(StBeamDirection eastwest, int channel, int prepost=0) const;
135  // unsigned short fpdLayer1DSM(StBeamDirection eastwest, int module, int board, int prepost=0) const;
136  unsigned short fpdLayer2DSMRaw(int channel) const;
137  // unsigned short fpdLayer2DSM(StBeamDirection eastwest, int module) const;
138 
139  // CTB
140  // unsigned short ctbRaw(int address, int prepost=0) const;
141  // unsigned short ctb(int pmt, int prepost=0) const;
142  // unsigned short ctbTraySlat(int tray, int slat, int prepost=0) const;
143  // unsigned short ctbSum(int prepost=0) const;
144 
145  // BBC
146  unsigned short bbcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
147  unsigned short bbcTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
148  unsigned short bbcADCSum(StBeamDirection eastwest, int prepost=0) const;
149  unsigned short bbcADCSumLargeTile(StBeamDirection eastwest, int prepost=0) const;
150  unsigned short bbcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
151  unsigned short bbcTimeDifference() const;
152  unsigned short bbcEarliestTDCLarge(StBeamDirection eastwest, int prepost=0) const;
153  unsigned short bbcTimeDifferenceLarge() const;
154 
155  // FPD
156  unsigned short fpd(StBeamDirection eastwest, int module, int pmt, int prepost=0) const;
157  unsigned short fpdSum(StBeamDirection eastwest, int module) const;
158 
159  // FMS
160  unsigned short nQTdata(int prepost=0) const;
161  unsigned int* QTdata(int prepost=0) const;
162  unsigned short fmsADC(int crt, int adr, int ch, int prepost=0) const;
163  unsigned short fmsTDC(int crt, int adr, int ch, int prepost=0) const;
164 
165  //ZDC
166  bool zdcPresent(int prepost=0) const;
167  unsigned short zdcAtChannel(int channel, int prepost=0) const;
168  unsigned short zdcAtAddress(int address, int prepost=0) const;
169  unsigned short zdcUnAttenuated(StBeamDirection eastwest, int prepost=0) const;
170  unsigned short zdcAttenuated(StBeamDirection eastwest, int prepost=0) const;
171  unsigned short zdcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
172  unsigned short zdcTDC(StBeamDirection eastwest, int prepost=0) const;
173  unsigned short zdcPmtTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
174  unsigned short zdcHardwareSum(int prepost=0) const;
175  //ZDC DSM L1
176  unsigned short zdcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
177  bool zdcSumADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
178  bool zdcFrontADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
179  bool zdcBackADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
180  unsigned short zdcTruncatedSum(StBeamDirection eastwest, int prepost=0) const;
181  //ZDC DSM L2
182  bool zdcSumADCaboveThresholdL2(StBeamDirection eastwest) const;
183  bool zdcFrontADCaboveThresholdL2(StBeamDirection eastwest) const;
184  bool zdcBackADCaboveThresholdL2(StBeamDirection eastwest) const;
185  unsigned short zdcTimeDifference() const;
186  //ZDC Last DSM
187  bool zdcSumADCaboveThresholdL3(StBeamDirection eastwest) const;
188  bool zdcFrontADCaboveThresholdL3(StBeamDirection eastwest) const;
189  bool zdcBackADCaboveThresholdL3(StBeamDirection eastwest) const;
190  bool zdcTimeDifferenceInWindow() const;
191 
192  //ZDCSMD
193  bool zdcSMDPresent(int prepost=0) const;
194  unsigned short zdcSMD(StBeamDirection eastwest, int verthori, int strip, int prepost=0) const;
195  unsigned short zdcSMDHighestStrip(StBeamDirection eastwest, int verthori, int prepost=0) const;
196 
197  // EMC
198  unsigned char bemcHighTower(int patch_id, int prepost=0) const;
199  unsigned char bemcJetPatch (int patch_id, int prepost=0) const;
200  unsigned char eemcHighTower(int patch_id, int prepost=0) const;
201  unsigned char eemcJetPatch (int patch_id, int prepost=0) const;
202  unsigned char bemcHighestTowerADC(int prepost=0) const;
203  unsigned char eemcHighestTowerADC(int prepost=0) const;
204 
205  // VPD
206  unsigned short vpdADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
207  unsigned short vpdTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
208  unsigned short vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
209  unsigned short vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
210  unsigned short vpdEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
211  unsigned short vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost=0) const;
212  unsigned short vpdTimeDifference() const;
213 
214  //MTD
215  unsigned short mtdAtAddress(int address, int prepost=0) const;
216  unsigned short mtdAdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
217  unsigned short mtdTdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
218  unsigned char mtdDsmAtCh(int ch, int prepost=0) const;
219  bool mtdDsmHit(int pmt, int prepost=0) const;
220  unsigned short mtdgemAtAddress(int address, int prepost=0) const;
221 
222  //TOF
223  unsigned short tofAtAddress(int address, int prepost=0) const;
224  unsigned short tofTrayMultiplicity(int tray, int prepost=0) const;
225  unsigned short tofMultiplicity(int prepost=0) const;
226 
227  //PP2PP
228  unsigned short pp2ppADC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
229  unsigned short pp2ppTAC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
230  unsigned long pp2ppDSM(int prepost=0) const;
231 
232  // Experts only
233  char* getTriggerStructure();
234  TriggerDataBlk2009* getTriggerStructure2009();
235  int getRawSize() const;
236 
237  unsigned char* getDsm0_BEMCE(int prepost=0) const;
238  unsigned char* getDsm0_BEMCW(int prepost=0) const;
239  unsigned short* getDsm1_BEMC(int prepost=0) const;
240  unsigned char* getDsm0_EEMC(int prepost=0) const;
241  unsigned short* getDsm1_EEMC(int prepost=0) const;
242  unsigned short* getDsm2_EMC() const;
243 
244  unsigned short* getDsm3() const;
245  unsigned char* getDsm_FMS(int prepost=0) const;
246  //unsigned char* getDsm01_FMS(int prepost=0) const;
247  //unsigned char* getDsm02_FMS(int prepost=0) const;
248  unsigned short* getDsm1_FMS(int prepost=0) const;
249  unsigned short* getDsm2_FMS() const;
250  unsigned int l2ResultLength() const;
251  const unsigned int* l2Result() const;
252 
253  // StFmsHitMaker only!!!
254  void killFMS();
255 
256 protected:
257  TriggerDataBlk2009 *mData;
258 
259  EvtDescData2009* EvtDesc;
260  L1_DSM_Data2009* L1_DSM;
261  TrgSumData2009* TrgSum;
262  BELayerBlock2009* mBC1[11];
263  QTBlock2009* mMXQ[11];
264  MIXBlock2009* mMIX[11];
265  BWestBlock2009* mBCW[11];
266  BEastBlock2009* mBCE[11];
267  QTBlock2009* mFEQ[11];
268  BBCBlock2009* mBBC[11];
269  QTBlock2009* mBBQ[11];
270  FMSBlock2009* mFMS[11];
271  QTBlock2009* mQT1[11];
272  QTBlock2009* mQT2[11];
273  QTBlock2009* mQT3[11];
274  QTBlock2009* mQT4[11];
275  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];
276  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];
277 
278  void swapOfflen(TrgOfflen2009* offlen);
279  void swapDataBlk(TriggerDataBlk2009* TrgData);
280  void swapEvtDesc(EvtDescData2009* EvtDesc);
281  void swapL1_DSM(L1_DSM_Data2009* L1_DSM);
282  void swapTrgSum(TrgSumData2009* TrgSum);
283  void swapRawDetOfflen(TrgOfflen2009* offlen);
284  void swapRawDet(DataBlock2009* data, int name, int hlength, int bs);
285 
286  ClassDef(StTriggerData2009,1)
287 };
288 
289 inline void StTriggerData2009::swapOfflen(TrgOfflen2009* offlen)
290 {
291  swapI((unsigned int*)&offlen->offset);
292  swapI((unsigned int*)&offlen->length);
293 }
294 
295 inline void StTriggerData2009::swapDataBlk(TriggerDataBlk2009 *TrgData)
296 {
297  swapI((unsigned int*)&TrgData->FormatVersion);
298  swapI((unsigned int*)&TrgData->totalTriggerLength);
299  swapI((unsigned int*)&TrgData->eventNumber);
300  swapOfflen(&TrgData->EventDesc_ofl);
301  swapOfflen(&TrgData->L1_DSM_ofl);
302  swapOfflen(&TrgData->Summary_ofl);
303  swapIn((unsigned int*)TrgData->PrePostList,10);
304 }
305 
306 inline void StTriggerData2009::swapEvtDesc(EvtDescData2009* EvtDesc)
307 {
308  swapIn((unsigned int*)&EvtDesc->length,3);
309  swapSCC((unsigned int*)&EvtDesc->actionWdDetectorBitMask);
310  swapSSn((unsigned int*)&EvtDesc->TrgToken,12);
311 }
312 
313 inline void StTriggerData2009::swapL1_DSM(L1_DSM_Data2009* L1_DSM)
314 {
315  swapI((unsigned int*)&L1_DSM->length);
316  swapSSn((unsigned int*)L1_DSM->TOF,16+8*6);
317 }
318 
319 inline void StTriggerData2009::swapTrgSum(TrgSumData2009* TrgSum)
320 {
321  swapIn((unsigned int*)&TrgSum->length,1+2+2+32+64+64);
322 }
323 
324 inline void StTriggerData2009::swapRawDetOfflen(TrgOfflen2009* offlen)
325 {
326  int i;
327  for (i=0; i<y9MAX_OFFLEN; i++) {
328  swapOfflen(&offlen[i]);
329  if (mDebug>0) printf("Offlen id=%2d offset=%d length=%d\n", i, offlen[i].offset, offlen[i].length);
330  }
331 }
332 
333 inline void StTriggerData2009::swapRawDet(DataBlock2009* data, int name, int hlength,int bs)
334 {
335  BELayerBlock2009* bc1;
336  MIXBlock2009* mix;
337  BBCBlock2009 *bbc;
338  QTBlock2009* qtdata;
339  int header_length = 8;
340  if(bs) swapI((unsigned int*)&data->length);
341  switch(name){
342  case y9MXQ_CONF_NUM : case y9FEQ_CONF_NUM : case y9BBQ_CONF_NUM :
343  case y9QT1_CONF_NUM : case y9QT2_CONF_NUM : case y9QT3_CONF_NUM : case y9QT4_CONF_NUM :
344  header_length = 12; break;
345  }
346  if (hlength != data->length + header_length){
347  mErrorFlag = mErrorFlag | (1 << name);
348  printf("StTriggerData2009: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
349  name,data->name[0],data->name[1],data->name[2],data->name[3],
350  hlength,data->length,header_length);
351  printf("StTriggerData2009: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
352  name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
353  data=0;
354  return;
355  }
356  if (bs){
357  switch(name){
358  case y9BC1_CONF_NUM :
359  bc1 = (BELayerBlock2009*) data;
360  swapSSn((unsigned int*)bc1->BEMClayer1,48);
361  swapSSn((unsigned int*)bc1->EEMClayer1,16);
362  break;
363  case y9MIX_CONF_NUM :
364  mix = (MIXBlock2009*) data;
365  swapSSn((unsigned int*)mix->FPDEastNSLayer1,8);
366  swapSSn((unsigned int*)mix->TOFLayer1,8+48);
367  break;
368  case y9BCW_CONF_NUM :
369  //only char
370  break;
371  case y9BCE_CONF_NUM :
372  //only char
373  break;
374  case y9BBC_CONF_NUM :
375  bbc = (BBCBlock2009*) data;
376  swapSSn((unsigned int*)bbc->BBClayer1,16+8+8);
377  break;
378  case y9FMS_CONF_NUM :
379  //only char
380  break;
381  case y9MXQ_CONF_NUM :
382  case y9FEQ_CONF_NUM :
383  case y9BBQ_CONF_NUM :
384  case y9QT1_CONF_NUM :
385  case y9QT2_CONF_NUM :
386  case y9QT3_CONF_NUM :
387  case y9QT4_CONF_NUM :
388  qtdata = (QTBlock2009*) data;
389  swapI((unsigned int*)&qtdata->dataLoss);
390  swapIn(qtdata->data, qtdata->length/4);
391  break;
392  }
393  }
394  if(mDebug>0)
395  printf("Read id=%2d name=%1c%1c%1c%1c length=%d\n",
396  name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
397 }
398 
399 #endif