30 #include "StTriggerData2022.h"
43 mYear=2022; mRun = run; mDebug = 0;
50 mYear=2022; mRun = run; mDebug = dbg;
51 if(mDebug==1) printf(
"StTriggerData2022 Constructor with trigger data block and byteswap option=%d\n",bs);
56 void StTriggerData2022::blindRunInfo()
58 mRun=1000000*int(mRun/1000000);
59 mData->eventNumber = 0;
60 EvtDesc->bunchXing_hi = 0;
61 EvtDesc->bunchXing_lo = 0;
62 L1_DSM->BCdata[2] = 0;
63 L1_DSM->BCdata[3] = 0;
64 L1_DSM->BCdata[10] = 0;
65 L1_DSM->BCdata[11] = 0;
70 if (data==0) {copyflag=0;}
71 if(mDebug==1) printf(
"StTriggerData2022::readData copyflag=%d byteswap=%d data=%p mData=%p\n",copyflag,bs,data,mData);
74 unsigned int ver = data->FormatVersion;
77 if (ver == y22FORMAT_VERSION ) {
78 if (mDebug==1) printf(
"StTriggerData2022: version = 0x%x (0x%x or 0x08121140)\n",ver,y22FORMAT_VERSION);
81 mErrorFlag = mErrorFlag | 0x1;
82 printf(
"StTriggerData2022: version = 0x%x != (0x%x)\n",ver,y22FORMAT_VERSION);
86 unsigned int size = data->totalTriggerLength;
88 if (size > y22MAX_TRG_BLK_SIZE) {
89 gMessMgr->Warning() <<
"StTriggerData2022: Data length = " << size
90 <<
" is bigger than max = " << y22MAX_TRG_BLK_SIZE
94 if (mDebug==1) printf(
"StTriggerData2022: size = %d, maxsize = %d\n",size,y22MAX_TRG_BLK_SIZE);
95 memcpy(mData,data,size);
99 if (bs) swapDataBlk(mData);
101 printf(
"StTriggerData2022: version = 0x%x (0x%x)\n",mData->FormatVersion,y22FORMAT_VERSION);
102 printf(
"StTriggerData2022: size = %d, maxsize = %d\n",mData->totalTriggerLength,y22MAX_TRG_BLK_SIZE);
103 printf(
"EventDesc length=%10d offset=%10d\n",mData->EventDesc_ofl.length,mData->EventDesc_ofl.offset);
104 printf(
"L1_DSM length=%10d offset=%10d\n",mData->L1_DSM_ofl.length,mData->L1_DSM_ofl.offset);
105 printf(
"Summary length=%10d offset=%10d\n",mData->Summary_ofl.length,mData->Summary_ofl.offset);
108 EvtDesc=0; L1_DSM=0; TrgSum=0;
109 if (mData->EventDesc_ofl.length > 0) EvtDesc = (
EvtDescData2022*)((
char*)mData + mData->EventDesc_ofl.offset);
110 if (mData->L1_DSM_ofl.length > 0) L1_DSM = (
L1_DSM_Data2022*)((
char*)mData + mData->L1_DSM_ofl.offset);
111 if (mData->Summary_ofl.length > 0) TrgSum = (
TrgSumData2022* )((
char*)mData + mData->Summary_ofl.offset);
113 if (EvtDesc) swapEvtDesc(EvtDesc);
114 if (L1_DSM) swapL1_DSM(L1_DSM);
115 if (TrgSum) swapTrgSum(TrgSum);
117 if (EvtDesc==0 || L1_DSM==0 || TrgSum==0){
118 mErrorFlag = mErrorFlag | 0x1;
119 gMessMgr->Warning() <<
"StTriggerData2022: EvtDesc, L1_DSM or TrgSum is missing"
120 <<
" mErrorFlag="<<mErrorFlag<<endm;
123 int npre = numberOfPreXing();
124 int npost = numberOfPostXing();
125 if (npre<0 || npre>10 || npost<0 || npost>10){
126 mErrorFlag = mErrorFlag | 0x2;
127 gMessMgr->Warning() <<
"StTriggerData2022: Invalid npre/post = "<< npre <<
" / " << npost
128 <<
" mErrorFlag="<<mErrorFlag<<endm;
130 if (mDebug==1) printf(
"StTriggerData2022: pre=%d post=%d\n",npre,npost);
132 memset(mBC1,0,
sizeof(mBC1));
133 memset(mMXQ,0,
sizeof(mMXQ));
134 memset(mMIX,0,
sizeof(mMIX));
135 memset(mBCW,0,
sizeof(mBCW));
136 memset(mBCE,0,
sizeof(mBCE));
137 memset(mEQ3,0,
sizeof(mEQ3));
138 memset(mBBC,0,
sizeof(mBBC));
139 memset(mBBQ,0,
sizeof(mBBQ));
140 memset(mFMS,0,
sizeof(mFMS));
141 memset(mQT1,0,
sizeof(mQT1));
142 memset(mQT2,0,
sizeof(mQT2));
143 memset(mQT3,0,
sizeof(mQT3));
144 memset(mQT4,0,
sizeof(mQT4));
145 memset(mEQ1,0,
sizeof(mEQ1));
146 memset(mEQ2,0,
sizeof(mEQ2));
147 memset(mEQ4,0,
sizeof(mEQ4));
148 memset(mxq,0,
sizeof(mxq)); memset(tmxq,0,
sizeof(tmxq));
149 memset(eq3,0,
sizeof(eq3)); memset(teq3,0,
sizeof(teq3));
150 memset(bbq,0,
sizeof(bbq)); memset(tbbq,0,
sizeof(tbbq));
151 memset(eq1,0,
sizeof(eq1)); memset(teq1,0,
sizeof(teq1));
152 memset(eq2,0,
sizeof(eq2)); memset(teq2,0,
sizeof(teq2));
153 memset(eq4,0,
sizeof(eq4)); memset(teq4,0,
sizeof(teq4));
156 for (
int i=0; i<1+npre+npost; i++) {
159 offlen = mData->MainX;
163 if (mData->PrePostList[i-1]==0)
continue;
164 offlen = (
TrgOfflen2022*) ((
char*)mData + mData->PrePostList[i-1]);
166 if (bs) swapRawDetOfflen(offlen);
167 for(
int k=0; k<y22MAX_OFFLEN; k++) {
168 if(static_cast<unsigned int>(offlen[k].length + offlen[k].offset) > static_cast<unsigned int>(mData->totalTriggerLength)) {
169 mErrorFlag = mErrorFlag | (1 << k);
170 gMessMgr->Warning() <<
"StTriggerData2022: offset ("<<offlen[k].offset<<
") + length ("<<offlen[k].length
171 <<
") exceeds total size("<<mData->totalTriggerLength<<
") for data block id="<<k
172 <<
" mErrorFlag="<<mErrorFlag<<endm;
178 j=offlen[y22BC1_CONF_NUM].length;
if (j>12){mBC1[i] = (
BELayerBlock2022*)((
char*)mData + offlen[y22BC1_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mBC1[i],y22BC1_CONF_NUM,j,bs);}
179 j=offlen[y22MXQ_CONF_NUM].length;
if (j>12){mMXQ[i] = (
QTBlock2022* )((
char*)mData + offlen[y22MXQ_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mMXQ[i],y22MXQ_CONF_NUM,j,bs);}
180 j=offlen[y22MIX_CONF_NUM].length;
if (j>12){mMIX[i] = (
MIXBlock2022* )((
char*)mData + offlen[y22MIX_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mMIX[i],y22MIX_CONF_NUM,j,bs);}
181 j=offlen[y22BCW_CONF_NUM].length;
if (j>12){mBCW[i] = (
BWestBlock2022* )((
char*)mData + offlen[y22BCW_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mBCW[i],y22BCW_CONF_NUM,j,bs);}
182 j=offlen[y22BCE_CONF_NUM].length;
if (j>12){mBCE[i] = (
BEastBlock2022* )((
char*)mData + offlen[y22BCE_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mBCE[i],y22BCE_CONF_NUM,j,bs);}
183 j=offlen[y22EQ3_CONF_NUM].length;
if (j>12){mEQ3[i] = (
QTBlock2022* )((
char*)mData + offlen[y22EQ3_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mEQ3[i],y22EQ3_CONF_NUM,j,bs);}
184 j=offlen[y22BBC_CONF_NUM].length;
if (j>12){mBBC[i] = (
BBCBlock2022* )((
char*)mData + offlen[y22BBC_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mBBC[i],y22BBC_CONF_NUM,j,bs);}
185 j=offlen[y22BBQ_CONF_NUM].length;
if (j>12){mBBQ[i] = (
QTBlock2022* )((
char*)mData + offlen[y22BBQ_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mBBQ[i],y22BBQ_CONF_NUM,j,bs);}
186 j=offlen[y22FMS_CONF_NUM].length;
if (j>12){mFMS[i] = (
FMSBlock2022* )((
char*)mData + offlen[y22FMS_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mFMS[i],y22FMS_CONF_NUM,j,bs);}
187 j=offlen[y22QT1_CONF_NUM].length;
if (j>12){mQT1[i] = (
QTBlock2022* )((
char*)mData + offlen[y22QT1_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mQT1[i],y22QT1_CONF_NUM,j,bs);}
188 j=offlen[y22QT2_CONF_NUM].length;
if (j>12){mQT2[i] = (
QTBlock2022* )((
char*)mData + offlen[y22QT2_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mQT2[i],y22QT2_CONF_NUM,j,bs);}
189 j=offlen[y22QT3_CONF_NUM].length;
if (j>12){mQT3[i] = (
QTBlock2022* )((
char*)mData + offlen[y22QT3_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mQT3[i],y22QT3_CONF_NUM,j,bs);}
190 j=offlen[y22QT4_CONF_NUM].length;
if (j>12){mQT4[i] = (
QTBlock2022* )((
char*)mData + offlen[y22QT4_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mQT4[i],y22QT4_CONF_NUM,j,bs);}
191 j=offlen[y22EQ1_CONF_NUM].length;
if (j>12){mEQ1[i] = (
QTBlock2022* )((
char*)mData + offlen[y22EQ1_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mEQ1[i],y22EQ1_CONF_NUM,j,bs);}
192 j=offlen[y22EQ2_CONF_NUM].length;
if (j>12){mEQ2[i] = (
QTBlock2022* )((
char*)mData + offlen[y22EQ2_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mEQ2[i],y22EQ2_CONF_NUM,j,bs);}
193 j=offlen[y22EQ4_CONF_NUM].length;
if (j>12){mEQ4[i] = (
QTBlock2022* )((
char*)mData + offlen[y22EQ4_CONF_NUM].offset); swapRawDet((
DataBlock2022*)mEQ4[i],y22EQ4_CONF_NUM,j,bs);}
194 if (mMXQ[i]) decodeQT(mMXQ[i]->length/4, mMXQ[i]->data, mxq[i], tmxq[i]);
195 if (mEQ3[i]) decodeQT(mEQ3[i]->length/4, mEQ3[i]->data, eq3[i], teq3[i]);
196 if (mBBQ[i]) decodeQT(mBBQ[i]->length/4, mBBQ[i]->data, bbq[i], tbbq[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]);
199 if (mEQ4[i]) decodeQT(mEQ4[i]->length/4, mEQ4[i]->data, eq4[i], teq4[i]);
201 if (mDebug==1) dump();
204 StTriggerData2022::~StTriggerData2022() {
delete mData;}
206 unsigned int StTriggerData2022::version()
const
208 return EvtDesc->TrgDataFmtVer;
211 unsigned int StTriggerData2022::eventNumber()
const
213 return mData->eventNumber;
216 unsigned int StTriggerData2022::token()
const
218 return EvtDesc->TrgToken;
221 unsigned int StTriggerData2022::triggerWord()
const
226 unsigned int StTriggerData2022::actionWord()
const
229 ( (
unsigned short)(EvtDesc->actionWdTrgCommand) * 16 * 16 * 16 ) +
230 ( (
unsigned short)(EvtDesc->actionWdDaqCommand) * 16 * 16 ) +
231 ( EvtDesc->actionWdDetectorBitMask & 0x00ff );
235 unsigned int StTriggerData2022::zdcKillerBit()
const{
236 return (EvtDesc->addBits>>4) & 0x1;
239 unsigned int StTriggerData2022::numberOfPreXing()
const
241 return EvtDesc->npre & 0xf;
244 unsigned int StTriggerData2022::numberOfPostXing()
const
246 return EvtDesc->npost & 0xf;
249 unsigned short StTriggerData2022::busyStatus()
const
251 return EvtDesc->internalBusy;
254 unsigned short StTriggerData2022::dsmInput()
const
256 return EvtDesc->DSMInput;
259 unsigned short StTriggerData2022::trgToken()
const
261 return EvtDesc->TrgToken;
264 unsigned short StTriggerData2022::dsmAddress()
const
266 return EvtDesc->DSMAddress;
269 unsigned short StTriggerData2022::mAddBits()
const
271 return EvtDesc->addBits;
274 unsigned short StTriggerData2022::bcData(
int channel)
const
276 return L1_DSM->BCdata[channel];
279 unsigned short StTriggerData2022::getTrgDetMask()
const
281 return EvtDesc->trgDetMask;
284 unsigned int StTriggerData2022::getTrgCrateMask()
const
286 unsigned int p = EvtDesc->npost & 0xfff0;
287 unsigned int r = EvtDesc->res1 & 0x0ff0;
289 ( ((EvtDesc->npre & 0xfff0) >> 4)
294 unsigned short StTriggerData2022::lastDSM(
int channel)
const
296 return L1_DSM->lastDSM[channel];
300 unsigned short StTriggerData2022::vertexDSM(
int channel)
const
302 int dsmmap[8] = {3,2,1,0,7,6,5,4};
303 if(channel<0 || channel>7)
return 0;
304 return L1_DSM->VTX[dsmmap[channel]];
307 unsigned short StTriggerData2022::tcuBits()
const
309 return EvtDesc->DSMInput;
313 unsigned int StTriggerData2022::tcuCounter()
const
315 unsigned int hi = EvtDesc->tcuCtrBunch_hi;
316 return (hi << 16) + EvtDesc->DSMAddress;
319 unsigned int StTriggerData2022::rccCounter(
int crate)
const
321 if(crate >= y22L1_CONF_NUM && crate <= y22EQ4_CONF_NUM){
322 return TrgSum->LocalClocks[crate];
327 unsigned long long StTriggerData2022::bunchCounter()
const
329 unsigned long long bxinghi,bxing1,bxinglo, bx;
330 bxinghi = L1_DSM->BCdata[3];
331 bxing1 = L1_DSM->BCdata[10];
332 bxinglo = (bxing1 << 16) + L1_DSM->BCdata[11];
333 bx = (bxinghi << 32) + bxinglo;
337 unsigned int StTriggerData2022::bunchCounterHigh()
const
339 return EvtDesc->bunchXing_hi;
342 unsigned int StTriggerData2022::bunchCounterLow()
const
344 return EvtDesc->bunchXing_lo;
347 unsigned int StTriggerData2022::bunchId48Bit()
const
349 return (
int)(bunchCounter() % 120);
352 unsigned int StTriggerData2022::bunchId7Bit()
const
355 b7dat = L1_DSM->BCdata[2];
360 unsigned int StTriggerData2022::revTick1()
const
362 return L1_DSM->BCdata[1] & 0x1;
365 unsigned int StTriggerData2022::revTick2()
const
367 return L1_DSM->BCdata[12] & 0x1;
370 unsigned int StTriggerData2022::revTick3()
const
372 return (L1_DSM->lastDSM[4] >> 3) & 0x1;
376 unsigned int StTriggerData2022::spinBit()
const
378 return (L1_DSM->lastDSM[4]/16)%256;
381 unsigned int StTriggerData2022::spinBitYellowFilled()
const
383 unsigned int sb = spinBit();
387 unsigned int StTriggerData2022::spinBitYellowUp()
const
392 unsigned int StTriggerData2022::spinBitYellowDown()
const
397 unsigned int StTriggerData2022::spinBitYellowUnpol()
const
402 unsigned int StTriggerData2022::spinBitBlueFilled()
const
404 unsigned int sb = spinBit();
408 unsigned int StTriggerData2022::spinBitBlueUp()
const
413 unsigned int StTriggerData2022::spinBitBlueDown()
const
418 unsigned int StTriggerData2022::spinBitBlueUnpol()
const
423 unsigned short StTriggerData2022::bbcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
425 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
426 4, 4, 4, 4, 4, 4, 4, 4},
427 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 4, 4, 4, 4, 4, 4, 4, 4} };
429 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
430 0, 1, 2, 3, 8, 9,10,11},
431 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
432 16,17,18,19,24,25,26,27} };
433 int buffer = prepostAddress(prepost);
434 if (buffer >= 0 && pmt>=1 && pmt<=16)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
438 unsigned short StTriggerData2022::bbcTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
440 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
441 4, 4, 4, 4, 4, 4, 4, 4},
442 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 4, 4, 4, 4, 4, 4, 4, 4} };
444 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
445 0, 1, 2, 3, 8, 9,10,11},
446 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
447 16,17,18,19,24,25,26,27} };
448 int buffer = prepostAddress(prepost);
449 if (buffer >= 0 && pmt>=1 && pmt<=16)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]+4];
453 unsigned short StTriggerData2022::bbcTDC5bit(StBeamDirection eastwest,
int pmt,
int prepost)
const
455 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
456 4, 4, 4, 4, 4, 4, 4, 4},
457 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 4, 4, 4, 4, 4, 4, 4, 4} };
459 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
460 0, 1, 2, 3, 8, 9,10,11},
461 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
462 16,17,18,19,24,25,26,27} };
463 int buffer = prepostAddress(prepost);
464 if (buffer >= 0 && pmt>=1 && pmt<=16)
return tbbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
468 unsigned short StTriggerData2022::bbcADCSum(StBeamDirection eastwest,
int prepost)
const
470 unsigned short sum=0;
471 int buffer = prepostAddress(prepost);
475 if(eastwest==east) { sum = mBBC[buffer]->BBClayer1[3]; }
476 else { sum = mBBC[buffer]->BBClayer1[1]; }
482 unsigned short StTriggerData2022::bbcADCSumLargeTile(StBeamDirection eastwest,
int prepost)
const
484 unsigned short sum=0;
490 unsigned short StTriggerData2022::bbcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
492 int buffer = prepostAddress(prepost);
495 if (eastwest==east) {
return mBBC[buffer]->BBClayer1[2]%4096;}
496 else {
return mBBC[buffer]->BBClayer1[0]%4096;}
502 unsigned short StTriggerData2022::bbcTimeDifference()
const
504 return L1_DSM->VTX[3]%8192;
507 unsigned short StTriggerData2022::bbcTacSum()
const
509 return (((L1_DSM->VTX[3]) >> 13) & 0x1);
512 unsigned short StTriggerData2022::bbcEarliestTDCLarge(StBeamDirection eastwest,
int prepost)
const
525 unsigned short StTriggerData2022::bbcTimeDifferenceLarge()
const
527 return L1_DSM->VTX[2]%8192;
531 unsigned short StTriggerData2022::bbcBB101(
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]];
543 unsigned short StTriggerData2022::bbcBB102(
int ch,
int prepost)
const
545 int dsmmap[8] = {3,2,1,0,7,6,5,4};
546 int buffer = prepostAddress(prepost);
549 if(ch>=0 && ch<=7)
return mBBC[buffer]->BBClayer1[dsmmap[ch]+8];
555 unsigned short StTriggerData2022::epdTimeDifference()
const
557 return L1_DSM->VTX[6]%8192;
560 bool StTriggerData2022::epdHitLayer2(StBeamDirection eastwest)
const
562 if(eastwest==east)
return (L1_DSM->VTX[6] & 0x40) ?
true :
false;
563 return (L1_DSM->VTX[6] & 0x80) ?
true :
false;
566 unsigned short StTriggerData2022::epdLayer0t(
int ch,
int prepost)
const
568 int dsmmap[16] = {3,2,1,0,7,6,5,4, 11,10,9,8,15,14,13,12};
569 int buffer = prepostAddress(prepost);
572 if(ch>=0 && ch<16)
return mBBC[buffer]->EPDlayer0t[dsmmap[ch]];
578 unsigned short StTriggerData2022::epdLayer1(
int ch,
int prepost)
const
580 return epdLayer1a(ch,prepost);
583 unsigned short StTriggerData2022::epdLayer1a(
int ch,
int prepost)
const
585 int dsmmap[8] = {3,2,1,0,7,6,5,4};
586 int buffer = prepostAddress(prepost);
589 if(ch>=0 && ch<8)
return mBBC[buffer]->EPDlayer1a[dsmmap[ch]];
595 unsigned short StTriggerData2022::epdEarliestTDC(StBeamDirection eastwest,
int prepost)
const
597 int buffer = prepostAddress(prepost);
600 unsigned short dsmEP001OutR = epdLayer1(0, prepost);
601 unsigned short dsmEP001OutL = epdLayer1(1, prepost);
602 unsigned int dsmEP001Out = (dsmEP001OutL<<16) + dsmEP001OutR;
603 int maxTac03 = (dsmEP001Out >> 12) & 0xfff;
604 int maxTac47 = (dsmEP001Out >> 0 ) & 0xfff;
605 return (maxTac03>maxTac47)?maxTac03:maxTac47;
607 unsigned short dsmEP002OutR = epdLayer1(2, prepost);
608 unsigned short dsmEP002OutL = epdLayer1(3, prepost);
609 unsigned int dsmEP002Out = (dsmEP002OutL<<16) + dsmEP002OutR;
610 int maxTac03 = (dsmEP002Out >> 12) & 0xfff;
611 int maxTac47 = (dsmEP002Out >> 0 ) & 0xfff;
612 return (maxTac03>maxTac47)?maxTac03:maxTac47;
618 unsigned short StTriggerData2022::epdNHits(StBeamDirection eastwest,
int prepost)
const
620 int buffer = prepostAddress(prepost);
623 unsigned short dsmEP001OutR = epdLayer1(0, prepost);
624 unsigned short dsmEP001OutL = epdLayer1(1, prepost);
625 unsigned int dsmEP001Out = (dsmEP001OutL<<16) + dsmEP001OutR;
626 return (dsmEP001Out >> 24) & 0xff;
628 unsigned short dsmEP002OutR = epdLayer1(2, prepost);
629 unsigned short dsmEP002OutL = epdLayer1(3, prepost);
630 unsigned int dsmEP002Out = (dsmEP002OutL<<16) + dsmEP002OutR;
631 return (dsmEP002Out >> 24) & 0xff;
637 unsigned short StTriggerData2022::epdLayer0aMult(
int ch,
int prepost)
const{
639 return epdLayer0a(ch,prepost) & 0x001f;
642 unsigned short StTriggerData2022::epdLayer0hMult(
int ch,
int mult12,
int prepost)
const{
644 unsigned short dsm=0, c=ch, out=0;
645 if(ch>=10) {dsm=1; c=ch-10;}
646 unsigned short chdiv=c/2;
647 unsigned short chmod=c%2;
648 unsigned short base=dsm*16 + chdiv*3;
649 unsigned short o0=epdLayer0h(base , prepost);
650 unsigned short o1=epdLayer0h(base+1, prepost);
651 unsigned short o2=epdLayer0h(base+2, prepost);
653 out = o0 + ((o1 & 0x0f)<<8);
655 out = ((o1 & 0xf0)>>4) + (o2<<4);
657 if(mult12==0)
return out;
658 if(mult12==1)
return (out & 0x003f);
659 if(mult12==2)
return (out & 0x0fc0) >> 6;
663 unsigned short StTriggerData2022::epdNHitsQT(
int crate,
int qt,
int mult12,
int prepost)
const {
667 const unsigned short dsmmap[3][11]={
668 {6,6,6,6,6,6,4,4,4,4,4},
669 {5,5,5,5,5,5,3,3,3,3,3},
670 {5,5,5,3,3,6,6,6,4,4,0}
672 const unsigned short chmap[3][11]={
673 {0,1,2,3,4,5,0,1,2,3,4},
674 {0,1,2,3,4,5,0,1,2,3,4},
675 {6,7,8,5,7,6,7,8,5,7,0}
677 if(crate<1 || crate>3)
return 0;
678 if(qt<1 || qt>11)
return 0;
679 unsigned short dsm=dsmmap[crate-1][qt-1];
680 unsigned short ch=chmap[crate-1][qt-1];
681 if(dsm==3 || dsm==4)
return epdLayer0aMult(ch + (dsm-3)*8, prepost);
682 if(dsm==5 || dsm==6)
return epdLayer0hMult(ch + (dsm-5)*10, mult12, prepost);
686 unsigned short StTriggerData2022::epdLayer1bMult(StBeamDirection eastwest,
int ring,
int prepost)
const
690 case 1:
return (epdLayer1b(0,prepost) & 0x007f);
691 case 2:
return (epdLayer1b(0,prepost) & 0x7f00) >> 8;
692 case 5:
return (epdLayer1b(1,prepost) & 0x00ff);
693 case 4:
return (epdLayer1b(1,prepost) & 0xff00) >> 8;
694 case 3:
return (epdLayer1b(2,prepost) & 0x00ff);
699 case 1:
return (epdLayer1b(3,prepost) & 0x007f);
700 case 2:
return (epdLayer1b(3,prepost) & 0x7f00) >> 8;
701 case 5:
return (epdLayer1b(4,prepost) & 0x00ff);
702 case 4:
return (epdLayer1b(4,prepost) & 0xff00) >> 8;
703 case 3:
return (epdLayer1b(5,prepost) & 0x00ff);
709 unsigned short StTriggerData2022::epdMultTotal(
int prepost)
const
711 return L1_DSM->VTX[6] & 0x00ff;
714 unsigned short StTriggerData2022::epdMultDiff(
int prepost)
const
716 return (L1_DSM->VTX[6] & 0xff00) >> 8;
719 unsigned short StTriggerData2022::fpd(StBeamDirection eastwest,
int module,
int pmt,
int prepost)
const
724 unsigned short StTriggerData2022::fpdSum(StBeamDirection eastwest,
int module)
const
729 bool StTriggerData2022::zdcPresent(
int prepost)
const
731 int buffer = prepostAddress(prepost);
732 if (buffer >= 0)
return mBBQ[buffer];
736 unsigned short StTriggerData2022::zdcAtChannel(
int channel,
int prepost)
const
738 int buffer = prepostAddress(prepost);
739 if (buffer >= 0 && channel>=0 && channel<32)
return bbq[buffer][14][channel];
743 unsigned short StTriggerData2022::zdcAtAddress(
int address,
int prepost)
const
745 return zdcAtChannel(address,prepost);
748 unsigned short StTriggerData2022::zdcUnAttenuated(StBeamDirection eastwest,
int prepost)
const
750 int buffer = prepostAddress(prepost);
752 if (eastwest == east)
return bbq[buffer][14][2];
753 else return bbq[buffer][14][18];
758 unsigned short StTriggerData2022::zdcAttenuated(StBeamDirection eastwest,
int prepost)
const
760 int buffer = prepostAddress(prepost);
762 if (eastwest == east)
return bbq[buffer][14][3];
763 else return bbq[buffer][14][19];
768 unsigned short StTriggerData2022::zdcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
770 int buffer = prepostAddress(prepost);
771 if (buffer >= 0 && pmt>=1 && pmt<=3) {
772 if (eastwest == east) {
773 if (pmt == 1)
return bbq[buffer][14][0];
774 if (pmt == 2)
return bbq[buffer][14][8];
775 if (pmt == 3)
return bbq[buffer][14][9];
778 if (pmt == 1)
return bbq[buffer][14][16];
779 if (pmt == 2)
return bbq[buffer][14][24];
780 if (pmt == 3)
return bbq[buffer][14][25];
786 unsigned short StTriggerData2022::zdcTDC(StBeamDirection eastwest,
int prepost)
const
788 int buffer = prepostAddress(prepost);
790 if (eastwest == east)
return bbq[buffer][14][6];
791 else return bbq[buffer][14][22];
796 unsigned short StTriggerData2022::zdcPmtTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
798 int buffer = prepostAddress(prepost);
799 if (buffer >= 0 && pmt>=1 && pmt<=3) {
800 if (eastwest == east) {
801 if (pmt == 1)
return bbq[buffer][14][4];
802 if (pmt == 2)
return bbq[buffer][14][12];
803 if (pmt == 3)
return bbq[buffer][14][13];
806 if (pmt == 1)
return bbq[buffer][14][20];
807 if (pmt == 2)
return bbq[buffer][14][28];
808 if (pmt == 3)
return bbq[buffer][14][29];
814 unsigned short StTriggerData2022::zdcHardwareSum(
int prepost)
const
816 int buffer = prepostAddress(prepost);
817 if (buffer >= 0)
return bbq[buffer][14][11];
821 bool StTriggerData2022::zdcSMDPresent(
int prepost)
const
823 int buffer = prepostAddress(prepost);
824 if (buffer >= 0)
return mMXQ[buffer];
828 unsigned short StTriggerData2022::zdcSMD(StBeamDirection eastwest,
int verthori,
int strip,
int prepost)
const
830 static const int zdcsmd_map[2][2][8] ={
831 { { 31, 30, 29, 28, 27, 26, 25, 19} ,
832 { 24, 23, 22, 21, 20, 16, 18, 17} } ,
833 { { 15, 14, 13, 12, 11, 10, 9, 2} ,
834 { 8, 7, 6, 5, 4, 3, 0, 1} }
836 static const int zdcsmd_map2011[2][2][8] ={
837 { {24, 25, 26, 27, 28, 29, 30, 31} ,
838 {16, 17, 18, 19, 20, 21, 22, 23} } ,
839 { {8, 9, 10, 11, 12, 13, 14, 15} ,
840 {0, 1, 2, 3, 4, 5, 6, 7} }
842 if (verthori<0 || verthori>1)
return 0;
843 if (strip<1 || strip>8)
return 0;
844 int buffer = prepostAddress(prepost);
847 return mxq[buffer][4][zdcsmd_map[eastwest][verthori][strip-1]];
849 return mxq[buffer][4][zdcsmd_map2011[eastwest][verthori][strip-1]];
855 unsigned short StTriggerData2022::zdcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
857 int buffer = prepostAddress(prepost);
861 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 12) % 16) | ((mBBC[buffer]->ZDClayer1[2] % 256) << 4);}
862 else {
return (mBBC[buffer]->ZDClayer1[3]) % 4096;}
864 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 10) % 64) | ((mBBC[buffer]->ZDClayer1[2] % 16) << 6);}
865 else {
return (mBBC[buffer]->ZDClayer1[3]) % 1024;}
872 bool StTriggerData2022::zdcSumADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
873 int buffer = prepostAddress(prepost);
877 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (27-16));}
878 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
880 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
881 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (22-16));}
888 bool StTriggerData2022::zdcFrontADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
889 int buffer = prepostAddress(prepost);
893 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (29-16));}
894 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (26-16));}
896 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (23-16));}
897 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (20-16));}
904 bool StTriggerData2022::zdcBackADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
905 int buffer = prepostAddress(prepost);
909 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (28-16));}
910 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
912 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
913 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (21-16));}
920 unsigned short StTriggerData2022::zdcTimeDifference()
const
922 return L1_DSM->VTX[1]%256;
925 bool StTriggerData2022::zdcSumADCaboveThresholdL2(StBeamDirection eastwest)
const {
926 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 10 : 11));
929 bool StTriggerData2022::zdcFrontADCaboveThresholdL2(StBeamDirection eastwest)
const {
930 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 12 : 14));
933 bool StTriggerData2022::zdcBackADCaboveThresholdL2(StBeamDirection eastwest)
const {
934 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 13 : 15));
937 bool StTriggerData2022::zdcSumADCaboveThresholdL3(StBeamDirection eastwest)
const {
938 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 7 : 8)); }
939 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 7 : 8)); }
942 bool StTriggerData2022::zdcFrontADCaboveThresholdL3(StBeamDirection eastwest)
const {
943 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 9 : 11)); }
944 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 9 : 11)); }
947 bool StTriggerData2022::zdcBackADCaboveThresholdL3(StBeamDirection eastwest)
const {
948 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 10 : 12)); }
949 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 10 : 12)); }
952 bool StTriggerData2022::zdcTimeDifferenceInWindow()
const
954 if(mRun<12000000){
return lastDSM(2) & (1 << 6); }
955 else {
return lastDSM(1) & (1 << 6); }
958 unsigned short StTriggerData2022::zdcSMDHighestStrip(StBeamDirection eastwest,
int verthori,
int prepost)
const
960 if(mRun<12000000)
return 0;
962 int buffer = prepostAddress(prepost);
965 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 6 : 9)) % 8;}
966 else {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 0 : 3)) % 8;}
972 unsigned short StTriggerData2022::zdcTruncatedSum(StBeamDirection eastwest,
int prepost)
const
974 if(mRun<12000000)
return 0;
975 int buffer = prepostAddress(prepost);
978 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[2] >> (26-16)) % 8;}
979 else {
return (mBBC[buffer]->ZDClayer1[2] >> (29-16)) % 8;}
985 unsigned short StTriggerData2022::pp2ppADC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
987 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
988 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
989 if (vh<0 || vh>1)
return 0;
990 if (udio<0 || udio>1)
return 0;
991 if (ch<0 || ch>1)
return 0;
992 int buffer = prepostAddress(prepost);
993 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]];
997 unsigned short StTriggerData2022::pp2ppTAC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
999 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
1000 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
1001 if (vh<0 || vh>1)
return 0;
1002 if (udio<0 || udio>1)
return 0;
1003 if (ch<0 || ch>1)
return 0;
1004 int buffer = prepostAddress(prepost);
1005 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]+4];
1009 unsigned long StTriggerData2022::pp2ppDSM(
int prepost)
const {
1010 if (prepost!=0)
return 0;
1011 return L1_DSM->TOF[7];
1014 unsigned short StTriggerData2022::bemcLayer1DSM(
int channel,
int prepost)
const {
1015 const int n_bemc_layer1=48;
1016 if (channel<0 || channel >=n_bemc_layer1) {
1017 gMessMgr->Warning() <<
"Barrel DSM layer 1 out of range (" << channel <<
")" << endm;
1020 int buffer = prepostAddress(prepost);
1021 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1[channel];
1025 unsigned short StTriggerData2022::eemcLayer1DSM(
int channel,
int prepost)
const {
1026 const int n_eemc_layer1=16;
1027 if (channel<0 || channel >=n_eemc_layer1) {
1028 gMessMgr->Warning() <<
"Endap DSM layer 1 out of range (" << channel <<
")" << endm;
1031 int buffer = prepostAddress(prepost);
1032 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1[channel];
1036 unsigned short StTriggerData2022::emcLayer2DSM(
int channel)
const {
1037 const int n_emc_layer2=8;
1038 if (channel<0 || channel >=n_emc_layer2) {
1039 gMessMgr->Warning() <<
"EMC DSM layer 2 out of range (" << channel <<
")" << endm;
1042 return L1_DSM->EMC[channel];
1045 unsigned short StTriggerData2022::tpcMaskDSM(
int channel)
const {
1046 const int n_tpcMask=8;
1047 if (channel<0 || channel >=n_tpcMask) {
1048 gMessMgr->Warning() <<
"TPCMask DSM out of range (" << channel <<
")" << endm;
1051 return L1_DSM->TPCMask[channel];
1054 unsigned char StTriggerData2022::bemcHighTower(
int patch_id,
int prepost)
const {
1056 const int m_max_patch=300;
1057 if ( patch_id < 0 || patch_id >= m_max_patch) {
1058 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
1061 int buffer = prepostAddress(prepost);
1063 int dsm=patch_id/10;
1064 int channel=patch_id%10;
1065 unsigned short trg_word;
1068 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
1074 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
1078 return trg_word & 0x3F;
1083 unsigned char StTriggerData2022::bemcJetPatch (
int patch_id,
int prepost)
const
1086 const int m_max_patch=300;
1087 if ( patch_id < 0 || patch_id >= m_max_patch) {
1088 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
1091 int buffer = prepostAddress(prepost);
1093 int dsm=patch_id/10;
1094 int channel=patch_id%10;
1095 unsigned short trg_word;
1098 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
1104 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
1108 return trg_word >> 6;
1114 unsigned char StTriggerData2022::eemcHighTower(
int patch_id,
int prepost)
const
1117 const int m_max_patch=90;
1118 if ( patch_id < 0 || patch_id >= m_max_patch) {
1119 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
1122 int buffer = prepostAddress(prepost);
1123 if (buffer >= 0 && mBC1[buffer]) {
1124 int dsm=patch_id/10;
1125 int channel=patch_id%10;
1126 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
1127 return trg_word & 0x3F;
1132 unsigned char StTriggerData2022::eemcJetPatch (
int patch_id,
int prepost)
const
1135 const int m_max_patch=90;
1136 if ( patch_id < 0 || patch_id >= m_max_patch) {
1137 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
1140 int buffer = prepostAddress(prepost);
1141 if (buffer >= 0 && mBC1[buffer]) {
1142 int dsm=patch_id/10;
1143 int channel=patch_id%10;
1144 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
1145 return trg_word >> 6;
1150 unsigned char StTriggerData2022::bemcHighestTowerADC(
int prepost)
const {
1152 const int m_max_patch=300;
1154 for (
int i=1; i<m_max_patch; i++){
1155 unsigned char hh=bemcHighTower(i,prepost);
1161 unsigned char StTriggerData2022::eemcHighestTowerADC(
int prepost)
const {
1163 const int m_max_patch=90;
1165 for (
int i=1; i<m_max_patch; i++){
1166 unsigned char hh=eemcHighTower(i,prepost);
1172 char* StTriggerData2022::getTriggerStructure()
1174 return (
char*) mData;
1182 int StTriggerData2022::getRawSize()
const
1184 return mData->totalTriggerLength;
1187 unsigned char* StTriggerData2022::getDsm0_BEMCE(
int prepost)
const {
1188 int buffer = prepostAddress(prepost);
1189 if (buffer >= 0)
if (mBCE[buffer])
return mBCE[buffer]->BEMCEast;
1193 unsigned char* StTriggerData2022::getDsm0_BEMCW(
int prepost)
const {
1194 int buffer = prepostAddress(prepost);
1195 if (buffer >= 0)
if (mBCW[buffer])
return mBCW[buffer]->BEMCWest;
1199 unsigned short* StTriggerData2022::getDsm1_BEMC(
int prepost)
const {
1200 int buffer = prepostAddress(prepost);
1201 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1;
1205 unsigned char* StTriggerData2022::getDsm0_EEMC(
int prepost)
const {
1206 int buffer = prepostAddress(prepost);
1207 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMC;
1211 unsigned short* StTriggerData2022::getDsm1_EEMC(
int prepost)
const{
1212 int buffer = prepostAddress(prepost);
1213 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1;
1217 unsigned short* StTriggerData2022::getDsm2_EMC()
const{
1221 unsigned short* StTriggerData2022::getDsm3()
const{
1222 return L1_DSM->lastDSM;
1225 int StTriggerData2022::L2ResultsOffset(StL2AlgorithmId
id)
const
1228 default:
return -999999999;
1232 bool StTriggerData2022::isL2Triggered(StL2TriggerResultType
id)
const
1237 unsigned int StTriggerData2022::l2ResultLength()
const
1239 return sizeof(TrgSum->L2Result)/
sizeof(
unsigned int);
1242 const unsigned int* StTriggerData2022::l2Result()
const
1244 return TrgSum->L2Result;
1247 unsigned long long StTriggerData2022::l2sum()
const
1251 unsigned long long hi = TrgSum->L2Sum[1];
1252 unsigned long long lo = TrgSum->L2Sum[0];
1253 unsigned long long mask=(hi<<32) | lo;
1257 unsigned short StTriggerData2022::vpdADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1259 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1260 if (pmt<1 || pmt>16)
return 0;
1261 int buffer = prepostAddress(prepost);
1263 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]];}
1264 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1269 unsigned short StTriggerData2022::vpdTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1271 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1272 if (pmt<1 || pmt>16)
return 0;
1273 int buffer = prepostAddress(prepost);
1275 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]+4];}
1276 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1281 unsigned short StTriggerData2022::vpdADCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1283 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1284 if (pmt<1 || pmt>16)
return 0;
1285 int buffer = prepostAddress(prepost);
1287 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1288 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1293 unsigned short StTriggerData2022::vpdTDCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1295 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1296 if (pmt<1 || pmt>16)
return 0;
1297 int buffer = prepostAddress(prepost);
1299 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1300 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]+4];};
1305 unsigned short StTriggerData2022::vpdEarliestTDC(StBeamDirection eastwest,
int prepost)
const
1307 int buffer = prepostAddress(prepost);
1310 if (mRun<=10096084){
1311 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1312 else {
return mBBC[buffer]->VPD[4]%4096;}
1314 else if(mRun<=12003001) {
1315 if (eastwest==east) {
return mBBC[buffer]->VPD[2]%4096;}
1316 else {
return mBBC[buffer]->VPD[0]%4096;}
1319 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1320 else {
return mBBC[buffer]->VPD[4]%4096;}
1328 unsigned short StTriggerData2022::vpdEarliestTDCHighThr(StBeamDirection eastwest,
int prepost)
const
1330 int buffer = prepostAddress(prepost);
1332 if (mRun<=10365999){
1335 else if(mRun<=12003001) {
1337 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1338 else {
return mBBC[buffer]->VPD[4]%4096;}
1340 }
else if(mRun<=14001001){
1342 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[13] + ((mMIX[buffer]->MTD_P2PLayer1[12]&0x0f)<<8);}
1343 else {
return mMIX[buffer]->MTD_P2PLayer1[9] + ((mMIX[buffer]->MTD_P2PLayer1[8]&0x0f)<<8);}
1347 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[11] + ((mMIX[buffer]->MTD_P2PLayer1[10]&0xf)<<8);}
1348 else {
return (mMIX[buffer]->MTD_P2PLayer1[10]>>4) + ((mMIX[buffer]->MTD_P2PLayer1[9]&0xff)<<4);}
1355 unsigned short StTriggerData2022::vpdADCSum(StBeamDirection eastwest,
int prepost)
const
1358 return (bbcVP101(4,prepost) & 0x7ff);
1360 return (bbcVP101(6,prepost) & 0x7ff);
1364 float StTriggerData2022::vpdMeanTimeDifference(
int prepost)
const
1367 unsigned int ne=(bbcVP101(4,prepost) >> 11) & 0x1f;
1368 unsigned int nw=(bbcVP101(6,prepost) >> 11) & 0x1f;
1369 unsigned int se=bbcVP101(5,prepost);
1370 unsigned int sw=bbcVP101(7,prepost);
1374 if(nenw>0)
return float(nwse-nesw)/float(nenw);
1378 unsigned short StTriggerData2022::bbcVP101(
int ch,
int prepost)
const
1380 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1381 if(ch<0 || ch>7)
return 0;
1382 int buffer = prepostAddress(prepost);
1383 if (buffer >= 0 && mBBC[buffer]){
1384 return mBBC[buffer]->VPD[map[ch]];
1390 unsigned short StTriggerData2022::dsmTF201Ch(
int ch)
const
1392 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1393 return L1_DSM->TOF[map[ch]];
1396 unsigned short StTriggerData2022::mtd4AtAddress(
int address,
int prepost)
const
1398 if (mRun<=15001001)
return 0;
1399 int buffer = prepostAddress(prepost);
1400 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][14][address];
1404 unsigned short StTriggerData2022::fmsADC(
int crt,
int adr,
int ch,
int prepost)
const
1406 int buffer = prepostAddress(prepost);
1407 if (buffer >= 0 && crt>=1 && crt<=8 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1409 case 0:
return bbq[buffer][adr][ch];
1410 case 5:
return eq3[buffer][adr][ch];
1411 case 6:
return eq1[buffer][adr][ch];
1412 case 7:
return eq2[buffer][adr][ch];
1413 case 8:
return eq4[buffer][adr][ch];
1419 unsigned short StTriggerData2022::fmsTDC(
int crt,
int adr,
int ch,
int prepost)
const
1421 int buffer = prepostAddress(prepost);
1422 if (buffer >= 0 && crt>=0 && crt<=8 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1424 case 0:
return tbbq[buffer][adr][ch];
1425 case 5:
return teq3[buffer][adr][ch];
1426 case 6:
return teq1[buffer][adr][ch];
1427 case 7:
return teq2[buffer][adr][ch];
1428 case 8:
return teq4[buffer][adr][ch];
1434 unsigned short StTriggerData2022::epdADC(
int crt,
int adr,
int ch,
int prepost)
const
1436 int buffer = prepostAddress(prepost);
1437 if (buffer >= 0 && crt>=1 && crt<=4 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1439 case 1:
return eq1[buffer][adr][ch];
1440 case 2:
return eq2[buffer][adr][ch];
1441 case 3:
return eq3[buffer][adr][ch];
1442 case 4:
return eq4[buffer][adr][ch];
1448 unsigned short StTriggerData2022::epdTDC(
int crt,
int adr,
int ch,
int prepost)
const
1450 int buffer = prepostAddress(prepost);
1451 if (buffer >= 0 && crt>=1 && crt<=4 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1453 case 1:
return teq1[buffer][adr][ch];
1454 case 2:
return teq2[buffer][adr][ch];
1455 case 3:
return teq3[buffer][adr][ch];
1456 case 4:
return teq4[buffer][adr][ch];
1462 unsigned short StTriggerData2022::mxqAtSlotAddress(
int address,
int prepost,
int slot)
const
1464 int buffer = prepostAddress(prepost);
1465 if (buffer >= 0 && address>=0 && address<32){
1466 if (slot >= 0 && slot<16){
1467 return mxq[buffer][slot][address];
1473 unsigned short StTriggerData2022::mtdQtAtCh(
int qtid,
int address,
int prepost)
const
1475 int map1[4] = {0, 10, 12, 14};
1476 int map2[8] = {0, 9, 10, 11, 12, 13, 14, 15};
1477 int map3[4] = {0, 9, 11, 13};
1479 int buffer = prepostAddress(prepost);
1480 if(buffer>=0 && qtid>0 && address>=0 && address<32){
1482 if(qtid>1)
return 0;
1483 else return mxq[buffer][map1[qtid-1]][address];
1485 else if(mRun<=14001001){
1486 if(qtid>2)
return 0;
1487 else return mxq[buffer][map1[qtid-1]][address];
1489 else if(mRun<=15001001){
1490 if(qtid>3)
return 0;
1491 else return mxq[buffer][map1[qtid-1]][address];
1493 else if(mRun<=17001001){
1494 if(qtid>4)
return 0;
1495 else return mxq[buffer][map1[qtid-1]][address];
1497 else if(mRun<=18001001){
1498 if(qtid>8)
return 0;
1499 else return mxq[buffer][map2[qtid-1]][address];
1502 if(qtid>4)
return 0;
1503 else return mxq[buffer][map3[qtid-1]][address];
1510 unsigned short StTriggerData2022::mtdAtAddress(
int address,
int prepost)
const
1512 int buffer = prepostAddress(prepost);
1513 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][0][address];
1517 unsigned short StTriggerData2022::mtdgemAtAddress(
int address,
int prepost)
const
1519 if (mRun<=12003001)
return 0;
1520 int buffer = prepostAddress(prepost);
1521 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][10][address];
1525 unsigned short StTriggerData2022::mtd3AtAddress(
int address,
int prepost)
const
1527 if (mRun<=14001001)
return 0;
1528 int buffer = prepostAddress(prepost);
1529 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][12][address];
1534 unsigned short StTriggerData2022::mtdAdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1537 int buffer = prepostAddress(prepost);
1538 if (buffer >= 0 && pmt==0){
1539 if (eastwest==east) {
1540 if (mRun<=10133008)
return mxq[buffer][0][0];
1541 else return mxq[buffer][0][24];
1543 if (eastwest==west)
return mxq[buffer][0][8];
1548 unsigned short StTriggerData2022::mtdTdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1551 int buffer = prepostAddress(prepost);
1552 if (buffer >= 0 && pmt==0){
1553 if (eastwest==east) {
1554 if (mRun<=10133008)
return mxq[buffer][0][4];
1555 else return mxq[buffer][0][28];
1557 if (eastwest==west)
return mxq[buffer][0][12];
1562 unsigned char StTriggerData2022::mtdDsmAtCh(
int ch,
int prepost)
const
1564 int map[16] = {7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8};
1566 int buffer = prepostAddress(prepost);
1567 if (buffer >= 0 && ch>=0){
1570 return mMIX[buffer]->MTD_P2PLayer1[map[ch]];
1583 bool StTriggerData2022::mtdDsmHit(
int pmt,
int prepost)
const
1586 int buffer = prepostAddress(prepost);
1589 if(mRun<10133008 && mRun<11000000){
1590 if( (mMIX[buffer]->MTD_P2PLayer1[5] & 0x1) && (mMIX[buffer]->MTD_P2PLayer1[5] & 0x10) )
return true;
1593 if(prepost!=0)
return false;
1594 return (L1_DSM->TOF[3] & 0x1);
1601 unsigned short StTriggerData2022::mtdVpdTacDiff()
const
1603 return (L1_DSM->TOF[3] & 0x3fff);
1606 unsigned short StTriggerData2022::tofAtAddress(
int address,
int prepost)
const
1608 int buffer = prepostAddress(prepost);
1609 if (buffer>=0 && address>=0 && address<48) {
1610 if (mMIX[buffer])
return mMIX[buffer]->TOF[address];
1615 unsigned short StTriggerData2022::tofTrayMultiplicity(
int tray,
int prepost)
const
1617 int dsmmap[8] = {3,2,1,0,7,6,5,4};
1618 int traydsm[120] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5,
1619 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
1620 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1621 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
1622 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
1623 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
1624 int traych[120] = { 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1625 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1626 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1627 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1628 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1629 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17};
1630 int buffer = prepostAddress(prepost);
1631 if (buffer>=0 && tray>=1 && tray<=120) {
1633 int address = traydsm[tray-1]*8 + dsmmap[traych[tray-1]/3];
1634 int ch = traych[tray-1]%3;
1635 return (mMIX[buffer]->TOF[address] >> (5*ch)) & 0x1f;
1641 unsigned short StTriggerData2022::tofMultiplicity(
int prepost)
const
1643 if (prepost==0)
return L1_DSM->TOF[1]%8192;
1647 void StTriggerData2022::dump()
const
1649 printf(
"***** StTriggerData Dump *****\n");
1650 printf(
" mDebug=%d mData=%p\n",mDebug,mData);
1651 printf(
" Year=%d EvtDesc version=%x header version%x\n",year(),version(),mData->FormatVersion);
1652 printf(
" Run#=%d Event#=%d\n",mRun,eventNumber());
1653 printf(
" %d pre and %d post crossing data available\n",numberOfPreXing(),numberOfPostXing());
1654 printf(
" Token=%d TriggerWord=%x ActionWord=%x BusyStatus=%x\n",
1655 token(), triggerWord(), actionWord(), busyStatus());
1656 printf(
" TUC Bits=%d : ",tcuBits());
1657 for (
int i=0; i<16; i++) {printf(
" %d",(tcuBits()>>(15-i))%2);}; printf(
"\n");
1658 printf(
" BunchId 7bit=%d 48bit=%d\n",bunchId7Bit(), bunchId48Bit());
1659 printf(
" Spin Bits=%d : ",spinBit());
1660 for (
int i=0; i<8; i++) {printf(
" %d",(spinBit()>>(7-i))%2);}; printf(
"\n");
1662 printf(
" BBC East ADC : ");
for (
int i=1; i<=16;i++){ printf(
"%2d ",bbcADC(east,i,0)); }; printf(
"\n");
1663 printf(
" BBC East TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%2d ",bbcTDC(east,i,0)); }; printf(
"\n");
1664 printf(
" BBC West ADC : ");
for (
int i=1; i<=16;i++){ printf(
"%2d ",bbcADC(west,i,0)); }; printf(
"\n");
1665 printf(
" BBC West TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%2d ",bbcTDC(west,i,0)); }; printf(
"\n");
1666 for (
int i=-numberOfPreXing(); i<=static_cast<int>(numberOfPostXing()); i++){
1667 printf(
" BBC Sums %d xing : ",i);
1668 printf(
"East=%d West=%d Large tile East=%d West=%d\n",
1669 bbcADCSum(east,i),bbcADCSum(west,i),
1670 bbcADCSumLargeTile(east,i),bbcADCSumLargeTile(west,i));
1672 printf(
" BBC Earilest : "); printf(
"East=%d West=%d Difference+256=%d\n",
1673 bbcEarliestTDC(east,0),bbcEarliestTDC(west,0),bbcTimeDifference());
1674 printf(
" ZDC Earilest : "); printf(
"East=%d West=%d Difference=%d\n",
1675 zdcEarliestTDC(east,0),zdcEarliestTDC(west,0),zdcTimeDifference());
1676 printf(
" ZDC Sum(A) East : ");printf(
"%d ",zdcAttenuated(east)); printf(
"\n");
1677 printf(
" ZDC Sum(A) West : ");printf(
"%d ",zdcAttenuated(west)); printf(
"\n");
1678 printf(
" ZDC Sum(UA) East : ");printf(
"%d ",zdcUnAttenuated(east)); printf(
"\n");
1679 printf(
" ZDC Sum(UA) West : ");printf(
"%d ",zdcUnAttenuated(west)); printf(
"\n");
1680 printf(
" VPD E Earliest TAC : %d\n", vpdEarliestTDC(east));
1681 printf(
" VPD W Earliest TAC : %d\n", vpdEarliestTDC(west));
1682 printf(
" VPD TimeDifference : %d\n", vpdTimeDifference());
1683 printf(
" L2 result : \n");
1684 for (
int j=0; j<4 ;j++) {
for (
int k=0; k<16; k++) {printf(
"%u ",*(l2Result()+j*16+k)); } printf(
"\n");}
1685 printf(
"BBClayer1:");
1686 int buffer = prepostAddress(0);
1689 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->BBClayer1[i]);
1693 printf(
"ZDClayer1:");
1696 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->ZDClayer1[i]);
1700 printf(
"VPDlayer1:");
1703 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->VPD[i]);
1706 printf(
"TOFMult=%d\n",tofMultiplicity());
1710 int map[4][16]={ {0x01,0xff, 0x02,0xff, 0x03,0xff, 0x04,0xff, 0x05,0xff, 0x06,0xff, 0x07,0xff, 0x08,0xff},
1711 {0x11,0xff, 0x12,0xff, 0x13,0xff, 0x14,0xff, 0x15,0xff, 0x16,0xff, 0x17,0xff, 0x18,0xff},
1712 {0x21,0xff, 0x22,0xff, 0x23,0xff, 0x24,0xff, 0x25,0xff, 0x26,0xff, 0x27,0xff, 0x28,0xff},
1713 {0x31,0xff, 0x32,0xff, 0x33,0xff, 0x34,0xff, 0x35,0xff, 0x36,0xff, 0x37,0xff, 0x38,0xff}};
1714 int mbc[4][16]={ {0x0c,0xff, 0x0c,0xff, 0x0b,0xff, 0x0b,0xff, 0x0c,0xff, 0x0c,0xff, 0x0d,0xff, 0x0b,0xff},
1715 {0x0c,0xff, 0x0c,0xff, 0x0b,0xff, 0x0b,0xff, 0x0c,0xff, 0x0c,0xff, 0x0d,0xff, 0x0b,0xff},
1716 {0x0c,0xff, 0x0c,0xff, 0x0b,0xff, 0x0b,0xff, 0x0c,0xff, 0x0d,0xff, 0x0b,0xff, 0x0b,0xff},
1717 {0x0c,0xff, 0x0b,0xff, 0x0b,0xff, 0x0b,0xff, 0x0c,0xff, 0x0c,0xff, 0x0d,0xff, 0x0b,0xff}};
1718 int epdm[4][16]; memset(epdm,0,
sizeof(epdm));
1719 for(
int c=1; c<=4; c++){
1720 for(
int s=0; s<16; s++){
1721 int bcd=mbc[c-1][s] & 0x0f;
1724 printf(
"EQ%1d S=%2d EQ0%02x bd=%1x 1/2 : ",c,s,eq,bcd);
1726 printf(
"EQ%1d S=%2d EQ bd= 1/2 : ",c,s);
1728 for (
int ch=0; ch<32; ch++){
1731 printf(
"\nEQ%1d S=%2d EQ0%02x bd=%1x 2/2 : ",c,s,eq,bcd);
1733 printf(
"\nEQ%1d S=%2d EQ bd= 1/2 : ",c,s);
1736 printf(
"%4d ",epdADC(c,s,ch));
1737 if(map[c-1][s]<0xff){
1738 if(mbc[c-1][s]==0xb){
1739 if(epdADC(c,s,ch)>16) epdm[c-1][s]++;
1740 }
else if(mbc[c-1][s]==0xc && (ch/4)%2==0){
1741 if(epdADC(c,s,ch)>16 && epdADC(c,s,ch+4)>300 && epdADC(c,s,ch+4)<2900) epdm[c-1][s]++;
1745 printf(
" mult=%d\n",epdm[c-1][s]);
1748 printf(
"EP001 TAC+hit: ");
for(
int c=0; c<8; c++){ printf(
"%4x ",epdLayer0t(c));} printf(
"\n");
1749 printf(
"EP002 TAC+hit: ");
for(
int c=8; c<16; c++){ printf(
"%4x ",epdLayer0t(c));} printf(
"\n");
1750 printf(
"EP003 Nhit: ");
for(
int c=0; c<8; c++){ printf(
"%2d ",epdLayer0aMult(c));} printf(
"\n");
1751 printf(
"EP004 Nhit: ");
for(
int c=8; c<16; c++){ printf(
"%2d ",epdLayer0aMult(c));} printf(
"\n");
1768 printf(
"EPD(VP201) mult total = %3d diff= %3d\n",epdMultTotal(),epdMultDiff());
1772 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->VTX[i]);
1775 printf(
"Last DSM:");
1777 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->lastDSM[i]);
1780 printf(
"***** End StTriggerData Dump *****\n");
1783 void StTriggerData2022::swapRawDet(
DataBlock2022* data,
int name,
int hlength,
int bs)
1789 int header_length = 8;
1790 if(bs) swapI((
unsigned int*)&data->length);
1792 case y22MXQ_CONF_NUM :
case y22EQ3_CONF_NUM :
case y22BBQ_CONF_NUM :
1793 case y22QT1_CONF_NUM :
case y22QT2_CONF_NUM :
case y22QT3_CONF_NUM :
case y22QT4_CONF_NUM :
1794 case y22EQ1_CONF_NUM :
case y22EQ2_CONF_NUM :
case y22EQ4_CONF_NUM :
1795 header_length = 12;
break;
1797 if (hlength != data->length + header_length){
1798 mErrorFlag = mErrorFlag | (1 << name);
1799 printf(
"StTriggerData2022: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
1800 name,data->name[0],data->name[1],data->name[2],data->name[3],
1801 hlength,data->length,header_length);
1802 printf(
"StTriggerData2022: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
1803 name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
1809 case y22BC1_CONF_NUM :
1811 swapSSn((
unsigned int*)bc1->BEMClayer1,48);
1812 swapSSn((
unsigned int*)bc1->EEMClayer1,16);
1814 case y22MIX_CONF_NUM :
1817 swapSSn((
unsigned int*)mix->TOFLayer1,8+48);
1819 case y22BCW_CONF_NUM :
1822 case y22BCE_CONF_NUM :
1825 case y22BBC_CONF_NUM :
1828 swapSSn((
unsigned int*)bbc->BBClayer1,(data->length)/2);
1831 case y22FMS_CONF_NUM :
1834 case y22MXQ_CONF_NUM :
1835 case y22EQ3_CONF_NUM :
1836 case y22BBQ_CONF_NUM :
1837 case y22QT1_CONF_NUM :
1838 case y22QT2_CONF_NUM :
1839 case y22QT3_CONF_NUM :
1840 case y22QT4_CONF_NUM :
1841 case y22EQ1_CONF_NUM :
1842 case y22EQ2_CONF_NUM :
1843 case y22EQ4_CONF_NUM :
1845 swapI((
unsigned int*)&qtdata->dataLoss);
1846 swapIn(qtdata->data, qtdata->length/4);
1851 printf(
"Read id=%2d name=%1c%1c%1c%1c length=%d\n",
1852 name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
1855 void StTriggerData2022::Streamer(TBuffer &R__b)
1859 if (R__b.IsReading()) {
1860 R__b.ReadClassBuffer(StTriggerData2022::Class(),
this);
1862 if(mData) readData();
1865 R__b.WriteClassBuffer(StTriggerData2022::Class(),
this);