diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index 44f552a0f6d..f909aa78a7e 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -19,27 +19,34 @@ #include #include +#include #include namespace o2::aod { namespace lf_selection_event { -DECLARE_SOA_COLUMN(DefaultSel, defaultSel, bool); -DECLARE_SOA_COLUMN(PhimesonSel, phimesonSel, bool); +// The selection an event passes, each level containing the next: an event with a phi is a selected event +enum Level : uint8_t { + kRejected = 0, + kDefault, // the default event selection + kDefaultWithPhi, // the default event selection and a phi +}; +DECLARE_SOA_COLUMN(SelectionLevel, selectionLevel, uint8_t); } // namespace lf_selection_event DECLARE_SOA_TABLE(PhiStrangeEvtSelDataLike, "AOD", "EVTSELDATA", - lf_selection_event::DefaultSel, - lf_selection_event::PhimesonSel); + lf_selection_event::SelectionLevel); DECLARE_SOA_TABLE(PhiStrangeEvtSelMcGen, "AOD", "EVTSELMCGEN", - lf_selection_event::DefaultSel, - lf_selection_event::PhimesonSel); + lf_selection_event::SelectionLevel); namespace lf_selection_phi_candidate { DECLARE_SOA_INDEX_COLUMN(Collision, collision); +// A generated candidate belongs to a generated collision: with an index to Collisions, a process over McCollisions +// would receive the candidates of the whole DF instead of those of its collision +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); DECLARE_SOA_COLUMN(M, m, float); DECLARE_SOA_COLUMN(Pt, pt, float); @@ -72,7 +79,7 @@ DECLARE_SOA_TABLE(PhimesonCandidatesMcReco, "AOD", "PHICANDMCREC", DECLARE_SOA_TABLE(PhimesonCandidatesMcGen, "AOD", "PHICANDMCGEN", soa::Index<>, - lf_selection_phi_candidate::CollisionId, + lf_selection_phi_candidate::McCollisionId, lf_selection_phi_candidate::M, lf_selection_phi_candidate::Pt, lf_selection_phi_candidate::Y, @@ -193,14 +200,17 @@ DECLARE_SOA_COLUMN(NSigmaTOF, nSigmaTOF, float); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Y, y, float); DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); +// Whether the TOF enters the PID of this track: it has a TOF signal and pT >= minPtTOFInPID of the producer, the +// threshold above which the producer also requires the TOF. Below it the pion is identified with the TPC alone, track +// with TOF or not, so that one threshold, in one place, decides where the TOF is used. +DECLARE_SOA_COLUMN(UseTOFInPID, useTOFInPID, bool); DECLARE_SOA_DYNAMIC_COLUMN(InNSigmaRegion, inNSigmaRegion, - [](float nSigmaTPC, bool hasTOF, float nSigmaTOF, float pidTPCMax, float pidTOFMax) -> bool { + [](float nSigmaTPC, bool useTOFInPID, float nSigmaTOF, float pidTPCMax, float pidTOFMax) -> bool { if (std::abs(nSigmaTPC) >= pidTPCMax) { return false; // TPC check failed } - if (hasTOF && std::abs(nSigmaTOF) >= pidTOFMax) { + if (useTOFInPID && std::abs(nSigmaTOF) >= pidTOFMax) { return false; // TOF check failed } return true; @@ -215,9 +225,9 @@ DECLARE_SOA_TABLE(PionTracksData, "AOD", "PITRACKSDATA", lf_selection_pion_track::Pt, lf_selection_pion_track::Y, lf_selection_pion_track::Phi, - lf_selection_pion_track::HasTOF, + lf_selection_pion_track::UseTOFInPID, lf_selection_pion_track::InNSigmaRegion); DECLARE_SOA_TABLE(PionTracksMcReco, "AOD", "PITRACKSMCREC", @@ -228,9 +238,9 @@ DECLARE_SOA_TABLE(PionTracksMcReco, "AOD", "PITRACKSMCREC", lf_selection_pion_track::Pt, lf_selection_pion_track::Y, lf_selection_pion_track::Phi, - lf_selection_pion_track::HasTOF, + lf_selection_pion_track::UseTOFInPID, lf_selection_pion_track::InNSigmaRegion); } // namespace o2::aod diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 456466e1627..568a2fc6e94 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -21,6 +21,8 @@ #include "PWGLF/Utils/inelGt.h" #include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -60,6 +62,26 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::aod::rctsel; + +namespace phi_strange_utils +{ +// The multiplicity percentile a collision is binned in: its own FT0M centrality, for a collision in data and for a +// generated one, and for a reconstructed collision in MC (TMcCollisions set) that of the generated collision it comes +// from (McCentFT0Ms), the one of the event selection and of the efficiencies. A reconstructed collision in MC has its +// own centFT0M too, but binning the reconstructed side in it and the generated side in the generated one would put the +// migration between multiplicity classes inside the efficiencies, to be unfolded to bring everything back to the +// generated multiplicity; how large that migration is has still to be studied +template +float multPercentile(const TCollision& collision) +{ + if constexpr (std::is_void_v) { + return collision.centFT0M(); + } else { + return collision.template mcCollision_as().centFT0M(); + } +} +} // namespace phi_strange_utils struct PhiMesonCandProducer { // Produce the table with the phi candidates information @@ -93,30 +115,23 @@ struct PhiMesonCandProducer { // Configurables on phi selection struct : ConfigurableGroup { - Configurable maxMPhi{"maxMPhi", 1.2f, "Maximum mass for Phi candidates"}; + Configurable maxMPhi{"maxMPhi", 1.5f, "Maximum mass for Phi candidates"}; Configurable minPhiPt{"minPhiPt", 0.4f, "Minimum pT for Phi candidates"}; Configurable cfgYAcceptance{"cfgYAcceptance", 0.5f, "Rapidity acceptance"}; } phiConfigs; - Configurable trueGenPhi{"trueGenPhi", false, "Phi trigger in MC Collisions: false - gen K+K- pair, true - gen phi meson"}; + Configurable trueGenPhi{"trueGenPhi", false, "Phi trigger in MC Collisions: false - gen K+K- pair, true - gen phi meson decaying to K+K-"}; // Configurables on phi pT bins - Configurable> binspTPhi{"binspTPhi", {0.4, 0.8, 1.4, 2.0, 2.8, 4.0, 6.0, 10.0}, "pT bin limits for Phi"}; + Configurable> binspTPhi{"binspTPhi", {0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 15.0, 20.0}, "pT bin limits for Phi"}; // Filter on default selected collisions - // Filter collisionFilter = aod::lf_selection_default_collision::defaultSel == true; - // Filter collisionFilter = aod::lf_selection_event::defaultSel == true; + // Filter collisionFilter = aod::lf_selection_event::selectionLevel >= static_cast(aod::lf_selection_event::kDefault); // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; using SimCollisions = soa::Join; - /*using SelCollisions = soa::Join; - using SimCollisions = soa::Join; - - using FilteredSelCollisions = soa::Filtered; - using FilteredSimCollisions = soa::Filtered;*/ - // Defining the type of the phi's daughter tracks for data and MC using FullTracks = soa::Join; using FullMCTracks = soa::Join; @@ -357,6 +372,10 @@ struct PhiMesonCandProducer { if (std::abs(mcParticle.pdgCode()) != o2::constants::physics::Pdg::kPhi) { continue; } + // Only phi -> K+K-, as the events with a phi of data and of trueGenPhi false + if (!RecoDecay::isMatchedMCGen(mcParticles, mcParticle, o2::constants::physics::Pdg::kPhi, std::array{-PDG_t::kKPlus, +PDG_t::kKPlus})) { + continue; + } if (mcParticle.pt() < phiConfigs.minPhiPt) { continue; } @@ -364,21 +383,19 @@ struct PhiMesonCandProducer { continue; } - phimesonCandidatesMcGen(mcCollision.globalIndex(), 0, mcParticle.pt(), mcParticle.y(), mcParticle.phi()); + // Its own mass, not a placeholder: the event selection keeps the candidates in the phi signal window, the + // generated phi as the K+K- pairs of trueGenPhi false (a mass of 0 made every event fail it) + phimesonCandidatesMcGen(mcCollision.globalIndex(), RecoDecay::m(mcParticle.p(), mcParticle.e()), mcParticle.pt(), mcParticle.y(), mcParticle.phi()); } } else { + // K+ outside, K- inside: every pair once for (const auto& mcParticle1 : mcParticles) { - if (!mcParticle1.isPhysicalPrimary() || std::abs(mcParticle1.eta()) > trackConfigs.etaMax) { + if (mcParticle1.pdgCode() != PDG_t::kKPlus || !mcParticle1.isPhysicalPrimary() || std::abs(mcParticle1.eta()) > trackConfigs.etaMax) { continue; } for (const auto& mcParticle2 : mcParticles) { - if (!mcParticle2.isPhysicalPrimary() || std::abs(mcParticle2.eta()) > trackConfigs.etaMax) { - continue; - } - - if ((mcParticle1.pdgCode() != PDG_t::kKPlus || mcParticle2.pdgCode() != PDG_t::kKMinus) && - (mcParticle1.pdgCode() != PDG_t::kKMinus || mcParticle2.pdgCode() != PDG_t::kKPlus)) { + if (mcParticle2.pdgCode() != PDG_t::kKMinus || !mcParticle2.isPhysicalPrimary() || std::abs(mcParticle2.eta()) > trackConfigs.etaMax) { continue; } @@ -434,38 +451,39 @@ struct V0ReducedCandProducer { Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; } trackConfigs; - // Configurables for V0 selection + // Configurables for V0 selection. The defaults of the topological cuts, the proper lifetime, the competing-mass + // rejection in the Lambda and the Armenteros cut are those of the K0S and Lambda analysis in pp at 13.6 TeV (V0 + // production vs multiplicity, analysis note of June 2026, Table 1) struct : ConfigurableGroup { - Configurable decayRadius{"decayRadius", 0.5f, "V0 decay radius"}; - Configurable dcaV0Dau{"dcaV0Dau", 1.0f, "DCA V0 Daughters"}; - Configurable dcaPosToPV{"dcaPosToPV", 0.1f, "DCA Pos To PV"}; - Configurable dcaNegToPV{"dcaNegToPV", 0.1f, "DCA Neg To PV"}; + Configurable decayRadius{"decayRadius", 0.9f, "V0 decay radius"}; + Configurable dcaV0Dau{"dcaV0Dau", 0.5f, "DCA V0 Daughters"}; + Configurable dcaPosToPV{"dcaPosToPV", 0.06f, "DCA Pos To PV"}; + Configurable dcaNegToPV{"dcaNegToPV", 0.06f, "DCA Neg To PV"}; - Configurable furtherV0Selection{"furtherV0Selection", false, "Further V0 selection"}; + Configurable applyCtauCut{"applyCtauCut", true, "Apply the ctau cuts (ctauK0S, ctauLambda)"}; Configurable yAcceptance{"yAcceptance", 0.5f, "Rapidity acceptance"}; - struct : ConfigurableGroup { - Configurable cosPAK0S{"cosPAK0S", 0.98f, "K0S CosPA"}; - Configurable ctauK0S{"ctauK0S", 20.0f, "C tau K0s(cm)"}; - Configurable rejMassK0S{"rejMassK0S", 0.005f, "V0 rej K0s"}; + // K0S + Configurable cosPAK0S{"cosPAK0S", 0.98f, "K0S CosPA"}; + Configurable ctauK0S{"ctauK0S", 20.0f, "C tau K0s(cm)"}; + Configurable rejMassK0S{"rejMassK0S", 0.005f, "K0S: half-width of the window around the Lambda mass in which vetoLambdaInK0S rejects (GeV/c2)"}; - Configurable paramArmenterosCutK0S{"paramArmenterosCutK0S", 0.2f, "Parameter for Armenteros Cut for K0S"}; + Configurable paramArmenterosCutK0S{"paramArmenterosCutK0S", 0.2f, "Parameter for Armenteros Cut for K0S"}; + Configurable applyArmenterosCutK0S{"applyArmenterosCutK0S", true, "Apply the Armenteros cut to the K0S (qT > paramArmenterosCutK0S |alpha|)"}; + Configurable vetoLambdaInK0S{"vetoLambdaInK0S", false, "Reject K0S candidates whose mass under the Lambda or AntiLambda hypothesis is within rejMassK0S of the Lambda mass"}; - Configurable minPtK0S{"minPtK0S", 0.1f, "K0S min pt"}; - Configurable> binspTK0S{"binspTK0S", {0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for K0S"}; - Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.47f, 0.53f}, "K0S mass range for signal extraction"}; - } k0sConfigs; + Configurable minPtK0S{"minPtK0S", 0.0f, "K0S min pt"}; + Configurable> binspTK0S{"binspTK0S", {0.0, 0.3, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.3, 3.6, 3.9, 4.2, 4.6, 5.0, 5.4, 5.9, 6.4, 7.0, 8.0, 10.0}, "pT bin limits for K0S"}; - struct : ConfigurableGroup { - Configurable cosPALambda{"cosPALambda", 0.98f, "Lambda CosPA"}; - Configurable ctauLambda{"ctauLambda", 7.89f, "C tau Lambda(cm)"}; - Configurable rejMassLambda{"rejMassLambda", 0.005f, "V0 rej Lambda"}; + // Lambda and AntiLambda + Configurable cosPALambda{"cosPALambda", 0.995f, "Lambda CosPA"}; + Configurable ctauLambda{"ctauLambda", 30.0f, "C tau Lambda(cm)"}; + Configurable rejMassLambda{"rejMassLambda", 0.01f, "Lambda: half-width of the window around the K0S mass in which vetoK0SInLambda rejects (GeV/c2)"}; + Configurable vetoK0SInLambda{"vetoK0SInLambda", true, "Reject Lambda and AntiLambda candidates whose mass under the K0S hypothesis is within rejMassLambda of the K0S mass"}; - Configurable minPtLambda{"minPtLambda", 0.1f, "Lambda min pt"}; - Configurable> binspTLambda{"binspTLambda", {0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Lambda"}; - Configurable> rangeMLambdaSignal{"rangeMLambdaSignal", {1.11f, 1.12f}, "Lambda mass range for signal extraction"}; - } lambdaConfigs; + Configurable minPtLambda{"minPtLambda", 0.8f, "Lambda min pt"}; + Configurable> binspTLambda{"binspTLambda", {0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.3, 3.6, 3.9, 4.2, 4.6, 5.0, 5.4, 5.9, 6.4, 7.0, 8.0, 10.0}, "pT bin limits for Lambda"}; } v0Configs; Configurable> binspTXi{"binspTXi", {0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Xi"}; @@ -475,8 +493,7 @@ struct V0ReducedCandProducer { static constexpr double MassLambda = o2::constants::physics::MassLambda0; // Filter on default selected collisions - // Filter collisionFilter = aod::lf_selection_default_collision::defaultSel == true; - Filter collisionFilter = aod::lf_selection_event::defaultSel == true; + Filter collisionFilter = aod::lf_selection_event::selectionLevel >= static_cast(aod::lf_selection_event::kDefault); // Defining filters on V0s (cannot filter on dynamic columns) Filter v0PreFilter = (nabs(aod::v0data::dcapostopv) > v0Configs.dcaPosToPV && @@ -500,8 +517,8 @@ struct V0ReducedCandProducer { void init(InitContext&) { AxisSpec binnedmultAxis{std::vector(binsMult), "centFT0M"}; - AxisSpec binnedpTK0SAxis{std::vector(v0Configs.k0sConfigs.binspTK0S), "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec binnedpTLambdaAxis{std::vector(v0Configs.lambdaConfigs.binspTLambda), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTK0SAxis{std::vector(v0Configs.binspTK0S), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTLambdaAxis{std::vector(v0Configs.binspTLambda), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTXiAxis{std::vector(binspTXi), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massK0SAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec massLambdaAxis = {200, 1.08f, 1.15f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; @@ -597,9 +614,10 @@ struct V0ReducedCandProducer { return false; } - const float cutCosPA = (v0Type == kK0S) ? v0Configs.k0sConfigs.cosPAK0S : v0Configs.lambdaConfigs.cosPALambda; - const float cutMinPt = (v0Type == kK0S) ? v0Configs.k0sConfigs.minPtK0S : v0Configs.lambdaConfigs.minPtLambda; - const float cutCtau = (v0Type == kK0S) ? v0Configs.k0sConfigs.ctauK0S : v0Configs.lambdaConfigs.ctauLambda; + constexpr bool IsK0S = v0Type == kK0S; + const float cutCosPA = IsK0S ? v0Configs.cosPAK0S : v0Configs.cosPALambda; + const float cutMinPt = IsK0S ? v0Configs.minPtK0S : v0Configs.minPtLambda; + const float cutCtau = IsK0S ? v0Configs.ctauK0S : v0Configs.ctauLambda; if (v0.v0cosPA() < cutCosPA) { return false; @@ -608,24 +626,27 @@ struct V0ReducedCandProducer { return false; } - if (v0Configs.furtherV0Selection) { - constexpr float assumedMass = v0Type == kK0S ? MassK0S : MassLambda; - if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * assumedMass > cutCtau) { + // Separate switches: the competing-mass rejection of one species must be possible without changing the selection + // of the other (a K0S whose pi+ passes the proton PID enters the Lambda mass spectrum with a kinematic edge + // that falls under the Lambda peak at low pT) + if (v0Configs.applyCtauCut) { + constexpr float AssumedMass = IsK0S ? MassK0S : MassLambda; + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * AssumedMass > cutCtau) { return false; } + } - if constexpr (v0Type == kK0S) { - if (std::abs(v0.mLambda() - MassLambda) < v0Configs.k0sConfigs.rejMassK0S || - std::abs(v0.mAntiLambda() - MassLambda) < v0Configs.k0sConfigs.rejMassK0S) { - return false; - } - if (v0.qtarm() < (v0Configs.k0sConfigs.paramArmenterosCutK0S * std::abs(v0.alpha()))) { - return false; - } - } else { - if (std::abs(v0.mK0Short() - MassK0S) < v0Configs.lambdaConfigs.rejMassLambda) { - return false; - } + if constexpr (IsK0S) { + if (v0Configs.vetoLambdaInK0S && + (std::abs(v0.mLambda() - MassLambda) < v0Configs.rejMassK0S || std::abs(v0.mAntiLambda() - MassLambda) < v0Configs.rejMassK0S)) { + return false; + } + if (v0Configs.applyArmenterosCutK0S && v0.qtarm() < v0Configs.paramArmenterosCutK0S * std::abs(v0.alpha())) { + return false; + } + } else { + if (v0Configs.vetoK0SInLambda && std::abs(v0.mK0Short() - MassK0S) < v0Configs.rejMassLambda) { + return false; } } @@ -755,50 +776,67 @@ struct CascadeReducedCandProducer { Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; } trackConfigs; - // Configurables for Cascade selection + // Configurables for Cascade selection. The defaults are those of the Xi and Omega analysis in pp at 13.6 TeV + // (ALICE-ANA-2026-1446, Table 3) struct : ConfigurableGroup { - Configurable dcaV0Dau{"dcaV0Dau", 1.0f, "DCA V0 Daughters"}; - Configurable dcaCascDau{"dcaCascDau", 1.0f, "DCA Cascade Daughters"}; - Configurable dcaPosToPV{"dcaPosToPV", 0.1f, "DCA Pos To PV"}; - Configurable dcaNegToPV{"dcaNegToPV", 0.1f, "DCA Neg To PV"}; - Configurable dcaBachToPV{"dcaBachToPV", 0.1f, "DCA Bach To PV"}; + Configurable dcaBachToPV{"dcaBachToPV", 0.05f, "DCA Bach To PV"}; + + // The cuts of the note that the trains have not applied so far, each with its own switch, off by default + Configurable applyDcaV0ToPVCut{"applyDcaV0ToPVCut", false, "Apply the minimum DCA of the V0 to the PV (dcaV0ToPVXi, dcaV0ToPVOmega)"}; + Configurable applyBachBaryonCut{"applyBachBaryonCut", false, "Apply the minimum DCAxy to the PV of the bachelor-baryon pair (dcaBachBaryonXi, dcaBachBaryonOmega)"}; + Configurable applyLambdaMassWindow{"applyLambdaMassWindow", false, "Apply the Lambda mass window to the V0 (massWindowLambdaXi, massWindowLambdaOmega)"}; + Configurable applyCtauCut{"applyCtauCut", false, "Apply the proper decay length cuts (ctauXi, ctauOmega)"}; + Configurable vetoXiInOmega{"vetoXiInOmega", false, "Reject Omega candidates within rejMassXiInOmega of the Xi mass"}; Configurable yAcceptance{"yAcceptance", 0.5f, "Rapidity acceptance"}; - struct : ConfigurableGroup { - Configurable v0CosPAXi{"v0CosPAXi", 0.98f, "Xi V0 CosPA"}; - Configurable cosPAXi{"cosPAXi", 0.98f, "Xi CosPA"}; - Configurable v0RadiusXi{"v0RadiusXi", 0.5f, "V0 decay radius"}; - Configurable radiusXi{"radiusXi", 0.5f, "Xi decay radius"}; - - Configurable minPtXi{"minPtXi", 0.8f, "Xi min pt"}; - Configurable> binspTXi{"binspTXi", {0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Xi"}; - } xiConfigs; - - struct : ConfigurableGroup { - Configurable v0CosPAOmega{"v0CosPAOmega", 0.98f, "Omega V0 CosPA"}; - Configurable cosPAOmega{"cosPAOmega", 0.98f, "Omega CosPA"}; - Configurable v0RadiusOmega{"v0RadiusOmega", 0.5f, "V0 decay radius"}; - Configurable radiusOmega{"radiusOmega", 0.5f, "Omega decay radius"}; - - Configurable minPtOmega{"minPtOmega", 0.8f, "Omega min pt"}; - Configurable> binspTOmega{"binspTOmega", {0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Omega"}; - } omegaConfigs; + // Xi + Configurable dcaPosToPVXi{"dcaPosToPVXi", 0.06f, "Xi: DCA Pos To PV"}; + Configurable dcaNegToPVXi{"dcaNegToPVXi", 0.06f, "Xi: DCA Neg To PV"}; + Configurable dcaV0DauXi{"dcaV0DauXi", 0.5f, "Xi: DCA V0 Daughters"}; + Configurable dcaCascDauXi{"dcaCascDauXi", 0.25f, "Xi: DCA Cascade Daughters (bachelor and V0)"}; + Configurable dcaV0ToPVXi{"dcaV0ToPVXi", 0.03f, "Xi: DCA V0 To PV"}; + Configurable dcaBachBaryonXi{"dcaBachBaryonXi", 0.02f, "Xi: minimum DCAxy to PV of the bachelor-baryon pair"}; + Configurable v0CosPAXi{"v0CosPAXi", 0.9876f, "Xi V0 CosPA"}; + Configurable cosPAXi{"cosPAXi", 0.9947f, "Xi CosPA"}; + Configurable v0RadiusXi{"v0RadiusXi", 1.2f, "V0 decay radius"}; + Configurable radiusXi{"radiusXi", 1.0f, "Xi decay radius"}; + Configurable massWindowLambdaXi{"massWindowLambdaXi", 0.0116f, "Xi: maximum |m(V0) - m(Lambda)| (GeV/c2)"}; + Configurable ctauXi{"ctauXi", 22.6f, "Xi: maximum proper decay length L m / p (cm); the note's 4.6 c tau, with c tau = 4.91 cm (PDG)"}; + + Configurable minPtXi{"minPtXi", 0.8f, "Xi min pt"}; + Configurable> binspTXi{"binspTXi", {0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.3, 3.6, 3.9, 4.2, 4.6, 5.0, 5.4, 5.9, 6.5}, "pT bin limits for Xi"}; + + // Omega + Configurable dcaPosToPVOmega{"dcaPosToPVOmega", 0.05f, "Omega: DCA Pos To PV"}; + Configurable dcaNegToPVOmega{"dcaNegToPVOmega", 0.05f, "Omega: DCA Neg To PV"}; + Configurable dcaV0DauOmega{"dcaV0DauOmega", 0.4f, "Omega: DCA V0 Daughters"}; + Configurable dcaCascDauOmega{"dcaCascDauOmega", 0.8f, "Omega: DCA Cascade Daughters (bachelor and V0)"}; + Configurable dcaV0ToPVOmega{"dcaV0ToPVOmega", 0.04f, "Omega: DCA V0 To PV"}; + Configurable dcaBachBaryonOmega{"dcaBachBaryonOmega", 0.015f, "Omega: minimum DCAxy to PV of the bachelor-baryon pair"}; + Configurable v0CosPAOmega{"v0CosPAOmega", 0.985f, "Omega V0 CosPA"}; + Configurable cosPAOmega{"cosPAOmega", 0.99f, "Omega CosPA"}; + Configurable v0RadiusOmega{"v0RadiusOmega", 1.2f, "V0 decay radius"}; + Configurable radiusOmega{"radiusOmega", 0.8f, "Omega decay radius"}; + Configurable massWindowLambdaOmega{"massWindowLambdaOmega", 0.0075f, "Omega: maximum |m(V0) - m(Lambda)| (GeV/c2)"}; + Configurable ctauOmega{"ctauOmega", 17.2f, "Omega: maximum proper decay length L m / p (cm); the note's 7 c tau, with c tau = 2.461 cm (PDG)"}; + Configurable rejMassXiInOmega{"rejMassXiInOmega", 0.01f, "Omega: reject candidates within this distance of the Xi mass (GeV/c2)"}; + + Configurable minPtOmega{"minPtOmega", 0.8f, "Omega min pt"}; + Configurable> binspTOmega{"binspTOmega", {0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.3, 3.6, 3.9, 4.2, 4.6, 5.0, 5.4, 5.9, 6.5}, "pT bin limits for Omega"}; } cascadeConfigs; // Constants static constexpr double MassXi = o2::constants::physics::MassXiMinus; static constexpr double MassOmega = o2::constants::physics::MassOmegaMinus; + static constexpr double MassLambda = o2::constants::physics::MassLambda0; // Filter on default selected collisions - Filter collisionFilter = aod::lf_selection_event::defaultSel == true; + Filter collisionFilter = aod::lf_selection_event::selectionLevel >= static_cast(aod::lf_selection_event::kDefault); - // Defining filters on Cascades (cannot filter on dynamic columns) - Filter cascadePreFilter = (nabs(aod::cascdata::dcapostopv) > cascadeConfigs.dcaPosToPV && - nabs(aod::cascdata::dcanegtopv) > cascadeConfigs.dcaNegToPV && - nabs(aod::cascdata::dcabachtopv) > cascadeConfigs.dcaBachToPV && - aod::cascdata::dcaV0daughters < cascadeConfigs.dcaV0Dau && - aod::cascdata::dcacascdaughters < cascadeConfigs.dcaCascDau); + // Defining filters on Cascades (cannot filter on dynamic columns); the cuts that differ between Xi and Omega are + // applied in selectionCascade + Filter cascadePreFilter = nabs(aod::cascdata::dcabachtopv) > cascadeConfigs.dcaBachToPV; // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; @@ -817,8 +855,8 @@ struct CascadeReducedCandProducer { void init(InitContext&) { AxisSpec binnedmultAxis{std::vector(binsMult), "centFT0M"}; - AxisSpec binnedpTXiAxis{std::vector(cascadeConfigs.xiConfigs.binspTXi), "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec binnedpTOmegaAxis{std::vector(cascadeConfigs.omegaConfigs.binspTOmega), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTXiAxis{std::vector(cascadeConfigs.binspTXi), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec binnedpTOmegaAxis{std::vector(cascadeConfigs.binspTOmega), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massXiAxis = {200, 1.2f, 1.4f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec massOmegaAxis = {200, 1.6f, 1.8f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; @@ -922,16 +960,41 @@ struct CascadeReducedCandProducer { return false; } - const float cutV0CosPA = (cascadeType == kXi || cascadeType == kAntiXi) ? cascadeConfigs.xiConfigs.v0CosPAXi : cascadeConfigs.omegaConfigs.v0CosPAOmega; - const float cutCosPA = (cascadeType == kXi || cascadeType == kAntiXi) ? cascadeConfigs.xiConfigs.cosPAXi : cascadeConfigs.omegaConfigs.cosPAOmega; - const float cutV0Radius = (cascadeType == kXi || cascadeType == kAntiXi) ? cascadeConfigs.xiConfigs.v0RadiusXi : cascadeConfigs.omegaConfigs.v0RadiusOmega; - const float cutRadius = (cascadeType == kXi || cascadeType == kAntiXi) ? cascadeConfigs.xiConfigs.radiusXi : cascadeConfigs.omegaConfigs.radiusOmega; - const float cutMinPt = (cascadeType == kXi || cascadeType == kAntiXi) ? cascadeConfigs.xiConfigs.minPtXi : cascadeConfigs.omegaConfigs.minPtOmega; + constexpr bool IsXi = cascadeType == kXi || cascadeType == kAntiXi; + const float cutDcaPosToPV = IsXi ? cascadeConfigs.dcaPosToPVXi : cascadeConfigs.dcaPosToPVOmega; + const float cutDcaNegToPV = IsXi ? cascadeConfigs.dcaNegToPVXi : cascadeConfigs.dcaNegToPVOmega; + const float cutDcaV0Dau = IsXi ? cascadeConfigs.dcaV0DauXi : cascadeConfigs.dcaV0DauOmega; + const float cutDcaCascDau = IsXi ? cascadeConfigs.dcaCascDauXi : cascadeConfigs.dcaCascDauOmega; + const float cutDcaV0ToPV = IsXi ? cascadeConfigs.dcaV0ToPVXi : cascadeConfigs.dcaV0ToPVOmega; + const float cutDcaBachBaryon = IsXi ? cascadeConfigs.dcaBachBaryonXi : cascadeConfigs.dcaBachBaryonOmega; + const float cutV0CosPA = IsXi ? cascadeConfigs.v0CosPAXi : cascadeConfigs.v0CosPAOmega; + const float cutCosPA = IsXi ? cascadeConfigs.cosPAXi : cascadeConfigs.cosPAOmega; + const float cutV0Radius = IsXi ? cascadeConfigs.v0RadiusXi : cascadeConfigs.v0RadiusOmega; + const float cutRadius = IsXi ? cascadeConfigs.radiusXi : cascadeConfigs.radiusOmega; + const float cutMassWindowLambda = IsXi ? cascadeConfigs.massWindowLambdaXi : cascadeConfigs.massWindowLambdaOmega; + const float cutCtau = IsXi ? cascadeConfigs.ctauXi : cascadeConfigs.ctauOmega; + const float cutMinPt = IsXi ? cascadeConfigs.minPtXi : cascadeConfigs.minPtOmega; const auto& pvx = collision.posX(); const auto& pvy = collision.posY(); const auto& pvz = collision.posZ(); + if (std::abs(cascade.dcapostopv()) < cutDcaPosToPV || std::abs(cascade.dcanegtopv()) < cutDcaNegToPV) { + return false; + } + if (cascade.dcaV0daughters() > cutDcaV0Dau || cascade.dcacascdaughters() > cutDcaCascDau) { + return false; + } + if (cascadeConfigs.applyDcaV0ToPVCut && cascade.dcav0topv(pvx, pvy, pvz) < cutDcaV0ToPV) { + return false; + } + // The bachelor and the baryon of the V0, fitted by the builder as a pair (bachBaryonDCAxyToPV): in a true cascade + // they come from two decay vertices and the pair does not point to the PV; when it does, the two are likely the + // pion and proton of a primary Lambda, joined by an unrelated track into a fake cascade, and such candidates pile + // up in a structure in the invariant mass + if (cascadeConfigs.applyBachBaryonCut && std::abs(cascade.bachBaryonDCAxyToPV()) < cutDcaBachBaryon) { + return false; + } if (cascade.v0cosPA(pvx, pvy, pvz) < cutV0CosPA) { return false; } @@ -944,6 +1007,23 @@ struct CascadeReducedCandProducer { if (cascade.cascradius() < cutRadius) { return false; } + if (cascadeConfigs.applyLambdaMassWindow && std::abs(cascade.mLambda() - MassLambda) > cutMassWindowLambda) { + return false; + } + if constexpr (!IsXi) { + if (cascadeConfigs.vetoXiInOmega && std::abs(cascade.mXi() - MassXi) < cascadeConfigs.rejMassXiInOmega) { + return false; + } + } + // Proper decay length L m / p in cm, as for the V0s (ctauK0S, ctauLambda); computed here, since the cascade tables + // have no distovertotmom (only the V0 tables do) + if (cascadeConfigs.applyCtauCut) { + const float decayLength = std::hypot(cascade.x() - pvx, cascade.y() - pvy, cascade.z() - pvz); + const float properLength = decayLength * (IsXi ? MassXi : MassOmega) / std::hypot(cascade.px(), cascade.py(), cascade.pz()); + if (properLength > cutCtau) { + return false; + } + } if (cascade.pt() < cutMinPt) { return false; } @@ -1041,7 +1121,9 @@ struct PionTrackProducer { Configurable minITSnCls{"minITSnCls", 4, "min number of ITS clusters"}; // Configurable forceTOF{"forceTOF", false, "force the TOF signal for the PID"}; - Configurable tofPIDThreshold{"tofPIDThreshold", 0.5, "minimum pT after which TOF PID is applicable"}; + // Was tofPIDThreshold, which bounded only this producer's TOF requirement: renamed with its meaning, now that it + // also decides where the TOF enters the PID (useTOFInPID), so that a train configuration says which rule it ran + Configurable minPtTOFInPID{"minPtTOFInPID", 0.5, "pT from which the TOF is required (cfgIsTOFChecked) and enters the pion PID, here and in the nSigma window of phiStrangeCorrelation"}; Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Kaon, o2::track::PID::Proton}, "Trk sel: Particles species for PID rejection, kaon, proton"}; Configurable applyElRejection{"applyElRejection", false, "Apply or not the electron rejection"}; Configurable> pidRangeTPCEl{"pidRangeTPCEl", {-3.0f, 5.0f}, "nSigma TPC range for electrons"}; @@ -1054,13 +1136,12 @@ struct PionTrackProducer { } trackConfigs; // Configurable on pion pT bins - Configurable> binspTPi{"binspTPi", {0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for pions"}; + Configurable> binspTPi{"binspTPi", {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0}, "pT bin limits for pions"}; static constexpr double MassPi = o2::constants::physics::MassPiPlus; // Filter on default selected collisions - // Filter collisionFilter = aod::lf_selection_default_collision::defaultSel == true; - Filter collisionFilter = aod::lf_selection_event::defaultSel == true; + Filter collisionFilter = aod::lf_selection_event::selectionLevel >= static_cast(aod::lf_selection_event::kDefault); // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; @@ -1068,6 +1149,7 @@ struct PionTrackProducer { using FilteredSelCollisions = soa::Filtered; using FilteredSimCollisions = soa::Filtered; + using MCCollisions = soa::Join; // Defining the type of the tracks for data and MC using FullTracks = soa::Join; @@ -1077,14 +1159,31 @@ struct PionTrackProducer { { AxisSpec binnedmultAxis{std::vector(binsMult), "centFT0M"}; AxisSpec binnedpTPiAxis{std::vector(binspTPi), "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec nSigmaPiAxis = {100, -10.0f, 10.0f, "N#sigma #pi"}; - - histos.add("h3PionTPCnSigma", "Pion TPC nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis}); - histos.add("h3PionTOFnSigma", "Pion TOF nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaPiAxis}); - - histos.add("h2RecMCDCAxyPrimPi", "Dcaxy distribution vs pt for Primary Pions", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - histos.add("h2RecMCDCAxySecWeakDecayPi", "Dcaz distribution vs pt for Secondary Pions from Weak Decay", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - histos.add("h2RecMCDCAxySecMaterialPi", "Dcaxy distribution vs pt for Secondary Pions from Material", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); + AxisSpec nSigmaTPCPiAxis = {100, -10.0f, 10.0f, "N#sigma_{TPC} #pi"}; + AxisSpec nSigmaTOFPiAxis = {100, -10.0f, 10.0f, "N#sigma_{TOF} #pi"}; + // Wide enough for the DCAxy cut at the lowest pT (0.004 + 0.013 / 0.2 = 0.069 cm with the defaults), so that the + // templates are not truncated where the secondaries weigh most + AxisSpec dcaXYPiAxis = {4000, -0.1f, 0.1f, "DCA_{xy} (cm)"}; + + histos.add("h3PionTPCnSigma", "Pion TPC nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis}); + histos.add("h3PionTOFnSigma", "Pion TOF nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTOFPiAxis}); + + // The selected pions split by TOF: with TOF, the TPC and TOF nSigma together; without TOF, the TPC one alone. + // phiStrangeCorrelation counts in the TPC window alone below minPtTOFInPID and in both windows above it + // (useTOFInPID), so fits of these give the purity and the nSigma-window efficiency of the counted sample, which the + // two distributions above, each over every track, cannot. Below the threshold, the tracks with TOF also show what a + // TOF cut would remove there + histos.add("h4PionTPCTOFnSigma", "Pion TPC and TOF nSigma, tracks with TOF", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis, nSigmaTOFPiAxis}); + histos.add("h3PionTPCnSigmaNoTOF", "Pion TPC nSigma, tracks without TOF", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis}); + // The same for the true primary pions, to compare the nSigma shapes of data and MC + histos.add("h4RecMCPionTPCTOFnSigma", "True primary pion TPC and TOF nSigma, tracks with TOF", kTHnSparseF, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis, nSigmaTOFPiAxis}); + histos.add("h3RecMCPionTPCnSigmaNoTOF", "True primary pion TPC nSigma, tracks without TOF", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis}); + + // The data to fit with the templates below: every selected track, so with whatever is not a pion among them + histos.add("h2PionDCAxy", "Dcaxy distribution vs pt for selected Pion tracks", kTH2F, {binnedpTPiAxis, dcaXYPiAxis}); + histos.add("h2RecMCDCAxyPrimPi", "Dcaxy distribution vs pt for Primary Pions", kTH2F, {binnedpTPiAxis, dcaXYPiAxis}); + histos.add("h2RecMCDCAxySecWeakDecayPi", "Dcaxy distribution vs pt for Secondary Pions from Weak Decay", kTH2F, {binnedpTPiAxis, dcaXYPiAxis}); + histos.add("h2RecMCDCAxySecMaterialPi", "Dcaxy distribution vs pt for Secondary Pions from Material", kTH2F, {binnedpTPiAxis, dcaXYPiAxis}); } /*// PID selection for Pions @@ -1103,7 +1202,7 @@ struct PionTrackProducer { if (std::abs(nSigmaTPC) >= trackConfigs.pidTPCMax->at(speciesIndex)) { return false; // TPC check failed } - if (trackConfigs.forceTOF || (track.pt() >= trackConfigs.tofPIDThreshold && track.hasTOF())) { + if (trackConfigs.forceTOF || (track.pt() >= trackConfigs.minPtTOFInPID && track.hasTOF())) { auto nSigmaTOF = aod::pidutils::tofNSigma(pid, track); if (std::abs(nSigmaTOF) >= trackConfigs.pidTOFMax->at(speciesIndex)) { return false; // TOF check failed @@ -1126,6 +1225,16 @@ struct PionTrackProducer { return true; }*/ + // The TOF enters the pion PID from minPtTOFInPID up and never below, here in the K/p rejection and in the nSigma + // window of phiStrangeCorrelation (the UseTOFInPID column). Below the threshold the TPC separates the pion alone; a + // TOF cut on the tracks that happen to have a TOF signal only adds the matching and the mismatch to the efficiency, + // on a fraction of the tracks that changes with pT, and the old fit-based analysis did not use the TOF there either + template + bool useTOFInPID(const T& track) + { + return track.pt() >= trackConfigs.minPtTOFInPID && track.hasTOF(); + } + // PID Hypotheses rejection for Pions template bool pidHypothesesRejection(const T& track) @@ -1152,8 +1261,8 @@ struct PionTrackProducer { auto nSigmaTPC = aod::pidutils::tpcNSigma(pid, track); if (std::abs(nSigmaTPC) < trackConfigs.pidTPCMaxHadrons) { - // Reject if only TPC is within threshold and TOF is unavailable or if both TPC and TOF are within thresholds - if (!track.hasTOF() || std::abs(aod::pidutils::tofNSigma(pid, track)) < trackConfigs.pidTOFMaxHadrons) { + // Reject if only TPC is within threshold and TOF is not used or if both TPC and TOF are within thresholds + if (!useTOFInPID(track) || std::abs(aod::pidutils::tofNSigma(pid, track)) < trackConfigs.pidTOFMaxHadrons) { return false; } } @@ -1211,7 +1320,7 @@ struct PionTrackProducer { } } - if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.tofPIDThreshold && !track.hasTOF()) { + if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.minPtTOFInPID && !track.hasTOF()) { return false; } @@ -1224,9 +1333,9 @@ struct PionTrackProducer { /* if (analysisMode == 1) { - if (track.pt() < trackConfigs.tofPIDThreshold && std::abs(track.tpcNSigmaPi()) >= trackConfigs.nSigmaCutTPCPrimPion) + if (track.pt() < trackConfigs.minPtTOFInPID && std::abs(track.tpcNSigmaPi()) >= trackConfigs.nSigmaCutTPCPrimPion) return false; - if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.tofPIDThreshold && (std::pow(track.tofNSigmaPi(), 2) + std::pow(track.tpcNSigmaPi(), 2)) >= std::pow(trackConfigs.nSigmaCutCombinedPi, 2)) + if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.minPtTOFInPID && (std::pow(track.tofNSigmaPi(), 2) + std::pow(track.tpcNSigmaPi(), 2)) >= std::pow(trackConfigs.nSigmaCutCombinedPi, 2)) return false; } */ @@ -1248,16 +1357,25 @@ struct PionTrackProducer { histos.fill(HIST("h3PionTPCnSigma"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); histos.fill(HIST("h3PionTOFnSigma"), collision.centFT0M(), track.pt(), track.tofNSigmaPi()); + if (track.hasTOF()) { + histos.fill(HIST("h4PionTPCTOFnSigma"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + } else { + histos.fill(HIST("h3PionTPCnSigmaNoTOF"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); + } + histos.fill(HIST("h2PionDCAxy"), track.pt(), track.dcaXY()); - pionTracksData(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), track.hasTOF()); + pionTracksData(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), useTOFInPID(track)); } } PROCESS_SWITCH(PionTrackProducer, processData, "Process function to select pion tracks in Data or in McReco (w/o MC truth) analysis", true); // void processMCReco(SimCollisions::iterator const& collision, FullMCTracks const& fullTracks, aod::McParticles const& mcParticles) - void processMCReco(FilteredSimCollisions::iterator const& collision, FullMCTracks const& fullTracks, aod::McParticles const& mcParticles) + void processMCReco(FilteredSimCollisions::iterator const& collision, MCCollisions const&, FullMCTracks const& fullTracks, aod::McParticles const& mcParticles) { + // The generated multiplicity, as in the event selection: a collision passing it has an MC collision + const float multiplicity = phi_strange_utils::multPercentile(collision); + for (const auto& track : fullTracks) { if (!selectionPion(track)) { continue; @@ -1282,7 +1400,13 @@ struct PionTrackProducer { continue; } - pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), track.hasTOF()); + if (track.hasTOF()) { + histos.fill(HIST("h4RecMCPionTPCTOFnSigma"), multiplicity, track.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + } else { + histos.fill(HIST("h3RecMCPionTPCnSigmaNoTOF"), multiplicity, track.pt(), track.tpcNSigmaPi()); + } + + pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), useTOFInPID(track)); } } @@ -1294,15 +1418,6 @@ struct EventSelectionProducer { Produces phiStrangeEvtSelDataLike; Produces phiStrangeEvtSelMcGen; - // Produces phiStrangeDefEvtSelDataLike; - // Produces phiStrangeDefEvtSelMcGen; - - /*Produces defaultSelectionData; - Produces defaultSelectionMcGen; - - Produces phimesonSelectionData; - Produces phimesonSelectionMcGen;*/ - HistogramRegistry histos{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Configurable for event selection @@ -1314,14 +1429,14 @@ struct EventSelectionProducer { // Configurable for MC Configurable cfgiskNoITSROFrameBorder{"cfgiskNoITSROFrameBorder", false, "kNoITSROFrameBorder request on MC collisions"}; - // Configurables on phi selection - struct : ConfigurableGroup { - Configurable minMPhiSignal{"minMPhiSignal", 1.0095f, "Upper limits on Phi mass for signal extraction"}; - Configurable maxMPhiSignal{"maxMPhiSignal", 1.029f, "Upper limits on Phi mass for signal extraction"}; - } phiConfigs; + // Configurable on phi selection + Configurable> rangeMPhiSignal{"rangeMPhiSignal", {1.0f, 1.05f}, "Phi mass range for signal extraction"}; Configurable withTrueGenPhi{"withTrueGenPhi", false, "Require the presence of a true generated phi meson in the event"}; + // Configurable for RCTFlagChecker + Configurable cfgRCTLabel{"cfgRCTLabel", "", "Which detector condition requirements? (CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo)"}; + // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; using SimCollisions = soa::Join; @@ -1334,6 +1449,9 @@ struct EventSelectionProducer { // Necessary service to flag INEL>0 events in GenMC Service pdgDB{}; + // Necessary tool to flag collision according to detector run condition + RCTFlagsChecker rctFlagsChecker; + void init(InitContext&) { // Defining histogram axes @@ -1341,17 +1459,25 @@ struct EventSelectionProducer { AxisSpec multAxis = {120, 0.0f, 120.0f, "centFT0M"}; AxisSpec binnedmultAxis{std::vector(binsMult), "centFT0M"}; + // The RCT selection, from the label in the configuration (read before init, not at construction) + rctFlagsChecker.init(cfgRCTLabel.value); + // A label it does not know leaves the checker without flags, which it would only report at the first event + if (!cfgRCTLabel.value.empty() && !rctFlagsChecker.any()) { + LOG(fatal) << "Unknown cfgRCTLabel '" << cfgRCTLabel.value << "': expected one of CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo"; + } + // Booking histograms for event selection QA // Number of events per selection in Data - histos.add("hEventSelectionData", "hEventSelectionData", kTH1F, {{5, -0.5f, 4.5f}}); + histos.add("hEventSelectionData", "hEventSelectionData", kTH1F, {{6, -0.5f, 5.5f}}); histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(1, "All collisions"); histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(3, "posZ cut"); histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(4, "INEL>0 cut"); - histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(5, "With at least a #phi cand"); + histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(5, "RCTFlags cut"); + histos.get(HIST("hEventSelectionData"))->GetXaxis()->SetBinLabel(6, "With at least a #phi cand"); // Number of MC events per selection in MC - histos.add("hEventSelectionMC", "hEventSelectionMC", kTH1F, {{8, -0.5f, 7.5f}}); + histos.add("hEventSelectionMC", "hEventSelectionMC", kTH1F, {{9, -0.5f, 8.5f}}); histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(1, "All collisions"); histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(2, "kIsTriggerTVX"); histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(3, "kNoTimeFrameBorder"); @@ -1359,7 +1485,8 @@ struct EventSelectionProducer { histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(5, "posZ cut"); histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(6, "INEL>0 cut"); histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(7, "With at least a gen coll"); - histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(8, "With at least a #phi cand"); + histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(8, "RCTFlags cut"); + histos.get(HIST("hEventSelectionMC"))->GetXaxis()->SetBinLabel(9, "With at least a #phi cand"); // Event information histos.add("hVertexZ", "Vertex Z", kTH1F, {vertexZAxis}); @@ -1374,8 +1501,6 @@ struct EventSelectionProducer { template bool defaultEventSelection(const T& collision) { - float multPercentile{0.0f}; - if constexpr (!isMC) { // data event histos.fill(HIST("hEventSelectionData"), 0); // all collisions if (!collision.sel8()) { @@ -1390,9 +1515,12 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionData"), 3); // INEL>0 collisions - - multPercentile = collision.centFT0M(); - } else { // MCreco event + if (!cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + histos.fill(HIST("hEventSelectionData"), 4); // RCTFlags cut + } else { + // MCreco event static_assert(!std::is_same_v, "Need to set MC_T to MCCollisions for isMC = true"); histos.fill(HIST("hEventSelectionMC"), 0); // all collisions @@ -1420,14 +1548,17 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionMC"), 6); // with at least a gen collision - - const auto& mcCollision = collision.template mcCollision_as(); - multPercentile = mcCollision.centFT0M(); + if (!cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + histos.fill(HIST("hEventSelectionMC"), 7); // RCTFlags cut } + const float multiplicity = phi_strange_utils::multPercentile(collision); + histos.fill(HIST("hVertexZ"), collision.posZ()); - histos.fill(HIST("hMultiplicityPercent"), multPercentile); - histos.fill(HIST("h2VertexZvsMult"), collision.posZ(), multPercentile); + histos.fill(HIST("hMultiplicityPercent"), multiplicity); + histos.fill(HIST("h2VertexZvsMult"), collision.posZ(), multiplicity); return true; } @@ -1442,9 +1573,10 @@ struct EventSelectionProducer { } } else { uint16_t nPhi{0}; + const auto& [minMass, maxMass] = rangeMPhiSignal.value; for (const auto& phiCand : phiCandidates) { - if (phiCand.inMassRegion(phiConfigs.minMPhiSignal, phiConfigs.maxMPhiSignal)) { + if (phiCand.inMassRegion(minMass, maxMass)) { nPhi++; } @@ -1460,26 +1592,18 @@ struct EventSelectionProducer { } } - float multPercentile{0.0f}; - if constexpr (!isMC) { - histos.fill(HIST("hEventSelectionData"), 4); - - multPercentile = collision.centFT0M(); - } else { - if constexpr (std::is_same_v) { - multPercentile = collision.centFT0M(); - } else { - histos.fill(HIST("hEventSelectionMC"), 7); - - const auto& mcCollision = collision.template mcCollision_as(); - multPercentile = mcCollision.centFT0M(); - } + histos.fill(HIST("hEventSelectionData"), 5); + } else if constexpr (!std::is_void_v) { + histos.fill(HIST("hEventSelectionMC"), 8); } + // MC_T void for a collision in data and for a generated one + const float multiplicity = phi_strange_utils::multPercentile(collision); + histos.fill(HIST("hVertexZWPhi"), collision.posZ()); - histos.fill(HIST("hMultiplicityPercentWPhi"), multPercentile); - histos.fill(HIST("h2VertexZvsMultWPhi"), collision.posZ(), multPercentile); + histos.fill(HIST("hMultiplicityPercentWPhi"), multiplicity); + histos.fill(HIST("h2VertexZvsMultWPhi"), collision.posZ(), multiplicity); return true; } @@ -1487,53 +1611,57 @@ struct EventSelectionProducer { // Default event selection void processData(SelCollisions::iterator const& collision) { - // phiStrangeDefEvtSelDataLike(defaultEventSelection(collision)); - phiStrangeEvtSelDataLike(defaultEventSelection(collision), false); - // defaultSelectionData(defaultEventSelection(collision), false); + phiStrangeEvtSelDataLike(defaultEventSelection(collision) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected); } PROCESS_SWITCH(EventSelectionProducer, processData, "Process function to select default events in Data", true); void processMCReco(SimCollisions::iterator const& collision, MCCollisions const&) { - // phiStrangeDefEvtSelDataLike(defaultEventSelection(collision)); - phiStrangeEvtSelDataLike(defaultEventSelection(collision), false); - // defaultSelectionData(defaultEventSelection(collision)); + phiStrangeEvtSelDataLike(defaultEventSelection(collision) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected); } PROCESS_SWITCH(EventSelectionProducer, processMCReco, "Process function to select default events in MCReco", false); void processMCGen(MCCollisions::iterator const&, aod::McParticles const& mcParticles) { - - // phiStrangeDefEvtSelMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB)); - phiStrangeEvtSelMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB), false); - // defaultSelectionMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB)); + phiStrangeEvtSelMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected); } PROCESS_SWITCH(EventSelectionProducer, processMCGen, "Process function to select default events in MCGen", false); - // Default event selection + phi meson requirement + // Default event selection + phi meson requirement. eventHasPhi runs only on the events the default selection keeps: + // it fills the WPhi QA histograms and, in MC reconstruction, reads the generated collision, which a rejected one + // may not have (has_mcCollision is part of the default selection) void processDataWPhi(SelCollisions::iterator const& collision, aod::PhimesonCandidatesData const& phiCandidatesData) { - phiStrangeEvtSelDataLike(defaultEventSelection(collision), eventHasPhi(collision, phiCandidatesData)); - // phimesonSelectionData(defaultEventSelection(collision) && eventHasPhi(collision, phiCandidatesData)); + auto level = defaultEventSelection(collision) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected; + if (level == aod::lf_selection_event::kDefault && eventHasPhi(collision, phiCandidatesData)) { + level = aod::lf_selection_event::kDefaultWithPhi; + } + phiStrangeEvtSelDataLike(level); } PROCESS_SWITCH(EventSelectionProducer, processDataWPhi, "Process function to select events with Phi mesons in Data", false); void processMCRecoWPhi(SimCollisions::iterator const& collision, MCCollisions const&, aod::PhimesonCandidatesData const& phiCandidatesData) { - phiStrangeEvtSelDataLike(defaultEventSelection(collision), eventHasPhi(collision, phiCandidatesData)); - // phimesonSelectionData(defaultEventSelection(collision) && eventHasPhi(collision, phiCandidatesData)); + auto level = defaultEventSelection(collision) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected; + if (level == aod::lf_selection_event::kDefault && eventHasPhi(collision, phiCandidatesData)) { + level = aod::lf_selection_event::kDefaultWithPhi; + } + phiStrangeEvtSelDataLike(level); } PROCESS_SWITCH(EventSelectionProducer, processMCRecoWPhi, "Process function to select events with Phi mesons in MCReco", false); void processMCGenWPhi(MCCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles, aod::PhimesonCandidatesMcGen const& phiCandidatesMcGen) { - phiStrangeEvtSelMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB), eventHasPhi(mcCollision, phiCandidatesMcGen)); - // phimesonSelectionMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB) && eventHasPhi(mcCollision, phiCandidatesMcGen)); + auto level = pwglf::isINELgt0mc(mcParticles, pdgDB) ? aod::lf_selection_event::kDefault : aod::lf_selection_event::kRejected; + if (level == aod::lf_selection_event::kDefault && eventHasPhi(mcCollision, phiCandidatesMcGen)) { + level = aod::lf_selection_event::kDefaultWithPhi; + } + phiStrangeEvtSelMcGen(level); } PROCESS_SWITCH(EventSelectionProducer, processMCGenWPhi, "Process function to select events with Phi mesons in MCGen", false); diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 83d250781e4..21bcc5c0f2e 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -39,12 +39,13 @@ #include #include +#include #include #include -#include #include #include +#include #include #include @@ -54,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -114,7 +114,9 @@ constexpr int getPdgCode() } } -using EffMapPtr = std::variant, std::shared_ptr>; +// Non-owning: CCDB owns its objects. With caching on (the default) the manager keeps each map and deletes it when a +// newer one replaces it, so wrapping the pointer in a smart pointer deletes the map while the cache still serves it +using EffMapPtr = std::variant; struct BoundEfficiencyMap { using CoordsTuple = std::tuple; @@ -125,26 +127,21 @@ struct BoundEfficiencyMap { BoundEfficiencyMap(const EffMapPtr& effMap, float x, float y, float z) : effMap(&effMap), coords(x, y, z) {} BoundEfficiencyMap(const EffMapPtr& effMap, const CoordsTuple& coords) : effMap(&effMap), coords(coords) {} - [[nodiscard]] std::pair getBinEfficiencyAndError() const + [[nodiscard]] float getBinEfficiency() const { return std::visit( - [this](auto&& mapPtr) -> std::pair { + [this](auto&& mapPtr) -> float { if (!mapPtr) { - return {1.0f, 0.0f}; + return 1.0f; } const auto& [x, y, z] = coords; - // Extract the actual histogram type (TH2 or TH3) held by the smart pointer - using HistoType = typename std::decay_t::element_type; - - // Compile-time branching: generates the exact correct function call - if constexpr (std::is_same_v) { - int bin = mapPtr->FindFixBin(y, z); // 2D case only - return {mapPtr->GetBinContent(bin), mapPtr->GetBinError(bin)}; + // Compile-time branching on the alternative held (TH2 or TH3): generates the exact correct function call + if constexpr (std::is_same_v, const TH2*>) { + return mapPtr->GetBinContent(mapPtr->FindFixBin(y, z)); // 2D case only } else { - int bin = mapPtr->FindFixBin(x, y, z); // Full 3D case - return {mapPtr->GetBinContent(bin), mapPtr->GetBinError(bin)}; + return mapPtr->GetBinContent(mapPtr->FindFixBin(x, y, z)); // Full 3D case } }, *effMap); @@ -160,9 +157,7 @@ struct BoundEfficiencyMap { const auto& [x, y, z] = coords; - using HistoType = typename std::decay_t::element_type; - - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v, const TH2*>) { return mapPtr->Interpolate(y, z); // Native 2D interpolation } else { return mapPtr->Interpolate(x, y, z); // Native 3D interpolation @@ -194,39 +189,39 @@ struct PhiStrangeCorrelation { Configurable analysisMode{"analysisMode", kDeltaYvsDeltaPhi, "Analysis mode: 0 - old method with online normalization, 1 - new method with offline normlization, 2 - deltay vs deltaphi"}; // Configurable for event selection - Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; // TO BE REMOVED + Configurable cutZVertex{"cutZVertex", 10.0f, "Accepted z-vertex range (cm)"}; // Configurable on multiplicity bins Configurable> binsMult{"binsMult", {0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 70.0, 100.0}, "Multiplicity bin limits"}; // Configurables on phi mass selection struct : ConfigurableGroup { - Configurable> rangeMPhiSignal{"rangeMPhiSignal", {1.0095f, 1.029f}, "Phi mass range for signal extraction"}; - Configurable> rangeMPhiSideband{"rangeMPhiSideband", {1.1f, 1.2f}, "Phi mass range for sideband extraction"}; + Configurable> rangeMPhiSignal{"rangeMPhiSignal", {1.0f, 1.05f}, "Phi mass range for signal extraction"}; + Configurable> rangeMPhiSideband{"rangeMPhiSideband", {1.06f, 1.08f}, "Phi mass range for sideband extraction"}; } phiConfigs; // Configurables for K0s selection struct : ConfigurableGroup { Configurable selectK0sInSigRegion{"selectK0sInSigRegion", true, "Select K0s candidates in signal region"}; - Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.47f, 0.53f}, "K0S mass range for signal extraction"}; + Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.475f, 0.515f}, "K0S mass range for signal extraction"}; } k0sConfigs; // Configurables for Lambda selection struct : ConfigurableGroup { Configurable selectLambdaInSigRegion{"selectLambdaInSigRegion", true, "Select Lambda candidates in signal region"}; - Configurable> rangeMLambdaSignal{"rangeMLambdaSignal", {1.11f, 1.12f}, "Lambda mass range for signal extraction"}; + Configurable> rangeMLambdaSignal{"rangeMLambdaSignal", {1.105f, 1.128f}, "Lambda mass range for signal extraction"}; } lambdaConfigs; // Configurables for Xi selection struct : ConfigurableGroup { Configurable selectXiInSigRegion{"selectXiInSigRegion", true, "Select Xi candidates in signal region"}; - Configurable> rangeMXiSignal{"rangeMXiSignal", {1.31f, 1.33f}, "Xi mass range for signal extraction"}; + Configurable> rangeMXiSignal{"rangeMXiSignal", {1.305f, 1.335f}, "Xi mass range for signal extraction"}; } xiConfigs; // Configurables for Omega selection struct : ConfigurableGroup { Configurable selectOmegaInSigRegion{"selectOmegaInSigRegion", true, "Select Omega candidates in signal region"}; - Configurable> rangeMOmegaSignal{"rangeMOmegaSignal", {1.66f, 1.68f}, "Omega mass range for signal extraction"}; + Configurable> rangeMOmegaSignal{"rangeMOmegaSignal", {1.655f, 1.685f}, "Omega mass range for signal extraction"}; } omegaConfigs; // Configurables for Pions selection @@ -234,7 +229,6 @@ struct PhiStrangeCorrelation { Configurable selectPionInSigRegion{"selectPionInSigRegion", true, "Select Pion candidates in signal region"}; Configurable pidTPCMax{"pidTPCMax", 3.0f, "Maximum nSigma TPC"}; Configurable pidTOFMax{"pidTOFMax", 3.0f, "Maximum nSigma TOF"}; - // Configurable tofPIDThreshold{"tofPIDThreshold", 0.5f, "Minimum pT after which TOF PID is applicable"}; } pionConfigs; // Configurables on phi pT bins @@ -242,26 +236,28 @@ struct PhiStrangeCorrelation { Configurable> binspTPhiExt{"binspTPhiExt", {0.0, 0.4, 0.8, 1.4, 2.0, 2.8, 4.0, 6.0, 10.0}, "pT bin limits for Phi extended for MC Gen"}; // Configurable on K0S pT bins - Configurable> binspTK0S{"binspTK0S", {0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for K0S"}; + Configurable> binspTK0S{"binspTK0S", {0.0, 0.3, 0.5, 0.8, 1.2, 1.6, 2.0, 2.4, 3.0, 4.2, 6.4}, "pT bin limits for K0S"}; Configurable> binspTK0SExt{"binspTK0SExt", {0.0, 0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for K0S extended for MC Gen"}; // Configurable on Lambda pT bins - Configurable> binspTLambda{"binspTLambda", {0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Lambda"}; + Configurable> binspTLambda{"binspTLambda", {0.8, 1.2, 1.6, 2.0, 2.4, 3.0, 4.2, 6.4}, "pT bin limits for Lambda"}; Configurable> binspTLambdaExt{"binspTLambdaExt", {0.0, 0.1, 0.5, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Lambda extended for MC Gen"}; // Configurable on Xi pT bins - Configurable> binspTXi{"binspTXi", {0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Xi"}; + Configurable> binspTXi{"binspTXi", {0.8, 1.2, 1.6, 2.0, 2.4, 3.0, 4.2, 6.5}, "pT bin limits for Xi"}; Configurable> binspTXiExt{"binspTXiExt", {0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Xi extended for MC Gen"}; // Configurable on Omega pT bins - Configurable> binspTOmega{"binspTOmega", {0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Omega"}; + Configurable> binspTOmega{"binspTOmega", {0.8, 1.2, 1.6, 2.0, 2.4, 3.0, 4.2, 6.5}, "pT bin limits for Omega"}; Configurable> binspTOmegaExt{"binspTOmegaExt", {0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.5, 3.0, 4.0, 6.0}, "pT bin limits for Omega extended for MC Gen"}; // Configurable on pion pT bins Configurable> binspTPi{"binspTPi", {0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for Pions"}; Configurable> binspTPiExt{"binspTPiExt", {0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for Pions extended for MC Gen"}; - Configurable> activeCorrelationTypes{"activeCorrelationTypes", {true, false, false, false, false, true}, "Enable correlation types: 0 - K0S, 1 - Lambda, 2 - AntiLambda, 3 - Xi, 4 - Omega, 5 - Pion"}; + // The species correlated with the phi, by name (those of AssocParticleLabels): a train configuration then says which + // species were on, which an array of switches, written as bare elements, does not + Configurable> activeCorrelationTypes{"activeCorrelationTypes", {"K0S", "Lambda", "AntiLambda", "Xi", "Omega", "Pi"}, "Species correlated with the phi, any of: K0S, Lambda, AntiLambda, Xi, Omega, Pi"}; // Configurables for delta y selection struct : ConfigurableGroup { @@ -276,7 +272,6 @@ struct PhiStrangeCorrelation { Configurable applyEfficiency{"applyEfficiency", false, "Use efficiency for filling histograms"}; Configurable useEffInterpolation{"useEffInterpolation", false, "If true, interpolates efficiency map, else uses bin center"}; Configurable applyPhiEfficiency{"applyPhiEfficiency", false, "Apply efficiency for Phi candidates"}; - Configurable propagateEffError{"propagateEffError", false, "Propagate efficiency error"}; Configurable perPeriodEfficiency{"perPeriodEfficiency", false, "Use per period efficiency maps"}; } efficiencyConfigs; @@ -290,17 +285,20 @@ struct PhiStrangeCorrelation { // Configurables for minimum pt selection in McGen struct : ConfigurableGroup { Configurable minPtPhi{"minPtPhi", 0.4f, "Minimum pT for Phi candidates"}; - Configurable minPtK0S{"minPtK0S", 0.1f, "Minimum pT for K0S candidates"}; - Configurable minPtLambda{"minPtLambda", 0.2f, "Minimum pT for Lambda candidates"}; + Configurable minPtK0S{"minPtK0S", 0.0f, "Minimum pT for K0S candidates"}; + Configurable minPtLambda{"minPtLambda", 0.8f, "Minimum pT for Lambda candidates"}; Configurable minPtXi{"minPtXi", 0.8f, "Minimum pT for Xi candidates"}; Configurable minPtOmega{"minPtOmega", 0.8f, "Minimum pT for Omega candidates"}; Configurable minPtPion{"minPtPion", 0.2f, "Minimum pT for Pion candidates"}; Configurable bypassPtCut{"bypassPtCut", false, "Bypass the minimum pt cut at MCGen level"}; } minPtMcGenConfigs; - // Filter on phi selected collisions - Filter collisionFilter = (eventSelectionType == 0 && aod::lf_selection_event::defaultSel == true) || - (eventSelectionType == 1 && aod::lf_selection_event::defaultSel == true && aod::lf_selection_event::phimesonSel == true); + // The generated phi of the efficiency: every channel by default, so that the phi efficiency holds the BR to K+K- as + // every other efficiency holds that of its channel; or phi -> K+K- only, the BR then left to be applied explicitly + Configurable phiEfficiencyKKOnly{"phiEfficiencyKKOnly", false, "Generated phi of the efficiency: false - every decay channel (the efficiency includes the BR to K+K-), true - phi -> K+K- only"}; + + // Filter on the selection level: eventSelectionType 0 keeps kDefault and above, 1 keeps kDefaultWithPhi + Filter collisionFilter = aod::lf_selection_event::selectionLevel > as(eventSelectionType); // Defining the type of the collisions for data and MC using SelCollisions = soa::Filtered>; @@ -326,24 +324,6 @@ struct PhiStrangeCorrelation { DEFINE_PRESLICE(omega, OmegaReduced, cascade) #undef DEFINE_PRESLICE - /*Preslice phiCandDataPerCollision = aod::lf_selection_phi_candidate::collisionId; - Preslice phiCandMcRecoPerCollision = aod::lf_selection_phi_candidate::collisionId; - - Preslice k0sDataPerCollision = aod::v0::collisionId; - Preslice k0sMcRecoPerCollision = aod::v0::collisionId; - - Preslice lambdaDataPerCollision = aod::v0::collisionId; - Preslice lambdaMcRecoPerCollision = aod::v0::collisionId; - - Preslice antiLambdaDataPerCollision = aod::v0::collisionId; - Preslice antiLambdaMcRecoPerCollision = aod::v0::collisionId; - - Preslice xiDataPerCollision = aod::cascade::collisionId; - Preslice xiMcRecoPerCollision = aod::cascade::collisionId; - - Preslice omegaDataPerCollision = aod::cascade::collisionId; - Preslice omegaMcRecoPerCollision = aod::cascade::collisionId;*/ - Preslice pionTrackDataPerCollision = aod::track::collisionId; Preslice pionTrackMcRecoPerCollision = aod::track::collisionId; @@ -355,6 +335,7 @@ struct PhiStrangeCorrelation { EffMapPtr effMapPhi; std::array effMapsAssoc{}; + std::array isCorrelationTypeActive{}; // from activeCorrelationTypes, in init // Binning policy and axes for mixed event ConfigurableAxis axisVertexMixing{"axisVertexMixing", {10, -10.0f, 10.0f}, "Z vertex axis binning for mixing"}; @@ -377,12 +358,6 @@ struct PhiStrangeCorrelation { float multiplicity{}; std::vector phiParticles; std::array, kAssocPartSize> assocParticles; - /*std::vector k0sParticles; - std::vector lambdaParticles; - std::vector antilambdaParticles; - std::vector xiParticles; - std::vector omegaParticles; - std::vector pionParticles;*/ }; // Buffer for mixed event, organized as a vector of deques, one for each multiplicity bin, containing the past events with their particles of interest needed for mixing @@ -392,36 +367,39 @@ struct PhiStrangeCorrelation { void init(InitContext&) { - AxisSpec vertexZAxis = {100, -cutZVertex, cutZVertex, "vrtx_{Z} [cm]"}; // TO BE REMOVED + // From the names to the positions of AssocParticleLabels, which the loops below index + for (const auto& name : activeCorrelationTypes.value) { + const auto label = std::ranges::find(AssocParticleLabels, name); + if (label == AssocParticleLabels.end()) { + LOG(fatal) << "activeCorrelationTypes: unknown species '" << name << "', expected any of " << fmt::format("{}", fmt::join(AssocParticleLabels, ", ")); + } + isCorrelationTypeActive[std::distance(AssocParticleLabels.begin(), label)] = true; + } + + AxisSpec vertexZAxis = {100, -cutZVertex, cutZVertex, "vrtx_{Z} [cm]"}; AxisSpec yAxis = {yConfigs.nBinsY, -yConfigs.cfgYAcceptance, yConfigs.cfgYAcceptance, "#it{y}"}; AxisSpec deltayAxis = {yConfigs.nBinsDeltaY, -1.0f, 1.0f, "#Delta#it{y}"}; AxisSpec deltaphiAxis = {72, -o2::constants::math::PIHalf, o2::constants::math::PIHalf * 3, "#Delta#varphi"}; - AxisSpec multAxis = {120, 0.0f, 120.0f, "centFT0M"}; AxisSpec binnedmultAxis{std::vector(binsMult), "centFT0M"}; AxisSpec massPhiAxis = {200, 0.9f, 1.2f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec pTPhiAxis = {120, 0.0f, 12.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTPhiAxis{std::vector(binspTPhi), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTPhiAxisExt{std::vector(binspTPhiExt), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massK0SAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec pTK0SAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTK0SAxis{std::vector(binspTK0S), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTK0SAxisExt{std::vector(binspTK0SExt), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massLambdaAxis = {200, 1.1f, 1.13f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec pTLambdaAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTLambdaAxis{std::vector(binspTLambda), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTLambdaAxisExt{std::vector(binspTLambdaExt), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massXiAxis = {200, 1.3f, 1.4f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec pTXiAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTXiAxis{std::vector(binspTXi), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTXiAxisExt{std::vector(binspTXiExt), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec massOmegaAxis = {200, 1.65f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - AxisSpec pTOmegaAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTOmegaAxis{std::vector(binspTOmega), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTOmegaAxisExt{std::vector(binspTOmegaExt), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec nSigmaPiAxis = {100, -10.0f, 10.0f, "N#sigma #pi"}; - AxisSpec pTPiAxis = {50, 0.0f, 5.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTPiAxis{std::vector(binspTPi), "#it{p}_{T} (GeV/#it{c})"}; AxisSpec binnedpTPiAxisExt{std::vector(binspTPiExt), "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec pTBeyondMapAxis = {100, 0.0f, 50.0f, "#it{p}_{T} (GeV/#it{c})"}; // the binned pT axes end where these candidates begin std::array massAxes = {massK0SAxis, massLambdaAxis, massLambdaAxis, massXiAxis, massOmegaAxis, nSigmaPiAxis}; std::array binnedpTAxes = {binnedpTK0SAxis, binnedpTLambdaAxis, binnedpTLambdaAxis, binnedpTXiAxis, binnedpTOmegaAxis, binnedpTPiAxis}; @@ -430,7 +408,16 @@ struct PhiStrangeCorrelation { std::array assocTitles = {"K0Short", "Lambda", "AntiLambda", "Xi", "Omega", "Pion"}; std::array dirNames = {"k0s", "lambda", "antilambda", "xi", "omega", "pi"}; - histos.add("phi/h3PhiData", "Invariant mass of Phi in Data", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + histos.add("phi/h3PhiData", "Invariant mass of Phi in Data", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}, true); + + // Entries dropped because an efficiency could not be computed (see computeWeight), in the coordinates of the + // particle whose efficiency failed: SE counts phi candidates (each with all its pairs) and pairs lost to the + // associated efficiency, ME the pairs lost to the associated efficiency (its phi are those of SE) + histos.add("zeroEfficiency/SE/h3Phi", "Phi candidates dropped for zero Phi efficiency, SE", kTH3F, {binnedmultAxis, binnedpTPhiAxis, yAxis}); + + // Entries dropped because the particle is at or beyond the last pT bin of its efficiency map (isPhiBeyondMap, + // isAssocBeyondMap), counted as zeroEfficiency/ is + histos.add("outOfMap/SE/h3Phi", "Phi candidates dropped beyond the Phi efficiency map, SE", kTH3F, {binnedmultAxis, pTBeyondMapAxis, yAxis}); histos.add("phi/h4PhiMCReco", "Phi in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTPhiAxis, yAxis}); histos.add("phi/h3PhiMCGen", "Phi in MC Gen", kTH3F, {binnedmultAxis, binnedpTPhiAxis, yAxis}); @@ -444,20 +431,28 @@ struct PhiStrangeCorrelation { std::string dir = dirNames[i]; if (i == kPion) { - histos.add("phiPi/h6PhiPiTPCData", "Invariant mass of Phi vs nSigmaTPC of Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); - histos.add("phiPi/h6PhiPiTPCDataME", "Invariant mass of Phi vs nSigmaTPC of Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); - histos.add("phiPi/h6PhiPiTOFData", "Invariant mass of Phi vs nSigmaTOF of Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); - histos.add("phiPi/h6PhiPiTOFDataME", "Invariant mass of Phi vs nSigmaTOF of Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); + histos.add("phiPi/h6PhiPiTPCData", "Invariant mass of Phi vs nSigmaTPC of Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); + histos.add("phiPi/h6PhiPiTPCDataME", "Invariant mass of Phi vs nSigmaTPC of Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); + histos.add("phiPi/h6PhiPiTOFData", "Invariant mass of Phi vs nSigmaTOF of Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); + histos.add("phiPi/h6PhiPiTOFDataME", "Invariant mass of Phi vs nSigmaTOF of Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); } else { - histos.add(fmt::format("phi{}/h6Phi{}Data", pName, pName).c_str(), fmt::format("Invariant mass of Phi vs Invariant mass of {} in Data", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); - histos.add(fmt::format("phi{}/h6Phi{}DataME", pName, pName).c_str(), fmt::format("Invariant mass of Phi vs Invariant mass of {} in Data ME", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}); + histos.add(fmt::format("phi{}/h6Phi{}Data", pName, pName).c_str(), fmt::format("Invariant mass of Phi vs Invariant mass of {} in Data", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); + histos.add(fmt::format("phi{}/h6Phi{}DataME", pName, pName).c_str(), fmt::format("Invariant mass of Phi vs Invariant mass of {} in Data ME", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, massPhiAxis, massAxes[i]}, true); } for (const auto& label : PhiMassRegionLabels) { - histos.add(fmt::format("phi{}/h5Phi{}Data{}", pName, pName, label).c_str(), fmt::format("Deltay vs deltaphi for Phi and {} in Data", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phi{}/h5Phi{}DataME{}", pName, pName, label).c_str(), fmt::format("Deltay vs deltaphi for Phi and {} in Data ME", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, deltaphiAxis}); + histos.add(fmt::format("phi{}/h5Phi{}Data{}", pName, pName, label).c_str(), fmt::format("Deltay vs deltaphi for Phi and {} in Data", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, deltaphiAxis}, true); + histos.add(fmt::format("phi{}/h5Phi{}DataME{}", pName, pName, label).c_str(), fmt::format("Deltay vs deltaphi for Phi and {} in Data ME", pTitle).c_str(), kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTAxes[i], deltayAxis, deltaphiAxis}, true); } + histos.add(fmt::format("zeroEfficiency/SE/h3{}", pName).c_str(), fmt::format("Phi-{} pairs dropped for zero {} efficiency, SE", pTitle, pTitle).c_str(), kTH3F, {binnedmultAxis, binnedpTAxes[i], yAxis}); + histos.add(fmt::format("zeroEfficiency/ME/h3{}", pName).c_str(), fmt::format("Phi-{} pairs dropped for zero {} efficiency, ME", pTitle, pTitle).c_str(), kTH3F, {binnedmultAxis, binnedpTAxes[i], yAxis}); + histos.add(fmt::format("outOfMap/SE/h3{}", pName).c_str(), fmt::format("Phi-{} pairs dropped beyond the {} efficiency map, SE", pTitle, pTitle).c_str(), kTH3F, {binnedmultAxis, pTBeyondMapAxis, yAxis}); + histos.add(fmt::format("outOfMap/ME/h3{}", pName).c_str(), fmt::format("Phi-{} pairs dropped beyond the {} efficiency map, ME", pTitle, pTitle).c_str(), kTH3F, {binnedmultAxis, pTBeyondMapAxis, yAxis}); + + // h4MCReco is cut in the signal region (mass window, pion nSigma window) only if selectInSigRegion is on, + // as the pairs are (isAssocValid). With selectPionInSigRegion off, the pions' is the efficiency without the + // window, whose own efficiency is then taken from the producer's nSigma histograms (MC) or from the data fits histos.add(fmt::format("{}/h4{}MCReco", dir, pName).c_str(), fmt::format("{} in MC Reco", pTitle).c_str(), kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTAxes[i], yAxis}); histos.add(fmt::format("{}/h3{}MCGen", dir, pName).c_str(), fmt::format("{} in MC Gen", pTitle).c_str(), kTH3F, {binnedmultAxis, binnedpTAxes[i], yAxis}); histos.add(fmt::format("{}/h4{}MCGenAssocReco", dir, pName).c_str(), fmt::format("{} in MC Gen Assoc Reco", pTitle).c_str(), kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTAxes[i], yAxis}); @@ -473,72 +468,6 @@ struct PhiStrangeCorrelation { histos.add("event/hGenMCAssocRecoMultiplicityPercent", "Generated MC associated Multiplicity Percentile", kTH1F, {binnedmultAxis}); histos.add("event/h2GenMCAssocRecoVertexZvsMult", "Generated MC associated reco Vertex Z vs multiplicity", kTH2F, {vertexZAxis, binnedmultAxis}); - /*histos.add("phiK0S/h6PhiK0SData", "Invariant mass of Phi vs Invariant mass of K0Short in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTK0SAxis, deltayAxis, massPhiAxis, massK0SAxis}); - histos.add("phiLambda/h6PhiLambdaData", "Invariant mass of Phi vs Invariant mass of Lambda in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTLambdaAxis, deltayAxis, massPhiAxis, massLambdaAxis}); - histos.add("phiXi/h6PhiXiData", "Invariant mass of Phi vs Invariant mass of Xi in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTXiAxis, deltayAxis, massPhiAxis, massXiAxis}); - histos.add("phiOmega/h6PhiOmegaData", "Invariant mass of Phi vs Invariant mass of Omega in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTOmegaAxis, deltayAxis, massPhiAxis, massOmegaAxis}); - histos.add("phiPi/h6PhiPiTPCData", "Invariant mass of Phi vs nSigmaTPC Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, massPhiAxis, nSigmaPiAxis}); - histos.add("phiPi/h6PhiPiTOFData", "Invariant mass of Phi vs nSigmaTOF Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, massPhiAxis, nSigmaPiAxis}); - - histos.add("phiK0S/h6PhiK0SDataME", "Invariant mass of Phi vs Invariant mass of K0Short in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTK0SAxis, deltayAxis, massPhiAxis, massK0SAxis}); - histos.add("phiLambda/h6PhiLambdaDataME", "Invariant mass of Phi vs Invariant mass of Lambda in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTLambdaAxis, deltayAxis, massPhiAxis, massLambdaAxis}); - histos.add("phiXi/h6PhiXiDataME", "Invariant mass of Phi vs Invariant mass of Xi in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTXiAxis, deltayAxis, massPhiAxis, massXiAxis}); - histos.add("phiOmega/h6PhiOmegaDataME", "Invariant mass of Phi vs Invariant mass of Omega in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTOmegaAxis, deltayAxis, massPhiAxis, massOmegaAxis}); - histos.add("phiPi/h6PhiPiTPCDataME", "Invariant mass of Phi vs nSigmaTPC Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, massPhiAxis, nSigmaPiAxis}); - histos.add("phiPi/h6PhiPiTOFDataME", "Invariant mass of Phi vs nSigmaTOF Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, massPhiAxis, nSigmaPiAxis});*/ - - /*for (const auto& label : PhiMassRegionLabels) { - histos.add(fmt::format("phiK0S/h5PhiK0SData{}", label).c_str(), "Deltay vs deltaphi for Phi and K0Short in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTK0SAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiLambda/h5PhiLambdaData{}", label).c_str(), "Deltay vs deltaphi for Phi and Lambda in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTLambdaAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiXi/h5PhiXiData{}", label).c_str(), "Deltay vs deltaphi for Phi and Xi in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTXiAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiOmega/h5PhiOmegaData{}", label).c_str(), "Deltay vs deltaphi for Phi and Omega in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTOmegaAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiPi/h5PhiPiData{}", label).c_str(), "Deltay vs deltaphi for Phi and Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, deltaphiAxis}); - - histos.add(fmt::format("phiK0S/h5PhiK0SDataME{}", label).c_str(), "Deltay vs deltaphi for Phi and K0Short in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTK0SAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiLambda/h5PhiLambdaDataME{}", label).c_str(), "Deltay vs deltaphi for Phi and Lambda in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTLambdaAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiXi/h5PhiXiDataME{}", label).c_str(), "Deltay vs deltaphi for Phi and Xi in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTXiAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiOmega/h5PhiOmegaDataME{}", label).c_str(), "Deltay vs deltaphi for Phi and Omega in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTOmegaAxis, deltayAxis, deltaphiAxis}); - histos.add(fmt::format("phiPi/h5PhiPiDataME{}", label).c_str(), "Deltay vs deltaphi for Phi and Pion in Data ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, deltaphiAxis}); - }*/ - - /*histos.add("k0s/h4K0SMCReco", "K0S in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTK0SAxis, yAxis}); - histos.add("k0s/h3K0SMCGen", "K0S in MC Gen", kTH3F, {binnedmultAxis, binnedpTK0SAxis, yAxis}); - histos.add("k0s/h4K0SMCGenAssocReco", "K0S in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTK0SAxis, yAxis}); - - histos.add("lambda/h4LambdaMCReco", "Lambda in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTLambdaAxis, yAxis}); - histos.add("lambda/h3LambdaMCGen", "Lambda in MC Gen", kTH3F, {binnedmultAxis, binnedpTLambdaAxis, yAxis}); - histos.add("lambda/h4LambdaMCGenAssocReco", "Lambda in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTLambdaAxis, yAxis}); - - histos.add("antilambda/h4AntiLambdaMCReco", "AntiLambda in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTLambdaAxis, yAxis}); - histos.add("antilambda/h3AntiLambdaMCGen", "AntiLambda in MC Gen", kTH3F, {binnedmultAxis, binnedpTLambdaAxis, yAxis}); - histos.add("antilambda/h4AntiLambdaMCGenAssocReco", "AntiLambda in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTLambdaAxis, yAxis}); - - histos.add("xi/h4XiMCReco", "Xi in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTXiAxis, yAxis}); - histos.add("xi/h3XiMCGen", "Xi in MC Gen", kTH3F, {binnedmultAxis, binnedpTXiAxis, yAxis}); - histos.add("xi/h4XiMCGenAssocReco", "Xi in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTXiAxis, yAxis}); - - histos.add("omega/h4OmegaMCReco", "Omega in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTOmegaAxis, yAxis}); - histos.add("omega/h3OmegaMCGen", "Omega in MC Gen", kTH3F, {binnedmultAxis, binnedpTOmegaAxis, yAxis}); - histos.add("omega/h4OmegaMCGenAssocReco", "Omega in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTOmegaAxis, yAxis}); - - histos.add("pi/h4PiMCReco", "Pion in MC Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTPiAxis, yAxis}); - histos.add("pi/h3PiMCGen", "Pion in MC Gen", kTH3F, {binnedmultAxis, binnedpTPiAxis, yAxis}); - histos.add("pi/h4PiMCGenAssocReco", "Pion in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTPiAxis, yAxis});*/ - - /*histos.add("phiK0S/h5PhiK0SClosureMCGen", "Deltay vs deltaphi for Phi and K0Short in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTK0SAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiLambda/h5PhiLambdaClosureMCGen", "Deltay vs deltaphi for Phi and Lambda in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTLambdaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiAntiLambda/h5PhiAntiLambdaClosureMCGen", "Deltay vs deltaphi for Phi and AntiLambda in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTLambdaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiXi/h5PhiXiClosureMCGen", "Deltay vs deltaphi for Phi and Xi in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTXiAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiOmega/h5PhiOmegaClosureMCGen", "Deltay vs deltaphi for Phi and Omega in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTOmegaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiPi/h5PhiPiClosureMCGen", "Deltay vs deltaphi for Phi and Pion in MCGen", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTPiAxisExt, deltayAxis, deltaphiAxis}); - - histos.add("phiK0S/h5PhiK0SClosureMCGenME", "Deltay vs deltaphi for Phi and K0Short in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTK0SAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiLambda/h5PhiLambdaClosureMCGenME", "Deltay vs deltaphi for Phi and Lambda in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTLambdaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiAntiLambda/h5PhiAntiLambdaClosureMCGenME", "Deltay vs deltaphi for Phi and AntiLambda in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTLambdaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiXi/h5PhiXiClosureMCGenME", "Deltay vs deltaphi for Phi and Xi in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTXiAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiOmega/h5PhiOmegaClosureMCGenME", "Deltay vs deltaphi for Phi and Omega in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTOmegaAxisExt, deltayAxis, deltaphiAxis}); - histos.add("phiPi/h5PhiPiClosureMCGenME", "Deltay vs deltaphi for Phi and Pion in MCGen ME", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxisExt, binnedpTPiAxisExt, deltayAxis, deltaphiAxis});*/ - // Load efficiency maps from CCDB if (efficiencyConfigs.applyEfficiency) { ccdb->setURL(ccdbUrl); @@ -558,18 +487,18 @@ struct PhiStrangeCorrelation { { std::string path = fmt::format("{}{}", ccdbEfficiencyPath.value, particleName); - auto fetchFromCCDB = [&]() -> std::shared_ptr { - auto mapPtr = runNumber ? ccdb->getForRun(path, *runNumber) : ccdb->get(path); - return std::shared_ptr(mapPtr); - }; + // Fetch once as TH1, the common base, and dispatch on the actual type: the CCDB cache is keyed by path only and + // hands back whatever it holds cast to the requested type, so asking the same path as TH3D and then as TH2D + // would return a TH2 as a non-null TH3 on a cache hit + const TH1* map = runNumber ? ccdb->getForRun(path, *runNumber) : ccdb->get(path); - if (auto map3D = fetchFromCCDB.operator()()) { + if (const auto* map3D = dynamic_cast(map)) { effMap = map3D; LOG(debug) << "Efficiency map (TH3) for " << particleName << " loaded from CCDB"; return; } - if (auto map2D = fetchFromCCDB.operator()()) { + if (const auto* map2D = dynamic_cast(map)) { effMap = map2D; LOG(debug) << "Efficiency map (TH2) for " << particleName << " loaded from CCDB"; return; @@ -595,7 +524,7 @@ struct PhiStrangeCorrelation { // Only load the associated maps that are explicitly enabled for (size_t i = 0; i < kAssocPartSize; ++i) { - if (activeCorrelationTypes->at(i)) { + if (isCorrelationTypeActive[i]) { fetchSingleEfficiencyMapFromCCDB(effMapsAssoc[i], AssocParticleLabels[i], runNumber); } } @@ -607,50 +536,45 @@ struct PhiStrangeCorrelation { } } - // Compute weight based on efficiencies + // Weight of an entry: the inverse of the product of the efficiencies of the maps it reads. Only the weight goes into + // the histograms, whose Sumw2 then gives the statistical variance, sum of w^2. The uncertainty of the maps is not + // added per entry: it is the same for every entry reading a map bin, so it adds linearly within the bin, which a + // per-entry sum in quadrature underestimates by sqrt(N); it is propagated offline. + // + // Empty when an efficiency cannot be computed: a map bin without reconstructed MC, or a candidate outside the map, + // reads 0, and interpolation near such bins can give a non-positive or non-finite value. Such an entry is dropped and + // counted (zeroEfficiency/), as the candidates beyond the last pT bin of the maps are (outOfMap/): a weight of 1 + // instead would mix corrected and uncorrected entries in one bin template - std::pair computeWeightAndError(const BoundEffMaps&... boundEffMaps) + std::optional computeWeight(const BoundEffMaps&... boundEffMaps) { if (!efficiencyConfigs.applyEfficiency) { - return {1.0f, 0.0f}; + return 1.0f; } float effTot = 1.0f; - float relErrSqSum = 0.0f; auto processMap = [&](const auto& boundMap) { - auto [eff, err] = boundMap.getBinEfficiencyAndError(); // Unpack efficiency and error from the map - - if (efficiencyConfigs.useEffInterpolation) { - eff = boundMap.interpolateEfficiency(); - // For simplicity, we keep the error from the bin content even when interpolating, but this can be refined if needed + const float eff = efficiencyConfigs.useEffInterpolation ? boundMap.interpolateEfficiency() : boundMap.getBinEfficiency(); + if (!(eff > 0.0f) || !std::isfinite(eff)) { + return false; } - effTot *= eff; - - if (eff > 0.0f) { - float mapErr = efficiencyConfigs.propagateEffError ? err : 0.0f; // Optionally propagate error, otherwise treat as zero - relErrSqSum += (mapErr / eff) * (mapErr / eff); - } + return true; }; - (processMap(boundEffMaps), ...); // Fold expression to process all bound efficiency maps - - if (effTot <= 0.0f) { - return {1.0f, 0.0f}; + if (!(processMap(boundEffMaps) && ...)) { // Fold expression, stops at the first efficiency that cannot be computed + return std::nullopt; } - float weight = 1.0f / effTot; - float weightErr = weight * std::sqrt(relErrSqSum); // Propagate relative error to the weight - - return {weight, weightErr}; + return 1.0f / effTot; } template - std::pair computeAssocWeight(float multiplicity, const auto& phiCand, const auto& assocCand) + std::optional computePhiAssocWeight(float multiplicity, const auto& phiCand, const auto& assocCand) { - return computeWeightAndError(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()), - BoundEfficiencyMap(effMapsAssoc[PartType], multiplicity, assocCand.pt(), assocCand.y())); + return computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()), + BoundEfficiencyMap(effMapsAssoc[PartType], multiplicity, assocCand.pt(), assocCand.y())); } float getDeltaPhi(float phiTrigger, float phiAssociated) @@ -712,95 +636,58 @@ struct PhiStrangeCorrelation { } } - template - void customFillHist(auto histId, const std::pair& weightPair, Args... coords) + // A candidate at or beyond the last pT bin of its efficiency map has no efficiency to read: with the efficiencies + // applied it is dropped, and counted in outOfMap/ + bool isPhiBeyondMap(float pt) { - auto hist = histos.get(histId); - if (!hist) { - return; - } - - // Extract the weight and its propagated uncertainty - auto [w, wErr] = weightPair; - - // Find the global bin number for the given physical coordinates - int bin = hist->FindFixBin(coords...); - - // Retrieve the previous bin content and its absolute error - double prevContent = hist->GetBinContent(bin); - double prevErr = hist->GetBinError(bin); - - // Calculate the new content by adding the current weight - double newContent = prevContent + w; - - // Error propagation in quadrature: - // prevErr^2 : previous accumulated variance - // (w * w) : statistical fluctuation added by this specific particle count - // (wErr * wErr) : systematic uncertainty added by the efficiency map inaccuracy - double newErr = std::sqrt(prevErr * prevErr + (w * w) + (wErr * wErr)); - - // Update the histogram bin - hist->SetBinContent(bin, newContent); - hist->SetBinError(bin, newErr); + return efficiencyConfigs.applyEfficiency && efficiencyConfigs.applyPhiEfficiency && pt >= binspTPhi.value.back(); } - template - void customFillTHn(auto histId, const std::pair& weightPair, Args... coords) + template + bool isAssocBeyondMap(float pt) { - auto hist = histos.get(histId); - if (!hist) { - return; + if (!efficiencyConfigs.applyEfficiency) { + return false; + } + if constexpr (PartType == kK0S) { + return pt >= binspTK0S.value.back(); + } else if constexpr (PartType == kLambda || PartType == kAntiLambda) { + return pt >= binspTLambda.value.back(); + } else if constexpr (PartType == kXi) { + return pt >= binspTXi.value.back(); + } else if constexpr (PartType == kOmega) { + return pt >= binspTOmega.value.back(); + } else { + static_assert(PartType == kPion, "Unsupported particle type in isAssocBeyondMap"); + return pt >= binspTPi.value.back(); } - - // Extract the weight and its propagated uncertainty - auto [w, wErr] = weightPair; - - // Create an array of floats for the coordinates to pass to GetBin and SetBinContent - std::array coordArray{static_cast(coords)...}; - - // Find the bin number. - // The 'true' flag is mandatory: it allocates the bin in memory if it doesn't exist yet. - auto bin = hist->GetBin(coordArray.data(), true); - - // Retrieve the previous content and the squared error (variance) - double prevContent = hist->GetBinContent(bin); - double prevErr2 = hist->GetBinError2(bin); - - // Calculate the new content - double newContent = prevContent + w; - - // Add the new variances to the accumulated variance - // (w * w) is the statistical term, (wErr * wErr) is the map uncertainty term - double newErr2 = prevErr2 + (w * w) + (wErr * wErr); - - // Update the THnSparse bin - hist->SetBinContent(bin, newContent); - hist->SetBinError2(bin, newErr2); // Note: SetBinError2 takes the squared error directly } + // The signal-region selection (mass or nSigma window) of an associated candidate, for the pairs and for the MC + // reconstructed of the efficiency alike; the pT range of the efficiency maps is checked apart (isAssocBeyondMap), only + // where an efficiency is applied template bool isAssocValid(TAssoc const& assoc) { if constexpr (PartType == kK0S) { const bool applyMassCut = (analysisMode == kDeltaYvsDeltaPhi) && k0sConfigs.selectK0sInSigRegion; const auto& [minMass, maxMass] = k0sConfigs.rangeMK0sSignal.value; - return (!efficiencyConfigs.applyEfficiency || assoc.pt() < binspTK0S->back()) && (!applyMassCut || assoc.inMassRegion(minMass, maxMass)); + return !applyMassCut || assoc.inMassRegion(minMass, maxMass); } else if constexpr (PartType == kLambda || PartType == kAntiLambda) { const bool applyMassCut = (analysisMode == kDeltaYvsDeltaPhi) && lambdaConfigs.selectLambdaInSigRegion; const auto& [minMass, maxMass] = lambdaConfigs.rangeMLambdaSignal.value; - return (!efficiencyConfigs.applyEfficiency || assoc.pt() < binspTLambda->back()) && (!applyMassCut || assoc.inMassRegion(minMass, maxMass)); + return !applyMassCut || assoc.inMassRegion(minMass, maxMass); } else if constexpr (PartType == kXi) { const bool applyMassCut = (analysisMode == kDeltaYvsDeltaPhi) && xiConfigs.selectXiInSigRegion; const auto& [minMass, maxMass] = xiConfigs.rangeMXiSignal.value; - return (!efficiencyConfigs.applyEfficiency || assoc.pt() < binspTXi->back()) && (!applyMassCut || assoc.inMassRegion(minMass, maxMass)); + return !applyMassCut || assoc.inMassRegion(minMass, maxMass); } else if constexpr (PartType == kOmega) { const bool applyMassCut = (analysisMode == kDeltaYvsDeltaPhi) && omegaConfigs.selectOmegaInSigRegion; const auto& [minMass, maxMass] = omegaConfigs.rangeMOmegaSignal.value; - return (!efficiencyConfigs.applyEfficiency || assoc.pt() < binspTOmega->back()) && (!applyMassCut || assoc.inMassRegion(minMass, maxMass)); + return !applyMassCut || assoc.inMassRegion(minMass, maxMass); } else if constexpr (PartType == kPion) { const bool applyNSigmaCut = (analysisMode == kDeltaYvsDeltaPhi) && pionConfigs.selectPionInSigRegion; - return (!efficiencyConfigs.applyEfficiency || assoc.pt() < binspTPi->back()) && - (!applyNSigmaCut || assoc.inNSigmaRegion(pionConfigs.pidTPCMax, pionConfigs.pidTOFMax)); + return !applyNSigmaCut || assoc.inNSigmaRegion(pionConfigs.pidTPCMax, pionConfigs.pidTOFMax); } else { static_assert(PartType == kK0S || PartType == kLambda || PartType == kAntiLambda || PartType == kXi || PartType == kOmega || PartType == kPion, @@ -816,7 +703,7 @@ struct PhiStrangeCorrelation { } template - void fillPhiAssocCorrelation(TPhiCand const& phiCand, TAssoc const& assoc, float multiplicity, const std::pair& weight) + void fillPhiAssocCorrelation(TPhiCand const& phiCand, TAssoc const& assoc, float multiplicity, float weight) { const std::array, kPhiMassRegions> phiMassRegions = {phiConfigs.rangeMPhiSignal, phiConfigs.rangeMPhiSideband}; @@ -825,13 +712,13 @@ struct PhiStrangeCorrelation { if (analysisMode == kMassvsMass) { -#define FILL_MASS_CASE(PART_ENUM, PART_STR) \ - if constexpr (PartType == PART_ENUM) { \ - if constexpr (IsME) { \ - customFillTHn(HIST("phi" PART_STR "/h6Phi" PART_STR "DataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.m()); \ - } else { \ - customFillTHn(HIST("phi" PART_STR "/h6Phi" PART_STR "Data"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.m()); \ - } \ +#define FILL_MASS_CASE(PART_ENUM, PART_STR) \ + if constexpr (PartType == PART_ENUM) { \ + if constexpr (IsME) { \ + histos.fill(HIST("phi" PART_STR "/h6Phi" PART_STR "DataME"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.m(), weight); \ + } else { \ + histos.fill(HIST("phi" PART_STR "/h6Phi" PART_STR "Data"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.m(), weight); \ + } \ } FILL_MASS_CASE(kK0S, "K0S"); @@ -841,67 +728,28 @@ struct PhiStrangeCorrelation { FILL_MASS_CASE(kOmega, "Omega"); if constexpr (PartType == kPion) { if constexpr (IsME) { - customFillTHn(HIST("phiPi/h6PhiPiTPCDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTPC()); - customFillTHn(HIST("phiPi/h6PhiPiTOFDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTOF()); + histos.fill(HIST("phiPi/h6PhiPiTPCDataME"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTPC(), weight); + histos.fill(HIST("phiPi/h6PhiPiTOFDataME"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTOF(), weight); } else { - customFillTHn(HIST("phiPi/h6PhiPiTPCData"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTPC()); - customFillTHn(HIST("phiPi/h6PhiPiTOFData"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTOF()); + histos.fill(HIST("phiPi/h6PhiPiTPCData"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTPC(), weight); + histos.fill(HIST("phiPi/h6PhiPiTOFData"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, phiCand.m(), assoc.nSigmaTOF(), weight); } } #undef FILL_MASS_CASE - /*if constexpr (PartType == kK0S) { - if constexpr (IsME) { - customFillTHn(HIST("phiK0S/h6PhiK0SDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } else { - customFillTHn(HIST("phiK0S/h6PhiK0SData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } - } else if constexpr (PartType == kLambda) { - if constexpr (IsME) { - customFillTHn(HIST("phiLambda/h6PhiLambdaDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } else { - customFillTHn(HIST("phiLambda/h6PhiLambdaData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } - } else if constexpr (PartType == kAntiLambda) { - if constexpr (IsME) { - customFillTHn(HIST("phiAntiLambda/h6PhiAntiLambdaDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } else { - customFillTHn(HIST("phiAntiLambda/h6PhiAntiLambdaData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } - } else if constexpr (PartType == kXi) { - if constexpr (IsME) { - customFillTHn(HIST("phiXi/h6PhiXiDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } else { - customFillTHn(HIST("phiXi/h6PhiXiData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } - } else if constexpr (PartType == kOmega) { - if constexpr (IsME) { - customFillTHn(HIST("phiOmega/h6PhiOmegaDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } else { - customFillTHn(HIST("phiOmega/h6PhiOmegaData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.m()); - } - } else if constexpr (PartType == kPion) { - if constexpr (IsME) { - customFillTHn(HIST("phiPi/h6PhiPiTPCDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.nSigmaTPC()); - customFillTHn(HIST("phiPi/h6PhiPiTOFDataME"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.nSigmaTOF()); - } else { - customFillTHn(HIST("phiPi/h6PhiPiTPCData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.nSigmaTPC()); - customFillTHn(HIST("phiPi/h6PhiPiTOFData"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), phiCand.m(), assoc.nSigmaTOF()); - } - }*/ } else if (analysisMode == kDeltaYvsDeltaPhi) { std::function fillSignal; std::function fillSideband; -#define FILL_DYDP_CASE(PART_ENUM, PART_STR) \ - if constexpr (PartType == PART_ENUM) { \ - if constexpr (IsME) { \ - fillSignal = [&]() { customFillTHn(HIST("phi" PART_STR "/h5Phi" PART_STR "DataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi); }; \ - fillSideband = [&]() { customFillTHn(HIST("phi" PART_STR "/h5Phi" PART_STR "DataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi); }; \ - } else { \ - fillSignal = [&]() { customFillTHn(HIST("phi" PART_STR "/h5Phi" PART_STR "DataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi); }; \ - fillSideband = [&]() { customFillTHn(HIST("phi" PART_STR "/h5Phi" PART_STR "DataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi); }; \ - } \ +#define FILL_DYDP_CASE(PART_ENUM, PART_STR) \ + if constexpr (PartType == PART_ENUM) { \ + if constexpr (IsME) { \ + fillSignal = [&]() { histos.fill(HIST("phi" PART_STR "/h5Phi" PART_STR "DataMESignal"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi, weight); }; \ + fillSideband = [&]() { histos.fill(HIST("phi" PART_STR "/h5Phi" PART_STR "DataMESideband"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi, weight); }; \ + } else { \ + fillSignal = [&]() { histos.fill(HIST("phi" PART_STR "/h5Phi" PART_STR "DataSignal"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi, weight); }; \ + fillSideband = [&]() { histos.fill(HIST("phi" PART_STR "/h5Phi" PART_STR "DataSideband"), multiplicity, phiCand.pt(), assoc.pt(), deltaY, deltaPhi, weight); }; \ + } \ } FILL_DYDP_CASE(kK0S, "K0S"); @@ -912,56 +760,6 @@ struct PhiStrangeCorrelation { FILL_DYDP_CASE(kPion, "Pi"); #undef FILL_DYDP_CASE - /*if constexpr (PartType == kK0S) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiK0S/h5PhiK0SDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiK0S/h5PhiK0SDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiK0S/h5PhiK0SDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiK0S/h5PhiK0SDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - } else if constexpr (PartType == kLambda) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiLambda/h5PhiLambdaDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiLambda/h5PhiLambdaDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiLambda/h5PhiLambdaDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiLambda/h5PhiLambdaDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - } else if constexpr (PartType == kAntiLambda) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiAntiLambda/h5PhiAntiLambdaDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiAntiLambda/h5PhiAntiLambdaDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiAntiLambda/h5PhiAntiLambdaDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiAntiLambda/h5PhiAntiLambdaDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - } else if constexpr (PartType == kXi) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiXi/h5PhiXiDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiXi/h5PhiXiDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiXi/h5PhiXiDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiXi/h5PhiXiDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - } else if constexpr (PartType == kOmega) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiOmega/h5PhiOmegaDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiOmega/h5PhiOmegaDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiOmega/h5PhiOmegaDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiOmega/h5PhiOmegaDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - } else if constexpr (PartType == kPion) { - if constexpr (IsME) { - fillSignal = [&]() { customFillTHn(HIST("phiPi/h5PhiPiDataMESignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiPi/h5PhiPiDataMESideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } else { - fillSignal = [&]() { customFillTHn(HIST("phiPi/h5PhiPiDataSignal"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - fillSideband = [&]() { customFillTHn(HIST("phiPi/h5PhiPiDataSideband"), weight, multiplicity, phiCand.pt(), assoc.pt(), phiCand.y() - assoc.y(), getDeltaPhi(phiCand.phi(), assoc.phi())); }; - } - }*/ - static_for<0, kPhiMassRegions - 1>([&](auto i_idx) { constexpr unsigned int Idx = i_idx.value; const auto& [minMassPhi, maxMassPhi] = phiMassRegions[Idx]; @@ -979,18 +777,38 @@ struct PhiStrangeCorrelation { template void processOneAssocPair(TPhiCand const& phiCand, TAssoc const& assoc, float multiplicity) { + if (isAssocBeyondMap(assoc.pt())) { + if constexpr (IsME) { + histos.fill(HIST("outOfMap/ME/h3") + HIST(AssocParticleLabels[PartType]), multiplicity, assoc.pt(), assoc.y()); + } else { + histos.fill(HIST("outOfMap/SE/h3") + HIST(AssocParticleLabels[PartType]), multiplicity, assoc.pt(), assoc.y()); + } + return; + } + if (!isAssocValid(assoc)) { return; } - auto weight = computeAssocWeight(multiplicity, phiCand, assoc); - fillPhiAssocCorrelation(phiCand, assoc, multiplicity, weight); + // The callers have already checked the phi efficiency, so a weight that cannot be computed here comes from the + // associated one + const auto weight = computePhiAssocWeight(multiplicity, phiCand, assoc); + if (!weight) { + if constexpr (IsME) { + histos.fill(HIST("zeroEfficiency/ME/h3") + HIST(AssocParticleLabels[PartType]), multiplicity, assoc.pt(), assoc.y()); + } else { + histos.fill(HIST("zeroEfficiency/SE/h3") + HIST(AssocParticleLabels[PartType]), multiplicity, assoc.pt(), assoc.y()); + } + return; + } + + fillPhiAssocCorrelation(phiCand, assoc, multiplicity, *weight); } template void processOneAssocSpeciesSE(TPhiCand const& phiCand, TAssocCands const& assocCands, float multiplicity) { - if (!activeCorrelationTypes->at(PartType)) { + if (!isCorrelationTypeActive[PartType]) { return; } @@ -1010,12 +828,19 @@ struct PhiStrangeCorrelation { } for (const auto& phiCand : phiCandidates) { - if (efficiencyConfigs.applyEfficiency && efficiencyConfigs.applyPhiEfficiency && phiCand.pt() >= binspTPhi->back()) { + if (isPhiBeyondMap(phiCand.pt())) { + histos.fill(HIST("outOfMap/SE/h3Phi"), multiplicity, phiCand.pt(), phiCand.y()); + continue; + } + + // Checked once per candidate, before the trigger count and the pairs, so that both see the same phi candidates + const auto weightPhi = computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y())); + if (!weightPhi) { + histos.fill(HIST("zeroEfficiency/SE/h3Phi"), multiplicity, phiCand.pt(), phiCand.y()); continue; } - auto weightPhi = computeWeightAndError(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y())); - customFillHist(HIST("phi/h3PhiData"), weightPhi, multiplicity, phiCand.pt(), phiCand.m()); + histos.fill(HIST("phi/h3PhiData"), multiplicity, phiCand.pt(), phiCand.m(), *weightPhi); // Fold expression: elaborate the correlation for each associated particle type in the parameter pack (processOneAssocSpeciesSE(phiCand, *assocInputs.candidates, multiplicity), ...); @@ -1067,6 +892,12 @@ struct PhiStrangeCorrelation { template void processPhiAssocME(TCollisions const& collisions, TPhiCands const& phiCandidates, TAssocCands const& assocCands) { + // As in the same event: a species left out of activeCorrelationTypes has no pairs, and no efficiency map loaded, + // whose absence would read as an efficiency of 1 + if (!isCorrelationTypeActive[PartType]) { + return; + } + auto tuplePhiAssoc = std::make_tuple(phiCandidates, assocCands); Pair pairPhiAssoc{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tuplePhiAssoc, &cache}; @@ -1079,7 +910,8 @@ struct PhiStrangeCorrelation { } for (const auto& [phiCand, assoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(phiCands, assocRed))) { - if (efficiencyConfigs.applyEfficiency && efficiencyConfigs.applyPhiEfficiency && phiCand.pt() >= binspTPhi->back()) { + // Not counted: the phi of c1 are those of the same event, already counted there once each + if (isPhiBeyondMap(phiCand.pt()) || !computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()))) { continue; } @@ -1121,126 +953,6 @@ struct PhiStrangeCorrelation { #undef DEFINE_ME_PROCESSES #undef DO_PROCESS_SWITCH - /*void processPhiK0SMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::K0sReducedCandidatesData const& k0sReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, k0sReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiK0SMEDataLike, "Process function for Phi-K0S 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiK0SMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::K0sReducedCandidatesMcReco const& k0sReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, k0sReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiK0SMEMCWithPDG, "Process function for Phi-K0S 2D Correlations in MC with PDG ME", true); - - void processPhiLambdaMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::LambdaReducedCandidatesData const& lambdaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, lambdaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiLambdaMEDataLike, "Process function for Phi-Lambda 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiLambdaMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::LambdaReducedCandidatesMcReco const& lambdaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, lambdaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiLambdaMEMCWithPDG, "Process function for Phi-Lambda 2D Correlations in MC with PDG ME", true); - - void processPhiAntiLambdaMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::AntiLambdaReducedCandidatesData const& antilambdaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, antilambdaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiAntiLambdaMEDataLike, "Process function for Phi-AntiLambda 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiAntiLambdaMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::AntiLambdaReducedCandidatesMcReco const& antilambdaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, antilambdaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiAntiLambdaMEMCWithPDG, "Process function for Phi-AntiLambda 2D Correlations in MC with PDG ME", true); - - void processPhiXiMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::XiReducedCandidatesData const& xiReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, xiReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiXiMEDataLike, "Process function for Phi-Xi 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiXiMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::XiReducedCandidatesMcReco const& xiReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, xiReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiXiMEMCWithPDG, "Process function for Phi-Xi 2D Correlations in MC with PDG ME", true); - - void processPhiOmegaMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::OmegaReducedCandidatesData const& omegaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, omegaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiOmegaMEDataLike, "Process function for Phi-Omega 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiOmegaMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::OmegaReducedCandidatesMcReco const& omegaReduced, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, omegaReduced); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiOmegaMEMCWithPDG, "Process function for Phi-Omega 2D Correlations in MC with PDG ME", true); - - void processPhiPionMEDataLike(SelCollisions const& collisions, - aod::PhimesonCandidatesData const& phiCandidates, - aod::PionTracksData const& pionTracks, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, pionTracks); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiPionMEDataLike, "Process function for Phi-Pion 2D Correlations in Data or MC w/o PDG ME", true); - - void processPhiPionMEMCWithPDG(SimCollisions const& collisions, - aod::PhimesonCandidatesMcReco const& phiCandidates, - aod::PionTracksMcReco const& pionTracks, - aod::BCs const&) - { - processPhiAssocME(collisions, phiCandidates, pionTracks); - } - - PROCESS_SWITCH(PhiStrangeCorrelation, processPhiPionMEMCWithPDG, "Process function for Phi-Pion 2D Correlations in MC with PDG ME", true);*/ - void processParticleEfficiency(MCCollisions const& mcCollisions, SimCollisions const& collisions, aod::PhimesonCandidatesMcReco const& phiCandidates, @@ -1290,7 +1002,7 @@ struct PhiStrangeCorrelation { } auto fillRecoAssocSpecies = [&](TAssocInputs const& assocCands, auto histoKey) { - if (!activeCorrelationTypes->at(TAssocInputs::Type)) { + if (!isCorrelationTypeActive[TAssocInputs::Type]) { return; } @@ -1347,7 +1059,7 @@ struct PhiStrangeCorrelation { }; auto fillGenAssocSpecies = [&](auto h3Key, auto h4Key) { - if (!activeCorrelationTypes->at(PartType) || !isGenSpeciesValid(mcParticle, false)) { + if (!isCorrelationTypeActive[PartType] || !isGenSpeciesValid(mcParticle, false)) { return; } @@ -1356,18 +1068,20 @@ struct PhiStrangeCorrelation { switch (std::abs(mcParticle.pdgCode())) { case o2::constants::physics::Pdg::kPhi: - if (eventSelectionType == 0 && mcParticle.pt() >= minPtMcGenConfigs.minPtPhi) { + if (eventSelectionType == 0 && mcParticle.pt() >= minPtMcGenConfigs.minPtPhi && + (!phiEfficiencyKKOnly || RecoDecay::isMatchedMCGen(mcParticles, mcParticle, o2::constants::physics::Pdg::kPhi, std::array{-PDG_t::kKPlus, +PDG_t::kKPlus}))) { fillGenHistos(HIST("phi/h3PhiMCGen"), HIST("phi/h4PhiMCGenAssocReco")); } break; case getPdgCode(): fillGenAssocSpecies.template operator()(HIST("k0s/h3K0SMCGen"), HIST("k0s/h4K0SMCGenAssocReco")); break; - case getPdgCode(): - fillGenAssocSpecies.template operator()(HIST("lambda/h3LambdaMCGen"), HIST("lambda/h4LambdaMCGenAssocReco")); - break; - case getPdgCode(): - fillGenAssocSpecies.template operator()(HIST("antilambda/h3AntiLambdaMCGen"), HIST("antilambda/h4AntiLambdaMCGenAssocReco")); + case getPdgCode(): // the switch is on |PDG|: the sign tells Lambda from AntiLambda + if (mcParticle.pdgCode() == getPdgCode()) { + fillGenAssocSpecies.template operator()(HIST("lambda/h3LambdaMCGen"), HIST("lambda/h4LambdaMCGenAssocReco")); + } else { + fillGenAssocSpecies.template operator()(HIST("antilambda/h3AntiLambdaMCGen"), HIST("antilambda/h4AntiLambdaMCGenAssocReco")); + } break; case getPdgCode(): fillGenAssocSpecies.template operator()(HIST("xi/h3XiMCGen"), HIST("xi/h4XiMCGenAssocReco")); @@ -1393,12 +1107,6 @@ struct PhiStrangeCorrelation { std::vector phiParticles; std::array, kAssocPartSize> assocParticles; - /*std::vector k0sParticles; - std::vector lambdaParticles; - std::vector antilambdaParticles; - std::vector xiParticles; - std::vector omegaParticles; - std::vector pionParticles;*/ // Preliminary loop to fill vectors of particles of interest for the current event, applying pt and y cuts for (const auto& mcParticle : mcParticles) { @@ -1407,25 +1115,29 @@ struct PhiStrangeCorrelation { } auto fillPartCollection = [&]() { - if (activeCorrelationTypes->at(PartType) && isGenSpeciesValid(mcParticle, minPtMcGenConfigs.bypassPtCut.value)) { + if (isCorrelationTypeActive[PartType] && isGenSpeciesValid(mcParticle, minPtMcGenConfigs.bypassPtCut.value)) { assocParticles[PartType].emplace_back(mcParticle.pt(), mcParticle.y(), mcParticle.phi()); } }; // NOLINT(readability/braces) switch (std::abs(mcParticle.pdgCode())) { case o2::constants::physics::Pdg::kPhi: - if (eventSelectionType == 0 && (minPtMcGenConfigs.bypassPtCut || mcParticle.pt() >= minPtMcGenConfigs.minPtPhi)) { + // Only phi -> K+K-, the trigger of data: a phi in another channel would be correlated with its own daughters + // (the K0S of K0S K0L, the pions of pi+pi-pi0), pairs data do not have + if ((minPtMcGenConfigs.bypassPtCut || mcParticle.pt() >= minPtMcGenConfigs.minPtPhi) && + RecoDecay::isMatchedMCGen(mcParticles, mcParticle, o2::constants::physics::Pdg::kPhi, std::array{-PDG_t::kKPlus, +PDG_t::kKPlus})) { phiParticles.emplace_back(mcParticle.pt(), mcParticle.y(), mcParticle.phi()); } break; case getPdgCode(): fillPartCollection.template operator()(); break; - case getPdgCode(): - fillPartCollection.template operator()(); - break; - case getPdgCode(): - fillPartCollection.template operator()(); + case getPdgCode(): // the switch is on |PDG|: the sign tells Lambda from AntiLambda + if (mcParticle.pdgCode() == getPdgCode()) { + fillPartCollection.template operator()(); + } else { + fillPartCollection.template operator()(); + } break; case getPdgCode(): fillPartCollection.template operator()(); @@ -1463,7 +1175,7 @@ struct PhiStrangeCorrelation { static_for<0, AssocParticleLabels.size() - 1>([&](auto i_idx) { constexpr unsigned int Idx = i_idx.value; - if (!activeCorrelationTypes->at(Idx)) { + if (!isCorrelationTypeActive[Idx]) { return; } @@ -1482,7 +1194,7 @@ struct PhiStrangeCorrelation { for (const auto& phiParticle : phiParticles) { static_for<0, AssocParticleLabels.size() - 1>([&](auto i_idx) { constexpr unsigned int Idx = i_idx.value; - if (!activeCorrelationTypes->at(Idx)) { + if (!isCorrelationTypeActive[Idx]) { return; } @@ -1500,12 +1212,6 @@ struct PhiStrangeCorrelation { currentEvent.multiplicity = multiplicity; currentEvent.phiParticles = std::move(phiParticles); currentEvent.assocParticles = std::move(assocParticles); - /*currentEvent.k0sParticles = std::move(k0sParticles); - currentEvent.lambdaParticles = std::move(lambdaParticles); - currentEvent.antilambdaParticles = std::move(antilambdaParticles); - currentEvent.xiParticles = std::move(xiParticles); - currentEvent.omegaParticles = std::move(omegaParticles); - currentEvent.pionParticles = std::move(pionParticles);*/ eventBuffer[multBin].push_front(std::move(currentEvent)); if (eventBuffer[multBin].size() > static_cast(cfgNoMixedEvents.value)) {