1 #include "StMuEmcUtil.h"
4 #include "StEventTypes.h"
5 #include "StMuEmcCollection.h"
6 #include "SystemOfUnits.h"
7 #include "StEmcUtil/geometry/StEmcGeom.h"
8 #include "StMuEmcTowerData.h"
12 #define __EMC_HITS_ID_DIM__ 18000
15 StMuEmcUtil::StMuEmcUtil()
18 for(Int_t i =0;i<4;i++) mGeo[i]=StEmcGeom::getEmcGeom(i+1);
20 StMuEmcUtil::~StMuEmcUtil()
25 if(!emccol)
return NULL;
27 fillMuEmc(muEmc,emccol);
32 if(!muEmc)
return NULL;
44 for(Int_t d=0; d<8; d++)
48 StDetectorId
id =
static_cast<StDetectorId
>(d+kBarrelEmcTowerId);
55 for(Int_t j=1;j<maxMod;j++)
60 const StSPtrVecEmcRawHit& rawHit=module->hits();
61 Int_t nhits=(Int_t)rawHit.size();
63 for(Int_t k=0;k<nhits;k++)
65 Int_t m = rawHit[k]->module();
66 Int_t e = rawHit[k]->eta();
67 Int_t s = abs(rawHit[k]->sub());
68 Int_t adc = rawHit[k]->adc();
69 Float_t energy = rawHit[k]->energy();
70 Int_t cal = rawHit[k]->calibrationType();
73 if(d<4 && cal>127) save =
false;
78 mGeo[d]->getId(m,e,s,rid);
82 if(getEndcapId(EmcDet,m,e,s,rid))
continue;
85 if(EmcDet == 1 || EmcDet == 5 )
87 muEmc->setTowerADC(rid,adc,EmcDet);
89 if(EmcDet==2 || EmcDet == 6)
91 muEmc->addPrsHit(EmcDet);
92 StMuEmcHit* muHit = muEmc->getPrsHit(muEmc->getNPrsHits(EmcDet)-1,EmcDet);
95 muHit->setEnergy(energy);
96 muHit->setCalType(cal);
98 if(EmcDet==3 || EmcDet==4 || EmcDet==7 || EmcDet==8)
100 muEmc->addSmdHit(EmcDet);
101 StMuEmcHit* muHit = muEmc->getSmdHit(muEmc->getNSmdHits(EmcDet)-1,EmcDet);
104 muHit->setEnergy(energy);
105 muHit->setCalType(cal);
115 n_crate=StMuEmcTowerData::nBTowCrates;
118 n_crate=StMuEmcTowerData::nBPrsCrates;
121 n_crate=StMuEmcTowerData::nBSmdCrates;
124 n_crate=StMuEmcTowerData::nETowCrates;
127 n_crate=StMuEmcTowerData::nEPrsCrates;
130 n_crate=StMuEmcTowerData::nESmdCrates;
133 for (Int_t i_crate=1; i_crate<=n_crate; i_crate++) {
134 muEmc->setCrateStatus(detector->crateStatus(i_crate),i_crate,EmcDet);
148 for(Int_t i=0;i<8;i++)
152 StDetectorId
id =
static_cast<StDetectorId
>(i+kBarrelEmcTowerId);
156 emc->setDetector(detector);
159 if (det==1) nh = 4800;
160 if (det==5) nh = 720;
161 if (det==2 || det ==6) nh=muEmc->getNPrsHits(det);
162 if (det==3 || det==4 || det==7 || det==8) nh=muEmc->getNSmdHits(det);
164 for(Int_t j=0;j<nh;j++)
172 a = muEmc->getTowerADC(j+1,det);
173 if(det==1) mGeo[det-1]->
getBin(j+1,m,e,s);
175 if( getEndcapBin(det,j+1,m,e,s)) continue ;
179 if(a==0) save = kFALSE;
181 if(det==2 || det ==6)
187 if(det==2) mGeo[det-1]->
getBin(rid,m,e,s);
189 if( getEndcapBin(det,rid,m,e,s)) continue ;
192 cal=hit->getCalType();
194 }
else save = kFALSE;
196 if(det==3 || det==4 || det==7 || det==8)
198 const StMuEmcHit* hit=muEmc->getSmdHit(j,det);
202 if(det<5) mGeo[det-1]->
getBin(rid,m,e,s);
204 if( getEndcapBin(det,rid,m,e,s)) continue ;
207 cal=hit->getCalType();
209 }
else save = kFALSE;
214 rawHit->setCalibrationType(cal);
216 detector->addHit(rawHit);
223 n_crate=StMuEmcTowerData::nBTowCrates;
226 n_crate=StMuEmcTowerData::nBPrsCrates;
230 n_crate=StMuEmcTowerData::nBSmdCrates;
233 n_crate=StMuEmcTowerData::nETowCrates;
236 n_crate=StMuEmcTowerData::nEPrsCrates;
240 n_crate=StMuEmcTowerData::nESmdCrates;
243 for (Int_t i_crate=1; i_crate<=n_crate; i_crate++) {
244 detector->setCrateStatus(i_crate,muEmc->getCrateStatus(i_crate,det));
252 int StMuEmcUtil::getEndcapId(
int d,
int m,
int e,
int s,
int &rid)
const {
260 if( m<=0 || m >12 || d<5 || d>8 ) {
261 text=
"m<=0 || m >12 || d<5 || d>8 ";
268 if( e<=0 || e>12 || s<=0 || s>5 ) {
269 text=
"e<=0 || e>12 || s<=0 || s>5 ,towers";
272 rid = 60*(m-1) + 12*(s-1) + e-1;
276 if( e<=0 || e>12 || s<=0 || s>15 ) {
277 text=
"e<=0 || e>12 || s<=0 || s>15 , pre/post";
280 rid = 180*(m-1) + 12*(s-1) + e-1;
285 if( s!=1 || e<=0 || e>288 ) {
286 text=
" s!=1 || e<=0 || e>288, SMD";
289 rid = 300*(m-1) + e-1;
304 gMessMgr->Error() <<
"StMuEmcUtil::getEndcapId(), FATAL internal error: "
305 <<text<<
"\n d="<<d<<
" m="<<m<<
" e="<<
" s="<<s<<
" rid "<<rid
306 <<
"\n ENDCAP data may be wrong, " << endm;
311 int StMuEmcUtil::getEndcapBin(
int d,
int rid0,
int &m,
int &e,
int &s)
const
322 if( rid0<=0 || d<5 || d>8 ) {
323 text=
"rid0<=0 || d<5 || d>8 ";
334 if ( m>12 || s<1 || s>5 || e>12 ) {
335 text=
" m>12 || s<1 || s>5 || e>12 , tower";
345 if ( m>12 || s<1 || s>15 || e>12 ) {
346 text=
" m>12 || s<1 || s>15 || e>12 , pre/post";
356 if ( m>12 || e>288 || e <1 ) {
357 text=
" m>12 || s<=0 || s>5 || e>12 , smd";
367 gMessMgr->Error() <<
"StMuEmcUtil::getEndcapBin(), FATAL internal error: "
368 <<text<<
"\n d="<<d<<
" m="<<m<<
" e="<<
" s="<<s<<
" rid0 "<<rid0
369 <<
"\n ENDCAP data may be wrong, "
370 <<
" assert() should be here, JB"<<endm;
int getId() const
Return Module number.
float getEnergy() const
Return Hit energy.
int getAdc() const
Return ADC value.
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const