36 #include "StTriggerData2017.h"
49 mYear=2017; mRun = run; mDebug = 0;
56 mYear=2017; mRun = run; mDebug = dbg;
57 if(mDebug==1) printf(
"StTriggerData2017 Constructor with trigger data block and byteswap option=%d\n",bs);
64 if (data==0) {copyflag=0;}
65 if(mDebug==1) printf(
"StTriggerData2017::readData copyflag=%d byteswap=%d data=%p mData=%p\n",copyflag,bs,data,mData);
68 unsigned int ver = data->FormatVersion;
71 if (ver == y17FORMAT_VERSION ) {
72 if (mDebug==1) printf(
"StTriggerData2017: version = 0x%x (0x%x or 0x08121140)\n",ver,y17FORMAT_VERSION);
75 mErrorFlag = mErrorFlag | 0x1;
76 printf(
"StTriggerData2017: version = 0x%x != (0x%x)\n",ver,y17FORMAT_VERSION);
80 unsigned int size = data->totalTriggerLength;
82 if (size > y17MAX_TRG_BLK_SIZE) {
83 gMessMgr->Warning() <<
"StTriggerData2017: Data length = " << size
84 <<
" is bigger than max = " << y17MAX_TRG_BLK_SIZE
88 if (mDebug==1) printf(
"StTriggerData2017: size = %d, maxsize = %d\n",size,y17MAX_TRG_BLK_SIZE);
89 memcpy(mData,data,size);
93 if (bs) swapDataBlk(mData);
95 printf(
"StTriggerData2017: version = 0x%x (0x%x)\n",mData->FormatVersion,y17FORMAT_VERSION);
96 printf(
"StTriggerData2017: size = %d, maxsize = %d\n",mData->totalTriggerLength,y17MAX_TRG_BLK_SIZE);
97 printf(
"EventDesc length=%10d offset=%10d\n",mData->EventDesc_ofl.length,mData->EventDesc_ofl.offset);
98 printf(
"L1_DSM length=%10d offset=%10d\n",mData->L1_DSM_ofl.length,mData->L1_DSM_ofl.offset);
99 printf(
"Summary length=%10d offset=%10d\n",mData->Summary_ofl.length,mData->Summary_ofl.offset);
102 EvtDesc=0; L1_DSM=0; TrgSum=0;
103 if (mData->EventDesc_ofl.length > 0) EvtDesc = (
EvtDescData2017*)((
char*)mData + mData->EventDesc_ofl.offset);
104 if (mData->L1_DSM_ofl.length > 0) L1_DSM = (
L1_DSM_Data2017*)((
char*)mData + mData->L1_DSM_ofl.offset);
105 if (mData->Summary_ofl.length > 0) TrgSum = (
TrgSumData2017* )((
char*)mData + mData->Summary_ofl.offset);
107 if (EvtDesc) swapEvtDesc(EvtDesc);
108 if (L1_DSM) swapL1_DSM(L1_DSM);
109 if (TrgSum) swapTrgSum(TrgSum);
111 if (EvtDesc==0 || L1_DSM==0 || TrgSum==0){
112 mErrorFlag = mErrorFlag | 0x1;
113 gMessMgr->Warning() <<
"StTriggerData2017: EvtDesc, L1_DSM or TrgSum is missing"
114 <<
" mErrorFlag="<<mErrorFlag<<endm;
117 int npre = numberOfPreXing();
118 int npost = numberOfPostXing();
119 if (npre<0 || npre>10 || npost<0 || npost>10){
120 mErrorFlag = mErrorFlag | 0x2;
121 gMessMgr->Warning() <<
"StTriggerData2017: Invalid npre/post = "<< npre <<
" / " << npost
122 <<
" mErrorFlag="<<mErrorFlag<<endm;
124 if (mDebug==1) printf(
"StTriggerData2017: pre=%d post=%d\n",npre,npost);
126 memset(mBC1,0,
sizeof(mBC1));
127 memset(mMXQ,0,
sizeof(mMXQ));
128 memset(mMIX,0,
sizeof(mMIX));
129 memset(mBCW,0,
sizeof(mBCW));
130 memset(mBCE,0,
sizeof(mBCE));
131 memset(mEPQ,0,
sizeof(mEPQ));
132 memset(mBBC,0,
sizeof(mBBC));
133 memset(mBBQ,0,
sizeof(mBBQ));
134 memset(mFMS,0,
sizeof(mFMS));
135 memset(mQT1,0,
sizeof(mQT1));
136 memset(mQT2,0,
sizeof(mQT2));
137 memset(mQT3,0,
sizeof(mQT3));
138 memset(mQT4,0,
sizeof(mQT4));
139 memset(mFQ1,0,
sizeof(mFQ1));
140 memset(mFQ2,0,
sizeof(mFQ2));
141 memset(mxq,0,
sizeof(mxq)); memset(tmxq,0,
sizeof(tmxq));
142 memset(epq,0,
sizeof(epq)); memset(tepq,0,
sizeof(tepq));
143 memset(bbq,0,
sizeof(bbq)); memset(tbbq,0,
sizeof(tbbq));
144 memset(qt1,0,
sizeof(qt1)); memset(tqt1,0,
sizeof(tqt1));
145 memset(qt2,0,
sizeof(qt2)); memset(tqt2,0,
sizeof(tqt2));
146 memset(qt3,0,
sizeof(qt3)); memset(tqt3,0,
sizeof(tqt3));
147 memset(qt4,0,
sizeof(qt4)); memset(tqt4,0,
sizeof(tqt4));
148 memset(fq1,0,
sizeof(fq1)); memset(tfq1,0,
sizeof(tfq1));
149 memset(fq2,0,
sizeof(fq2)); memset(tfq2,0,
sizeof(tfq2));
152 for (
int i=0; i<1+npre+npost; i++){
155 offlen = mData->MainX;
159 if (mData->PrePostList[i-1]==0)
continue;
160 offlen = (
TrgOfflen2017*) ((
char*)mData + mData->PrePostList[i-1]);
162 if (bs) swapRawDetOfflen(offlen);
163 for(
int k=0; k<y17MAX_OFFLEN; k++){
164 if(static_cast<unsigned int>(offlen[k].length + offlen[k].offset) > static_cast<unsigned int>(mData->totalTriggerLength)) {
165 mErrorFlag = mErrorFlag | (1 << k);
166 gMessMgr->Warning() <<
"StTriggerData2017: offset ("<<offlen[k].offset<<
") + length ("<<offlen[k].length
167 <<
") exceeds total size("<<mData->totalTriggerLength<<
") for data block id="<<k
168 <<
" mErrorFlag="<<mErrorFlag<<endm;
172 j=offlen[y17BC1_CONF_NUM].length;
if (j>0){mBC1[i] = (
BELayerBlock2017*)((
char*)mData + offlen[y17BC1_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mBC1[i],y17BC1_CONF_NUM,j,bs);}
173 j=offlen[y17MXQ_CONF_NUM].length;
if (j>0){mMXQ[i] = (
QTBlock2017* )((
char*)mData + offlen[y17MXQ_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mMXQ[i],y17MXQ_CONF_NUM,j,bs);}
174 j=offlen[y17MIX_CONF_NUM].length;
if (j>0){mMIX[i] = (
MIXBlock2017* )((
char*)mData + offlen[y17MIX_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mMIX[i],y17MIX_CONF_NUM,j,bs);}
175 j=offlen[y17BCW_CONF_NUM].length;
if (j>0){mBCW[i] = (
BWestBlock2017* )((
char*)mData + offlen[y17BCW_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mBCW[i],y17BCW_CONF_NUM,j,bs);}
176 j=offlen[y17BCE_CONF_NUM].length;
if (j>0){mBCE[i] = (
BEastBlock2017* )((
char*)mData + offlen[y17BCE_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mBCE[i],y17BCE_CONF_NUM,j,bs);}
177 j=offlen[y17EPQ_CONF_NUM].length;
if (j>0){mEPQ[i] = (
QTBlock2017* )((
char*)mData + offlen[y17EPQ_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mEPQ[i],y17EPQ_CONF_NUM,j,bs);}
178 j=offlen[y17BBC_CONF_NUM].length;
if (j>0){mBBC[i] = (
BBCBlock2017* )((
char*)mData + offlen[y17BBC_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mBBC[i],y17BBC_CONF_NUM,j,bs);}
179 j=offlen[y17BBQ_CONF_NUM].length;
if (j>0){mBBQ[i] = (
QTBlock2017* )((
char*)mData + offlen[y17BBQ_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mBBQ[i],y17BBQ_CONF_NUM,j,bs);}
180 j=offlen[y17FMS_CONF_NUM].length;
if (j>0){mFMS[i] = (
FMSBlock2017* )((
char*)mData + offlen[y17FMS_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mFMS[i],y17FMS_CONF_NUM,j,bs);}
181 j=offlen[y17QT1_CONF_NUM].length;
if (j>0){mQT1[i] = (
QTBlock2017* )((
char*)mData + offlen[y17QT1_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mQT1[i],y17QT1_CONF_NUM,j,bs);}
182 j=offlen[y17QT2_CONF_NUM].length;
if (j>0){mQT2[i] = (
QTBlock2017* )((
char*)mData + offlen[y17QT2_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mQT2[i],y17QT2_CONF_NUM,j,bs);}
183 j=offlen[y17QT3_CONF_NUM].length;
if (j>0){mQT3[i] = (
QTBlock2017* )((
char*)mData + offlen[y17QT3_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mQT3[i],y17QT3_CONF_NUM,j,bs);}
184 j=offlen[y17QT4_CONF_NUM].length;
if (j>0){mQT4[i] = (
QTBlock2017* )((
char*)mData + offlen[y17QT4_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mQT4[i],y17QT4_CONF_NUM,j,bs);}
185 j=offlen[y17FQ1_CONF_NUM].length;
if (j>0){mFQ1[i] = (
QTBlock2017* )((
char*)mData + offlen[y17FQ1_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mFQ1[i],y17FQ1_CONF_NUM,j,bs);}
186 j=offlen[y17FQ2_CONF_NUM].length;
if (j>0){mFQ2[i] = (
QTBlock2017* )((
char*)mData + offlen[y17FQ2_CONF_NUM].offset); swapRawDet((
DataBlock2017*)mFQ2[i],y17FQ2_CONF_NUM,j,bs);}
187 if (mMXQ[i]) decodeQT(mMXQ[i]->length/4, mMXQ[i]->data, mxq[i], tmxq[i]);
188 if (mEPQ[i]) decodeQT(mEPQ[i]->length/4, mEPQ[i]->data, epq[i], tepq[i]);
189 if (mBBQ[i]) decodeQT(mBBQ[i]->length/4, mBBQ[i]->data, bbq[i], tbbq[i]);
190 if (mQT1[i]) decodeQT(mQT1[i]->length/4, mQT1[i]->data, qt1[i], tqt1[i]);
191 if (mQT2[i]) decodeQT(mQT2[i]->length/4, mQT2[i]->data, qt2[i], tqt2[i]);
192 if (mQT3[i]) decodeQT(mQT3[i]->length/4, mQT3[i]->data, qt3[i], tqt3[i]);
193 if (mQT4[i]) decodeQT(mQT4[i]->length/4, mQT4[i]->data, qt4[i], tqt4[i]);
194 if (mFQ1[i]) decodeQT(mFQ1[i]->length/4, mFQ1[i]->data, fq1[i], tfq1[i]);
195 if (mFQ2[i]) decodeQT(mFQ2[i]->length/4, mFQ2[i]->data, fq2[i], tfq2[i]);
197 if (mDebug==1) dump();
200 StTriggerData2017::~StTriggerData2017() {
delete mData;}
202 unsigned int StTriggerData2017::version()
const
204 return EvtDesc->TrgDataFmtVer;
207 unsigned int StTriggerData2017::eventNumber()
const
209 return mData->eventNumber;
212 unsigned int StTriggerData2017::token()
const
214 return EvtDesc->TrgToken;
217 unsigned int StTriggerData2017::triggerWord()
const
222 unsigned int StTriggerData2017::actionWord()
const
225 ( (
unsigned short)(EvtDesc->actionWdTrgCommand) * 16 * 16 * 16 ) +
226 ( (
unsigned short)(EvtDesc->actionWdDaqCommand) * 16 * 16 ) +
227 ( EvtDesc->actionWdDetectorBitMask & 0x00ff );
230 unsigned int StTriggerData2017::numberOfPreXing()
const
232 return EvtDesc->npre & 0xf;
235 unsigned int StTriggerData2017::numberOfPostXing()
const
237 return EvtDesc->npost & 0xf;
240 unsigned short StTriggerData2017::busyStatus()
const
242 return EvtDesc->internalBusy;
245 unsigned short StTriggerData2017::dsmInput()
const
247 return EvtDesc->DSMInput;
250 unsigned short StTriggerData2017::trgToken()
const
252 return EvtDesc->TrgToken;
255 unsigned short StTriggerData2017::dsmAddress()
const
257 return EvtDesc->DSMAddress;
260 unsigned short StTriggerData2017::mAddBits()
const
262 return EvtDesc->addBits;
265 unsigned short StTriggerData2017::bcData(
int channel)
const
267 return L1_DSM->BCdata[channel];
270 unsigned short StTriggerData2017::getTrgDetMask()
const
272 return EvtDesc->trgDetMask;
275 unsigned int StTriggerData2017::getTrgCrateMask()
const
277 unsigned int p = EvtDesc->npost & 0xfff0;
278 unsigned int r = EvtDesc->res1 & 0x0ff0;
280 ( ((EvtDesc->npre & 0xfff0) >> 4)
285 unsigned short StTriggerData2017::lastDSM(
int channel)
const
287 return L1_DSM->lastDSM[channel];
290 unsigned short StTriggerData2017::tcuBits()
const
292 return EvtDesc->DSMInput;
296 unsigned int StTriggerData2017::tcuCounter()
const
298 unsigned int hi = EvtDesc->tcuCtrBunch_hi;
299 return (hi << 16) + EvtDesc->DSMAddress;
302 unsigned int StTriggerData2017::rccCounter(
int crate)
const
304 if(crate >= y17L1_CONF_NUM && crate <= y17QT4_CONF_NUM){
305 return TrgSum->LocalClocks[crate];
310 unsigned long long StTriggerData2017::bunchCounter()
const
312 unsigned long long bxinghi,bxing1,bxinglo, bx;
313 bxinghi = L1_DSM->BCdata[3];
314 bxing1 = L1_DSM->BCdata[10];
315 bxinglo = (bxing1 << 16) + L1_DSM->BCdata[11];
316 bx = (bxinghi << 32) + bxinglo;
320 unsigned int StTriggerData2017::bunchCounterHigh()
const
322 return EvtDesc->bunchXing_hi;
325 unsigned int StTriggerData2017::bunchCounterLow()
const
327 return EvtDesc->bunchXing_lo;
330 unsigned int StTriggerData2017::bunchId48Bit()
const
332 return (
int)(bunchCounter() % 120);
335 unsigned int StTriggerData2017::bunchId7Bit()
const
338 b7dat = L1_DSM->BCdata[2];
343 unsigned int StTriggerData2017::spinBit()
const
346 return (L1_DSM->lastDSM[7]/16)%256;
348 return (L1_DSM->lastDSM[4]/16)%256;
352 unsigned int StTriggerData2017::spinBitYellowFilled()
const
354 unsigned int sb = spinBit();
358 unsigned int StTriggerData2017::spinBitYellowUp()
const
360 unsigned int sb = spinBit();
364 unsigned int StTriggerData2017::spinBitYellowDown()
const
366 unsigned int sb = spinBit();
370 unsigned int StTriggerData2017::spinBitYellowUnpol()
const
372 unsigned int sb = spinBit();
376 unsigned int StTriggerData2017::spinBitBlueFilled()
const
378 unsigned int sb = spinBit();
382 unsigned int StTriggerData2017::spinBitBlueUp()
const
384 unsigned int sb = spinBit();
388 unsigned int StTriggerData2017::spinBitBlueDown()
const
390 unsigned int sb = spinBit();
394 unsigned int StTriggerData2017::spinBitBlueUnpol()
const
396 unsigned int sb = spinBit();
400 unsigned short StTriggerData2017::bbcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
402 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
403 4, 4, 4, 4, 4, 4, 4, 4},
404 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 4, 4, 4, 4, 4, 4, 4, 4} };
406 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
407 0, 1, 2, 3, 8, 9,10,11},
408 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
409 16,17,18,19,24,25,26,27} };
410 int buffer = prepostAddress(prepost);
411 if (buffer >= 0 && pmt>=1 && pmt<=24)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
415 unsigned short StTriggerData2017::bbcTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
417 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
418 4, 4, 4, 4, 4, 4, 4, 4},
419 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 4, 4, 4, 4, 4, 4, 4, 4} };
421 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
422 0, 1, 2, 3, 8, 9,10,11},
423 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
424 16,17,18,19,24,25,26,27} };
425 int buffer = prepostAddress(prepost);
426 if (buffer >= 0 && pmt>=1 && pmt<=24)
return bbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]+4];
430 unsigned short StTriggerData2017::bbcTDC5bit(StBeamDirection eastwest,
int pmt,
int prepost)
const
432 const int addrmap[2][24] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
433 4, 4, 4, 4, 4, 4, 4, 4},
434 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 4, 4, 4, 4, 4, 4, 4, 4} };
436 const int chmap[2][24] = { { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
437 0, 1, 2, 3, 8, 9,10,11},
438 { 0, 3, 8,16,19,24, 1, 2, 9,10,11,17,18,25,26,27,
439 16,17,18,19,24,25,26,27} };
440 int buffer = prepostAddress(prepost);
441 if (buffer >= 0 && pmt>=1 && pmt<=24)
return tbbq[buffer][addrmap[eastwest][pmt-1]][chmap[eastwest][pmt-1]];
445 unsigned short StTriggerData2017::bbcADCSum(StBeamDirection eastwest,
int prepost)
const
447 unsigned short sum=0;
448 int buffer = prepostAddress(prepost);
452 if(eastwest==east) { sum = mBBC[buffer]->BBClayer1[3]; }
453 else { sum = mBBC[buffer]->BBClayer1[1]; }
459 unsigned short StTriggerData2017::bbcADCSumLargeTile(StBeamDirection eastwest,
int prepost)
const
461 unsigned short sum=0;
462 int buffer = prepostAddress(prepost);
463 if (buffer >= 0)
for(
int i=17; i<=24; i++) {sum+=bbcADC(eastwest,i,prepost);}
467 unsigned short StTriggerData2017::bbcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
469 int buffer = prepostAddress(prepost);
472 if (eastwest==east) {
return mBBC[buffer]->BBClayer1[2]%4096;}
473 else {
return mBBC[buffer]->BBClayer1[0]%4096;}
479 unsigned short StTriggerData2017::bbcTimeDifference()
const
481 return L1_DSM->VTX[3]%8192;
484 unsigned short StTriggerData2017::bbcTacSum()
const
486 return (((L1_DSM->VTX[3]) >> 13) & 0x1);
489 unsigned short StTriggerData2017::bbcEarliestTDCLarge(StBeamDirection eastwest,
int prepost)
const
491 int buffer = prepostAddress(prepost);
494 if (eastwest==east) {
return mBBC[buffer]->BBClayer1[11] & 0x0fff;}
495 else {
return ((mBBC[buffer]->BBClayer1[11] & 0xf000) >> 12)
496 +((mBBC[buffer]->BBClayer1[10] & 0x00ff) << 4 );}
502 unsigned short StTriggerData2017::bbcTimeDifferenceLarge()
const
504 return L1_DSM->VTX[2]%8192;
508 unsigned short StTriggerData2017::bbcBB101(
int ch,
int prepost)
const
510 int dsmmap[8] = {3,2,1,0,7,6,5,4};
511 int buffer = prepostAddress(prepost);
514 if(ch>=0 && ch<=7)
return mBBC[buffer]->BBClayer1[dsmmap[ch]];
520 unsigned short StTriggerData2017::bbcBB102(
int ch,
int prepost)
const
522 int dsmmap[8] = {3,2,1,0,7,6,5,4};
523 int buffer = prepostAddress(prepost);
526 if(ch>=0 && ch<=7)
return mBBC[buffer]->BBClayer1[dsmmap[ch]+8];
533 unsigned short StTriggerData2017::fpd(StBeamDirection eastwest,
int module,
int pmt,
int prepost)
const
538 unsigned short StTriggerData2017::fpdSum(StBeamDirection eastwest,
int module)
const
543 unsigned short StTriggerData2017::fpdLayer1DSMRaw(StBeamDirection eastwest,
int channel,
int prepost)
const{
544 int buffer = prepostAddress(prepost);
546 if (eastwest==east) {
if (mMIX[buffer])
return mMIX[buffer]->FPDEastNSLayer1[channel]; }
547 else {
if (mFMS[buffer])
return mFMS[buffer]->FMS[channel]; }
552 unsigned short StTriggerData2017::fpdLayer2DSMRaw(
int channel)
const{
553 if (channel<8)
return L1_DSM->FPD[channel];
557 bool StTriggerData2017::zdcPresent(
int prepost)
const
559 int buffer = prepostAddress(prepost);
560 if (buffer >= 0)
return mBBQ[buffer];
564 unsigned short StTriggerData2017::zdcAtChannel(
int channel,
int prepost)
const
566 int buffer = prepostAddress(prepost);
567 if (buffer >= 0 && channel>=0 && channel<32)
return bbq[buffer][14][channel];
571 unsigned short StTriggerData2017::zdcAtAddress(
int address,
int prepost)
const
573 return zdcAtChannel(address,prepost);
576 unsigned short StTriggerData2017::zdcUnAttenuated(StBeamDirection eastwest,
int prepost)
const
578 int buffer = prepostAddress(prepost);
580 if (eastwest == east)
return bbq[buffer][14][2];
581 else return bbq[buffer][14][18];
586 unsigned short StTriggerData2017::zdcAttenuated(StBeamDirection eastwest,
int prepost)
const
588 int buffer = prepostAddress(prepost);
590 if (eastwest == east)
return bbq[buffer][14][3];
591 else return bbq[buffer][14][19];
596 unsigned short StTriggerData2017::zdcADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
598 int buffer = prepostAddress(prepost);
599 if (buffer >= 0 && pmt>=1 && pmt<=3) {
600 if (eastwest == east) {
601 if (pmt == 1)
return bbq[buffer][14][0];
602 if (pmt == 2)
return bbq[buffer][14][8];
603 if (pmt == 3)
return bbq[buffer][14][9];
606 if (pmt == 1)
return bbq[buffer][14][16];
607 if (pmt == 2)
return bbq[buffer][14][24];
608 if (pmt == 3)
return bbq[buffer][14][25];
614 unsigned short StTriggerData2017::zdcTDC(StBeamDirection eastwest,
int prepost)
const
616 int buffer = prepostAddress(prepost);
618 if (eastwest == east)
return bbq[buffer][14][6];
619 else return bbq[buffer][14][22];
624 unsigned short StTriggerData2017::zdcPmtTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
626 int buffer = prepostAddress(prepost);
627 if (buffer >= 0 && pmt>=1 && pmt<=3) {
628 if (eastwest == east) {
629 if (pmt == 1)
return bbq[buffer][14][4];
630 if (pmt == 2)
return bbq[buffer][14][12];
631 if (pmt == 3)
return bbq[buffer][14][13];
634 if (pmt == 1)
return bbq[buffer][14][20];
635 if (pmt == 2)
return bbq[buffer][14][28];
636 if (pmt == 3)
return bbq[buffer][14][29];
642 unsigned short StTriggerData2017::zdcHardwareSum(
int prepost)
const
644 int buffer = prepostAddress(prepost);
645 if (buffer >= 0)
return bbq[buffer][14][11];
649 bool StTriggerData2017::zdcSMDPresent(
int prepost)
const
651 int buffer = prepostAddress(prepost);
652 if (buffer >= 0)
return mMXQ[buffer];
656 unsigned short StTriggerData2017::zdcSMD(StBeamDirection eastwest,
int verthori,
int strip,
int prepost)
const
658 static const int zdcsmd_map[2][2][8] ={
659 { { 31, 30, 29, 28, 27, 26, 25, 19} ,
660 { 24, 23, 22, 21, 20, 16, 18, 17} } ,
661 { { 15, 14, 13, 12, 11, 10, 9, 2} ,
662 { 8, 7, 6, 5, 4, 3, 0, 1} }
664 static const int zdcsmd_map2011[2][2][8] ={
665 { {24, 25, 26, 27, 28, 29, 30, 31} ,
666 {16, 17, 18, 19, 20, 21, 22, 23} } ,
667 { {8, 9, 10, 11, 12, 13, 14, 15} ,
668 {0, 1, 2, 3, 4, 5, 6, 7} }
670 if (verthori<0 || verthori>1)
return 0;
671 if (strip<1 || strip>8)
return 0;
672 int buffer = prepostAddress(prepost);
675 return mxq[buffer][4][zdcsmd_map[eastwest][verthori][strip-1]];
677 return mxq[buffer][4][zdcsmd_map2011[eastwest][verthori][strip-1]];
683 unsigned short StTriggerData2017::zdcEarliestTDC(StBeamDirection eastwest,
int prepost)
const
685 int buffer = prepostAddress(prepost);
689 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 12) % 16) | ((mBBC[buffer]->ZDClayer1[2] % 256) << 4);}
690 else {
return (mBBC[buffer]->ZDClayer1[3]) % 4096;}
692 if (eastwest==east) {
return ((mBBC[buffer]->ZDClayer1[3] >> 10) % 64) | ((mBBC[buffer]->ZDClayer1[2] % 16) << 6);}
693 else {
return (mBBC[buffer]->ZDClayer1[3]) % 1024;}
700 bool StTriggerData2017::zdcSumADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
701 int buffer = prepostAddress(prepost);
705 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (27-16));}
706 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
708 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
709 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (22-16));}
716 bool StTriggerData2017::zdcFrontADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
717 int buffer = prepostAddress(prepost);
721 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (29-16));}
722 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (26-16));}
724 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (23-16));}
725 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (20-16));}
732 bool StTriggerData2017::zdcBackADCaboveThreshold(StBeamDirection eastwest,
int prepost)
const {
733 int buffer = prepostAddress(prepost);
737 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (28-16));}
738 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (25-16));}
740 if (eastwest==east) {
return mBBC[buffer]->ZDClayer1[2] & (1 << (24-16));}
741 else {
return mBBC[buffer]->ZDClayer1[2] & (1 << (21-16));}
748 unsigned short StTriggerData2017::zdcTimeDifference()
const
750 return L1_DSM->VTX[1]%1024;
753 bool StTriggerData2017::zdcSumADCaboveThresholdL2(StBeamDirection eastwest)
const {
754 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 10 : 11));
757 bool StTriggerData2017::zdcFrontADCaboveThresholdL2(StBeamDirection eastwest)
const {
758 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 12 : 14));
761 bool StTriggerData2017::zdcBackADCaboveThresholdL2(StBeamDirection eastwest)
const {
762 return L1_DSM->VTX[1] & (1 << ((eastwest==east) ? 13 : 15));
765 bool StTriggerData2017::zdcSumADCaboveThresholdL3(StBeamDirection eastwest)
const {
766 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 7 : 8)); }
767 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 7 : 8)); }
770 bool StTriggerData2017::zdcFrontADCaboveThresholdL3(StBeamDirection eastwest)
const {
771 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 9 : 11)); }
772 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 9 : 11)); }
775 bool StTriggerData2017::zdcBackADCaboveThresholdL3(StBeamDirection eastwest)
const {
776 if(mRun<12000000){
return lastDSM(2) & (1 << ((eastwest==east) ? 10 : 12)); }
777 else {
return lastDSM(1) & (1 << ((eastwest==east) ? 10 : 12)); }
780 bool StTriggerData2017::zdcTimeDifferenceInWindow()
const
782 if(mRun<12000000){
return lastDSM(2) & (1 << 6); }
783 else {
return lastDSM(1) & (1 << 6); }
786 unsigned short StTriggerData2017::zdcSMDHighestStrip(StBeamDirection eastwest,
int verthori,
int prepost)
const
788 if(mRun<12000000)
return 0;
790 int buffer = prepostAddress(prepost);
793 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 6 : 9)) % 8;}
794 else {
return (mBBC[buffer]->ZDClayer1[1] >> (verthori ? 0 : 3)) % 8;}
800 unsigned short StTriggerData2017::zdcTruncatedSum(StBeamDirection eastwest,
int prepost)
const
802 if(mRun<12000000)
return 0;
803 int buffer = prepostAddress(prepost);
806 if (eastwest==east) {
return (mBBC[buffer]->ZDClayer1[2] >> (26-16)) % 8;}
807 else {
return (mBBC[buffer]->ZDClayer1[2] >> (29-16)) % 8;}
813 unsigned short StTriggerData2017::pp2ppADC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
815 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
816 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
817 if (vh<0 || vh>1)
return 0;
818 if (udio<0 || udio>1)
return 0;
819 if (ch<0 || ch>1)
return 0;
820 int buffer = prepostAddress(prepost);
821 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]];
825 unsigned short StTriggerData2017::pp2ppTAC(StBeamDirection eastwest,
int vh,
int udio,
int ch,
int prepost)
const
827 static const int map[2][2][2][2] ={ { { { 0, 1}, { 2, 3} } , { {16,17}, {18,19} } , } ,
828 { { { 8, 9}, {10,11} } , { {24,25}, {26,27} } , } };
829 if (vh<0 || vh>1)
return 0;
830 if (udio<0 || udio>1)
return 0;
831 if (ch<0 || ch>1)
return 0;
832 int buffer = prepostAddress(prepost);
833 if (buffer >= 0)
return mxq[buffer][2][map[eastwest][vh][udio][ch]+4];
837 unsigned long StTriggerData2017::pp2ppDSM(
int prepost)
const {
838 if (prepost!=0)
return 0;
839 return L1_DSM->TOF[7];
842 unsigned short StTriggerData2017::bemcLayer1DSM(
int channel,
int prepost)
const {
843 const int n_bemc_layer1=48;
844 if (channel<0 || channel >=n_bemc_layer1) {
845 gMessMgr->Warning() <<
"Barrel DSM layer 1 out of range (" << channel <<
")" << endm;
848 int buffer = prepostAddress(prepost);
849 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1[channel];
853 unsigned short StTriggerData2017::eemcLayer1DSM(
int channel,
int prepost)
const {
854 const int n_eemc_layer1=16;
855 if (channel<0 || channel >=n_eemc_layer1) {
856 gMessMgr->Warning() <<
"Endap DSM layer 1 out of range (" << channel <<
")" << endm;
859 int buffer = prepostAddress(prepost);
860 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1[channel];
864 unsigned short StTriggerData2017::emcLayer2DSM(
int channel)
const {
865 const int n_emc_layer2=8;
866 if (channel<0 || channel >=n_emc_layer2) {
867 gMessMgr->Warning() <<
"EMC DSM layer 2 out of range (" << channel <<
")" << endm;
870 return L1_DSM->EMC[channel];
873 unsigned short StTriggerData2017::tpcMaskDSM(
int channel)
const {
874 const int n_tpcMask=8;
875 if (channel<0 || channel >=n_tpcMask) {
876 gMessMgr->Warning() <<
"TPCMask DSM out of range (" << channel <<
")" << endm;
879 return L1_DSM->TPCMask[channel];
882 unsigned char StTriggerData2017::bemcHighTower(
int patch_id,
int prepost)
const {
884 const int m_max_patch=300;
885 if ( patch_id < 0 || patch_id >= m_max_patch) {
886 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
889 int buffer = prepostAddress(prepost);
892 int channel=patch_id%10;
893 unsigned short trg_word;
896 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
902 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
906 return trg_word & 0x3F;
911 unsigned char StTriggerData2017::bemcJetPatch (
int patch_id,
int prepost)
const
914 const int m_max_patch=300;
915 if ( patch_id < 0 || patch_id >= m_max_patch) {
916 gMessMgr->Warning() <<
"Invalid Barrel patch id: " << patch_id << endm;
919 int buffer = prepostAddress(prepost);
922 int channel=patch_id%10;
923 unsigned short trg_word;
926 trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast);
932 trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest);
936 return trg_word >> 6;
942 unsigned char StTriggerData2017::eemcHighTower(
int patch_id,
int prepost)
const
945 const int m_max_patch=90;
946 if ( patch_id < 0 || patch_id >= m_max_patch) {
947 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
950 int buffer = prepostAddress(prepost);
951 if (buffer >= 0 && mBC1[buffer]) {
953 int channel=patch_id%10;
954 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
955 return trg_word & 0x3F;
960 unsigned char StTriggerData2017::eemcJetPatch (
int patch_id,
int prepost)
const
963 const int m_max_patch=90;
964 if ( patch_id < 0 || patch_id >= m_max_patch) {
965 gMessMgr->Warning() <<
"Invalid Endcap patch id" << endm;
968 int buffer = prepostAddress(prepost);
969 if (buffer >= 0 && mBC1[buffer]) {
971 int channel=patch_id%10;
972 unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC);
973 return trg_word >> 6;
978 unsigned char StTriggerData2017::bemcHighestTowerADC(
int prepost)
const {
980 const int m_max_patch=300;
982 for (
int i=1; i<m_max_patch; i++){
983 unsigned char hh=bemcHighTower(i,prepost);
989 unsigned char StTriggerData2017::eemcHighestTowerADC(
int prepost)
const {
991 const int m_max_patch=90;
993 for (
int i=1; i<m_max_patch; i++){
994 unsigned char hh=eemcHighTower(i,prepost);
1000 char* StTriggerData2017::getTriggerStructure()
1002 return (
char*) mData;
1010 int StTriggerData2017::getRawSize()
const
1012 return mData->totalTriggerLength;
1015 unsigned char* StTriggerData2017::getDsm0_BEMCE(
int prepost)
const {
1016 int buffer = prepostAddress(prepost);
1017 if (buffer >= 0)
if (mBCE[buffer])
return mBCE[buffer]->BEMCEast;
1021 unsigned char* StTriggerData2017::getDsm0_BEMCW(
int prepost)
const {
1022 int buffer = prepostAddress(prepost);
1023 if (buffer >= 0)
if (mBCW[buffer])
return mBCW[buffer]->BEMCWest;
1027 unsigned short* StTriggerData2017::getDsm1_BEMC(
int prepost)
const {
1028 int buffer = prepostAddress(prepost);
1029 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->BEMClayer1;
1033 unsigned char* StTriggerData2017::getDsm0_EEMC(
int prepost)
const {
1034 int buffer = prepostAddress(prepost);
1035 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMC;
1039 unsigned short* StTriggerData2017::getDsm1_EEMC(
int prepost)
const{
1040 int buffer = prepostAddress(prepost);
1041 if (buffer >= 0)
if (mBC1[buffer])
return mBC1[buffer]->EEMClayer1;
1045 unsigned short* StTriggerData2017::getDsm2_EMC()
const{
1049 unsigned short* StTriggerData2017::getDsm3()
const{
1050 return L1_DSM->lastDSM;
1053 int StTriggerData2017::L2ResultsOffset(StL2AlgorithmId
id)
const
1056 default:
return -999999999;
1060 bool StTriggerData2017::isL2Triggered(StL2TriggerResultType
id)
const
1065 unsigned int StTriggerData2017::l2ResultLength()
const
1067 return sizeof(TrgSum->L2Result)/
sizeof(
unsigned int);
1070 const unsigned int* StTriggerData2017::l2Result()
const
1072 return TrgSum->L2Result;
1075 unsigned long long StTriggerData2017::l2sum()
const
1079 unsigned long long hi = TrgSum->L2Sum[1];
1080 unsigned long long lo = TrgSum->L2Sum[0];
1081 unsigned long long mask=(hi<<32) | lo;
1085 unsigned short StTriggerData2017::vpdADC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1087 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1088 if (pmt<1 || pmt>16)
return 0;
1089 int buffer = prepostAddress(prepost);
1091 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]];}
1092 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1097 unsigned short StTriggerData2017::vpdTDC(StBeamDirection eastwest,
int pmt,
int prepost)
const
1099 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1100 if (pmt<1 || pmt>16)
return 0;
1101 int buffer = prepostAddress(prepost);
1103 if (mRun<=12003001) {
return bbq[buffer][10+(int)eastwest*2][map[pmt-1]+4];}
1104 else {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1109 unsigned short StTriggerData2017::vpdADCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1111 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1112 if (pmt<1 || pmt>16)
return 0;
1113 int buffer = prepostAddress(prepost);
1115 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1116 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]];}
1121 unsigned short StTriggerData2017::vpdTDCHighThr(StBeamDirection eastwest,
int pmt,
int prepost)
const
1123 static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27};
1124 if (pmt<1 || pmt>16)
return 0;
1125 int buffer = prepostAddress(prepost);
1127 if (mRun<=12003001) {
return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}
1128 else {
return mxq[buffer][6+(int)eastwest*2][map[pmt-1]+4];};
1133 unsigned short StTriggerData2017::vpdEarliestTDC(StBeamDirection eastwest,
int prepost)
const
1135 int buffer = prepostAddress(prepost);
1138 if (mRun<=10096084){
1139 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1140 else {
return mBBC[buffer]->VPD[4]%4096;}
1142 else if(mRun<=12003001) {
1143 if (eastwest==east) {
return mBBC[buffer]->VPD[2]%4096;}
1144 else {
return mBBC[buffer]->VPD[0]%4096;}
1147 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1148 else {
return mBBC[buffer]->VPD[4]%4096;}
1156 unsigned short StTriggerData2017::vpdEarliestTDCHighThr(StBeamDirection eastwest,
int prepost)
const
1158 int buffer = prepostAddress(prepost);
1160 if (mRun<=10365999){
1163 else if(mRun<=12003001) {
1165 if (eastwest==east) {
return mBBC[buffer]->VPD[6]%4096;}
1166 else {
return mBBC[buffer]->VPD[4]%4096;}
1168 }
else if(mRun<=14001001){
1170 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[13] + ((mMIX[buffer]->MTD_P2PLayer1[12]&0x0f)<<8);}
1171 else {
return mMIX[buffer]->MTD_P2PLayer1[9] + ((mMIX[buffer]->MTD_P2PLayer1[8]&0x0f)<<8);}
1175 if (eastwest==east) {
return mMIX[buffer]->MTD_P2PLayer1[11] + ((mMIX[buffer]->MTD_P2PLayer1[10]&0xf)<<8);}
1176 else {
return (mMIX[buffer]->MTD_P2PLayer1[10]>>4) + ((mMIX[buffer]->MTD_P2PLayer1[9]&0xff)<<4);}
1183 unsigned short StTriggerData2017::vpdTimeDifference()
const
1185 return L1_DSM->VTX[7]%8192;
1189 unsigned short StTriggerData2017::bbcVP101(
int ch,
int prepost)
const
1191 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1192 if(ch<0 || ch>7)
return 0;
1193 int buffer = prepostAddress(prepost);
1194 if (buffer >= 0 && mBBC[buffer]){
1195 return mBBC[buffer]->VPD[map[ch]];
1201 unsigned short StTriggerData2017::dsmTF201Ch(
int ch)
const
1203 int map[8]={3, 2, 1, 0, 7, 6, 5, 4};
1204 return L1_DSM->TOF[map[ch]];
1207 unsigned short StTriggerData2017::mtd4AtAddress(
int address,
int prepost)
const
1209 if (mRun<=15001001)
return 0;
1210 int buffer = prepostAddress(prepost);
1211 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][14][address];
1215 unsigned short StTriggerData2017::nQTdata(
int prepost)
const
1220 unsigned int* StTriggerData2017::QTdata(
int prepost)
const
1225 unsigned short StTriggerData2017::fmsADC(
int crt,
int adr,
int ch,
int prepost)
const
1227 int buffer = prepostAddress(prepost);
1228 if (buffer >= 0 && crt>=0 && crt<=5 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1230 case 0:
return bbq[buffer][adr][ch];
1231 case 1:
return qt1[buffer][adr][ch];
1232 case 2:
return qt2[buffer][adr][ch];
1233 case 3:
return qt3[buffer][adr][ch];
1234 case 4:
return qt4[buffer][adr][ch];
1235 case 5:
return epq[buffer][adr][ch];
1236 case 6:
return fq1[buffer][adr][ch];
1237 case 7:
return fq2[buffer][adr][ch];
1243 unsigned short StTriggerData2017::fmsTDC(
int crt,
int adr,
int ch,
int prepost)
const
1245 int buffer = prepostAddress(prepost);
1246 if (buffer >= 0 && crt>=0 && crt<=5 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1248 case 0:
return tbbq[buffer][adr][ch];
1249 case 1:
return tqt1[buffer][adr][ch];
1250 case 2:
return tqt2[buffer][adr][ch];
1251 case 3:
return tqt3[buffer][adr][ch];
1252 case 4:
return tqt4[buffer][adr][ch];
1253 case 5:
return tepq[buffer][adr][ch];
1254 case 6:
return tfq1[buffer][adr][ch];
1255 case 7:
return tfq2[buffer][adr][ch];
1261 unsigned short StTriggerData2017::epdADC(
int crt,
int adr,
int ch,
int prepost)
const
1263 int buffer = prepostAddress(prepost);
1264 if (buffer >= 0 && crt>=1 && crt<=1 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1266 case 1:
return epq[buffer][adr][ch];
1272 unsigned short StTriggerData2017::epdTDC(
int crt,
int adr,
int ch,
int prepost)
const
1274 int buffer = prepostAddress(prepost);
1275 if (buffer >= 0 && crt>=1 && crt<=1 && adr>=0 && adr<16 && ch>=0 && ch<=31){
1277 case 1:
return tepq[buffer][adr][ch];
1283 unsigned char* StTriggerData2017::getDsm_FMS(
int prepost)
const
1285 int buffer = prepostAddress(prepost);
1286 if (buffer >= 0)
if (mFMS[buffer])
return mFMS[buffer]->FMS;
1290 unsigned short* StTriggerData2017::getDsm1_FMS(
int prepost)
const
1292 int buffer = prepostAddress(prepost);
1293 if (buffer >= 0)
if (mMIX[buffer])
return mMIX[buffer]->FPDEastNSLayer1;
1297 unsigned short* StTriggerData2017::getDsm2_FMS()
const {
return L1_DSM->FPD;}
1299 unsigned short StTriggerData2017::mxqAtSlotAddress(
int address,
int prepost,
int slot)
const
1301 int buffer = prepostAddress(prepost);
1302 if (buffer >= 0 && address>=0 && address<32){
1303 if (slot >= 0 && slot<16){
1304 return mxq[buffer][slot][address];
1310 unsigned short StTriggerData2017::mtdQtAtCh(
int qtid,
int address,
int prepost)
const
1312 int map1[4] = {0, 10, 12, 14};
1313 int map2[8] = {0, 9, 10, 11, 12, 13, 14, 15};
1314 int map3[4] = {0, 9, 11, 13};
1316 int buffer = prepostAddress(prepost);
1317 if(buffer>=0 && qtid>0 && address>=0 && address<32){
1319 if(qtid>1)
return 0;
1320 else return mxq[buffer][map1[qtid-1]][address];
1322 else if(mRun<=14001001){
1323 if(qtid>2)
return 0;
1324 else return mxq[buffer][map1[qtid-1]][address];
1326 else if(mRun<=15001001){
1327 if(qtid>3)
return 0;
1328 else return mxq[buffer][map1[qtid-1]][address];
1330 else if(mRun<=17001001){
1331 if(qtid>4)
return 0;
1332 else return mxq[buffer][map1[qtid-1]][address];
1334 else if(mRun<=18001001){
1335 if(qtid>8)
return 0;
1336 else return mxq[buffer][map2[qtid-1]][address];
1339 if(qtid>4)
return 0;
1340 else return mxq[buffer][map3[qtid-1]][address];
1347 unsigned short StTriggerData2017::mtdAtAddress(
int address,
int prepost)
const
1349 int buffer = prepostAddress(prepost);
1350 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][0][address];
1354 unsigned short StTriggerData2017::mtdgemAtAddress(
int address,
int prepost)
const
1356 if (mRun<=12003001)
return 0;
1357 int buffer = prepostAddress(prepost);
1358 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][10][address];
1362 unsigned short StTriggerData2017::mtd3AtAddress(
int address,
int prepost)
const
1364 if (mRun<=14001001)
return 0;
1365 int buffer = prepostAddress(prepost);
1366 if (buffer >= 0 && address>=0 && address<32)
return mxq[buffer][12][address];
1371 unsigned short StTriggerData2017::mtdAdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1374 int buffer = prepostAddress(prepost);
1375 if (buffer >= 0 && pmt==0){
1376 if (eastwest==east) {
1377 if (mRun<=10133008)
return mxq[buffer][0][0];
1378 else return mxq[buffer][0][24];
1380 if (eastwest==west)
return mxq[buffer][0][8];
1385 unsigned short StTriggerData2017::mtdTdc(StBeamDirection eastwest,
int pmt,
int prepost)
const
1388 int buffer = prepostAddress(prepost);
1389 if (buffer >= 0 && pmt==0){
1390 if (eastwest==east) {
1391 if (mRun<=10133008)
return mxq[buffer][0][4];
1392 else return mxq[buffer][0][28];
1394 if (eastwest==west)
return mxq[buffer][0][12];
1399 unsigned char StTriggerData2017::mtdDsmAtCh(
int ch,
int prepost)
const
1401 int map[16] = {7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8};
1402 int map2[8] = {3, 2, 1, 0, 7, 6, 5, 4};
1403 int buffer = prepostAddress(prepost);
1404 if (buffer >= 0 && ch>=0){
1407 return mMIX[buffer]->MTD_P2PLayer1[map[ch]];
1409 int add= 8 + map2[(ch-16)/2];
1411 if(ch%2==0){ v=(
unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0xff00)>>8);}
1412 else { v=(
unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0x00ff) );}
1420 bool StTriggerData2017::mtdDsmHit(
int pmt,
int prepost)
const
1423 int buffer = prepostAddress(prepost);
1426 if(mRun<10133008 && mRun<11000000){
1427 if( (mMIX[buffer]->MTD_P2PLayer1[5] & 0x1) && (mMIX[buffer]->MTD_P2PLayer1[5] & 0x10) )
return true;
1430 if(prepost!=0)
return false;
1431 return (L1_DSM->TOF[3] & 0x1);
1438 unsigned short StTriggerData2017::mtdVpdTacDiff()
const
1440 return (L1_DSM->TOF[3] & 0x3fff);
1443 unsigned short StTriggerData2017::tofAtAddress(
int address,
int prepost)
const
1445 int buffer = prepostAddress(prepost);
1446 if (buffer>=0 && address>=0 && address<48) {
1447 if (mMIX[buffer])
return mMIX[buffer]->TOF[address];
1452 unsigned short StTriggerData2017::tofTrayMultiplicity(
int tray,
int prepost)
const
1454 int dsmmap[8] = {3,2,1,0,7,6,5,4};
1455 int traydsm[120] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5,
1456 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
1457 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1458 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
1459 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
1460 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
1461 int traych[120] = { 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1462 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1463 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3,
1464 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1465 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,
1466 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17};
1467 int buffer = prepostAddress(prepost);
1468 if (buffer>=0 && tray>=1 && tray<=120) {
1470 int address = traydsm[tray-1]*8 + dsmmap[traych[tray-1]/3];
1471 int ch = traych[tray-1]%3;
1472 return (mMIX[buffer]->TOF[address] >> (5*ch)) & 0x1f;
1478 unsigned short StTriggerData2017::tofMultiplicity(
int prepost)
const
1480 if (prepost==0)
return L1_DSM->TOF[1]%8192;
1484 void StTriggerData2017::dump()
const
1486 printf(
"***** StTriggerData Dump *****\n");
1487 printf(
" mDebug=%d mData=%p\n",mDebug,mData);
1488 printf(
" Year=%d Version=%x\n",year(),version());
1489 printf(
" Run#=%d Event#=%d\n",mRun,eventNumber());
1490 printf(
" %d pre and %d post crossing data available\n",numberOfPreXing(),numberOfPostXing());
1491 printf(
" Token=%d TriggerWord=%x ActionWord=%x BusyStatus=%x\n",
1492 token(), triggerWord(), actionWord(), busyStatus());
1493 printf(
" TUC Bits=%d : ",tcuBits());
1494 for (
int i=0; i<16; i++) {printf(
" %d",(tcuBits()>>(15-i))%2);}; printf(
"\n");
1495 printf(
" BunchId 7bit=%d 48bit=%d\n",bunchId7Bit(), bunchId48Bit());
1496 printf(
" Spin Bits=%d : ",spinBit());
1497 for (
int i=0; i<8; i++) {printf(
" %d",(spinBit()>>(7-i))%2);}; printf(
"\n");
1499 printf(
" BBC East ADC : ");
for (
int i=1; i<=24;i++){ printf(
"%d ",bbcADC(east,i,0)); }; printf(
"\n");
1500 printf(
" BBC West ADC : ");
for (
int i=1; i<=24;i++){ printf(
"%d ",bbcADC(west,i,0)); }; printf(
"\n");
1501 printf(
" BBC East TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%d ",bbcTDC(east,i,0)); }; printf(
"\n");
1502 printf(
" BBC West TAC : ");
for (
int i=1; i<=16;i++){ printf(
"%d ",bbcTDC(west,i,0)); }; printf(
"\n");
1503 for (
int i=-numberOfPreXing(); i<=static_cast<int>(numberOfPostXing()); i++){
1504 printf(
" BBC Sums %d xing : ",i);
1505 printf(
"East=%d West=%d Large tile East=%d West=%d\n",
1506 bbcADCSum(east,i),bbcADCSum(west,i),
1507 bbcADCSumLargeTile(east,i),bbcADCSumLargeTile(west,i));
1509 printf(
" BBC Earilest : "); printf(
"East=%d West=%d Difference+256=%d\n",
1510 bbcEarliestTDC(east,0),bbcEarliestTDC(west,0),bbcTimeDifference());
1511 printf(
" ZDC Earilest : "); printf(
"East=%d West=%d Difference=%d\n",
1512 zdcEarliestTDC(east,0),zdcEarliestTDC(west,0),zdcTimeDifference());
1524 printf(
" ZDC Sum(A) East : ");printf(
"%d ",zdcAttenuated(east)); printf(
"\n");
1525 printf(
" ZDC Sum(A) West : ");printf(
"%d ",zdcAttenuated(west)); printf(
"\n");
1526 printf(
" ZDC Sum(UA) East : ");printf(
"%d ",zdcUnAttenuated(east)); printf(
"\n");
1527 printf(
" ZDC Sum(UA) West : ");printf(
"%d ",zdcUnAttenuated(west)); printf(
"\n");
1528 printf(
" VPD E Earliest TAC : %d\n", vpdEarliestTDC(east));
1529 printf(
" VPD W Earliest TAC : %d\n", vpdEarliestTDC(west));
1530 printf(
" VPD TimeDifference : %d\n", vpdTimeDifference());
1531 printf(
" L2 result : \n");
1532 for (
int j=0; j<4 ;j++) {
for (
int k=0; k<16; k++) {printf(
"%u ",*(l2Result()+j*16+k)); } printf(
"\n");}
1533 printf(
"BBClayer1:");
1534 int buffer = prepostAddress(0);
1537 for (
int i = 0;i < 16;i++) printf(
" %1x %04X", i, mBBC[buffer]->BBClayer1[i]);
1541 printf(
"ZDClayer1:");
1544 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->ZDClayer1[i]);
1548 printf(
"VPDlayer1:");
1551 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, mBBC[buffer]->VPD[i]);
1557 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->VTX[i]);
1560 printf(
"Last DSM:");
1562 for (
int i = 0;i < 8;i++) printf(
" %1x %04X", i, L1_DSM->lastDSM[i]);
1565 printf(
"***** End StTriggerData Dump *****\n");
1568 void StTriggerData2017::killFMS(){
1570 int npre = numberOfPreXing();
1571 int npost = numberOfPostXing();
1572 for (
int i=0; i<1+npre+npost; i++){
1574 {offlen = mData->MainX;}
1576 if (mData->PrePostList[i-1]==0)
continue;
1577 offlen = (
TrgOfflen2017*) ((
char*)mData + mData->PrePostList[i-1]);
1580 j=offlen[y17QT1_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y17QT1_CONF_NUM].offset, 0, j); offlen[y17QT1_CONF_NUM].length=0;};
1581 j=offlen[y17QT2_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y17QT2_CONF_NUM].offset, 0, j); offlen[y17QT2_CONF_NUM].length=0;};
1582 j=offlen[y17QT3_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y17QT3_CONF_NUM].offset, 0, j); offlen[y17QT3_CONF_NUM].length=0;};
1583 j=offlen[y17QT4_CONF_NUM].length;
if (j>0){memset((
char*)mData + offlen[y17QT4_CONF_NUM].offset, 0, j); offlen[y17QT4_CONF_NUM].length=0;};
1587 void StTriggerData2017::swapRawDet(
DataBlock2017* data,
int name,
int hlength,
int bs)
1593 int header_length = 8;
1594 if(bs) swapI((
unsigned int*)&data->length);
1596 case y17MXQ_CONF_NUM :
case y17EPQ_CONF_NUM :
case y17BBQ_CONF_NUM :
1597 case y17QT1_CONF_NUM :
case y17QT2_CONF_NUM :
case y17QT3_CONF_NUM :
case y17QT4_CONF_NUM :
1598 case y17FQ1_CONF_NUM :
case y17FQ2_CONF_NUM :
1599 header_length = 12;
break;
1601 if (hlength != data->length + header_length){
1602 mErrorFlag = mErrorFlag | (1 << name);
1603 printf(
"StTriggerData2017: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
1604 name,data->name[0],data->name[1],data->name[2],data->name[3],
1605 hlength,data->length,header_length);
1606 printf(
"StTriggerData2017: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
1607 name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
1613 case y17BC1_CONF_NUM :
1615 swapSSn((
unsigned int*)bc1->BEMClayer1,48);
1616 swapSSn((
unsigned int*)bc1->EEMClayer1,16);
1618 case y17MIX_CONF_NUM :
1620 swapSSn((
unsigned int*)mix->FPDEastNSLayer1,8);
1621 swapSSn((
unsigned int*)mix->TOFLayer1,8+48);
1623 case y17BCW_CONF_NUM :
1626 case y17BCE_CONF_NUM :
1629 case y17BBC_CONF_NUM :
1631 swapSSn((
unsigned int*)bbc->BBClayer1,16+8+8);
1633 case y17FMS_CONF_NUM :
1636 case y17MXQ_CONF_NUM :
1637 case y17EPQ_CONF_NUM :
1638 case y17BBQ_CONF_NUM :
1639 case y17QT1_CONF_NUM :
1640 case y17QT2_CONF_NUM :
1641 case y17QT3_CONF_NUM :
1642 case y17QT4_CONF_NUM :
1643 case y17FQ1_CONF_NUM :
1644 case y17FQ2_CONF_NUM :
1646 swapI((
unsigned int*)&qtdata->dataLoss);
1647 swapIn(qtdata->data, qtdata->length/4);
1652 printf(
"Read id=%2d name=%1c%1c%1c%1c length=%d\n",
1653 name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
1656 void StTriggerData2017::Streamer(TBuffer &R__b)
1660 if (R__b.IsReading()) {
1661 R__b.ReadClassBuffer(StTriggerData2017::Class(),
this);
1663 if(mData) readData();
1666 R__b.WriteClassBuffer(StTriggerData2017::Class(),
this);