5 #include "StBemcStatusMaker.h"
10 #include "StTriggerIdCollection.h"
11 #include "StTriggerId.h"
12 #include "StEmcCollection.h"
13 #include "StEmcDetector.h"
14 #include "StEmcModule.h"
15 #include "StEmcRawHit.h"
16 #include "StL0Trigger.h"
17 #include "StMuDSTMaker/COMMON/StMuDst.h"
18 #include "StMuDSTMaker/COMMON/StMuEmcUtil.h"
19 #include "StMuDSTMaker/COMMON/StMuEvent.h"
20 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
21 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
22 #include "StMuDSTMaker/COMMON/StMuEmcTowerData.h"
23 #include "StEmcADCtoEMaker/StEmcADCtoEMaker.h"
25 #include "StEmcUtil/geometry/StEmcGeom.h"
26 #include "StEEmcUtil/database/StEEmcDb.h"
27 #include "StEEmcUtil/database/EEmcDbItem.h"
29 #include "StDbManager.hh"
30 #include "StDbConfigNode.hh"
31 #include "StDataBaseI.hh"
33 StBemcStatusMaker::StBemcStatusMaker(
StMuDstMaker* maker)
34 :
StMaker(
"bemcStatus"), mMuDstMaker(maker) {
35 mOutputDirectory =
"/tmp";
36 mOutputFilePrefix =
"junk";
40 cout <<
"EEmcDbMaker not in chain. Add it." << endl;
45 Int_t StBemcStatusMaker::Init() {
46 eeDb = (
StEEmcDb*)this->GetDataSet(
"StEEmcDb");
48 string s = mOutputDirectory +
"/" + mOutputFilePrefix +
"cal.minirun.root";
49 mOutputFile =
new TFile(s.c_str(),
"RECREATE");
50 mOutputTree =
new TTree(
"calinfo",
"Extraneous Information");
51 mOutputTree->Branch(
"fillnum",&mFillNumber,
"fillnum/F");
52 mOutputTree->Branch(
"thedate",&mTheDate,
"thedate/I");
53 mOutputTree->Branch(
"thetime",&mTheTime,
"thetime/I");
54 mOutputTree->Branch(
"statusEEMC",mEemcStatusBits,
"statusEEMC/F");
55 mOutputTree->Branch(
"statusBEMC",mBemcStatusBits,
"statusBEMC/F");
57 if (!mOutputFile)
return kStErr;
63 Int_t runnumber=muEvent->eventInfo().runId();
68 vector<unsigned int> trgId=oflTrgId.triggerIds();
71 for(i = 0; i < trgId.size() ; i++){
73 if(trgId[i]==117001 || trgId[i]==117811 || trgId[i]==147001) isGood=
true;
89 cout <<
" Not StEvent!"<<endl;
95 cout <<
"No emc Collection"<<endl;
100 cout <<
"No barrel!" << endl;
106 for(
int crate = 1; crate<=MAXCRATES; crate++) {
107 StEmcCrateStatus crateStatus = bemc->crateStatus(crate);
108 if (crateStatus==crateHeaderCorrupt) {
109 cout <<
"corruption!" << endl;
118 TH2F* bemcAdcHist = getBemcAdcHist(runnumber);
125 cout <<
"Problems with Histo"<<endl;
131 for (UInt_t i = 1; i <= bemc->numberOfModules(); i++) {
134 StSPtrVecEmcRawHit& hits = module->hits();
135 for (StEmcRawHitIterator
hit = hits.begin();
hit!=hits.end(); ++
hit) {
137 StEmcGeom* geom = StEmcGeom::instance(
"bemc");
138 geom->getId((*hit)->module(),(*hit)->eta(),(*hit)->sub(),id);
139 bemcAdcHist->Fill(
id,(*hit)->adc());
145 int id, sec, sub, etabin, rawadc;
147 for (
int i = 0; i < muemcColl->getNEndcapTowerADC(); i++) {
148 muemcColl->getEndcapTowerADC(i,rawadc,sec,sub,etabin);
153 mMuDstMaker->
muEmcUtil()->getEndcapId(5,sec,etabin,sub,
id);
155 cout <<
"my scheme for EEMC doesn't work right" << endl;
156 cout <<
"i is " << i <<
" and id is " <<
id << endl;
167 StDbTable* tab=node->addDbTable(
"beamInfo");
171 sprintf(queryStr,
" where runNumber='%d' and deactive=0",runnumber);
172 cout << queryStr << endl;
173 ts = filldb->QueryDb(tab,queryStr);
176 char* start = tab->getBeginDateTime();
177 int startTime = atoi(&(start[8]));
179 mTheDate = atoi(start);
180 if (start[12] ==
'0')
181 mTheTime = startTime - 50;
183 mTheTime = startTime - 10;
187 mFillNumber=muEvent->runInfo().beamFillNumber(yellow);
188 for(
int i=0; i<720; i++) {
189 muemcColl->getEndcapTowerADC(i,rawadc,sec,sub,etabin);
205 mOutputFile->Write();
212 TH2F* StBemcStatusMaker::getBemcAdcHist(Int_t runNumber) {
214 snprintf(name,254,
"bemcStatusAdc_%d",runNumber);
216 TH2F* hist =
dynamic_cast<TH2F*
>(mOutputFile->Get(name));
219 snprintf(title,254,
"BEMC tower adc run %d",runNumber);
222 hist =
new TH2F(name, title,4801,-0.5,4800.5,3000,0,3000);
223 hist->GetXaxis()->SetTitle(
"tower id");
224 hist->GetYaxis()->SetTitle(
"adc");
229 TH2F* StBemcStatusMaker::getBemcEnergyHist(Int_t runNumber) {
231 snprintf(name,254,
"bemcStatusEnergy_%d",runNumber);
233 TH2F* hist =
dynamic_cast<TH2F*
>(mOutputFile->Get(name));
236 snprintf(title,254,
"BEMC tower energy run %d",runNumber);
237 hist =
new TH2F(name, title,4801,-0.5,4800.5,150,0,3);
238 hist->GetXaxis()->SetTitle(
"tower id");
239 hist->GetYaxis()->SetTitle(
"adc");
244 TH2F* StBemcStatusMaker::getEemcAdcHist(Int_t runNumber) {
246 snprintf(name,254,
"eemcStatusAdc_%d",runNumber);
248 TH2F* hist =
dynamic_cast<TH2F*
>(mOutputFile->Get(name));
251 snprintf(title,254,
"EEMC tower adc run %d",runNumber);
252 hist =
new TH2F(name, title,721,-0.5,720.5,150,0,150);
253 hist->GetXaxis()->SetTitle(
"tower id");
254 hist->GetYaxis()->SetTitle(
"adc");
259 TH2F* StBemcStatusMaker::getEemcEnergyHist(Int_t runNumber) {
261 snprintf(name,254,
"eemcStatusEnergy_%d",runNumber);
263 TH2F* hist =
dynamic_cast<TH2F*
>(mOutputFile->Get(name));
266 snprintf(title,254,
"EEMC tower energy run %d",runNumber);
267 hist =
new TH2F(name, title,4801,-0.5,4800.5,150,0,3);
268 hist->GetXaxis()->SetTitle(
"tower id");
269 hist->GetYaxis()->SetTitle(
"adc");
StMuEmcUtil * muEmcUtil()
return pointer to StMuEmcUtil;
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)
static StDbManager * Instance()
strdup(..) is not ANSI
Collection of trigger ids as stored in MuDst.