From 83d60009846c1013a58f1b7082ff4ac77eb1e012 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 16 Oct 2026 11:34:02 +0200 Subject: [PATCH 01/25] [PWGLF] Fix ownership of CCDB efficiency maps in phiStrangeCorrelation The efficiency maps were wrapped in std::shared_ptr, but with caching on (the default) BasicCCDBManager owns the objects it returns. The double ownership deleted each map twice, and with per-run fetching the reassignment at a run change deleted a map still held by the cache (use-after-free). The maps are now non-owning const pointers. Fetching the same path as TH3D and then as TH2D is also replaced by one fetch as TH1 plus dynamic_cast: the cache is keyed by path only and returns its object cast to the requested type, so on a cache hit a TH2 map came back as a non-null TH3. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 83d250781e4..2c14e1c226e 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -39,6 +39,7 @@ #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; @@ -135,11 +137,8 @@ struct BoundEfficiencyMap { 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) { + // Compile-time branching on the alternative held (TH2 or TH3): generates the exact correct function call + if constexpr (std::is_same_v, const TH2*>) { int bin = mapPtr->FindFixBin(y, z); // 2D case only return {mapPtr->GetBinContent(bin), mapPtr->GetBinError(bin)}; } else { @@ -160,9 +159,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 @@ -558,18 +555,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; From ecefcba58b55f67c620278306e7fffdaec1c3bbf Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 16 Oct 2026 11:50:11 +0200 Subject: [PATCH 02/25] [PWGLF] Clean up phiStrangeCorrelation Remove the code commented out in the previous PR (#18061), the seven unused uniform-binning axes (multAxis and the pT axes, superseded by the binned ones) and the "TO BE REMOVED" tags on cutZVertex and vertexZAxis, which stay. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 322 +----------------- 1 file changed, 2 insertions(+), 320 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 2c14e1c226e..c60b857e84f 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -191,7 +191,7 @@ 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"}; @@ -323,24 +323,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; @@ -374,12 +356,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 @@ -389,34 +365,27 @@ struct PhiStrangeCorrelation { void init(InitContext&) { - AxisSpec vertexZAxis = {100, -cutZVertex, cutZVertex, "vrtx_{Z} [cm]"}; // TO BE REMOVED + 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})"}; @@ -470,72 +439,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); @@ -847,45 +750,6 @@ struct PhiStrangeCorrelation { } #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; @@ -909,56 +773,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]; @@ -1118,126 +932,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, @@ -1390,12 +1084,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) { @@ -1497,12 +1185,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)) { From c6fc31dee11739db6e4f0190450c167a697a9243 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 16 Oct 2026 13:12:46 +0200 Subject: [PATCH 03/25] [PWGLF] Fill the weighted histograms with Sumw2 in phiStrangeCorrelation The uncertainty of the efficiency maps is no longer added per entry, and propagateEffError goes with it. All entries reading a map bin share that bin's uncertainty, so within the bin it adds linearly. Summed in quadrature per entry it is underestimated by sqrt(N), which leaves the statistical error larger by only sqrt(1 + r^2), with r the relative error of the map. It is to be propagated offline. The weight alone goes into the histograms. They are registered with Sumw2 and filled through the registry with the weight as last argument, so each bin carries the statistical variance, sum of w^2. customFillHist and customFillTHn are removed. Bin contents are unchanged; errors are smaller by sqrt(1 + r^2) where the efficiency is applied with propagateEffError=true, and unchanged where it was false. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 181 +++++------------- 1 file changed, 49 insertions(+), 132 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index c60b857e84f..e3260e04352 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -42,7 +42,6 @@ #include #include #include -#include #include #include @@ -127,23 +126,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; // Compile-time branching on the alternative held (TH2 or TH3): generates the exact correct function call if constexpr (std::is_same_v, const TH2*>) { - int bin = mapPtr->FindFixBin(y, z); // 2D case only - return {mapPtr->GetBinContent(bin), mapPtr->GetBinError(bin)}; + 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); @@ -273,7 +270,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; @@ -396,7 +392,7 @@ 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); 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}); @@ -410,18 +406,18 @@ 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("{}/h4{}MCReco", dir, pName).c_str(), fmt::format("{} in MC Reco", pTitle).c_str(), kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTAxes[i], yAxis}); @@ -507,50 +503,37 @@ 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 template - std::pair computeWeightAndError(const BoundEffMaps&... boundEffMaps) + float 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 - } - - 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); - } + effTot *= efficiencyConfigs.useEffInterpolation ? boundMap.interpolateEfficiency() : boundMap.getBinEfficiency(); }; (processMap(boundEffMaps), ...); // Fold expression to process all bound efficiency maps if (effTot <= 0.0f) { - return {1.0f, 0.0f}; + return 1.0f; } - 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) + float computeAssocWeight(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) @@ -612,72 +595,6 @@ struct PhiStrangeCorrelation { } } - template - void customFillHist(auto histId, const std::pair& weightPair, Args... coords) - { - 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); - } - - template - void customFillTHn(auto histId, const std::pair& weightPair, Args... coords) - { - auto hist = histos.get(histId); - if (!hist) { - return; - } - - // 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 - } - template bool isAssocValid(TAssoc const& assoc) { @@ -716,7 +633,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}; @@ -725,13 +642,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"); @@ -741,11 +658,11 @@ 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 @@ -754,15 +671,15 @@ struct PhiStrangeCorrelation { 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"); @@ -825,8 +742,8 @@ struct PhiStrangeCorrelation { continue; } - auto weightPhi = computeWeightAndError(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y())); - customFillHist(HIST("phi/h3PhiData"), weightPhi, multiplicity, phiCand.pt(), phiCand.m()); + auto weightPhi = computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y())); + 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), ...); From a796c78acd8a038df0233da176a5d0d64ed3527b Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 12 Nov 2026 14:53:16 +0100 Subject: [PATCH 04/25] [PWGLF] Drop and count candidates with zero efficiency in phiStrangeCorrelation An efficiency that cannot be computed (a map bin without reconstructed MC, a candidate outside the map, a non-positive or non-finite interpolation) was handled on the product of the two efficiencies: the pair got weight 1, losing the correction of the other particle as well, and nothing recorded it. The efficiency is now checked per particle. computeWeight returns no weight when one of its efficiencies cannot be computed, and the entry is dropped, as candidates beyond the last pT bin of the maps already are. It is counted in zeroEfficiency/{SE,ME}/h3, in the multiplicity, pT and rapidity of the particle whose efficiency failed. A phi candidate is checked once, before the trigger count and its pairs, so that both see the same candidates. computeAssocWeight is renamed computePhiAssocWeight: it is the weight of the pair. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 63 +++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index e3260e04352..8353d7eed1d 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -394,6 +394,12 @@ struct PhiStrangeCorrelation { 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 counts pairs + histos.add("zeroEfficiency/SE/h3Phi", "Phi candidates dropped for zero Phi efficiency, SE", kTH3F, {binnedmultAxis, binnedpTPhiAxis, yAxis}); + histos.add("zeroEfficiency/ME/h3Phi", "Phi-associated pairs dropped for zero Phi efficiency, ME", kTH3F, {binnedmultAxis, binnedpTPhiAxis, 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}); histos.add("phi/h4PhiMCGenAssocReco", "Phi in MC Gen Assoc Reco", kTHnSparseF, {vertexZAxis, binnedmultAxis, binnedpTPhiAxis, yAxis}); @@ -420,6 +426,9 @@ struct PhiStrangeCorrelation { 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("{}/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}); @@ -506,9 +515,14 @@ struct PhiStrangeCorrelation { // 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 + // 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 already are: a weight of 1 instead + // would mix corrected and uncorrected entries in one bin template - float computeWeight(const BoundEffMaps&... boundEffMaps) + std::optional computeWeight(const BoundEffMaps&... boundEffMaps) { if (!efficiencyConfigs.applyEfficiency) { return 1.0f; @@ -517,20 +531,23 @@ struct PhiStrangeCorrelation { float effTot = 1.0f; auto processMap = [&](const auto& boundMap) { - effTot *= efficiencyConfigs.useEffInterpolation ? boundMap.interpolateEfficiency() : boundMap.getBinEfficiency(); + const float eff = efficiencyConfigs.useEffInterpolation ? boundMap.interpolateEfficiency() : boundMap.getBinEfficiency(); + if (!(eff > 0.0f) || !std::isfinite(eff)) { + return false; + } + effTot *= eff; + return true; }; - (processMap(boundEffMaps), ...); // Fold expression to process all bound efficiency maps - - if (effTot <= 0.0f) { - return 1.0f; + if (!(processMap(boundEffMaps) && ...)) { // Fold expression, stops at the first efficiency that cannot be computed + return std::nullopt; } return 1.0f / effTot; } template - float computeAssocWeight(float multiplicity, const auto& phiCand, const auto& assocCand) + std::optional computePhiAssocWeight(float multiplicity, const auto& phiCand, const auto& assocCand) { return computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()), BoundEfficiencyMap(effMapsAssoc[PartType], multiplicity, assocCand.pt(), assocCand.y())); @@ -711,8 +728,19 @@ struct PhiStrangeCorrelation { 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 @@ -742,8 +770,14 @@ struct PhiStrangeCorrelation { continue; } - auto weightPhi = computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y())); - histos.fill(HIST("phi/h3PhiData"), multiplicity, phiCand.pt(), phiCand.m(), weightPhi); + // 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; + } + + 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), ...); @@ -811,6 +845,11 @@ struct PhiStrangeCorrelation { continue; } + if (!computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()))) { + histos.fill(HIST("zeroEfficiency/ME/h3Phi"), multiplicity, phiCand.pt(), phiCand.y()); + continue; + } + processOneAssocPair(phiCand, assoc, multiplicity); } } From 03ce238ef2d39828bf158acb17a01ec08e55c55d Mon Sep 17 00:00:00 2001 From: scannito Date: Wed, 18 Nov 2026 09:27:46 +0100 Subject: [PATCH 05/25] [PWGLF] Keep the generated phi triggers with eventSelectionType 1 in phiStrangeCorrelation In processMCGenClosure a generated phi was taken as trigger only with eventSelectionType == 0. With type 1 the collision filter keeps only events with a generated phi, and the guard then dropped every one of them: the trigger count and the SE/ME pairs of the generated closure stayed empty, with no message. The guard belongs to the efficiency (processParticleEfficiency), where events selected on a phi would bias the phi efficiency; in the closure the phi is the trigger. Only the pT cut is kept. --- PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 8353d7eed1d..beeeb317d24 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -1055,7 +1055,7 @@ struct PhiStrangeCorrelation { switch (std::abs(mcParticle.pdgCode())) { case o2::constants::physics::Pdg::kPhi: - if (eventSelectionType == 0 && (minPtMcGenConfigs.bypassPtCut || mcParticle.pt() >= minPtMcGenConfigs.minPtPhi)) { + if (minPtMcGenConfigs.bypassPtCut || mcParticle.pt() >= minPtMcGenConfigs.minPtPhi) { phiParticles.emplace_back(mcParticle.pt(), mcParticle.y(), mcParticle.phi()); } break; From 19f1a12d59ee8d5af8a60b49d6ba11b8e1d9b949 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 20 Nov 2026 16:21:12 +0100 Subject: [PATCH 06/25] [PWGLF] Optional RCT flag selection in the event selection of phiStrangeCorrelator cfgRCTLabel selects one of the predefined run-condition selections (CBT, CBT_hadronPID, ...) of RCTFlagsChecker; empty, the default, applies none. The cut is applied after INEL>0 in data and after the generated-collision match in MC reconstructed events, and gets its own bin in hEventSelectionData and hEventSelectionMC, before the one of events with a phi candidate. An unknown label stops the task in init instead of at the first event. Also removes the commented-out Produces of the event selection tables. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 456466e1627..2b8b0775255 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -21,6 +21,7 @@ #include "PWGLF/Utils/inelGt.h" #include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/RCTSelectionFlags.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -60,6 +61,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::aod::rctsel; struct PhiMesonCandProducer { // Produce the table with the phi candidates information @@ -1294,15 +1296,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 @@ -1322,6 +1315,9 @@ struct EventSelectionProducer { 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 +1330,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 +1340,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 +1366,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}); @@ -1390,6 +1398,10 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionData"), 3); // INEL>0 collisions + if (!cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + histos.fill(HIST("hEventSelectionData"), 4); // RCTFlags cut multPercentile = collision.centFT0M(); } else { // MCreco event @@ -1420,6 +1432,10 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionMC"), 6); // with at least a gen collision + if (!cfgRCTLabel.value.empty() && !rctFlagsChecker(collision)) { + return false; + } + histos.fill(HIST("hEventSelectionMC"), 7); // RCTFlags cut const auto& mcCollision = collision.template mcCollision_as(); multPercentile = mcCollision.centFT0M(); @@ -1463,14 +1479,14 @@ struct EventSelectionProducer { float multPercentile{0.0f}; if constexpr (!isMC) { - histos.fill(HIST("hEventSelectionData"), 4); + histos.fill(HIST("hEventSelectionData"), 5); multPercentile = collision.centFT0M(); } else { if constexpr (std::is_same_v) { multPercentile = collision.centFT0M(); } else { - histos.fill(HIST("hEventSelectionMC"), 7); + histos.fill(HIST("hEventSelectionMC"), 8); const auto& mcCollision = collision.template mcCollision_as(); multPercentile = mcCollision.centFT0M(); From fcb422319000498b0deb7ea536026a2cd575f933 Mon Sep 17 00:00:00 2001 From: scannito Date: Mon, 23 Nov 2026 10:50:42 +0100 Subject: [PATCH 07/25] [PWGLF] Count generated anti-Lambdas as AntiLambda in phiStrangeCorrelation The generated-particle switches of processParticleEfficiency and processMCGenClosure are on |PDG|, so the AntiLambda case (-3122) could never match: every generated anti-Lambda went into the Lambda histograms and the Lambda generated collection, and the AntiLambda ones stayed empty. The reconstructed side tells them apart by the signed PDG code, so the Lambda efficiency came out about half the true one and the AntiLambda efficiency could not be computed. The |PDG| 3122 case now takes the sign: Lambda for +3122, AntiLambda for -3122. Xi, Omega and pions keep both charges in one species, as on the reconstructed side. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index beeeb317d24..441334f46a6 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -1010,11 +1010,12 @@ struct PhiStrangeCorrelation { 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")); @@ -1062,11 +1063,12 @@ struct PhiStrangeCorrelation { 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()(); From 7a214fb4659cfe0795e8fe21f717ca0c62234a0c Mon Sep 17 00:00:00 2001 From: scannito Date: Mon, 23 Nov 2026 10:50:42 +0100 Subject: [PATCH 08/25] [PWGLF] Phi signal window of the event selection as one pair, as in phiStrangeCorrelation EventSelectionProducer counts events with a phi candidate in a signal window given by two floats in a configurable group; it is now one std::pair rangeMPhiSignal, named and written as the window of the correlation task, with the value every train uses, {1.0, 1.05}. The group, left with one member, is gone. The wagon key changes from minMPhiSignal/maxMPhiSignal to rangeMPhiSignal. Co-Authored-By: Claude Opus 5.5 --- .../TableProducer/Strangeness/phiStrangeCorrelator.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 2b8b0775255..34d2b5076ec 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1307,11 +1307,8 @@ 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"}; @@ -1458,9 +1455,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++; } From c464ae46409be0e43a5ce429efd56bbe44f80ae1 Mon Sep 17 00:00:00 2001 From: scannito Date: Mon, 23 Nov 2026 10:50:42 +0100 Subject: [PATCH 09/25] [PWGLF] Defaults of phiStrangeCorrelation and phiStrangeCorrelator aligned with the trains The defaults of the selections, mass windows, pT binnings and active species are set to the values every current data train uses: the V0 and cascade selections, the phi mass limit of the candidate producer, the signal and sideband windows, the minimum pT of K0S and Lambda, the analysis pT bins of the correlation task and the finer bins of the producers (from which the purity is fitted and merged). MC trains keep overriding the correlation binning with finer bins for the efficiency; every analysis bin edge is also an edge there. No current train changes: all of them set these values. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 46 +++++++++---------- .../Strangeness/phiStrangeCorrelation.cxx | 26 +++++------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 34d2b5076ec..63dafdf3868 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -95,7 +95,7 @@ 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; @@ -103,7 +103,7 @@ struct PhiMesonCandProducer { Configurable trueGenPhi{"trueGenPhi", false, "Phi trigger in MC Collisions: false - gen K+K- pair, true - gen phi meson"}; // 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; @@ -438,10 +438,10 @@ struct V0ReducedCandProducer { // Configurables for V0 selection struct : ConfigurableGroup { - Configurable decayRadius{"decayRadius", 0.5f, "V0 decay radius"}; + Configurable decayRadius{"decayRadius", 0.9f, "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 dcaPosToPV{"dcaPosToPV", 0.06f, "DCA Pos To PV"}; + Configurable dcaNegToPV{"dcaNegToPV", 0.06f, "DCA Neg To PV"}; Configurable furtherV0Selection{"furtherV0Selection", false, "Further V0 selection"}; @@ -454,18 +454,18 @@ struct V0ReducedCandProducer { Configurable paramArmenterosCutK0S{"paramArmenterosCutK0S", 0.2f, "Parameter for Armenteros Cut for K0S"}; - 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 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"}; Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.47f, 0.53f}, "K0S mass range for signal extraction"}; } k0sConfigs; struct : ConfigurableGroup { - Configurable cosPALambda{"cosPALambda", 0.98f, "Lambda CosPA"}; - Configurable ctauLambda{"ctauLambda", 7.89f, "C tau Lambda(cm)"}; + Configurable cosPALambda{"cosPALambda", 0.995f, "Lambda CosPA"}; + Configurable ctauLambda{"ctauLambda", 30.0f, "C tau Lambda(cm)"}; Configurable rejMassLambda{"rejMassLambda", 0.005f, "V0 rej Lambda"}; - 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 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"}; Configurable> rangeMLambdaSignal{"rangeMLambdaSignal", {1.11f, 1.12f}, "Lambda mass range for signal extraction"}; } lambdaConfigs; } v0Configs; @@ -759,32 +759,32 @@ struct CascadeReducedCandProducer { // Configurables for Cascade selection struct : ConfigurableGroup { - Configurable dcaV0Dau{"dcaV0Dau", 1.0f, "DCA V0 Daughters"}; + Configurable dcaV0Dau{"dcaV0Dau", 0.5f, "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 dcaPosToPV{"dcaPosToPV", 0.06f, "DCA Pos To PV"}; + Configurable dcaNegToPV{"dcaNegToPV", 0.06f, "DCA Neg To PV"}; Configurable dcaBachToPV{"dcaBachToPV", 0.1f, "DCA Bach To PV"}; 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 cosPAXi{"cosPAXi", 0.99f, "Xi CosPA"}; + Configurable v0RadiusXi{"v0RadiusXi", 1.2f, "V0 decay radius"}; + Configurable radiusXi{"radiusXi", 1.0f, "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"}; + 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"}; } 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 cosPAOmega{"cosPAOmega", 0.99f, "Omega CosPA"}; + Configurable v0RadiusOmega{"v0RadiusOmega", 1.2f, "V0 decay radius"}; + Configurable radiusOmega{"radiusOmega", 0.8f, "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"}; + 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"}; } omegaConfigs; } cascadeConfigs; @@ -1056,7 +1056,7 @@ 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; diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 441334f46a6..d4969c408a2 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -195,32 +195,32 @@ struct PhiStrangeCorrelation { // 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 @@ -236,26 +236,26 @@ 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"}; + Configurable> activeCorrelationTypes{"activeCorrelationTypes", {true, false, false, true, true, true}, "Enable correlation types: 0 - K0S, 1 - Lambda, 2 - AntiLambda, 3 - Xi, 4 - Omega, 5 - Pion"}; // Configurables for delta y selection struct : ConfigurableGroup { @@ -283,8 +283,8 @@ 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"}; From 789ef9dfed85ad9334fb228f95ea0c48e3783289 Mon Sep 17 00:00:00 2001 From: scannito Date: Mon, 23 Nov 2026 17:41:12 +0100 Subject: [PATCH 10/25] [PWGLF] Separate switches for the V0 ctau cuts and competing-mass rejections in phiStrangeCorrelator furtherV0Selection gated, all together, the ctau cuts of K0S and Lambda, the rejection of Lambda among the K0S (with the Armenteros cut) and the rejection of K0S among the Lambda, so the competing-mass rejection could not be switched on for the Lambda without changing the K0S selection. 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. It is replaced by three switches: applyCtauCut, vetoLambdaInK0S, vetoK0SInLambda. All are off by default, as furtherV0Selection was in the trains. Also removes rangeMK0sSignal and rangeMLambdaSignal, declared and never read: the signal windows of the associated particles are those of phiStrangeCorrelation. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 63dafdf3868..1e020d52fa9 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -443,7 +443,7 @@ struct V0ReducedCandProducer { 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", false, "Apply the ctau cuts (ctauK0S, ctauLambda)"}; Configurable yAcceptance{"yAcceptance", 0.5f, "Rapidity acceptance"}; @@ -453,20 +453,20 @@ struct V0ReducedCandProducer { Configurable rejMassK0S{"rejMassK0S", 0.005f, "V0 rej K0s"}; Configurable paramArmenterosCutK0S{"paramArmenterosCutK0S", 0.2f, "Parameter for Armenteros Cut for K0S"}; + Configurable vetoLambdaInK0S{"vetoLambdaInK0S", false, "Reject K0S candidates within rejMassK0S of the Lambda mass (either charge) and apply the Armenteros cut"}; 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"}; - Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.47f, 0.53f}, "K0S mass range for signal extraction"}; } k0sConfigs; struct : ConfigurableGroup { Configurable cosPALambda{"cosPALambda", 0.995f, "Lambda CosPA"}; Configurable ctauLambda{"ctauLambda", 30.0f, "C tau Lambda(cm)"}; Configurable rejMassLambda{"rejMassLambda", 0.005f, "V0 rej Lambda"}; + Configurable vetoK0SInLambda{"vetoK0SInLambda", false, "Reject Lambda and AntiLambda candidates within rejMassLambda of the K0S mass"}; 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"}; - Configurable> rangeMLambdaSignal{"rangeMLambdaSignal", {1.11f, 1.12f}, "Lambda mass range for signal extraction"}; } lambdaConfigs; } v0Configs; @@ -610,13 +610,18 @@ struct V0ReducedCandProducer { return false; } - if (v0Configs.furtherV0Selection) { + // 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 = v0Type == kK0S ? MassK0S : MassLambda; if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * assumedMass > cutCtau) { return false; } + } - if constexpr (v0Type == kK0S) { + if constexpr (v0Type == kK0S) { + if (v0Configs.k0sConfigs.vetoLambdaInK0S) { if (std::abs(v0.mLambda() - MassLambda) < v0Configs.k0sConfigs.rejMassK0S || std::abs(v0.mAntiLambda() - MassLambda) < v0Configs.k0sConfigs.rejMassK0S) { return false; @@ -624,10 +629,10 @@ struct V0ReducedCandProducer { if (v0.qtarm() < (v0Configs.k0sConfigs.paramArmenterosCutK0S * std::abs(v0.alpha()))) { return false; } - } else { - if (std::abs(v0.mK0Short() - MassK0S) < v0Configs.lambdaConfigs.rejMassLambda) { - return false; - } + } + } else { + if (v0Configs.lambdaConfigs.vetoK0SInLambda && std::abs(v0.mK0Short() - MassK0S) < v0Configs.lambdaConfigs.rejMassLambda) { + return false; } } From 043caff0d196afc308f5ddf8da849757a6b2c166 Mon Sep 17 00:00:00 2001 From: scannito Date: Tue, 24 Nov 2026 11:54:59 +0100 Subject: [PATCH 11/25] [PWGLF] Pion nSigma split by TOF in the phiStrangeCorrelator pion producer phiStrangeCorrelation counts a pion within the TPC nSigma window, and within the TOF one as well when the track has TOF. The two existing histograms hold each nSigma over every selected track: the TPC one mixes the tracks with and without TOF, and the TOF one puts the tracks without TOF in its underflow, at -999. Neither gives the purity or the window efficiency of the counted sample. Adds, for the selected pions, the TPC and TOF nSigma together for the tracks with TOF (THnSparse) and the TPC nSigma alone for those without, and the same two for the true primary pions in MC reconstruction. The old histograms are kept, with their nSigma axes now titled TPC and TOF: they are the sums of the new ones, and they are what is read offline until the new ones are. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 1e020d52fa9..a7df510efde 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1084,10 +1084,20 @@ 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"}; + AxisSpec nSigmaTPCPiAxis = {100, -10.0f, 10.0f, "N#sigma_{TPC} #pi"}; + AxisSpec nSigmaTOFPiAxis = {100, -10.0f, 10.0f, "N#sigma_{TOF} #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("h3PionTPCnSigma", "Pion TPC nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTPCPiAxis}); + histos.add("h3PionTOFnSigma", "Pion TOF nSigma distribution", kTH3F, {binnedmultAxis, binnedpTPiAxis, nSigmaTOFPiAxis}); + + // The selected pions split as phiStrangeCorrelation counts them (inNSigmaRegion): with TOF, the TPC and TOF nSigma + // together; without TOF, the TPC one alone. 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 + 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}); 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)"}}); @@ -1255,6 +1265,11 @@ 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()); + } pionTracksData(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), track.hasTOF()); } @@ -1289,6 +1304,12 @@ struct PionTrackProducer { continue; } + if (track.hasTOF()) { + histos.fill(HIST("h4RecMCPionTPCTOFnSigma"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + } else { + histos.fill(HIST("h3RecMCPionTPCnSigmaNoTOF"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); + } + pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), track.hasTOF()); } } From e744e3c1b17e6cf5bf1e3c83fda93f83fcacff85 Mon Sep 17 00:00:00 2001 From: scannito Date: Tue, 24 Nov 2026 17:10:16 +0100 Subject: [PATCH 12/25] [PWGLF] One TOF threshold for the pion PID in phiStrangeCorrelator and phiStrangeCorrelation The producer requires the TOF from tofPIDThreshold up, but the nSigma window of phiStrangeCorrelation cut in nSigma TOF every track that had a TOF signal, at any pT, and so did the K/p rejection. Below the threshold the counted sample was therefore mixed: the tracks with TOF, a fraction that grows with pT, passed a cut the others did not, and the efficiency carried the TOF matching and mismatch there, which the MC reproduces worse than the TPC response. Below the threshold the TPC separates the pion alone. The TOF now enters the PID from tofPIDThreshold up and never below, everywhere: - useTOFInPID (pT >= tofPIDThreshold and a TOF signal) decides the K/p rejection in the producer; - the pion tables carry it as UseTOFInPID, replacing HasTOF, and InNSigmaRegion applies the TOF window only when it is true, so the threshold exists in one place and the task keeps no copy of it. Co-Authored-By: Claude Opus 5.5 --- .../DataModel/LFPhiStrangeCorrelationTables.h | 17 +++++++----- .../Strangeness/phiStrangeCorrelator.cxx | 26 ++++++++++++++----- .../Strangeness/phiStrangeCorrelation.cxx | 1 - 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index 44f552a0f6d..3b32538e6d1 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -193,14 +193,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 >= tofPIDThreshold 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 +218,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 +231,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 a7df510efde..5c36c99f3f3 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1090,9 +1090,11 @@ struct PionTrackProducer { 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 as phiStrangeCorrelation counts them (inNSigmaRegion): with TOF, the TPC and TOF nSigma - // together; without TOF, the TPC one alone. 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 + // 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 tofPIDThreshold 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 @@ -1143,6 +1145,16 @@ struct PionTrackProducer { return true; }*/ + // The TOF enters the pion PID from tofPIDThreshold 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.tofPIDThreshold && track.hasTOF(); + } + // PID Hypotheses rejection for Pions template bool pidHypothesesRejection(const T& track) @@ -1169,8 +1181,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; } } @@ -1271,7 +1283,7 @@ struct PionTrackProducer { histos.fill(HIST("h3PionTPCnSigmaNoTOF"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); } - 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)); } } @@ -1310,7 +1322,7 @@ struct PionTrackProducer { histos.fill(HIST("h3RecMCPionTPCnSigmaNoTOF"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); } - pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), track.hasTOF()); + pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(MassPi), track.phi(), useTOFInPID(track)); } } diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index d4969c408a2..aa89457c6cb 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -228,7 +228,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 From 7488980f137b3b42324845fd0499aa214fed5d2e Mon Sep 17 00:00:00 2001 From: scannito Date: Wed, 25 Nov 2026 10:07:06 +0100 Subject: [PATCH 13/25] [PWGLF] Generated multiplicity in the MC histograms of the phiStrangeCorrelator pion producer The pion producer filled its true-primary nSigma histograms (h4RecMCPionTPCTOFnSigma, h3RecMCPionTPCnSigmaNoTOF) with the reconstructed centFT0M of the collision, while the event selection and the efficiencies of phiStrangeCorrelation use the generated one (McCentFT0Ms). The fraction of pions inside the nSigma window taken from them was therefore binned in a different multiplicity than the efficiency it multiplies. phi_strange_utils::multPercentile gives the percentile a collision is binned in: its own centFT0M in data and for a generated collision, that of the generated collision it comes from for a reconstructed one in MC. The pion producer and the event-selection producer, which did the same lookup twice, read it there; the event selection's behaviour is unchanged. In phiStrangeCorrelation, a comment on h4MCReco: it is cut in the signal region only if selectInSigRegion is on, and with selectPionInSigRegion off the window's own efficiency comes from those producer histograms (MC) or from the data fits. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 64 +++++++++++-------- .../Strangeness/phiStrangeCorrelation.cxx | 3 + 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 5c36c99f3f3..c9f5149de76 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -63,6 +63,25 @@ 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 Produces phimesonCandidatesData; @@ -1075,6 +1094,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; @@ -1290,8 +1310,11 @@ struct PionTrackProducer { 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; @@ -1317,9 +1340,9 @@ struct PionTrackProducer { } if (track.hasTOF()) { - histos.fill(HIST("h4RecMCPionTPCTOFnSigma"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); + histos.fill(HIST("h4RecMCPionTPCTOFnSigma"), multiplicity, track.pt(), track.tpcNSigmaPi(), track.tofNSigmaPi()); } else { - histos.fill(HIST("h3RecMCPionTPCnSigmaNoTOF"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); + 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)); @@ -1417,8 +1440,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()) { @@ -1437,8 +1458,6 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionData"), 4); // RCTFlags cut - - multPercentile = collision.centFT0M(); } else { // MCreco event static_assert(!std::is_same_v, "Need to set MC_T to MCCollisions for isMC = true"); @@ -1471,14 +1490,13 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionMC"), 7); // RCTFlags cut - - const auto& mcCollision = collision.template mcCollision_as(); - multPercentile = mcCollision.centFT0M(); } + 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; } @@ -1512,26 +1530,18 @@ struct EventSelectionProducer { } } - float multPercentile{0.0f}; - if constexpr (!isMC) { histos.fill(HIST("hEventSelectionData"), 5); - - multPercentile = collision.centFT0M(); - } else { - if constexpr (std::is_same_v) { - multPercentile = collision.centFT0M(); - } else { - histos.fill(HIST("hEventSelectionMC"), 8); - - const auto& mcCollision = collision.template mcCollision_as(); - multPercentile = mcCollision.centFT0M(); - } + } 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; } diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index aa89457c6cb..5ccba2011a7 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -428,6 +428,9 @@ struct PhiStrangeCorrelation { 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}); + // 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}); From 544578322f1f9353224070f78d66901851703fd3 Mon Sep 17 00:00:00 2001 From: scannito Date: Wed, 25 Nov 2026 10:39:11 +0100 Subject: [PATCH 14/25] [PWGLF] Phi requirement only on selected events in the phiStrangeCorrelator event selection The process...WPhi functions of EventSelectionProducer passed the default selection and eventHasPhi as two arguments of the same call, so eventHasPhi ran on every collision, also on those the default selection had rejected. It then filled the WPhi QA histograms and the "with a phi" bin of hEventSelectionData/MC with rejected events, and in MC reconstruction it read the generated collision through mcCollision_as also for a collision without one. The selection seen by phiStrangeCorrelation was right, since its filter requires defaultSel and phimesonSel together. The single-column table of before February 2026 had the && that avoided this; it was lost when the selection became two columns. eventHasPhi is now evaluated only when the default selection (INEL>0 for the generated collisions) passes; phimesonSel is then false for a rejected event, which changes no selection. Also removed the commented-out leftovers of the old selection tables (DefaultSelection*, PhimesonSelection*, PhiStrangeDefEvtSel*, lf_selection_default_collision), which no longer exist in the data model. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index c9f5149de76..5fa51ea6ddd 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -125,19 +125,12 @@ struct PhiMesonCandProducer { 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; // 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; @@ -496,7 +489,6 @@ 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; // Defining filters on V0s (cannot filter on dynamic columns) @@ -1085,7 +1077,6 @@ struct PionTrackProducer { 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; // Defining the type of the collisions for data and MC @@ -1549,18 +1540,14 @@ struct EventSelectionProducer { // Default event selection void processData(SelCollisions::iterator const& collision) { - // phiStrangeDefEvtSelDataLike(defaultEventSelection(collision)); phiStrangeEvtSelDataLike(defaultEventSelection(collision), false); - // defaultSelectionData(defaultEventSelection(collision), false); } 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)); } PROCESS_SWITCH(EventSelectionProducer, processMCReco, "Process function to select default events in MCReco", false); @@ -1568,34 +1555,35 @@ struct EventSelectionProducer { 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)); } 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). phimesonSel is then false for a rejected event, + // which changes no selection: it is read only together with defaultSel void processDataWPhi(SelCollisions::iterator const& collision, aod::PhimesonCandidatesData const& phiCandidatesData) { - phiStrangeEvtSelDataLike(defaultEventSelection(collision), eventHasPhi(collision, phiCandidatesData)); - // phimesonSelectionData(defaultEventSelection(collision) && eventHasPhi(collision, phiCandidatesData)); + const bool isSelected = defaultEventSelection(collision); + phiStrangeEvtSelDataLike(isSelected, isSelected && eventHasPhi(collision, phiCandidatesData)); } 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)); + const bool isSelected = defaultEventSelection(collision); + phiStrangeEvtSelDataLike(isSelected, isSelected && eventHasPhi(collision, phiCandidatesData)); } 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)); + const bool isSelected = pwglf::isINELgt0mc(mcParticles, pdgDB); + phiStrangeEvtSelMcGen(isSelected, isSelected && eventHasPhi(mcCollision, phiCandidatesMcGen)); } PROCESS_SWITCH(EventSelectionProducer, processMCGenWPhi, "Process function to select events with Phi mesons in MCGen", false); From eb8ddc1d460d250355e014c5b4cba7bcd641a400 Mon Sep 17 00:00:00 2001 From: scannito Date: Wed, 25 Nov 2026 11:37:36 +0100 Subject: [PATCH 15/25] [PWGLF] tofPIDThreshold of the phiStrangeCorrelator pion producer renamed minPtTOFInPID The option bounded only the producer's TOF requirement (cfgIsTOFChecked); since the TOF enters the pion PID from it up and never below (useTOFInPID, the K/p rejection and the nSigma window of phiStrangeCorrelation), it means something else with the same values. Renamed with its meaning, so that a train configuration says which rule a production ran with, which the option values alone cannot. Co-Authored-By: Claude Opus 5.5 --- .../DataModel/LFPhiStrangeCorrelationTables.h | 2 +- .../Strangeness/phiStrangeCorrelator.cxx | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index 3b32538e6d1..003691f794f 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -193,7 +193,7 @@ DECLARE_SOA_COLUMN(NSigmaTOF, nSigmaTOF, float); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Y, y, float); DECLARE_SOA_COLUMN(Phi, phi, float); -// Whether the TOF enters the PID of this track: it has a TOF signal and pT >= tofPIDThreshold of the producer, the +// 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); diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 5fa51ea6ddd..4cb20d5a501 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1059,7 +1059,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"}; @@ -1102,7 +1104,7 @@ struct PionTrackProducer { 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 tofPIDThreshold and in both windows above it + // 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 @@ -1133,7 +1135,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 @@ -1156,14 +1158,14 @@ struct PionTrackProducer { return true; }*/ - // The TOF enters the pion PID from tofPIDThreshold up and never below, here in the K/p rejection and in the nSigma + // 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.tofPIDThreshold && track.hasTOF(); + return track.pt() >= trackConfigs.minPtTOFInPID && track.hasTOF(); } // PID Hypotheses rejection for Pions @@ -1251,7 +1253,7 @@ struct PionTrackProducer { } } - if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.tofPIDThreshold && !track.hasTOF()) { + if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.minPtTOFInPID && !track.hasTOF()) { return false; } @@ -1264,9 +1266,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; } */ From d13ba5bff32276d62a061f15e098bdc6610dca62 Mon Sep 17 00:00:00 2001 From: scannito Date: Wed, 25 Nov 2026 17:14:18 +0100 Subject: [PATCH 16/25] [PWGLF] activeCorrelationTypes of phiStrangeCorrelation as a list of species names The option was a std::array, which a train configuration records as bare elements (activeCorrelationTypes._M_elems[i]): which element is which species was known only from this file. It is now the list of the species correlated with the phi, by the names of AssocParticleLabels, so that the configuration says which species were on and their order no longer matters. init turns the names into the positions the loops index, and stops on a name that is not a species. The default lists all six species, Lambda and AntiLambda included, so that the MC trains have them for the efficiencies. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 5ccba2011a7..ce0c6572139 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -254,7 +255,9 @@ struct PhiStrangeCorrelation { 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, true, true, 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 { @@ -329,6 +332,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"}; @@ -360,6 +364,15 @@ struct PhiStrangeCorrelation { void init(InitContext&) { + // 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}"}; @@ -502,7 +515,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); } } @@ -748,7 +761,7 @@ struct PhiStrangeCorrelation { template void processOneAssocSpeciesSE(TPhiCand const& phiCand, TAssocCands const& assocCands, float multiplicity) { - if (!activeCorrelationTypes->at(PartType)) { + if (!isCorrelationTypeActive[PartType]) { return; } @@ -939,7 +952,7 @@ struct PhiStrangeCorrelation { } auto fillRecoAssocSpecies = [&](TAssocInputs const& assocCands, auto histoKey) { - if (!activeCorrelationTypes->at(TAssocInputs::Type)) { + if (!isCorrelationTypeActive[TAssocInputs::Type]) { return; } @@ -996,7 +1009,7 @@ struct PhiStrangeCorrelation { }; auto fillGenAssocSpecies = [&](auto h3Key, auto h4Key) { - if (!activeCorrelationTypes->at(PartType) || !isGenSpeciesValid(mcParticle, false)) { + if (!isCorrelationTypeActive[PartType] || !isGenSpeciesValid(mcParticle, false)) { return; } @@ -1051,7 +1064,7 @@ 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) @@ -1108,7 +1121,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; } @@ -1127,7 +1140,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; } From b12fb4cc533d8db9eec48bedd2500a008eaa0f3b Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 26 Nov 2026 09:58:49 +0100 Subject: [PATCH 17/25] [PWGLF] Generated phi as phi -> K+K- in phiStrangeCorrelation and phiStrangeCorrelator - processMCGenClosure: a generated phi is a trigger only if it decays to K+K-, the trigger of data. A phi in another channel was correlated with its own daughters (the K0S of K0S K0L, the pions of pi+pi-pi0), pairs data do not have. - processParticleEfficiency: new option phiEfficiencyKKOnly (default false, today's behaviour). With it the generated phi of the efficiency is only phi -> K+K-, so the phi efficiency leaves out the BR to K+K- instead of holding it as every other efficiency holds that of its channel. - PhiMesonCandProducer::processMCGen with trueGenPhi: only phi -> K+K-, as the events with a phi of data and of trueGenPhi false. With trueGenPhi false the generated K+K- pairs are formed K+ outside, K- inside: each pair is written once instead of twice, and the inner loop runs only for the K+. - EventSelectionProducer: a comment moved to its own line, which clang-format required. The decay channel is checked with RecoDecay::isMatchedMCGen. Pythia adds no photon to phi -> K+K- (HadronLevel:QED off): in an MC AO2D, 0 of the 42370 phi decay to K+K-gamma. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 20 ++++++++++--------- .../Strangeness/phiStrangeCorrelation.cxx | 12 +++++++++-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 4cb20d5a501..f82b7a26b8c 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -22,6 +22,7 @@ #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" @@ -119,7 +120,7 @@ struct PhiMesonCandProducer { 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.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"}; @@ -371,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; } @@ -381,18 +386,14 @@ struct PhiMesonCandProducer { phimesonCandidatesMcGen(mcCollision.globalIndex(), 0, 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; } @@ -1451,7 +1452,8 @@ struct EventSelectionProducer { return false; } histos.fill(HIST("hEventSelectionData"), 4); // RCTFlags cut - } else { // MCreco event + } 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 diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index ce0c6572139..cbb5def2ae9 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -293,6 +293,10 @@ struct PhiStrangeCorrelation { Configurable bypassPtCut{"bypassPtCut", false, "Bypass the minimum pt cut at MCGen level"}; } minPtMcGenConfigs; + // 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 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); @@ -1018,7 +1022,8 @@ 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; @@ -1071,7 +1076,10 @@ struct PhiStrangeCorrelation { switch (std::abs(mcParticle.pdgCode())) { case o2::constants::physics::Pdg::kPhi: - if (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; From a62174c60c0ff58f7e12bdf378f51c2f7dae0b7f Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 26 Nov 2026 10:19:48 +0100 Subject: [PATCH 18/25] [PWGLF] Event selection of phiStrangeCorrelator as one level instead of two flags PhiStrangeEvtSelDataLike and PhiStrangeEvtSelMcGen had two bool columns, DefaultSel and PhimesonSel, and phiStrangeCorrelation filtered on both. Since the phi requirement runs only on selected events, an event with a phi is always a selected one, so the two flags are one hierarchy. They are now one column, SelectionLevel (kRejected, kDefault, kDefaultWithPhi), which cannot hold the combination that must not exist (a phi in a rejected event): - the producer writes the level each event reaches; the WPhi processes raise kDefault to kDefaultWithPhi only after eventHasPhi, still evaluated on selected events only; - the V0, cascade and pion producers keep the events at kDefault and above; - phiStrangeCorrelation keeps selectionLevel > eventSelectionType: 0 keeps every selected event, 1 those with a phi. The option is compared as as, the column's type, as the framework's own test of a filter on a uint8_t column does. Also assumedMass renamed AssumedMass (O2 linter, constexpr constant). Co-Authored-By: Claude Opus 5.5 --- .../DataModel/LFPhiStrangeCorrelationTables.h | 16 ++++--- .../Strangeness/phiStrangeCorrelator.cxx | 43 +++++++++++-------- .../Strangeness/phiStrangeCorrelation.cxx | 5 +-- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index 003691f794f..97f280d57b6 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -19,23 +19,27 @@ #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 { diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index f82b7a26b8c..c1cd501f7cd 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -126,7 +126,7 @@ struct PhiMesonCandProducer { 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_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; @@ -490,7 +490,7 @@ struct V0ReducedCandProducer { 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 V0s (cannot filter on dynamic columns) Filter v0PreFilter = (nabs(aod::v0data::dcapostopv) > v0Configs.dcaPosToPV && @@ -626,8 +626,8 @@ struct V0ReducedCandProducer { // 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 = v0Type == kK0S ? MassK0S : MassLambda; - if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * assumedMass > cutCtau) { + constexpr float AssumedMass = v0Type == kK0S ? MassK0S : MassLambda; + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * AssumedMass > cutCtau) { return false; } } @@ -810,7 +810,7 @@ struct CascadeReducedCandProducer { static constexpr double MassOmega = o2::constants::physics::MassOmegaMinus; // 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 && @@ -1080,7 +1080,7 @@ struct PionTrackProducer { static constexpr double MassPi = o2::constants::physics::MassPiPlus; // 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 the type of the collisions for data and MC using SelCollisions = soa::Join; @@ -1544,50 +1544,57 @@ struct EventSelectionProducer { // Default event selection void processData(SelCollisions::iterator const& collision) { - phiStrangeEvtSelDataLike(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&) { - phiStrangeEvtSelDataLike(defaultEventSelection(collision), false); + 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) { - - phiStrangeEvtSelMcGen(pwglf::isINELgt0mc(mcParticles, pdgDB), false); + 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. 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). phimesonSel is then false for a rejected event, - // which changes no selection: it is read only together with defaultSel + // may not have (has_mcCollision is part of the default selection) void processDataWPhi(SelCollisions::iterator const& collision, aod::PhimesonCandidatesData const& phiCandidatesData) { - const bool isSelected = defaultEventSelection(collision); - phiStrangeEvtSelDataLike(isSelected, isSelected && 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) { - const bool isSelected = defaultEventSelection(collision); - phiStrangeEvtSelDataLike(isSelected, isSelected && 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) { - const bool isSelected = pwglf::isINELgt0mc(mcParticles, pdgDB); - phiStrangeEvtSelMcGen(isSelected, isSelected && 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 cbb5def2ae9..23fbf72500e 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -297,9 +297,8 @@ struct PhiStrangeCorrelation { // 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 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); + // 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>; From aeb63b19019421ba0631d77f6a48d0fbae157347 Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 26 Nov 2026 10:54:35 +0100 Subject: [PATCH 19/25] [PWGLF] Wider DCAxy axis of the pion MC templates in phiStrangeCorrelator The DCAxy templates of the primary, weak-decay and material pions covered |DCAxy| < 0.05 cm, while the producer's cut is 0.004 + 0.013/pT: 0.069 cm at 0.2 GeV/c. Below about 0.28 GeV/c the accepted tracks with the largest DCA fell outside the axis, the tails where the secondaries weigh most. The axis now spans +-0.1 cm with the same bin width. The weak-decay template's title said DCAz. Co-Authored-By: Claude Opus 5.5 --- PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index c1cd501f7cd..8497101d230 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1100,6 +1100,9 @@ struct PionTrackProducer { AxisSpec binnedpTPiAxis{std::vector(binspTPi), "#it{p}_{T} (GeV/#it{c})"}; 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}); @@ -1115,9 +1118,9 @@ struct PionTrackProducer { 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}); - 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)"}}); + 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 From 62ba249e596fec6ae5d45745503fb721e2edd505 Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 26 Nov 2026 10:57:03 +0100 Subject: [PATCH 20/25] [PWGLF] DCAxy of the selected pion tracks in data in phiStrangeCorrelator h2PionDCAxy, (pT, DCAxy) of every track the pion producer selects in data, with the axes of the MC templates of primary, weak-decay and material pions: the distribution to fit with them for the fraction of primaries. It holds whatever is not a pion among the selected tracks; the nSigma window is applied by phiStrangeCorrelation, not here. Co-Authored-By: Claude Opus 5.5 --- PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 8497101d230..0aa6f281f44 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -1118,6 +1118,8 @@ struct PionTrackProducer { 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}); @@ -1299,6 +1301,7 @@ struct PionTrackProducer { } 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(), useTOFInPID(track)); } From 47a83c41f743837290fe09d89b1ba1dc1e5185e2 Mon Sep 17 00:00:00 2001 From: scannito Date: Thu, 26 Nov 2026 16:02:29 +0100 Subject: [PATCH 21/25] [PWGLF] V0 and cascade selections of phiStrangeCorrelator aligned with the strangeness analysis notes Defaults from the K0S/Lambda (V0 production vs multiplicity, June 2026, Table 1) and Xi/Omega (ALICE-ANA-2026-1446, Table 3) analyses in pp at 13.6 TeV. V0s: - dcaV0Dau 1.0 -> 0.5; applyCtauCut, vetoK0SInLambda on; rejMassLambda 5 -> 10 MeV; - the Armenteros cut of the K0S has its own switch, applyArmenterosCutK0S (on), separate from vetoLambdaInK0S, which now only rejects the Lambda mass (off), as the note applies the one without the other. Cascades: - the cuts that differ between Xi and Omega are per species: dcaPosToPV, dcaNegToPV, dcaV0Dau, dcaCascDau, cosPA, v0CosPA; the common prefilter keeps only dcaBachToPV (0.1 -> 0.05), the rest is applied in selectionCascade; - the cuts of the note the trains have not applied so far, each with a switch, OFF by default: the DCA of the V0 to the PV (applyDcaV0ToPVCut), the DCAxy of the bachelor-baryon pair (applyBachBaryonCut), the Lambda mass window (applyLambdaMassWindow), the proper decay length in cm as for the V0s (applyCtauCut, ctauXi 22.6 and ctauOmega 17.2 = 4.6 and 7 c tau), the Xi mass rejection in the Omega (vetoXiInOmega). The per-species option groups are folded into v0Configs and cascadeConfigs (no prefix, so the option names are unchanged), and the descriptions of the competing-mass vetoes say which mass is compared. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelator.cxx | 207 +++++++++++------- 1 file changed, 133 insertions(+), 74 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 0aa6f281f44..77e729436f3 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -449,38 +449,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.9f, "V0 decay radius"}; - Configurable dcaV0Dau{"dcaV0Dau", 1.0f, "DCA V0 Daughters"}; + 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 applyCtauCut{"applyCtauCut", false, "Apply the ctau cuts (ctauK0S, ctauLambda)"}; + 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 vetoLambdaInK0S{"vetoLambdaInK0S", false, "Reject K0S candidates within rejMassK0S of the Lambda mass (either charge) and apply the Armenteros cut"}; + 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.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"}; - } 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.995f, "Lambda CosPA"}; - Configurable ctauLambda{"ctauLambda", 30.0f, "C tau Lambda(cm)"}; - Configurable rejMassLambda{"rejMassLambda", 0.005f, "V0 rej Lambda"}; - Configurable vetoK0SInLambda{"vetoK0SInLambda", false, "Reject Lambda and AntiLambda candidates within rejMassLambda of the K0S mass"}; + // 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.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"}; - } 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"}; @@ -514,8 +515,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}]"}; @@ -611,9 +612,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; @@ -626,24 +628,22 @@ struct V0ReducedCandProducer { // 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 = v0Type == kK0S ? MassK0S : MassLambda; + constexpr float AssumedMass = IsK0S ? MassK0S : MassLambda; if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * AssumedMass > cutCtau) { return false; } } - if constexpr (v0Type == kK0S) { - if (v0Configs.k0sConfigs.vetoLambdaInK0S) { - 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; - } + 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.lambdaConfigs.vetoK0SInLambda && std::abs(v0.mK0Short() - MassK0S) < v0Configs.lambdaConfigs.rejMassLambda) { + if (v0Configs.vetoK0SInLambda && std::abs(v0.mK0Short() - MassK0S) < v0Configs.rejMassLambda) { return false; } } @@ -774,50 +774,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", 0.5f, "DCA V0 Daughters"}; - Configurable dcaCascDau{"dcaCascDau", 1.0f, "DCA Cascade Daughters"}; - Configurable dcaPosToPV{"dcaPosToPV", 0.06f, "DCA Pos To PV"}; - Configurable dcaNegToPV{"dcaNegToPV", 0.06f, "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.99f, "Xi CosPA"}; - Configurable v0RadiusXi{"v0RadiusXi", 1.2f, "V0 decay radius"}; - Configurable radiusXi{"radiusXi", 1.0f, "Xi decay radius"}; - - 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"}; - } xiConfigs; - - struct : ConfigurableGroup { - Configurable v0CosPAOmega{"v0CosPAOmega", 0.98f, "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 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"}; - } 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::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; @@ -836,8 +853,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}]"}; @@ -941,16 +958,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; } @@ -963,6 +1005,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; } From 6062e25b5e62bd1df1dc338be8066f224518dbf5 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 16:16:11 +0100 Subject: [PATCH 22/25] [PWGLF] Generated phi candidates of phiStrangeCorrelator indexed to McCollisions PhimesonCandidatesMcGen had an index to Collisions while the producer fills it with the McCollision index. processMCGenWPhi, over McCollisions, could then not group it and received the candidates of the whole DF: a generated event passed the phi requirement if any event of its DF had a candidate in the window. Measured on a local MC AO2D (LHC24f4d, 112408 generated INEL>0 events), with eventSelectionType 1 and trueGenPhi false: generated events with a phi 112408 before, 3494 after. The reconstructed side is unchanged (287 events). Co-Authored-By: Claude Opus 5.5 --- PWGLF/DataModel/LFPhiStrangeCorrelationTables.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index 97f280d57b6..f909aa78a7e 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -44,6 +44,9 @@ DECLARE_SOA_TABLE(PhiStrangeEvtSelMcGen, "AOD", "EVTSELMCGEN", 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); @@ -76,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, From 8fad67fd50c18c03239e169f772a305fac163806 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 16:40:40 +0100 Subject: [PATCH 23/25] [PWGLF] True generated phi of phiStrangeCorrelator written with its mass With trueGenPhi the generated phi was written with a mass of 0, and the event selection keeps only candidates in the phi signal window (unless withTrueGenPhi): no generated event passed the phi requirement, with no message. The phi is now written with its own mass, so the window applies to it as to the K+K- pairs of trueGenPhi false. Measured on a local MC AO2D (LHC24f4d, 112408 generated INEL>0 events), with eventSelectionType 1: generated events with a phi 0 before, 1509 after, and the 1536 generated phi -> K+K- of the closure all kept (PYTHIA generates the phi within 1.00-1.04 GeV/c2, inside the default window 1.00-1.05). Co-Authored-By: Claude Opus 5.5 --- PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 77e729436f3..568a2fc6e94 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -383,7 +383,9 @@ 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 From 66b8afce2e21394edf9653204694bc3b033758dd Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 17:41:41 +0100 Subject: [PATCH 24/25] [PWGLF] Candidates beyond the efficiency maps of phiStrangeCorrelation counted in outOfMap/ With the efficiencies applied, a candidate at or beyond the last pT bin of its map has no efficiency to read and is dropped. It was dropped uncounted, while the comment of computeWeight said it was counted. It is now counted as a zero efficiency is: outOfMap/SE/h3Phi per phi candidate, outOfMap/{SE,ME}/h3 per pair. The rule is one predicate per particle (isPhiBeyondMap, isAssocBeyondMap); isAssocValid keeps only the signal-region selection, so the MC reconstructed of the efficiency no longer depend on the pT range of the online maps. The phi of the mixed event are the candidates of the same event, already counted there once each: zeroEfficiency/ME/h3Phi is removed and no outOfMap/ME/h3Phi is added. Measured on a local data AO2D (run 528531) with the pp26_highIR_updated maps: 34 phi of 8549 beyond the map (pT > 10 GeV/c) now in outOfMap/SE/h3Phi, the weighted histograms unchanged. Co-Authored-By: Claude Opus 5.5 --- .../Strangeness/phiStrangeCorrelation.cxx | 75 ++++++++++++++----- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index 23fbf72500e..c3f7628c544 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -399,6 +399,7 @@ struct PhiStrangeCorrelation { AxisSpec nSigmaPiAxis = {100, -10.0f, 10.0f, "N#sigma #pi"}; 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}; @@ -411,9 +412,12 @@ struct PhiStrangeCorrelation { // 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 counts pairs + // 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}); - histos.add("zeroEfficiency/ME/h3Phi", "Phi-associated pairs dropped for zero Phi efficiency, ME", 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}); @@ -443,6 +447,8 @@ struct PhiStrangeCorrelation { 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 @@ -537,8 +543,8 @@ struct PhiStrangeCorrelation { // // 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 already are: a weight of 1 instead - // would mix corrected and uncorrected entries in one bin + // 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::optional computeWeight(const BoundEffMaps&... boundEffMaps) { @@ -630,29 +636,58 @@ struct PhiStrangeCorrelation { } } + // 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) + { + return efficiencyConfigs.applyEfficiency && efficiencyConfigs.applyPhiEfficiency && pt >= binspTPhi.value.back(); + } + + template + bool isAssocBeyondMap(float pt) + { + 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(); + } + } + + // 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, @@ -742,6 +777,15 @@ 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; } @@ -784,7 +828,8 @@ 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; } @@ -859,12 +904,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()) { - continue; - } - - if (!computeWeight(BoundEfficiencyMap(effMapPhi, multiplicity, phiCand.pt(), phiCand.y()))) { - histos.fill(HIST("zeroEfficiency/ME/h3Phi"), multiplicity, phiCand.pt(), phiCand.y()); + // 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; } From 72b9cf0eeb58f188d98ddef9736484485e3b4155 Mon Sep 17 00:00:00 2001 From: scannito Date: Fri, 27 Nov 2026 17:43:49 +0100 Subject: [PATCH 25/25] [PWGLF] Mixed event of phiStrangeCorrelation only for the active species processPhiAssocME ran for every species whose ME process switch is on, also those left out of activeCorrelationTypes, which the same event skips. Their efficiency map is not loaded, and BoundEfficiencyMap reads an absent map as an efficiency of 1: with the efficiencies applied those pairs got the phi weight alone, with no message. Measured on a local data AO2D with K0S, Xi, Omega and pi active: 61 phi-Lambda and 74 phi-AntiLambda ME pairs filled, no SE pair. The ME now returns for an inactive species, as the same event does. Co-Authored-By: Claude Opus 5.5 --- PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index c3f7628c544..21bcc5c0f2e 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -892,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};