Skip to content

Commit fc257b8

Browse files
meiALICEYuanjun Mei
andauthored
[PWGCF] Add separated event-level cuts and improve getHistogramWithWeights (#18246)
Co-authored-by: Yuanjun Mei <yuanjun.mei@cern.ch>
1 parent 40f656f commit fc257b8

1 file changed

Lines changed: 55 additions & 86 deletions

File tree

‎PWGCF/MultiparticleCorrelations/Tasks/multiparticleCorrelationsMei.cxx‎

Lines changed: 55 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
203203
Configurable<std::string> cfFileWithWeights{"cfFileWithWeights", "/alice-ccdb.cern.ch/Users/m/mei/thesis-", "path to external ROOT file which holds all particle weights"};
204204

205205
// *) Binnings
206-
Configurable<bool> cfALICECentBinSwitch{"cfALICECentBinSwitch", true, "switch on or off to use ALICE default binning"};
206+
Configurable<bool> cfALICECentBinSwitch{"cfALICECentBinSwitch", false, "switch on or off to use ALICE default binning for centrality hist"};
207207
Configurable<std::vector<float>> cfCentBins{"cfCentBins", {100, 0., 100.}, "Centrality bins: nCentBins, centMin, centMax"};
208-
Configurable<std::vector<float>> cfMultBins{"cfMultBins", {400, 0., 30000.}, "Multiplicity bins: nMultBins, multMin, multMax"};
208+
Configurable<std::vector<float>> cfMultBins{"cfMultBins", {400, 0., 25000.}, "Multiplicity bins: nMultBins, multMin, multMax"};
209209
Configurable<std::vector<float>> cfMultBinsRef{"cfMultBinsRef", {400, 0., 25000.}, "Reference mult bins: nMultBins, multMin, multMax"};
210210
Configurable<std::vector<float>> cfContribBins{"cfContribBins", {400, 0., 7000.}, "Number of contributors bins: nBinsContrib, contribMin, contribMax"};
211211
Configurable<std::vector<float>> cfVxBins{"cfVxBins", {500, -0.04, 0.04}, "Vertex X hist: nVxBins, vxMin, vxMax"};
@@ -223,9 +223,12 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
223223
Configurable<std::vector<std::string>> cfTechnicalCutSwitch{"cfTechnicalCutSwitch", {"1NoCollInTimeRangeStandard", "1NoCollInRofStandard", "1NoSameBunchPileUp", "1IsVertexITSTPC", "1IsGoodITSLayersAll", "1IsGoodZvtxFT0vsPV", "1NoHighMultCollInPrevRof"}, "technical cuts switch, on and off by the first number before name"};
224224

225225
// event level cuts
226-
Configurable<bool> cfEventCutSwitch{"cfEventCutSwitch", true, "switch to apply event level cut"};
226+
Configurable<bool> cfSel8CutSwitch{"cfSel8CutSwitch", true, "switch to apply Sel8 cut"};
227+
Configurable<bool> cfVertexZCutSwitch{"cfVertexZCutSwitch", true, "switch to apply VertexZ cut"};
227228
Configurable<std::vector<float>> cfVertexZCutRange{"cfVertexZCutRange", {-10., 10.}, "vertex z position range: {min, max}[cm], with convention: min <= Vz <= max"};
229+
Configurable<bool> cfCentCutSwitch{"cfCentCutSwitch", true, "switch to apply centrality cut"};
228230
Configurable<std::vector<float>> cfCentCutRange{"cfCentCutRange", {0., 80.}, "centrality range: {min, max}[cm], with convention: min <= cent <= max"};
231+
Configurable<bool> cfNContribCutSwitch{"cfNContribCutSwitch", true, "switch to apply NContrib cut"};
229232
Configurable<int> cfNContribCutInf{"cfNContribCutInf", 2, "Cuts on number of tracks used for the vertex, only numContrib > cfNContribCutInf survives"};
230233

231234
// particle level cuts
@@ -263,7 +266,10 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
263266
bool fALICECentBinSwitch = true;
264267

265268
bool fMasterCutSwitch = true;
266-
bool fEventCutSwitch = true;
269+
bool fSel8CutSwitch = true;
270+
bool fVertexZCutSwitch = true;
271+
bool fCentCutSwitch = true;
272+
bool fNContribCutSwitch = true;
267273
bool fPtCutSwitch = true;
268274
bool fEtaCutSwitch = true;
269275
bool fChargeCutSwitch = true;
@@ -455,7 +461,6 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
455461
bool bFileIsInCCDB = false;
456462

457463
std::string path(filePath);
458-
459464
if (path.starts_with("/alice/cern.ch/")) {
460465
bFileIsInAliEn = true;
461466
} else if (path.starts_with("/alice-ccdb.cern.ch/")) {
@@ -476,49 +481,20 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
476481
if (!baseList) {
477482
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
478483
}
479-
480-
// Finally, from the top-level TList, get the desired nested TList => the technical problem here is that it can be nested at any level, for that there is a helper utility function getObjectFromList(...) , see its implementation further below
481-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
482-
if (!listWithRuns) {
483-
TString runNumberWithLeadingZeroes = "000";
484-
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
485-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
486-
if (!listWithRuns) {
487-
LOGF(error, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
488-
return;
489-
}
490-
}
491-
492-
// OK, we got the desired TList with efficiency corrections, after that we can use the common code for all 3 cases (local, AliEn, CCDB, that common code is below)
493484
} else if (bFileIsInCCDB) {
494-
// File you want to access is in your home dir in CCDB:
495-
// Remember that here I do not access the file; instead, I directly access the object in that file.
485+
// File you want to access is in your home dir in CCDB: Remember that here I do not access the file; instead, I directly access the object in that file.
496486
ccdb->setURL("https://alice-ccdb.cern.ch");
497487
baseList = dynamic_cast<TList*>(ccdb->get<TList>(TString(filePath).ReplaceAll("/alice-ccdb.cern.ch/", "").Data()));
498488
if (!baseList) {
499489
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
500490
}
501-
502-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
503-
if (!listWithRuns) {
504-
TString runNumberWithLeadingZeroes = "000";
505-
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
506-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
507-
if (!listWithRuns) {
508-
LOGF(error, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
509-
return;
510-
}
511-
}
512-
513-
// OK, we got the desired TList with efficiency corrections, after that we can use the common code for all 3 cases (local, AliEn, CCDB, that common code is below)
514491
} else {
515492
// this is the local case:
516493
// Check if the external ROOT file exists at the specified path:
517494
if (gSystem->AccessPathName(filePath, kFileExists)) {
518495
LOGF(info, "\033[1;33m if(gSystem->AccessPathName(filePath,kFileExists)), filePath = %s \033[0m", filePath);
519496
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
520497
}
521-
522498
TFile* weightsFile = TFile::Open(filePath, "READ");
523499
if (!weightsFile) {
524500
LOGF(fatal, "\033[1;31m%s at line %d\033[0m can't open file", __FUNCTION__, __LINE__);
@@ -527,23 +503,18 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
527503
if (!baseList) {
528504
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
529505
}
530-
531-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
532-
if (!listWithRuns) {
533-
TString runNumberWithLeadingZeroes = "000";
534-
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
535-
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
536-
if (!listWithRuns) {
537-
LOGF(error, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, runNumber);
538-
return;
539-
}
540-
}
541506
}
542507

543508
// Here comes the common code for all three cases, where from "listWithRuns" you fetch the desired histogram with efficiency corrections:
509+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
544510
if (!listWithRuns) {
545-
LOGF(fatal, "\033[1;31m%s: listWithRuns is null for run %s\033[0m", __FUNCTION__, runNumber);
546-
return;
511+
TString runNumberWithLeadingZeroes = "000";
512+
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
513+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
514+
if (!listWithRuns) {
515+
LOGF(warning, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, runNumber);
516+
return;
517+
}
547518
}
548519

549520
for (int i = 0; i < eWeightsHistograms_N; ++i) {
@@ -563,7 +534,8 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
563534
}
564535

565536
delete baseList;
566-
} // end of TH1F* getHistogramWithWeights(const char* filePath, const char* runNumber, const char* histName)
537+
baseList = nullptr;
538+
} // end of void getHistogramWithWeights(const char* filePath, const char* runNumber)
567539

568540
// templates
569541
template <typename T1>
@@ -640,32 +612,30 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
640612
}
641613
}
642614
if constexpr (rs == eRec || rs == eRecAndSim) {
643-
if (tc.fEventCutSwitch) { // event level cuts for Rec
644-
if constexpr (rm == eReal) {
645-
if (!collision.sel8()) { // sel8 cut
646-
return false;
647-
}
648-
if (collision.posZ() > tc.fVertexZCutRange[1] || collision.posZ() < tc.fVertexZCutRange[0]) { // vertex z cut
649-
return false;
650-
}
651-
auto thisCent = chooseCent(collision, tc.fCentralityEstimator);
652-
if (thisCent > tc.fCentCutRange[1] || thisCent < tc.fCentCutRange[0]) { // centrality cut
653-
return false;
654-
}
655-
if (collision.numContrib() < tc.fNContribCutInf) { // number of contribution cuts
656-
return false;
657-
}
615+
if (tc.fSel8CutSwitch && !collision.sel8()) { // sel8 cut
616+
return false;
617+
}
618+
if constexpr (rm == eReal) {
619+
if (tc.fVertexZCutSwitch && (collision.posZ() > tc.fVertexZCutRange[1] || collision.posZ() < tc.fVertexZCutRange[0])) { // vertex z cut
620+
return false;
658621
}
659-
if constexpr (rs == eRecAndSim && rm == eMC) { // event level cuts for Sim
660-
auto thisMCCollision = collision.mcCollision();
661-
auto impactParameter = thisMCCollision.impactParameter();
662-
auto centralityMC = math::PI * impactParameter * impactParameter / tc.fSigmaInel;
663-
if (thisMCCollision.posZ() > tc.fVertexZCutRange[1] || thisMCCollision.posZ() < tc.fVertexZCutRange[0]) { // vertex z cut
664-
return false;
665-
}
666-
if (centralityMC > tc.fCentCutRange[1] || centralityMC < tc.fCentCutRange[0]) { // centrality cut
667-
return false;
668-
}
622+
auto thisCent = chooseCent(collision, tc.fCentralityEstimator);
623+
if (tc.fCentCutSwitch && (thisCent > tc.fCentCutRange[1] || thisCent < tc.fCentCutRange[0])) { // centrality cut
624+
return false;
625+
}
626+
if (tc.fNContribCutSwitch && (collision.numContrib() < tc.fNContribCutInf)) { // number of contribution cuts
627+
return false;
628+
}
629+
}
630+
if constexpr (rs == eRecAndSim && rm == eMC) { // event level cuts for Sim
631+
auto thisMCCollision = collision.mcCollision();
632+
auto impactParameter = thisMCCollision.impactParameter();
633+
auto centralityMC = math::PI * impactParameter * impactParameter / tc.fSigmaInel;
634+
if (thisMCCollision.posZ() > tc.fVertexZCutRange[1] || thisMCCollision.posZ() < tc.fVertexZCutRange[0]) { // vertex z cut
635+
return false;
636+
}
637+
if (centralityMC > tc.fCentCutRange[1] || centralityMC < tc.fCentCutRange[0]) { // centrality cut
638+
return false;
669639
}
670640
}
671641
}
@@ -717,7 +687,6 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
717687
ec.fEventHist[eHistVertexY][eSim][eBefore]->Fill(thisMCCollision.posY());
718688
ec.fEventHist[eHistVertexZ][eSim][eBefore]->Fill(thisMCCollision.posZ());
719689
}
720-
721690
if constexpr (cuts == eAfter) {
722691
ec.fEventHist[eHistMultiplicity][eSim][eAfter]->Fill(multiplicitySim);
723692
ec.fEventHist[eHistCentrality][eSim][eAfter]->Fill(centralityMC);
@@ -726,7 +695,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
726695
ec.fEventHist[eHistVertexY][eSim][eAfter]->Fill(thisMCCollision.posY());
727696
ec.fEventHist[eHistVertexZ][eSim][eAfter]->Fill(thisMCCollision.posZ());
728697
}
729-
}
698+
} // end of if constexpr (rs == eRecAndSim && rm == eMC) {
730699
}
731700
}
732701

