Skip to content

Commit c460c2b

Browse files
authored
PWGCF: flow-pbpb: apply NUA and NUE weights (#4562)
* change ccdb url; using enum for array index * change pt bins; Apply NUA and NUE weights
1 parent 09757ea commit c460c2b

File tree

1 file changed

+93
-21
lines changed

1 file changed

+93
-21
lines changed

PWGCF/Flow/Tasks/FlowPbPbTask.cxx

Lines changed: 93 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "GFWPowerArray.h"
2727
#include "GFW.h"
2828
#include "GFWCumulant.h"
29+
#include "GFWWeights.h"
2930
#include "FlowContainer.h"
3031
#include "TList.h"
3132
#include <TProfile.h>
@@ -48,24 +49,33 @@ struct FlowPbPbTask {
4849
O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters")
4950
O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables")
5051
O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples")
52+
O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, false, "Fill and output NUA weights")
53+
O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object")
54+
O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object")
5155

5256
ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"};
5357
ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"};
5458
ConfigurableAxis axisEta{"axisEta", {40, -1., 1.}, "eta axis for histograms"};
5559
ConfigurableAxis axisPtHist{"axisPtHist", {100, 0., 10.}, "pt axis for histograms"};
56-
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.30, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60, 1.70, 1.80, 1.90, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00}, "pt axis for histograms"};
60+
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.5, 4, 5, 6, 8, 10}, "pt axis for histograms"};
5761
ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality axis for histograms"};
5862

5963
Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
6064
Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls);
6165

66+
// Corrections
67+
TH1D* mEfficiency = nullptr;
68+
GFWWeights* mAcceptance = nullptr;
69+
bool correctionsLoaded = false;
70+
6271
// Connect to ccdb
6372
Service<ccdb::BasicCCDBManager> ccdb;
6473
Configurable<int64_t> nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
65-
Configurable<std::string> url{"ccdb-url", "http://ccdb-test.cern.ch:8080", "url of the ccdb repository"};
74+
Configurable<std::string> url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
6675

6776
// Define output
6877
OutputObj<FlowContainer> fFC{FlowContainer("FlowContainer")};
78+
OutputObj<GFWWeights> fWeights{GFWWeights("weights")};
6979
HistogramRegistry registry{"registry"};
7080

