Skip to content

Commit 4b72aa4

Browse files
committed
fixes
1 parent 18d9d6e commit 4b72aa4

1 file changed

Lines changed: 31 additions & 17 deletions

File tree

‎PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx‎

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,25 @@ struct HfTaskCorrelationDplusHadrons {
102102
Configurable<bool> fillHistoData{"fillHistoData", true, "Flag for filling histograms in data processes"};
103103
Configurable<bool> fillHistoMcRec{"fillHistoMcRec", true, "Flag for filling histograms in MC Rec processes"};
104104
Configurable<bool> fillHistoMcGen{"fillHistoMcGen", true, "Flag for filling histograms in MC Gen processes"};
105-
Configurable<bool> fillHistoMcEff{"fillHistoMcEff", true, "Flag for filling histograms in efficiency processes"};
106105
Configurable<int> applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"};
107106
Configurable<bool> loadAccXEffFromCCDB{"loadAccXEffFromCCDB", false, "Flag for loading efficiency distributions from CCDB"};
108107
Configurable<int> selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; // 7 corresponds to topo+PID cuts
109108
Configurable<bool> selNoSameBunchPileUpColl{"selNoSameBunchPileUpColl", true, "Flag for rejecting the collisions associated with the same bunch crossing"};
110109
// Machine Learning options and selections
111110
Configurable<std::vector<int>> classMl{"classMl", {0, 1, 2}, "Indexes of ML scores to be stored. Three indexes max."};
112-
Configurable<std::vector<double>> mlScorePromptOrNonPromptMin{"mlScorePromptOrNonPromptMin", {0.5, 0.5, 0.5, 0.5}, "Minimum Machine learning scores for prompt or Feed-down"};
113-
Configurable<std::vector<double>> mlScorePromptOrNonPromptMax{"mlScorePromptOrNonPromptMax", {1.0, 1.0, 1.0, 1.0}, "Maximum Machine learning scores for prompt or Feed-down"};
114-
Configurable<std::vector<double>> mlScoreBkg{"mlScoreBkg", {0.5, 0.5, 0.5, 0.5}, "Machine learning scores for bkg"};
111+
// default ML cuts defined in the default pT bins of the ML cuts (binsPtEfficiencyD, since binsPtMl is empty by default)
112+
Configurable<std::vector<double>> mlScorePromptOrNonPromptMin{"mlScorePromptOrNonPromptMin", std::vector<double>(npTBinsEfficiency, 0.), "Minimum Machine learning scores for prompt or Feed-down, one per pT bin of the ML cuts"};
113+
Configurable<std::vector<double>> mlScorePromptOrNonPromptMax{"mlScorePromptOrNonPromptMax", std::vector<double>(npTBinsEfficiency, 1.0), "Maximum Machine learning scores for prompt or Feed-down, one per pT bin of the ML cuts"};
114+
Configurable<std::vector<double>> mlScoreBkg{"mlScoreBkg", std::vector<double>(npTBinsEfficiency, 0.5), "Machine learning scores for bkg, one per pT bin of the ML cuts"};
115115
Configurable<std::vector<double>> binsPtMl{"binsPtMl", std::vector<double>{}, "pT bin limits for the ML cuts, defining also the accepted D+ pT range (if empty, binsPtEfficiencyD is used)"};
116116
// pT ranges of the signal and sideband regions (the pT axis of all the histograms is binsPtEfficiencyD), can be redefined via json files
117117
Configurable<std::vector<double>> binsPtCorrelations{"binsPtCorrelations", std::vector<double>{ptBinsCorrelationsVec}, "pT bin limits for the signal and sideband regions"};
118118
Configurable<std::vector<double>> binsPtHadron{"binsPtHadron", std::vector<double>{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for assoc particle efficiency"};
119119
Configurable<std::vector<double>> binsPtEfficiencyD{"binsPtEfficiencyD", std::vector<double>{o2::analysis::hf_cuts_dplus_to_pi_k_pi::vecBinsPt}, "pT bin limits for efficiency and for the D+ pT axis of all the histograms"};
120120
Configurable<std::vector<double>> binsPtEfficiencyHad{"binsPtEfficiencyHad", std::vector<double>{0.3, 2., 4., 8., 12., 50.}, "pT bin limits for associated particle efficiency"};
121-
Configurable<std::vector<float>> efficiencyD{"efficiencyD", {1., 1., 1., 1., 1., 1.}, "efficiency values for prompt D+ meson"};
122-
Configurable<std::vector<float>> efficiencyFdD{"efficiencyFdD", {1., 1., 1., 1., 1., 1.}, "efficiency values for beauty feed-down D+ meson"};
123-
Configurable<std::vector<float>> efficiencyHad{"efficiencyHad", {1., 1., 1., 1., 1., 1.}, "efficiency values for associated particles"};
121+
Configurable<std::vector<float>> efficiencyD{"efficiencyD", std::vector<float>(npTBinsEfficiency, 1.f), "efficiency values for prompt D+ meson, one per pT bin of binsPtEfficiencyD"};
122+
Configurable<std::vector<float>> efficiencyFdD{"efficiencyFdD", std::vector<float>(npTBinsEfficiency, 1.f), "efficiency values for beauty feed-down D+ meson, one per pT bin of binsPtEfficiencyD"};
123+
Configurable<std::vector<float>> efficiencyHad{"efficiencyHad", {1., 1., 1., 1., 1.}, "efficiency values for associated particles, one per pT bin of binsPtEfficiencyHad"};
124124
// signal and sideband region edges, to be defined via json file (initialised to empty)
125125
Configurable<std::vector<double>> signalRegionInner{"signalRegionInner", std::vector<double>{signalRegionInnerVec}, "Inner values of signal region vs pT"};
126126
Configurable<std::vector<double>> signalRegionOuter{"signalRegionOuter", std::vector<double>{signalRegionOuterVec}, "Outer values of signal region vs pT"};
@@ -138,7 +138,7 @@ struct HfTaskCorrelationDplusHadrons {
138138
Configurable<float> yCandMax{"yCandMax", 0.8, "max. cand. rapidity"};
139139
Configurable<float> yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"};
140140
Configurable<float> ptDaughterMin{"ptDaughterMin", 0.1, "min. daughter pT"};
141-
Configurable<int> nTpcCrossedRaws{"nTpcCrossedRaws", 70, "Number of crossed TPC Rows"};
141+
Configurable<int> nTpcCrossedRows{"nTpcCrossedRows", 70, "Number of crossed TPC Rows"};
142142
Configurable<float> cutCollPosZMc{"cutCollPosZMc", 10., "max z-vertex position for collision acceptance"};
143143
Configurable<bool> storeMassAxis{"storeMassAxis", false, "Store Mass axis in THnSparse"};
144144
Configurable<bool> storeBMotherInfo{"storeBMotherInfo", false, "Store generated pT(B mother) and phi(D+) - phi(B mother) of non-prompt D+ in MC Rec histograms"};
@@ -193,11 +193,11 @@ struct HfTaskCorrelationDplusHadrons {
193193
AxisSpec const axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"};
194194
AxisSpec axisDeltaEta = {binsEta, "#it{#eta}^{Hadron}-#it{#eta}^{D}"};
195195
AxisSpec axisDeltaPhi = {binsPhi, "#it{#varphi}^{Hadron}-#it{#varphi}^{D} (rad)"};
196-
AxisSpec axisPtHadron = {(std::vector<double>)binsPtHadron, "#it{p}_{T}^{Hadron} (GeV/#it{c})"};
196+
AxisSpec axisPtHadron = {std::vector<double>(binsPtHadron), "#it{p}_{T}^{Hadron} (GeV/#it{c})"};
197197
AxisSpec axisPoolBin = {binsPoolBin, "poolBin"};
198198
AxisSpec axisDplusPrompt = {2, -0.5, 1.5, "Prompt D+"};
199199
AxisSpec const axisBdtScore = {binsBdtScore, "Bdt score"};
200-
AxisSpec axisPtBMother = {(std::vector<double>)binsPtBMother, "#it{p}_{T}^{B} (GeV/#it{c})"};
200+
AxisSpec axisPtBMother = {std::vector<double>(binsPtBMother), "#it{p}_{T}^{B} (GeV/#it{c})"};
201201
AxisSpec axisDeltaPhiBMother = {binsDeltaPhiBMother, "#it{#varphi}^{D}-#it{#varphi}^{B} (rad)"};
202202

203203
// Histograms for data analysis
@@ -253,23 +253,22 @@ struct HfTaskCorrelationDplusHadrons {
253253
registry.add("hDeltaPhiPtIntSidebandRightMcRec", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTH1F, {axisDeltaPhi}});
254254
registry.add("hCorrel2DVsPtSidebandRightMcRec", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
255255
registry.add("hCorrel2DVsPtSignalRegionPromptDplusPromptHadronMcRec", stringDHadron + "signal region PromptD - Prompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
256-
registry.add("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec", stringDHadron + " signal region PromptD - NonPrompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
256+
registry.add("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec", stringDHadron + " signal region NonPrompt - NonPrompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
257257

258258
registry.get<THnSparse>(HIST("hCorrel2DVsPtSignalRegionMcRec"))->Sumw2();
259259
registry.get<THnSparse>(HIST("hCorrel2DVsPtSidebandsMcRec"))->Sumw2();
260260
registry.get<THnSparse>(HIST("hCorrel2DVsPtSignalMcRec"))->Sumw2();
261261
registry.get<THnSparse>(HIST("hCorrel2DVsPtBkgMcRec"))->Sumw2();
262262
registry.get<THnSparse>(HIST("hCorrel2DVsPtSidebandLeftMcRec"))->Sumw2();
263263
registry.get<THnSparse>(HIST("hCorrel2DVsPtSidebandRightMcRec"))->Sumw2();
264-
registry.get<THnSparse>(HIST("hCorrel2DVsPtSignalRegionMcRec"))->Sumw2();
265264
registry.get<THnSparse>(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"))->Sumw2();
266265

267266
// beauty-mother information of non-prompt D+ (generated B, reconstructed D+)
268267
if (storeBMotherInfo) {
269268
registry.add("hMassNonPromptDplusVsPtVsPtBMother", "D+ non prompt candidates mass Vs Pt Vs Pt B mother", {HistType::kTH3F, {{axisMassD}, {axisPtD}, {axisPtBMother}}});
270269
registry.add("hDeltaPhiBMotherVsPtVsPtBMother", "D+ non prompt candidates #varphi^{D}-#varphi^{B} Vs Pt Vs Pt B mother", {HistType::kTH3F, {{axisDeltaPhiBMother}, {axisPtD}, {axisPtBMother}}});
271270
registry.add("hCorrel2DVsPtNonPromptDplusPhysicalPrimaryMcRecBMother", stringDHadron + "non-prompt D (only true primary particles)" + stringSignal, {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPtBMother}, {axisDeltaPhiBMother}}});
272-
registry.add("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRecBMother", stringDHadron + "signal region NonPromptD - NonPrompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPtBMother}, {axisDeltaPhiBMother}}});
271+
registry.add("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRecBMother", stringDHadron + "NonPrompt D - Non Prompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPtBMother}, {axisDeltaPhiBMother}}});
273272

274273
registry.get<THnSparse>(HIST("hCorrel2DVsPtNonPromptDplusPhysicalPrimaryMcRecBMother"))->Sumw2();
275274
registry.get<THnSparse>(HIST("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRecBMother"))->Sumw2();
@@ -279,7 +278,6 @@ struct HfTaskCorrelationDplusHadrons {
279278
if (fillHistoMcGen) {
280279
registry.add("hDeltaEtaPtIntMcGen", stringMCParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}});
281280
registry.add("hDeltaPhiPtIntMcGen", stringMCParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}});
282-
registry.add("hCorrel2DPtIntMcGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}});
283281
registry.add("hCorrel2DVsPtMcGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + stringPtD + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
284282
registry.add("hCorrel2DVsPtMcGenPrompt", stringDHadron + " Prompt MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
285283
registry.add("hCorrel2DVsPtMcGenPromptDPromptHadron", stringDHadron + "prompt D prompt h MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}});
@@ -337,8 +335,24 @@ struct HfTaskCorrelationDplusHadrons {
337335
LOGF(info, "Loaded associated efficiency histogram from %s", associatedEffCcdbPath.value.c_str());
338336
}
339337

340-
// pT bins of the ML cuts, decoupled from the efficiency binning
341338
constexpr std::size_t NBinLimitsMin{2u}; // at least one pT bin
339+
340+
// efficiency values from configurables: one entry per pT bin
341+
if ((applyEfficiency != 0) && !loadAccXEffFromCCDB) {
342+
if (binsPtEfficiencyD->size() < NBinLimitsMin || binsPtEfficiencyHad->size() < NBinLimitsMin) {
343+
LOGF(fatal, "binsPtEfficiencyD and binsPtEfficiencyHad must contain at least two pT bin limits");
344+
}
345+
std::size_t const nBinsPtEffD = binsPtEfficiencyD->size() - 1;
346+
if (efficiencyD->size() != nBinsPtEffD || efficiencyFdD->size() != nBinsPtEffD) {
347+
LOGF(fatal, "efficiencyD (%zu entries) and efficiencyFdD (%zu entries) must have one entry per pT bin of binsPtEfficiencyD (%zu bins)", efficiencyD->size(), efficiencyFdD->size(), nBinsPtEffD);
348+
}
349+
std::size_t const nBinsPtEffHad = binsPtEfficiencyHad->size() - 1;
350+
if (efficiencyHad->size() != nBinsPtEffHad) {
351+
LOGF(fatal, "efficiencyHad (%zu entries) must have one entry per pT bin of binsPtEfficiencyHad (%zu bins)", efficiencyHad->size(), nBinsPtEffHad);
352+
}
353+
}
354+
355+
// pT bins of the ML cuts, decoupled from the efficiency binning
342356
binsPtMlD = binsPtMl->empty() ? binsPtEfficiencyD.value : binsPtMl.value;
343357
if (binsPtMlD.size() < NBinLimitsMin) {
344358
LOGF(fatal, "binsPtMl (or binsPtEfficiencyD if binsPtMl is empty) must contain at least two pT bin limits");
@@ -463,7 +477,7 @@ struct HfTaskCorrelationDplusHadrons {
463477
if (!isSelectedMl(ptD, bdtScoreBkg, bdtScorePrompt, bdtScoreNonPrompt)) {
464478
continue;
465479
}
466-
if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) {
480+
if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRows) {
467481
continue;
468482
}
469483
double const efficiencyWeight = getEfficiencyWeight(ptD, isPromptAnalysis, ptHadron);
@@ -567,7 +581,7 @@ struct HfTaskCorrelationDplusHadrons {
567581
if (!isSelectedMl(ptD, bdtScoreBkg, bdtScorePrompt, bdtScoreNonPrompt)) {
568582
continue;
569583
}
570-
if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) {
584+
if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRows) {
571585
continue;
572586
}
573587
double const efficiencyWeight = getEfficiencyWeight(ptD, isDplusPrompt, ptHadron);

0 commit comments

Comments
 (0)