@@ -801,7 +770,6 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
801770
pc.fParticleHist[eHistEta][eRec][eBefore]->Fill(track.eta());
802771
pc.fParticleHist[eHistCharge][eRec][eBefore]->Fill(track.sign());
803772
}
804-
805773
if constexpr (cuts == eAfter) {
806774
pc.fParticleHist[eHistPt][eRec][eAfter]->Fill(track.pt());
807775
pc.fParticleHist[eHistPhi][eRec][eAfter]->Fill(track.phi());
@@ -830,7 +798,6 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
830798
pc.fParticleHist[eHistCharge][eSim][eBefore]->Fill(chargeMC);
831799
}
832800
}
833-
834801
if constexpr (cuts == eAfter) {
835802
pc.fParticleHist[eHistPt][eSim][eAfter]->Fill(thisMCParticle.pt());
836803
pc.fParticleHist[eHistPhi][eSim][eAfter]->Fill(thisMCParticle.phi());
@@ -839,9 +806,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
839806
pc.fParticleHist[eHistCharge][eSim][eAfter]->Fill(chargeMC);
840807
}
841808
}
842-
}
809+
} // end of if constexpr (rs == eRecAndSim && rm == eMC) {
843810
}
844-
}
811+
} // end of void particleHistFill(T1 const& track)
845812

