1 #include "StEmcADCtoEMaker.h"
2 #include "StEventTypes.h"
6 #include "StEmcUtil/others/emcDetectorName.h"
7 #include "StEmcUtil/geometry/StEmcGeom.h"
8 #include "TStopwatch.h"
11 #include "StDaqLib/GENERIC/EventReader.hh"
12 #include "StDaqLib/EMC/EMC_Reader.hh"
13 #include "StDAQMaker/StDAQReader.h"
14 #include "StDaqLib/EMC/StEmcDecoder.h"
15 #include "StMessMgr.h"
16 #include "StMuDSTMaker/COMMON/StMuDst.h"
17 #include "StMuDSTMaker/COMMON/StMuDebug.h"
18 #include "StMuDSTMaker/COMMON/StMuEmcUtil.h"
19 #include "StMuDSTMaker/COMMON/StMuEvent.h"
34 mBemcData->towerMapBug(kTRUE);
35 mBemcData->psdMapBug2(kTRUE);
36 mBemcData->smdMapBug(kTRUE);
37 mBemcData->setCrateVeto(1);
39 StDetectorId bemcid =
static_cast<StDetectorId
>(kBarrelEmcTowerId);
40 setCheckStatus(bemcid,1);
41 StDetectorId bprsid =
static_cast<StDetectorId
>(kBarrelEmcPreShowerId);
42 setCheckStatus(bprsid,1);
43 StDetectorId bsmdeid =
static_cast<StDetectorId
>(kBarrelSmdEtaStripId);
44 setCheckStatus(bsmdeid, 1);
45 StDetectorId bsmdpid =
static_cast<StDetectorId
>(kBarrelSmdPhiStripId);
46 setCheckStatus(bsmdpid, 1);
61 mBemcData->initHisto();
63 return StMaker::Init();
68 LOG_INFO <<
"Getting database tables for the BEMC detector "<<endm;
71 if(muDst && muDst->
event())
72 mBemcData->
setProdVer(muDst->
event()->runInfo().productionVersion().Data());
75 LOG_INFO <<
"Setting done prod version"<<endm;
79 LOG_INFO <<
"loading table done"<<endm;
81 return StMaker::InitRun(run);
99 LOG_DEBUG <<
"StEmcADCtoEMaker::Make()******************************************************************"<<endm;
100 mTestedCorruption = kFALSE;
101 if(!prepareEnvironment())
102 LOG_WARN <<
"Could not prepare the proper environment"<<endm;
104 LOG_WARN <<
"Could not make BEMC detector"<<endm;
107 LOG_DEBUG <<
"Time to run StEmcADCtoEMaker::Make() real = "<<clock.RealTime()<<
" cpu = "<<clock.CpuTime()<<endm;
108 LOG_DEBUG <<
"*******************************************************************************************"<<endm;
116 Bool_t StEmcADCtoEMaker::prepareEnvironment()
119 LOG_DEBUG <<
"Get StEvent pointer and make it ready for filling"<<endm;
123 mEvent = (
StEvent*)GetDataSet(
"StEvent");
128 emc = mEvent->emcCollection();
133 emc = mEvent->emcCollection();
139 mEvent->setEmcCollection(emc);
147 emc->setBemcRawData(BemcData);
160 Bool_t StEmcADCtoEMaker::makeBemc()
166 TDataSet* TheData = GetDataSet(
"StDAQReader");
169 LOG_DEBUG <<
"Copying EMC information from DAQ structure "<<endm;
170 return mBemcData->
make(TheData,mEvent);
173 if(mEvent && !mMyStEvent)
178 LOG_DEBUG <<
"Copying EMC information from StEmcCollection "<<endm;
179 return mBemcData->
make(emc,mEvent);
190 LOG_DEBUG <<
"Copying EMC information from StEmcCollection "<<endm;
191 Bool_t ok = mBemcData->
make(muEmc,mEvent);
208 void StEmcADCtoEMaker::fillHistograms()
211 mBemcData->fillHisto();
215 LOG_INFO <<
"::setPrint() is obsolete. Use logger config file to set verbosity instead." << endm;
236 return mEvent->emcCollection();
241 if(!mTestedCorruption)
245 void StEmcADCtoEMaker::testCorruption()
247 mIsCorrupted = kFALSE;
248 mTestedCorruption = kTRUE;
257 mIsCorrupted = kTRUE;
261 Bool_t flagsAreOk = kFALSE;
264 for(
int crate = 1; crate<=MAXCRATES; crate++)
266 StEmcCrateStatus crateStatus = det->crateStatus(crate);
267 if (crateStatus==crateHeaderCorrupt)
268 mIsCorrupted = kTRUE;
269 if (crateStatus==crateHeaderCorrupt || crateStatus==crateOK)
294 StEmcGeom* geom = StEmcGeom::instance(
"bemc");
296 Int_t nModulesWithNoHits = 0;
297 Int_t nModulesOff = 0;
299 for(UInt_t imod = 1; imod <= det->numberOfModules(); ++imod)
303 StSPtrVecEmcRawHit& hits = module->hits();
304 for(UInt_t i = 0;i<hits.size();i++)
305 if(hits[i]->adc()==0)
309 nModulesWithNoHits += 1;
311 Int_t nTowersNoGood = 0;
312 for(Int_t eta = 1; eta<=20; eta++)
314 for(Int_t sub = 1; sub<=2; sub++)
317 geom->getId(imod, eta, sub, tower_id);
319 tables->
getStatus(BTOW, tower_id, status);
324 if(nTowersNoGood>=20)
328 if(nModulesWithNoHits != nModulesOff)
329 mIsCorrupted = kTRUE;
void setCheckStatus(Int_t det, Int_t flag, const char *option="")
Bool_t make(TDataSet *, StEvent *)
Make the BEMC detector from DAQ.
void PrintPsdMap(ofstream *out) const
Print SMD MAP.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Bool_t isCorrupted()
Returns if BTOW is corrupted or not.
virtual Int_t Init()
Init function. This method initializes the histograms.
void setPrint(Bool_t)
Obsolete function; users can control messages with logger config file.
virtual Int_t Make()
Process each event.
StBemcData * getBemcData()
Return the StBemcData pointer.
void PrintTowerMap(ofstream *out) const
Print Tower MAP.
void setProdVer(string prodVer)
Set event date.
void PrintSmdMap(ofstream *out) const
Print SMD MAP.
StBemcTables * getTables()
Return the StBemcTable pointer.
virtual Int_t Finish()
Finish function.
void setDate(Int_t d)
Set event date.
StEmcCollection * getEmcCollection()
Return emcCollection.
void createDecoder(Int_t, Int_t)
Create new StEmcDecoder.
void printMap(Int_t, char *)
print map for an EMC detector
StEmcDecoder * getDecoder()
Return the StEmcDecoder pointer.
void loadTables(StMaker *anyMaker)
load tables.
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual Int_t InitRun(Int_t)
InitRun function.
void printConf()
Print configuration.
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
static void setEmcCollection(StEmcCollection *emc_coll)
set pointer to current StEmcCollection
virtual ~StEmcADCtoEMaker()
StEmcADCtoEMaker destructor.
void setCheckStatus(StDetectorId det, int flag, const char *option="")