11 void checkStRefMultCorrOO(
const char *inFileName,
12 const char *oFileName =
"oTest.root") {
13 const bool bUseRefMult6 =
false;
14 gROOT->LoadMacro(
"$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
15 loadSharedLibraries();
16 gSystem->Load(
"StPicoEvent");
17 gSystem->Load(
"StRefMultCorr");
19 std::cout <<
"Hi! Lets do some physics, Master!" << std::endl;
27 std::cout <<
"Explicit read status for some branches" << std::endl;
33 std::cout <<
"Status has been set" << std::endl;
35 std::cout <<
"Now I know what to read, Master!" << std::endl;
37 if( !picoReader->
chain() ) {
38 std::cout <<
"No chain has been found." << std::endl;
39 std::cout <<
"Terminating..." << std::endl;
42 Long64_t eventsInTree = picoReader->
tree()->GetEntries();
43 std::cout <<
"eventsInTree: " << eventsInTree << std::endl;
44 Long64_t events2read = picoReader->
chain()->GetEntries();
46 std::cout <<
"Number of events to read: " << events2read << std::endl;
50 TH1F *hRefMult =
new TH1F(Form(
"h%s",(bUseRefMult6)?
"RefMult6":
"TotnMIP"), Form(
"Reference multiplicity;%s",(bUseRefMult6)?
"refMult6":
"totnMIP"), 1000, -0.5, 999.5);
51 TH2F *hTofMatchVsRefMult6BeforeCut =
new TH2F(
"hTofMatchVsRefMult6BeforeCut",
";bTofMatched;refMult6",
52 500, -0.5, 499.5, 500, -0.5, 499.5);
53 TH2F *hTofMatchVsRefMult6AfterCut =
new TH2F(
"hTofMatchVsRefMult6AfterCut",
";bTofMatched;refMult6",
54 500, -0.5, 499.5, 500, -0.5, 499.5);
55 TH2F *hTofMatchVsTotnMIPBeforeCut =
new TH2F(
"hTofMatchVsTotnMIPBeforeCut",
";bTofMatched;totnMIP",
56 500, -0.5, 499.5, 1000, -0.5, 999.5);
57 TH2F *hTofMatchVsTotnMIPAfterCut =
new TH2F(
"hTofMatchVsTotnMIPAfterCut",
";bTofMatched;totnMIP",
58 500, -0.5, 499.5, 1000, -0.5, 999.5);
59 TH2F *hWeightVsRefMultCorr =
new TH2F(Form(
"hWeightVs%sCorr",(bUseRefMult6)?
"RefMult6":
"TotnMIP"),Form(
";%s;weight",(bUseRefMult6)?
"refMult6":
"totnMIP"),
60 1000, -0.5, 999.5, 125, 0.5, 3.);
61 TH1F *hRefMultCorr =
new TH1F(Form(
"h%sCorr",(bUseRefMult6)?
"RefMult6":
"TotnMIP"), Form(
"Corrected reference multiplicity;%s",(bUseRefMult6)?
"refMult6":
"totnMIP"), 1000, -0.5, 999.5);
62 TH1F *hCent16 =
new TH1F(
"hCent16",
"Centrality bins;Centrality bin", 16, -0.5, 15.5);
63 TH2F *hVtxXvsY =
new TH2F(
"hVtxXvsY",
"hVtxXvsY", 200,-10.,10.,200,-10.,10.);
64 TH1F *hVtxZ =
new TH1F(
"hVtxZ",
"hVtxZ", 210, -210., 210.);
69 if (bUseRefMult6) mRefMultCorrUtil =
new StRefMultCorr(
"refmult6");
74 Int_t loopSize = 1000;
75 Bool_t verbose = kTRUE;
78 for(Long64_t iEvent=0; iEvent<events2read; iEvent++) {
81 if ( counter >= loopSize ) {
82 std::cout <<
"Working on event #[" << (iEvent+1) <<
"/" << events2read <<
"]" << std::endl;
89 std::cout <<
"No input was provided" << std::endl;
99 std::cout <<
"No event was found" << std::endl;
105 if (fabs(pVtx.Z()) > 30.)
continue;
106 if (sqrt(pow(pVtx.X(),2.)+pow(pVtx.Y(),2.)) > 2.)
continue;
107 Int_t runId =
event->runId();
108 mRefMultCorrUtil->
init(runId);
111 std::cout <<
"Checking bad run";
114 if ( mRefMultCorrUtil->
isBadRun( runId ) ) {
116 std::cout <<
"\t[failed]" << std::endl;
121 std::cout <<
"\t[passed]" << std::endl;
125 std::cout <<
"Checking MB triggers";
129 if ( !event->isTrigger(860001) && !
event->isTrigger(860002)) {
131 std::cout <<
"\t[failed]" << std::endl;
136 std::cout <<
"\t[passed]" << std::endl;
143 if ( !track )
continue;
145 if ( TMath::Abs( track->
pMom().Eta() ) > 1.5 )
continue;
146 if ( track->
pPt() >= 2.0 )
continue;
147 if ( track->
pPt() <= 0.2 )
continue;
148 if ( track->
gDCA(event->primaryVertex()).Mag() >= 3. )
continue;
149 if ( track->
nHitsFit() <= 15 )
continue;
153 Double_t totnMIP = 0.;
155 for(Int_t iHit=0; iHit<nEpdHits; iHit++) {
157 if( !epdHit )
continue;
158 if (epdHit->
nMIP() > 6.) totnMIP += 6.;
159 else if (epdHit->
nMIP() < 0.3)
continue;
160 else totnMIP += epdHit->
nMIP();
163 Int_t nBTofMatched =
event->nBTOFMatch();
164 hTofMatchVsRefMult6BeforeCut->Fill( nBTofMatched, refMult6 );
165 hTofMatchVsTotnMIPBeforeCut->Fill( nBTofMatched, totnMIP );
168 if (mRefMultCorrUtil->
isPileUpEvent( refMult6, nBTofMatched, pVtx.Z(), totnMIP ) )
continue;
170 if (bUseRefMult6) mRefMultCorrUtil->initEvent(refMult6, pVtx.Z());
171 else mRefMultCorrUtil->initEvent(totnMIP, pVtx.Z());
177 std::cout <<
"\tBad centrality < 0" << std::endl;
185 Double_t weight = mRefMultCorrUtil->
getWeight();
188 std::cout <<
"refMult: " << Form(
"%d",(bUseRefMult6) ? refMult6 : totnMIP) <<
" refMultCorr: " << refMultCorr
189 <<
" cent16: " << cent16 <<
" cent9: " << cent9
190 <<
" Total weight: " << weight <<
" trigger efficiency: "
192 <<
" z: " << pVtx.Z()
197 hRefMult->Fill( (bUseRefMult6) ? refMult6 : totnMIP );
198 hRefMultCorr->Fill( refMultCorr );
199 hCent16->Fill( cent16 );
200 hVtxXvsY->Fill( pVtx.X(), pVtx.Y() );
201 hVtxZ->Fill( pVtx.Z() );
202 hTofMatchVsRefMult6AfterCut->Fill( nBTofMatched, refMult6 );
203 hTofMatchVsTotnMIPAfterCut->Fill( nBTofMatched, totnMIP );
204 hWeightVsRefMultCorr->Fill(refMultCorr, weight);
209 TFile *oFile =
new TFile(oFileName,
"recreate");
211 hRefMultCorr->Write();
212 hWeightVsRefMultCorr->Write();
216 hTofMatchVsRefMult6BeforeCut->Write();
217 hTofMatchVsRefMult6AfterCut->Write();
218 hTofMatchVsTotnMIPBeforeCut->Write();
219 hTofMatchVsTotnMIPAfterCut->Write();
223 std::cout <<
"Analysis was finished" << std::endl;
Bool_t isPrimary() const
Return if track is primary.
Bool_t readPicoEvent(Long64_t iEvent)
Read next event in the chain.
Allows to read picoDst file(s)
Int_t getCentralityBin9() const
Get 9 centrality bins (10% increment except for 0-5 and 5-10)
Double_t getShapeWeight_SubVz2Center() const
Shape reweighting of refmult: ratio of refMult in each Vz bin to that in the center (|Vz|<10cm) ...
Float_t pPt() const
Return transverse momentum (GeV/c) of the primary track.
Int_t getCentralityBin16() const
Get 16 centrality bins (5% increment, 0-5, 5-10, ..., 75-80)
TChain * chain()
Return pointer to the chain of .picoDst.root files.
Int_t nHitsPoss() const
Return number of hits possible.
StPicoDst * picoDst()
Return a pointer to picoDst (return NULL if no dst is found)
static StPicoEpdHit * epdHit(Int_t i)
Return pointer to i-th epd hit.
Double_t getRefMultCorr() const
Get corrected multiplicity, correction as a function of primary z-vertex.
static StPicoEvent * event()
Return pointer to current StPicoEvent (class holding the event wise information)
Double_t getWeight() const
Total weighting factor: incorporates shape and trigger efficiency weights.
void SetStatus(const Char_t *branchNameRegex, Int_t enable)
Set enable/disable branch matching when reading picoDst.
Holds information about track parameters.
Double_t triggerWeight() const
Trigger efficiency: fit of the Glauber/Data.
static UInt_t numberOfEpdHits()
Return number of EPD hits.
static UInt_t numberOfTracks()
Return number of tracks.
Main class that keeps TClonesArrays with main classes.
TVector3 pMom() const
Return momentum (GeV/c) of the primary track. Return (0,0,0) if not primary track.
Bool_t isBadRun(const Int_t RunId)
Check if run is bad.
void Init()
Calls openRead()
static StPicoTrack * track(Int_t i)
Return pointer to i-th track.
TTree * tree()
Return pointer to the current TTree.
Int_t nHitsFit() const
Return number of hits fit.
Float_t gDCA(Float_t pVtxX, Float_t pVtxY, Float_t pVtxZ) const
Return distance in xyz direction (cm) between the (x,y,z) point and the DCA point to primary vertex...
Stores global information about the event.
Bool_t isPileUpEvent(Double_t refmult, Double_t ntofmatch, Double_t vz=0., Double_t totnMIP=-999.) const
Check if pile-up event.
void Finish()
Close files and finilize.
void setVerbose(const Bool_t &verbose)
Print debug information.
TVector3 primaryVertex() const
Return primary vertex position.
void init(const Int_t RunId)
Initialization of centrality bins etc.