11 #include <StMessMgr.h>
12 #include <StThreeVectorF.hh>
15 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
16 #include <StMuDSTMaker/COMMON/StMuDst.h>
17 #include <StMuDSTMaker/COMMON/StMuEvent.h>
19 #include "StEmcUtil/database/StBemcTables.h"
20 #include "StEmcUtil/geometry/StEmcGeom.h"
22 #include "StEEmcUtil/database/StEEmcDb.h"
23 #include "StEEmcUtil/database/EEmcDbItem.h"
24 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
25 #include "StEEmcUtil/StEEmcSmd/EEmcSmdGeom.h"
28 #include "StSpinPool/StJetEvent/StJetEvent.h"
29 #include "StSpinPool/StJetEvent/StJetVertex.h"
30 #include "StSpinPool/StJetEvent/StJetCandidate.h"
32 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
33 #include "WeventDisplay.h"
34 #include "St2011WMaker.h"
41 char muDstMakerName[]=
"MuDst";
46 mTreeChain=
new TChain(
"mWtree",
"W candidate events");
51 assert(mMuDstMaker || mTreeChain);
53 mJetTreeChain=
new TChain(
"jet",
"Jet Tree");
59 LOG_WARN<<GetName()<<Form(
"::constructor() NO JETS , W-algo is not working properly, continue")<<endm;
62 par_l2bwTrgID=parE_l2ewTrgID=0;
67 nInpEve= nTrigEve= nAccEve=0;
70 par_l0emulAdcThresh=30;
71 par_l2emulSeedThresh=5.0;
72 par_l2emulClusterThresh=12.0;
86 par_nearTotEtFrac=0.88;
88 par_leptonEtaLow=-1.5;
89 par_leptonEtaHigh=1.5;
94 par_trackRin=90; par_trackRout=160;
101 parE_trackEtaMin=0.7;
103 parE_clustFrac24=0.90;
104 parE_nearTotEtFrac=0.85;
106 parE_leptonEtaLow=0.7;
107 parE_leptonEtaHigh=2.5;
112 parE_trackRin=120; parE_trackRout=70;
120 parE_QET2PTlow = 0.4;
121 parE_QET2PThigh = 1.8;
123 assert(2*parE_nSmdStrip+1==41);
124 assert(parE_esmdGL<=parE_esmdWL);
125 assert(parE_esmdWL<parE_nSmdStrip);
130 par_awayDeltaPhi=0.7;
150 St2011WMaker::Init(){
157 for(
int isec=0;isec<mxTpcSec;isec++) {
159 float Rin=par_trackRin,Rout=par_trackRout;
160 float RinE=parE_trackRin,RoutE=parE_trackRout;
162 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
163 mTpcFilterE[isec].setCuts(parE_nFitPts,parE_nHitFrac,RinE,RoutE);
165 mTpcFilter[isec].init(
"sec",sec,HListTpc,
true);
166 mTpcFilterE[isec].init(
"secEemcTr",sec,HListTpc,
false);
170 mJetTreeChain->SetBranchAddress(mJetTreeBranch,&mJetEvent);
171 mJetTreeChain->SetBranchAddress(mJetTreeBranch_noEEMC,&mJetEvent_noEEMC);
176 mDbE = (
StEEmcDb*)GetDataSet(
"StEEmcDb");
182 mTreeChain-> SetBranchAddress(
"wEve",&wEve);
185 mBtowGeom = StEmcGeom::instance(
"bemc");
186 mBSmdGeom[kBSE] = StEmcGeom::instance(
"bsmde");
187 mBSmdGeom[kBSP] = StEmcGeom::instance(
"bsmdp");
189 geoSmd= EEmcSmdGeom::instance();
194 if(isMC) par_minPileupVert=1;
198 mTreeFile=
new TFile(mTreeName,
"recreate");
202 mWtree=
new TTree(
"mWtree",
"W candidate Events");
203 mWtree->Branch(
"wEve",
"Wevent2011",&wEve);
206 return StMaker::Init();
212 St2011WMaker::InitRun(
int runNo){
213 LOG_INFO<<Form(
"::InitRun(%d) start",runNo)<<endm;
214 if(!isMC) assert(mRunNo==0);
224 LOG_INFO<<Form(
"::InitRun(%d) %s done\n Barrel W-algo params: trigID L2BW=%d isMC=%d\n TPC: nPileupVert>%d, vertex |Z|<%.1fcm, primEleTrack: nFit>%d, hitFrac>%.2f Rin<%.1fcm, Rout>%.1fcm, PT>%.1fGeV/c\n BTOW ADC: kSigPed=%d AdcThr>%d maxAdc>%.0f clustET>%.1f GeV ET2x2/ET4x4>%0.2f ET2x2/nearTotET>%0.2f\n dist(track-clust)<%.1fcm, nearDelR<%.1f\n W selection highET>%.1f awayDelPhi<%.1frad ptBalance>%.1fGeV %.1f<leptonEta<%.1f ",
225 mRunNo, coreTitle.Data(), par_l2bwTrgID,isMC,
226 par_minPileupVert,par_vertexZ,
227 par_nFitPts,par_nHitFrac, par_trackRin, par_trackRout, par_trackPt,
228 par_kSigPed, par_AdcThres,par_maxADC,par_clustET,par_clustFrac24,par_nearTotEtFrac,
229 par_delR3D,par_nearDeltaR,
230 par_highET,par_awayDeltaPhi,par_ptBalance,par_leptonEtaLow,par_leptonEtaHigh
233 cout<<Form(
"\n Endcap W-algo params: trigID: L2EW=%d isMC=%d\n TPC: nPileupVert>%d, vertex |Z|<%.1fcm, primEleTrack: nFit>%d, hitFrac>%.2f Rin<%.1fcm, Rout>%.1fcm, PT>%.1fGeV/c\n ETOW ADC: kSigPed=%d AdcThr>%d maxAdc>%.0f clustET>%.1f GeV ET2x1/ET4x4>%0.2f ET2x1/nearTotET>%0.2f\n dist(track-clust)<%.1fcm, nearDelR<%.1f\n W selection highET>%.1f awayDelPhi<%.1frad ptBalance>%.1fGeV , \n ESMD: nSmdStrip=%d, gateL=%d windowL=%d smdRatio=%.2f",
235 par_minPileupVert,par_vertexZ,
236 parE_nFitPts,parE_nHitFrac,parE_trackRin,parE_trackRout,parE_trackPt,
237 par_kSigPed,par_AdcThres,par_maxADC,parE_clustET,parE_clustFrac24,parE_nearTotEtFrac,
238 parE_delR3D,par_nearDeltaR,
239 par_highET,par_awayDeltaPhi,parE_ptBalance, parE_nSmdStrip, parE_esmdGL, parE_esmdWL, parE_smdRatio
241 cout<<Form(
"\n EtowScaleFact=%.2f BtowScaleFacor=%.2f" ,par_etowScale, par_btowScale)<<endl;
245 for(
int isec=0;isec<mxTpcSec;isec++) {
247 float Rin=par_trackRin,Rout=par_trackRout;
248 float RinE=parE_trackRin,RoutE=parE_trackRout;
252 if(sec==4 && mRunNo>=10090089 && mRunNo<=11000000 ) Rin=125.;
253 if(sec==11 && mRunNo>=10083013 && mRunNo<=11000000 ) Rin=125.;
254 if(sec==15 && mRunNo>=10088096 && mRunNo<=10090112 ) Rin=125.;
259 if((sec==5 || sec==6 || sec==7 || sec==21) && (mRunNo>=13000000 || mRunNo/100==3) ) Rin=125.;
264 if(sec==5 && mRunNo>=10098029 && mRunNo<=11000000) Rout=140.;
265 if(sec==6 && mRunNo<=11000000 ) Rout=140.;
266 if(sec==20 && mRunNo>=10095120 && mRunNo<=10099078 ) Rout=140.;
273 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
274 mTpcFilterE[isec].setCuts(parE_nFitPts,parE_nHitFrac,RinE,RoutE);
279 if(mMuDstMaker && spinDb)
280 {
char txt[1000],txt0[100];
281 sprintf(txt0,
"bxIdeal%d",nRun);
282 sprintf(txt,
"intended fill pattern R%d-%d vs. bXing; %s", runNo,nRun,spinDb->getV124comment());
284 Tfirst=int(2e9); Tlast=-Tfirst;
285 hbxIdeal=
new TH1F(txt0,txt,128,-0.5,127.5);
286 hbxIdeal->SetFillColor(kYellow);
287 HList->Add(hbxIdeal);
290 for(
int bx=0;bx<120;bx++){
304 LOG_INFO<<endl<<
"Output tree file "<<mTreeName<<endl<<endl;
310 sprintf(txt,
"events T= %d %d",Tfirst,Tlast);
311 printf(
"Finish run=%d , events time range %s\n",mRunNo,txt);
312 hbxIdeal->GetYaxis()->SetTitle(txt);
321 St2011WMaker::FinishRun(
int runNo){
322 LOG_INFO<<Form(
"::FinishRun(%d)",runNo)<<endm;
329 St2011WMaker::Clear(
const Option_t*){
340 wEve->id=mMuDstMaker->
muDst()->
event()->eventId();
341 wEve->runNo=mMuDstMaker->
muDst()->
event()->runId();
342 wEve->time=mMuDstMaker->
muDst()->
event()->eventInfo().time();
343 wEve->zdcRate=mMuDstMaker->
muDst()->
event()->runInfo().zdcCoincidenceRate();
346 if(Tfirst>T) Tfirst=T;
348 hA[13]->Fill(wEve->zdcRate);
351 mJetTreeChain->GetEntry(indexJet++);
353 const char *afile = mMuDstMaker->
GetFile();
355 if(nInpEve%200==1) printf(
"\n-----in---- %s, muDst nEve: inp=%d trig=%d accpt=%d daqFile=%s\n",
GetName(),nInpEve,nTrigEve, nAccEve,afile);
357 hA[0]->Fill(
"inp",1.);
358 hE[0]->Fill(
"inp",1.);
360 int btowStat=accessBTOW();
361 int etowStat=accessETOW();
363 int btrig=accessBarrelTrig();
364 int etrig=accessEndcapTrig();
366 if( btrig && etrig ) {mWtree->Fill();
return kStOK;}
375 if( accessTracks()) {mWtree->Fill();
return kStOK;}
383 if(wEve->l2bitET && wEve->bemc.tileIn[0]==1) hA[0]->Fill(
"B-in",1.0);
384 if(wEve->l2EbitET && wEve->etow.etowIn==1) hE[0]->Fill(
"E-in",1.0);
385 if(wEve->l2bitET && !btowStat) hA[0]->Fill(
"B200",1.0);
386 if(wEve->l2EbitET && !etowStat) hE[0]->Fill(
"E200",1.0);
388 if( btowStat && etowStat )
return kStOK;
392 for (
int i_jet=0; i_jet<mJetEvent->vertex()->numberOfJets(); ++i_jet){
394 float jet_pt = jet->pt();
395 float jet_eta = jet->eta();
396 float jet_phi = jet->phi();
397 hA[117]->Fill(jet_eta,jet_phi);
398 hA[118]->Fill(jet_pt);
405 hA[13]->Fill(wEve->zdcRate);
408 for(
int i=0; i<4800; i++) wEve->bemc.eneTile[0][i]*=par_btowScale;
410 if(nInpEve%200==1) printf(
"\n-----in---- %s, W-Tree nEve: inp=%d \n",
GetName(),nInpEve);
413 hA[0]->Fill(
"inp",1.);
414 hE[0]->Fill(
"inp",1.);
417 if(wEve->l2bitET) hA[0]->Fill(
"L2bwET",1.);
418 if(wEve->l2bitRnd) hA[0]->Fill(
"L2bwRnd",1.);
419 if(wEve->l2EbitET) hE[0]->Fill(
"L2ewET",1.);
420 if(wEve->l2EbitRnd) hE[0]->Fill(
"L2ewRnd",1.);
422 if(!wEve->l2bitET && !wEve->l2EbitET)
return kStOK;
426 int nVerR=0;
int nTrOK=0;
427 for(
unsigned int iv=0;iv<wEve->vertex.size();iv++) {
428 if(wEve->vertex[iv].rank > 0) nVerR++;
429 if(wEve->vertex[iv].eleTrack.size() > 0) nTrOK++;
431 if(wEve->l2bitET && nVerR>0) hA[0]->Fill(
"vertZ",1.);
432 if(wEve->l2EbitET && wEve->vertex.size()>0) hE[0]->Fill(
"vertZ",1.);
433 if(wEve->l2bitET && nTrOK>0) hA[0]->Fill(
"Pt10",1.);
434 if(wEve->l2EbitET && nTrOK>0) hE[0]->Fill(
"Pt10",1.);
436 if(nTrOK<=0)
return kStOK;
439 if(wEve->l2bitET && wEve->bemc.tileIn[0]==1) hA[0]->Fill(
"B-in",1.0);
440 if(wEve->l2EbitET && wEve->etow.etowIn==1) hE[0]->Fill(
"E-in",1.0);
441 if(wEve->l2bitET && wEve->bemc.maxAdc>par_maxADC) hA[0]->Fill(
"B200",1.0);
442 if(wEve->l2EbitET && wEve->etow.maxAdc>par_maxADC) hE[0]->Fill(
"E200",1.0);
444 if(wEve->bemc.maxAdc<par_maxADC && wEve->etow.maxAdc<par_maxADC)
return kStOK;
448 for (
int i_jet=0; i_jet<mJetEvent->vertex()->numberOfJets(); ++i_jet){
450 float jet_pt = jet->pt();
451 float jet_eta = jet->eta();
452 float jet_phi = jet->phi();
453 hA[117]->Fill(jet_eta,jet_phi);
454 hA[118]->Fill(jet_pt);
460 extendTrack2Barrel();
461 int bmatch=matchTrack2BtowCluster();
464 extendTrack2Endcap();
465 int ematch=matchTrack2EtowCluster();
467 if(bmatch && ematch)
return kStOK;
478 if(!bmatch) tag_Z_boson();
487 if(!bmatch) find_W_boson();
488 if(!ematch) findEndcap_W_boson();
489 if(nAccEve<2 ||nAccEve%1000==1 ) wEve->print(0x0,isMC);
498 St2011WMaker::initGeom(){
501 memset(mapBtowIJ2ID,0,
sizeof(mapBtowIJ2ID));
502 for(
int softID=1; softID<=mxBtow; softID++) {
505 mBtowGeom->
getBin(softID,m,e,s);
507 mBtowGeom->getEta(m,e,etaF);
508 mBtowGeom->getPhi(m,s,phiF);
511 assert(L2algoEtaPhi2IJ(etaF,phiF,iEta, iPhi)==0);
512 int IJ=iEta+ iPhi*mxBTetaBin;
513 assert(mapBtowIJ2ID[IJ ]==0);
514 mapBtowIJ2ID[IJ ]=softID;
517 assert( mBtowGeom->getXYZ(softID,x,y,z)==0);
518 positionBtow[softID-1]=TVector3(x,y,z);
522 for(
int iep=0;iep<mxBSmd;iep++) {
523 for(
int softID=1; softID<=mxBStrips; softID++) {
525 assert( mBSmdGeom[iep]->getXYZ(softID,x,y,z)==0);
526 positionBsmd[iep][softID-1]=TVector3(x,y,z);
531 for(
int isec=0;isec<mxEtowSec;isec++){
532 for(
int isub=0;isub<mxEtowSub;isub++){
533 for(
int ieta=0;ieta<mxEtowEta;ieta++){
534 positionEtow[isec*mxEtowSub+isub][ieta]=geomE->
getTowerCenter(isec,isub,ieta);
545 St2011WMaker::L2algoEtaPhi2IJ(
float etaF,
float phiF,
int &iEta,
int &iPhi) {
546 if( phiF<0) phiF+=2*C_PI;
547 if(fabs(etaF)>=0.99)
return -1;
548 int kEta=1+(int)((etaF+1.)/0.05);
549 iPhi=24-(int)( phiF/C_PI*60.);
550 if(iPhi<0) iPhi+=120;
554 if(iEta<0 || iEta>=mxBTetaBin)
return -2;
555 if(iPhi<0 || iPhi>=mxBTphiBin)
return -3;
563 St2011WMaker::getJetEvent(){
568 while(mJetEvent->eventId()!=wEve->id || mJetEvent->runId()!=wEve->runNo) {
569 mJetTreeChain->GetEntry(indexJet++);
572 assert(mJetEvent->eventId()==wEve->id);
573 assert(mJetEvent->runId()==wEve->runNo);
574 assert(mJetEvent_noEEMC->eventId()==wEve->id);
575 assert(mJetEvent_noEEMC->runId()==wEve->runNo);
582 Int_t St2011WMaker::getEvent(Int_t i, Int_t ijet)
584 Int_t stat=mTreeChain->GetEntry(i);
585 Int_t statJet=mJetTreeChain->GetEntry(ijet);
586 if (!stat && !statJet)
return kStEOF;
591 void St2011WMaker::chainFile(
const Char_t *file )
595 cout<<
"Chain W tree files"<<endl;
596 if ( !fname.Contains(
"tree.root") )
return;
597 cout <<
"+ " << fname << endl;
598 mTreeChain->Add(fname);
602 void St2011WMaker::chainJetFile(
const Char_t *file )
606 cout<<
"Chain jet tree files"<<endl;
607 if ( !fname.Contains(
"jets_") )
return;
608 cout <<
"+ " << fname << endl;
609 mJetTreeChain->Add(fname);
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
bool isBXfilledUsingInternalBX(int bx)
defined only for 2005 run by CAD , based on first 4 filled bunches in both rings. Note...
virtual const char * GetFile() const
Returns name of current input or output file, depending on mode (GetFileName does the same...
void loadTables(StMaker *anyMaker)
load tables.
void print(int level=0)
vs. STAR==yellow bXing
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
muDst based extraction of W-signal from pp500 data from 2011
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const