846813
template <ERecSim rs, ERealMC rm, ECuts cuts, typename T1>
847814
void qaFill(T1 const& collision)
@@ -987,18 +954,16 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
987954
if (noneZeroDenom(resultTwo)) {
988955
obs.fProfTwo[eRec]->Fill(thisCollCentReal, (resultTwo[0] / resultTwo[1].Re()).Re());
989956
}
990-
}
991957

992-
if constexpr (rs == eRecAndSim) {
993-
if (passEventCutsReal && passTechnicalCut) {
958+
if constexpr (rs == eRecAndSim) {
994959
auto impactParam = collision.mcCollision().impactParameter();
995960
auto thisCollCentMC = math::PI * impactParam * impactParam / tc.fSigmaInel;
996961
resultTwo = two(qVectorsTableMC, n2);
997962
if (noneZeroDenom(resultTwo)) {
998963
obs.fProfTwo[eSim]->Fill(thisCollCentMC, (resultTwo[0] / resultTwo[1].Re()).Re());
999964
}
1000-
} // end of if (passEventCutsReal && passTechnicalCut) {
1001-
} // end of if constexpr (rs == eRecAndSim) {
965+
} // end of if constexpr (rs == eRecAndSim) {
966+
}
1002967
} // end of if (tc.fMasterCutSwitch) {
1003968

1004969
isFirstCollision = false; // Now the first collision ends
@@ -1029,7 +994,11 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
1029994

1030995
tc.fMasterCutSwitch = cfMasterCutSwitch;
1031996
tc.fTechnicalCutSwitch = cfTechnicalCutSwitch.value;
1032-
tc.fEventCutSwitch = cfEventCutSwitch;
997+
998+
tc.fSel8CutSwitch = cfSel8CutSwitch;
999+
tc.fVertexZCutSwitch = cfVertexZCutSwitch;
1000+
tc.fCentCutSwitch = cfCentCutSwitch;
1001+
tc.fNContribCutSwitch = cfNContribCutSwitch;
10331002
tc.fVertexZCutRange = cfVertexZCutRange.value;
10341003
tc.fCentCutRange = cfCentCutRange.value;
10351004
tc.fNContribCutInf = cfNContribCutInf;

0 commit comments

Comments
 (0)