Skip to content

Commit ea32ba0

Browse files
moved to the appropriate directory, added pid manager, central collision selection and histogram registry generator
1 parent eef7474 commit ea32ba0

File tree

1 file changed

+41
-49
lines changed

1 file changed

+41
-49
lines changed

PWGLF/Utils/nucleiUtils.h

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,14 @@ enum Flags {
119119
kIsSecondaryFromWeakDecay = BIT(11) /// the last 4 bits are reserved for the PID in tracking
120120
};
121121

122-
int getSpeciesFromPdg(int pdg) {
122+
constexpr int getSpeciesFromPdg(int pdg) {
123123
switch (std::abs(pdg)) {
124-
case PDG_t::kProton:
125-
return Species::kPr;
126-
case o2::constants::physics::Pdg::kDeuteron:
127-
return Species::kDe;
128-
case o2::constants::physics::Pdg::kTriton:
129-
return Species::kTr;
130-
case o2::constants::physics::Pdg::kHelium3:
131-
return Species::kHe;
132-
case o2::constants::physics::Pdg::kAlpha:
133-
return Species::kAl;
134-
default:
135-
return -1;
124+
case PDG_t::kProton: return Species::kPr;
125+
case o2::constants::physics::Pdg::kDeuteron: return Species::kDe;
126+
case o2::constants::physics::Pdg::kTriton: return Species::kTr;
127+
case o2::constants::physics::Pdg::kHelium3: return Species::kHe;
128+
case o2::constants::physics::Pdg::kAlpha: return Species::kAl;
129+
default: return -1;
136130
}
137131
}
138132

@@ -212,9 +206,11 @@ constexpr double DownscalingDefault[Species::kNspecies][1]{
212206
// constexpr bool storeTreesDefault[Species::kNspecies]{false, false, false, false, false};
213207
constexpr float charges[Species::kNspecies]{1.f, 1.f, 1.f, 2.f, 2.f};
214208
constexpr float masses[Species::kNspecies]{MassProton, MassDeuteron, MassTriton, MassHelium3, MassAlpha};
209+
constexpr int pdgCodes[Species::kNspecies]{PDG_t::kProton, o2::constants::physics::Pdg::kDeuteron, o2::constants::physics::Pdg::kTriton, o2::constants::physics::Pdg::kHelium3, o2::constants::physics::Pdg::kAlpha};
210+
static constexpr std::string_view cNames[] = {"proton", "deuteron", "triton", "He3", "alpha"};
211+
static const std::vector<std::string> names{"proton", "deuteron", "triton", "He3", "alpha"};
215212
static const std::vector<std::string> matter{"M", "A"};
216213
static const std::vector<std::string> pidName{"TPC", "TOF"};
217-
static const std::vector<std::string> names{"proton", "deuteron", "triton", "He3", "alpha"};
218214
static const std::vector<std::string> treeConfigNames{"Filter trees", "Use TOF selection"};
219215
static const std::vector<std::string> flowConfigNames{"Save flow hists"};
220216
static const std::vector<std::string> DCAConfigNames{"Save DCA hist", "Matter/Antimatter"};
@@ -270,10 +266,17 @@ constexpr int EvSelDefault[8][1]{
270266
template <typename Tcollision> // move to nucleiUtils
271267
bool eventSelection(const Tcollision& collision, HistogramRegistry& registry, LabeledArray<int> eventSelections, const float cutVertex)
272268
{
269+
if (!registry.contains(HIST("hVtxZBefore"))) {
270+
registry.add("hVtxZBefore", "Vertex distribution in Z before selections;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}});
271+
}
272+
if (!registry.contains(HIST("hVtxZ"))) {
273+
registry.add("hVtxZ", "Vertex distribution in Z;Z (cm)", {HistType::kTH1F, {{400, -20.0, 20.0}}});
274+
}
273275
if (!registry.contains(HIST("hEventSelections"))) {
274276
registry.add("hEventSelections", "hEventSelections", {HistType::kTH1D, {{evSel::kNevSels + 1, -0.5f, static_cast<float>(evSel::kNevSels) + 0.5f}}});
275277
}
276278
registry.fill(HIST("hEventSelections"), 0);
279+
registry.fill(HIST("hVtxZBefore"), collision.posZ());
277280

278281
if (eventSelections.get(evSel::kTVX) && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) {
279282
return false;
@@ -319,6 +322,7 @@ bool eventSelection(const Tcollision& collision, HistogramRegistry& registry, La
319322
}
320323
registry.fill(HIST("hEventSelections"), evSel::kIsEPtriggered + 1);
321324
}
325+
registry.fill(HIST("hVtxZ"), collision.posZ());
322326

323327
return true;
324328
}
@@ -352,43 +356,36 @@ enum trackSelection {
352356
};
353357
static const std::array<std::string, static_cast<int>(trackSelection::kNtrackSelections)> trackSelectionLabels{"All", "Track cuts", "PID cuts"};
354358

355-
HistogramRegistry createHistogramRegistryNucleus(const int iSpecies) {
359+
template<int iSpecies>
360+
void createHistogramRegistryNucleus(HistogramRegistry& registry) {
356361

357-
if (!checkSpeciesValidity(iSpecies)) {
362+
constexpr int index = iSpecies;
363+
if (!checkSpeciesValidity(index)) {
358364
std::runtime_error("species contains invalid nucleus index");
359365
}
360366

361-
HistogramRegistry registry{
362-
names[iSpecies].c_str(),
363-
{
364-
{"hTrackSelections", *Form("%s", names[iSpecies].c_str()) + " track selections; Selection step; Counts", {HistType::kTH1D, {{trackSelection::kNtrackSelections, -0.5f, static_cast<float>(trackSelection::kNtrackSelections) - 0.5f}}}},
365-
{"hPtReconstructed", *Form("%s", names[iSpecies].c_str()) + " - reconstructed variables; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); Counts", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}},
366-
{"h3PtVsEtaVsCentralityReconstructed", *Form("%s", names[iSpecies].c_str()) + " - reconstructed variables; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); #eta; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, -1.0f, 1.f}, {20, 0.0f, 100.0f}}}},
367-
{"h3PhiVsEtaVsCentralityReconstructed", *Form("%s", names[iSpecies].c_str()) + " - reconstructed variables; #phi (radians); #eta; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, 0.0f, o2::constants::math::TwoPI}, {20, 0.0f, 100.0f}}}},
368-
{"h3DCAxyVsPtVsCentrality", *Form("%s", names[iSpecies].c_str()) + "; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); DCA_{xy} (cm); CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}}}},
369-
{"h3DCAzVsPtVsCentrality", *Form("%s", names[iSpecies].c_str()) + "; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); DCA_{z} (cm); CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}}}},
370-
{"h3NsigmaTPC_preselectionVsCentrality", *Form("Nsigma%s TPC distribution; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{TPC}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}, {20, 0.0f, 100.0f}}}},
371-
{"h3NsigmaTPCVsCentrality", *Form("Nsigma%s TPC distribution; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{TPC}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}}}},
372-
{"h3NSigmaITS_preselectionVsCentrality", *Form("Nsigma%s ITS distribution; signed #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{ITS}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}, {20, 0.0f, 100.0f}}}},
373-
{"h3NSigmaITSVsCentrality", *Form("Nsigma%s ITS distribution; signed #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{ITS}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}, {20, 0.0f, 100.0f}}}},
374-
{"h3NSigmaTOF_preselectionVsCentrality", *Form("Nsigma%s TOF distribution; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{TOF}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}, {20, 0.0f, 100.0f}}}},
375-
{"h3NSigmaTOFVsCentrality", *Form("Nsigma%s TOF distribution; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); n#sigma_{TOF}(%s);", names[iSpecies].c_str(), names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}}}},
376-
{"h3BetaVsPtVsCentrality", *Form("%s", names[iSpecies].c_str()) + "; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); #beta; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {100, 0.0f, 1.0f}, {20, 0.0f, 100.0f}}}},
377-
{"h3dEdxVsPVsCentrality", *Form("dEdx distribution for %s; #it{p} (GeV/#it{c}); d#it{E}/d#it{x} (a.u.);", names[iSpecies].c_str()) + "CentralityFT0C (%)", {HistType::kTH3F, {{200, -6.0f, 6.0f}, {100, 0.0f, 2000.0f}, {20, 0.0f, 100.0f}}}},
378-
{"h3ClusterSizeVsPtVsCentrality", *Form("%s", names[iSpecies].c_str()) + "; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); Cluster size ITS; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {90, 0.f, 15.f}, {20, 0.0f, 100.0f}}}},
379-
{"hPtGenerated", *Form("%s", names[iSpecies].c_str()) + " - generated variables; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); Counts", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}},
380-
{"h3PtVsEtaVsCentralityGenerated", *Form("%s", names[iSpecies].c_str()) + " - generated variables; #it{p}_{T} / |#it{Z}| (GeV/#it{c}); #eta; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, -1.0f, 1.f}, {20, 0.0f, 100.0f}}}},
381-
{"h3PhiVsEtaVsCentralityGenerated", *Form("%s", names[iSpecies].c_str()) + " - generated variables; #phi (radians); #eta; CentralityFT0C (%)", {HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, 0.0f, o2::constants::math::TwoPI}, {20, 0.0f, 100.0f}}}},
382-
},
383-
OutputObjHandlingPolicy::AnalysisObject,
384-
false,
385-
true};
367+
registry.add(fmt::format("{}/hTrackSelections", cNames[index]).c_str(), (fmt::format("{} track selections;", cNames[index]) + std::string("Selection step; Counts")).c_str(), HistType::kTH1D, {{trackSelection::kNtrackSelections, -0.5f, static_cast<float>(trackSelection::kNtrackSelections) - 0.5f}});
368+
registry.add(fmt::format("{}/hPtReconstructed", cNames[index]).c_str(), (fmt::format("{} - reconstructed variables;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); Counts")).c_str(), HistType::kTH1F, {{240, -6.0f, 6.0f}});
369+
registry.add(fmt::format("{}/h3PtVsEtaVsCentralityReconstructed", cNames[index]).c_str(), (fmt::format("{} - reconstructed variables;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); #eta; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, -1.0f, 1.f}, {20, 0.0f, 100.0f}});
370+
registry.add(fmt::format("{}/h3PhiVsEtaVsCentralityReconstructed", cNames[index]).c_str(), (fmt::format("{} - reconstructed variables;", cNames[index]) + std::string("#phi (radians); #eta; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, 0.0f, o2::constants::math::TwoPI}, {20, 0.0f, 100.0f}});
371+
registry.add(fmt::format("{}/h3DCAxyVsPtVsCentrality", cNames[index]).c_str(), (fmt::format(";", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); DCA_{xy} (cm); CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}});
372+
registry.add(fmt::format("{}/h3DCAzVsPtVsCentrality", cNames[index]).c_str(), (fmt::format("{};", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); DCA_{z} (cm); CentralityFT0C (%)")).c_str() , HistType::kTH3F, {{240, -6.0f, 6.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}});
373+
registry.add(fmt::format("{}/h3NsigmaTPC_preselectionVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} TPC distribution;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{TPC}}({}); CentralityFT0C (%)", cNames[index])).c_str(), HistType::kTH3F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}, {20, 0.0f, 100.0f}});
374+
registry.add(fmt::format("{}/h3NsigmaTPCVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} TPC distribution;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{TPC}}({}); Centrality FT0C (%)", cNames[index])).c_str(), HistType::kTH3F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}});
375+
registry.add(fmt::format("{}/h3NsigmaITS_preselectionVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} ITS distribution;", cNames[index]) + std::string("signed #it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{ITS}}({}); Centrality FT0C (%)", cNames[index])).c_str(), HistType::kTH3F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}, {20, 0.0f, 100.0f}});
376+
registry.add(fmt::format("{}/h3NsigmaITSVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} ITS distribution;", cNames[index]) + std::string("signed #it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{ITS}}({}); Centrality FT0C (%)", cNames[index])).c_str(), HistType::kTH3F, {{50, -5.0f, 5.0f}, {120, -3.0f, 3.0f}, {20, 0.0f, 100.0f}});
377+
registry.add(fmt::format("{}/h3NsigmaTOF_preselectionVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} TOF distribution;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{TOF}}({}); Centrality FT0C (%)", cNames[index])).c_str(), HistType::kTH3F, {{100, -5.0f, 5.0f}, {400, -10.0f, 10.0f}, {20, 0.0f, 100.0f}});
378+
registry.add(fmt::format("{}/h3NsigmaTOFVsCentrality", cNames[index]).c_str(), (fmt::format("Nsigma{} TOF distribution;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c});") + fmt::format("n#sigma_{{TOF}}({}); Centrality FT0C (%)", cNames[index], cNames[index])).c_str(), HistType::kTH3F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}, {20, 0.0f, 100.0f}});
379+
registry.add(fmt::format("{}/h3BetaVsPtVsCentrality", cNames[index]).c_str(), (fmt::format("{};", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); #beta; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {100, 0.0f, 1.0f}, {20, 0.0f, 100.0f}});
380+
registry.add(fmt::format("{}/h3dEdxVsPVsCentrality", cNames[index]).c_str(), (fmt::format("dEdx distribution for {};", cNames[index]) + std::string("#it{p} (GeV/#it{c}); d#it{E}/d#it{x} (a.u.); Centrality FT0C (%)")).c_str(), HistType::kTH3F, {{200, -6.0f, 6.0f}, {100, 0.0f, 2000.0f}, {20, 0.0f, 100.0f}});
381+
registry.add(fmt::format("{}/h3ClusterSizeVsPtVsCentrality", cNames[index]).c_str(), (fmt::format("{};", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); Cluster size ITS; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {90, 0.f, 15.f}, {20, 0.0f, 100.0f}});
382+
registry.add(fmt::format("{}/hPtGenerated", cNames[index]).c_str(), (fmt::format("{} - generated variables;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); Counts")).c_str(), HistType::kTH1F, {{240, -6.0f, 6.0f}});
383+
registry.add(fmt::format("{}/h3PtVsEtaVsCentralityGenerated", cNames[index]).c_str(), (fmt::format("{} - generated variables;", cNames[index]) + std::string("#it{p}_{T} / |#it{Z}| (GeV/#it{c}); #eta; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, -1.0f, 1.f}, {20, 0.0f, 100.0f}});
384+
registry.add(fmt::format("{}/h3PhiVsEtaVsCentralityGenerated", cNames[index]).c_str(), (fmt::format("{} - generated variables;", cNames[index]) + std::string("#phi (radians); #eta; CentralityFT0C (%)")).c_str(), HistType::kTH3F, {{240, -6.0f, 6.0f}, {40, 0.0f, o2::constants::math::TwoPI}, {20, 0.0f, 100.0f}});
386385

387386
for (size_t iSel = 0; iSel < trackSelection::kNtrackSelections; iSel++) {
388-
registry.get<TH1>(HIST("hTrackSelections"))->GetXaxis()->SetBinLabel(iSel + 1, trackSelectionLabels[iSel].c_str());
387+
registry.get<TH1>(HIST(cNames[index]) + HIST("/hTrackSelections"))->GetXaxis()->SetBinLabel(iSel + 1, trackSelectionLabels[iSel].c_str());
389388
}
390-
391-
return registry;
392389
};
393390

394391
// PID manager class
@@ -455,11 +452,6 @@ class PidManager {
455452
}
456453
}
457454

458-
// ITS
459-
void initMcResponseITS() {
460-
mResponseITS.setMCDefaultParameters();
461-
}
462-
463455
template <typename Ttrack>
464456
float getClusterSizeCosLambdaITS(const Ttrack& track)
465457
{

0 commit comments

Comments
 (0)