From 7208f8b8d0772c1acf721199ede640b44247e835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BiaoZhang=20=28=E5=BC=A0=E5=BD=AA=29?= <52267892+zhangbiao-phy@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:43:40 +0100 Subject: [PATCH] Refactor centrality and event status handling Updated comments and variable names related to centrality and event status for clarity. --- PWGHF/D2H/Tasks/taskD0.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/PWGHF/D2H/Tasks/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index 59778af1fa0..260f6b07fc2 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -100,7 +100,7 @@ struct HfTaskD0 { Configurable selectionPid{"selectionPid", 1, "Selection Flag for reco PID candidates"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; Configurable centEstimator{"centEstimator", 0, "Centrality estimation (None: 0, FT0C: 2, FT0M: 3)"}; - Configurable fillEventStatus{"fillEventStatus", false, "Use generated centrality in hSparseAcc and append reco-event status (requires storeCentrality)"}; + Configurable fillEventStatus{"fillEventStatus", false, "Append generated centrality and reco-event status to hSparseAcc (requires storeCentrality)"}; Configurable occEstimator{"occEstimator", 0, "Occupancy estimation (None: 0, ITS: 1, FT0C: 2)"}; Configurable storeCentrality{"storeCentrality", false, "Flag to store centrality information"}; Configurable storeOccupancyAndIR{"storeOccupancyAndIR", false, "Flag to store occupancy information and interaction rate"}; @@ -341,7 +341,7 @@ struct HfTaskD0 { std::vector axesAcc = {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin, thnAxisNumPvContr}; if (storeCentrality) { - axesAcc.emplace_back(thnConfigAxisCent, fillEventStatus ? "Generated centrality (%)" : "Centrality"); + axesAcc.emplace_back(thnConfigAxisCent, fillEventStatus ? "Reco centrality (%)" : "Centrality"); } // interaction rate only store in Data and MC Reco. Level if (storeOccupancyAndIR) { @@ -355,6 +355,7 @@ struct HfTaskD0 { if (centEstimator != CentralityEstimator::FT0C && centEstimator != CentralityEstimator::FT0M) { LOGP(fatal, "centEstimator must be FT0C (2) or FT0M (3)."); } + axesAcc.emplace_back(thnConfigAxisCent, "Generated centrality (%)"); axesAcc.emplace_back(3, -0.5, 2.5, "Reco event status (0: no reco, 1: none selected, 2: selected)"); } registry.add("hSparseAcc", "Thn for generated D0 from charm and beauty", HistType::kTHnSparseD, axesAcc); @@ -1315,6 +1316,7 @@ struct HfTaskD0 { registry.fill(HIST("hPtVsYGen"), ptGen, yGen); int eventStatus = NoRecoCollision; + float centGen{-1.f}; unsigned maxNumContrib = 0; float cent{-1.f}; @@ -1341,14 +1343,15 @@ struct HfTaskD0 { const auto mcCollision = particle.template mcCollision_as(); const auto eventEntry = recoEventStatus.find(mcCollision.globalIndex()); eventStatus = eventEntry == recoEventStatus.end() ? NoRecoCollision : eventEntry->second; - // Replace the existing centrality coordinate, including zero-reco events. - cent = centEstimator == CentralityEstimator::FT0C ? mcCollision.centFT0C() : mcCollision.centFT0M(); + // Append generated centrality; retain the existing reco-centrality coordinate. + centGen = centEstimator == CentralityEstimator::FT0C ? mcCollision.centFT0C() : mcCollision.centFT0M(); } + const auto histSparseAcc = HIST("hSparseAcc"); const auto fillGeneratedSparse = [&](auto... coordinates) { if (fillEventStatus) { - registry.fill(HIST("hSparseAcc"), coordinates..., eventStatus); + registry.fill(histSparseAcc, coordinates..., centGen, eventStatus); } else { - registry.fill(HIST("hSparseAcc"), coordinates...); + registry.fill(histSparseAcc, coordinates...); } };