From 372827d6f360480d1aa09715918cb87707b67511 Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Sun, 8 Nov 2026 13:18:09 -0500 Subject: [PATCH 1/8] PWGCF: add q-space K+K- pair task (Q_inv, Q_long, Q_out, Q_side), first version Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Tpx2ZQ7HXMcQXLLUbEx35H --- .../Core/QSpaceKinematics.h | 93 +++++++++ .../Tasks/CMakeLists.txt | 5 + .../Tasks/qSpaceBalanceFunction.cxx | 176 ++++++++++++++++++ 3 files changed, 274 insertions(+) create mode 100644 PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h create mode 100644 PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx diff --git a/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h b/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h new file mode 100644 index 00000000000..7b8eb2ea232 --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h @@ -0,0 +1,93 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file QSpaceKinematics.h +/// \brief Relative momentum of a particle pair in the pair rest frame (Q_inv, Q_long, Q_out, Q_side) +/// \author Lakshitha Fernando +/// +/// Definitions follow Pratt and Cheng, PRC 68 (2003) 014907 and Pruneau et al., PRC 107 (2023) 014902. +/// The projection steps follow newpairfunc() in PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h. + +#ifndef PWGCF_TWOPARTICLECORRELATIONS_CORE_QSPACEKINEMATICS_H_ +#define PWGCF_TWOPARTICLECORRELATIONS_CORE_QSPACEKINEMATICS_H_ + +#include +#include + +namespace o2::analysis::qspace +{ + +/// Pair variables in GeV/c (mass in GeV/c^2). The components are signed: exchanging the two particles flips them. +struct PairQ { + double qInv = 0.; ///< from Lorentz invariants, never from the components + double qLong = 0.; ///< along the beam axis + double qOut = 0.; ///< along the pair transverse momentum + double qSide = 0.; ///< transverse, perpendicular to out; (out, side, long) is right-handed + double mass = 0.; ///< pair invariant mass +}; + +/// Computes the pair variables of particle 1 relative to particle 2. +/// Sequence: Bertsch-Pratt axes, boost along the beam to the frame where the pair has P_z = 0 (LCMS), +/// then boost along out to the pair rest frame, so that qLong^2 + qOut^2 + qSide^2 = qInv^2. +/// For equal masses qInv = 2 k*, with k* the momentum of either particle in the pair rest frame. +inline PairQ computePairQ(double pt1, double eta1, double phi1, double mass1, + double pt2, double eta2, double phi2, double mass2) +{ + const double px1 = pt1 * std::cos(phi1); + const double py1 = pt1 * std::sin(phi1); + const double pz1 = pt1 * std::sinh(eta1); + const double e1 = std::sqrt(px1 * px1 + py1 * py1 + pz1 * pz1 + mass1 * mass1); + const double px2 = pt2 * std::cos(phi2); + const double py2 = pt2 * std::sin(phi2); + const double pz2 = pt2 * std::sinh(eta2); + const double e2 = std::sqrt(px2 * px2 + py2 * py2 + pz2 * pz2 + mass2 * mass2); + + const double sumPx = px1 + px2; + const double sumPy = py1 + py2; + const double sumPz = pz1 + pz2; + const double sumE = e1 + e2; + const double diffPx = px1 - px2; + const double diffPy = py1 - py2; + const double diffPz = pz1 - pz2; + const double diffE = e1 - e2; + + const double pairPt2 = sumPx * sumPx + sumPy * sumPy; + const double pairPt = std::sqrt(pairPt2); + const double pairMt2 = sumE * sumE - sumPz * sumPz; + const double pairMt = std::sqrt(pairMt2); + const double pairS = pairMt2 - pairPt2; + + PairQ result; + result.mass = std::sqrt(std::max(pairS, 0.)); + + // invariant definition: Q_inv^2 = -(p1-p2)^2 + (m1^2-m2^2)^2/s + const double massTerm = mass1 * mass1 - mass2 * mass2; + const double qInv2 = diffPx * diffPx + diffPy * diffPy + diffPz * diffPz - diffE * diffE + massTerm * massTerm / pairS; + result.qInv = std::sqrt(std::max(qInv2, 0.)); + + // transverse axes; a pair with exactly zero transverse momentum has no out direction, then x is used + const double outX = pairPt > 0. ? sumPx / pairPt : 1.; + const double outY = pairPt > 0. ? sumPy / pairPt : 0.; + const double diffOut = diffPx * outX + diffPy * outY; + result.qSide = -diffPx * outY + diffPy * outX; + + // boost along the beam to P_z = 0: gamma = E/M_T, gamma*beta = P_z/M_T + result.qLong = (sumE * diffPz - sumPz * diffE) / pairMt; + const double diffELcms = (sumE * diffE - sumPz * diffPz) / pairMt; + + // boost along out to the rest frame: gamma = M_T/M, gamma*beta = P_T/M + result.qOut = (pairMt * diffOut - pairPt * diffELcms) / result.mass; + return result; +} + +} // namespace o2::analysis::qspace + +#endif // PWGCF_TWOPARTICLECORRELATIONS_CORE_QSPACEKINEMATICS_H_ diff --git a/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt b/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt index 8c283cecc40..cbd25a5b656 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt +++ b/PWGCF/TwoParticleCorrelations/Tasks/CMakeLists.txt @@ -43,6 +43,11 @@ o2physics_add_dpl_workflow(dpt-dpt-per-run-extra-qc PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(q-space-balance-function + SOURCES qSpaceBalanceFunction.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(corr-reso SOURCES corrReso.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore O2Physics::TwoPartCorrCore O2Physics::AnalysisCCDB diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx new file mode 100644 index 00000000000..171dbfdd8d1 --- /dev/null +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -0,0 +1,176 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file qSpaceBalanceFunction.cxx +/// \brief K+K- pair densities in Q_inv, Q_long, Q_out and Q_side, the inputs of q-space balance functions +/// \author Lakshitha Fernando +/// +/// Reads the tables of dpt-dpt-filter, which must run in the same workflow with only kaons enabled, +/// so that trackacceptedid is 0 for K+ and 1 for K-. +/// Pairs are ORDERED, as in dpt-dpt-correlations: every particle takes the role of particle 1 in turn. +/// Each of ++, +-, -+, -- is filled; an unordered like-sign pair therefore enters twice, an unordered +/// opposite-sign pair once in +- and once in -+. OS = (+-) + (-+) and LS = (++) + (--) are comparable. + +#include "PWGCF/DataModel/DptDptFiltered.h" +#include "PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace +{ +constexpr int NCharges = 2; +const std::array chargeTags{"P", "M"}; +enum IdCheckBin { + kIdCheckGood = 1, + kIdCheckNotKaonId, + kIdCheckWrongPdg +}; +} // namespace + +struct QSpaceBalanceFunction { + ConfigurableAxis cfgBinsQinv{"cfgBinsQinv", {2500, 0., 5.}, "Q_inv binning (GeV/c)"}; + ConfigurableAxis cfgBinsQComponent{"cfgBinsQComponent", {1000, -5., 5.}, "Q_long, Q_out, Q_side binning (GeV/c)"}; + ConfigurableAxis cfgBinsMass{"cfgBinsMass", {6000, 0., 6.}, "Pair invariant mass binning (GeV/c^2)"}; + ConfigurableAxis cfgBinsPt{"cfgBinsPt", {18, 0.2, 2.}, "pT binning (GeV/c)"}; + ConfigurableAxis cfgBinsEta{"cfgBinsEta", {16, -0.8, 0.8}, "Pseudorapidity binning"}; + ConfigurableAxis cfgBinsResidual{"cfgBinsResidual", {200, -1.e-10, 1.e-10}, "Residual binning (GeV^2/c^2)"}; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + using HistoPerCharge = std::array, NCharges>; + using Histo2DPerCharge = std::array, NCharges>; + using Histo2DPerPair = std::array; + using HistoPerPair = std::array; + + std::shared_ptr fhEvents; + std::shared_ptr fhIdCheck; + Histo2DPerCharge fhPtVsCent; + HistoPerCharge fhEta, fhPhi; + Histo2DPerPair fhQinv, fhQlong, fhQout, fhQside; + HistoPerPair fhMass, fhSumRuleResidual, fhMassRuleResidual; + + Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true)); + Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0)); + + void init(InitContext const&) + { + const AxisSpec axisCent{std::vector{0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1}, "multiplicity percentile"}; + const AxisSpec axisZ{28, -7., 7., "z_{vtx} (cm)"}; + const AxisSpec axisPt{cfgBinsPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisEta{cfgBinsEta, "#eta"}; + const AxisSpec axisPhi{72, 0., constants::math::TwoPI, "#varphi (rad)"}; + const AxisSpec axisQinv{cfgBinsQinv, "Q_{inv} (GeV/#it{c})"}; + const AxisSpec axisQlong{cfgBinsQComponent, "Q_{long} (GeV/#it{c})"}; + const AxisSpec axisQout{cfgBinsQComponent, "Q_{out} (GeV/#it{c})"}; + const AxisSpec axisQside{cfgBinsQComponent, "Q_{side} (GeV/#it{c})"}; + const AxisSpec axisMass{cfgBinsMass, "M_{KK} (GeV/#it{c}^{2})"}; + const AxisSpec axisResidual{cfgBinsResidual, "residual (GeV^{2}/#it{c}^{2})"}; + + fhEvents = registry.add("events/hZVsCent", "analysed events", kTH2D, {axisCent, axisZ}); + fhIdCheck = registry.add("singles/hIdCheck", "particle id check", kTH1D, {{3, 0.5, 3.5}}); + fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckGood, "kaon, id agrees with PDG"); + fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNotKaonId, "id is not 0 or 1"); + fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckWrongPdg, "id disagrees with PDG"); + + for (int charge1 = 0; charge1 < NCharges; ++charge1) { + const std::string& tag1 = chargeTags[charge1]; + fhPtVsCent[charge1] = registry.add(("singles/hPtVsCent_" + tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt}); + fhEta[charge1] = registry.add(("singles/hEta_" + tag1).c_str(), "kaon #eta", kTH1D, {axisEta}); + fhPhi[charge1] = registry.add(("singles/hPhi_" + tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi}); + for (int charge2 = 0; charge2 < NCharges; ++charge2) { + const std::string tag = tag1 + chargeTags[charge2]; + fhQinv[charge1][charge2] = registry.add(("pairs/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + fhQlong[charge1][charge2] = registry.add(("pairs/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + fhQout[charge1][charge2] = registry.add(("pairs/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + fhQside[charge1][charge2] = registry.add(("pairs/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + fhMass[charge1][charge2] = registry.add(("pairs/hMass_" + tag).c_str(), "ordered pairs", kTH1F, {axisMass}); + fhSumRuleResidual[charge1][charge2] = registry.add(("checks/hSumRuleResidual_" + tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + fhMassRuleResidual[charge1][charge2] = registry.add(("checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + } + } + } + + /// Fills singles and ordered pair histograms for one collision + template + void fillCollision(TCollision const& collision, TParticles const& particles) + { + const float centMult = collision.centmult(); + const double massKaon = constants::physics::MassKaonCharged; + fhEvents->Fill(centMult, collision.posZ()); + + for (auto const& particle1 : particles) { + const int charge1 = particle1.trackacceptedid(); + if (charge1 >= NCharges) { + fhIdCheck->Fill(kIdCheckNotKaonId); + continue; + } + fhIdCheck->Fill((particle1.pdgCode() == (charge1 == 0 ? kKPlus : kKMinus)) ? kIdCheckGood : kIdCheckWrongPdg); + fhPtVsCent[charge1]->Fill(centMult, particle1.pt()); + fhEta[charge1]->Fill(particle1.eta()); + fhPhi[charge1]->Fill(particle1.phi()); + + for (auto const& particle2 : particles) { + const int charge2 = particle2.trackacceptedid(); + if (charge2 >= NCharges || particle1.globalIndex() == particle2.globalIndex()) { + continue; + } + const auto pair = analysis::qspace::computePairQ(particle1.pt(), particle1.eta(), particle1.phi(), massKaon, + particle2.pt(), particle2.eta(), particle2.phi(), massKaon); + fhQinv[charge1][charge2]->Fill(centMult, pair.qInv); + fhQlong[charge1][charge2]->Fill(centMult, pair.qLong); + fhQout[charge1][charge2]->Fill(centMult, pair.qOut); + fhQside[charge1][charge2]->Fill(centMult, pair.qSide); + fhMass[charge1][charge2]->Fill(pair.mass); + const double qInvSquared = pair.qInv * pair.qInv; + fhSumRuleResidual[charge1][charge2]->Fill(pair.qLong * pair.qLong + pair.qOut * pair.qOut + pair.qSide * pair.qSide - qInvSquared); + fhMassRuleResidual[charge1][charge2]->Fill(pair.mass * pair.mass - 4. * massKaon * massKaon - qInvSquared); + } + } + } + + void processGenLevelNotStored(soa::Filtered>::iterator const& collision, + soa::Filtered> const& particles) + { + fillCollision(collision, particles); + } + PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelNotStored, "Generator level, filter tables made in the same workflow", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} From 8b3ab6e0e55ec9c4f4cf3e0356070b4a912826e6 Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Sun, 8 Nov 2026 20:53:47 +0000 Subject: [PATCH 2/8] PWGCF: add author email to q-space task files Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Tpx2ZSUeCZncb9cRCRUxvQ --- PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h | 2 +- PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h b/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h index 7b8eb2ea232..9d6d02a1a84 100644 --- a/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h +++ b/PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h @@ -11,7 +11,7 @@ /// \file QSpaceKinematics.h /// \brief Relative momentum of a particle pair in the pair rest frame (Q_inv, Q_long, Q_out, Q_side) -/// \author Lakshitha Fernando +/// \author Lakshitha Fernando /// /// Definitions follow Pratt and Cheng, PRC 68 (2003) 014907 and Pruneau et al., PRC 107 (2023) 014902. /// The projection steps follow newpairfunc() in PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h. diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index 171dbfdd8d1..c9406ea0737 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -11,7 +11,7 @@ /// \file qSpaceBalanceFunction.cxx /// \brief K+K- pair densities in Q_inv, Q_long, Q_out and Q_side, the inputs of q-space balance functions -/// \author Lakshitha Fernando +/// \author Lakshitha Fernando /// /// Reads the tables of dpt-dpt-filter, which must run in the same workflow with only kaons enabled, /// so that trackacceptedid is 0 for K+ and 1 for K-. From 09a12f1198241dccf3ca3e4e753b97f9899b65e1 Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Fri, 20 Nov 2026 15:58:30 -0500 Subject: [PATCH 3/8] PWGCF: q-space task, classify K+K- pairs by MC mother (phi, other decay, none) Beam and non-hadron mothers are rejected, same criterion as particleOriginAnalysis. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Tpx2ZQhMsissFM7LZMPFGi --- .../Tasks/qSpaceBalanceFunction.cxx | 106 +++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index c9406ea0737..dd8e160f7dc 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -18,6 +18,8 @@ /// Pairs are ORDERED, as in dpt-dpt-correlations: every particle takes the role of particle 1 in turn. /// Each of ++, +-, -+, -- is filled; an unordered like-sign pair therefore enters twice, an unordered /// opposite-sign pair once in +- and once in -+. OS = (+-) + (-+) and LS = (++) + (--) are comparable. +/// At generator level every pair is also classified by the mother particles of the two kaons: +/// phi pair (same mother, mother is a phi(1020)), other common mother, or no common mother. #include "PWGCF/DataModel/DptDptFiltered.h" #include "PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h" @@ -41,7 +43,9 @@ #include #include +#include #include +#include #include #include #include @@ -59,6 +63,26 @@ enum IdCheckBin { kIdCheckNotKaonId, kIdCheckWrongPdg }; +/// Pair origin classes from the MC mother of the two kaons +enum PairOrigin { + kPairPhi = 0, + kPairOtherCommonMother, + kPairNoCommonMother, + NPairOrigins +}; +const std::array pairOriginTags{"phi", "otherMother", "noCommonMother"}; +/// PDG codes above this value are hadrons; below are quarks, leptons, gauge bosons and generator-internal codes +static constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code) +/// Generator status codes of beam and event-setup entries (PYTHIA 11-19) and the HepMC beam status (4). +/// Same criterion as PWGCF/TwoParticleCorrelations/Tasks/particleOriginAnalysis.cxx (V. Gonzalez) +static constexpr int KBeamStatusCodeMin = 11; +static constexpr int KBeamStatusCodeMax = 19; +static constexpr int KHepMCBeamStatusCode = 4; +/// Mother of a particle: global index (-1 if none) and PDG code (0 if none) +struct MotherInfo { + int64_t index = -1; + int pdgCode = 0; +}; } // namespace struct QSpaceBalanceFunction { @@ -82,6 +106,10 @@ struct QSpaceBalanceFunction { HistoPerCharge fhEta, fhPhi; Histo2DPerPair fhQinv, fhQlong, fhQout, fhQside; HistoPerPair fhMass, fhSumRuleResidual, fhMassRuleResidual; + /// pair histograms split by pair origin (generator level only): [origin][charge1][charge2] + std::array fhQinvOrigin, fhQlongOrigin, fhQoutOrigin, fhQsideOrigin; + HistoPerCharge fhPtFromPhi; + std::shared_ptr fhCommonMotherPdg; Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true)); Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0)); @@ -122,17 +150,65 @@ struct QSpaceBalanceFunction { fhMassRuleResidual[charge1][charge2] = registry.add(("checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); } } + if (doprocessGenLevelNotStored.value) { + for (int origin = 0; origin < NPairOrigins; ++origin) { + for (int charge1 = 0; charge1 < NCharges; ++charge1) { + for (int charge2 = 0; charge2 < NCharges; ++charge2) { + const std::string tag = chargeTags[charge1] + chargeTags[charge2] + "_" + pairOriginTags[origin]; + fhQinvOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + fhQlongOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + fhQoutOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + fhQsideOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + } + } + } + for (int charge = 0; charge < NCharges; ++charge) { + fhPtFromPhi[charge] = registry.add(("singles/hPtFromPhi_" + chargeTags[charge]).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt}); + } + fhCommonMotherPdg = registry.add("pairsByOrigin/hCommonMotherPdg", "|PDG code| of the common mother, ordered pairs (overflow = |PDG| >= 10000)", kTH1D, {{10000, 0., 10000.}}); + } + } + + /// Decay mother of a generated particle, looked up in the unfiltered particle table of the same MC collision. + /// Only hadronic, non-beam mothers count: in the stored MC record, hadrons produced directly in string fragmentation + /// point to a beam proton, which would otherwise make unrelated kaons share a "mother". + template + static MotherInfo findMother(TParticle const& particle, TAllParticles const& allParticles) + { + MotherInfo info; + const auto& motherIds = particle.mothersIds(); + if (motherIds.size() == 0 || motherIds[0] < 0) { + return info; + } + const int64_t localIndex = motherIds[0] - static_cast(allParticles.offset()); + if (localIndex < 0 || localIndex >= static_cast(allParticles.size())) { + return info; // mother outside this MC collision: treat as unknown + } + const auto mother = allParticles.rawIteratorAt(localIndex); + const int genStatus = mother.getGenStatusCode(); + const bool isBeam = (genStatus >= KBeamStatusCodeMin && genStatus <= KBeamStatusCodeMax) || mother.getHepMCStatusCode() == KHepMCBeamStatusCode; + if (isBeam || std::abs(mother.pdgCode()) <= KPdgHadronThreshold) { + return info; // beam particle or parton/string entry: not a decay mother, the particle counts as having no mother + } + info.index = motherIds[0]; + info.pdgCode = mother.pdgCode(); + return info; } /// Fills singles and ordered pair histograms for one collision + /// mothers is empty when the mother information is not available (detector level); otherwise mothers[i] belongs to + /// the i-th particle of the iteration template - void fillCollision(TCollision const& collision, TParticles const& particles) + void fillCollision(TCollision const& collision, TParticles const& particles, std::vector const& mothers) { const float centMult = collision.centmult(); const double massKaon = constants::physics::MassKaonCharged; + const bool withOrigin = !mothers.empty(); fhEvents->Fill(centMult, collision.posZ()); + std::size_t position1 = 0; for (auto const& particle1 : particles) { + const std::size_t index1 = position1++; const int charge1 = particle1.trackacceptedid(); if (charge1 >= NCharges) { fhIdCheck->Fill(kIdCheckNotKaonId); @@ -142,8 +218,13 @@ struct QSpaceBalanceFunction { fhPtVsCent[charge1]->Fill(centMult, particle1.pt()); fhEta[charge1]->Fill(particle1.eta()); fhPhi[charge1]->Fill(particle1.phi()); + if (withOrigin && mothers[index1].pdgCode == o2::constants::physics::Pdg::kPhi) { + fhPtFromPhi[charge1]->Fill(particle1.pt()); + } + std::size_t position2 = 0; for (auto const& particle2 : particles) { + const std::size_t index2 = position2++; const int charge2 = particle2.trackacceptedid(); if (charge2 >= NCharges || particle1.globalIndex() == particle2.globalIndex()) { continue; @@ -158,14 +239,33 @@ struct QSpaceBalanceFunction { const double qInvSquared = pair.qInv * pair.qInv; fhSumRuleResidual[charge1][charge2]->Fill(pair.qLong * pair.qLong + pair.qOut * pair.qOut + pair.qSide * pair.qSide - qInvSquared); fhMassRuleResidual[charge1][charge2]->Fill(pair.mass * pair.mass - 4. * massKaon * massKaon - qInvSquared); + if (withOrigin) { + const MotherInfo& mother1 = mothers[index1]; + const bool commonMother = (mother1.index >= 0) && (mother1.index == mothers[index2].index); + int origin = kPairNoCommonMother; + if (commonMother) { + origin = (mother1.pdgCode == o2::constants::physics::Pdg::kPhi) ? kPairPhi : kPairOtherCommonMother; + fhCommonMotherPdg->Fill(std::abs(mother1.pdgCode)); + } + fhQinvOrigin[origin][charge1][charge2]->Fill(centMult, pair.qInv); + fhQlongOrigin[origin][charge1][charge2]->Fill(centMult, pair.qLong); + fhQoutOrigin[origin][charge1][charge2]->Fill(centMult, pair.qOut); + fhQsideOrigin[origin][charge1][charge2]->Fill(centMult, pair.qSide); + } } } } void processGenLevelNotStored(soa::Filtered>::iterator const& collision, - soa::Filtered> const& particles) + soa::Filtered> const& particles, + soa::Join const& allParticles) { - fillCollision(collision, particles); + std::vector mothers; + mothers.reserve(particles.size()); + for (auto const& particle : particles) { + mothers.push_back(findMother(particle, allParticles)); + } + fillCollision(collision, particles, mothers); } PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelNotStored, "Generator level, filter tables made in the same workflow", true); }; From bdb49150f6e33664421755115f7e2a7d2ab223aa Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Fri, 20 Nov 2026 16:19:11 -0500 Subject: [PATCH 4/8] PWGCF: q-space task, detector level of MC with truth matching, pair purity and Q resolution Histograms grouped per level (generator at top level, detector under rec/); MC origin split at both levels; split tracks never count as a common mother. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Tpx2ZQhMsissFM7LZMPFGi --- .../Tasks/qSpaceBalanceFunction.cxx | 278 ++++++++++++------ 1 file changed, 191 insertions(+), 87 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index dd8e160f7dc..9874cbfceba 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -18,8 +18,10 @@ /// Pairs are ORDERED, as in dpt-dpt-correlations: every particle takes the role of particle 1 in turn. /// Each of ++, +-, -+, -- is filled; an unordered like-sign pair therefore enters twice, an unordered /// opposite-sign pair once in +- and once in -+. OS = (+-) + (-+) and LS = (++) + (--) are comparable. -/// At generator level every pair is also classified by the mother particles of the two kaons: -/// phi pair (same mother, mother is a phi(1020)), other common mother, or no common mother. +/// Every pair is also classified by the MC mothers of the two kaons: phi pair (same mother, a phi(1020)), +/// other common mother, or no common mother. At detector level (processRecLevelMcNotStored) the mothers come from the +/// MC particles matched to the tracks, the true species gives the pair purity, and the true momenta give the +/// resolution Q_rec - Q_true. Detector-level histograms are stored under rec/, generator-level ones at the top level. #include "PWGCF/DataModel/DptDptFiltered.h" #include "PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h" @@ -61,7 +63,8 @@ const std::array chargeTags{"P", "M"}; enum IdCheckBin { kIdCheckGood = 1, kIdCheckNotKaonId, - kIdCheckWrongPdg + kIdCheckWrongPdg, + kIdCheckNoMcTruth }; /// Pair origin classes from the MC mother of the two kaons enum PairOrigin { @@ -71,6 +74,13 @@ enum PairOrigin { NPairOrigins }; const std::array pairOriginTags{"phi", "otherMother", "noCommonMother"}; +/// MC truth of a detector-level pair +enum PairTruthBin { + kPairBothTrueKaons = 1, + kPairMisidentified, + kPairUnmatched, + kPairSameMcParticle +}; /// PDG codes above this value are hadrons; below are quarks, leptons, gauge bosons and generator-internal codes static constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code) /// Generator status codes of beam and event-setup entries (PYTHIA 11-19) and the HepMC beam status (4). @@ -83,6 +93,37 @@ struct MotherInfo { int64_t index = -1; int pdgCode = 0; }; +/// MC truth of one accepted particle (generator level) or track (detector level), computed once per collision +struct TruthInfo { + bool hasMc = false; ///< generator level: always; detector level: the track has an MC label + int64_t mcIndex = -1; ///< global index of the MC particle + int pdgCode = 0; ///< true PDG code + float pt = 0.f; ///< true kinematics + float eta = 0.f; + float phi = 0.f; + MotherInfo mother; +}; +/// All histograms of one level (generator or detector) +struct PairHistos { + using HistoPerCharge = std::array, NCharges>; + using Histo2DPerCharge = std::array, NCharges>; + using Histo2DPerPair = std::array; + using HistoPerPair = std::array; + bool booked = false; + bool withResolution = false; + std::shared_ptr fhEvents; + std::shared_ptr fhIdCheck; + Histo2DPerCharge fhPtVsCent; + HistoPerCharge fhEta, fhPhi, fhPtFromPhi; + Histo2DPerPair fhQinv, fhQlong, fhQout, fhQside; + HistoPerPair fhMass, fhSumRuleResidual, fhMassRuleResidual; + /// pair histograms split by pair origin: [origin][charge1][charge2] + std::array fhQinvOrigin, fhQlongOrigin, fhQoutOrigin, fhQsideOrigin; + std::shared_ptr fhCommonMotherPdg; + /// detector level only: pair truth status and resolution (Q_true, Q_rec - Q_true) for pairs of two true kaons + HistoPerPair fhPairTruth; + Histo2DPerPair fhResQinv, fhResQlong, fhResQout, fhResQside; +}; } // namespace struct QSpaceBalanceFunction { @@ -92,29 +133,20 @@ struct QSpaceBalanceFunction { ConfigurableAxis cfgBinsPt{"cfgBinsPt", {18, 0.2, 2.}, "pT binning (GeV/c)"}; ConfigurableAxis cfgBinsEta{"cfgBinsEta", {16, -0.8, 0.8}, "Pseudorapidity binning"}; ConfigurableAxis cfgBinsResidual{"cfgBinsResidual", {200, -1.e-10, 1.e-10}, "Residual binning (GeV^2/c^2)"}; + ConfigurableAxis cfgBinsQinvTrue{"cfgBinsQinvTrue", {50, 0., 1.}, "true Q_inv binning of the resolution maps (GeV/c)"}; + ConfigurableAxis cfgBinsQComponentTrue{"cfgBinsQComponentTrue", {50, -1., 1.}, "true Q component binning of the resolution maps (GeV/c)"}; + ConfigurableAxis cfgBinsQResolution{"cfgBinsQResolution", {200, -0.05, 0.05}, "Q_rec - Q_true binning (GeV/c)"}; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - using HistoPerCharge = std::array, NCharges>; - using Histo2DPerCharge = std::array, NCharges>; - using Histo2DPerPair = std::array; - using HistoPerPair = std::array; - - std::shared_ptr fhEvents; - std::shared_ptr fhIdCheck; - Histo2DPerCharge fhPtVsCent; - HistoPerCharge fhEta, fhPhi; - Histo2DPerPair fhQinv, fhQlong, fhQout, fhQside; - HistoPerPair fhMass, fhSumRuleResidual, fhMassRuleResidual; - /// pair histograms split by pair origin (generator level only): [origin][charge1][charge2] - std::array fhQinvOrigin, fhQlongOrigin, fhQoutOrigin, fhQsideOrigin; - HistoPerCharge fhPtFromPhi; - std::shared_ptr fhCommonMotherPdg; + PairHistos genHistos; ///< generator level, top-level folders (as before the detector level existed) + PairHistos recHistos; ///< detector level, folder rec/ Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true)); Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0)); - void init(InitContext const&) + /// Books the histograms of one level under the folder prefix ("" or "rec/") + void bookHistos(PairHistos& histos, const std::string& prefix, bool withResolution) { const AxisSpec axisCent{std::vector{0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1}, "multiplicity percentile"}; const AxisSpec axisZ{28, -7., 7., "z_{vtx} (cm)"}; @@ -128,48 +160,66 @@ struct QSpaceBalanceFunction { const AxisSpec axisMass{cfgBinsMass, "M_{KK} (GeV/#it{c}^{2})"}; const AxisSpec axisResidual{cfgBinsResidual, "residual (GeV^{2}/#it{c}^{2})"}; - fhEvents = registry.add("events/hZVsCent", "analysed events", kTH2D, {axisCent, axisZ}); - fhIdCheck = registry.add("singles/hIdCheck", "particle id check", kTH1D, {{3, 0.5, 3.5}}); - fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckGood, "kaon, id agrees with PDG"); - fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNotKaonId, "id is not 0 or 1"); - fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckWrongPdg, "id disagrees with PDG"); - + histos.withResolution = withResolution; + histos.fhEvents = registry.add((prefix + "events/hZVsCent").c_str(), "analysed events", kTH2D, {axisCent, axisZ}); + histos.fhIdCheck = registry.add((prefix + "singles/hIdCheck").c_str(), "particle id vs MC truth", kTH1D, {{4, 0.5, 4.5}}); + histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckGood, "kaon, id agrees with true PDG"); + histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNotKaonId, "id is not 0 or 1"); + histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckWrongPdg, "id disagrees with true PDG"); + histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNoMcTruth, "no MC label"); for (int charge1 = 0; charge1 < NCharges; ++charge1) { const std::string& tag1 = chargeTags[charge1]; - fhPtVsCent[charge1] = registry.add(("singles/hPtVsCent_" + tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt}); - fhEta[charge1] = registry.add(("singles/hEta_" + tag1).c_str(), "kaon #eta", kTH1D, {axisEta}); - fhPhi[charge1] = registry.add(("singles/hPhi_" + tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi}); + histos.fhPtVsCent[charge1] = registry.add((prefix + "singles/hPtVsCent_" + tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt}); + histos.fhEta[charge1] = registry.add((prefix + "singles/hEta_" + tag1).c_str(), "kaon #eta", kTH1D, {axisEta}); + histos.fhPhi[charge1] = registry.add((prefix + "singles/hPhi_" + tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi}); + histos.fhPtFromPhi[charge1] = registry.add((prefix + "singles/hPtFromPhi_" + tag1).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt}); for (int charge2 = 0; charge2 < NCharges; ++charge2) { const std::string tag = tag1 + chargeTags[charge2]; - fhQinv[charge1][charge2] = registry.add(("pairs/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); - fhQlong[charge1][charge2] = registry.add(("pairs/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); - fhQout[charge1][charge2] = registry.add(("pairs/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); - fhQside[charge1][charge2] = registry.add(("pairs/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); - fhMass[charge1][charge2] = registry.add(("pairs/hMass_" + tag).c_str(), "ordered pairs", kTH1F, {axisMass}); - fhSumRuleResidual[charge1][charge2] = registry.add(("checks/hSumRuleResidual_" + tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); - fhMassRuleResidual[charge1][charge2] = registry.add(("checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + histos.fhQinv[charge1][charge2] = registry.add((prefix + "pairs/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + histos.fhQlong[charge1][charge2] = registry.add((prefix + "pairs/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + histos.fhQout[charge1][charge2] = registry.add((prefix + "pairs/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + histos.fhQside[charge1][charge2] = registry.add((prefix + "pairs/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + histos.fhMass[charge1][charge2] = registry.add((prefix + "pairs/hMass_" + tag).c_str(), "ordered pairs", kTH1F, {axisMass}); + histos.fhSumRuleResidual[charge1][charge2] = registry.add((prefix + "checks/hSumRuleResidual_" + tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + histos.fhMassRuleResidual[charge1][charge2] = registry.add((prefix + "checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + for (int origin = 0; origin < NPairOrigins; ++origin) { + const std::string originTag = tag + "_" + pairOriginTags[origin]; + histos.fhQinvOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQinv_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + histos.fhQlongOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQlong_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + histos.fhQoutOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQout_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + histos.fhQsideOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQside_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + } + if (withResolution) { + const AxisSpec axisQinvTrue{cfgBinsQinvTrue, "true Q_{inv} (GeV/#it{c})"}; + const AxisSpec axisQComponentTrue{cfgBinsQComponentTrue, "true Q component (GeV/#it{c})"}; + const AxisSpec axisResolution{cfgBinsQResolution, "Q_{rec} - Q_{true} (GeV/#it{c})"}; + histos.fhPairTruth[charge1][charge2] = registry.add((prefix + "resolution/hPairTruth_" + tag).c_str(), "ordered pairs by MC truth", kTH1D, {{4, 0.5, 4.5}}); + histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairBothTrueKaons, "both true kaons, right charge"); + histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairMisidentified, "at least one misidentified"); + histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairUnmatched, "at least one without MC label"); + histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairSameMcParticle, "both tracks from one MC particle"); + histos.fhResQinv[charge1][charge2] = registry.add((prefix + "resolution/hResQinv_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQinvTrue, axisResolution}); + histos.fhResQlong[charge1][charge2] = registry.add((prefix + "resolution/hResQlong_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + histos.fhResQout[charge1][charge2] = registry.add((prefix + "resolution/hResQout_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + histos.fhResQside[charge1][charge2] = registry.add((prefix + "resolution/hResQside_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + } } } + histos.fhCommonMotherPdg = registry.add((prefix + "pairsByOrigin/hCommonMotherPdg").c_str(), "|PDG code| of the common mother, ordered pairs (overflow = |PDG| >= 10000)", kTH1D, {{10000, 0., 10000.}}); + histos.booked = true; + } + + void init(InitContext const&) + { if (doprocessGenLevelNotStored.value) { - for (int origin = 0; origin < NPairOrigins; ++origin) { - for (int charge1 = 0; charge1 < NCharges; ++charge1) { - for (int charge2 = 0; charge2 < NCharges; ++charge2) { - const std::string tag = chargeTags[charge1] + chargeTags[charge2] + "_" + pairOriginTags[origin]; - fhQinvOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); - fhQlongOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); - fhQoutOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); - fhQsideOrigin[origin][charge1][charge2] = registry.add(("pairsByOrigin/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); - } - } - } - for (int charge = 0; charge < NCharges; ++charge) { - fhPtFromPhi[charge] = registry.add(("singles/hPtFromPhi_" + chargeTags[charge]).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt}); - } - fhCommonMotherPdg = registry.add("pairsByOrigin/hCommonMotherPdg", "|PDG code| of the common mother, ordered pairs (overflow = |PDG| >= 10000)", kTH1D, {{10000, 0., 10000.}}); + bookHistos(genHistos, "", false); + } + if (doprocessRecLevelMcNotStored.value) { + bookHistos(recHistos, "rec/", true); } } - /// Decay mother of a generated particle, looked up in the unfiltered particle table of the same MC collision. + /// Decay mother of an MC particle, looked up in the particle table given (one MC collision or the whole table). /// Only hadronic, non-beam mothers count: in the stored MC record, hadrons produced directly in string fragmentation /// point to a beam proton, which would otherwise make unrelated kaons share a "mother". template @@ -182,7 +232,7 @@ struct QSpaceBalanceFunction { } const int64_t localIndex = motherIds[0] - static_cast(allParticles.offset()); if (localIndex < 0 || localIndex >= static_cast(allParticles.size())) { - return info; // mother outside this MC collision: treat as unknown + return info; // mother outside the table given: treat as unknown } const auto mother = allParticles.rawIteratorAt(localIndex); const int genStatus = mother.getGenStatusCode(); @@ -195,31 +245,46 @@ struct QSpaceBalanceFunction { return info; } - /// Fills singles and ordered pair histograms for one collision - /// mothers is empty when the mother information is not available (detector level); otherwise mothers[i] belongs to - /// the i-th particle of the iteration + /// Truth of one MC particle + template + static TruthInfo truthOf(TMcParticle const& mcParticle, TAllParticles const& allParticles) + { + TruthInfo truth; + truth.hasMc = true; + truth.mcIndex = mcParticle.globalIndex(); + truth.pdgCode = mcParticle.pdgCode(); + truth.pt = mcParticle.pt(); + truth.eta = mcParticle.eta(); + truth.phi = mcParticle.phi(); + truth.mother = findMother(mcParticle, allParticles); + return truth; + } + + /// Fills singles and ordered pair histograms of one level for one collision; truth[i] belongs to the i-th particle template - void fillCollision(TCollision const& collision, TParticles const& particles, std::vector const& mothers) + void fillCollision(PairHistos& histos, TCollision const& collision, TParticles const& particles, std::vector const& truth) { const float centMult = collision.centmult(); const double massKaon = constants::physics::MassKaonCharged; - const bool withOrigin = !mothers.empty(); - fhEvents->Fill(centMult, collision.posZ()); + histos.fhEvents->Fill(centMult, collision.posZ()); std::size_t position1 = 0; for (auto const& particle1 : particles) { const std::size_t index1 = position1++; const int charge1 = particle1.trackacceptedid(); if (charge1 >= NCharges) { - fhIdCheck->Fill(kIdCheckNotKaonId); + histos.fhIdCheck->Fill(kIdCheckNotKaonId); continue; } - fhIdCheck->Fill((particle1.pdgCode() == (charge1 == 0 ? kKPlus : kKMinus)) ? kIdCheckGood : kIdCheckWrongPdg); - fhPtVsCent[charge1]->Fill(centMult, particle1.pt()); - fhEta[charge1]->Fill(particle1.eta()); - fhPhi[charge1]->Fill(particle1.phi()); - if (withOrigin && mothers[index1].pdgCode == o2::constants::physics::Pdg::kPhi) { - fhPtFromPhi[charge1]->Fill(particle1.pt()); + const TruthInfo& truth1 = truth[index1]; + const int expectedPdg1 = (charge1 == 0) ? kKPlus : kKMinus; + const bool trueKaon1 = truth1.hasMc && truth1.pdgCode == expectedPdg1; + histos.fhIdCheck->Fill(!truth1.hasMc ? kIdCheckNoMcTruth : (trueKaon1 ? kIdCheckGood : kIdCheckWrongPdg)); + histos.fhPtVsCent[charge1]->Fill(centMult, particle1.pt()); + histos.fhEta[charge1]->Fill(particle1.eta()); + histos.fhPhi[charge1]->Fill(particle1.phi()); + if (truth1.mother.pdgCode == o2::constants::physics::Pdg::kPhi) { + histos.fhPtFromPhi[charge1]->Fill(particle1.pt()); } std::size_t position2 = 0; @@ -229,28 +294,50 @@ struct QSpaceBalanceFunction { if (charge2 >= NCharges || particle1.globalIndex() == particle2.globalIndex()) { continue; } + const TruthInfo& truth2 = truth[index2]; const auto pair = analysis::qspace::computePairQ(particle1.pt(), particle1.eta(), particle1.phi(), massKaon, particle2.pt(), particle2.eta(), particle2.phi(), massKaon); - fhQinv[charge1][charge2]->Fill(centMult, pair.qInv); - fhQlong[charge1][charge2]->Fill(centMult, pair.qLong); - fhQout[charge1][charge2]->Fill(centMult, pair.qOut); - fhQside[charge1][charge2]->Fill(centMult, pair.qSide); - fhMass[charge1][charge2]->Fill(pair.mass); + histos.fhQinv[charge1][charge2]->Fill(centMult, pair.qInv); + histos.fhQlong[charge1][charge2]->Fill(centMult, pair.qLong); + histos.fhQout[charge1][charge2]->Fill(centMult, pair.qOut); + histos.fhQside[charge1][charge2]->Fill(centMult, pair.qSide); + histos.fhMass[charge1][charge2]->Fill(pair.mass); const double qInvSquared = pair.qInv * pair.qInv; - fhSumRuleResidual[charge1][charge2]->Fill(pair.qLong * pair.qLong + pair.qOut * pair.qOut + pair.qSide * pair.qSide - qInvSquared); - fhMassRuleResidual[charge1][charge2]->Fill(pair.mass * pair.mass - 4. * massKaon * massKaon - qInvSquared); - if (withOrigin) { - const MotherInfo& mother1 = mothers[index1]; - const bool commonMother = (mother1.index >= 0) && (mother1.index == mothers[index2].index); - int origin = kPairNoCommonMother; - if (commonMother) { - origin = (mother1.pdgCode == o2::constants::physics::Pdg::kPhi) ? kPairPhi : kPairOtherCommonMother; - fhCommonMotherPdg->Fill(std::abs(mother1.pdgCode)); + histos.fhSumRuleResidual[charge1][charge2]->Fill(pair.qLong * pair.qLong + pair.qOut * pair.qOut + pair.qSide * pair.qSide - qInvSquared); + histos.fhMassRuleResidual[charge1][charge2]->Fill(pair.mass * pair.mass - 4. * massKaon * massKaon - qInvSquared); + + // origin: both truths known, two different MC particles (two tracks of one split particle are not a decay pair), same decay mother + const bool twoMcParticles = truth1.hasMc && truth2.hasMc && truth1.mcIndex != truth2.mcIndex; + const bool commonMother = twoMcParticles && truth1.mother.index >= 0 && truth1.mother.index == truth2.mother.index; + int origin = kPairNoCommonMother; + if (commonMother) { + origin = (truth1.mother.pdgCode == o2::constants::physics::Pdg::kPhi) ? kPairPhi : kPairOtherCommonMother; + histos.fhCommonMotherPdg->Fill(std::abs(truth1.mother.pdgCode)); + } + histos.fhQinvOrigin[origin][charge1][charge2]->Fill(centMult, pair.qInv); + histos.fhQlongOrigin[origin][charge1][charge2]->Fill(centMult, pair.qLong); + histos.fhQoutOrigin[origin][charge1][charge2]->Fill(centMult, pair.qOut); + histos.fhQsideOrigin[origin][charge1][charge2]->Fill(centMult, pair.qSide); + + if (histos.withResolution) { + const int expectedPdg2 = (charge2 == 0) ? kKPlus : kKMinus; + int status = kPairBothTrueKaons; + if (!truth1.hasMc || !truth2.hasMc) { + status = kPairUnmatched; + } else if (truth1.mcIndex == truth2.mcIndex) { + status = kPairSameMcParticle; + } else if (!trueKaon1 || truth2.pdgCode != expectedPdg2) { + status = kPairMisidentified; + } + histos.fhPairTruth[charge1][charge2]->Fill(status); + if (status == kPairBothTrueKaons) { + const auto pairTrue = analysis::qspace::computePairQ(truth1.pt, truth1.eta, truth1.phi, massKaon, + truth2.pt, truth2.eta, truth2.phi, massKaon); + histos.fhResQinv[charge1][charge2]->Fill(pairTrue.qInv, pair.qInv - pairTrue.qInv); + histos.fhResQlong[charge1][charge2]->Fill(pairTrue.qLong, pair.qLong - pairTrue.qLong); + histos.fhResQout[charge1][charge2]->Fill(pairTrue.qOut, pair.qOut - pairTrue.qOut); + histos.fhResQside[charge1][charge2]->Fill(pairTrue.qSide, pair.qSide - pairTrue.qSide); } - fhQinvOrigin[origin][charge1][charge2]->Fill(centMult, pair.qInv); - fhQlongOrigin[origin][charge1][charge2]->Fill(centMult, pair.qLong); - fhQoutOrigin[origin][charge1][charge2]->Fill(centMult, pair.qOut); - fhQsideOrigin[origin][charge1][charge2]->Fill(centMult, pair.qSide); } } } @@ -260,14 +347,31 @@ struct QSpaceBalanceFunction { soa::Filtered> const& particles, soa::Join const& allParticles) { - std::vector mothers; - mothers.reserve(particles.size()); + std::vector truth; + truth.reserve(particles.size()); for (auto const& particle : particles) { - mothers.push_back(findMother(particle, allParticles)); + truth.push_back(truthOf(particle, allParticles)); } - fillCollision(collision, particles, mothers); + fillCollision(genHistos, collision, particles, truth); } PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelNotStored, "Generator level, filter tables made in the same workflow", true); + + void processRecLevelMcNotStored(soa::Filtered>::iterator const& collision, + soa::Filtered> const& tracks, + aod::McParticles const& mcParticles) + { + std::vector truth; + truth.reserve(tracks.size()); + for (auto const& track : tracks) { + if (track.has_mcParticle()) { + truth.push_back(truthOf(track.template mcParticle_as(), mcParticles)); + } else { + truth.emplace_back(); + } + } + fillCollision(recHistos, collision, tracks, truth); + } + PROCESS_SWITCH(QSpaceBalanceFunction, processRecLevelMcNotStored, "Detector level of MC (tracks with MC labels), filter tables made in the same workflow", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 96cb109e6ef53a7a340c0a9bf78137d3d67edc3e Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Sat, 21 Nov 2026 15:00:37 -0500 Subject: [PATCH 5/8] PWGCF: q-space task, same/mixed-event pair densities per (zvtx, multiplicity) class --- .../Tasks/qSpaceBalanceFunction.cxx | 174 +++++++++++++++++- 1 file changed, 172 insertions(+), 2 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index 9874cbfceba..49e9ad65c5e 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -22,6 +22,16 @@ /// other common mother, or no common mother. At detector level (processRecLevelMcNotStored) the mothers come from the /// MC particles matched to the tracks, the true species gives the pair purity, and the true momenta give the /// resolution Q_rec - Q_true. Detector-level histograms are stored under rec/, generator-level ones at the top level. +/// +/// Balance-function inputs (folder bf/, rec/bf/): events are sorted into classes of (z_vtx, multiplicity percentile) +/// with the binning policy of the event mixing, class = iz + nz * imult. Per class the task stores +/// - same-event ordered pairs i != j (both orders, as above) vs Q: summed over events, their integral is +/// sum N_a (N_b - delta_ab), i.e. factorial moments for like-sign pairs; +/// - mixed-event ordered pairs: each unordered pair of events (e1, e2) of one class is filled in BOTH orders, +/// (a from e1, b from e2) and (a from e2, b from e1), so the reference per event is mixed / (2 x number of event pairs), +/// whose integral is , the uncorrelated product rho1 x rho1; +/// - events, event pairs, kaons per charge and sum N_a (N_b - delta_ab), for the normalisation and the integral checks. +/// Then rho2 = same / N_events, rho1rho1 = mixed / (2 N_eventPairs), C2 = rho2 - rho1rho1, A2^ab = C2^ab / , done offline. #include "PWGCF/DataModel/DptDptFiltered.h" #include "PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h" @@ -32,7 +42,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -50,6 +62,7 @@ #include #include #include +#include #include using namespace o2; @@ -103,6 +116,20 @@ struct TruthInfo { float phi = 0.f; MotherInfo mother; }; +/// Combination index of the per-class factorial moments sum N_a (N_b - delta_ab): PP, PM, MP, MM +constexpr int NChargeCombinations = NCharges * NCharges; +/// Balance-function inputs of one level, per event class (z_vtx, multiplicity) +struct BfHistos { + using Histo2DPerCharge = std::array, NCharges>; + using Histo2DPerPair = std::array; + std::shared_ptr fhEventsPerClass; ///< accepted events per class + std::shared_ptr fhEventsOutsideClasses; ///< events outside the class binning (not used in bf/) + std::shared_ptr fhMixedEventPairsPerClass; ///< unordered pairs of events mixed, per class + std::shared_ptr fhKaonsPerClass; ///< sum over events of N_a, per class and charge + std::shared_ptr fhFactorialPerClass; ///< sum over events of N_a (N_b - delta_ab), per class and charge combination + Histo2DPerPair fhSameQinv, fhSameQlong, fhSameQout, fhSameQside; + Histo2DPerPair fhMixedQinv, fhMixedQlong, fhMixedQout, fhMixedQside; +}; /// All histograms of one level (generator or detector) struct PairHistos { using HistoPerCharge = std::array, NCharges>; @@ -123,6 +150,7 @@ struct PairHistos { /// detector level only: pair truth status and resolution (Q_true, Q_rec - Q_true) for pairs of two true kaons HistoPerPair fhPairTruth; Histo2DPerPair fhResQinv, fhResQlong, fhResQout, fhResQside; + BfHistos bf; }; } // namespace @@ -136,6 +164,22 @@ struct QSpaceBalanceFunction { ConfigurableAxis cfgBinsQinvTrue{"cfgBinsQinvTrue", {50, 0., 1.}, "true Q_inv binning of the resolution maps (GeV/c)"}; ConfigurableAxis cfgBinsQComponentTrue{"cfgBinsQComponentTrue", {50, -1., 1.}, "true Q component binning of the resolution maps (GeV/c)"}; ConfigurableAxis cfgBinsQResolution{"cfgBinsQResolution", {200, -0.05, 0.05}, "Q_rec - Q_true binning (GeV/c)"}; + ConfigurableAxis cfgMixBinsZ{"cfgMixBinsZ", {VARIABLE_WIDTH, -7., -5., -3., -1., 1., 3., 5., 7.}, "z_vtx edges of the event classes (cm), same and mixed events"}; + ConfigurableAxis cfgMixBinsMult{"cfgMixBinsMult", {VARIABLE_WIDTH, 0., 1., 2., 5., 10., 15., 20., 30., 40., 50., 60., 70., 80., 90., 100.1}, "multiplicity percentile edges of the event classes, same and mixed events (the filter accepts 0-100%)"}; + Configurable cfgMixDepth{"cfgMixDepth", 10, "each event is mixed with the next cfgMixDepth events of its class"}; + + using BinningZMultGen = ColumnBinningPolicy; + using BinningZMultRec = ColumnBinningPolicy; + /// Plain members (not std::optional: the framework counts task members by brace initialisation, which std::optional breaks). + /// Built here with the configurable defaults and rebuilt in init from the configured values; under/overflow give class -1. + BinningZMultGen binningGen{{std::vector{VARIABLE_WIDTH, -7., 7.}, std::vector{VARIABLE_WIDTH, 0., 100.1}}, true}; + BinningZMultRec binningRec{{std::vector{VARIABLE_WIDTH, -7., 7.}, std::vector{VARIABLE_WIDTH, 0., 100.1}}, true}; + SliceCache cache; + + using GenCollisions = soa::Filtered>; + using GenParticles = soa::Filtered>; + using RecCollisions = soa::Filtered>; + using RecTracks = soa::Filtered>; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -206,19 +250,111 @@ struct QSpaceBalanceFunction { } } histos.fhCommonMotherPdg = registry.add((prefix + "pairsByOrigin/hCommonMotherPdg").c_str(), "|PDG code| of the common mother, ordered pairs (overflow = |PDG| >= 10000)", kTH1D, {{10000, 0., 10000.}}); + bookBfHistos(histos.bf, prefix + "bf/", axisQinv, axisQlong, axisQout, axisQside); histos.booked = true; } + /// Books the balance-function inputs of one level; the class axis follows the mixing binning + void bookBfHistos(BfHistos& bf, const std::string& prefix, const AxisSpec& axisQinv, const AxisSpec& axisQlong, const AxisSpec& axisQout, const AxisSpec& axisQside) + { + const int nClasses = binningGen.getAllBinsCount(); + const AxisSpec axisClass{nClasses, -0.5, nClasses - 0.5, "event class (iz + n_{z} imult)"}; + bf.fhEventsPerClass = registry.add((prefix + "hEventsPerClass").c_str(), "accepted events", kTH1D, {axisClass}); + bf.fhEventsOutsideClasses = registry.add((prefix + "hEventsOutsideClasses").c_str(), "events outside the class binning", kTH1D, {{1, 0.5, 1.5}}); + bf.fhMixedEventPairsPerClass = registry.add((prefix + "hMixedEventPairsPerClass").c_str(), "unordered event pairs mixed (each filled in both orders)", kTH1D, {axisClass}); + bf.fhKaonsPerClass = registry.add((prefix + "hKaonsPerClass").c_str(), "#sum N_{a}", kTH2D, {axisClass, {NCharges, -0.5, NCharges - 0.5, "charge (0 = K^{+}, 1 = K^{-})"}}); + bf.fhFactorialPerClass = registry.add((prefix + "hFactorialPerClass").c_str(), "#sum N_{a}(N_{b}-#delta_{ab})", kTH2D, {axisClass, {NChargeCombinations, -0.5, NChargeCombinations - 0.5, "ab (0 = PP, 1 = PM, 2 = MP, 3 = MM)"}}); + for (int charge1 = 0; charge1 < NCharges; ++charge1) { + for (int charge2 = 0; charge2 < NCharges; ++charge2) { + const std::string tag = chargeTags[charge1] + chargeTags[charge2]; + bf.fhSameQinv[charge1][charge2] = registry.add((prefix + "same/hQinv_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQinv}); + bf.fhSameQlong[charge1][charge2] = registry.add((prefix + "same/hQlong_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQlong}); + bf.fhSameQout[charge1][charge2] = registry.add((prefix + "same/hQout_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQout}); + bf.fhSameQside[charge1][charge2] = registry.add((prefix + "same/hQside_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQside}); + bf.fhMixedQinv[charge1][charge2] = registry.add((prefix + "mixed/hQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQinv}); + bf.fhMixedQlong[charge1][charge2] = registry.add((prefix + "mixed/hQlong_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQlong}); + bf.fhMixedQout[charge1][charge2] = registry.add((prefix + "mixed/hQout_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQout}); + bf.fhMixedQside[charge1][charge2] = registry.add((prefix + "mixed/hQside_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside}); + } + } + } + void init(InitContext const&) { - if (doprocessGenLevelNotStored.value) { + binningGen = BinningZMultGen{{cfgMixBinsZ.value, cfgMixBinsMult.value}, true}; + binningRec = BinningZMultRec{{cfgMixBinsZ.value, cfgMixBinsMult.value}, true}; + if (doprocessGenLevelNotStored.value || doprocessGenLevelMixedNotStored.value) { bookHistos(genHistos, "", false); } - if (doprocessRecLevelMcNotStored.value) { + if (doprocessRecLevelMcNotStored.value || doprocessRecLevelMixedNotStored.value) { bookHistos(recHistos, "rec/", true); } } + /// Fills ordered pairs (a from tracksA, b from tracksB) of one event class; for the same event the pair of a + /// particle with itself is skipped, so like-sign pairs count N(N-1) + template + void fillBfPairs(BfHistos& bf, int eventClass, TTracksA const& tracksA, TTracksB const& tracksB) + { + const double massKaon = constants::physics::MassKaonCharged; + for (auto const& particle1 : tracksA) { + const int charge1 = particle1.trackacceptedid(); + if (charge1 >= NCharges) { + continue; + } + for (auto const& particle2 : tracksB) { + const int charge2 = particle2.trackacceptedid(); + if (charge2 >= NCharges) { + continue; + } + if constexpr (sameEvent) { + if (particle1.globalIndex() == particle2.globalIndex()) { + continue; + } + } + const auto pair = analysis::qspace::computePairQ(particle1.pt(), particle1.eta(), particle1.phi(), massKaon, + particle2.pt(), particle2.eta(), particle2.phi(), massKaon); + if constexpr (sameEvent) { + bf.fhSameQinv[charge1][charge2]->Fill(eventClass, pair.qInv); + bf.fhSameQlong[charge1][charge2]->Fill(eventClass, pair.qLong); + bf.fhSameQout[charge1][charge2]->Fill(eventClass, pair.qOut); + bf.fhSameQside[charge1][charge2]->Fill(eventClass, pair.qSide); + } else { + bf.fhMixedQinv[charge1][charge2]->Fill(eventClass, pair.qInv); + bf.fhMixedQlong[charge1][charge2]->Fill(eventClass, pair.qLong); + bf.fhMixedQout[charge1][charge2]->Fill(eventClass, pair.qOut); + bf.fhMixedQside[charge1][charge2]->Fill(eventClass, pair.qSide); + } + } + } + } + + /// Same-event balance-function inputs of one collision: event and kaon counters, factorial moments, pairs + template + void fillBfSameEvent(BfHistos& bf, int eventClass, TParticles const& particles) + { + if (eventClass < 0) { + bf.fhEventsOutsideClasses->Fill(1.); + return; + } + std::array nKaons{0, 0}; + for (auto const& particle : particles) { + const int charge = particle.trackacceptedid(); + if (charge < NCharges) { + nKaons[charge]++; + } + } + bf.fhEventsPerClass->Fill(eventClass); + for (int charge1 = 0; charge1 < NCharges; ++charge1) { + bf.fhKaonsPerClass->Fill(eventClass, charge1, nKaons[charge1]); + for (int charge2 = 0; charge2 < NCharges; ++charge2) { + const int pairsInEvent = nKaons[charge1] * (nKaons[charge2] - (charge1 == charge2 ? 1 : 0)); + bf.fhFactorialPerClass->Fill(eventClass, charge1 * NCharges + charge2, pairsInEvent); + } + } + fillBfPairs(bf, eventClass, particles, particles); + } + /// Decay mother of an MC particle, looked up in the particle table given (one MC collision or the whole table). /// Only hadronic, non-beam mothers count: in the stored MC record, hadrons produced directly in string fragmentation /// point to a beam proton, which would otherwise make unrelated kaons share a "mother". @@ -353,6 +489,7 @@ struct QSpaceBalanceFunction { truth.push_back(truthOf(particle, allParticles)); } fillCollision(genHistos, collision, particles, truth); + fillBfSameEvent(genHistos.bf, binningGen.getBin(std::make_tuple(collision.posZ(), collision.centmult())), particles); } PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelNotStored, "Generator level, filter tables made in the same workflow", true); @@ -370,8 +507,41 @@ struct QSpaceBalanceFunction { } } fillCollision(recHistos, collision, tracks, truth); + fillBfSameEvent(recHistos.bf, binningRec.getBin(std::make_tuple(collision.posZ(), collision.centmult())), tracks); } PROCESS_SWITCH(QSpaceBalanceFunction, processRecLevelMcNotStored, "Detector level of MC (tracks with MC labels), filter tables made in the same workflow", false); + + /// Mixed events: SameKindPair pairs each accepted collision with the next cfgMixDepth collisions of the same class + /// (unordered, without repetition; collisions without kaons are paired too, so the event-pair count is unbiased) + template + void mixEvents(BfHistos& bf, TPairs& eventPairs, TBinning const& binning) + { + for (auto const& [collision1, tracks1, collision2, tracks2] : eventPairs) { + const int eventClass = binning.getBin(std::make_tuple(collision1.posZ(), collision1.centmult())); + if (eventClass < 0) { + continue; + } + bf.fhMixedEventPairsPerClass->Fill(eventClass); + fillBfPairs(bf, eventClass, tracks1, tracks2); + fillBfPairs(bf, eventClass, tracks2, tracks1); + } + } + + void processGenLevelMixedNotStored(GenCollisions const& collisions, GenParticles const& particles) + { + auto particlesTuple = std::make_tuple(particles); + SameKindPair eventPairs{binningGen, cfgMixDepth.value, -1, collisions, particlesTuple, &cache}; + mixEvents(genHistos.bf, eventPairs, binningGen); + } + PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelMixedNotStored, "Generator level mixed events, filter tables made in the same workflow", false); + + void processRecLevelMixedNotStored(RecCollisions const& collisions, RecTracks const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + SameKindPair eventPairs{binningRec, cfgMixDepth.value, -1, collisions, tracksTuple, &cache}; + mixEvents(recHistos.bf, eventPairs, binningRec); + } + PROCESS_SWITCH(QSpaceBalanceFunction, processRecLevelMixedNotStored, "Detector level mixed events, filter tables made in the same workflow", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From ab0d1b20a91e5ee6e007df80949a44e1ce6e45dc Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Sun, 22 Nov 2026 14:37:52 -0500 Subject: [PATCH 6/8] PWGCF: q-space task, own cross-DF mixing pool and event subsamples for statistical errors --- .../Tasks/qSpaceBalanceFunction.cxx | 207 +++++++++++------- 1 file changed, 127 insertions(+), 80 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index 49e9ad65c5e..eddee5214a5 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -27,11 +27,17 @@ /// with the binning policy of the event mixing, class = iz + nz * imult. Per class the task stores /// - same-event ordered pairs i != j (both orders, as above) vs Q: summed over events, their integral is /// sum N_a (N_b - delta_ab), i.e. factorial moments for like-sign pairs; -/// - mixed-event ordered pairs: each unordered pair of events (e1, e2) of one class is filled in BOTH orders, -/// (a from e1, b from e2) and (a from e2, b from e1), so the reference per event is mixed / (2 x number of event pairs), -/// whose integral is , the uncorrelated product rho1 x rho1; +/// - mixed-event ordered pairs: each event is mixed with the previous cfgMixDepth events of its class, kept in a pool +/// owned by the task, so mixing crosses data-frame boundaries (the framework's grouped combinations only pair events +/// within one data frame, which holds too few kaon events per class). Each unordered pair of events (e1, e2) is filled in +/// BOTH orders, (a from e1, b from e2) and (a from e2, b from e1), so the reference per event is +/// mixed / (2 x number of event pairs), whose integral is , the uncorrelated product rho1 x rho1. +/// Events without kaons enter the pool too, so the event-pair count is unbiased. /// - events, event pairs, kaons per charge and sum N_a (N_b - delta_ab), for the normalisation and the integral checks. /// Then rho2 = same / N_events, rho1rho1 = mixed / (2 N_eventPairs), C2 = rho2 - rho1rho1, A2^ab = C2^ab / , done offline. +/// Statistical errors: events are split into cfgNSubsamples subsamples (collision index modulo N; a mixed event pair goes to +/// the subsample of the newer event); the same inputs vs Q_inv only (coarser binning) are stored per subsample in bf/sub/, +/// so the spread of B between subsamples gives errors that include event-to-event fluctuations. #include "PWGCF/DataModel/DptDptFiltered.h" #include "PWGCF/TwoParticleCorrelations/Core/QSpaceKinematics.h" @@ -44,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +58,7 @@ #include #include +#include #include #include @@ -60,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +125,14 @@ struct TruthInfo { }; /// Combination index of the per-class factorial moments sum N_a (N_b - delta_ab): PP, PM, MP, MM constexpr int NChargeCombinations = NCharges * NCharges; +/// Kaon kept in the mixing pool +struct MixKaon { + float pt = 0.f; + float eta = 0.f; + float phi = 0.f; + int charge = 0; ///< 0 = K+, 1 = K- +}; +using MixEvent = std::vector; /// Balance-function inputs of one level, per event class (z_vtx, multiplicity) struct BfHistos { using Histo2DPerCharge = std::array, NCharges>; @@ -129,6 +144,14 @@ struct BfHistos { std::shared_ptr fhFactorialPerClass; ///< sum over events of N_a (N_b - delta_ab), per class and charge combination Histo2DPerPair fhSameQinv, fhSameQlong, fhSameQout, fhSameQside; Histo2DPerPair fhMixedQinv, fhMixedQlong, fhMixedQout, fhMixedQside; + /// subsamples (only if cfgNSubsamples > 0): axes (class, subsample, ...) + bool withSubsamples = false; + std::shared_ptr fhSubEvents; ///< events per (class, subsample) + std::shared_ptr fhSubEventPairs; ///< mixed event pairs per (class, subsample of the first event) + std::shared_ptr fhSubKaons; ///< sum N_a per (class, subsample, charge) + std::array, NCharges>, NCharges> fhSubSameQinv, fhSubMixedQinv; ///< (class, subsample, Q_inv) + /// mixing pool: per class, the last cfgMixDepth events (newest first) + std::vector> pool; }; /// All histograms of one level (generator or detector) struct PairHistos { @@ -166,7 +189,10 @@ struct QSpaceBalanceFunction { ConfigurableAxis cfgBinsQResolution{"cfgBinsQResolution", {200, -0.05, 0.05}, "Q_rec - Q_true binning (GeV/c)"}; ConfigurableAxis cfgMixBinsZ{"cfgMixBinsZ", {VARIABLE_WIDTH, -7., -5., -3., -1., 1., 3., 5., 7.}, "z_vtx edges of the event classes (cm), same and mixed events"}; ConfigurableAxis cfgMixBinsMult{"cfgMixBinsMult", {VARIABLE_WIDTH, 0., 1., 2., 5., 10., 15., 20., 30., 40., 50., 60., 70., 80., 90., 100.1}, "multiplicity percentile edges of the event classes, same and mixed events (the filter accepts 0-100%)"}; - Configurable cfgMixDepth{"cfgMixDepth", 10, "each event is mixed with the next cfgMixDepth events of its class"}; + Configurable cfgDoMixing{"cfgDoMixing", true, "mix each event with the previous events of its class (reference rho1 x rho1)"}; + Configurable cfgMixDepth{"cfgMixDepth", 10, "number of previous events of the same class each event is mixed with"}; + Configurable cfgNSubsamples{"cfgNSubsamples", 10, "number of event subsamples for statistical errors (0 = none)"}; + ConfigurableAxis cfgBinsQinvSub{"cfgBinsQinvSub", {100, 0., 2.}, "Q_inv binning of the subsample histograms (GeV/c)"}; using BinningZMultGen = ColumnBinningPolicy; using BinningZMultRec = ColumnBinningPolicy; @@ -174,12 +200,6 @@ struct QSpaceBalanceFunction { /// Built here with the configurable defaults and rebuilt in init from the configured values; under/overflow give class -1. BinningZMultGen binningGen{{std::vector{VARIABLE_WIDTH, -7., 7.}, std::vector{VARIABLE_WIDTH, 0., 100.1}}, true}; BinningZMultRec binningRec{{std::vector{VARIABLE_WIDTH, -7., 7.}, std::vector{VARIABLE_WIDTH, 0., 100.1}}, true}; - SliceCache cache; - - using GenCollisions = soa::Filtered>; - using GenParticles = soa::Filtered>; - using RecCollisions = soa::Filtered>; - using RecTracks = soa::Filtered>; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -262,6 +282,7 @@ struct QSpaceBalanceFunction { bf.fhEventsPerClass = registry.add((prefix + "hEventsPerClass").c_str(), "accepted events", kTH1D, {axisClass}); bf.fhEventsOutsideClasses = registry.add((prefix + "hEventsOutsideClasses").c_str(), "events outside the class binning", kTH1D, {{1, 0.5, 1.5}}); bf.fhMixedEventPairsPerClass = registry.add((prefix + "hMixedEventPairsPerClass").c_str(), "unordered event pairs mixed (each filled in both orders)", kTH1D, {axisClass}); + bf.pool.assign(nClasses, {}); bf.fhKaonsPerClass = registry.add((prefix + "hKaonsPerClass").c_str(), "#sum N_{a}", kTH2D, {axisClass, {NCharges, -0.5, NCharges - 0.5, "charge (0 = K^{+}, 1 = K^{-})"}}); bf.fhFactorialPerClass = registry.add((prefix + "hFactorialPerClass").c_str(), "#sum N_{a}(N_{b}-#delta_{ab})", kTH2D, {axisClass, {NChargeCombinations, -0.5, NChargeCombinations - 0.5, "ab (0 = PP, 1 = PM, 2 = MP, 3 = MM)"}}); for (int charge1 = 0; charge1 < NCharges; ++charge1) { @@ -277,61 +298,81 @@ struct QSpaceBalanceFunction { bf.fhMixedQside[charge1][charge2] = registry.add((prefix + "mixed/hQside_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside}); } } + if (cfgNSubsamples.value > 0) { + const int nSub = cfgNSubsamples.value; + const AxisSpec axisSub{nSub, -0.5, nSub - 0.5, "subsample"}; + const AxisSpec axisQinvSub{cfgBinsQinvSub, "Q_{inv} (GeV/#it{c})"}; + bf.withSubsamples = true; + bf.fhSubEvents = registry.add((prefix + "sub/hEvents").c_str(), "accepted events", kTH2D, {axisClass, axisSub}); + bf.fhSubEventPairs = registry.add((prefix + "sub/hMixedEventPairs").c_str(), "unordered event pairs mixed, subsample of the newer event", kTH2D, {axisClass, axisSub}); + bf.fhSubKaons = registry.add((prefix + "sub/hKaons").c_str(), "#sum N_{a}", kTH3D, {axisClass, axisSub, {NCharges, -0.5, NCharges - 0.5, "charge (0 = K^{+}, 1 = K^{-})"}}); + for (int charge1 = 0; charge1 < NCharges; ++charge1) { + for (int charge2 = 0; charge2 < NCharges; ++charge2) { + const std::string tag = chargeTags[charge1] + chargeTags[charge2]; + bf.fhSubSameQinv[charge1][charge2] = registry.add((prefix + "sub/hSameQinv_" + tag).c_str(), "same-event ordered pairs", kTH3F, {axisClass, axisSub, axisQinvSub}); + bf.fhSubMixedQinv[charge1][charge2] = registry.add((prefix + "sub/hMixedQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders", kTH3F, {axisClass, axisSub, axisQinvSub}); + } + } + } + } + + /// Subsample of a collision from its index (-1 if subsamples are off) + int subsampleOf(int64_t collisionIndex) const + { + return cfgNSubsamples.value > 0 ? static_cast(collisionIndex % cfgNSubsamples.value) : -1; } void init(InitContext const&) { binningGen = BinningZMultGen{{cfgMixBinsZ.value, cfgMixBinsMult.value}, true}; binningRec = BinningZMultRec{{cfgMixBinsZ.value, cfgMixBinsMult.value}, true}; - if (doprocessGenLevelNotStored.value || doprocessGenLevelMixedNotStored.value) { + if (doprocessGenLevelNotStored.value) { bookHistos(genHistos, "", false); } - if (doprocessRecLevelMcNotStored.value || doprocessRecLevelMixedNotStored.value) { + if (doprocessRecLevelMcNotStored.value) { bookHistos(recHistos, "rec/", true); } } - /// Fills ordered pairs (a from tracksA, b from tracksB) of one event class; for the same event the pair of a - /// particle with itself is skipped, so like-sign pairs count N(N-1) - template - void fillBfPairs(BfHistos& bf, int eventClass, TTracksA const& tracksA, TTracksB const& tracksB) + /// Fills one ordered pair (charge1, charge2) into the same- or mixed-event histograms of one event class + template + void fillBfPair(BfHistos& bf, int eventClass, int subsample, int charge1, int charge2, + float pt1, float eta1, float phi1, float pt2, float eta2, float phi2) { const double massKaon = constants::physics::MassKaonCharged; - for (auto const& particle1 : tracksA) { - const int charge1 = particle1.trackacceptedid(); - if (charge1 >= NCharges) { - continue; + const auto pair = analysis::qspace::computePairQ(pt1, eta1, phi1, massKaon, pt2, eta2, phi2, massKaon); + if constexpr (sameEvent) { + bf.fhSameQinv[charge1][charge2]->Fill(eventClass, pair.qInv); + bf.fhSameQlong[charge1][charge2]->Fill(eventClass, pair.qLong); + bf.fhSameQout[charge1][charge2]->Fill(eventClass, pair.qOut); + bf.fhSameQside[charge1][charge2]->Fill(eventClass, pair.qSide); + if (subsample >= 0) { + bf.fhSubSameQinv[charge1][charge2]->Fill(eventClass, subsample, pair.qInv); } - for (auto const& particle2 : tracksB) { - const int charge2 = particle2.trackacceptedid(); - if (charge2 >= NCharges) { - continue; - } - if constexpr (sameEvent) { - if (particle1.globalIndex() == particle2.globalIndex()) { - continue; - } - } - const auto pair = analysis::qspace::computePairQ(particle1.pt(), particle1.eta(), particle1.phi(), massKaon, - particle2.pt(), particle2.eta(), particle2.phi(), massKaon); - if constexpr (sameEvent) { - bf.fhSameQinv[charge1][charge2]->Fill(eventClass, pair.qInv); - bf.fhSameQlong[charge1][charge2]->Fill(eventClass, pair.qLong); - bf.fhSameQout[charge1][charge2]->Fill(eventClass, pair.qOut); - bf.fhSameQside[charge1][charge2]->Fill(eventClass, pair.qSide); - } else { - bf.fhMixedQinv[charge1][charge2]->Fill(eventClass, pair.qInv); - bf.fhMixedQlong[charge1][charge2]->Fill(eventClass, pair.qLong); - bf.fhMixedQout[charge1][charge2]->Fill(eventClass, pair.qOut); - bf.fhMixedQside[charge1][charge2]->Fill(eventClass, pair.qSide); - } + } else { + bf.fhMixedQinv[charge1][charge2]->Fill(eventClass, pair.qInv); + bf.fhMixedQlong[charge1][charge2]->Fill(eventClass, pair.qLong); + bf.fhMixedQout[charge1][charge2]->Fill(eventClass, pair.qOut); + bf.fhMixedQside[charge1][charge2]->Fill(eventClass, pair.qSide); + if (subsample >= 0) { + bf.fhSubMixedQinv[charge1][charge2]->Fill(eventClass, subsample, pair.qInv); + } + } + } + + /// Mixes ordered pairs (a from eventA, b from eventB) of one event class + void fillBfMixedPairs(BfHistos& bf, int eventClass, int subsample, MixEvent const& eventA, MixEvent const& eventB) + { + for (auto const& kaon1 : eventA) { + for (auto const& kaon2 : eventB) { + fillBfPair(bf, eventClass, subsample, kaon1.charge, kaon2.charge, kaon1.pt, kaon1.eta, kaon1.phi, kaon2.pt, kaon2.eta, kaon2.phi); } } } /// Same-event balance-function inputs of one collision: event and kaon counters, factorial moments, pairs template - void fillBfSameEvent(BfHistos& bf, int eventClass, TParticles const& particles) + void fillBfSameEvent(BfHistos& bf, int eventClass, int subsample, TParticles const& particles) { if (eventClass < 0) { bf.fhEventsOutsideClasses->Fill(1.); @@ -345,14 +386,52 @@ struct QSpaceBalanceFunction { } } bf.fhEventsPerClass->Fill(eventClass); + if (subsample >= 0) { + bf.fhSubEvents->Fill(eventClass, subsample); + } for (int charge1 = 0; charge1 < NCharges; ++charge1) { bf.fhKaonsPerClass->Fill(eventClass, charge1, nKaons[charge1]); + if (subsample >= 0) { + bf.fhSubKaons->Fill(eventClass, subsample, charge1, nKaons[charge1]); + } for (int charge2 = 0; charge2 < NCharges; ++charge2) { const int pairsInEvent = nKaons[charge1] * (nKaons[charge2] - (charge1 == charge2 ? 1 : 0)); bf.fhFactorialPerClass->Fill(eventClass, charge1 * NCharges + charge2, pairsInEvent); } } - fillBfPairs(bf, eventClass, particles, particles); + MixEvent current; + current.reserve(nKaons[0] + nKaons[1]); + for (auto const& particle1 : particles) { + const int charge1 = particle1.trackacceptedid(); + if (charge1 >= NCharges) { + continue; + } + current.push_back({particle1.pt(), particle1.eta(), particle1.phi(), charge1}); + for (auto const& particle2 : particles) { + const int charge2 = particle2.trackacceptedid(); + if (charge2 >= NCharges || particle1.globalIndex() == particle2.globalIndex()) { + continue; // a particle is never paired with itself: like-sign pairs count N(N-1) + } + fillBfPair(bf, eventClass, subsample, charge1, charge2, particle1.pt(), particle1.eta(), particle1.phi(), particle2.pt(), particle2.eta(), particle2.phi()); + } + } + if (!cfgDoMixing.value) { + return; + } + // mix with the previous events of the class, then keep this event (also when it has no kaon, so that event pairs are unbiased) + auto& classPool = bf.pool[eventClass]; + for (auto const& previous : classPool) { + bf.fhMixedEventPairsPerClass->Fill(eventClass); + if (subsample >= 0) { + bf.fhSubEventPairs->Fill(eventClass, subsample); + } + fillBfMixedPairs(bf, eventClass, subsample, current, previous); + fillBfMixedPairs(bf, eventClass, subsample, previous, current); + } + classPool.push_front(std::move(current)); + while (static_cast(classPool.size()) > cfgMixDepth.value) { + classPool.pop_back(); + } } /// Decay mother of an MC particle, looked up in the particle table given (one MC collision or the whole table). @@ -489,7 +568,7 @@ struct QSpaceBalanceFunction { truth.push_back(truthOf(particle, allParticles)); } fillCollision(genHistos, collision, particles, truth); - fillBfSameEvent(genHistos.bf, binningGen.getBin(std::make_tuple(collision.posZ(), collision.centmult())), particles); + fillBfSameEvent(genHistos.bf, binningGen.getBin(std::make_tuple(collision.posZ(), collision.centmult())), subsampleOf(collision.globalIndex()), particles); } PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelNotStored, "Generator level, filter tables made in the same workflow", true); @@ -507,41 +586,9 @@ struct QSpaceBalanceFunction { } } fillCollision(recHistos, collision, tracks, truth); - fillBfSameEvent(recHistos.bf, binningRec.getBin(std::make_tuple(collision.posZ(), collision.centmult())), tracks); + fillBfSameEvent(recHistos.bf, binningRec.getBin(std::make_tuple(collision.posZ(), collision.centmult())), subsampleOf(collision.globalIndex()), tracks); } PROCESS_SWITCH(QSpaceBalanceFunction, processRecLevelMcNotStored, "Detector level of MC (tracks with MC labels), filter tables made in the same workflow", false); - - /// Mixed events: SameKindPair pairs each accepted collision with the next cfgMixDepth collisions of the same class - /// (unordered, without repetition; collisions without kaons are paired too, so the event-pair count is unbiased) - template - void mixEvents(BfHistos& bf, TPairs& eventPairs, TBinning const& binning) - { - for (auto const& [collision1, tracks1, collision2, tracks2] : eventPairs) { - const int eventClass = binning.getBin(std::make_tuple(collision1.posZ(), collision1.centmult())); - if (eventClass < 0) { - continue; - } - bf.fhMixedEventPairsPerClass->Fill(eventClass); - fillBfPairs(bf, eventClass, tracks1, tracks2); - fillBfPairs(bf, eventClass, tracks2, tracks1); - } - } - - void processGenLevelMixedNotStored(GenCollisions const& collisions, GenParticles const& particles) - { - auto particlesTuple = std::make_tuple(particles); - SameKindPair eventPairs{binningGen, cfgMixDepth.value, -1, collisions, particlesTuple, &cache}; - mixEvents(genHistos.bf, eventPairs, binningGen); - } - PROCESS_SWITCH(QSpaceBalanceFunction, processGenLevelMixedNotStored, "Generator level mixed events, filter tables made in the same workflow", false); - - void processRecLevelMixedNotStored(RecCollisions const& collisions, RecTracks const& tracks) - { - auto tracksTuple = std::make_tuple(tracks); - SameKindPair eventPairs{binningRec, cfgMixDepth.value, -1, collisions, tracksTuple, &cache}; - mixEvents(recHistos.bf, eventPairs, binningRec); - } - PROCESS_SWITCH(QSpaceBalanceFunction, processRecLevelMixedNotStored, "Detector level mixed events, filter tables made in the same workflow", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 9311ff9396d59816cc1e7ab53b5b10903da78cb5 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Sun, 22 Nov 2026 22:29:35 +0000 Subject: [PATCH 7/8] Please consider the following formatting changes --- .../TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index eddee5214a5..c618fc216a2 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -146,9 +146,9 @@ struct BfHistos { Histo2DPerPair fhMixedQinv, fhMixedQlong, fhMixedQout, fhMixedQside; /// subsamples (only if cfgNSubsamples > 0): axes (class, subsample, ...) bool withSubsamples = false; - std::shared_ptr fhSubEvents; ///< events per (class, subsample) - std::shared_ptr fhSubEventPairs; ///< mixed event pairs per (class, subsample of the first event) - std::shared_ptr fhSubKaons; ///< sum N_a per (class, subsample, charge) + std::shared_ptr fhSubEvents; ///< events per (class, subsample) + std::shared_ptr fhSubEventPairs; ///< mixed event pairs per (class, subsample of the first event) + std::shared_ptr fhSubKaons; ///< sum N_a per (class, subsample, charge) std::array, NCharges>, NCharges> fhSubSameQinv, fhSubMixedQinv; ///< (class, subsample, Q_inv) /// mixing pool: per class, the last cfgMixDepth events (newest first) std::vector> pool; From c8c9c17a4f7a213b115d7bf18547607022b4c938 Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Sun, 22 Nov 2026 18:02:02 -0500 Subject: [PATCH 8/8] PWGCF: q-space task, include for std::move --- PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index c618fc216a2..a67529fd229 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -70,6 +70,7 @@ #include #include #include +#include #include using namespace o2;