12 #include <StMessMgr.h>
14 #include "StBarrelMonitorMaker.h"
15 #include "StJanBarrelDbMaker.h"
16 #include "JanBprsEveA.h"
17 #include "BprsCapPolygraph.h"
18 #include "BarrelMipCalib.h"
20 #include "StMuDSTMaker/COMMON/StMuEvent.h"
21 #include "StMuDSTMaker/COMMON/StMuDst.h"
22 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
24 #include "StEmcRawMaker/defines.h"
25 #include "StEmcUtil/geometry/StEmcGeom.h"
27 #include "StDetectorDbMaker/St_tpcGasC.h"
28 #include "St_db_Maker/St_db_Maker.h"
29 #include "StEmcUtil/database/StEmcDecoder.h"
32 #include "StEventTypes.h"
33 #include "StMcEventTypes.hh"
34 #include "StMcEvent.hh"
43 cTile[0]=
'T'; cTile[1]=
'P';
44 cTile4[0]=
"BTOW"; cTile4[1]=
"BPRS";
46 nInpEve=nAcceptEve=nTrigEve=nCorrEve= mGeantEveInp=0;
62 StBarrelMonitorMaker::Init(){
67 mBtowGeom = StEmcGeom::instance(
"bemc");
68 mBprsGeom = StEmcGeom::instance(
"bprs");
69 mSmdEGeom = StEmcGeom::instance(
"bsmde");
70 mSmdPGeom = StEmcGeom::instance(
"bsmdp");
72 mMuDstMaker = (
StMuDstMaker*)GetMaker(
"MuDst"); assert(mMuDstMaker);
76 bprsPolygraph->setCut(50, 0.98,1,0.1);
77 bprsPolygraph->print();
80 mipCalib->setCut(60.,0.35,1.3,0.51, 3.3, 1.0, 180);
84 LOG_INFO<<Form(
"::Init() filter trigID=%d done", trigID)<<endm;
85 return StMaker::Init();
91 StBarrelMonitorMaker::InitRun(
int runNo){
92 LOG_INFO<<Form(
"::InitRun(%d) start",runNo)<<endm;
97 mMappB =
new StEmcDecoder(mydb->GetDateTime().GetDate(),mydb->GetDateTime().GetTime());
98 float airPres=St_tpcGasC::instance()-> barometricPressure();
99 LOG_INFO<<Form(
"::InitRun(%d) AirPressure=%.2f",runNo, airPres)<<endm;
101 LOG_WARN<<Form(
"::InitRun(%d) ??? , it is OK for M-C ",runNo)<<endm;
104 LOG_INFO<<Form(
"::InitRun() algo params: bprsHisto=%d calibPass=%d (bits)",
105 par_bprsHisto,par_calibPass
115 gMessMgr->Message(
"",
"I") <<
GetName()<<
"::Finish()\n inputEve="<<nInpEve<<
" trigFilterEve="<<nTrigEve<<
" nCorrEve="<<nCorrEve<<
" nAcceptEve="<<nAcceptEve<<endm;
122 StBarrelMonitorMaker::Clear(
const Option_t*){
125 for(
int icr=0; icr <mxBprsCrate;icr++) janBprsEveA[icr].clear();
136 eventID=muEve->eventId();
139 int nPrimV=mMuDstMaker->
muDst()->numberOfPrimaryVertices();
141 LOG_INFO <<
GetName()<<
"\n\n::Make()================ isMC="<<isMC<<
" eveID="<<eventID<<
" nInpEve="<<nInpEve<<
" nPrimV="<<nPrimV<<endm;
144 vector<unsigned int> trgL=mMuDstMaker->
muDst()->
event()->triggerIdCollection().nominal().triggerIds();
145 printf(
"trigL len=%d\n",
int(trgL.size()));
147 for( ii=0;ii<trgL.size();ii++) printf(
"ii=%d trigID=%d\n",ii,trgL[ii]);
148 if (mMuDstMaker->
muDst()->
event()->triggerIdCollection().nominal().isTrigger(19))
return kStOK;
155 unpackStTiles(kBTow);
156 unpackStTiles(kBPrs);
161 for(
int bprsCrateID=0; bprsCrateID<mxBprsCrate; bprsCrateID++)
165 bprsPolygraph->doBaseline(bprsEve,janEve);
166 bprsPolygraph->findBestCap(bprsEve,janEve);
167 bprsPolygraph->doPedResidua(bprsEve);
168 if(par_calibPass & kPassCapFix)
169 janEve.bprsCap[bprsCrateID]=bprsEve.getBestCapID();
172 calibrateTiles(kBPrs);
173 calibrateTiles(kBTow);
178 mipCalib->search(janEve);
188 StBarrelMonitorMaker::~StBarrelMonitorMaker(){
195 StBarrelMonitorMaker::saveHisto(TString fname){
196 TString outName=fname+
".hist.root";
197 TFile f( outName,
"recreate");
199 printf(
"HHH %d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
209 StBarrelMonitorMaker::unpackStTiles(
int ibp){
210 StEvent *mEvent = (
StEvent*)StMaker::GetChain()-> GetInputDS(
"StEvent");
224 detector=emc->detector(kBarrelEmcPreShowerId);
228 printf(
"no %s data, nInpEve=%d\n",cTile4[ibp],nInpEve);
234 for(
int icr=0;icr<mxBprsCrate;icr++) {
235 StEmcModule* module = detector->module(2+icr*30);assert(module);
236 StSPtrVecEmcRawHit& rawHit=module->hits();
237 if(rawHit.size()<=0) {
238 printf(
"ss icr=%d n=%dL, ABORT BpRS for this event\n",icr,
int(rawHit.size()));
241 assert(rawHit.size()>0);
242 janEve.bprsCap[icr]= rawHit[10]->calibrationType();
244 if(icr==3) janEve.bprsCap[icr]= rawHit[32]->calibrationType();
250 for(Int_t m = 1; m <= 120; ++m) {
253 if(!module)
continue;
255 StSPtrVecEmcRawHit& rawHit=module->hits();
257 for(UInt_t k = 0; k < rawHit.size(); ++k){
260 Int_t m=rawHit[k]->module();
261 Int_t e=rawHit[k]->eta();
262 Int_t s=abs(rawHit[k]->sub());
263 float rawAdc=rawHit[k]->adc()+0.5;
266 geomB->getId(m,e,s,
id);
268 #if 0 // tmp for Matt, to QA new mapping
270 int id1=(int)mJanDbMaker->bprsReMap()->GetBinContent(
id);
271 printf(
"BPRSX %d %d %d %d\n",nInpEve-1,id1,rawHit[k]->adc(),rawHit[k]->calibrationType());
278 janEve.rawAdcTile[ibp][
id-1]=rawAdc;
284 janEve.tileIn[ibp]=1;
291 StBarrelMonitorMaker::calibrateTiles(
int ibp){
293 if(janEve.tileIn[ibp]==0)
return;
295 for(
int id0=0; id0<mxBtow; id0++) {
300 int stat =mJanDbMaker->statTile(ibp,
id);
303 crateID= mJanDbMaker->bprsCrate(
id);
304 capID=janEve.bprsCap[crateID];
307 float ped =mJanDbMaker->pedTile(ibp,
id,capID);
308 float rawAdc =janEve.rawAdcTile[ibp][id0];
311 if(ibp==kBPrs && rawAdc>100 && rawAdc<300){
313 hTonko0->Fill(
id,capID,1.);
314 hTonko1->Fill(
id,capID,rawAdc);
315 hTonko2->Fill(
id,capID,rawAdc*rawAdc);
318 if(!(par_calibPass & kPassPedSub)) {
319 hTile[ibp]->Fill(
id,rawAdc);
320 if(par_bprsHisto==2) hBprs3D->Fill(
id,rawAdc,capID);
323 if(par_calibPass==0)
continue;
327 id=(int)mJanDbMaker->btowReMap()->GetBinContent(
id);
328 }
else if(ibp==kBPrs) {
329 id=(int)mJanDbMaker->bprsReMap()->GetBinContent(
id);
336 janEve.statTile[ibp][
id-1]=stat;
339 janEve.statTile[ibp][
id-1]=0;
342 float adc=rawAdc-ped;
343 janEve.adcTile[ibp][
id-1]= adc;
345 if(par_calibPass & kPassPedSub){
346 hTile[ibp]->Fill(
id,adc);
348 hBprsA[crateID]->Fill(adc);
349 if(par_bprsHisto==2) hBprs3D->Fill(
id,adc,capID);
364 StBarrelMonitorMaker::populateBprsEveA(){
366 if(janEve.tileIn[kBPrs]==0)
return;
368 for(
int icr=0; icr <mxBprsCrate;icr++) {
369 int capID=janEve.bprsCap[icr];
370 janBprsEveA[icr].set(capID,icr,eventID);
374 for(
int id0=0; id0<mxBtow; id0++) {
376 int icr=mJanDbMaker->bprsCrate(
id);
377 float rawAdc =janEve.rawAdcTile[ibp][id0];
378 janBprsEveA[icr].addRawValue(
id,rawAdc);
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual const char * GetName() const
special overload