57 #include "StL0Trigger.h"
58 #include "StTriggerData.h"
59 #include "tables/St_dst_L0_Trigger_Table.h"
60 #include "tables/St_dst_TrgDet_Table.h"
62 #if !defined(ST_NO_NAMESPACES)
67 static const char rcsid[] =
"$Id: StL0Trigger.cxx,v 2.12 2006/07/18 14:41:01 ullrich Exp $";
73 mMwcCtbMultiplicity = 0;
77 fill_n(mCoarsePixelArray, static_cast<int>(mMaxPixels), 0);
83 fill_n(mLastDsmArray, static_cast<unsigned short>(mMaxLastDsm), 0);
84 fill_n(mBcDataArray, static_cast<unsigned short>(mMaxBcData), 0);
87 void StL0Trigger::set(
const dst_L0_Trigger_st *t)
90 if (TestBit(1))
return;
92 mTriggerWord = t->TriggerWd;
93 mTriggerActionWord = t->TriggerActionWd;
94 mMwcCtbMultiplicity = t->MWC_CTB_mul;
95 mMwcCtbDipole = t->MWC_CTB_dipole;
96 mMwcCtbTopology = t->MWC_CTB_topology;
97 mMwcCtbMoment = t->MWC_CTB_moment;
98 copy(t->CPA+0, t->CPA+mMaxPixels, mCoarsePixelArray);
99 mDsmInput = t->DSMInput;
100 mDetectorBusy = t->DetectorBusy;
101 mTriggerToken = t->TrgToken;
102 mDsmAddress = t->DSMAddress;
103 mAddBits = t->addBits;
106 void StL0Trigger::set(
const dst_TrgDet_st* n)
110 if (TestBit(2))
return;
112 copy(n->lastDSM+0, n->lastDSM+mMaxLastDsm, mLastDsmArray);
113 copy(n->BCdata +0, n->BCdata+mMaxBcData , mBcDataArray );
121 mTriggerWord = t->triggerWord();
122 mTriggerActionWord = t->actionWord();
123 mMwcCtbMultiplicity=0;
127 mDsmInput=t->dsmInput();
129 mTriggerToken=t->trgToken();
130 mDsmAddress=t->dsmAddress();
131 mAddBits = t->mAddBits();
132 for(
int i=0; i<mMaxLastDsm; i++){mLastDsmArray[i]=t->lastDSM(i);}
133 for(
int i=0; i<mMaxBcData; i++){mBcDataArray[i]=t->bcData(i);}
137 StL0Trigger::~StL0Trigger() { }
140 StL0Trigger::coarsePixelArraySize() {
return mMaxPixels;}
143 StL0Trigger::coarsePixelArray(
unsigned int i)
146 return mCoarsePixelArray[i];
152 StL0Trigger::lastDsmArraySize()
const {
return mMaxLastDsm;}
155 StL0Trigger::lastDsmArray(
unsigned int i)
158 return mLastDsmArray[i];
164 StL0Trigger::bcDataArraySize()
const {
return mMaxBcData;}
167 StL0Trigger::bcDataArray(
unsigned int i)
170 return mBcDataArray[i];
176 StL0Trigger::mwcCtbMultiplicity()
const {
return mMwcCtbMultiplicity;}
179 StL0Trigger::mwcCtbDipole()
const {
return mMwcCtbDipole;}
182 StL0Trigger::mwcCtbTopology()
const {
return mMwcCtbTopology;}
185 StL0Trigger::mwcCtbMoment()
const {
return mMwcCtbMoment;}
188 StL0Trigger::dsmInput()
const {
return mDsmInput;}
191 StL0Trigger::detectorBusy()
const {
return mDetectorBusy;}
194 StL0Trigger::triggerToken()
const {
return mTriggerToken;}
197 StL0Trigger::dsmAddress()
const {
return mDsmAddress;}
200 StL0Trigger::addBits()
const {
return mAddBits;}
203 StL0Trigger::setMwcCtbMultiplicity(
int val) { mMwcCtbMultiplicity = val; }
206 StL0Trigger::setMwcCtbDipole(
int val) { mMwcCtbDipole = val; }
209 StL0Trigger::setMwcCtbTopology(
int val) { mMwcCtbTopology = val; }
212 StL0Trigger::setMwcCtbMoment(
int val) { mMwcCtbMoment = val; }
215 StL0Trigger::setCoarsePixelArray(
unsigned int i,
int val)
218 mCoarsePixelArray[i] = val;
222 StL0Trigger::setDsmInput(
unsigned short val) {mDsmInput = val;}
225 StL0Trigger::setDetectorBusy(
unsigned char val) {mDetectorBusy = val;}
228 StL0Trigger::setTriggerToken(
unsigned short val) {mTriggerToken = val;}
231 StL0Trigger::setDsmAddress(
unsigned short val) {mDsmAddress = val;}
234 StL0Trigger::setAddBits(
unsigned char val) {mAddBits = val;}
238 StL0Trigger::setLastDsmArray(
unsigned int i,
unsigned short val)
241 mLastDsmArray[i] = val;
245 StL0Trigger::setBcDataArray(
unsigned int i,
unsigned short val)
248 mBcDataArray[i] = val;
252 StL0Trigger::bunchCrossingId7bit(
int runNumber)
const
254 unsigned int b7dat = mBcDataArray[2];
263 if (runNumber>4000000)
272 if(runNumber<3010000) { ibits=7; }
275 for (
int i=0; i<7; i++) {
276 b7 += (!((b7dat>>(ibits-i)) & 0x1) << (i)) & 0x7f;
282 StL0Trigger::bunchCrossingId()
const
284 unsigned long long bxinghi,bxing1,bxinglo,bxing,bx0,bx1,bx2;
286 bxinghi = mBcDataArray[3];
287 bxing1 = mBcDataArray[10];
288 bxinglo = (bxing1 << 16) + mBcDataArray[11];
289 bxing = (bxinghi << 32) + bxinglo;
294 return static_cast<unsigned int>(b120);
298 StL0Trigger::spinBits(
int runNumber)
const
300 int ldsm0,spin1,spin2,spin3,spin4;
301 if (runNumber<4000000){
302 ldsm0 = mLastDsmArray[0];
303 spin1 = (ldsm0>>8) & 0x1;
304 spin2 = (ldsm0>>9) & 0x1;
305 spin3 = (ldsm0>>10) & 0x1;
306 spin4 = (ldsm0>>11) & 0x1;
307 return spin1+spin2*2+spin3*4+spin4*8;
310 ldsm0 = (mLastDsmArray[7]/16)%256;
311 spin1 = (ldsm0/ 2)%2;
312 spin2 = (ldsm0/ 4)%2;
313 spin3 = (ldsm0/32)%2;
314 spin4 = (ldsm0/64)%2;
315 return spin1+spin2*2+spin3*4+spin4*8;
320 StL0Trigger::spinBitYellowUp(
int runNumber)
const
322 if (runNumber<4000000){
323 return (mLastDsmArray[0]>>8) & 0x1;
326 int ldsm0 = (mLastDsmArray[7]/16)%256;
332 StL0Trigger::spinBitYellowDown(
int runNumber)
const
334 if (runNumber<4000000){
335 return (mLastDsmArray[0]>>9) & 0x1;
338 int ldsm0 = (mLastDsmArray[7]/16)%256;
344 StL0Trigger::spinBitBlueUp(
int runNumber)
const
346 if (runNumber<4000000){
347 return (mLastDsmArray[0]>>9) & 0x1;
350 int ldsm0 = (mLastDsmArray[7]/16)%256;
356 StL0Trigger::spinBitBlueDown(
int runNumber)
const
358 if (runNumber<4000000){
359 return (mLastDsmArray[0]>>10) & 0x1;
362 int ldsm0 = (mLastDsmArray[7]/16)%256;