Skip to content

Commit e86c4d7

Browse files
meiALICEYuanjun Mei
andauthored
[PWGCF] Improvements on efficiency correction (#18120)
Co-authored-by: Yuanjun Mei <yuanjun.mei@cern.ch>
1 parent 572b956 commit e86c4d7

1 file changed

Lines changed: 40 additions & 30 deletions

File tree

‎PWGCF/MultiparticleCorrelations/Tasks/multiparticleCorrelationsMei.cxx‎

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ enum EMiscHistograms {
134134
eMiscHistograms_N
135135
};
136136

137-
enum EExternalHistograms {
137+
enum EWeightsHistograms {
138138
ePhi = 0,
139139
ePt,
140-
eExternalHistograms_N
140+
eWeightsHistograms_N
141141
};
142142

143143
enum EObservables {
@@ -159,7 +159,7 @@ static constexpr std::array<const char*, eMultiplicityTables_N> MultiplicityTabl
159159
"multFT0M",
160160
"multNTracksPV"};
161161

162-
static constexpr std::array<const char*, eExternalHistograms_N> WeightsNames = {
162+
static constexpr std::array<const char*, eWeightsHistograms_N> WeightsNames = {
163163
"ePhi",
164164
"ePt"};
165165

@@ -187,7 +187,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
187187

188188
// *) external root files
189189
Configurable<bool> cfExternalFileSwitch{"cfExternalFileSwitch", false, "choose to include external root files or not"};
190-
Configurable<std::string> cfFileWithWeights{"cfFileWithWeights", "/alice-ccdb.cern.ch/Users/m/mei/O2challenge-", "path to external ROOT file which holds all particle weights"};
190+
Configurable<std::string> cfFileWithWeights{"cfFileWithWeights", "/alice-ccdb.cern.ch/Users/m/mei/thesis-", "path to external ROOT file which holds all particle weights"};
191191

192192
// *) binnings
193193
Configurable<bool> cfALICECentBinSwitch{"cfALICECentBinSwitch", true, "switch on or off to use ALICE default binning"};
@@ -219,6 +219,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
219219
// *) misc
220220
Configurable<double> sigmaInel{"sigmaInel", 7.71, "inelastic cross section in mb"};
221221
Configurable<bool> qualityAssuranceSwitch{"qualityAssuranceSwitch", false, "quality assurance switch"};
222+
Configurable<bool> runMessageSwitch{"runMessageSwitch", false, "run message switch"};
222223

223224
// *) Define and initialize all data members to be called in the main process* functions:
224225
// **) Task configuration:
@@ -247,7 +248,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
247248
// *) External histograms:
248249
struct ExternalHistograms {
249250
TList* fExternalHistogramsList = nullptr;
250-
std::array<std::array<TH1F*, eCuts_N>, eExternalHistograms_N> fWeights{}; //! [type][before, after cuts]
251+
std::array<std::array<TH1F*, eCuts_N>, eWeightsHistograms_N> fWeights{}; //! [type][before, after cuts]
251252
} ex;
252253

253254
struct Observables {
@@ -275,7 +276,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
275276
}
276277

277278
template <typename T1>
278-
void updateQVectorsTable(std::vector<std::vector<TComplex>>& QVectorsTable, T1 phi, T1 weight = T1(1))
279+
void updateQVectorsTable(std::vector<std::vector<TComplex>>& QVectorsTable, T1 const& phi, T1 weight = T1(1))
279280
{
280281
const int maxHarmonic = QVectorsTable.size();
281282
const int maxPower = QVectorsTable.empty() ? 0 : QVectorsTable[0].size();
@@ -526,9 +527,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
526527

527528
// templates
528529
template <typename T1>
529-
float chooseCent(T1 const& collision)
530+
float chooseCent(T1 const& collision, int const& whichEstimator)
530531
{
531-
switch (centralityEstimator) {
532+
switch (whichEstimator) {
532533
case eFT0C:
533534
return static_cast<float>(collision.centFT0C());
534535
case eFT0M:
@@ -544,9 +545,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
544545
}
545546

546547
template <typename T1>
547-
float chooseMult(T1 const& collision)
548+
float chooseMult(T1 const& collision, int const& whichTable)
548549
{
549-
switch (multiplicityTables) {
550+
switch (whichTable) {
550551
case eMultTPC:
551552
return static_cast<float>(collision.multTPC());
552553
case eMultFV0M:
@@ -598,8 +599,8 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
598599
if constexpr (rs == eRec || rs == eRecAndSim) {
599600
// Fill reconstructed-level event histograms
600601
if (rm == eReal) {
601-
auto thisCent = chooseCent(collision);
602-
auto thisRefMult = chooseMult(collision);
602+
auto thisCent = chooseCent(collision, centralityEstimator);
603+
auto thisRefMult = chooseMult(collision, multiplicityTables);
603604
int multiplicityRec = static_cast<int>(tracks.size());
604605
if constexpr (cuts == eBefore) {
605606
ec.fEventHist[eHistMultiplicity][eRec][eBefore]->Fill(multiplicityRec);
@@ -772,10 +773,13 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
772773

773774
void loadWeights(int runNumber)
774775
{
775-
for (int i = 0; i < eExternalHistograms_N; ++i) {
776+
for (int i = 0; i < eWeightsHistograms_N; ++i) {
776777
for (int j = 0; j < eCuts_N; ++j) {
777-
ex.fWeights[i][j] =
778-
getHistogramWithWeights(cfFileWithWeights.value.c_str(), Form("%d", runNumber), Form("[%s][%s]", WeightsNames[i], CutsNames[j]));
778+
ex.fWeights[i][j] = getHistogramWithWeights(cfFileWithWeights.value.c_str(), Form("%d", runNumber), Form("[%s][%s]", WeightsNames[i], CutsNames[j]));
779+
if (!ex.fWeights[i][j]) {
780+
LOGF(info, "[%s][%s] not found", WeightsNames[i], CutsNames[j]);
781+
continue;
782+
}
779783
ex.fExternalHistogramsList->Add(ex.fWeights[i][j]);
780784
}
781785
}
@@ -784,7 +788,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
784788
template <ERecSim rs, typename T1>
785789
void qaFill(T1 const& collision)
786790
{
787-
auto thisCent = chooseCent(collision);
791+
auto thisCent = chooseCent(collision, centralityEstimator);
788792
if constexpr (rs == eRecAndSim || rs == eSim) {
789793
if (!collision.has_mcCollision()) {
790794
return;
@@ -807,7 +811,10 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
807811
if (tc.fDryRun) {
808812
return;
809813
}
810-
int thisRunNumber = collision.bc().runNumber();
814+
const int thisRunNumber = collision.bc().runNumber();
815+
if (runMessageSwitch) {
816+
LOGF(info, "Successfully running, run number is %d", thisRunNumber);
817+
}
811818

812819
if (isFirstCollision) {
813820
// Get run number
@@ -848,27 +855,30 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
848855
auto track = tracks.iteratorAt(0); // set the type and scope from one instance
849856
for (int64_t i = 0; i < tracks.size(); i++) {
850857
track = tracks.iteratorAt(i);
851-
const float thisPhi = track.phi();
852-
const float thisPt = track.pt();
853-
float wPhiBefore = 1.f;
854-
float wPhiAfter = 1.f;
855-
float wPtBefore = 1.f;
856-
float wPtAfter = 1.f;
857-
if (cfExternalFileSwitch && ex.fWeights[ePhi][eBefore]) {
858-
wPhiBefore = ex.fWeights[ePhi][eBefore]->GetBinContent(ex.fWeights[ePhi][eBefore]->FindBin(thisPhi));
859-
wPhiAfter = ex.fWeights[ePhi][eAfter]->GetBinContent(ex.fWeights[ePhi][eAfter]->FindBin(thisPhi));
860-
wPtBefore = ex.fWeights[ePt][eBefore]->GetBinContent(ex.fWeights[ePt][eBefore]->FindBin(thisPt));
861-
wPtAfter = ex.fWeights[ePt][eAfter]->GetBinContent(ex.fWeights[ePt][eAfter]->FindBin(thisPt));
858+
float thisPhi = track.phi();
859+
float thisPt = track.pt();
860+
std::array<float, 2> thisPhiAndPt = {thisPhi, thisPt};
861+
std::array<std::array<float, 2>, 2> thisWeights = {{{1.f, 1.f}, {1.f, 1.f}}}; // {{wPhiBefore, wPhiAfter},{wPtBefore, wPtAfter}}
862+
863+
// eWeightsHistograms_N
864+
if (cfExternalFileSwitch) {
865+
for (int k = 0; k < eWeightsHistograms_N; ++k) {
866+
for (int j = 0; j < eCuts_N; ++j) {
867+
if (ex.fWeights[k][j]) {
868+
thisWeights[k][j] = ex.fWeights[k][j]->GetBinContent(ex.fWeights[k][j]->FindBin(thisPhiAndPt[k]));
869+
}
870+
}
871+
}
862872
}
863873

864874
particleHistFill<rs, eReal, eBefore>(track);
865875
particleHistFill<rs, eMC, eBefore>(track);
866-
updateQVectorsTable(qVectorsTableBeforeCutsReal, thisPhi, wPhiBefore * wPtBefore);
876+
updateQVectorsTable(qVectorsTableBeforeCutsReal, thisPhi, thisWeights[ePhi][eBefore] * thisWeights[ePt][eBefore]);
867877

868878
if (cfMasterCutSwitch) {
869879
if (passesEventCutsReal && particleCuts<rs, eReal>(track)) {
870880
particleHistFill<rs, eReal, eAfter>(track);
871-
updateQVectorsTable(qVectorsTableAfterCutsReal, thisPhi, wPhiAfter * wPtAfter);
881+
updateQVectorsTable(qVectorsTableAfterCutsReal, thisPhi, thisWeights[ePhi][eAfter] * thisWeights[ePt][eAfter]);
872882
}
873883
if (passesEventCutsMC && particleCuts<rs, eMC>(track)) {
874884
particleHistFill<rs, eMC, eAfter>(track);

0 commit comments

Comments
 (0)