1 #include "StEmcCalibrationMaker.h"
7 #include "StEventTypes.h"
11 #include "StEmcUtil/geometry/StEmcGeom.h"
12 #include "StEmcUtil/filters/StEmcFilter.h"
13 #include "StEmcUtil/projection/StEmcPosition.h"
14 #include "StarClassLibrary/StThreeVectorF.hh"
15 #include "StarClassLibrary/StElectron.hh"
16 #include "tables/St_emcStatus_Table.h"
17 #include "PhysicalConstants.h"
18 #include "tables/St_emcPed_Table.h"
19 #include "tables/St_smdPed_Table.h"
20 #include "tables/St_emcStatus_Table.h"
21 #include "tables/St_smdStatus_Table.h"
22 #include "StEmcADCtoEMaker/StBemcData.h"
23 #include "StDbLib/StDbManager.hh"
24 #include "StDbLib/StDbTable.h"
25 #include "StDbLib/StDbConfigNode.hh"
26 #include "StDaqLib/EMC/StEmcDecoder.h"
37 TString n[MAXBEMC]={
"bemc",
"bprs",
"bsmde",
"bsmdp"};
38 for(
int i=0;i<MAXBEMC;i++) mGeom[i] = StEmcGeom::instance(n[i].Data());
46 StEmcCalibrationMaker::~StEmcCalibrationMaker()
50 Int_t StEmcCalibrationMaker::Init()
52 return StMaker::Init();
55 void StEmcCalibrationMaker::zeroAll()
63 for(
int i=0;i<MAXTRACK;i++)
66 mTrackP[i] = mTrackPt[i] = mTrackTower[i] = mTrackNPoints[i] = mTrackTowerExit[i] =0;
68 for(
int i=0;i<MAXBEMC;i++)
for(
int j=0;j<mNChannel[i];j++)
70 mADC[i][j] = mADCPedSub[i][j] = 0;
71 mCap[i][j] = mNTracksTower[j] = 0;
72 mPedRms[i][j] = mPed[i][j] = 0;
73 if(i==0) mIsIsolatedTower[j] =
true;
74 mHasDetector[i] =
false;
83 mStEvent = (
StEvent*)GetInputDS(
"StEvent");
84 if(!mStEvent)
return kStOk;
86 if(!mEmcCol)
return kStOk;
92 mVx-=position.x(); mVy=position.y(); mVz=position.z();
99 if (evtSummary) mField = evtSummary->magneticField()/10;
112 void StEmcCalibrationMaker::fillEmcArrays()
114 TString n[MAXBEMC]={
"bemc",
"bprs",
"bsmde",
"bsmdp"};
116 for(
int i = 0;i<MAXBEMC;i++)
118 mHasDetector[i] =
false;
119 TString calibDb=
"Calibrations/emc/y3";
121 TDataSet *emcDb=GetInputDB(calibDb.Data());
126 St_emcPed *ped = (St_emcPed*)emcDb->
Find(table.Data());
127 emcPed_st *pedst=NULL;
128 if(ped) pedst=ped->GetTable();
129 if(pedst)
for(
int j=0;j<mNChannel[i];j++)
131 mPed[i][j] = (float)pedst[0].AdcPedestal[j]/100.;
132 mPedRms[i][j] = (float)pedst[0].AdcPedestalRMS[j]/100.;
136 else if(i>=2 && emcDb)
138 St_smdPed *ped = (St_smdPed*)emcDb->
Find(table.Data());
139 smdPed_st *pedst=NULL;
140 if(ped) pedst=ped->GetTable();
141 if(pedst)
for(
int j=0;j<mNChannel[i];j++)
143 mPed[i][j] = (float)pedst[0].AdcPedestal[j][0]/100.;
144 mPedRms[i][j] = (float)pedst[0].AdcPedestalRMS[j][0]/100.;
149 StDetectorId
id =
static_cast<StDetectorId
>(i+kBarrelEmcTowerId);
151 if(detector)
for(
int m=1;m<=120;m++)
156 StSPtrVecEmcRawHit& rawHit=module->hits();
157 for(
unsigned int k=0;k<rawHit.size();k++)
if(rawHit[k])
159 mHasDetector[i] =
true;
161 int mod=rawHit[k]->module();
162 int e=rawHit[k]->eta();
163 int s=abs(rawHit[k]->sub());
164 int ADC = rawHit[k]->adc();
165 int stat = mGeom[i]->getId(mod,e,s,did);
168 mADC[i][did-1] = ADC;
169 mADCPedSub[i][did-1] = (short)(ADC - mPed[i][did-1]);
170 mCap[i][did-1] = (char) rawHit[k]->calibrationType();
171 if(mCap[i][did-1]>127) mCap[i][did-1]-=128;
172 if(mPed[i][did-1]==0 || mPedRms[i][did-1]==0) mADCPedSub[i][did-1] = 0;
175 if(mCap[i][did-1]==CAP1 || mCap[i][did-1]==CAP1)
177 mADCPedSub[i][did-1] = 0;
188 void StEmcCalibrationMaker::fillTrackArrays()
190 StSPtrVecTrackNode& tracks=mStEvent->trackNodes();
191 mNTracks = tracks.size();
195 if(mStEvent->l3Trigger())
197 tracks =mStEvent->l3Trigger()->trackNodes();
198 mNTracks = tracks.size();
204 for(
int t=0;t<mNTracks;t++)
209 if(track->geometry())
211 mTrackPt[t] = track->geometry()->momentum().perp();
212 mTrackP[t] = track->geometry()->momentum().mag();
213 mTrackNPoints[t] = track->fitTraits().numberOfFitPoints();
215 bool tok = mPosition->
trackOnEmc(&position,&momentum,(
StTrack*)track,(Double_t)mField,(Double_t)mGeom[0]->Radius());
219 float eta=position.pseudoRapidity();
220 float phi=position.phi();
221 int stat = mGeom[0]->
getBin(phi,eta,m,e,s);
222 stat = mGeom[0]->getId(m,e,s,
id);
226 mNTracksTower[
id-1]++;
228 bool tok1 = mPosition->
trackOnEmc(&position1,&momentum1,(
StTrack*)track,(Double_t)mField,(Double_t)mGeom[0]->Radius()+30.0);
232 eta=position1.pseudoRapidity();
234 stat = mGeom[0]->
getBin(phi,eta,m,e,s);
235 stat = mGeom[0]->getId(m,e,s,id2);
238 mTrackTowerExit[t] = id2;
239 if(id2!=
id) mNTracksTower[id2-1]++;
249 for(
int i=0;i<mNChannel[0];i++)
252 mIsIsolatedTower[
id-1] =
true;
253 for(
int j=-1;j<=1;j++)
for(
int k=-1;k<=1;k++)
256 if(id2!=
id)
if(id2>=1 && id2<=4800)
if(mNTracksTower[id2-1]>0) { mIsIsolatedTower[
id-1] =
false;
break; }
260 void StEmcCalibrationMaker::makeStatus(
bool t,
bool p,
bool se,
bool sp)
265 for(
int i =0;i<4800;i++) towers[i] = 1;
267 int crates[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
268 1,1,1,1,0,1,1,1,1,1,0,1,1,1,1};
273 for(
int i =0;i<4800;i++) psd[i] = 1;
274 for(
int i =2400;i<4800;i++) psd[i] = 0;
279 for(
int i =0;i<18000;i++) smde[i] = 1;
282 for(
int i =0;i<120;i++) smdeMod[i] = 1;
283 for(
int i =60;i<120;i++) smdeMod[i] = 0;
288 for(
int i =0;i<18000;i++) smdp[i] = 1;
291 for(
int i =0;i<120;i++) smdpMod[i] = 1;
292 for(
int i =60;i<120;i++) smdpMod[i] = 0;
297 const char *timestamp =
"2004-01-01 00:00:00";
306 St_emcStatus *mBemc =
new St_emcStatus(
"emcStatus",1);
307 emcStatus_st *bemc=mBemc->GetTable();
309 for(
int i=0;i<4800;i++)
311 bemc[0].Status[i] = towers[i];
316 bemc[0].Status[i] = crates[crate-1];
319 StDbTable* tab1=node->addDbTable(
"bemcStatus");
321 mgr->setStoreTime(timestamp);
322 mgr->storeDbTable(tab1);
329 St_emcStatus *mPSD =
new St_emcStatus(
"emcStatus",1);
330 emcStatus_st *psdt = mPSD->GetTable();
332 for(
int i=0;i<4800;i++)
334 psdt[0].Status[i] = psd[i];
337 StDbTable* tab2=node->addDbTable(
"bprsStatus");
339 mgr->setStoreTime(timestamp);
340 mgr->storeDbTable(tab2);
347 St_smdStatus *mSMDE =
new St_smdStatus(
"smdStatus",1);
348 smdStatus_st *smdet = mSMDE->GetTable();
349 StEmcGeom *geo3 = StEmcGeom::instance(
"bsmde");
351 for(
int i=0;i<18000;i++)
353 smdet[0].Status[i] = smde[i];
356 smdet[0].Status[i] = smdeMod[m-1];
359 StDbTable* tab3=node->addDbTable(
"bsmdeStatus");
361 mgr->setStoreTime(timestamp);
362 mgr->storeDbTable(tab3);
368 St_smdStatus *mSMDP =
new St_smdStatus(
"smdStatus",1);
369 smdStatus_st *smdpt = mSMDP->GetTable();
370 StEmcGeom *geo4 = StEmcGeom::instance(
"bsmdp");
372 for(
int i=0;i<18000;i++)
374 smdpt[0].Status[i] = smdp[i];
377 smdpt[0].Status[i] = smdpMod[m-1];
380 StDbTable* tab4=node->addDbTable(
"bsmdpStatus");
382 mgr->setStoreTime(timestamp);
383 mgr->storeDbTable(tab4);
Bool_t trackOnEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StTrack *const track, Double_t magField, Double_t emcRadius=225.405) const
Track projection utility.
int GetTowerCrateFromDaqId(int RDO, int &crate, int &sequence) const
Get crate number from Daq Id for towers.
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
Int_t getNextTowerId(Float_t eta, Float_t phi, Int_t nTowersdEta, Int_t nTowersdPhi) const
Return neighbor tower id's.
static StDbManager * Instance()
strdup(..) is not ANSI
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
int GetDaqIdFromTowerId(int softId, int &RDO) const
Get Daq Id from Software Id for towers.
virtual TDataSet * Find(const char *path) const