StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerData2017.cxx
1 /***************************************************************************
2  *
3  * $Id: StTriggerData2017.cxx,v 2.6 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.cxx,v $
13  * Revision 2.6 2017/10/13 20:14:26 ullrich
14  * Added access fct epdADC() and epdTDC().
15  *
16  * Revision 2.5 2017/05/30 15:59:14 ullrich
17  * Added bbcTDC5bit() method.
18  *
19  * Revision 2.4 2017/05/13 00:59:54 ullrich
20  * Added bbcBB101() and bbcBB102().
21  *
22  * Revision 2.3 2017/02/20 16:33:37 ullrich
23  * Changed mtdQtAtCh for run17 mapping
24  *
25  * Revision 2.2 2016/12/15 16:30:07 ullrich
26  * Updates from Jeff.
27  *
28  * Revision 2.1 2016/12/08 18:58:28 ullrich
29  * Initial Revision.
30  *
31  *
32  **************************************************************************/
33 #include <string.h>
34 #include <assert.h>
35 #include <iostream>
36 #include "StTriggerData2017.h"
37 
38 ClassImp(StTriggerData2017)
39 
41 {
42  mDebug = 0;
43  // printf("StTriggerData2017 Default Constructor\n");
44 }
45 
46 StTriggerData2017::StTriggerData2017(const TriggerDataBlk2017* data, int run):mData()
47 {
48  //printf("StTriggerData2017 Constructor with trigger data block\n");
49  mYear=2017; mRun = run; mDebug = 0;
50  mData = new TriggerDataBlk2017;
51  readData(data,1);
52 }
53 
54 StTriggerData2017::StTriggerData2017(const TriggerDataBlk2017* data, int run, int bs, int dbg):mData()
55 {
56  mYear=2017; mRun = run; mDebug = dbg;
57  if(mDebug==1) printf("StTriggerData2017 Constructor with trigger data block and byteswap option=%d\n",bs);
58  mData = new TriggerDataBlk2017;
59  readData(data,bs);
60 }
61 
62 void StTriggerData2017::readData(const TriggerDataBlk2017* data, int bs) {
63  int copyflag=1;
64  if (data==0) {copyflag=0;}
65  if(mDebug==1) printf("StTriggerData2017::readData copyflag=%d byteswap=%d data=%p mData=%p\n",copyflag,bs,data,mData);
66 
67  if (copyflag==1){
68  unsigned int ver = data->FormatVersion;
69  if (bs) swapI(&ver);
70 
71  if (ver == y17FORMAT_VERSION ) {
72  if (mDebug==1) printf("StTriggerData2017: version = 0x%x (0x%x or 0x08121140)\n",ver,y17FORMAT_VERSION);
73  }
74  else {
75  mErrorFlag = mErrorFlag | 0x1;
76  printf("StTriggerData2017: version = 0x%x != (0x%x)\n",ver,y17FORMAT_VERSION);
77  assert(0);
78  }
79 
80  unsigned int size = data->totalTriggerLength;
81  if (bs) swapI(&size);
82  if (size > y17MAX_TRG_BLK_SIZE) {
83  gMessMgr->Warning() << "StTriggerData2017: Data length = " << size
84  << " is bigger than max = " << y17MAX_TRG_BLK_SIZE
85  << endm;
86  assert(0);
87  }
88  if (mDebug==1) printf("StTriggerData2017: size = %d, maxsize = %d\n",size,y17MAX_TRG_BLK_SIZE);
89  memcpy(mData,data,size);
90  memset((char*)mData+size,0,sizeof(TriggerDataBlk2017)-size);
91  }
92 
93  if (bs) swapDataBlk(mData);
94  if (mDebug==1){
95  printf("StTriggerData2017: version = 0x%x (0x%x)\n",mData->FormatVersion,y17FORMAT_VERSION);
96  printf("StTriggerData2017: size = %d, maxsize = %d\n",mData->totalTriggerLength,y17MAX_TRG_BLK_SIZE);
97  printf("EventDesc length=%10d offset=%10d\n",mData->EventDesc_ofl.length,mData->EventDesc_ofl.offset);
98  printf("L1_DSM length=%10d offset=%10d\n",mData->L1_DSM_ofl.length,mData->L1_DSM_ofl.offset);
99  printf("Summary length=%10d offset=%10d\n",mData->Summary_ofl.length,mData->Summary_ofl.offset);
100  }
101 
102  EvtDesc=0; L1_DSM=0; TrgSum=0;
103  if (mData->EventDesc_ofl.length > 0) EvtDesc = (EvtDescData2017*)((char*)mData + mData->EventDesc_ofl.offset);
104  if (mData->L1_DSM_ofl.length > 0) L1_DSM = (L1_DSM_Data2017*)((char*)mData + mData->L1_DSM_ofl.offset);
105  if (mData->Summary_ofl.length > 0) TrgSum = (TrgSumData2017* )((char*)mData + mData->Summary_ofl.offset);
106  if (bs){
107  if (EvtDesc) swapEvtDesc(EvtDesc);
108  if (L1_DSM) swapL1_DSM(L1_DSM);
109  if (TrgSum) swapTrgSum(TrgSum);
110  }
111  if (EvtDesc==0 || L1_DSM==0 || TrgSum==0){
112  mErrorFlag = mErrorFlag | 0x1;
113  gMessMgr->Warning() << "StTriggerData2017: EvtDesc, L1_DSM or TrgSum is missing"
114  <<" mErrorFlag="<<mErrorFlag<<endm;
115  }
116 
117  int npre = numberOfPreXing();
118  int npost = numberOfPostXing();
119  if (npre<0 || npre>10 || npost<0 || npost>10){
120  mErrorFlag = mErrorFlag | 0x2;
121  gMessMgr->Warning() << "StTriggerData2017: Invalid npre/post = "<< npre << " / " << npost
122  <<" mErrorFlag="<<mErrorFlag<<endm;
123  }
124  if (mDebug==1) printf("StTriggerData2017: pre=%d post=%d\n",npre,npost);
125 
126  memset(mBC1,0,sizeof(mBC1));
127  memset(mMXQ,0,sizeof(mMXQ));
128  memset(mMIX,0,sizeof(mMIX));
129  memset(mBCW,0,sizeof(mBCW));
130  memset(mBCE,0,sizeof(mBCE));
131  memset(mEPQ,0,sizeof(mEPQ));
132  memset(mBBC,0,sizeof(mBBC));
133  memset(mBBQ,0,sizeof(mBBQ));
134  memset(mFMS,0,sizeof(mFMS));
135  memset(mQT1,0,sizeof(mQT1));
136  memset(mQT2,0,sizeof(mQT2));
137  memset(mQT3,0,sizeof(mQT3));
138  memset(mQT4,0,sizeof(mQT4));
139  memset(mFQ1,0,sizeof(mFQ1));
140  memset(mFQ2,0,sizeof(mFQ2));
141  memset(mxq,0,sizeof(mxq)); memset(tmxq,0,sizeof(tmxq));
142  memset(epq,0,sizeof(epq)); memset(tepq,0,sizeof(tepq));
143  memset(bbq,0,sizeof(bbq)); memset(tbbq,0,sizeof(tbbq));
144  memset(qt1,0,sizeof(qt1)); memset(tqt1,0,sizeof(tqt1));
145  memset(qt2,0,sizeof(qt2)); memset(tqt2,0,sizeof(tqt2));
146  memset(qt3,0,sizeof(qt3)); memset(tqt3,0,sizeof(tqt3));
147  memset(qt4,0,sizeof(qt4)); memset(tqt4,0,sizeof(tqt4));
148  memset(fq1,0,sizeof(fq1)); memset(tfq1,0,sizeof(tfq1));
149  memset(fq2,0,sizeof(fq2)); memset(tfq2,0,sizeof(tfq2));
151 
152  for (int i=0; i<1+npre+npost; i++){
153  //printf("Doing prepost = %d\n",i);
154  if (i==0) {
155  offlen = mData->MainX;
156  }
157  else {
158  //printf("Prepost list offset = %d\n",mData->PrePostList[i-1]);
159  if (mData->PrePostList[i-1]==0) continue;
160  offlen = (TrgOfflen2017*) ((char*)mData + mData->PrePostList[i-1]);
161  }
162  if (bs) swapRawDetOfflen(offlen);
163  for(int k=0; k<y17MAX_OFFLEN; k++){
164  if(static_cast<unsigned int>(offlen[k].length + offlen[k].offset) > static_cast<unsigned int>(mData->totalTriggerLength)) {
165  mErrorFlag = mErrorFlag | (1 << k);
166  gMessMgr->Warning() << "StTriggerData2017: offset ("<<offlen[k].offset<<") + length ("<<offlen[k].length
167  <<") exceeds total size("<<mData->totalTriggerLength<<") for data block id="<<k
168  <<" mErrorFlag="<<mErrorFlag<<endm;
169  }
170  }
171  int j;
172  j=offlen[y17BC1_CONF_NUM].length; if (j>0){mBC1[i] = (BELayerBlock2017*)((char*)mData + offlen[y17BC1_CONF_NUM].offset); swapRawDet((DataBlock2017*)mBC1[i],y17BC1_CONF_NUM,j,bs);}
173  j=offlen[y17MXQ_CONF_NUM].length; if (j>0){mMXQ[i] = (QTBlock2017* )((char*)mData + offlen[y17MXQ_CONF_NUM].offset); swapRawDet((DataBlock2017*)mMXQ[i],y17MXQ_CONF_NUM,j,bs);}
174  j=offlen[y17MIX_CONF_NUM].length; if (j>0){mMIX[i] = (MIXBlock2017* )((char*)mData + offlen[y17MIX_CONF_NUM].offset); swapRawDet((DataBlock2017*)mMIX[i],y17MIX_CONF_NUM,j,bs);}
175  j=offlen[y17BCW_CONF_NUM].length; if (j>0){mBCW[i] = (BWestBlock2017* )((char*)mData + offlen[y17BCW_CONF_NUM].offset); swapRawDet((DataBlock2017*)mBCW[i],y17BCW_CONF_NUM,j,bs);}
176  j=offlen[y17BCE_CONF_NUM].length; if (j>0){mBCE[i] = (BEastBlock2017* )((char*)mData + offlen[y17BCE_CONF_NUM].offset); swapRawDet((DataBlock2017*)mBCE[i],y17BCE_CONF_NUM,j,bs);}
177  j=offlen[y17EPQ_CONF_NUM].length; if (j>0){mEPQ[i] = (QTBlock2017* )((char*)mData + offlen[y17EPQ_CONF_NUM].offset); swapRawDet((DataBlock2017*)mEPQ[i],y17EPQ_CONF_NUM,j,bs);}
178  j=offlen[y17BBC_CONF_NUM].length; if (j>0){mBBC[i] = (BBCBlock2017* )((char*)mData + offlen[y17BBC_CONF_NUM].offset); swapRawDet((DataBlock2017*)mBBC[i],y17BBC_CONF_NUM,j,bs);}
179  j=offlen[y17BBQ_CONF_NUM].length; if (j>0){mBBQ[i] = (QTBlock2017* )((char*)mData + offlen[y17BBQ_CONF_NUM].offset); swapRawDet((DataBlock2017*)mBBQ[i],y17BBQ_CONF_NUM,j,bs);}
180  j=offlen[y17FMS_CONF_NUM].length; if (j>0){mFMS[i] = (FMSBlock2017* )((char*)mData + offlen[y17FMS_CONF_NUM].offset); swapRawDet((DataBlock2017*)mFMS[i],y17FMS_CONF_NUM,j,bs);}
181  j=offlen[y17QT1_CONF_NUM].length; if (j>0){mQT1[i] = (QTBlock2017* )((char*)mData + offlen[y17QT1_CONF_NUM].offset); swapRawDet((DataBlock2017*)mQT1[i],y17QT1_CONF_NUM,j,bs);}
182  j=offlen[y17QT2_CONF_NUM].length; if (j>0){mQT2[i] = (QTBlock2017* )((char*)mData + offlen[y17QT2_CONF_NUM].offset); swapRawDet((DataBlock2017*)mQT2[i],y17QT2_CONF_NUM,j,bs);}
183  j=offlen[y17QT3_CONF_NUM].length; if (j>0){mQT3[i] = (QTBlock2017* )((char*)mData + offlen[y17QT3_CONF_NUM].offset); swapRawDet((DataBlock2017*)mQT3[i],y17QT3_CONF_NUM,j,bs);}
184  j=offlen[y17QT4_CONF_NUM].length; if (j>0){mQT4[i] = (QTBlock2017* )((char*)mData + offlen[y17QT4_CONF_NUM].offset); swapRawDet((DataBlock2017*)mQT4[i],y17QT4_CONF_NUM,j,bs);}
185  j=offlen[y17FQ1_CONF_NUM].length; if (j>0){mFQ1[i] = (QTBlock2017* )((char*)mData + offlen[y17FQ1_CONF_NUM].offset); swapRawDet((DataBlock2017*)mFQ1[i],y17FQ1_CONF_NUM,j,bs);}
186  j=offlen[y17FQ2_CONF_NUM].length; if (j>0){mFQ2[i] = (QTBlock2017* )((char*)mData + offlen[y17FQ2_CONF_NUM].offset); swapRawDet((DataBlock2017*)mFQ2[i],y17FQ2_CONF_NUM,j,bs);}
187  if (mMXQ[i]) decodeQT(mMXQ[i]->length/4, mMXQ[i]->data, mxq[i], tmxq[i]);
188  if (mEPQ[i]) decodeQT(mEPQ[i]->length/4, mEPQ[i]->data, epq[i], tepq[i]);
189  if (mBBQ[i]) decodeQT(mBBQ[i]->length/4, mBBQ[i]->data, bbq[i], tbbq[i]);
190  if (mQT1[i]) decodeQT(mQT1[i]->length/4, mQT1[i]->data, qt1[i], tqt1[i]);
191  if (mQT2[i]) decodeQT(mQT2[i]->length/4, mQT2[i]->data, qt2[i], tqt2[i]);
192  if (mQT3[i]) decodeQT(mQT3[i]->length/4, mQT3[i]->data, qt3[i], tqt3[i]);
193  if (mQT4[i]) decodeQT(mQT4[i]->length/4, mQT4[i]->data, qt4[i], tqt4[i]);
194  if (mFQ1[i]) decodeQT(mFQ1[i]->length/4, mFQ1[i]->data, fq1[i], tfq1[i]);
195  if (mFQ2[i]) decodeQT(mFQ2[i]->length/4, mFQ2[i]->data, fq2[i], tfq2[i]);
196  }
197  if (mDebug==1) dump();
198 }
199 
200 StTriggerData2017::~StTriggerData2017() {delete mData;}
201 
202 unsigned int StTriggerData2017::version() const
203 {
204  return EvtDesc->TrgDataFmtVer;
205 }
206 
207 unsigned int StTriggerData2017::eventNumber() const
208 {
209  return mData->eventNumber;
210 }
211 
212 unsigned int StTriggerData2017::token() const
213 {
214  return EvtDesc->TrgToken;
215 }
216 
217 unsigned int StTriggerData2017::triggerWord() const
218 {
219  return 0;
220 }
221 
222 unsigned int StTriggerData2017::actionWord() const
223 {
224  return
225  ( (unsigned short)(EvtDesc->actionWdTrgCommand) * 16 * 16 * 16 ) +
226  ( (unsigned short)(EvtDesc->actionWdDaqCommand) * 16 * 16 ) +
227  ( EvtDesc->actionWdDetectorBitMask & 0x00ff );
228 }
229 
230 unsigned int StTriggerData2017::numberOfPreXing() const
231 {
232  return EvtDesc->npre & 0xf;
233 }
234 
235 unsigned int StTriggerData2017::numberOfPostXing() const
236 {
237  return EvtDesc->npost & 0xf;
238 }
239 
240 unsigned short StTriggerData2017::busyStatus() const
241 {
242  return EvtDesc->internalBusy;
243 }
244 
245 unsigned short StTriggerData2017::dsmInput() const
246 {
247  return EvtDesc->DSMInput;
248 }
249 
250 unsigned short StTriggerData2017::trgToken() const
251 {
252  return EvtDesc->TrgToken;
253 }
254 
255 unsigned short StTriggerData2017::dsmAddress() const
256 {
257  return EvtDesc->DSMAddress;
258 }
259 
260 unsigned short StTriggerData2017::mAddBits() const
261 {
262  return EvtDesc->addBits;
263 }
264 
265 unsigned short StTriggerData2017::bcData(int channel) const
266 {
267  return L1_DSM->BCdata[channel];
268 }
269 
270 unsigned short StTriggerData2017::getTrgDetMask() const
271 {
272  return EvtDesc->trgDetMask;
273 }
274 
275 unsigned int StTriggerData2017::getTrgCrateMask() const
276 {
277  unsigned int p = EvtDesc->npost & 0xfff0;
278  unsigned int r = EvtDesc->res1 & 0x0ff0;
279  return
280  ( ((EvtDesc->npre & 0xfff0) >> 4)
281  + (p << 8)
282  + (r << 20) );
283 }
284 
285 unsigned short StTriggerData2017::lastDSM(int channel) const
286 {
287  return L1_DSM->lastDSM[channel];
288 }
289 
290 unsigned short StTriggerData2017::tcuBits() const
291 {
292  return EvtDesc->DSMInput;
293 }
294 
295 
296 unsigned int StTriggerData2017::tcuCounter() const
297 {
298  unsigned int hi = EvtDesc->tcuCtrBunch_hi;
299  return (hi << 16) + EvtDesc->DSMAddress;
300 }
301 
302 unsigned int StTriggerData2017::rccCounter(int crate) const
303 {
304  if(crate >= y17L1_CONF_NUM && crate <= y17QT4_CONF_NUM){
305  return TrgSum->LocalClocks[crate];
306  }
307  return 0;
308 }
309 
310 unsigned long long StTriggerData2017::bunchCounter() const
311 {
312  unsigned long long bxinghi,bxing1,bxinglo, bx;
313  bxinghi = L1_DSM->BCdata[3];
314  bxing1 = L1_DSM->BCdata[10];
315  bxinglo = (bxing1 << 16) + L1_DSM->BCdata[11];
316  bx = (bxinghi << 32) + bxinglo;
317  return bx;
318 }
319 
320 unsigned int StTriggerData2017::bunchCounterHigh() const
321 {
322  return EvtDesc->bunchXing_hi;
323 }
324 
325 unsigned int StTriggerData2017::bunchCounterLow() const
326 {
327  return EvtDesc->bunchXing_lo;
328 }
329 
330 unsigned int StTriggerData2017::bunchId48Bit() const
331 {
332  return (int)(bunchCounter() % 120);
333 }
334 
335 unsigned int StTriggerData2017::bunchId7Bit() const
336 {
337  int b7=0, b7dat;
338  b7dat = L1_DSM->BCdata[2];
339  b7 = b7dat & 0x7f;
340  return b7;
341 }
342 
343 unsigned int StTriggerData2017::spinBit() const
344 {
345  if(mRun<12000000){
346  return (L1_DSM->lastDSM[7]/16)%256;
347  }else{
348  return (L1_DSM->lastDSM[4]/16)%256;
349  }
350 }
351 
352 unsigned int StTriggerData2017::spinBitYellowFilled() const
353 {
354  unsigned int sb = spinBit();
355  return sb%2;
356 }
357 
358 unsigned int StTriggerData2017::spinBitYellowUp() const
359 {
360  unsigned int sb = spinBit();
361  return (sb/2)%2;
362 }
363 
364 unsigned int StTriggerData2017::spinBitYellowDown() const
365 {
366  unsigned int sb = spinBit();
367  return (sb/4)%2;
368 }
369 
370 unsigned int StTriggerData2017::spinBitYellowUnpol() const
371 {
372  unsigned int sb = spinBit();
373  return (sb/8)%2;
374 }
375 
376 unsigned int StTriggerData2017::spinBitBlueFilled() const
377 {
378  unsigned int sb = spinBit();
379  return (sb/16)%2;
380 }
381 
382 unsigned int StTriggerData2017::spinBitBlueUp() const
383 {
384  unsigned int sb = spinBit();
385  return (sb/32)%2;
386 }
387 
388 unsigned int StTriggerData2017::spinBitBlueDown() const
389 {
390  unsigned int sb = spinBit();
391  return (sb/64)%2;
392 }
393 
394 unsigned int StTriggerData2017::spinBitBlueUnpol() const
395 {
396  unsigned int sb = spinBit();
397  return (sb/128)%2;
398 }
399 
400 unsigned short StTriggerData2017::bbcADC(StBeamDirection eastwest, int pmt, int prepost) const
401 {
402  const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
403  4, 4, 4, 4, 4, 4, 4, 4},
404  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405  4, 4, 4, 4, 4, 4, 4, 4} };
406  const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
407  0, 1, 2, 3, 8, 9,10,11},
408  { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
409  16,17,18,19,24,25,26,27} };
410  int buffer = prepostAddress(prepost);
411  if (buffer >= 0 && pmt>=1 && pmt<=24) return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
412  return 0;
413 }
414 
415 unsigned short StTriggerData2017::bbcTDC(StBeamDirection eastwest, int pmt, int prepost) const
416 {
417  const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
418  4, 4, 4, 4, 4, 4, 4, 4},
419  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420  4, 4, 4, 4, 4, 4, 4, 4} };
421  const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
422  0, 1, 2, 3, 8, 9,10,11},
423  { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
424  16,17,18,19,24,25,26,27} };
425  int buffer = prepostAddress(prepost);
426  if (buffer >= 0 && pmt>=1 && pmt<=24) return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]+4];
427  return 0;
428 }
429 
430 unsigned short StTriggerData2017::bbcTDC5bit(StBeamDirection eastwest, int pmt, int prepost) const
431 {
432  const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
433  4, 4, 4, 4, 4, 4, 4, 4},
434  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435  4, 4, 4, 4, 4, 4, 4, 4} };
436  const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
437  0, 1, 2, 3, 8, 9,10,11},
438  { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
439  16,17,18,19,24,25,26,27} };
440  int buffer = prepostAddress(prepost);
441  if (buffer >= 0 && pmt>=1 && pmt<=24) return tbbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
442  return 0;
443 }
444 
445 unsigned short StTriggerData2017::bbcADCSum(StBeamDirection eastwest, int prepost) const
446 {
447  unsigned short sum=0;
448  int buffer = prepostAddress(prepost);
449  //if (buffer >= 0) for(int i=1; i<=16; i++) {sum+=bbcADC(eastwest,i,prepost);}
450  if(buffer>=0){
451  if (mBBC[buffer]){
452  if(eastwest==east) { sum = mBBC[buffer]->BBClayer1[3]; }
453  else { sum = mBBC[buffer]->BBClayer1[1]; }
454  }
455  }
456  return sum;
457 }
458 
459 unsigned short StTriggerData2017::bbcADCSumLargeTile(StBeamDirection eastwest, int prepost) const
460 {
461  unsigned short sum=0;
462  int buffer = prepostAddress(prepost);
463  if (buffer >= 0) for(int i=17; i<=24; i++) {sum+=bbcADC(eastwest,i,prepost);}
464  return sum;
465 }
466 
467 unsigned short StTriggerData2017::bbcEarliestTDC(StBeamDirection eastwest, int prepost) const
468 {
469  int buffer = prepostAddress(prepost);
470  if (buffer >=0){
471  if (mBBC[buffer]){
472  if (eastwest==east) {return mBBC[buffer]->BBClayer1[2]%4096;}
473  else {return mBBC[buffer]->BBClayer1[0]%4096;}
474  }
475  }
476  return 0;
477 }
478 
479 unsigned short StTriggerData2017::bbcTimeDifference() const
480 {
481  return L1_DSM->VTX[3]%8192;
482 }
483 
484 unsigned short StTriggerData2017::bbcTacSum() const
485 {
486  return (((L1_DSM->VTX[3]) >> 13) & 0x1);
487 }
488 
489 unsigned short StTriggerData2017::bbcEarliestTDCLarge(StBeamDirection eastwest, int prepost) const
490 {
491  int buffer = prepostAddress(prepost);
492  if (buffer >=0){
493  if (mBBC[buffer]){
494  if (eastwest==east) {return mBBC[buffer]->BBClayer1[11] & 0x0fff;}
495  else {return ((mBBC[buffer]->BBClayer1[11] & 0xf000) >> 12)
496  +((mBBC[buffer]->BBClayer1[10] & 0x00ff) << 4 );}
497  }
498  }
499  return 0;
500 }
501 
502 unsigned short StTriggerData2017::bbcTimeDifferenceLarge() const
503 {
504  return L1_DSM->VTX[2]%8192;
505 }
506 
507 
508 unsigned short StTriggerData2017::bbcBB101(int ch, int prepost) const
509 {
510  int dsmmap[8] = {3,2,1,0,7,6,5,4};
511  int buffer = prepostAddress(prepost);
512  if (buffer>=0){
513  if (mBBC[buffer]){
514  if(ch>=0 && ch<=7) return mBBC[buffer]->BBClayer1[dsmmap[ch]];
515  }
516  }
517  return 0;
518 }
519 
520 unsigned short StTriggerData2017::bbcBB102(int ch, int prepost) const
521 {
522  int dsmmap[8] = {3,2,1,0,7,6,5,4};
523  int buffer = prepostAddress(prepost);
524  if (buffer>=0){
525  if (mBBC[buffer]){
526  if(ch>=0 && ch<=7) return mBBC[buffer]->BBClayer1[dsmmap[ch]+8];
527  }
528  }
529  return 0;
530 }
531 
532 
533 unsigned short StTriggerData2017::fpd(StBeamDirection eastwest, int module, int pmt, int prepost) const
534 {
535  return 0;
536 }
537 
538 unsigned short StTriggerData2017::fpdSum(StBeamDirection eastwest, int module) const
539 {
540  return 0;
541 }
542 
543 unsigned short StTriggerData2017::fpdLayer1DSMRaw(StBeamDirection eastwest, int channel, int prepost) const{
544  int buffer = prepostAddress(prepost);
545  if (buffer >= 0){
546  if (eastwest==east) { if (mMIX[buffer]) return mMIX[buffer]->FPDEastNSLayer1[channel]; }
547  else { if (mFMS[buffer]) return mFMS[buffer]->FMS[channel]; }
548  }
549  return 0;
550 }
551 
552 unsigned short StTriggerData2017::fpdLayer2DSMRaw(int channel) const{
553  if (channel<8) return L1_DSM->FPD[channel];
554  return 0;
555 }
556 
557 bool StTriggerData2017::zdcPresent(int prepost) const
558 {
559  int buffer = prepostAddress(prepost);
560  if (buffer >= 0) return mBBQ[buffer];
561  return false;
562 }
563 
564 unsigned short StTriggerData2017::zdcAtChannel(int channel, int prepost) const
565 {
566  int buffer = prepostAddress(prepost);
567  if (buffer >= 0 && channel>=0 && channel<32) return bbq[buffer][14][channel];
568  return 0;
569 }
570 
571 unsigned short StTriggerData2017::zdcAtAddress(int address, int prepost) const
572 {
573  return zdcAtChannel(address,prepost);
574 }
575 
576 unsigned short StTriggerData2017::zdcUnAttenuated(StBeamDirection eastwest, int prepost) const
577 {
578  int buffer = prepostAddress(prepost);
579  if (buffer >= 0) {
580  if (eastwest == east) return bbq[buffer][14][2];
581  else return bbq[buffer][14][18];
582  }
583  return 0;
584 }
585 
586 unsigned short StTriggerData2017::zdcAttenuated(StBeamDirection eastwest, int prepost) const
587 {
588  int buffer = prepostAddress(prepost);
589  if (buffer >= 0) {
590  if (eastwest == east) return bbq[buffer][14][3];
591  else return bbq[buffer][14][19];
592  }
593  return 0;
594 }
595 
596 unsigned short StTriggerData2017::zdcADC(StBeamDirection eastwest, int pmt, int prepost) const
597 {
598  int buffer = prepostAddress(prepost);
599  if (buffer >= 0 && pmt>=1 && pmt<=3) {
600  if (eastwest == east) {
601  if (pmt == 1) return bbq[buffer][14][0];
602  if (pmt == 2) return bbq[buffer][14][8];
603  if (pmt == 3) return bbq[buffer][14][9];
604  }
605  else {
606  if (pmt == 1) return bbq[buffer][14][16];
607  if (pmt == 2) return bbq[buffer][14][24];
608  if (pmt == 3) return bbq[buffer][14][25];
609  }
610  }
611  return 0;
612 }
613 
614 unsigned short StTriggerData2017::zdcTDC(StBeamDirection eastwest, int prepost) const
615 {
616  int buffer = prepostAddress(prepost);
617  if (buffer >= 0) {
618  if (eastwest == east) return bbq[buffer][14][6];
619  else return bbq[buffer][14][22];
620  }
621  return 0;
622 }
623 
624 unsigned short StTriggerData2017::zdcPmtTDC(StBeamDirection eastwest, int pmt, int prepost) const
625 {
626  int buffer = prepostAddress(prepost);
627  if (buffer >= 0 && pmt>=1 && pmt<=3) {
628  if (eastwest == east) {
629  if (pmt == 1) return bbq[buffer][14][4];
630  if (pmt == 2) return bbq[buffer][14][12];
631  if (pmt == 3) return bbq[buffer][14][13];
632  }
633  else {
634  if (pmt == 1) return bbq[buffer][14][20];
635  if (pmt == 2) return bbq[buffer][14][28];
636  if (pmt == 3) return bbq[buffer][14][29];
637  }
638  }
639  return 0;
640 }
641 
642 unsigned short StTriggerData2017::zdcHardwareSum(int prepost) const
643 {
644  int buffer = prepostAddress(prepost);
645  if (buffer >= 0) return bbq[buffer][14][11];
646  return 0;
647 }
648 
649 bool StTriggerData2017::zdcSMDPresent(int prepost) const
650 {
651  int buffer = prepostAddress(prepost);
652  if (buffer >= 0) return mMXQ[buffer];
653  return false;
654 }
655 
656 unsigned short StTriggerData2017::zdcSMD(StBeamDirection eastwest, int verthori, int strip, int prepost) const
657 {
658  static const int zdcsmd_map[2][2][8] ={
659  { { 31, 30, 29, 28, 27, 26, 25, 19} ,
660  { 24, 23, 22, 21, 20, 16, 18, 17} } ,
661  { { 15, 14, 13, 12, 11, 10, 9, 2} ,
662  { 8, 7, 6, 5, 4, 3, 0, 1} }
663  };
664  static const int zdcsmd_map2011[2][2][8] ={
665  { {24, 25, 26, 27, 28, 29, 30, 31} ,
666  {16, 17, 18, 19, 20, 21, 22, 23} } ,
667  { {8, 9, 10, 11, 12, 13, 14, 15} ,
668  {0, 1, 2, 3, 4, 5, 6, 7} }
669  };
670  if (verthori<0 || verthori>1) return 0;
671  if (strip<1 || strip>8) return 0;
672  int buffer = prepostAddress(prepost);
673  if (buffer >= 0) {
674  if(mRun<12034085){
675  return mxq[buffer][4][zdcsmd_map[eastwest][verthori][strip-1]];
676  }else{
677  return mxq[buffer][4][zdcsmd_map2011[eastwest][verthori][strip-1]];
678  }
679  }
680  return 0;
681 }
682 
683 unsigned short StTriggerData2017::zdcEarliestTDC(StBeamDirection eastwest, int prepost) const
684 {
685  int buffer = prepostAddress(prepost);
686  if (buffer >=0){
687  if (mBBC[buffer]){
688  if(mRun<12000000){
689  if (eastwest==east) {return ((mBBC[buffer]->ZDClayer1[3] >> 12) % 16) | ((mBBC[buffer]->ZDClayer1[2] % 256) << 4);}
690  else {return (mBBC[buffer]->ZDClayer1[3]) % 4096;}
691  }else{
692  if (eastwest==east) {return ((mBBC[buffer]->ZDClayer1[3] >> 10) % 64) | ((mBBC[buffer]->ZDClayer1[2] % 16) << 6);}
693  else {return (mBBC[buffer]->ZDClayer1[3]) % 1024;}
694  }
695  }
696  }
697  return 0;
698 }
699 
700 bool StTriggerData2017::zdcSumADCaboveThreshold(StBeamDirection eastwest, int prepost) const {
701  int buffer = prepostAddress(prepost);
702  if (buffer >=0){
703  if (mBBC[buffer]){
704  if(mRun<12000000){
705  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (27-16));}
706  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
707  }else{
708  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
709  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (22-16));}
710  }
711  }
712  }
713  return 0;
714 }
715 
716 bool StTriggerData2017::zdcFrontADCaboveThreshold(StBeamDirection eastwest, int prepost) const {
717  int buffer = prepostAddress(prepost);
718  if (buffer >=0){
719  if (mBBC[buffer]){
720  if(mRun<12000000){
721  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (29-16));}
722  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (26-16));}
723  }else{
724  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (23-16));}
725  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (20-16));}
726  }
727  }
728  }
729  return 0;
730 }
731 
732 bool StTriggerData2017::zdcBackADCaboveThreshold(StBeamDirection eastwest, int prepost) const {
733  int buffer = prepostAddress(prepost);
734  if (buffer >=0){
735  if (mBBC[buffer]){
736  if(mRun<12000000){
737  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (28-16));}
738  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
739  }else{
740  if (eastwest==east) {return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
741  else {return mBBC[buffer]->ZDClayer1[2] & (1 << (21-16));}
742  }
743  }
744  }
745  return 0;
746 }
747 
748 unsigned short StTriggerData2017::zdcTimeDifference() const
749 {
750  return L1_DSM->VTX[1]%1024;
751 }
752 
753 bool StTriggerData2017::zdcSumADCaboveThresholdL2(StBeamDirection eastwest) const {
754  return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 10 : 11));
755 }
756 
757 bool StTriggerData2017::zdcFrontADCaboveThresholdL2(StBeamDirection eastwest) const {
758  return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 12 : 14));
759 }
760 
761 bool StTriggerData2017::zdcBackADCaboveThresholdL2(StBeamDirection eastwest) const {
762  return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 13 : 15));
763 }
764 
765 bool StTriggerData2017::zdcSumADCaboveThresholdL3(StBeamDirection eastwest) const {
766  if(mRun<12000000){ return lastDSM(2) & (1 << ((eastwest==east) ? 7 : 8)); }
767  else { return lastDSM(1) & (1 << ((eastwest==east) ? 7 : 8)); }
768 }
769 
770 bool StTriggerData2017::zdcFrontADCaboveThresholdL3(StBeamDirection eastwest) const {
771  if(mRun<12000000){ return lastDSM(2) & (1 << ((eastwest==east) ? 9 : 11)); }
772  else { return lastDSM(1) & (1 << ((eastwest==east) ? 9 : 11)); }
773 }
774 
775 bool StTriggerData2017::zdcBackADCaboveThresholdL3(StBeamDirection eastwest) const {
776  if(mRun<12000000){ return lastDSM(2) & (1 << ((eastwest==east) ? 10 : 12)); }
777  else { return lastDSM(1) & (1 << ((eastwest==east) ? 10 : 12)); }
778 }
779 
780 bool StTriggerData2017::zdcTimeDifferenceInWindow() const
781 {
782  if(mRun<12000000){ return lastDSM(2) & (1 << 6); }
783  else { return lastDSM(1) & (1 << 6); }
784 }
785 
786 unsigned short StTriggerData2017::zdcSMDHighestStrip(StBeamDirection eastwest, int verthori, int prepost) const
787 {
788  if(mRun<12000000) return 0;
789  // copy of the scaler output from ZDC SMD QT is sent to ZD101 J2
790  int buffer = prepostAddress(prepost);
791  if (buffer >=0){
792  if (mBBC[buffer]){
793  if (eastwest==east) {return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 6 : 9)) % 8;}
794  else {return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 0 : 3)) % 8;}
795  }
796  }
797  return 0;
798 }
799 
800 unsigned short StTriggerData2017::zdcTruncatedSum(StBeamDirection eastwest, int prepost) const
801 {
802  if(mRun<12000000) return 0;
803  int buffer = prepostAddress(prepost);
804  if (buffer >=0){
805  if (mBBC[buffer]){
806  if (eastwest==east) {return (mBBC[buffer]->ZDClayer1[2] >> (26-16)) % 8;}
807  else {return (mBBC[buffer]->ZDClayer1[2] >> (29-16)) % 8;}
808  }
809  }
810  return 0;
811 }
812 
813 unsigned short StTriggerData2017::pp2ppADC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost) const
814 {
815  static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
816  { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
817  if (vh<0 || vh>1) return 0;
818  if (udio<0 || udio>1) return 0;
819  if (ch<0 || ch>1) return 0;
820  int buffer = prepostAddress(prepost);
821  if (buffer >= 0) return mxq[buffer][2][map[eastwest][vh][udio][ch]];
822  return 0;
823 }
824 
825 unsigned short StTriggerData2017::pp2ppTAC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost) const
826 {
827  static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
828  { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
829  if (vh<0 || vh>1) return 0;
830  if (udio<0 || udio>1) return 0;
831  if (ch<0 || ch>1) return 0;
832  int buffer = prepostAddress(prepost);
833  if (buffer >= 0) return mxq[buffer][2][map[eastwest][vh][udio][ch]+4];
834  return 0;
835 }
836 
837 unsigned long StTriggerData2017::pp2ppDSM(int prepost) const {
838  if (prepost!=0) return 0;
839  return L1_DSM->TOF[7];
840 }
841 
842 unsigned short StTriggerData2017::bemcLayer1DSM(int channel, int prepost) const {
843  const int n_bemc_layer1=48;
844  if (channel<0 || channel >=n_bemc_layer1) {
845  gMessMgr->Warning() << "Barrel DSM layer 1 out of range (" << channel << ")" << endm;
846  return 0;
847  }
848  int buffer = prepostAddress(prepost);
849  if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->BEMClayer1[channel];
850  return 0;
851 }
852 
853 unsigned short StTriggerData2017::eemcLayer1DSM(int channel, int prepost) const {
854  const int n_eemc_layer1=16;
855  if (channel<0 || channel >=n_eemc_layer1) {
856  gMessMgr->Warning() << "Endap DSM layer 1 out of range (" << channel << ")" << endm;
857  return 0;
858  }
859  int buffer = prepostAddress(prepost);
860  if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMClayer1[channel];
861  return 0;
862 }
863 
864 unsigned short StTriggerData2017::emcLayer2DSM(int channel) const {
865  const int n_emc_layer2=8;
866  if (channel<0 || channel >=n_emc_layer2) {
867  gMessMgr->Warning() << "EMC DSM layer 2 out of range (" << channel << ")" << endm;
868  return 0;
869  }
870  return L1_DSM->EMC[channel];
871 }
872 
873 unsigned short StTriggerData2017::tpcMaskDSM(int channel) const {
874  const int n_tpcMask=8;
875  if (channel<0 || channel >=n_tpcMask) {
876  gMessMgr->Warning() << "TPCMask DSM out of range (" << channel << ")" << endm;
877  return 0;
878  }
879  return L1_DSM->TPCMask[channel];
880 }
881 
882 unsigned char StTriggerData2017::bemcHighTower(int patch_id, int prepost) const {
883  // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches)
884  const int m_max_patch=300; // Full barrel
885  if ( patch_id < 0 || patch_id >= m_max_patch) {
886  gMessMgr->Warning() << "Invalid Barrel patch id: " << patch_id << endm;
887  return 0;
888  }
889  int buffer = prepostAddress(prepost);
890  if (buffer >= 0) {
891  int dsm=patch_id/10;
892  int channel=patch_id%10;
893  unsigned short trg_word;
894  if (dsm>=15) {
895  if (mBCE[buffer])
896  trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
897  else
898  return 0;
899  }
900  else {
901  if (mBCW[buffer])
902  trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
903  else
904  return 0;
905  }
906  return trg_word & 0x3F;
907  }
908  return 0;
909 }
910 
911 unsigned char StTriggerData2017::bemcJetPatch (int patch_id, int prepost) const
912 {
913  // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches)
914  const int m_max_patch=300; // Full barrel
915  if ( patch_id < 0 || patch_id >= m_max_patch) {
916  gMessMgr->Warning() << "Invalid Barrel patch id: " << patch_id << endm;
917  return 0;
918  }
919  int buffer = prepostAddress(prepost);
920  if (buffer >= 0) {
921  int dsm=patch_id/10;
922  int channel=patch_id%10;
923  unsigned short trg_word;
924  if (dsm>=15) {
925  if (mBCE[buffer])
926  trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
927  else
928  return 0;
929  }
930  else {
931  if (mBCW[buffer])
932  trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
933  else
934  return 0;
935  }
936  return trg_word >> 6;
937  }
938  return 0;
939 }
940 
941 
942 unsigned char StTriggerData2017::eemcHighTower(int patch_id, int prepost) const
943 {
944  // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches)
945  const int m_max_patch=90;
946  if ( patch_id < 0 || patch_id >= m_max_patch) {
947  gMessMgr->Warning() << "Invalid Endcap patch id" << endm;
948  return 0;
949  }
950  int buffer = prepostAddress(prepost);
951  if (buffer >= 0 && mBC1[buffer]) {
952  int dsm=patch_id/10;
953  int channel=patch_id%10;
954  unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
955  return trg_word & 0x3F;
956  }
957  return 0;
958 }
959 
960 unsigned char StTriggerData2017::eemcJetPatch (int patch_id, int prepost) const
961 {
962  // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches)
963  const int m_max_patch=90;
964  if ( patch_id < 0 || patch_id >= m_max_patch) {
965  gMessMgr->Warning() << "Invalid Endcap patch id" << endm;
966  return 0;
967  }
968  int buffer = prepostAddress(prepost);
969  if (buffer >= 0 && mBC1[buffer]) {
970  int dsm=patch_id/10;
971  int channel=patch_id%10;
972  unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
973  return trg_word >> 6;
974  }
975  return 0;
976 }
977 
978 unsigned char StTriggerData2017::bemcHighestTowerADC(int prepost) const {
979  // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches)
980  const int m_max_patch=300; // Full barrel
981  unsigned char h=0;
982  for (int i=1; i<m_max_patch; i++){
983  unsigned char hh=bemcHighTower(i,prepost);
984  if (h>hh) h=hh;
985  }
986  return h;
987 }
988 
989 unsigned char StTriggerData2017::eemcHighestTowerADC(int prepost) const {
990  // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches)
991  const int m_max_patch=90;
992  unsigned char h=0;
993  for (int i=1; i<m_max_patch; i++){
994  unsigned char hh=eemcHighTower(i,prepost);
995  if (h>hh) h=hh;
996  }
997  return h;
998 }
999 
1000 char* StTriggerData2017::getTriggerStructure()
1001 {
1002  return (char*) mData;
1003 }
1004 
1005 TriggerDataBlk2017* StTriggerData2017::getTriggerStructure2017()
1006 {
1007  return mData;
1008 }
1009 
1010 int StTriggerData2017::getRawSize() const
1011 {
1012  return mData->totalTriggerLength;
1013 }
1014 
1015 unsigned char* StTriggerData2017::getDsm0_BEMCE(int prepost) const {
1016  int buffer = prepostAddress(prepost);
1017  if (buffer >= 0) if (mBCE[buffer]) return mBCE[buffer]->BEMCEast;
1018  return 0;
1019 }
1020 
1021 unsigned char* StTriggerData2017::getDsm0_BEMCW(int prepost) const {
1022  int buffer = prepostAddress(prepost);
1023  if (buffer >= 0) if (mBCW[buffer]) return mBCW[buffer]->BEMCWest;
1024  return 0;
1025 }
1026 
1027 unsigned short* StTriggerData2017::getDsm1_BEMC(int prepost) const {
1028  int buffer = prepostAddress(prepost);
1029  if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->BEMClayer1;
1030  return 0;
1031 }
1032 
1033 unsigned char* StTriggerData2017::getDsm0_EEMC(int prepost) const {
1034  int buffer = prepostAddress(prepost);
1035  if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMC;
1036  return 0;
1037 }
1038 
1039 unsigned short* StTriggerData2017::getDsm1_EEMC(int prepost) const{
1040  int buffer = prepostAddress(prepost);
1041  if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMClayer1;
1042  return 0;
1043 }
1044 
1045 unsigned short* StTriggerData2017::getDsm2_EMC() const{
1046  return L1_DSM->EMC;
1047 }
1048 
1049 unsigned short* StTriggerData2017::getDsm3() const{
1050  return L1_DSM->lastDSM;
1051 }
1052 
1053 int StTriggerData2017::L2ResultsOffset(StL2AlgorithmId id) const
1054 {
1055  switch(id) {
1056  default: return -999999999;
1057  }
1058 }
1059 
1060 bool StTriggerData2017::isL2Triggered(StL2TriggerResultType id) const
1061 {
1062  return false;
1063 }
1064 
1065 unsigned int StTriggerData2017::l2ResultLength() const
1066 {
1067  return sizeof(TrgSum->L2Result)/sizeof(unsigned int);
1068 }
1069 
1070 const unsigned int* StTriggerData2017::l2Result() const
1071 {
1072  return TrgSum->L2Result;
1073 }
1074 
1075 unsigned long long StTriggerData2017::l2sum() const
1076 {
1077  //printf("L2sum0=%08o\n",TrgSum->L2Sum[0]);
1078  //printf("L2sum1=%08o\n",TrgSum->L2Sum[1]);
1079  unsigned long long hi = TrgSum->L2Sum[1];
1080  unsigned long long lo = TrgSum->L2Sum[0];
1081  unsigned long long mask=(hi<<32) | lo;
1082  return mask;
1083 }
1084 
1085 unsigned short StTriggerData2017::vpdADC(StBeamDirection eastwest, int pmt, int prepost) const
1086 {
1087  static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1088  if (pmt<1 || pmt>16) return 0;
1089  int buffer = prepostAddress(prepost);
1090  if (buffer >= 0) {
1091  if (mRun<=12003001) {return bbq[buffer][10+(int)eastwest*2][map[pmt-1]];}
1092  else {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1093  }
1094  return 0;
1095 }
1096 
1097 unsigned short StTriggerData2017::vpdTDC(StBeamDirection eastwest, int pmt, int prepost) const
1098 {
1099  static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1100  if (pmt<1 || pmt>16) return 0;
1101  int buffer = prepostAddress(prepost);
1102  if (buffer >= 0) {
1103  if (mRun<=12003001) {return bbq[buffer][10+(int)eastwest*2][map[pmt-1]+4];}
1104  else {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1105  }
1106  return 0;
1107 }
1108 
1109 unsigned short StTriggerData2017::vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost) const
1110 {
1111  static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1112  if (pmt<1 || pmt>16) return 0;
1113  int buffer = prepostAddress(prepost);
1114  if (buffer >= 0) {
1115  if (mRun<=12003001) {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1116  else {return mxq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1117  }
1118  return 0;
1119 }
1120 
1121 unsigned short StTriggerData2017::vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost) const
1122 {
1123  static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1124  if (pmt<1 || pmt>16) return 0;
1125  int buffer = prepostAddress(prepost);
1126  if (buffer >= 0) {
1127  if (mRun<=12003001) {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1128  else {return mxq[buffer][6+(int)eastwest*2][map[pmt-1]+4];};
1129  }
1130  return 0;
1131 }
1132 
1133 unsigned short StTriggerData2017::vpdEarliestTDC(StBeamDirection eastwest, int prepost) const
1134 {
1135  int buffer = prepostAddress(prepost);
1136  if (buffer >= 0){
1137  if (mBBC[buffer]){
1138  if (mRun<=10096084){
1139  if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;}
1140  else {return mBBC[buffer]->VPD[4]%4096;}
1141  }
1142  else if(mRun<=12003001) {
1143  if (eastwest==east) {return mBBC[buffer]->VPD[2]%4096;}
1144  else {return mBBC[buffer]->VPD[0]%4096;}
1145  }
1146  else {
1147  if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;}
1148  else {return mBBC[buffer]->VPD[4]%4096;}
1149  }
1150 
1151  }
1152  }
1153  return 0;
1154 }
1155 
1156 unsigned short StTriggerData2017::vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost) const
1157 {
1158  int buffer = prepostAddress(prepost);
1159  if (buffer >= 0){
1160  if (mRun<=10365999){
1161  return 0;
1162  }
1163  else if(mRun<=12003001) {
1164  if (mBBC[buffer]){
1165  if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;}
1166  else {return mBBC[buffer]->VPD[4]%4096;}
1167  }
1168  }else if(mRun<=14001001){
1169  if(mMIX[buffer]){
1170  if (eastwest==east) {return mMIX[buffer]->MTD_P2PLayer1[13] + ((mMIX[buffer]->MTD_P2PLayer1[12]&0x0f)<<8);}
1171  else {return mMIX[buffer]->MTD_P2PLayer1[9] + ((mMIX[buffer]->MTD_P2PLayer1[8]&0x0f)<<8);}
1172  }
1173  }else {
1174  if(mMIX[buffer]){
1175  if (eastwest==east) {return mMIX[buffer]->MTD_P2PLayer1[11] + ((mMIX[buffer]->MTD_P2PLayer1[10]&0xf)<<8);}
1176  else {return (mMIX[buffer]->MTD_P2PLayer1[10]>>4) + ((mMIX[buffer]->MTD_P2PLayer1[9]&0xff)<<4);}
1177  }
1178  }
1179  }
1180  return 0;
1181 }
1182 
1183 unsigned short StTriggerData2017::vpdTimeDifference() const
1184 {
1185  return L1_DSM->VTX[7]%8192;
1186 }
1187 
1188 
1189 unsigned short StTriggerData2017::bbcVP101(int ch, int prepost) const
1190 {
1191  int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1192  if(ch<0 || ch>7) return 0;
1193  int buffer = prepostAddress(prepost);
1194  if (buffer >= 0 && mBBC[buffer]){
1195  return mBBC[buffer]->VPD[map[ch]];
1196  }
1197  return 0;
1198 }
1199 
1200 
1201 unsigned short StTriggerData2017::dsmTF201Ch(int ch) const // read TF201 data
1202 {
1203  int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1204  return L1_DSM->TOF[map[ch]]; //ch4-7 currently unused
1205 }
1206 
1207 unsigned short StTriggerData2017::mtd4AtAddress(int address, int prepost) const // read QT4 data
1208 {
1209  if (mRun<=15001001) return 0; // Run-14 onwards...
1210  int buffer = prepostAddress(prepost);
1211  if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][14][address];
1212  return 0;
1213 }
1214 
1215 unsigned short StTriggerData2017::nQTdata(int prepost) const
1216 {
1217  return 0;
1218 }
1219 
1220 unsigned int* StTriggerData2017::QTdata(int prepost) const
1221 {
1222  return 0;
1223 }
1224 
1225 unsigned short StTriggerData2017::fmsADC(int crt, int adr, int ch, int prepost) const
1226 {
1227  int buffer = prepostAddress(prepost);
1228  if (buffer >= 0 && crt>=0 && crt<=5 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1229  switch(crt){
1230  case 0: return bbq[buffer][adr][ch];
1231  case 1: return qt1[buffer][adr][ch];
1232  case 2: return qt2[buffer][adr][ch];
1233  case 3: return qt3[buffer][adr][ch];
1234  case 4: return qt4[buffer][adr][ch];
1235  case 5: return epq[buffer][adr][ch];
1236  case 6: return fq1[buffer][adr][ch];
1237  case 7: return fq2[buffer][adr][ch];
1238  }
1239  }
1240  return 0;
1241 }
1242 
1243 unsigned short StTriggerData2017::fmsTDC(int crt, int adr, int ch, int prepost) const
1244 {
1245  int buffer = prepostAddress(prepost);
1246  if (buffer >= 0 && crt>=0 && crt<=5 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1247  switch(crt){
1248  case 0: return tbbq[buffer][adr][ch];
1249  case 1: return tqt1[buffer][adr][ch];
1250  case 2: return tqt2[buffer][adr][ch];
1251  case 3: return tqt3[buffer][adr][ch];
1252  case 4: return tqt4[buffer][adr][ch];
1253  case 5: return tepq[buffer][adr][ch];
1254  case 6: return tfq1[buffer][adr][ch];
1255  case 7: return tfq2[buffer][adr][ch];
1256  }
1257  }
1258  return 0;
1259 }
1260 
1261 unsigned short StTriggerData2017::epdADC(int crt, int adr, int ch, int prepost) const
1262 {
1263  int buffer = prepostAddress(prepost);
1264  if (buffer >= 0 && crt>=1 && crt<=1 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1265  switch(crt){
1266  case 1: return epq[buffer][adr][ch];
1267  }
1268  }
1269  return 0;
1270 }
1271 
1272 unsigned short StTriggerData2017::epdTDC(int crt, int adr, int ch, int prepost) const
1273 {
1274  int buffer = prepostAddress(prepost);
1275  if (buffer >= 0 && crt>=1 && crt<=1 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1276  switch(crt){
1277  case 1: return tepq[buffer][adr][ch];
1278  }
1279  }
1280  return 0;
1281 }
1282 
1283 unsigned char* StTriggerData2017::getDsm_FMS(int prepost) const
1284 {
1285  int buffer = prepostAddress(prepost);
1286  if (buffer >= 0) if (mFMS[buffer]) return mFMS[buffer]->FMS;
1287  return 0;
1288 }
1289 
1290 unsigned short* StTriggerData2017::getDsm1_FMS(int prepost) const
1291 {
1292  int buffer = prepostAddress(prepost);
1293  if (buffer >= 0) if (mMIX[buffer]) return mMIX[buffer]->FPDEastNSLayer1;
1294  return 0;
1295 }
1296 
1297 unsigned short* StTriggerData2017::getDsm2_FMS() const {return L1_DSM->FPD;}
1298 
1299 unsigned short StTriggerData2017::mxqAtSlotAddress(int address, int prepost, int slot) const
1300 {
1301  int buffer = prepostAddress(prepost);
1302  if (buffer >= 0 && address>=0 && address<32){
1303  if (slot >= 0 && slot<16){
1304  return mxq[buffer][slot][address];
1305  }
1306  }
1307  return 0;
1308 }
1309 
1310 unsigned short StTriggerData2017::mtdQtAtCh(int qtid, int address, int prepost) const
1311 { // read all the MTD QTs data, and the range of qtid is 1-8
1312  int map1[4] = {0, 10, 12, 14};
1313  int map2[8] = {0, 9, 10, 11, 12, 13, 14, 15};
1314  int map3[4] = {0, 9, 11, 13};
1315 
1316  int buffer = prepostAddress(prepost);
1317  if(buffer>=0 && qtid>0 && address>=0 && address<32){
1318  if(mRun<=12003001){
1319  if(qtid>1) return 0;
1320  else return mxq[buffer][map1[qtid-1]][address];
1321  }
1322  else if(mRun<=14001001){
1323  if(qtid>2) return 0;
1324  else return mxq[buffer][map1[qtid-1]][address];
1325  }
1326  else if(mRun<=15001001){
1327  if(qtid>3) return 0;
1328  else return mxq[buffer][map1[qtid-1]][address];
1329  }
1330  else if(mRun<=17001001){
1331  if(qtid>4) return 0;
1332  else return mxq[buffer][map1[qtid-1]][address];
1333  }
1334  else if(mRun<=18001001){
1335  if(qtid>8) return 0;
1336  else return mxq[buffer][map2[qtid-1]][address];
1337  }
1338  else{
1339  if(qtid>4) return 0;
1340  else return mxq[buffer][map3[qtid-1]][address];
1341  }
1342  }
1343 
1344  return 0;
1345 }
1346 
1347 unsigned short StTriggerData2017::mtdAtAddress(int address, int prepost) const
1348 {
1349  int buffer = prepostAddress(prepost);
1350  if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][0][address];
1351  return 0;
1352 }
1353 
1354 unsigned short StTriggerData2017::mtdgemAtAddress(int address, int prepost) const
1355 {
1356  if (mRun<=12003001) return 0;
1357  int buffer = prepostAddress(prepost);
1358  if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][10][address];
1359  return 0;
1360 }
1361 
1362 unsigned short StTriggerData2017::mtd3AtAddress(int address, int prepost) const
1363 {
1364  if (mRun<=14001001) return 0; // Run-13 onwards...
1365  int buffer = prepostAddress(prepost);
1366  if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][12][address];
1367  return 0;
1368 }
1369 
1370 
1371 unsigned short StTriggerData2017::mtdAdc(StBeamDirection eastwest, int pmt, int prepost) const
1372 {
1373  //pmt in not used for 2017, it is place holder for next year
1374  int buffer = prepostAddress(prepost);
1375  if (buffer >= 0 && pmt==0){
1376  if (eastwest==east) {
1377  if (mRun<=10133008) return mxq[buffer][0][0];
1378  else return mxq[buffer][0][24];
1379  }
1380  if (eastwest==west) return mxq[buffer][0][8];
1381  }
1382  return 0;
1383 }
1384 
1385 unsigned short StTriggerData2017::mtdTdc(StBeamDirection eastwest, int pmt, int prepost) const
1386 {
1387  //pmt in not used for 2017, it is place holder for next year
1388  int buffer = prepostAddress(prepost);
1389  if (buffer >= 0 && pmt==0){
1390  if (eastwest==east) {
1391  if (mRun<=10133008) return mxq[buffer][0][4];
1392  else return mxq[buffer][0][28];
1393  }
1394  if (eastwest==west) return mxq[buffer][0][12];
1395  }
1396  return 0;
1397 }
1398 
1399 unsigned char StTriggerData2017::mtdDsmAtCh(int ch, int prepost) const
1400 {
1401  int map[16] = {7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8};
1402  int map2[8] = {3, 2, 1, 0, 7, 6, 5, 4};
1403  int buffer = prepostAddress(prepost);
1404  if (buffer >= 0 && ch>=0){
1405  if(mMIX[buffer]){
1406  if(ch<16){
1407  return mMIX[buffer]->MTD_P2PLayer1[map[ch]];
1408  }else if(ch<32){
1409  int add= 8 + map2[(ch-16)/2];
1410  unsigned char v=0;
1411  if(ch%2==0){ v=(unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0xff00)>>8);}
1412  else { v=(unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0x00ff) );}
1413  return v;
1414  }
1415  }
1416  }
1417  return 0;
1418 }
1419 
1420 bool StTriggerData2017::mtdDsmHit(int pmt, int prepost) const
1421 {
1422  //pmt in not used for 2017, it is place holder for next year
1423  int buffer = prepostAddress(prepost);
1424  if (buffer >= 0){
1425  if(mMIX[buffer]){
1426  if(mRun<10133008 && mRun<11000000){
1427  if( (mMIX[buffer]->MTD_P2PLayer1[5] & 0x1) && (mMIX[buffer]->MTD_P2PLayer1[5] & 0x10) ) return true;
1428  }
1429  else{
1430  if(prepost!=0) return false;
1431  return (L1_DSM->TOF[3] & 0x1);
1432  }
1433  }
1434  }
1435  return false;
1436 }
1437 
1438 unsigned short StTriggerData2017::mtdVpdTacDiff() const
1439 {
1440  return (L1_DSM->TOF[3] & 0x3fff);
1441 }
1442 
1443 unsigned short StTriggerData2017::tofAtAddress(int address, int prepost) const
1444 {
1445  int buffer = prepostAddress(prepost);
1446  if (buffer>=0 && address>=0 && address<48) {
1447  if (mMIX[buffer]) return mMIX[buffer]->TOF[address];
1448  }
1449  return 0;
1450 }
1451 
1452 unsigned short StTriggerData2017::tofTrayMultiplicity(int tray, int prepost) const
1453 {
1454  int dsmmap[8] = {3,2,1,0,7,6,5,4};
1455  int traydsm[120] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5,
1456  5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
1457  3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1458  1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
1459  3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
1460  5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
1461  int traych[120] = { 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1462  2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1463  2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1464  18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1465  18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1466  18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17};
1467  int buffer = prepostAddress(prepost);
1468  if (buffer>=0 && tray>=1 && tray<=120) {
1469  if (mMIX[buffer]) {
1470  int address = traydsm[tray-1]*8 + dsmmap[traych[tray-1]/3];
1471  int ch = traych[tray-1]%3;
1472  return (mMIX[buffer]->TOF[address] >> (5*ch)) & 0x1f;
1473  }
1474  }
1475  return 0;
1476 }
1477 
1478 unsigned short StTriggerData2017::tofMultiplicity(int prepost) const
1479 {
1480  if (prepost==0) return L1_DSM->TOF[1]%8192;
1481  return 0;
1482 }
1483 
1484 void StTriggerData2017::dump() const
1485 {
1486  printf("***** StTriggerData Dump *****\n");
1487  printf(" mDebug=%d mData=%p\n",mDebug,mData);
1488  printf(" Year=%d Version=%x\n",year(),version());
1489  printf(" Run#=%d Event#=%d\n",mRun,eventNumber());
1490  printf(" %d pre and %d post crossing data available\n",numberOfPreXing(),numberOfPostXing());
1491  printf(" Token=%d TriggerWord=%x ActionWord=%x BusyStatus=%x\n",
1492  token(), triggerWord(), actionWord(), busyStatus());
1493  printf(" TUC Bits=%d : ",tcuBits());
1494  for (int i=0; i<16; i++) {printf(" %d",(tcuBits()>>(15-i))%2);}; printf("\n");
1495  printf(" BunchId 7bit=%d 48bit=%d\n",bunchId7Bit(), bunchId48Bit());
1496  printf(" Spin Bits=%d : ",spinBit());
1497  for (int i=0; i<8; i++) {printf(" %d",(spinBit()>>(7-i))%2);}; printf("\n");
1498  // printf(" CTB ADC : "); for (int i=0; i<240;i++){ printf("%d ",ctb(i,0)); }; printf("\n");
1499  printf(" BBC East ADC : "); for (int i=1; i<=24;i++){ printf("%d ",bbcADC(east,i,0)); }; printf("\n");
1500  printf(" BBC West ADC : "); for (int i=1; i<=24;i++){ printf("%d ",bbcADC(west,i,0)); }; printf("\n");
1501  printf(" BBC East TAC : "); for (int i=1; i<=16;i++){ printf("%d ",bbcTDC(east,i,0)); }; printf("\n");
1502  printf(" BBC West TAC : "); for (int i=1; i<=16;i++){ printf("%d ",bbcTDC(west,i,0)); }; printf("\n");
1503  for (int i=-numberOfPreXing(); i<=static_cast<int>(numberOfPostXing()); i++){
1504  printf(" BBC Sums %d xing : ",i);
1505  printf("East=%d West=%d Large tile East=%d West=%d\n",
1506  bbcADCSum(east,i),bbcADCSum(west,i),
1507  bbcADCSumLargeTile(east,i),bbcADCSumLargeTile(west,i));
1508  }
1509  printf(" BBC Earilest : "); printf("East=%d West=%d Difference+256=%d\n",
1510  bbcEarliestTDC(east,0),bbcEarliestTDC(west,0),bbcTimeDifference());
1511  printf(" ZDC Earilest : "); printf("East=%d West=%d Difference=%d\n",
1512  zdcEarliestTDC(east,0),zdcEarliestTDC(west,0),zdcTimeDifference());
1513  //printf(" FPD East North : ");for (int i=1; i<=49;i++){ printf("%d ",fpd(east,0,i,0)); }; printf("\n");
1514  //printf(" FPD East South : ");for (int i=1; i<=49;i++){ printf("%d ",fpd(east,1,i,0)); }; printf("\n");
1515  //printf(" FPD East Top : ");for (int i=1; i<=25;i++){ printf("%d ",fpd(east,2,i,0)); }; printf("\n");
1516  //printf(" FPD East Bottom : ");for (int i=1; i<=25;i++){ printf("%d ",fpd(east,3,i,0)); }; printf("\n");
1517  //printf(" FPD East North PS: ");for (int i=1; i<= 7;i++){ printf("%d ",fpd(east,4,i,0)); }; printf("\n");
1518  //printf(" FPD East South PS: ");for (int i=1; i<= 7;i++){ printf("%d ",fpd(east,5,i,0)); }; printf("\n");
1519  //printf(" FPD West South : ");for (int i=1; i<=49;i++){ printf("%d ",fpd(west,1,i,0)); }; printf("\n");
1520  //printf(" FPD West Bottom : ");for (int i=1; i<=25;i++){ printf("%d ",fpd(west,3,i,0)); }; printf("\n");
1521  //printf(" FPD West South PS: ");for (int i=1; i<= 7;i++){ printf("%d ",fpd(west,5,i,0)); }; printf("\n");
1522  //printf(" FPD Sums East : ");for (int j=0; j<4 ;j++) printf("%d ",fpdSum(east,j)); printf("\n");
1523  //printf(" FPD Sums West : ");for (int j=0; j<4 ;j++) printf("%d ",fpdSum(west,j)); printf("\n");
1524  printf(" ZDC Sum(A) East : ");printf("%d ",zdcAttenuated(east)); printf("\n");
1525  printf(" ZDC Sum(A) West : ");printf("%d ",zdcAttenuated(west)); printf("\n");
1526  printf(" ZDC Sum(UA) East : ");printf("%d ",zdcUnAttenuated(east)); printf("\n");
1527  printf(" ZDC Sum(UA) West : ");printf("%d ",zdcUnAttenuated(west)); printf("\n");
1528  printf(" VPD E Earliest TAC : %d\n", vpdEarliestTDC(east));
1529  printf(" VPD W Earliest TAC : %d\n", vpdEarliestTDC(west));
1530  printf(" VPD TimeDifference : %d\n", vpdTimeDifference());
1531  printf(" L2 result : \n");
1532  for (int j=0; j<4 ;j++) { for (int k=0; k<16; k++) {printf("%u ",*(l2Result()+j*16+k)); } printf("\n");}
1533  printf("BBClayer1:");
1534  int buffer = prepostAddress(0);
1535  if (buffer >=0){
1536  if (mBBC[buffer]){
1537  for (int i = 0;i < 16;i++) printf(" %1x %04X", i, mBBC[buffer]->BBClayer1[i]);
1538  }
1539  }
1540  printf("\n");
1541  printf("ZDClayer1:");
1542  if (buffer >=0){
1543  if (mBBC[buffer]){
1544  for (int i = 0;i < 8;i++) printf(" %1x %04X", i, mBBC[buffer]->ZDClayer1[i]);
1545  }
1546  }
1547  printf("\n");
1548  printf("VPDlayer1:");
1549  if (buffer >=0){
1550  if (mBBC[buffer]){
1551  for (int i = 0;i < 8;i++) printf(" %1x %04X", i, mBBC[buffer]->VPD[i]);
1552  }
1553  }
1554  printf("\n");
1555  printf("VTX:");
1556  if (L1_DSM){
1557  for (int i = 0;i < 8;i++) printf(" %1x %04X", i, L1_DSM->VTX[i]);
1558  }
1559  printf("\n");
1560  printf("Last DSM:");
1561  if (L1_DSM){
1562  for (int i = 0;i < 8;i++) printf(" %1x %04X", i, L1_DSM->lastDSM[i]);
1563  }
1564  printf("\n");
1565  printf("***** End StTriggerData Dump *****\n");
1566 }
1567 
1568 void StTriggerData2017::killFMS(){
1569  TrgOfflen2017* offlen;
1570  int npre = numberOfPreXing();
1571  int npost = numberOfPostXing();
1572  for (int i=0; i<1+npre+npost; i++){
1573  if (i==0)
1574  {offlen = mData->MainX;}
1575  else {
1576  if (mData->PrePostList[i-1]==0) continue;
1577  offlen = (TrgOfflen2017*) ((char*)mData + mData->PrePostList[i-1]);
1578  }
1579  int j;
1580  j=offlen[y17QT1_CONF_NUM].length; if (j>0){memset((char*)mData + offlen[y17QT1_CONF_NUM].offset, 0, j); offlen[y17QT1_CONF_NUM].length=0;};
1581  j=offlen[y17QT2_CONF_NUM].length; if (j>0){memset((char*)mData + offlen[y17QT2_CONF_NUM].offset, 0, j); offlen[y17QT2_CONF_NUM].length=0;};
1582  j=offlen[y17QT3_CONF_NUM].length; if (j>0){memset((char*)mData + offlen[y17QT3_CONF_NUM].offset, 0, j); offlen[y17QT3_CONF_NUM].length=0;};
1583  j=offlen[y17QT4_CONF_NUM].length; if (j>0){memset((char*)mData + offlen[y17QT4_CONF_NUM].offset, 0, j); offlen[y17QT4_CONF_NUM].length=0;};
1584  }
1585 }
1586 
1587 void StTriggerData2017::swapRawDet(DataBlock2017* data, int name, int hlength,int bs)
1588 {
1589  BELayerBlock2017* bc1;
1590  MIXBlock2017* mix;
1591  BBCBlock2017 *bbc;
1592  QTBlock2017* qtdata;
1593  int header_length = 8;
1594  if(bs) swapI((unsigned int*)&data->length);
1595  switch(name){
1596  case y17MXQ_CONF_NUM : case y17EPQ_CONF_NUM : case y17BBQ_CONF_NUM :
1597  case y17QT1_CONF_NUM : case y17QT2_CONF_NUM : case y17QT3_CONF_NUM : case y17QT4_CONF_NUM :
1598  case y17FQ1_CONF_NUM : case y17FQ2_CONF_NUM :
1599  header_length = 12; break;
1600  }
1601  if (hlength != data->length + header_length){
1602  mErrorFlag = mErrorFlag | (1 << name);
1603  printf("StTriggerData2017: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
1604  name,data->name[0],data->name[1],data->name[2],data->name[3],
1605  hlength,data->length,header_length);
1606  printf("StTriggerData2017: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
1607  name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
1608  data=0;
1609  return;
1610  }
1611  if (bs){
1612  switch(name){
1613  case y17BC1_CONF_NUM :
1614  bc1 = (BELayerBlock2017*) data;
1615  swapSSn((unsigned int*)bc1->BEMClayer1,48);
1616  swapSSn((unsigned int*)bc1->EEMClayer1,16);
1617  break;
1618  case y17MIX_CONF_NUM :
1619  mix = (MIXBlock2017*) data;
1620  swapSSn((unsigned int*)mix->FPDEastNSLayer1,8);
1621  swapSSn((unsigned int*)mix->TOFLayer1,8+48);
1622  break;
1623  case y17BCW_CONF_NUM :
1624  //only char
1625  break;
1626  case y17BCE_CONF_NUM :
1627  //only char
1628  break;
1629  case y17BBC_CONF_NUM :
1630  bbc = (BBCBlock2017*) data;
1631  swapSSn((unsigned int*)bbc->BBClayer1,16+8+8);
1632  break;
1633  case y17FMS_CONF_NUM :
1634  //only char
1635  break;
1636  case y17MXQ_CONF_NUM :
1637  case y17EPQ_CONF_NUM :
1638  case y17BBQ_CONF_NUM :
1639  case y17QT1_CONF_NUM :
1640  case y17QT2_CONF_NUM :
1641  case y17QT3_CONF_NUM :
1642  case y17QT4_CONF_NUM :
1643  case y17FQ1_CONF_NUM :
1644  case y17FQ2_CONF_NUM :
1645  qtdata = (QTBlock2017*) data;
1646  swapI((unsigned int*)&qtdata->dataLoss);
1647  swapIn(qtdata->data, qtdata->length/4);
1648  break;
1649  }
1650  }
1651  if(mDebug>0)
1652  printf("Read id=%2d name=%1c%1c%1c%1c length=%d\n",
1653  name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
1654 }
1655 
1656 void StTriggerData2017::Streamer(TBuffer &R__b)
1657 {
1658  // Stream an object of class StTriggerData2017.
1659 
1660  if (R__b.IsReading()) {
1661  R__b.ReadClassBuffer(StTriggerData2017::Class(),this);
1662  // cout << "StTriggerData2017::Streamer read trigger data!!!"<<endl;
1663  if(mData) readData();
1664  }
1665  else {
1666  R__b.WriteClassBuffer(StTriggerData2017::Class(),this);
1667  }
1668 }