Skip to content

Commit c4f3bed

Browse files
[PWGHF/D2H] Added THnSparse for Invariant mass vs BDT score (#8165)
1 parent 52b0220 commit c4f3bed

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct HfTaskDstarToD0Pi {
3939
Configurable<std::vector<double>> ptBins{"ptBins", std::vector<double>{hf_cuts_dstar_to_d0_pi::vecBinsPt}, "pT bin limits for Dstar"};
4040

4141
using CandDstarWSelFlag = soa::Join<aod::HfD0FromDstar, aod::HfCandDstars, aod::HfSelDstarToD0Pi>;
42+
using CandDstarWSelFlagWMl = soa::Join<aod::HfD0FromDstar, aod::HfCandDstars, aod::HfSelDstarToD0Pi, aod::HfMlDstarToD0Pi>;
4243
/// @brief specially for MC data
4344
// full reconstructed Dstar candidate
4445
using CandDstarWSelFlagMcRec = soa::Join<aod::HfD0FromDstar, aod::HfCandDstars, aod::HfSelDstarToD0Pi, aod::HfCandDstarMcRec>;
@@ -49,6 +50,7 @@ struct HfTaskDstarToD0Pi {
4950

5051
Filter candFilter = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi;
5152
Preslice<soa::Filtered<CandDstarWSelFlag>> preslicSelectedCandDstarPerCol = aod::hf_cand::collisionId;
53+
Preslice<soa::Filtered<CandDstarWSelFlagWMl>> preslicSelectedCandDstarPerColWMl = aod::hf_cand::collisionId;
5254

5355
PresliceUnsorted<CollisionsWCentMcLabel> colsPerMcCollision = aod::mccollisionlabel::mcCollisionId;
5456
SliceCache cache;
@@ -58,8 +60,10 @@ struct HfTaskDstarToD0Pi {
5860
ConfigurableAxis binningImpactParam{"binningImpactParam", {1000, 0.1, -0.1}, " Bins of Impact Parameter"};
5961
ConfigurableAxis binningDecayLength{"binningDecayLength", {1000, 0.0, 0.7}, "Bins of Decay Length"};
6062
ConfigurableAxis binningNormDecayLength{"binningNormDecayLength", {1000, 0.0, 40.0}, "Bins of Normalised Decay Length"};
61-
ConfigurableAxis binningCentrality{"binningCentrality", {VARIABLE_WIDTH, 0.0, 10.0, 20.0, 30.0, 60.0, 100.0}, "centrality binning"};
63+
ConfigurableAxis binningCentrality{"binningCentrality", {VARIABLE_WIDTH, 0.0, 1.0, 10.0, 30.0, 50.0, 70.0, 100.0}, "centrality binning"};
6264
ConfigurableAxis binningDeltaInvMass{"binningDeltaInvMass", {100, 0.13, 0.16}, "Bins of Delta InvMass of Dstar"};
65+
ConfigurableAxis binningBkgBDTScore{"binningBkgBDTScore", {100, 0.0f, 1.0f}, "Bins for background BDT Score"};
66+
ConfigurableAxis binningSigBDTScore{"binningSigBDTScore", {100, 0.0f, 1.0f}, "Bins for Signal (Prompts + Non Prompt) BDT Score"};
6367

6468
HistogramRegistry registry{
6569
"registry",
@@ -81,6 +85,9 @@ struct HfTaskDstarToD0Pi {
8185
AxisSpec axisNormDecayLength = {binningNormDecayLength, "normalised decay length (cm)"};
8286
AxisSpec axisCentrality = {binningCentrality, "centrality (%)"};
8387
AxisSpec axisDeltaInvMass = {binningDeltaInvMass, "#Delta #it{M}_{inv} D*"};
88+
AxisSpec axisBDTScorePrompt = {binningSigBDTScore, "BDT Score for Prompt Cand"};
89+
AxisSpec axisBDTScoreNonPrompt = {binningSigBDTScore, "BDT Score for Non-Prompt Cand"};
90+
AxisSpec axisBDTScoreBackground = {binningBkgBDTScore, "BDT Score for Background Cand"};
8491

8592
registry.add("Yield/hDeltaInvMassDstar3D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c}); FT0M centrality", {HistType::kTH3F, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true);
8693
registry.add("Yield/hDeltaInvMassDstar2D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}, true);
@@ -116,6 +123,7 @@ struct HfTaskDstarToD0Pi {
116123
registry.add("QA/hPtVsYRecoTopolDstarRecSig", "MC Matched RecoTopol D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
117124
registry.add("QA/hPtVsYRecoPidDstarRecSig", "MC Matched RecoPid D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
118125
registry.add("QA/hPtFullRecoDstarRecSig", "MC Matched FullReco D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c})", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}});
126+
registry.add("Efficiency/hPtVsCentFullRecoDstarRecSig", "MC Matched FullReco D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); Centrality (%)", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true);
119127
// Only Prompt RecSig
120128
registry.add("QA/hPtVsYSkimPromptDstarRecSig", "MC Matched Skimed Prompt D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}; #it{y})", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
121129
registry.add("QA/hPtVsYRecoTopolPromptDstarRecSig", "MC Matched RecoTopol Prompt D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
@@ -148,17 +156,21 @@ struct HfTaskDstarToD0Pi {
148156
registry.add("Efficiency/hNumPvContributorsAll", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true);
149157
registry.add("Efficiency/hNumPvContributorsCand", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true);
150158
registry.add("Efficiency/hNumPvContributorsCandInMass", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true);
159+
160+
// BDT Score
161+
registry.add("Yield/hDeltaInvMassVsPtVsCentVsBDTScore", "#Delta #it{M}_{inv} Vs Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseL, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}, {axisBDTScoreBackground}}});
151162
}
152163

153-
void process(CollisionsWCent const& cols, soa::Filtered<CandDstarWSelFlag> const& selectedCands)
164+
template <bool applyMl, typename T1, typename T2>
165+
void runTaskDstar(CollisionsWCent const& cols, T1 selectedCands, T2 preslice)
154166
{
155167
for (const auto& col : cols) {
156168
auto nPVContributors = col.numContrib();
157169
auto centrality = col.centFT0M();
158170
registry.fill(HIST("Efficiency/hNumPvContributorsAll"), nPVContributors, centrality);
159171

160172
auto gIndexCol = col.globalIndex();
161-
auto selectedCandsCurrentCol = selectedCands.sliceBy(preslicSelectedCandDstarPerCol, gIndexCol);
173+
auto selectedCandsCurrentCol = selectedCands.sliceBy(preslice, gIndexCol);
162174
auto nCandsCurrentCol = selectedCandsCurrentCol.size();
163175

164176
if (nCandsCurrentCol > 0) {
@@ -207,6 +219,12 @@ struct HfTaskDstarToD0Pi {
207219
if (0.142f < deltaMDstar && deltaMDstar < 0.15f) {
208220
nCandsSignalRegion++;
209221
}
222+
223+
if constexpr (applyMl) {
224+
auto mlBdtScore = candDstar.mlProbDstarToD0Pi();
225+
registry.fill(HIST("Yield/hDeltaInvMassVsPtVsCentVsBDTScore"), deltaMDstar, candDstar.pt(), centrality, mlBdtScore[0], mlBdtScore[1], mlBdtScore[2]);
226+
}
227+
210228
registry.fill(HIST("Yield/hDeltaInvMassDstar3D"), deltaMDstar, candDstar.pt(), centrality);
211229
registry.fill(HIST("Yield/hDeltaInvMassDstar2D"), deltaMDstar, candDstar.pt());
212230
registry.fill(HIST("Yield/hInvMassD0"), invD0, candDstar.ptD0());
@@ -237,6 +255,20 @@ struct HfTaskDstarToD0Pi {
237255
} // collision loop ends
238256
}
239257

258+
// process function without susing ML
259+
void processWoML(CollisionsWCent const& cols, soa::Filtered<CandDstarWSelFlag> const& selectedCands)
260+
{
261+
runTaskDstar<false, soa::Filtered<CandDstarWSelFlag>, Preslice<soa::Filtered<CandDstarWSelFlag>>>(cols, selectedCands, preslicSelectedCandDstarPerCol);
262+
}
263+
PROCESS_SWITCH(HfTaskDstarToD0Pi, processWoML, "Process without ML", true);
264+
265+
// process function with susing ML, Here we store BDT score as well
266+
void processWML(CollisionsWCent const& cols, soa::Filtered<CandDstarWSelFlagWMl> const& selectedCands)
267+
{
268+
runTaskDstar<true, soa::Filtered<CandDstarWSelFlagWMl>, Preslice<soa::Filtered<CandDstarWSelFlagWMl>>>(cols, selectedCands, preslicSelectedCandDstarPerColWMl);
269+
}
270+
PROCESS_SWITCH(HfTaskDstarToD0Pi, processWML, "Process with ML", false);
271+
240272
void processMC(aod::McCollisions const&, CollisionsWCentMcLabel const& collisions, CandDstarWSelFlagMcRec const&,
241273
CandDstarMcGen const& rowsMcPartilces,
242274
aod::TracksWMc const&)
@@ -259,6 +291,7 @@ struct HfTaskDstarToD0Pi {
259291
auto particleMother = rowsMcPartilces.rawIteratorAt(indexMother); // What is difference between rawIterator() or iteratorAt() methods?
260292
registry.fill(HIST("QA/hPtSkimDstarGenSig"), particleMother.pt()); // generator level pt
261293
registry.fill(HIST("Efficiency/hPtVsCentSkimDstarGenSig"), particleMother.pt(), centrality);
294+
registry.fill(HIST("Efficiency/hPtVsCentFullRecoDstarRecSig"), ptDstarRecSig, centrality);
262295

263296
// auto recCollision = candDstarMcRec.collision_as<CollisionsWCentMcLabel>();
264297
// float centFT0M = recCollision.centFT0M();

0 commit comments

Comments
 (0)