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