11 #include "StEmcFilter.h"
12 #include "StMcEventTypes.hh"
13 #include "StEventTypes.h"
14 #include "StMcEvent.hh"
18 #include "StTpcDedxPidAlgorithm.h"
19 #include "StEventUtilities/StuRefMult.hh"
20 #include "StEmcUtil/geometry/StEmcGeom.h"
21 #include "StEmcPosition.h"
22 #include "StarClassLibrary/SystemOfUnits.h"
23 #include "StuProbabilityPidAlgorithm.h"
25 #ifndef ST_NO_NAMESPACES
40 mGeo[0] = StEmcGeom::getEmcGeom(
"bemc");
41 mGeo[1] = StEmcGeom::getEmcGeom(
"bprs");
42 mGeo[2] = StEmcGeom::getEmcGeom(
"bsmde");
43 mGeo[3] = StEmcGeom::getEmcGeom(
"bsmdp");
45 mPion=StPionPlus::instance();
46 mProton=StProton::instance();
47 mKaon=StKaonPlus::instance();
48 mElectron=StElectron::instance();
56 mEmcETotalMin=-100000;
70 mMustProjectEmc=kTRUE;
81 mV0TrackProjectOnEmc = kTRUE;
84 mMaxTracksPerTower = 0;
96 mMcMustProjectEmc = kTRUE;
102 mBemcRunningOrig=NULL;
104 mBsmdeRunning = NULL;
105 mBsmdpRunning = NULL;
109 mBemcRunning =
new St_emcStatus(
"bemcStatus",1);
110 emcStatus_st *table=mBemcRunning->GetTable();
111 for(Int_t i=0;i<4800;i++)
113 table[0].Status[i]=0;
114 if(mode==1 && i<2400) table[0].Status[i]=1;
115 if(mode==2) table[0].Status[i]=1;
117 mBemcRunningOrig=mBemcRunning;
126 if(mBemcRunningOrig)
delete mBemcRunningOrig;
130 void StEmcFilter::calcCentrality(
StEvent* event)
134 if(fabs(mBField)>0.4)
136 Int_t cent[] = {14,30,56,94,146,217,312,431,510,1000};
137 for(Int_t i=0;i<10;i++) mCentrality[i] = cent[i];
141 Int_t cent[] = {14,32,59,98,149,216,302,409,474,1000};
142 for(Int_t i=0;i<10;i++) mCentrality[i] = cent[i];
145 Int_t primaries=uncorrectedNumberOfPrimaries(*event);
149 for(Int_t i=0;i<9;i++)
150 if(primaries < mCentrality[i]) { mCentralityBin=i;
return; }
156 if(!event)
return kFALSE;
160 UInt_t trigger =
event->triggerMask();
162 for(UInt_t n = 0;n<mNTriggerMask;n++)
163 if(mTriggerMask[n] == trigger) accept = kTRUE;
164 if(!accept)
return kFALSE;
171 if(!vertex)
return kFALSE;
175 if(fabs(vz)>fabs(mZVertexCut))
177 cout <<
"\nVertex = "<<vz<<endl<<endl;
183 StSPtrVecPrimaryTrack& tracks = vertex->daughters();
184 if(tracks.size()==0)
return kFALSE;
188 calcCentrality(event);
190 Float_t EventMultiplicity = uncorrectedNumberOfNegativePrimaries(*event);
191 if(EventMultiplicity<mMinMult || EventMultiplicity>mMaxMult)
return kFALSE;
196 if(!emc)
return kFALSE;
199 if(emcETotal<mEmcETotalMin || emcETotal>mEmcETotalMax)
return kFALSE;
212 StDetectorId
id =
static_cast<StDetectorId
>(0+kBarrelEmcTowerId);
214 if(!emcDet)
return 0;
215 for(Int_t m=1;m<121;m++)
220 StSPtrVecEmcRawHit& Hits = module->hits();
222 for(Int_t k=0;k<(Int_t)Hits.size();k++)
223 ETotal+=Hits[k]->energy();
231 for(Int_t i=0;i<NTOWER;i++)
243 StDetectorId
id =
static_cast<StDetectorId
>(0+kBarrelEmcTowerId);
246 for(Int_t m=1;m<121;m++)
251 StSPtrVecEmcRawHit& Hits = module->hits();
253 for(Int_t k=0;k<(Int_t)Hits.size();k++)
255 Int_t m = Hits[k]->module();
256 Int_t e = Hits[k]->eta();
257 Int_t s = abs(Hits[k]->sub());
261 mGeo[0]->getId(m,e,s,rid);
262 mETower[rid-1]=Hits[k]->energy();
272 StSPtrVecTrackNode& tracks=
event->trackNodes();
273 ntracks=tracks.size();
277 if(event->l3Trigger())
279 StSPtrVecTrackNode& tracks =
event->l3Trigger()->trackNodes();
280 ntracks=tracks.size();
284 if(ntracks>0)
for (UInt_t i = 0; i < ntracks; i++)
290 StSPtrVecTrackNode& tracks=
event->trackNodes();
291 track=tracks[i]->track(0);
295 StSPtrVecTrackNode& tracks =
event->l3Trigger()->trackNodes();
296 track=tracks[i]->track(0);
301 if (mEmcPosition->
trackOnEmc(&position, &momentum, track, mBField,mGeo[0]->Radius()))
303 Float_t eta=position.pseudoRapidity();
304 Float_t phi=position.phi();
306 mGeo[0]->
getBin(phi,eta,m,e,s);
308 if(m<1 || m>120)
goto NEXT;
309 if(s<1 || s>2 )
goto NEXT;
310 if(e<1 || e>20 )
goto NEXT;
312 mGeo[0]->getId(m,e,s,rid);
314 mNTracksTower[rid-1]++;
315 mPtTower[rid-1]+=track->geometry()->momentum().perp();
325 if(!track)
return kFALSE;
328 if(p.mag()==0)
return kFALSE;
330 if(p.perp()<mPtCut)
return kFALSE;
331 if(p.perp()>mPtCutMax)
return kFALSE;
333 if(p.pseudoRapidity()<mEtaMin || p.pseudoRapidity()>mEtaMax)
return kFALSE;
334 if(track->fitTraits().numberOfFitPoints()<mFitPointsCut)
return kFALSE;
335 if(track->impactParameter()>mDCACut)
return kFALSE;
340 if (!mEmcPosition->
trackOnEmc(&position, &momentum, track, mBField,mGeo[0]->Radius()))
return kFALSE;
343 Float_t eta=position.pseudoRapidity();
344 Float_t phi=position.phi();
346 mGeo[0]->
getBin(phi,eta,m,e,s);
348 if(m<1 || m>120)
return kFALSE;
349 if(s<1 || s>2 )
return kFALSE;
350 if(e<1 || e>20 )
return kFALSE;
352 mGeo[0]->getId(m,e,s,
id);
362 if(!event)
return kFALSE;
365 if(!vertex)
return kFALSE;
368 if(fabs(position.z())>mZVertexCut)
return kFALSE;
375 if(!vertex)
return kFALSE;
377 if(p.perp()<mV0Pt)
return kFALSE;
378 if(!mV0TrackProjectOnEmc)
return kTRUE;
380 UInt_t nd = vertex->numberOfDaughters();
381 if(nd==0)
return kFALSE;
383 for(UInt_t i=0;i<nd;i++)
389 if (mEmcPosition->
trackOnEmc(&position, &momentum, track, mBField,mGeo[0]->Radius()))
392 Float_t eta=position.pseudoRapidity();
393 Float_t phi=position.phi();
395 mGeo[0]->
getBin(phi,eta,m,e,s);
397 if(m>=1 && m<=120)
if(s>=1 && s<=2 )
if(e>=1 && e<=20 )
400 mGeo[0]->getId(m,e,s,
id);
411 if(!track)
return kFALSE;
415 Int_t geantId = (Int_t)track->geantId();
416 if(geantId<8 || geantId>32)
return kFALSE;
419 if(mMcChargeType != kALL)
421 Int_t charge = (Int_t)track->particleDefinition()->charge();
424 if(charge!=0) signal = charge/abs(charge);
426 if(signal == 0 && mMcChargeType != kNEUTRAL)
return kFALSE;
427 if(signal == -1 && (mMcChargeType != kCHARGED && mMcChargeType != kNEGATIVE))
return kFALSE;
428 if(signal == +1 && (mMcChargeType != kCHARGED && mMcChargeType != kPOSITIVE))
return kFALSE;
432 if(p.mag()==0)
return kFALSE;
433 if(p.perp()<mMcPtCut)
return kFALSE;
434 if(p.pseudoRapidity()<mMcEtaMin || p.pseudoRapidity()>mMcEtaMax)
return kFALSE;
436 if(mMcMustProjectEmc)
443 Float_t stopRadius = ::sqrt(po.x()*po.x()+po.y()*po.y());
444 if(stopRadius<mGeo[0]->Radius())
return kFALSE;
448 if (!mEmcPosition->
trackOnEmc(&position, &momentum, track, mBField,mGeo[0]->Radius()))
return kFALSE;
451 Float_t eta=position.pseudoRapidity();
452 Float_t phi=position.phi();
454 mGeo[0]->
getBin(phi,eta,m,e,s);
456 if(m<1 || m>120)
return kFALSE;
457 if(s<1 || s>2 )
return kFALSE;
458 if(e<1 || e>20 )
return kFALSE;
460 mGeo[0]->getId(m,e,s,
id);
468 if(rid<1 || rid>4800)
return kFALSE;
470 if(mNTracksTower[rid-1]>mMaxTracksPerTower)
return kFALSE;
471 if(mETower[rid-1]<mEMin || mETower[rid-1]>mEMax)
return kFALSE;
472 if(mPtTower[rid-1]<mPtMin || mPtTower[rid-1]>mPtMax)
return kFALSE;
474 if(mTNeighbor) { size = 3;
goto DOIT;}
475 if(mSNeighbor) { size = 2;
goto DOIT;}
476 if(mPNeighbor) size = 1;
478 if(size==0)
return kTRUE;
480 mGeo[0]->getEtaPhi(rid,eta,phi);
481 for(Int_t i = -size; i<= size; i++)
482 for(Int_t j = -size; j<= size; j++)
488 if(mNTracksTower[rid1-1]>0)
return kFALSE;
497 mGeo[0]->getId(m,e,s,rid);
503 if(rid<1 || rid>4800)
return 0;
504 return mNTracksTower[rid-1];
510 mGeo[0]->getId(m,e,s,rid);
516 if(rid<1 || rid>4800)
return 0;
517 return mPtTower[rid-1];
523 mGeo[0]->getId(m,e,s,rid);
538 return getTrackId(track,npt,dEdX,mass,
id,order,nSigma);
558 if(!track)
return kFALSE;
559 if(!track->geometry())
return kFALSE;
560 Int_t charge=track->geometry()->charge();
563 Double_t momentum = fabs(track->geometry()->momentum().mag());
564 if(momentum==0)
return kFALSE;
565 StPtrVecTrackPidTraits traits = track->pidTraits(kTpcId);
566 UInt_t size = traits.size();
567 if(size==0)
return kFALSE;
570 m[0] = mPion->mass();
571 m[1] = mProton->mass();
572 m[2] = mKaon->mass();
573 m[3] = mElectron->mass();
574 Int_t kk[4]={0,0,0,1};
579 for (UInt_t i = 0; i < traits.size(); i++)
582 if (pid)
if(pid->method() == kTruncatedMeanId)
break;
584 if(!pid)
return kFALSE;
586 dEdX = (Float_t)pid->mean();
587 if(dEdX==0)
return kFALSE;
588 Double_t npt = (Double_t)pid->numberOfPoints();
590 if(nPoints==0)
return kFALSE;
591 Double_t dedx_expected;
592 Double_t dedx_resolution = (Double_t)pid->errorOnMean();
593 if(dedx_resolution<=0) dedx_resolution=npt > 0 ? 0.45/::sqrt(npt) : 1000.;
595 Float_t nSigma[4],nSigmaTmp[4];
596 Float_t length = (Float_t)pid->length();
597 if(length<=0) length = 60.;
598 for(Int_t i=0;i<4;i++)
601 dedx_expected = 1.0e-6*mBB.Sirrf(momentum/m[i],length,kk[i])*mdEdXScale;
602 z = ::log((Double_t)dEdX/dedx_expected);
603 nSigmaTmp[i]=(Float_t) z/dedx_resolution;
604 nSigma[i]=fabs(nSigmaTmp[i]) ;
607 Float_t SigmaOrder[4];
609 for(Int_t i=0;i<4;i++)
611 SigmaOrder[i]=999999;
613 for(Int_t k=0;k<4;k++)
615 if(nSigma[k]<SigmaOrder[i]) {SigmaOrder[i]=nSigma[k]; nSigmaFinal[i]=nSigmaTmp[k]; type[i]=k;}
617 nSigma[type[i]]=9999;
620 for(Int_t i=0;i<4;i++)
622 if(type[i]==0 && charge>0) idOrder[i] = 8;
623 if(type[i]==0 && charge<0) idOrder[i] = 9;
624 if(type[i]==1 && charge>0) idOrder[i] = 14;
625 if(type[i]==1 && charge<0) idOrder[i] = 15;
626 if(type[i]==2 && charge>0) idOrder[i] = 11;
627 if(type[i]==2 && charge<0) idOrder[i] = 12;
628 if(type[i]==3 && charge>0) idOrder[i] = 2;
629 if(type[i]==3 && charge<0) idOrder[i] = 3;
632 if(momentum>mdEdXPMax)
return kFALSE;
633 if(npt<mPointsdEdX)
return kFALSE;
634 if(dEdX<mdEdXCut)
return kFALSE;
636 if(SigmaOrder[0]<=mdEdXNSigma)
638 if(type[0]==0 && charge>0) {mass=mPion->mass();
id = 8;
return kTRUE;}
639 if(type[0]==0 && charge<0) {mass=mPion->mass();
id = 9;
return kTRUE;}
641 if(type[0]==1 && charge>0) {mass=mProton->mass();
id = 14;
return kTRUE;}
642 if(type[0]==1 && charge<0) {mass=mProton->mass();
id = 15;
return kTRUE;}
644 if(type[0]==2 && charge>0) {mass=mKaon->mass();
id = 11;
return kTRUE;}
645 if(type[0]==2 && charge<0) {mass=mKaon->mass();
id = 12;
return kTRUE;}
647 if(type[0]==3 && charge>0) {mass=mElectron->mass();
id = 2;
return kTRUE;}
648 if(type[0]==3 && charge<0) {mass=mElectron->mass();
id = 3;
return kTRUE;}
669 emcStatus_st *st=mBemcRunning->GetTable();
670 if(id<1 || id >4800)
return kBAD;
673 Int_t status = (Int_t) st[0].Status[
id-1];
674 if(status == 1)
return kGOOD;
else return kBAD;
680 if ((
id >= 1 &&
id <= 340) || (
id >= 1861 &&
id <= 2340) )
return kGOOD;
687 emcStatus_st *st=mBprsRunning->GetTable();
688 if(id<1 || id >4800)
return kBAD;
691 Int_t status = (Int_t) st[0].Status[
id-1];
692 if(status == 1)
return kGOOD;
else return kBAD;
701 smdStatus_st *st=mBsmdeRunning->GetTable();
702 if(id<1 || id >18000)
return kBAD;
705 Int_t status = (Int_t) st[0].Status[
id-1];
706 if(status == 1)
return kGOOD;
else return kBAD;
715 smdStatus_st *st=mBsmdpRunning->GetTable();
716 if(id<1 || id >18000)
return kBAD;
719 Int_t status = (Int_t) st[0].Status[
id-1];
720 if(status == 1)
return kGOOD;
else return kBAD;
737 if(det<1 || det>4)
return 0.;
740 Float_t TotalTowers=60*mGeo[det-1]->NSub();
742 if(etabin<1 || etabin>mGeo[det-1]->NEta())
return 0.;
745 if(side==1) {mi=61; mf=120;}
747 for(Int_t m=mi;m<=mf;m++)
748 for(Int_t s=1;s<=mGeo[det-1]->NSub();s++)
751 mGeo[det-1]->getId(m,etabin,s,
id);
755 return ntowers/TotalTowers;
763 if(det<1 || det>4)
return 0.;
764 Int_t nEta = mGeo[det-1]->NEta();
767 for(Int_t i=1;i<=nEta;i++)
771 return phiFr/(Float_t)nEta;
779 if(det<1 || det>4)
return 0.;
780 Int_t nEta = mGeo[det-1]->NEta();
783 for(Int_t i=1;i<=nEta;i++)
787 return phiFr/(Float_t)nEta;
795 if(det<1 || det>4)
return 0.;
799 return (WPhiFr+EPhiFr)/2.;
804 TString TF[]={
"kFALSE",
"kTRUE"};
805 TString CH[]={
"kNEGATIVE",
"kNEUTRAL",
"kPOSITIVE",
"kCHARGED",
"kALL"};
806 cout <<
"EMC Filter ---------------------------------------------------\n\n";
807 cout <<
" 1. Event Cuts \n";
808 cout <<
" EmcPresent = "<<TF[(Int_t)mEmcPresent].Data()<<endl;
809 cout <<
" HaveVertex = "<<TF[(Int_t)mHaveVertex].Data()<<endl;
810 cout <<
" HavePrimaries = "<<TF[(Int_t)mHavePrimaries].Data()<<endl;
811 cout <<
" ZVertexCut = "<<mZVertexCut<<
" cm\n";
812 cout <<
" EmcETotalMin = "<<mEmcETotalMin<<
" GeV\n";
813 cout <<
" EmcETotalMax = "<<mEmcETotalMax<<
" GeV\n";
814 cout <<
" MinMult = "<<mMinMult<<endl;
815 cout <<
" MaxMult = "<<mMaxMult<<endl;
816 cout <<
" BField = "<<mBField<<
" Tesla \n";
818 cout <<
" 2. Tracks cuts\n";
819 cout <<
" DCACut = "<<mDCACut<<
" cm\n";
820 cout <<
" PtCut = "<<mPtCut<<
" GeV/c\n";
821 cout <<
" EtaMin = "<<mEtaMin<<endl;
822 cout <<
" EtaMax = "<<mEtaMax<<endl;
823 cout <<
" FitPointsCut = "<<mFitPointsCut<<endl;
824 cout <<
" MusProjectEmc = "<<TF[(Int_t)mMustProjectEmc].Data()<<endl;
826 cout <<
" 3. dE/dX cuts for StTrack Id\n";
827 cout <<
" dEdXScale = "<<mdEdXScale<<endl;
828 cout <<
" PointsdEdX = "<<mPointsdEdX<<endl;
829 cout <<
" dEdXPMax = "<<mdEdXPMax<<
" GeV/c\n";
830 cout <<
" dEdXCut = "<<mdEdXCut<<
" GeV/cm\n";
831 cout <<
" dEdXNSigma = "<<mdEdXNSigma<<endl;
833 cout <<
" 4. MC Tracks cuts\n";
834 cout <<
" OnlyHadrons = "<<TF[(Int_t)mOnlyHadrons].Data()<<endl;
835 cout <<
" McChargeType = "<<CH[(Int_t)mMcChargeType+1].Data()<<endl;
836 cout <<
" McMustProjectEmc = "<<TF[(Int_t)mMcMustProjectEmc].Data()<<endl;
837 cout <<
" McEtaMin = "<<mMcEtaMin<<endl;
838 cout <<
" McEtaMac = "<<mMcEtaMax<<endl;
839 cout <<
"--------------------------------------------------------------\n";
Bool_t trackOnEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StTrack *const track, Double_t magField, Double_t emcRadius=225.405) const
Track projection utility.
EmcStatus getEmcStatus(Int_t, Int_t)
Return EMC status (kGOOD, kBAD, kOTHER) for a given detector and bin.
Float_t getFraction(Int_t, Int_t, Int_t=0)
Return fraction of EMC live on a given detector and eta bin.
void printCuts()
Print filter parameters.
Float_t getEmcETotal(StEvent *)
Return total energy on EMC.
Int_t getNTracksTower(Int_t)
Returns number of tracks pointing to the tower with given id.
void initEmcTowers(StEvent *, Int_t=0)
Use this function before using accept(), getNTracksTower() and getPtTower() methods for towers...
~StEmcFilter()
StEmcFilter destructor.
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Int_t getNextTowerId(Float_t eta, Float_t phi, Int_t nTowersdEta, Int_t nTowersdPhi) const
Return neighbor tower id's.
Bool_t accept(StEvent *)
Returns kTRUE/kFALSE if StEvent is accepted.
Bool_t getTrackId(StTrack *, Float_t &, Int_t &)
Return track id based on dE/dX.
Float_t getEastFraction(Int_t=1)
Return fraction of EMC live on east side of STAR.
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
Float_t getPtTower(Int_t)
Returns the total pt from projected tracks in tower with id.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
Float_t getWestFraction(Int_t=1)
Return fraction of EMC live on west side of STAR.
Float_t getTotalFraction(Int_t=1)
Return fraction of EMC live on STAR.