27 #include "StTriggerData2018.h"
40 mYear=2018; mRun = run; mDebug = 0;
47 mYear=2018; mRun = run; mDebug = dbg;
48 if(mDebug==1) printf(
"StTriggerData2018 Constructor with trigger data block and byteswap option=%d\n",bs);
53 void StTriggerData2018::blindRunInfo()
55 mRun=1000000*int(mRun/1000000);
56 mData->eventNumber = 0;
57 EvtDesc->bunchXing_hi = 0;
58 EvtDesc->bunchXing_lo = 0;
59 L1_DSM->BCdata[2] = 0;
60 L1_DSM->BCdata[3] = 0;
61 L1_DSM->BCdata[10] = 0;
62 L1_DSM->BCdata[11] = 0;
67 if (data==0) {copyflag=0;}
68 if(mDebug==1) printf(
"StTriggerData2018::readData copyflag=%d byteswap=%d data=%p mData=%p\n",copyflag,bs,data,mData);
71 unsigned int ver = data->FormatVersion;
74 if (ver == y18FORMAT_VERSION ) {
75 if (mDebug==1) printf(
"StTriggerData2018: version = 0x%x (0x%x or 0x08121140)\n",ver,y18FORMAT_VERSION);
78 mErrorFlag = mErrorFlag | 0x1;
79 printf(
"StTriggerData2018: version = 0x%x != (0x%x)\n",ver,y18FORMAT_VERSION);
83 unsigned int size = data->totalTriggerLength;
85 if (size > y18MAX_TRG_BLK_SIZE) {
86 gMessMgr->Warning() <<
"StTriggerData2018: Data length = " << size
87 <<
" is bigger than max = " << y18MAX_TRG_BLK_SIZE
91 if (mDebug==1) printf(
"StTriggerData2018: size = %d, maxsize = %d\n",size,y18MAX_TRG_BLK_SIZE);
92 memcpy(mData,data,size);
96 if (bs) swapDataBlk(mData);
98 printf(
"StTriggerData2018: version = 0x%x (0x%x)\n",mData->FormatVersion,y18FORMAT_VERSION);
99 printf(
"StTriggerData2018: size = %d, maxsize = %d\n",mData->totalTriggerLength,y18MAX_TRG_BLK_SIZE);
100 printf(
"EventDesc length=%10d offset=%10d\n",mData->EventDesc_ofl.length,mData->EventDesc_ofl.offset);
101 printf(
"L1_DSM length=%10d offset=%10d\n",mData->L1_DSM_ofl.length,mData->L1_DSM_ofl.offset);
102 printf(
"Summary length=%10d offset=%10d\n",mData->Summary_ofl.length,mData->Summary_ofl.offset);
105 EvtDesc=0; L1_DSM=0; TrgSum=0;
106 if (mData->EventDesc_ofl.length > 0) EvtDesc = (
EvtDescData2018*)((
char*)mData + mData->EventDesc_ofl.offset);
107 if (mData->L1_DSM_ofl.length > 0) L1_DSM = (
L1_DSM_Data2018*)((
char*)mData + mData->L1_DSM_ofl.offset);
108 if (mData->Summary_ofl.length > 0) TrgSum = (
TrgSumData2018* )((
char*)mData + mData->Summary_ofl.offset);
110 if (EvtDesc) swapEvtDesc(EvtDesc);
111 if (L1_DSM) swapL1_DSM(L1_DSM);
112 if (TrgSum) swapTrgSum(TrgSum);
114 if (EvtDesc==0 || L1_DSM==0 || TrgSum==0){
115 mErrorFlag = mErrorFlag | 0x1;
116 gMessMgr->Warning() <<
"StTriggerData2018: EvtDesc, L1_DSM or TrgSum is missing"
117 <<
" mErrorFlag="<<mErrorFlag<<endm;
120 int npre = numberOfPreXing();
121 int npost = numberOfPostXing();
122 if (npre<0 || npre>10 || npost<0 || npost>10){
123 mErrorFlag = mErrorFlag | 0x2;
124 gMessMgr->Warning() <<
"StTriggerData2018: Invalid npre/post = "<< npre <<
" / " << npost
125 <<
" mErrorFlag="<<mErrorFlag<<endm;
127 if (mDebug==1) printf(
"StTriggerData2018: pre=%d post=%d\n",npre,npost);
129 memset(mBC1,0,
sizeof(mBC1));
130 memset(mMXQ,0,
sizeof(mMXQ));
131 memset(mMIX,0,
sizeof(mMIX));
132 memset(mBCW,0,
sizeof(mBCW));
133 memset(mBCE,0,
sizeof(mBCE));
134 memset(mEQ3,0,
sizeof(mEQ3));
135 memset(mBBC,0,
sizeof(mBBC));
136 memset(mBBQ,0,
sizeof(mBBQ));
137 memset(mFMS,0,
sizeof(mFMS));
138 memset(mQT1,0,
sizeof(mQT1));
139 memset(mQT2,0,
sizeof(mQT2));
140 memset(mQT3,0,
sizeof(mQT3));
141 memset(mQT4,0,
sizeof(mQT4));
142 memset(mEQ1,0,
sizeof(mEQ1));
143 memset(mEQ2,0,
sizeof(mEQ2));
144 memset(mxq,0,
sizeof(mxq)); memset(tmxq,0,
sizeof(tmxq));
145 memset(eq3,0,
sizeof(eq3)); memset(teq3,0,
sizeof(teq3));
146 memset(bbq,0,
sizeof(bbq)); memset(tbbq,0,
sizeof(tbbq));
147 memset(qt1,0,
sizeof(qt1)); memset(tqt1,0,
sizeof(tqt1));
148 memset(qt2,0,
sizeof(qt2)); memset(tqt2,0,
sizeof(tqt2));
149 memset(qt3,0,
sizeof(qt3)); memset(tqt3,0,
sizeof(tqt3));
150 memset(qt4,0,
sizeof(qt4)); memset(tqt4,0,
sizeof(tqt4));
151 memset(eq1,0,
sizeof(eq1)); memset(teq1,0,
sizeof(teq1));
152 memset(eq2,0,
sizeof(eq2)); memset(teq2,0,
sizeof(teq2));
155 for (
int i=0; i<1+npre+npost; i++) {
158 offlen = mData->MainX;
162 if (mData->PrePostList[i-1]==0)
continue;
163 offlen = (
TrgOfflen2018*) ((
char*)mData + mData->PrePostList[i-1]);
165 if (bs) swapRawDetOfflen(offlen);
166 for(
int k=0; k<y18MAX_OFFLEN; k++) {
167 if(static_cast<unsigned int>(offlen[k].length + offlen[k].offset) > static_cast<unsigned int>(mData->totalTriggerLength)) {
168 mErrorFlag = mErrorFlag | (1 << k);
169 gMessMgr->Warning() <<
"StTriggerData2018: offset ("<<offlen[k].offset<<
") + length ("<<offlen[k].length
170 <<
") exceeds total size("<<mData->totalTriggerLength<<
") for data block id="<<k
171 <<
" mErrorFlag="<<mErrorFlag<<endm;
175 j=offlen[y18BC1_CONF_NUM].length;
if (j>0){mBC1[i] = (
BELayerBlock2018*)((
char*)mData + offlen[y18BC1_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mBC1[i],y18BC1_CONF_NUM,j,bs);}
176 j=offlen[y18MXQ_CONF_NUM].length;
if (j>0){mMXQ[i] = (
QTBlock2018* )((
char*)mData + offlen[y18MXQ_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mMXQ[i],y18MXQ_CONF_NUM,j,bs);}
177 j=offlen[y18MIX_CONF_NUM].length;
if (j>0){mMIX[i] = (
MIXBlock2018* )((
char*)mData + offlen[y18MIX_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mMIX[i],y18MIX_CONF_NUM,j,bs);}
178 j=offlen[y18BCW_CONF_NUM].length;
if (j>0){mBCW[i] = (
BWestBlock2018* )((
char*)mData + offlen[y18BCW_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mBCW[i],y18BCW_CONF_NUM,j,bs);}
179 j=offlen[y18BCE_CONF_NUM].length;
if (j>0){mBCE[i] = (
BEastBlock2018* )((
char*)mData + offlen[y18BCE_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mBCE[i],y18BCE_CONF_NUM,j,bs);}
180 j=offlen[y18EQ3_CONF_NUM].length;
if (j>0){mEQ3[i] = (
QTBlock2018* )((
char*)mData + offlen[y18EQ3_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mEQ3[i],y18EQ3_CONF_NUM,j,bs);}
181 j=offlen[y18BBC_CONF_NUM].length;
if (j>0){mBBC[i] = (
BBCBlock2018* )((
char*)mData + offlen[y18BBC_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mBBC[i],y18BBC_CONF_NUM,j,bs);}
182 j=offlen[y18BBQ_CONF_NUM].length;
if (j>0){mBBQ[i] = (
QTBlock2018* )((
char*)mData + offlen[y18BBQ_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mBBQ[i],y18BBQ_CONF_NUM,j,bs);}
183 j=offlen[y18FMS_CONF_NUM].length;
if (j>0){mFMS[i] = (
FMSBlock2018* )((
char*)mData + offlen[y18FMS_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mFMS[i],y18FMS_CONF_NUM,j,bs);}
184 j=offlen[y18QT1_CONF_NUM].length;
if (j>0){mQT1[i] = (
QTBlock2018* )((
char*)mData + offlen[y18QT1_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mQT1[i],y18QT1_CONF_NUM,j,bs);}
185 j=offlen[y18QT2_CONF_NUM].length;
if (j>0){mQT2[i] = (
QTBlock2018* )((
char*)mData + offlen[y18QT2_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mQT2[i],y18QT2_CONF_NUM,j,bs);}
186 j=offlen[y18QT3_CONF_NUM].length;
if (j>0){mQT3[i] = (
QTBlock2018* )((
char*)mData + offlen[y18QT3_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mQT3[i],y18QT3_CONF_NUM,j,bs);}
187 j=offlen[y18QT4_CONF_NUM].length;
if (j>0){mQT4[i] = (
QTBlock2018* )((
char*)mData + offlen[y18QT4_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mQT4[i],y18QT4_CONF_NUM,j,bs);}
188 j=offlen[y18EQ1_CONF_NUM].length;
if (j>0){mEQ1[i] = (
QTBlock2018* )((
char*)mData + offlen[y18EQ1_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mEQ1[i],y18EQ1_CONF_NUM,j,bs);}
189 j=offlen[y18EQ2_CONF_NUM].length;
if (j>0){mEQ2[i] = (
QTBlock2018* )((
char*)mData + offlen[y18EQ2_CONF_NUM].offset); swapRawDet((
DataBlock2018*)mEQ2[i],y18EQ2_CONF_NUM,j,bs);}
190 if (mMXQ[i]) decodeQT(mMXQ[i]->length/4, mMXQ[i]->data, mxq[i], tmxq[i]);
191 if (mEQ3[i]) decodeQT(mEQ3[i]->length/4, mEQ3[i]->data, eq3[i], teq3[i]);
192 if (mBBQ[i]) decodeQT(mBBQ[i]->length/4, mBBQ[i]->data, bbq[i], tbbq[i]);
193 if (mQT1[i]) decodeQT(mQT1[i]->length/4, mQT1[i]->data, qt1[i], tqt1[i]);
194 if (mQT2[i]) decodeQT(mQT2[i]->length/4, mQT2[i]->data, qt2[i], tqt2[i]);
195 if (mQT3[i]) decodeQT(mQT3[i]->length/4, mQT3[i]->data, qt3[i], tqt3[i]);
196 if (mQT4[i]) decodeQT(mQT4[i]->length/4, mQT4[i]->data, qt4[i], tqt4[i]);
197 if (mEQ1[i]) decodeQT(mEQ1[i]->length/4, mEQ1[i]->data, eq1[i], teq1[i]);
198 if (mEQ2[i]) decodeQT(mEQ2[i]->length/4, mEQ2[i]->data, eq2[i], teq2[i]);
200 if (mDebug==1) dump();
203 StTriggerData2018::~StTriggerData2018() {
delete mData;}
205 unsigned int StTriggerData2018::version()
const
207 return EvtDesc->TrgDataFmtVer;
210 unsigned int StTriggerData2018::eventNumber()
const
212 return mData->eventNumber;
215 unsigned int StTriggerData2018::token()
const
217 return EvtDesc->TrgToken;
220 unsigned int StTriggerData2018::triggerWord()
const
225 unsigned int StTriggerData2018::actionWord()
const
228 ( (
unsigned short)(EvtDesc->actionWdTrgCommand) * 16 * 16 * 16 ) +
229 ( (
unsigned short)(EvtDesc->actionWdDaqCommand) * 16 * 16 ) +
230 ( EvtDesc->actionWdDetectorBitMask & 0x00ff );
233 unsigned int StTriggerData2018::numberOfPreXing()
const
235 return EvtDesc->npre & 0xf;
238 unsigned int StTriggerData2018::numberOfPostXing()
const
240 return EvtDesc->npost & 0xf;
243 unsigned short StTriggerData2018::busyStatus()
const
245 return EvtDesc->internalBusy;
248 unsigned short StTriggerData2018::dsmInput()
const
250 return EvtDesc->DSMInput;
253 unsigned short StTriggerData2018::trgToken()
const
255 return EvtDesc->TrgToken;
258 unsigned short StTriggerData2018::dsmAddress()
const
260 return EvtDesc->DSMAddress;
263 unsigned short StTriggerData2018::mAddBits()
const
265 return EvtDesc->addBits;
268 unsigned short StTriggerData2018::bcData(
int channel)
const
270 return L1_DSM->BCdata[channel];
273 unsigned short StTriggerData2018::getTrgDetMask()
const
275 return EvtDesc->trgDetMask;
278 unsigned int StTriggerData2018::getTrgCrateMask()
const
280 unsigned int p = EvtDesc->npost & 0xfff0;
281 unsigned int r = EvtDesc->res1 & 0x0ff0;
283 ( ((EvtDesc->npre & 0xfff0) >> 4)
288 unsigned short StTriggerData2018::lastDSM(
int channel)
const
290 return L1_DSM->lastDSM[channel];
294 unsigned short StTriggerData2018::vertexDSM(
int channel)
const
296 int dsmmap[8] = {3,2,1,0,7,6,5,4};
297 if(channel<0 || channel>7)
return 0;
298 return L1_DSM->VTX[dsmmap[channel]];
301 unsigned short StTriggerData2018::tcuBits()
const
303 return EvtDesc->DSMInput;
307 unsigned int StTriggerData2018::tcuCounter()
const
309 unsigned int hi = EvtDesc->tcuCtrBunch_hi;
310 return (hi << 16) + EvtDesc->DSMAddress;
313 unsigned int StTriggerData2018::rccCounter(
int crate)
const
315 if(crate >= y18L1_CONF_NUM && crate <= y18EQ2_CONF_NUM){
316 return TrgSum->LocalClocks[crate];
321 unsigned long long StTriggerData2018::bunchCounter()
const
323 unsigned long long bxinghi,bxing1,bxinglo, bx;
324 bxinghi = L1_DSM->BCdata[3];
325 bxing1 = L1_DSM->BCdata[10];
326 bxinglo = (bxing1 << 16) + L1_DSM->BCdata[11];
327 bx = (bxinghi << 32) + bxinglo;
331 unsigned int StTriggerData2018::bunchCounterHigh()
const
333 return EvtDesc->bunchXing_hi;
336 unsigned int StTriggerData2018::bunchCounterLow()
const
338 return EvtDesc->bunchXing_lo;
341 unsigned int StTriggerData2018::bunchId48Bit()
const
343 return (
int)(bunchCounter() % 120);
346 unsigned int StTriggerData2018::bunchId7Bit()
const
349 b7dat = L1_DSM->BCdata[2];
354 unsigned int StTriggerData2018::spinBit()
const
357 return (L1_DSM->lastDSM[7]/16)%256;
359 return (L1_DSM->lastDSM[4]/16)%256;
363 unsigned int StTriggerData2018::spinBitYellowFilled()
const
365 unsigned int sb = spinBit();
369 unsigned int StTriggerData2018::spinBitYellowUp()
const
371 unsigned int sb = spinBit();
375 unsigned int StTriggerData2018::spinBitYellowDown()
const
377 unsigned int sb = spinBit();
381 unsigned int StTriggerData2018::spinBitYellowUnpol()
const
383 unsigned int sb = spinBit();
387 unsigned int StTriggerData2018::spinBitBlueFilled()
const
389 unsigned int sb = spinBit();
393 unsigned int StTriggerData2018::spinBitBlueUp()
const
395 unsigned int sb = spinBit();
399 unsigned int StTriggerData2018::spinBitBlueDown()
const
401 unsigned int sb = spinBit();
405 unsigned int StTriggerData2018::spinBitBlueUnpol()
const
407 unsigned int sb = spinBit();
411 unsigned short StTriggerData2018::bbcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
413 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
414 4, 4, 4, 4, 4, 4, 4, 4},
415 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 4, 4, 4, 4, 4, 4, 4, 4} };
417 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
418 0, 1, 2, 3, 8, 9,10,11},
419 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
420 16,17,18,19,24,25,26,27} };
421 int buffer = prepostAddress(prepost);
422 if (buffer >= 0 && pmt>=1 && pmt<=16)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
426 unsigned short StTriggerData2018::bbcTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
428 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
429 4, 4, 4, 4, 4, 4, 4, 4},
430 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 4, 4, 4, 4, 4, 4, 4, 4} };
432 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
433 0, 1, 2, 3, 8, 9,10,11},
434 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
435 16,17,18,19,24,25,26,27} };
436 int buffer = prepostAddress(prepost);
437 if (buffer >= 0 && pmt>=1 && pmt<=16)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]+4];
441 unsigned short StTriggerData2018::bbcTDC5bit(StBeamDirection eastwest,
int pmt,
int prepost)
const
443 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
444 4, 4, 4, 4, 4, 4, 4, 4},
445 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 4, 4, 4, 4, 4, 4, 4, 4} };
447 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
448 0, 1, 2, 3, 8, 9,10,11},
449 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
450 16,17,18,19,24,25,26,27} };
451 int buffer = prepostAddress(prepost);
452 if (buffer >= 0 && pmt>=1 && pmt<=16)
return tbbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
456 unsigned short StTriggerData2018::bbcADCSum(StBeamDirection eastwest,
int prepost)
const
458 unsigned short sum=0;
459 int buffer = prepostAddress(prepost);
463 if(eastwest==east) { sum = mBBC[buffer]->BBClayer1[3]; }
464 else { sum = mBBC[buffer]->BBClayer1[1]; }
470 unsigned short StTriggerData2018::bbcADCSumLargeTile(StBeamDirection eastwest,
int prepost)
const
472 unsigned short sum=0;
478 unsigned short StTriggerData2018::bbcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
480 int buffer = prepostAddress(prepost);
483 if (eastwest==east) {
return mBBC[buffer]->BBClayer1[2]%4096;}
484 else {
return mBBC[buffer]->BBClayer1[0]%4096;}
490 unsigned short StTriggerData2018::bbcTimeDifference()
const
492 return L1_DSM->VTX[3]%8192;
495 unsigned short StTriggerData2018::bbcTacSum()
const
497 return (((L1_DSM->VTX[3]) >> 13) & 0x1);
500 unsigned short StTriggerData2018::bbcEarliestTDCLarge(StBeamDirection eastwest,
int prepost)
const
513 unsigned short StTriggerData2018::bbcTimeDifferenceLarge()
const
515 return L1_DSM->VTX[2]%8192;
519 unsigned short StTriggerData2018::bbcBB101(
int ch,
int prepost)
const
521 int dsmmap[8] = {3,2,1,0,7,6,5,4};
522 int buffer = prepostAddress(prepost);
525 if(ch>=0 && ch<=7)
return mBBC[buffer]->BBClayer1[dsmmap[ch]];
531 unsigned short StTriggerData2018::bbcBB102(
int ch,
int prepost)
const
533 int dsmmap[8] = {3,2,1,0,7,6,5,4};
534 int buffer = prepostAddress(prepost);
537 if(ch>=0 && ch<=7)
return mBBC[buffer]->BBClayer1[dsmmap[ch]+8];
543 unsigned short StTriggerData2018::epdTimeDifference()
const
545 return L1_DSM->VTX[6]%8192;
548 bool StTriggerData2018::epdHitLayer2(StBeamDirection eastwest)
const
550 if(eastwest==east)
return (L1_DSM->VTX[6] & 0x40) ?
true :
false;
551 return (L1_DSM->VTX[6] & 0x80) ?
true :
false;
554 unsigned short StTriggerData2018::epdLayer0t(
int ch,
int prepost)
const
556 int dsmmap[16] = {3,2,1,0,7,6,5,4, 11,10,9,8,15,14,13,12};
557 int buffer = prepostAddress(prepost);
560 if(ch>=0 && ch<16)
return mBBC[buffer]->EPDlayer0t[dsmmap[ch]];
566 unsigned short StTriggerData2018::epdLayer1(
int ch,
int prepost)
const
568 int dsmmap[8] = {3,2,1,0,7,6,5,4};
569 int buffer = prepostAddress(prepost);
572 if(ch>=0 && ch<8)
return mBBC[buffer]->EPDlayer1[dsmmap[ch]];
578 unsigned short StTriggerData2018::epdNHits(StBeamDirection eastwest,
int prepost)
const
580 int buffer = prepostAddress(prepost);
583 unsigned short dsmEP001OutR = epdLayer1(0, 0);
584 unsigned short dsmEP001OutL = epdLayer1(1, 0);
585 unsigned int dsmEP001Out = (dsmEP001OutL<<16) + dsmEP001OutR;
586 return (dsmEP001Out >> 24) & 0xff;
588 unsigned short dsmEP002OutR = epdLayer1(2, 0);
589 unsigned short dsmEP002OutL = epdLayer1(3, 0);
590 unsigned int dsmEP002Out = (dsmEP002OutL<<16) + dsmEP002OutR;
591 return (dsmEP002Out >> 24) & 0xff;
598 unsigned short StTriggerData2018::epdLayer0a(
int ch,
int prepost)
const
600 int dsmmap[16] = {3,2,1,0,7,6,5,4};
601 int buffer = prepostAddress(prepost);
604 if(ch>=0 && ch<8)
return mBBC[buffer]->EPDlayer0a[dsmmap[ch]];
610 unsigned short StTriggerData2018::fpd(StBeamDirection eastwest,
int module,
int pmt,
int prepost)
const
615 unsigned short StTriggerData2018::fpdSum(StBeamDirection eastwest,
int module)
const
620 unsigned short StTriggerData2018::fpdLayer1DSMRaw(StBeamDirection eastwest,
int channel,
int prepost)
const{
621 int buffer = prepostAddress(prepost);
623 if (eastwest==east) {
if (mMIX[buffer])
return mMIX[buffer]->FPDEastNSLayer1[channel]; }
624 else {
if (mFMS[buffer])
return mFMS[buffer]->FMS[channel]; }
629 unsigned short StTriggerData2018::fpdLayer2DSMRaw(
int channel)
const{
630 if (channel<8)
return L1_DSM->FPD[channel];
634 bool StTriggerData2018::zdcPresent(
int prepost)
const
636 int buffer = prepostAddress(prepost);
637 if (buffer >= 0)
return mBBQ[buffer];
641 unsigned short StTriggerData2018::zdcAtChannel(
int channel,
int prepost)
const
643 int buffer = prepostAddress(prepost);
644 if (buffer >= 0 && channel>=0 && channel<32)
return bbq[buffer][14][channel];
648 unsigned short StTriggerData2018::zdcAtAddress(
int address,
int prepost)
const
650 return zdcAtChannel(address,prepost);
653 unsigned short StTriggerData2018::zdcUnAttenuated(StBeamDirection eastwest,
int prepost)
const
655 int buffer = prepostAddress(prepost);
657 if (eastwest == east)
return bbq[buffer][14][2];
658 else return bbq[buffer][14][18];
663 unsigned short StTriggerData2018::zdcAttenuated(StBeamDirection eastwest,
int prepost)
const
665 int buffer = prepostAddress(prepost);
667 if (eastwest == east)
return bbq[buffer][14][3];
668 else return bbq[buffer][14][19];
673 unsigned short StTriggerData2018::zdcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
675 int buffer = prepostAddress(prepost);
676 if (buffer >= 0 && pmt>=1 && pmt<=3) {
677 if (eastwest == east) {
678 if (pmt == 1)
return bbq[buffer][14][0];
679 if (pmt == 2)
return bbq[buffer][14][8];
680 if (pmt == 3)
return bbq[buffer][14][9];
683 if (pmt == 1)
return bbq[buffer][14][16];
684 if (pmt == 2)
return bbq[buffer][14][24];
685 if (pmt == 3)
return bbq[buffer][14][25];
691 unsigned short StTriggerData2018::zdcTDC(StBeamDirection eastwest,
int prepost)
const
693 int buffer = prepostAddress(prepost);
695 if (eastwest == east)
return bbq[buffer][14][6];
696 else return bbq[buffer][14][22];
701 unsigned short StTriggerData2018::zdcPmtTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
703 int buffer = prepostAddress(prepost);
704 if (buffer >= 0 && pmt>=1 && pmt<=3) {
705 if (eastwest == east) {
706 if (pmt == 1)
return bbq[buffer][14][4];
707 if (pmt == 2)
return bbq[buffer][14][12];
708 if (pmt == 3)
return bbq[buffer][14][13];
711 if (pmt == 1)
return bbq[buffer][14][20];
712 if (pmt == 2)
return bbq[buffer][14][28];
713 if (pmt == 3)
return bbq[buffer][14][29];
719 unsigned short StTriggerData2018::zdcHardwareSum(
int prepost)
const
721 int buffer = prepostAddress(prepost);
722 if (buffer >= 0)
return bbq[buffer][14][11];
726 bool StTriggerData2018::zdcSMDPresent(
int prepost)
const
728 int buffer = prepostAddress(prepost);
729 if (buffer >= 0)
return mMXQ[buffer];
733 unsigned short StTriggerData2018::zdcSMD(StBeamDirection eastwest,
int verthori,
int strip,
int prepost)
const
735 static const int zdcsmd_map[2][2][8] ={
736 { { 31, 30, 29, 28, 27, 26, 25, 19} ,
737 { 24, 23, 22, 21, 20, 16, 18, 17} } ,
738 { { 15, 14, 13, 12, 11, 10, 9, 2} ,
739 { 8, 7, 6, 5, 4, 3, 0, 1} }
741 static const int zdcsmd_map2011[2][2][8] ={
742 { {24, 25, 26, 27, 28, 29, 30, 31} ,
743 {16, 17, 18, 19, 20, 21, 22, 23} } ,
744 { {8, 9, 10, 11, 12, 13, 14, 15} ,
745 {0, 1, 2, 3, 4, 5, 6, 7} }
747 if (verthori<0 || verthori>1)
return 0;
748 if (strip<1 || strip>8)
return 0;
749 int buffer = prepostAddress(prepost);
752 return mxq[buffer][4][zdcsmd_map[eastwest][verthori][strip-1]];
754 return mxq[buffer][4][zdcsmd_map2011[eastwest][verthori][strip-1]];
760 unsigned short StTriggerData2018::zdcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
762 int buffer = prepostAddress(prepost);
766 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 12) % 16) | ((mBBC[buffer]->ZDClayer1[2] % 256) << 4);}
767 else {
return (mBBC[buffer]->ZDClayer1[3]) % 4096;}
769 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 10) % 64) | ((mBBC[buffer]->ZDClayer1[2] % 16) << 6);}
770 else {
return (mBBC[buffer]->ZDClayer1[3]) % 1024;}
777 bool StTriggerData2018::zdcSumADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
778 int buffer = prepostAddress(prepost);
782 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (27-16));}
783 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
785 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
786 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (22-16));}
793 bool StTriggerData2018::zdcFrontADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
794 int buffer = prepostAddress(prepost);
798 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (29-16));}
799 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (26-16));}
801 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (23-16));}
802 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (20-16));}
809 bool StTriggerData2018::zdcBackADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
810 int buffer = prepostAddress(prepost);
814 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (28-16));}
815 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
817 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
818 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (21-16));}
825 unsigned short StTriggerData2018::zdcTimeDifference()
const
827 return L1_DSM->VTX[1]%256;
830 bool StTriggerData2018::zdcSumADCaboveThresholdL2(StBeamDirection eastwest)
const {
831 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 10 : 11));
834 bool StTriggerData2018::zdcFrontADCaboveThresholdL2(StBeamDirection eastwest)
const {
835 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 12 : 14));
838 bool StTriggerData2018::zdcBackADCaboveThresholdL2(StBeamDirection eastwest)
const {
839 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 13 : 15));
842 bool StTriggerData2018::zdcSumADCaboveThresholdL3(StBeamDirection eastwest)
const {
843 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 7 : 8)); }
844 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 7 : 8)); }
847 bool StTriggerData2018::zdcFrontADCaboveThresholdL3(StBeamDirection eastwest)
const {
848 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 9 : 11)); }
849 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 9 : 11)); }
852 bool StTriggerData2018::zdcBackADCaboveThresholdL3(StBeamDirection eastwest)
const {
853 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 10 : 12)); }
854 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 10 : 12)); }
857 bool StTriggerData2018::zdcTimeDifferenceInWindow()
const
859 if(mRun<12000000){
return lastDSM(2) & (1 << 6); }
860 else {
return lastDSM(1) & (1 << 6); }
863 unsigned short StTriggerData2018::zdcSMDHighestStrip(StBeamDirection eastwest,
int verthori,
int prepost)
const
865 if(mRun<12000000)
return 0;
867 int buffer = prepostAddress(prepost);
870 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 6 : 9)) % 8;}
871 else {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 0 : 3)) % 8;}
877 unsigned short StTriggerData2018::zdcTruncatedSum(StBeamDirection eastwest,
int prepost)
const
879 if(mRun<12000000)
return 0;
880 int buffer = prepostAddress(prepost);
883 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[2] >> (26-16)) % 8;}
884 else {
return (mBBC[buffer]->ZDClayer1[2] >> (29-16)) % 8;}
890 unsigned short StTriggerData2018::pp2ppADC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
892 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
893 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
894 if (vh<0 || vh>1)
return 0;
895 if (udio<0 || udio>1)
return 0;
896 if (ch<0 || ch>1)
return 0;
897 int buffer = prepostAddress(prepost);
898 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]];
902 unsigned short StTriggerData2018::pp2ppTAC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
904 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
905 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
906 if (vh<0 || vh>1)
return 0;
907 if (udio<0 || udio>1)
return 0;
908 if (ch<0 || ch>1)
return 0;
909 int buffer = prepostAddress(prepost);
910 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]+4];
914 unsigned long StTriggerData2018::pp2ppDSM(
int prepost)
const {
915 if (prepost!=0)
return 0;
916 return L1_DSM->TOF[7];
919 unsigned short StTriggerData2018::bemcLayer1DSM(
int channel,
int prepost)
const {
920 const int n_bemc_layer1=48;
921 if (channel<0 || channel >=n_bemc_layer1) {
922 gMessMgr->Warning() <<
"Barrel DSM layer 1 out of range (" << channel <<
")" << endm;
925 int buffer = prepostAddress(prepost);
926 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1[channel];
930 unsigned short StTriggerData2018::eemcLayer1DSM(
int channel,
int prepost)
const {
931 const int n_eemc_layer1=16;
932 if (channel<0 || channel >=n_eemc_layer1) {
933 gMessMgr->Warning() <<
"Endap DSM layer 1 out of range (" << channel <<
")" << endm;
936 int buffer = prepostAddress(prepost);
937 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1[channel];
941 unsigned short StTriggerData2018::emcLayer2DSM(
int channel)
const {
942 const int n_emc_layer2=8;
943 if (channel<0 || channel >=n_emc_layer2) {
944 gMessMgr->Warning() <<
"EMC DSM layer 2 out of range (" << channel <<
")" << endm;
947 return L1_DSM->EMC[channel];
950 unsigned short StTriggerData2018::tpcMaskDSM(
int channel)
const {
951 const int n_tpcMask=8;
952 if (channel<0 || channel >=n_tpcMask) {
953 gMessMgr->Warning() <<
"TPCMask DSM out of range (" << channel <<
")" << endm;
956 return L1_DSM->TPCMask[channel];
959 unsigned char StTriggerData2018::bemcHighTower(
int patch_id,
int prepost)
const {
961 const int m_max_patch=300;
962 if ( patch_id < 0 || patch_id >= m_max_patch) {
963 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
966 int buffer = prepostAddress(prepost);
969 int channel=patch_id%10;
970 unsigned short trg_word;
973 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
979 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
983 return trg_word & 0x3F;
988 unsigned char StTriggerData2018::bemcJetPatch (
int patch_id,
int prepost)
const
991 const int m_max_patch=300;
992 if ( patch_id < 0 || patch_id >= m_max_patch) {
993 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
996 int buffer = prepostAddress(prepost);
999 int channel=patch_id%10;
1000 unsigned short trg_word;
1003 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
1009 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
1013 return trg_word >> 6;
1019 unsigned char StTriggerData2018::eemcHighTower(
int patch_id,
int prepost)
const
1022 const int m_max_patch=90;
1023 if ( patch_id < 0 || patch_id >= m_max_patch) {
1024 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
1027 int buffer = prepostAddress(prepost);
1028 if (buffer >= 0 && mBC1[buffer]) {
1029 int dsm=patch_id/10;
1030 int channel=patch_id%10;
1031 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
1032 return trg_word & 0x3F;
1037 unsigned char StTriggerData2018::eemcJetPatch (
int patch_id,
int prepost)
const
1040 const int m_max_patch=90;
1041 if ( patch_id < 0 || patch_id >= m_max_patch) {
1042 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
1045 int buffer = prepostAddress(prepost);
1046 if (buffer >= 0 && mBC1[buffer]) {
1047 int dsm=patch_id/10;
1048 int channel=patch_id%10;
1049 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
1050 return trg_word >> 6;
1055 unsigned char StTriggerData2018::bemcHighestTowerADC(
int prepost)
const {
1057 const int m_max_patch=300;
1059 for (
int i=1; i<m_max_patch; i++){
1060 unsigned char hh=bemcHighTower(i,prepost);
1066 unsigned char StTriggerData2018::eemcHighestTowerADC(
int prepost)
const {
1068 const int m_max_patch=90;
1070 for (
int i=1; i<m_max_patch; i++){
1071 unsigned char hh=eemcHighTower(i,prepost);
1077 char* StTriggerData2018::getTriggerStructure()
1079 return (
char*) mData;
1087 int StTriggerData2018::getRawSize()
const
1089 return mData->totalTriggerLength;
1092 unsigned char* StTriggerData2018::getDsm0_BEMCE(
int prepost)
const {
1093 int buffer = prepostAddress(prepost);
1094 if (buffer >= 0)
if (mBCE[buffer])
return mBCE[buffer]->BEMCEast;
1098 unsigned char* StTriggerData2018::getDsm0_BEMCW(
int prepost)
const {
1099 int buffer = prepostAddress(prepost);
1100 if (buffer >= 0)
if (mBCW[buffer])
return mBCW[buffer]->BEMCWest;
1104 unsigned short* StTriggerData2018::getDsm1_BEMC(
int prepost)
const {
1105 int buffer = prepostAddress(prepost);
1106 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1;
1110 unsigned char* StTriggerData2018::getDsm0_EEMC(
int prepost)
const {
1111 int buffer = prepostAddress(prepost);
1112 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMC;
1116 unsigned short* StTriggerData2018::getDsm1_EEMC(
int prepost)
const{
1117 int buffer = prepostAddress(prepost);
1118 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1;
1122 unsigned short* StTriggerData2018::getDsm2_EMC()
const{
1126 unsigned short* StTriggerData2018::getDsm3()
const{
1127 return L1_DSM->lastDSM;
1130 int StTriggerData2018::L2ResultsOffset(StL2AlgorithmId
id)
const
1133 default:
return -999999999;
1137 bool StTriggerData2018::isL2Triggered(StL2TriggerResultType
id)
const
1142 unsigned int StTriggerData2018::l2ResultLength()
const
1144 return sizeof(TrgSum->L2Result)/
sizeof(
unsigned int);
1147 const unsigned int* StTriggerData2018::l2Result()
const
1149 return TrgSum->L2Result;
1152 unsigned long long StTriggerData2018::l2sum()
const
1156 unsigned long long hi = TrgSum->L2Sum[1];
1157 unsigned long long lo = TrgSum->L2Sum[0];
1158 unsigned long long mask=(hi<<32) | lo;
1162 unsigned short StTriggerData2018::vpdADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1164 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1165 if (pmt<1 || pmt>16)
return 0;
1166 int buffer = prepostAddress(prepost);
1168 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]];}
1169 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1174 unsigned short StTriggerData2018::vpdTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1176 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1177 if (pmt<1 || pmt>16)
return 0;
1178 int buffer = prepostAddress(prepost);
1180 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]+4];}
1181 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1186 unsigned short StTriggerData2018::vpdADCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1188 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1189 if (pmt<1 || pmt>16)
return 0;
1190 int buffer = prepostAddress(prepost);
1192 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1193 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1198 unsigned short StTriggerData2018::vpdTDCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1200 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1201 if (pmt<1 || pmt>16)
return 0;
1202 int buffer = prepostAddress(prepost);
1204 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1205 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]+4];};
1210 unsigned short StTriggerData2018::vpdEarliestTDC(StBeamDirection eastwest,
int prepost)
const
1212 int buffer = prepostAddress(prepost);
1215 if (mRun<=10096084){
1216 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1217 else {
return mBBC[buffer]->VPD[4]%4096;}
1219 else if(mRun<=12003001) {
1220 if (eastwest==east) {
return mBBC[buffer]->VPD[2]%4096;}
1221 else {
return mBBC[buffer]->VPD[0]%4096;}
1224 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1225 else {
return mBBC[buffer]->VPD[4]%4096;}
1233 unsigned short StTriggerData2018::vpdEarliestTDCHighThr(StBeamDirection eastwest,
int prepost)
const
1235 int buffer = prepostAddress(prepost);
1237 if (mRun<=10365999){
1240 else if(mRun<=12003001) {
1242 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1243 else {
return mBBC[buffer]->VPD[4]%4096;}
1245 }
else if(mRun<=14001001){
1247 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[13] + ((mMIX[buffer]->MTD_P2PLayer1[12]&0x0f)<<8);}
1248 else {
return mMIX[buffer]->MTD_P2PLayer1[9] + ((mMIX[buffer]->MTD_P2PLayer1[8]&0x0f)<<8);}
1252 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[11] + ((mMIX[buffer]->MTD_P2PLayer1[10]&0xf)<<8);}
1253 else {
return (mMIX[buffer]->MTD_P2PLayer1[10]>>4) + ((mMIX[buffer]->MTD_P2PLayer1[9]&0xff)<<4);}
1260 unsigned short StTriggerData2018::vpdADCSum(StBeamDirection eastwest,
int prepost)
const
1263 return (bbcVP101(4,prepost) & 0x7ff);
1265 return (bbcVP101(6,prepost) & 0x7ff);
1269 float StTriggerData2018::vpdMeanTimeDifference(
int prepost)
const
1272 unsigned int ne=(bbcVP101(4,prepost) >> 11) & 0x1f;
1273 unsigned int nw=(bbcVP101(6,prepost) >> 11) & 0x1f;
1274 unsigned int se=bbcVP101(5,prepost);
1275 unsigned int sw=bbcVP101(7,prepost);
1279 if(nenw>0)
return float(nwse-nesw)/float(nenw);
1283 unsigned short StTriggerData2018::bbcVP101(
int ch,
int prepost)
const
1285 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1286 if(ch<0 || ch>7)
return 0;
1287 int buffer = prepostAddress(prepost);
1288 if (buffer >= 0 && mBBC[buffer]){
1289 return mBBC[buffer]->VPD[map[ch]];
1295 unsigned short StTriggerData2018::dsmTF201Ch(
int ch)
const
1297 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1298 return L1_DSM->TOF[map[ch]];
1301 unsigned short StTriggerData2018::mtd4AtAddress(
int address,
int prepost)
const
1303 if (mRun<=15001001)
return 0;
1304 int buffer = prepostAddress(prepost);
1305 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][14][address];
1309 unsigned short StTriggerData2018::nQTdata(
int prepost)
const
1314 unsigned int* StTriggerData2018::QTdata(
int prepost)
const
1319 unsigned short StTriggerData2018::fmsADC(
int crt,
int adr,
int ch,
int prepost)
const
1321 int buffer = prepostAddress(prepost);
1322 if (buffer >= 0 && crt>=1 && crt<=7 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1324 case 0:
return bbq[buffer][adr][ch];
1325 case 1:
return qt1[buffer][adr][ch];
1326 case 2:
return qt2[buffer][adr][ch];
1327 case 3:
return qt3[buffer][adr][ch];
1328 case 4:
return qt4[buffer][adr][ch];
1329 case 5:
return eq3[buffer][adr][ch];
1330 case 6:
return eq1[buffer][adr][ch];
1331 case 7:
return eq2[buffer][adr][ch];
1337 unsigned short StTriggerData2018::fmsTDC(
int crt,
int adr,
int ch,
int prepost)
const
1339 int buffer = prepostAddress(prepost);
1340 if (buffer >= 0 && crt>=0 && crt<=7 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1342 case 0:
return tbbq[buffer][adr][ch];
1343 case 1:
return tqt1[buffer][adr][ch];
1344 case 2:
return tqt2[buffer][adr][ch];
1345 case 3:
return tqt3[buffer][adr][ch];
1346 case 4:
return tqt4[buffer][adr][ch];
1347 case 5:
return teq3[buffer][adr][ch];
1348 case 6:
return teq1[buffer][adr][ch];
1349 case 7:
return teq2[buffer][adr][ch];
1355 unsigned short StTriggerData2018::epdADC(
int crt,
int adr,
int ch,
int prepost)
const
1357 int buffer = prepostAddress(prepost);
1358 if (buffer >= 0 && crt>=1 && crt<=3 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1360 case 1:
return eq1[buffer][adr][ch];
1361 case 2:
return eq2[buffer][adr][ch];
1362 case 3:
return eq3[buffer][adr][ch];
1368 unsigned short StTriggerData2018::epdTDC(
int crt,
int adr,
int ch,
int prepost)
const
1370 int buffer = prepostAddress(prepost);
1371 if (buffer >= 0 && crt>=1 && crt<=3 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1373 case 1:
return teq1[buffer][adr][ch];
1374 case 2:
return teq2[buffer][adr][ch];
1375 case 3:
return teq3[buffer][adr][ch];
1381 unsigned char* StTriggerData2018::getDsm_FMS(
int prepost)
const
1383 int buffer = prepostAddress(prepost);
1384 if (buffer >= 0)
if (mFMS[buffer])
return mFMS[buffer]->FMS;
1388 unsigned short* StTriggerData2018::getDsm1_FMS(
int prepost)
const
1390 int buffer = prepostAddress(prepost);
1391 if (buffer >= 0)
if (mMIX[buffer])
return mMIX[buffer]->FPDEastNSLayer1;
1395 unsigned short* StTriggerData2018::getDsm2_FMS()
const {
return L1_DSM->FPD;}
1397 unsigned short StTriggerData2018::mxqAtSlotAddress(
int address,
int prepost,
int slot)
const
1399 int buffer = prepostAddress(prepost);
1400 if (buffer >= 0 && address>=0 && address<32){
1401 if (slot >= 0 && slot<16){
1402 return mxq[buffer][slot][address];
1408 unsigned short StTriggerData2018::mtdQtAtCh(
int qtid,
int address,
int prepost)
const
1410 int map1[4] = {0, 10, 12, 14};
1411 int map2[8] = {0, 9, 10, 11, 12, 13, 14, 15};
1412 int map3[4] = {0, 9, 11, 13};
1414 int buffer = prepostAddress(prepost);
1415 if(buffer>=0 && qtid>0 && address>=0 && address<32){
1417 if(qtid>1)
return 0;
1418 else return mxq[buffer][map1[qtid-1]][address];
1420 else if(mRun<=14001001){
1421 if(qtid>2)
return 0;
1422 else return mxq[buffer][map1[qtid-1]][address];
1424 else if(mRun<=15001001){
1425 if(qtid>3)
return 0;
1426 else return mxq[buffer][map1[qtid-1]][address];
1428 else if(mRun<=17001001){
1429 if(qtid>4)
return 0;
1430 else return mxq[buffer][map1[qtid-1]][address];
1432 else if(mRun<=18001001){
1433 if(qtid>8)
return 0;
1434 else return mxq[buffer][map2[qtid-1]][address];
1437 if(qtid>4)
return 0;
1438 else return mxq[buffer][map3[qtid-1]][address];
1445 unsigned short StTriggerData2018::mtdAtAddress(
int address,
int prepost)
const
1447 int buffer = prepostAddress(prepost);
1448 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][0][address];
1452 unsigned short StTriggerData2018::mtdgemAtAddress(
int address,
int prepost)
const
1454 if (mRun<=12003001)
return 0;
1455 int buffer = prepostAddress(prepost);
1456 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][10][address];
1460 unsigned short StTriggerData2018::mtd3AtAddress(
int address,
int prepost)
const
1462 if (mRun<=14001001)
return 0;
1463 int buffer = prepostAddress(prepost);
1464 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][12][address];
1469 unsigned short StTriggerData2018::mtdAdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1472 int buffer = prepostAddress(prepost);
1473 if (buffer >= 0 && pmt==0){
1474 if (eastwest==east) {
1475 if (mRun<=10133008)
return mxq[buffer][0][0];
1476 else return mxq[buffer][0][24];
1478 if (eastwest==west)
return mxq[buffer][0][8];
1483 unsigned short StTriggerData2018::mtdTdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1486 int buffer = prepostAddress(prepost);
1487 if (buffer >= 0 && pmt==0){
1488 if (eastwest==east) {
1489 if (mRun<=10133008)
return mxq[buffer][0][4];
1490 else return mxq[buffer][0][28];
1492 if (eastwest==west)
return mxq[buffer][0][12];
1497 unsigned char StTriggerData2018::mtdDsmAtCh(
int ch,
int prepost)
const
1499 int map[16] = {7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8};
1501 int buffer = prepostAddress(prepost);
1502 if (buffer >= 0 && ch>=0){
1505 return mMIX[buffer]->MTD_P2PLayer1[map[ch]];
1518 bool StTriggerData2018::mtdDsmHit(
int pmt,
int prepost)
const
1521 int buffer = prepostAddress(prepost);
1524 if(mRun<10133008 && mRun<11000000){
1525 if( (mMIX[buffer]->MTD_P2PLayer1[5] & 0x1) && (mMIX[buffer]->MTD_P2PLayer1[5] & 0x10) )
return true;
1528 if(prepost!=0)
return false;
1529 return (L1_DSM->TOF[3] & 0x1);
1536 unsigned short StTriggerData2018::mtdVpdTacDiff()
const
1538 return (L1_DSM->TOF[3] & 0x3fff);
1541 unsigned short StTriggerData2018::tofAtAddress(
int address,
int prepost)
const
1543 int buffer = prepostAddress(prepost);
1544 if (buffer>=0 && address>=0 && address<48) {
1545 if (mMIX[buffer])
return mMIX[buffer]->TOF[address];
1550 unsigned short StTriggerData2018::tofTrayMultiplicity(
int tray,
int prepost)
const
1552 int dsmmap[8] = {3,2,1,0,7,6,5,4};
1553 int traydsm[120] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5,
1554 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
1555 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1556 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
1557 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
1558 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
1559 int traych[120] = { 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1560 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1561 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1562 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1563 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1564 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17};
1565 int buffer = prepostAddress(prepost);
1566 if (buffer>=0 && tray>=1 && tray<=120) {
1568 int address = traydsm[tray-1]*8 + dsmmap[traych[tray-1]/3];
1569 int ch = traych[tray-1]%3;
1570 return (mMIX[buffer]->TOF[address] >> (5*ch)) & 0x1f;
1576 unsigned short StTriggerData2018::tofMultiplicity(
int prepost)
const
1578 if (prepost==0)
return L1_DSM->TOF[1]%8192;
1582 void StTriggerData2018::dump()
const
1584 printf(
"***** StTriggerData Dump *****\n");
1585 printf(
" mDebug=%d mData=%p\n",mDebug,mData);
1586 printf(
" Year=%d EvtDesc version=%x header version%x\n",year(),version(),mData->FormatVersion);
1587 printf(
" Run#=%d Event#=%d\n",mRun,eventNumber());
1588 printf(
" %d pre and %d post crossing data available\n",numberOfPreXing(),numberOfPostXing());
1589 printf(
" Token=%d TriggerWord=%x ActionWord=%x BusyStatus=%x\n",
1590 token(), triggerWord(), actionWord(), busyStatus());
1591 printf(
" TUC Bits=%d : ",tcuBits());
1592 for (
int i=0; i<16; i++) {printf(
" %d",(tcuBits()>>(15-i))%2);}; printf(
"\n");
1593 printf(
" BunchId 7bit=%d 48bit=%d\n",bunchId7Bit(), bunchId48Bit());
1594 printf(
" Spin Bits=%d : ",spinBit());
1595 for (
int i=0; i<8; i++) {printf(
" %d",(spinBit()>>(7-i))%2);}; printf(
"\n");
1597 printf(
" BBC East ADC : ");
for (
int i=1; i<=24;i++){ printf(
"%d ",bbcADC(east,i,0)); }; printf(
"\n");
1598 printf(
" BBC West ADC : ");
for (
int i=1; i<=24;i++){ printf(
"%d ",bbcADC(west,i,0)); }; printf(
"\n");
1599 printf(
" BBC East TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%d ",bbcTDC(east,i,0)); }; printf(
"\n");
1600 printf(
" BBC West TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%d ",bbcTDC(west,i,0)); }; printf(
"\n");
1601 for (
int i=-numberOfPreXing(); i<=static_cast<int>(numberOfPostXing()); i++){
1602 printf(
" BBC Sums %d xing : ",i);
1603 printf(
"East=%d West=%d Large tile East=%d West=%d\n",
1604 bbcADCSum(east,i),bbcADCSum(west,i),
1605 bbcADCSumLargeTile(east,i),bbcADCSumLargeTile(west,i));
1607 printf(
" BBC Earilest : "); printf(
"East=%d West=%d Difference+256=%d\n",
1608 bbcEarliestTDC(east,0),bbcEarliestTDC(west,0),bbcTimeDifference());
1609 printf(
" ZDC Earilest : "); printf(
"East=%d West=%d Difference=%d\n",
1610 zdcEarliestTDC(east,0),zdcEarliestTDC(west,0),zdcTimeDifference());
1622 printf(
" ZDC Sum(A) East : ");printf(
"%d ",zdcAttenuated(east)); printf(
"\n");
1623 printf(
" ZDC Sum(A) West : ");printf(
"%d ",zdcAttenuated(west)); printf(
"\n");
1624 printf(
" ZDC Sum(UA) East : ");printf(
"%d ",zdcUnAttenuated(east)); printf(
"\n");
1625 printf(
" ZDC Sum(UA) West : ");printf(
"%d ",zdcUnAttenuated(west)); printf(
"\n");
1626 printf(
" VPD E Earliest TAC : %d\n", vpdEarliestTDC(east));
1627 printf(
" VPD W Earliest TAC : %d\n", vpdEarliestTDC(west));
1628 printf(
" VPD TimeDifference : %d\n", vpdTimeDifference());
1629 printf(
" L2 result : \n");
1630 for (
int j=0; j<4 ;j++) {
for (
int k=0; k<16; k++) {printf(
"%u ",*(l2Result()+j*16+k)); } printf(
"\n");}
1631 printf(
"BBClayer1:");
1632 int buffer = prepostAddress(0);
1635 for (
int i = 0;i < 16;i++) printf(
" %1x %04X", i, mBBC[buffer]->BBClayer1[i]);
1639 printf(
"ZDClayer1:");
1642 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->ZDClayer1[i]);
1646 printf(
"VPDlayer1:");
1649 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->VPD[i]);
1655 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->VTX[i]);
1658 printf(
"Last DSM:");
1660 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->lastDSM[i]);
1663 printf(
"***** End StTriggerData Dump *****\n");
1666 void StTriggerData2018::killFMS(){
1668 int npre = numberOfPreXing();
1669 int npost = numberOfPostXing();
1670 for (
int i=0; i<1+npre+npost; i++){
1672 {offlen = mData->MainX;}
1674 if (mData->PrePostList[i-1]==0)
continue;
1675 offlen = (
TrgOfflen2018*) ((
char*)mData + mData->PrePostList[i-1]);
1678 j=offlen[y18QT1_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y18QT1_CONF_NUM].offset, 0, j); offlen[y18QT1_CONF_NUM].length=0;};
1679 j=offlen[y18QT2_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y18QT2_CONF_NUM].offset, 0, j); offlen[y18QT2_CONF_NUM].length=0;};
1680 j=offlen[y18QT3_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y18QT3_CONF_NUM].offset, 0, j); offlen[y18QT3_CONF_NUM].length=0;};
1681 j=offlen[y18QT4_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y18QT4_CONF_NUM].offset, 0, j); offlen[y18QT4_CONF_NUM].length=0;};
1685 void StTriggerData2018::swapRawDet(
DataBlock2018* data,
int name,
int hlength,
int bs)
1691 int header_length = 8;
1692 if(bs) swapI((
unsigned int*)&data->length);
1694 case y18MXQ_CONF_NUM :
case y18EQ3_CONF_NUM :
case y18BBQ_CONF_NUM :
1695 case y18QT1_CONF_NUM :
case y18QT2_CONF_NUM :
case y18QT3_CONF_NUM :
case y18QT4_CONF_NUM :
1696 case y18EQ1_CONF_NUM :
case y18EQ2_CONF_NUM :
1697 header_length = 12;
break;
1699 if (hlength != data->length + header_length){
1700 mErrorFlag = mErrorFlag | (1 << name);
1701 printf(
"StTriggerData2018: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
1702 name,data->name[0],data->name[1],data->name[2],data->name[3],
1703 hlength,data->length,header_length);
1704 printf(
"StTriggerData2018: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
1705 name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
1711 case y18BC1_CONF_NUM :
1713 swapSSn((
unsigned int*)bc1->BEMClayer1,48);
1714 swapSSn((
unsigned int*)bc1->EEMClayer1,16);
1716 case y18MIX_CONF_NUM :
1718 swapSSn((
unsigned int*)mix->FPDEastNSLayer1,8);
1719 swapSSn((
unsigned int*)mix->TOFLayer1,8+48);
1721 case y18BCW_CONF_NUM :
1724 case y18BCE_CONF_NUM :
1727 case y18BBC_CONF_NUM :
1729 swapSSn((
unsigned int*)bbc->BBClayer1,16+8+8+16+8+8);
1731 case y18FMS_CONF_NUM :
1734 case y18MXQ_CONF_NUM :
1735 case y18EQ3_CONF_NUM :
1736 case y18BBQ_CONF_NUM :
1737 case y18QT1_CONF_NUM :
1738 case y18QT2_CONF_NUM :
1739 case y18QT3_CONF_NUM :
1740 case y18QT4_CONF_NUM :
1741 case y18EQ1_CONF_NUM :
1742 case y18EQ2_CONF_NUM :
1744 swapI((
unsigned int*)&qtdata->dataLoss);
1745 swapIn(qtdata->data, qtdata->length/4);
1750 printf(
"Read id=%2d name=%1c%1c%1c%1c length=%d\n",
1751 name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
1754 void StTriggerData2018::Streamer(TBuffer &R__b)
1758 if (R__b.IsReading()) {
1759 R__b.ReadClassBuffer(StTriggerData2018::Class(),
this);
1761 if(mData) readData();
1764 R__b.WriteClassBuffer(StTriggerData2018::Class(),
this);