7181
// define global variables
@@ -74,6 +84,16 @@ struct FlowPbPbTask {
7484
TAxis* fPtAxis;
7585
TRandom3* fRndm = new TRandom3(0);
7686
std::vector<std::vector<std::shared_ptr<TProfile>>> BootstrapArray;
87+
enum ExtraProfile {
88+
// here are TProfiles for vn-pt correlations that are not implemented in GFW
89+
kMeanPt_InGap08 = 0,
90+
kC22_Gap08_Weff,
91+
kC22_Gap08_MeanPt,
92+
kPtVarParA_InGap08,
93+
kPtVarParB_InGap08,
94+
// Count the total number of enum
95+
kCount_ExtraProfile
96+
};
7797

7898
using aodCollisions = soa::Filtered<soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs>>;
7999
using aodTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TrackSelection, aod::TracksExtra>>;
@@ -101,22 +121,26 @@ struct FlowPbPbTask {
101121
// initial array
102122
BootstrapArray.resize(cfgNbootstrap);
103123
for (int i = 0; i < cfgNbootstrap; i++) {
104-
// currently we have 5 TProfiles in each sub dir
105-
BootstrapArray[i].resize(5);
124+
BootstrapArray[i].resize(kCount_ExtraProfile);
106125
}
107126
for (int i = 0; i < cfgNbootstrap; i++) {
108-
BootstrapArray[i][0] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/hMeanPtWithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
109-
BootstrapArray[i][1] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/c22_gap08_Weff", i), "", {HistType::kTProfile, {axisMultiplicity}}));
110-
BootstrapArray[i][2] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/c22_gap08_trackMeanPt", i), "", {HistType::kTProfile, {axisMultiplicity}}));
111-
BootstrapArray[i][3] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/PtVariance_partA_WithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
112-
BootstrapArray[i][4] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/PtVariance_partB_WithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
127+
BootstrapArray[i][kMeanPt_InGap08] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/hMeanPtWithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
128+
BootstrapArray[i][kC22_Gap08_Weff] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/c22_gap08_Weff", i), "", {HistType::kTProfile, {axisMultiplicity}}));
129+
BootstrapArray[i][kC22_Gap08_MeanPt] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/c22_gap08_trackMeanPt", i), "", {HistType::kTProfile, {axisMultiplicity}}));
130+
BootstrapArray[i][kPtVarParA_InGap08] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/PtVariance_partA_WithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
131+
BootstrapArray[i][kPtVarParB_InGap08] = std::get<std::shared_ptr<TProfile>>(registry.add(Form("BootstrapContainer_%d/PtVariance_partB_WithinGap08", i), "", {HistType::kTProfile, {axisMultiplicity}}));
113132
}
114133

115134
o2::framework::AxisSpec axis = axisPt;
116135
int nPtBins = axis.binEdges.size() - 1;
117136
double* PtBins = &(axis.binEdges)[0];
118137
fPtAxis = new TAxis(nPtBins, PtBins);
119138

139+
if (cfgOutputNUAWeights) {
140+
fWeights->SetPtBins(nPtBins, PtBins);
141+
fWeights->Init(true, false);
142+
}
143+
120144
// add in FlowContainer to Get boostrap sample automatically
121145
TObjArray* oba = new TObjArray();
122146
oba->Add(new TNamed("ChGap22", "ChGap22"));
@@ -283,8 +307,48 @@ struct FlowPbPbTask {
283307
return;
284308
}
285309

310+
void loadCorrections(uint64_t timestamp)
311+
{
312+
if (correctionsLoaded)
313+
return;
314+
if (cfgAcceptance.value.empty() == false) {
315+
mAcceptance = ccdb->getForTimeStamp<GFWWeights>(cfgAcceptance, timestamp);
316+
if (mAcceptance)
317+
LOGF(info, "Loaded acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance);
318+
else
319+
LOGF(warning, "Could not load acceptance weights from %s (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance);
320+
}
321+
if (cfgEfficiency.value.empty() == false) {
322+
mEfficiency = ccdb->getForTimeStamp<TH1D>(cfgEfficiency, timestamp);
323+
if (mEfficiency == nullptr) {
324+
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgEfficiency.value.c_str());
325+
}
326+
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)mEfficiency);
327+
}
328+
correctionsLoaded = true;
329+
}
330+
331+
bool setCurrentParticleWeights(float& weight_nue, float& weight_nua, const float& phi, const float& eta, const float& pt, const float& vtxz)
332+
{
333+
float eff = 1.;
334+
if (mEfficiency)
335+
eff = mEfficiency->GetBinContent(mEfficiency->FindBin(pt));
336+
else
337+
eff = 1.0;
338+
if (eff == 0)
339+
return false;
340+
weight_nue = 1. / eff;
341+
if (mAcceptance)
342+
weight_nua = mAcceptance->GetNUA(phi, eta, vtxz);
343+
else
344+
weight_nua = 1;
345+
return true;
346+
}
347+
286348
void process(aodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks)
287349
{
350+
if (!collision.sel8())
351+
return;
288352
int Ntot = tracks.size();
289353
if (Ntot < 1)
290354
return;
@@ -295,6 +359,9 @@ struct FlowPbPbTask {
295359
registry.fill(HIST("hCent"), collision.centFT0C());
296360
fGFW->Clear();
297361
const auto cent = collision.centFT0C();
362+
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
363+
loadCorrections(bc.timestamp());
364+
298365
float weff = 1, wacc = 1;
299366
double weffEvent = 0, waccEvent = 0;
300367
int TrackNum = 0;
@@ -305,11 +372,16 @@ struct FlowPbPbTask {
305372
for (auto& track : tracks) {
306373
double pt = track.pt();
307374
double eta = track.eta();
375+
double phi = track.phi();
376+
if (cfgOutputNUAWeights)
377+
fWeights->Fill(phi, eta, vtxz, pt, cent, 0);
378+
if (!setCurrentParticleWeights(weff, wacc, phi, eta, pt, vtxz))
379+
continue;
308380
bool WithinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range
309381
bool WithinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range
310382
bool WithinEtaGap08 = (eta >= -0.4) && (eta <= 0.4);
311383
if (WithinPtRef) {
312-
registry.fill(HIST("hPhi"), track.phi());
384+
registry.fill(HIST("hPhi"), phi);
313385
registry.fill(HIST("hEta"), track.eta());
314386
registry.fill(HIST("hPt"), pt);
315387
weffEvent += weff;
@@ -325,11 +397,11 @@ struct FlowPbPbTask {
325397
}
326398
}
327399
if (WithinPtRef)
328-
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), wacc * weff, 1);
400+
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 1);
329401
if (WithinPtPOI)
330-
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), wacc * weff, 2);
402+
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 2);
331403
if (WithinPtPOI && WithinPtRef)
332-
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), wacc * weff, 4);
404+
fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, phi, wacc * weff, 4);
333405
}
334406

335407
double WeffEvent_diff_WithGap08 = weffEvent_WithinGap08 * weffEvent_WithinGap08 - weffEventSquare_WithinGap08;
@@ -355,16 +427,16 @@ struct FlowPbPbTask {
355427
// Filling Bootstrap Samples
356428
int SampleIndex = static_cast<int>(cfgNbootstrap * l_Random);
357429
if (weffEvent_WithinGap08 > 1e-6)
358-
BootstrapArray[SampleIndex][0]->Fill(cent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08);
430+
BootstrapArray[SampleIndex][kMeanPt_InGap08]->Fill(cent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08);
359431
if (weffEvent_WithinGap08 > 1e-6)
360-
FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, BootstrapArray[SampleIndex][1], BootstrapArray[SampleIndex][2], cent);
432+
FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, BootstrapArray[SampleIndex][kC22_Gap08_Weff], BootstrapArray[SampleIndex][kC22_Gap08_MeanPt], cent);
361433
if (WeffEvent_diff_WithGap08 > 1e-6) {
362-
BootstrapArray[SampleIndex][3]->Fill(cent,
363-
(ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08,
364-
WeffEvent_diff_WithGap08);
365-
BootstrapArray[SampleIndex][4]->Fill(cent,
366-
(weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08,
367-
WeffEvent_diff_WithGap08);
434+
BootstrapArray[SampleIndex][kPtVarParA_InGap08]->Fill(cent,
435+
(ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08,
436+
WeffEvent_diff_WithGap08);
437+
BootstrapArray[SampleIndex][kPtVarParB_InGap08]->Fill(cent,
438+
(weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08,
439+
WeffEvent_diff_WithGap08);
368440
}
369441

370442
// Filling Flow Container

0 commit comments

Comments
 (0)