34 #include "StFpdTriggerDetector.h"
35 #include "tables/St_dst_TrgDet_Table.h"
36 #include "StTriggerData.h"
38 static const char rcsid[] =
"$Id: StFpdTriggerDetector.cxx,v 2.6 2007/07/11 23:06:45 perev Exp $";
48 StFpdTriggerDetector::StFpdTriggerDetector(
const dst_TrgDet_st& t)
54 StFpdTriggerDetector::StFpdTriggerDetector(
const StTriggerData& t)
58 for(
int ew=0; ew<2; ew++) {
59 for(
unsigned int nstbps=0; nstbps<mMaxModule; nstbps++) {
60 int tst=(
char*)&mAdc[ew][nstbps]-(
char*)&mAdc[0][0];
61 assert(tst>=0 && tst<(
int)
sizeof(mAdc));
62 for(
unsigned int tower=0; tower<mMaxTower[nstbps]; tower++){
63 mAdc[ew][nstbps][tower]=t.fpd((StBeamDirection)ew,nstbps,tower+1);
65 for(
unsigned int nstbps=0; nstbps<mMaxBoard; nstbps++) {
66 for(
int bd=0; bd<mMaxBoard; bd++) {
67 int tst=(
char*)&mLayer1[ew][nstbps][bd]-(
char*)&mLayer1[0][0][0];
68 assert(tst>=0 && tst<(
int)
sizeof(mLayer1));
69 mLayer1[ew][nstbps][bd]=t.fpdLayer1DSM((StBeamDirection)ew,nstbps,bd);
71 mLayer2[ew][nstbps]=t.fpdLayer2DSM((StBeamDirection)ew,nstbps);
79 copy(det.mEN, det.mEN+mMaxNS, mEN);
80 copy(det.mES, det.mES+mMaxNS, mES);
81 copy(det.mET, det.mET+mMaxTB, mET);
82 copy(det.mEB, det.mEB+mMaxTB, mEB);
83 copy(det.mEPN, det.mEPN+mMaxPS, mEPN);
84 copy(det.mEPS, det.mEPS+mMaxPS, mEPS);
85 copy(det.mWN, det.mWN+mMaxNS, mWN);
86 copy(det.mWS, det.mWS+mMaxNS, mWS);
87 copy(det.mWT, det.mWT+mMaxTB, mWT);
88 copy(det.mWB, det.mWB+mMaxTB, mWB);
89 copy(det.mWPN, det.mWPN+mMaxPS, mWPN);
90 copy(det.mWPS, det.mWPS+mMaxPS, mWPS);
91 for (
int i=0; i<2; i++)
92 for (
int j=0; j<mMaxModule; j++) {
93 for (
int k=0; k<mMaxBoard; k++) mLayer1[i][j][k] = det.mLayer1[i][j][k] ;
94 mLayer2[i][j] = det.mLayer2[i][j];
103 copy(det.mEN, det.mEN+mMaxNS, mEN);
104 copy(det.mES, det.mES+mMaxNS, mES);
105 copy(det.mET, det.mET+mMaxTB, mET);
106 copy(det.mEB, det.mEB+mMaxTB, mEB);
107 copy(det.mEPN, det.mEPN+mMaxPS, mEPN);
108 copy(det.mEPS, det.mEPS+mMaxPS, mEPS);
109 copy(det.mWN, det.mWN+mMaxNS, mWN);
110 copy(det.mWS, det.mWS+mMaxNS, mWS);
111 copy(det.mWT, det.mWT+mMaxTB, mWT);
112 copy(det.mWB, det.mWB+mMaxTB, mWB);
113 copy(det.mWPN, det.mWPN+mMaxPS, mWPN);
114 copy(det.mWPS, det.mWPS+mMaxPS, mWPS);
115 for (
int i=0; i<2; i++)
116 for (
int j=0; j<mMaxModule; j++) {
117 for (
int k=0; k<mMaxBoard; k++) mLayer1[i][j][k] = det.mLayer1[i][j][k] ;
118 mLayer2[i][j] = det.mLayer2[i][j];
124 StFpdTriggerDetector::~StFpdTriggerDetector() {}
127 StFpdTriggerDetector::init()
129 mMaxTower[0]=mMaxNS; mMaxTower[1]=mMaxNS;
130 mMaxTower[2]=mMaxTB; mMaxTower[3]=mMaxTB;
131 mMaxTower[4]=mMaxPS; mMaxTower[5]=mMaxPS;
132 mAdc[0][0]=mEN ;mAdc[0][1]=mES ;mAdc[0][2]=mET;mAdc[0][3]=mEB;
133 mAdc[0][4]=mEPN;mAdc[0][5]=mEPS;
134 mAdc[1][0]=mWN ;mAdc[1][1]=mWS ;mAdc[1][2]=mWT;mAdc[1][3]=mWB;
135 mAdc[1][4]=mWPN;mAdc[1][5]=mWPS;
139 StFpdTriggerDetector::clear()
141 memset(mBeg,0,mEnd-mBeg);
145 StFpdTriggerDetector::numberOfTowers(
unsigned int nstbps)
const
147 if (nstbps<mMaxModule)
148 return mMaxTower[nstbps];
154 StFpdTriggerDetector::numberOfModules()
const {
return mMaxModule;}
157 StFpdTriggerDetector::numberOfLayer1Boards()
const {
return mMaxBoard;}
160 StFpdTriggerDetector::adc(StBeamDirection ew,
unsigned int nstbps,
unsigned int tower)
const
162 if (nstbps<mMaxModule) {
163 if (tower < mMaxTower[nstbps])
164 return static_cast<unsigned int>(mAdc[ew][nstbps][tower]);
170 StFpdTriggerDetector::layer1(StBeamDirection ew,
unsigned int nstbps,
unsigned int board)
const
172 if (nstbps<mMaxModule && board<mMaxBoard)
173 return static_cast<unsigned int>(mLayer1[ew][nstbps][board]);
178 StFpdTriggerDetector::layer2(StBeamDirection ew,
unsigned int nstbps)
const
180 if (nstbps<mMaxModule)
181 return static_cast<unsigned int>(mLayer2[ew][nstbps]);
186 StFpdTriggerDetector::setAdc(StBeamDirection ew,
unsigned int nstbps,
unsigned int tower,
unsigned char v)
188 if (nstbps<mMaxModule)
189 if (tower < mMaxTower[nstbps])
190 mAdc[ew][nstbps][tower]=v;
194 StFpdTriggerDetector::setLayer1(StBeamDirection ew,
unsigned int nstbps,
unsigned int board,
unsigned short v)
196 if (nstbps<mMaxModule && board<mMaxBoard)
197 mLayer1[ew][nstbps][board]=v;
201 StFpdTriggerDetector::setLayer2(StBeamDirection ew,
unsigned int nstbps,
unsigned short v)
203 if (nstbps<mMaxModule)
204 mLayer2[ew][nstbps]=v;
208 StFpdTriggerDetector::dump()
const
210 printf(
"StFpdTriggerDetector::dump()\n");
211 printf(
"numberOfModules()=%d numberOfLayer1Boards()=%d\n",numberOfModules(),numberOfLayer1Boards());
212 for(
int ew=0; ew<2; ew++){
213 if(ew==0) printf(
"East\n");
214 else printf(
"West\n");
215 for(
unsigned int nstbps=0; nstbps<numberOfModules(); nstbps++){
216 printf(
"Module=%d numberOfTowers=%d\n",nstbps,numberOfTowers(nstbps));
217 for(
unsigned int tower=0; tower<numberOfTowers(nstbps); tower++){
218 printf(
"%4d ",adc((StBeamDirection)ew,nstbps,tower));
219 if(numberOfTowers(nstbps)==49 && tower%7==6) printf(
"\n");
220 if(numberOfTowers(nstbps)==25 && tower%5==4) printf(
"\n");
221 if(numberOfTowers(nstbps)==7 && tower%7==6) printf(
"\n");
224 for(
unsigned int bd=0; bd<numberOfLayer1Boards(); bd++){
225 printf(
"%4d ",layer1((StBeamDirection)ew,nstbps,bd));
227 printf(
"\nLayer2=%d\n",layer2((StBeamDirection)ew,nstbps));