Skip to content

Commit 319b626

Browse files
authored
[PWGCF] separate eff for Nch correction (#14892)
1 parent 14d0adb commit 319b626

File tree

1 file changed

+51
-30
lines changed

1 file changed

+51
-30
lines changed

PWGCF/Flow/Tasks/flowTask.cxx

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,24 @@ struct FlowTask {
104104
O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables")
105105
O2_DEFINE_CONFIGURABLE(cfgUseNchCorrected, bool, false, "Use Nch-corrected for flow observables, you also need to set cfgUseNch to true")
106106
O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 30, "Number of subsamples")
107-
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights")
108-
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins")
109-
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRunbyRun, bool, false, "NUA weights are filled run-by-run")
110-
O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object")
111-
O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object")
112-
O2_DEFINE_CONFIGURABLE(cfgUseSmallMemory, bool, false, "Use small memory mode")
113107
O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction")
114108
O2_DEFINE_CONFIGURABLE(cfgUseCentralMoments, bool, true, "Use central moments in vn-pt calculations")
115109
O2_DEFINE_CONFIGURABLE(cfgUsePtRef, bool, true, "Use refernce pt range for pt container (if you are checking the spectra, you need to extent it)")
116110
O2_DEFINE_CONFIGURABLE(cfgMpar, int, 4, "Highest order of pt-pt correlations")
117111
Configurable<std::vector<std::string>> cfgUserDefineGFWCorr{"cfgUserDefineGFWCorr", std::vector<std::string>{"refN02 {2} refP02 {-2}", "refN12 {2} refP12 {-2}"}, "User defined GFW CorrelatorConfig"};
118112
Configurable<std::vector<std::string>> cfgUserDefineGFWName{"cfgUserDefineGFWName", std::vector<std::string>{"Ch02Gap22", "Ch12Gap22"}, "User defined GFW Name"};
119113
Configurable<GFWCorrConfigs> cfgUserPtVnCorrConfig{"cfgUserPtVnCorrConfig", {{"refP {2} refN {-2}", "refP {3} refN {-3}"}, {"ChGap22", "ChGap32"}, {0, 0}, {3, 3}}, "Configurations for vn-pt correlations"};
120-
Configurable<std::vector<int>> cfgRunRemoveList{"cfgRunRemoveList", std::vector<int>{-1}, "excluded run numbers"};
114+
struct : ConfigurableGroup {
115+
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights")
116+
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRefPt, bool, false, "NUA weights are filled in ref pt bins")
117+
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeightsRunbyRun, bool, false, "NUA weights are filled run-by-run")
118+
O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object")
119+
O2_DEFINE_CONFIGURABLE(cfgEfficiencyForNch, std::string, "", "CCDB path to efficiency object, only for Nch correction")
120+
O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object")
121+
O2_DEFINE_CONFIGURABLE(cfgUseSmallMemory, bool, false, "Use small memory mode")
122+
Configurable<std::vector<int>> cfgRunRemoveList{"cfgRunRemoveList", std::vector<int>{-1}, "excluded run numbers"};
123+
} cfgUserIO;
124+
121125
struct : ConfigurableGroup {
122126
O2_DEFINE_CONFIGURABLE(cfgEvSelV0AT0ACut, bool, false, "V0A T0A 5 sigma cut")
123127
Configurable<std::vector<double>> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector<double>{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"};
@@ -198,6 +202,7 @@ struct FlowTask {
198202

199203
// Corrections
200204
TH1D* mEfficiency = nullptr;
205+
TH1D* mEfficiencyForNch = nullptr;
201206
GFWWeights* mAcceptance = nullptr;
202207
bool correctionsLoaded = false;
203208

@@ -309,7 +314,7 @@ struct FlowTask {
309314
registry.add("MCGen/MChMult", "Multiplicity distribution", {HistType::kTH1D, {{3000, 0.5, 3000.5}}});
310315
registry.add("MCGen/MChCent", hCentTitle.c_str(), {HistType::kTH1D, {{100, 0, 100}}});
311316
}
312-
if (!cfgUseSmallMemory) {
317+
if (!cfgUserIO.cfgUseSmallMemory) {
313318
registry.add("BeforeSel8_globalTracks_centT0C", "before sel8;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}});
314319
registry.add("BeforeCut_globalTracks_centT0C", "before cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}});
315320
registry.add("BeforeCut_PVTracks_centT0C", "before cut;Centrality T0C;mulplicity PV tracks", {HistType::kTH2D, {axisCentForQA, axisNch}});
@@ -377,7 +382,7 @@ struct FlowTask {
377382
double* ptBins = &(axis.binEdges)[0];
378383
fPtAxis = new TAxis(nPtBins, ptBins);
379384

380-
if (cfgOutputNUAWeights) {
385+
if (cfgUserIO.cfgOutputNUAWeights) {
381386
fWeights->setPtBins(nPtBins, ptBins);
382387
fWeights->init(true, false);
383388
}
@@ -770,19 +775,26 @@ struct FlowTask {
770775
{
771776
if (correctionsLoaded)
772777
return;
773-
if (cfgAcceptance.value.empty() == false) {
774-
mAcceptance = ccdb->getForTimeStamp<GFWWeights>(cfgAcceptance, timestamp);
778+
if (cfgUserIO.cfgAcceptance.value.empty() == false) {
779+
mAcceptance = ccdb->getForTimeStamp<GFWWeights>(cfgUserIO.cfgAcceptance, timestamp);
775780
if (mAcceptance)
776-
LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance);
781+
LOGF(info, "Loaded acceptance weights from %s (%p)", cfgUserIO.cfgAcceptance.value.c_str(), (void*)mAcceptance);
777782
else
778-
LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance);
783+
LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgUserIO.cfgAcceptance.value.c_str(), (void*)mAcceptance);
779784
}
780-
if (cfgEfficiency.value.empty() == false) {
781-
mEfficiency = ccdb->getForTimeStamp<TH1D>(cfgEfficiency, timestamp);
785+
if (cfgUserIO.cfgEfficiency.value.empty() == false) {
786+
mEfficiency = ccdb->getForTimeStamp<TH1D>(cfgUserIO.cfgEfficiency, timestamp);
782787
if (mEfficiency == nullptr) {
783-
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str());
788+
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgUserIO.cfgEfficiency.value.c_str());
789+
}
790+
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgUserIO.cfgEfficiency.value.c_str(), (void*)mEfficiency);
791+
}
792+
if (cfgUserIO.cfgEfficiencyForNch.value.empty() == false) {
793+
mEfficiencyForNch = ccdb->getForTimeStamp<TH1D>(cfgUserIO.cfgEfficiencyForNch, timestamp);
794+
if (mEfficiencyForNch == nullptr) {
795+
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgUserIO.cfgEfficiencyForNch.value.c_str());
784796
}
785-
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency);
797+
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgUserIO.cfgEfficiencyForNch.value.c_str(), (void*)mEfficiencyForNch);
786798
}
787799
if (cfgFuncParas.cfgDptDisEnable && cfgFuncParas.cfgDptDishEvAvgMeanPt.value.empty() == false) {
788800
cfgFuncParas.hEvAvgMeanPt = ccdb->getForTimeStamp<TH1D>(cfgFuncParas.cfgDptDishEvAvgMeanPt, timestamp);
@@ -810,7 +822,7 @@ struct FlowTask {
810822
correctionsLoaded = true;
811823
}
812824

813-
bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float phi, float eta, float pt, float vtxz)
825+
bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, float& eff_nch, float phi, float eta, float pt, float vtxz)
814826
{
815827
float eff = 1.;
816828
if (mEfficiency)
@@ -821,6 +833,15 @@ struct FlowTask {
821833
return false;
822834
weight_nue = 1. / eff;
823835

836+
float effNch = 1.;
837+
if (mEfficiencyForNch)
838+
effNch = mEfficiencyForNch->GetBinContent(mEfficiencyForNch->FindBin(pt));
839+
else
840+
effNch = 1.0;
841+
if (effNch == 0)
842+
return false;
843+
eff_nch = 1. / effNch;
844+
824845
if (mAcceptance)
825846
weight_nua = mAcceptance->getNUA(phi, eta, vtxz);
826847
else
@@ -1024,7 +1045,7 @@ struct FlowTask {
10241045
void processData(FilteredCollisions::iterator const& collision, aod::BCsWithTimestamps const&, FilteredTracks const& tracks)
10251046
{
10261047
registry.fill(HIST("hEventCount"), 0.5);
1027-
if (!cfgUseSmallMemory && tracks.size() >= 1) {
1048+
if (!cfgUserIO.cfgUseSmallMemory && tracks.size() >= 1) {
10281049
registry.fill(HIST("BeforeSel8_globalTracks_centT0C"), collision.centFT0C(), tracks.size());
10291050
}
10301051
if (!collision.sel8())
@@ -1034,12 +1055,12 @@ struct FlowTask {
10341055
registry.fill(HIST("hEventCount"), 1.5);
10351056
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
10361057
int currentRunNumber = bc.runNumber();
1037-
for (const auto& ExcludedRun : cfgRunRemoveList.value) {
1058+
for (const auto& ExcludedRun : cfgUserIO.cfgRunRemoveList.value) {
10381059
if (currentRunNumber == ExcludedRun) {
10391060
return;
10401061
}
10411062
}
1042-
if (cfgOutputNUAWeightsRunbyRun && currentRunNumber != lastRunNumber) {
1063+
if (cfgUserIO.cfgOutputNUAWeightsRunbyRun && currentRunNumber != lastRunNumber) {
10431064
lastRunNumber = currentRunNumber;
10441065
if (std::find(runNumbers.begin(), runNumbers.end(), currentRunNumber) == runNumbers.end()) {
10451066
// if run number is not in the preconfigured list, create new output histograms for this run
@@ -1054,7 +1075,7 @@ struct FlowTask {
10541075
}
10551076

10561077
registry.fill(HIST("hEventCount"), 2.5);
1057-
if (!cfgUseSmallMemory) {
1078+
if (!cfgUserIO.cfgUseSmallMemory) {
10581079
registry.fill(HIST("BeforeCut_globalTracks_centT0C"), collision.centFT0C(), tracks.size());
10591080
registry.fill(HIST("BeforeCut_PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV());
10601081
registry.fill(HIST("BeforeCut_globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size());
@@ -1087,7 +1108,7 @@ struct FlowTask {
10871108
registry.fill(HIST("hEventCount"), 4.5);
10881109

10891110
// fill event QA
1090-
if (!cfgUseSmallMemory) {
1111+
if (!cfgUserIO.cfgUseSmallMemory) {
10911112
registry.fill(HIST("globalTracks_centT0C"), collision.centFT0C(), tracks.size());
10921113
registry.fill(HIST("PVTracks_centT0C"), collision.centFT0C(), collision.multNTracksPV());
10931114
registry.fill(HIST("globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size());
@@ -1101,7 +1122,7 @@ struct FlowTask {
11011122
}
11021123

11031124
// track weights
1104-
float weff = 1, wacc = 1;
1125+
float weff = 1, wacc = 1, weffForNch = 1;
11051126
double weffEvent = 0;
11061127
double ptSum = 0., ptSum_Gap08 = 0.;
11071128
double weffEventWithinGap08 = 0., weffEventSquareWithinGap08 = 0.;
@@ -1152,20 +1173,20 @@ struct FlowTask {
11521173
bool withinPtPOI = (cfgCutPtPOIMin < track.pt()) && (track.pt() < cfgCutPtPOIMax); // within POI pT range
11531174
bool withinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT range
11541175
bool withinEtaGap08 = (std::abs(track.eta()) < cfgCutEta);
1155-
if (cfgOutputNUAWeights) {
1156-
if (cfgOutputNUAWeightsRefPt) {
1176+
if (cfgUserIO.cfgOutputNUAWeights) {
1177+
if (cfgUserIO.cfgOutputNUAWeightsRefPt) {
11571178
if (withinPtRef) {
11581179
fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0);
1159-
if (cfgOutputNUAWeightsRunbyRun)
1180+
if (cfgUserIO.cfgOutputNUAWeightsRunbyRun)
11601181
th3sPerRun[currentRunNumber]->Fill(track.phi(), track.eta(), collision.posZ());
11611182
}
11621183
} else {
11631184
fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0);
1164-
if (cfgOutputNUAWeightsRunbyRun)
1185+
if (cfgUserIO.cfgOutputNUAWeightsRunbyRun)
11651186
th3sPerRun[currentRunNumber]->Fill(track.phi(), track.eta(), collision.posZ());
11661187
}
11671188
}
1168-
if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz))
1189+
if (!setCurrentParticleWeights(weff, wacc, weffForNch, track.phi(), track.eta(), track.pt(), vtxz))
11691190
continue;
11701191
if (cfgTrackDensityCorrUse && withinPtRef) {
11711192
double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est));
@@ -1194,7 +1215,7 @@ struct FlowTask {
11941215
registry.fill(HIST("hDCAxy"), track.dcaXY(), track.pt());
11951216
weffEvent += weff;
11961217
ptSum += weff * track.pt();
1197-
nTracksCorrected += weff;
1218+
nTracksCorrected += weffForNch;
11981219
if (withinEtaGap08) {
11991220
ptSum_Gap08 += weff * track.pt();
12001221
sumPtWsquareWithinGap08 += weff * weff * track.pt();

0 commit comments

Comments
 (0)