diff --git a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h index e72662a92e5..aca738fe6f2 100644 --- a/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFPhiStrangeCorrelationTables.h @@ -148,6 +148,18 @@ 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); + +DECLARE_SOA_DYNAMIC_COLUMN(InNSigmaRegion, inNSigmaRegion, + [](float nSigmaTPC, float pt, bool hasTOF, float nSigmaTOF, float pidTPCMax, float tofPIDThreshold, float pidTOFMax) -> bool { + if (std::abs(nSigmaTPC) >= pidTPCMax) { + return false; // TPC check failed + } + if (pt >= tofPIDThreshold && hasTOF && std::abs(nSigmaTOF) >= pidTOFMax) { + return false; // TOF check failed + } + return true; + }); } // namespace lf_selection_pion_track DECLARE_SOA_TABLE(PionTracksData, "AOD", "PITRACKSDATA", @@ -157,7 +169,10 @@ DECLARE_SOA_TABLE(PionTracksData, "AOD", "PITRACKSDATA", lf_selection_pion_track::NSigmaTOF, lf_selection_pion_track::Pt, lf_selection_pion_track::Y, - lf_selection_pion_track::Phi); + lf_selection_pion_track::Phi, + lf_selection_pion_track::HasTOF, + lf_selection_pion_track::InNSigmaRegion); DECLARE_SOA_TABLE(PionTracksMcReco, "AOD", "PITRACKSMCRECO", soa::Index<>, @@ -166,7 +181,10 @@ DECLARE_SOA_TABLE(PionTracksMcReco, "AOD", "PITRACKSMCRECO", lf_selection_pion_track::NSigmaTOF, lf_selection_pion_track::Pt, lf_selection_pion_track::Y, - lf_selection_pion_track::Phi); + lf_selection_pion_track::Phi, + lf_selection_pion_track::HasTOF, + lf_selection_pion_track::InNSigmaRegion); } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFPHISTRANGECORRELATIONTABLES_H_ diff --git a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx index 211302881a7..b4f266b96b1 100644 --- a/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx +++ b/PWGLF/TableProducer/Strangeness/phiStrangeCorrelator.cxx @@ -419,9 +419,9 @@ struct K0sReducedCandProducer { { AxisSpec binnedmultAxis{(std::vector)binsMult, "centFT0M"}; AxisSpec binnedpTK0SAxis{(std::vector)binspTK0S, "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec massK0sAxis = {200, 0.4f, 0.6f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec massK0SAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; - histos.add("h3K0sCandidatesMass", "K^{0}_{S} candidate invariant mass", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0sAxis}); + histos.add("h3K0sCandidatesMass", "K^{0}_{S} candidate invariant mass", kTH3F, {binnedmultAxis, binnedpTK0SAxis, massK0SAxis}); } // Single track selection for strangeness sector @@ -527,7 +527,7 @@ struct PionTrackProducer { HistogramRegistry histos{"pionTracks", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Configurable for analysis mode - Configurable analysisMode{"analysisMode", 1, "Analysis mode: 0 - old method with online normalization, 1 - new method with correlations"}; + // Configurable analysisMode{"analysisMode", 1, "Analysis mode: 0 - old method with online normalization, 1 - new method with correlations"}; // 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"}; @@ -547,11 +547,11 @@ struct PionTrackProducer { Configurable minTPCnClsFound{"minTPCnClsFound", 70, "min number of found TPC clusters"}; Configurable minITSnCls{"minITSnCls", 4, "min number of ITS clusters"}; - Configurable forceTOF{"forceTOF", false, "force the TOF signal for the PID"}; + // Configurable forceTOF{"forceTOF", false, "force the TOF signal for the PID"}; Configurable tofPIDThreshold{"tofPIDThreshold", 0.5, "minimum pT after which TOF PID is applicable"}; - Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton}, "Trk sel: Particles species for PID, proton, pion, kaon"}; - Configurable> pidTPCMax{"pidTPCMax", std::vector{2.0f, 2.0f, 2.0f}, "maximum nSigma TPC"}; - Configurable> pidTOFMax{"pidTOFMax", std::vector{2.0f, 2.0f, 2.0f}, "maximum nSigma TOF"}; + Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Kaon, o2::track::PID::Proton}, "Trk sel: Particles species for PID rejection, kaon, proton"}; + Configurable> pidTPCMax{"pidTPCMax", std::vector{2.0f, 2.0f}, "maximum nSigma TPC"}; + Configurable> pidTOFMax{"pidTOFMax", std::vector{2.0f, 2.0f}, "maximum nSigma TOF"}; Configurable cfgYAcceptance{"cfgYAcceptance", 0.5f, "Rapidity acceptance"}; } trackConfigs; @@ -590,7 +590,7 @@ struct PionTrackProducer { histos.add("h2RecMCDCAxySecMaterialPi", "Dcaxy distribution vs pt for Secondary Pions from Material", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); } - // PID selection for Pions + /*// PID selection for Pions template bool pidSelectionPion(const T& track) { @@ -626,6 +626,29 @@ struct PionTrackProducer { } } + return true; + }*/ + + // PID Hypotheses rejection for Pions + template + bool pidHypothesesRejection(const T& track) + { + for (size_t speciesIndex = 0; speciesIndex < trackConfigs.trkPIDspecies->size(); ++speciesIndex) { + auto const& pid = trackConfigs.trkPIDspecies->at(speciesIndex); + auto nSigmaTPC = aod::pidutils::tpcNSigma(pid, track); + + if (std::abs(nSigmaTPC) < trackConfigs.pidTPCMax->at(speciesIndex)) { // Check TPC nSigma first + if (track.hasTOF()) { + auto nSigmaTOF = aod::pidutils::tofNSigma(pid, track); + if (std::abs(nSigmaTOF) < trackConfigs.pidTOFMax->at(speciesIndex)) { + return false; // Reject if both TPC and TOF are within thresholds + } + } else { + return false; // Reject if only TPC is within threshold and TOF is unavailable + } + } + } + return true; } @@ -657,7 +680,10 @@ struct PionTrackProducer { if (trackConfigs.cfgIsTOFChecked && track.pt() >= trackConfigs.tofPIDThreshold && !track.hasTOF()) return false; - if (analysisMode == 1 && !pidSelectionPion(track)) + /*if (analysisMode == 1 && !pidSelectionPion(track)) + return false;*/ + + if (!pidHypothesesRejection(track)) return false; /* @@ -685,7 +711,7 @@ struct PionTrackProducer { histos.fill(HIST("h3PionTPCnSigma"), collision.centFT0M(), track.pt(), track.tpcNSigmaPi()); histos.fill(HIST("h3PionTOFnSigma"), collision.centFT0M(), track.pt(), track.tofNSigmaPi()); - pionTracksData(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(massPi), track.phi()); + pionTracksData(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(massPi), track.phi(), track.hasTOF()); } } @@ -715,7 +741,7 @@ struct PionTrackProducer { continue; } - pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(massPi), track.phi()); + pionTracksMcReco(collision.globalIndex(), track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt(), track.rapidity(massPi), track.phi(), track.hasTOF()); } } diff --git a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx index b427eafa899..d5d30fe0841 100644 --- a/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/phiStrangeCorrelation.cxx @@ -77,6 +77,12 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +enum AnalysisMode { + kOldNormalization = 0, + kMassvsMass, + kDeltaYvsDeltaPhi +}; + static constexpr std::array phiMassRegionLabels{"Signal", "Sideband"}; enum ParticleOfInterest { @@ -155,7 +161,7 @@ struct PhiStrangenessCorrelation { Configurable eventSelectionType{"eventSelectionType", 0, "Event selection type: 0 - default selection only, 1 - default + phi meson selection"}; // Configurable for analysis mode - Configurable analysisMode{"analysisMode", 1, "Analysis mode: 0 - old method with online normalization, 1 - new method with correlations"}; + Configurable analysisMode{"analysisMode", kMassvsMass, "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 @@ -175,6 +181,14 @@ struct PhiStrangenessCorrelation { Configurable> rangeMK0sSignal{"rangeMK0sSignal", {0.47f, 0.53f}, "K0S mass range for signal extraction"}; } k0sConfigs; + // Configurables for Pions selection + struct : ConfigurableGroup { + Configurable selectPionInSigRegion{"selectPionInSigRegion", false, "Select Pion candidates in signal region"}; + Configurable pidTPCMax{"pidTPCMax", 2.0f, "Maximum nSigma TPC"}; + Configurable pidTOFMax{"pidTOFMax", 2.0f, "Maximum nSigma TOF"}; + Configurable tofPIDThreshold{"tofPIDThreshold", 0.5f, "Minimum pT after which TOF PID is applicable"}; + } pionConfigs; + // 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"}; @@ -201,7 +215,7 @@ struct PhiStrangenessCorrelation { // Configurables for CCDB Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository to use"}; - Configurable ccdbEfficiencyPath{"ccdbEfficiencyPath", "Users/s/scannito/Efficiencies", "Correction path to file"}; + Configurable ccdbEfficiencyPath{"ccdbEfficiencyPath", "Users/s/scannito/Efficiencies/h3EffMap", "Correction path to file"}; // Configurables for minimum pt selection in McGen struct : ConfigurableGroup { @@ -224,7 +238,8 @@ struct PhiStrangenessCorrelation { struct : PresliceGroup { Preslice phiCandDataPerCollision = aod::lf_selection_phi_candidate::collisionId; - PresliceUnsorted phiCandMcRecoPerCollision = aod::lf_selection_phi_candidate::collisionId; + // PresliceUnsorted phiCandMcRecoPerCollision = aod::lf_selection_phi_candidate::collisionId; + Preslice phiCandMcRecoPerCollision = aod::lf_selection_phi_candidate::collisionId; Preslice k0sDataPerCollision = aod::v0::collisionId; Preslice k0sMcRecoPerCollision = aod::v0::collisionId; @@ -258,12 +273,23 @@ struct PhiStrangenessCorrelation { 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 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 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})"}; histos.add("phi/h3PhiData", "Invariant mass of Phi in Data", kTH3F, {binnedmultAxis, binnedpTPhiAxis, massPhiAxis}); + + histos.add("phiK0S/h6PhiK0SData", "Invariant mass of Phi vs Invariant mass of K0Short in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTK0SAxis, deltayAxis, massPhiAxis, massK0SAxis}); + 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("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("phiPi/h5PhiPiData{}", label).c_str(), "Deltay vs deltaphi for Phi and Pion in Data", kTHnSparseF, {binnedmultAxis, binnedpTPhiAxis, binnedpTPiAxis, deltayAxis, deltaphiAxis}); @@ -291,10 +317,6 @@ struct PhiStrangenessCorrelation { 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("pi/h2RecMCDCAxyPrimPi", "Dcaxy distribution vs pt for Primary Pions", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - histos.add("pi/h2RecMCDCAxySecWeakDecayPi", "Dcaz distribution vs pt for Secondary Pions from Weak Decay", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - histos.add("pi/h2RecMCDCAxySecMaterialPi", "Dcaxy distribution vs pt for Secondary Pions from Material", kTH2F, {binnedpTPiAxis, {2000, -0.05, 0.05, "DCA_{xy} (cm)"}}); - // Load efficiency maps from CCDB if (applyEfficiency) { ccdb->setURL(ccdbUrl); @@ -310,7 +332,7 @@ struct PhiStrangenessCorrelation { void loadEfficiencyMapFromCCDB(ParticleOfInterest poi) { - effMaps[poi] = std::shared_ptr(ccdb->get(fmt::format("{}/h3EffMap{}", ccdbEfficiencyPath.value, particleOfInterestLabels[poi]))); + effMaps[poi] = std::shared_ptr(ccdb->get(fmt::format("{}{}", ccdbEfficiencyPath.value, particleOfInterestLabels[poi]))); if (!effMaps[poi]) LOG(fatal) << "Could not load efficiency map for " << particleOfInterestLabels[poi] << "!"; LOG(info) << "Efficiency map for " << particleOfInterestLabels[poi] << " loaded from CCDB"; @@ -333,18 +355,88 @@ struct PhiStrangenessCorrelation { return RecoDecay::constrainAngle(phiTrigger - phiAssociated, -o2::constants::math::PIHalf); } - void processPhiK0SPionData(SelCollisions::iterator const& collision, aod::PhimesonCandidatesData const& phiCandidates, aod::K0sReducedCandidatesData const& k0sReduced, aod::PionTracksData const& pionTracks) + template + void processPhiK0SPionSE(TCollision const& collision, TPhiCands const& phiCandidates, TK0SCands const& k0sReduced, TPionCands const& pionTracks) { float multiplicity = collision.centFT0M(); const std::array, 2> phiMassRegions = {phiConfigs.rangeMPhiSignal, phiConfigs.rangeMPhiSideband}; + const bool applyK0sMassCut = (analysisMode == kDeltaYvsDeltaPhi) && k0sConfigs.selectK0sInSigRegion; + const auto& [minMassK0s, maxMassK0s] = k0sConfigs.rangeMK0sSignal.value; + auto isK0sValid = [&](const auto& k0s) { + return !applyK0sMassCut || k0s.inMassRegion(minMassK0s, maxMassK0s); + }; + + const bool applyPionNSigmaCut = (analysisMode == kDeltaYvsDeltaPhi) && pionConfigs.selectPionInSigRegion; + const float& pidTPCMax = pionConfigs.pidTPCMax; + const float& pidTOFMax = pionConfigs.pidTOFMax; + const float& tofPIDThreshold = pionConfigs.tofPIDThreshold; + + auto isPionValid = [&](const auto& pion) { + return !applyPionNSigmaCut || pion.inNSigmaRegion(pidTPCMax, tofPIDThreshold, pidTOFMax); + }; + for (const auto& phiCand : phiCandidates) { float weightPhi = computeWeight(BoundEfficiencyMap(effMaps[Phi], multiplicity, phiCand.pt(), phiCand.y())); histos.fill(HIST("phi/h3PhiData"), multiplicity, phiCand.pt(), phiCand.m(), weightPhi); - static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + auto processCorrelations = [&](auto fillK0S, auto fillPion) { + // Loop over all reduced K0S candidates + for (const auto& k0s : k0sReduced) { + /*if (k0sConfigs.selectK0sInSigRegion) { + const auto& [minMassK0s, maxMassK0s] = k0sConfigs.rangeMK0sSignal.value; + if (!k0s.inMassRegion(minMassK0s, maxMassK0s)) + continue; + }*/ + if (!isK0sValid(k0s)) + continue; + + float weightPhiK0S = computeWeight(BoundEfficiencyMap(effMaps[Phi], multiplicity, phiCand.pt(), phiCand.y()), + BoundEfficiencyMap(effMaps[K0S], multiplicity, k0s.pt(), k0s.y())); + fillK0S(k0s, weightPhiK0S); + } + + // Loop over all primary pion candidates + for (const auto& pionTrack : pionTracks) { + if (!isPionValid(pionTrack)) + continue; + + float weightPhiPion = computeWeight(BoundEfficiencyMap(effMaps[Phi], multiplicity, phiCand.pt(), phiCand.y()), + BoundEfficiencyMap(effMaps[Pion], multiplicity, pionTrack.pt(), pionTrack.y())); + fillPion(pionTrack, weightPhiPion); + } + }; + + if (analysisMode == kMassvsMass) { + processCorrelations( + [&](const auto& k0s, float w) { + histos.fill(HIST("phiK0S/h6PhiK0SData"), multiplicity, phiCand.pt(), k0s.pt(), phiCand.y() - k0s.y(), phiCand.m(), k0s.m(), w); + }, + [&](const auto& pion, float w) { + histos.fill(HIST("phiPi/h6PhiPiTPCData"), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), phiCand.m(), pion.nSigmaTPC(), w); + histos.fill(HIST("phiPi/h6PhiPiTOFData"), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), phiCand.m(), pion.nSigmaTOF(), w); + }); + } else if (analysisMode == kDeltaYvsDeltaPhi) { + static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + constexpr unsigned int i = i_idx.value; + + const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; + if (!phiCand.inMassRegion(minMassPhi, maxMassPhi)) + return; + + processCorrelations( + [&](const auto& k0s, float w) { + histos.fill(HIST("phiK0S/h5PhiK0SData") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), k0s.pt(), phiCand.y() - k0s.y(), getDeltaPhi(phiCand.phi(), k0s.phi()), w); + }, + [&](const auto& pion, float w) { + histos.fill(HIST("phiPi/h5PhiPiData") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), getDeltaPhi(phiCand.phi(), pion.phi()), w); + }); + }); + } + + /*static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { constexpr unsigned int i = i_idx.value; const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; @@ -372,25 +464,82 @@ struct PhiStrangenessCorrelation { histos.fill(HIST("phiPi/h5PhiPiData") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), pionTrack.pt(), phiCand.y() - pionTrack.y(), getDeltaPhi(phiCand.phi(), pionTrack.phi()), weightPhiPion); } - }); + });*/ } } - PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SPionData, "Process function for Phi-K0S and Phi-Pion Deltay and Deltaphi 2D Correlations in Data", true); + // PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SPionSE, "Process function for Phi-K0S and Phi-Pion Deltay and Deltaphi 2D Correlations in SE", true); + + void processPhiK0SPionSEDataLike(SelCollisions::iterator const& collision, aod::PhimesonCandidatesData const& phiCandidates, aod::K0sReducedCandidatesData const& k0sReduced, aod::PionTracksData const& pionTracks) + { + processPhiK0SPionSE(collision, phiCandidates, k0sReduced, pionTracks); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SPionSEDataLike, "Process function for Phi-K0S and Phi-Pion 2D Correlations in Data or MC w/o PDG SE", true); - void processPhiK0SDataME(SelCollisions const& collisions, aod::PhimesonCandidatesData const& phiCandidates, aod::K0sReducedCandidatesData const& k0sReduced) + void processPhiK0SPionSEMCWithPDG(SimCollisions::iterator const& collision, aod::PhimesonCandidatesMcReco const& phiCandidates, aod::K0sReducedCandidatesMcReco const& k0sReduced, aod::PionTracksMcReco const& pionTracks) + { + processPhiK0SPionSE(collision, phiCandidates, k0sReduced, pionTracks); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SPionSEMCWithPDG, "Process function for Phi-K0S and Phi-Pion 2D Correlations in MC with PDG SE", true); + + template + void processPhiK0SME(TCollisions const& collisions, TPhiCands const& phiCandidates, TK0SCands const& k0sReduced) { const std::array, 2> phiMassRegions = {phiConfigs.rangeMPhiSignal, phiConfigs.rangeMPhiSideband}; + const bool applyK0sMassCut = (analysisMode == kDeltaYvsDeltaPhi) && k0sConfigs.selectK0sInSigRegion; + const auto& [minMassK0s, maxMassK0s] = k0sConfigs.rangeMK0sSignal.value; + + auto isK0sValid = [&](const auto& k0s) { + return !applyK0sMassCut || k0s.inMassRegion(minMassK0s, maxMassK0s); + }; + auto tuplePhiK0S = std::make_tuple(phiCandidates, k0sReduced); - Pair pairPhiK0S{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tuplePhiK0S, &cache}; + Pair pairPhiK0S{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tuplePhiK0S, &cache}; for (const auto& [c1, phiCands, c2, k0sRed] : pairPhiK0S) { float multiplicity = c1.centFT0M(); for (const auto& [phiCand, k0s] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(phiCands, k0sRed))) { - static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + if (!isK0sValid(k0s)) + continue; + + auto processCorrelations = [&](auto fillK0S) { + /*if (k0sConfigs.selectK0sInSigRegion) { + const auto& [minMassK0s, maxMassK0s] = k0sConfigs.rangeMK0sSignal.value; + if (!k0s.inMassRegion(minMassK0s, maxMassK0s)) + continue; + }*/ + + float weightPhiK0S = computeWeight(BoundEfficiencyMap(effMaps[Phi], multiplicity, phiCand.pt(), phiCand.y()), + BoundEfficiencyMap(effMaps[K0S], multiplicity, k0s.pt(), k0s.y())); + fillK0S(k0s, weightPhiK0S); + }; + + if (analysisMode == kMassvsMass) { + processCorrelations( + [&](const auto& k0s, float w) { + histos.fill(HIST("phiK0S/h6PhiK0SDataMe"), multiplicity, phiCand.pt(), k0s.pt(), phiCand.y() - k0s.y(), phiCand.m(), k0s.m(), w); + }); + } else if (analysisMode == kDeltaYvsDeltaPhi) { + static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + constexpr unsigned int i = i_idx.value; + + const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; + if (!phiCand.inMassRegion(minMassPhi, maxMassPhi)) + return; + + processCorrelations( + [&](const auto& k0s, float w) { + histos.fill(HIST("phiK0S/h5PhiK0SDataME") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), k0s.pt(), phiCand.y() - k0s.y(), getDeltaPhi(phiCand.phi(), k0s.phi()), w); + }); + }); + } + + /*static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { constexpr unsigned int i = i_idx.value; const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; @@ -407,26 +556,80 @@ struct PhiStrangenessCorrelation { BoundEfficiencyMap(effMaps[K0S], multiplicity, k0s.pt(), k0s.y())); histos.fill(HIST("phiK0S/h5PhiK0SDataME") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), k0s.pt(), phiCand.y() - k0s.y(), getDeltaPhi(phiCand.phi(), k0s.phi()), weightPhiK0S); - }); + });*/ } } } - PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SDataME, "Process function for Phi-K0S and Deltay and Deltaphi 2D Correlations in Data ME", false); + // PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SME, "Process function for Phi-K0S and Deltay and Deltaphi 2D Correlations in Data ME", false); + + void processPhiK0SMEDataLike(SelCollisions const& collisions, aod::PhimesonCandidatesData const& phiCandidates, aod::K0sReducedCandidatesData const& k0sReduced) + { + processPhiK0SME(collisions, phiCandidates, k0sReduced); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, 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) + { + processPhiK0SME(collisions, phiCandidates, k0sReduced); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiK0SMEMCWithPDG, "Process function for Phi-K0S 2D Correlations in MC with PDG ME", true); - void processPhiPionDataME(SelCollisions const& collisions, aod::PhimesonCandidatesData const& phiCandidates, aod::PionTracksData const& pionTracks) + template + void processPhiPionME(TCollisions const& collisions, TPhiCands const& phiCandidates, TPionCands const& pionTracks) { const std::array, 2> phiMassRegions = {phiConfigs.rangeMPhiSignal, phiConfigs.rangeMPhiSideband}; + const bool applyPionNSigmaCut = (analysisMode == kDeltaYvsDeltaPhi) && pionConfigs.selectPionInSigRegion; + const float& pidTPCMax = pionConfigs.pidTPCMax; + const float& pidTOFMax = pionConfigs.pidTOFMax; + const float& tofPIDThreshold = pionConfigs.tofPIDThreshold; + + auto isPionValid = [&](const auto& pion) { + return !applyPionNSigmaCut || pion.inNSigmaRegion(pidTPCMax, tofPIDThreshold, pidTOFMax); + }; + auto tuplePhiPion = std::make_tuple(phiCandidates, pionTracks); - Pair pairPhiPion{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tuplePhiPion, &cache}; + Pair pairPhiPion{binningOnVertexAndCent, cfgNoMixedEvents, -1, collisions, tuplePhiPion, &cache}; for (const auto& [c1, phiCands, c2, piTracks] : pairPhiPion) { float multiplicity = c1.centFT0M(); for (const auto& [phiCand, piTrack] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(phiCands, piTracks))) { - static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + if (!isPionValid(piTrack)) + continue; + + auto processCorrelations = [&](auto fillPion) { + float weightPhiPion = computeWeight(BoundEfficiencyMap(effMaps[Phi], multiplicity, phiCand.pt(), phiCand.y()), + BoundEfficiencyMap(effMaps[Pion], multiplicity, piTrack.pt(), piTrack.y())); + fillPion(piTrack, weightPhiPion); + }; + + if (analysisMode == kMassvsMass) { + processCorrelations( + [&](const auto& pion, float w) { + histos.fill(HIST("phiPi/h6PhiPiTPCDataME"), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), phiCand.m(), pion.nSigmaTPC(), w); + histos.fill(HIST("phiPi/h6PhiPiTOFDataME"), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), phiCand.m(), pion.nSigmaTOF(), w); + }); + } else if (analysisMode == kDeltaYvsDeltaPhi) { + static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { + constexpr unsigned int i = i_idx.value; + + const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; + if (!phiCand.inMassRegion(minMassPhi, maxMassPhi)) + return; + + processCorrelations( + [&](const auto& pion, float w) { + histos.fill(HIST("phiPi/h5PhiPiDataME") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), pion.pt(), phiCand.y() - pion.y(), getDeltaPhi(phiCand.phi(), pion.phi()), w); + }); + }); + } + + /*static_for<0, phiMassRegionLabels.size() - 1>([&](auto i_idx) { constexpr unsigned int i = i_idx.value; const auto& [minMassPhi, maxMassPhi] = phiMassRegions[i]; @@ -437,16 +640,44 @@ struct PhiStrangenessCorrelation { BoundEfficiencyMap(effMaps[Pion], multiplicity, piTrack.pt(), piTrack.y())); histos.fill(HIST("phiPi/h5PhiPiDataME") + HIST(phiMassRegionLabels[i]), multiplicity, phiCand.pt(), piTrack.pt(), phiCand.y() - piTrack.y(), getDeltaPhi(phiCand.phi(), piTrack.phi()), weightPhiPion); - }); + });*/ } } } - PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiPionDataME, "Process function for Phi-Pion Deltay and Deltaphi 2D Correlations in Data ME", false); + // PROCESS_SWITCH(PhiStrangenessCorrelation, processPhiPionME, "Process function for Phi-Pion Deltay and Deltaphi 2D Correlations in Data ME", false); + + void processPhiPionMEDataLike(SelCollisions const& collisions, aod::PhimesonCandidatesData const& phiCandidates, aod::PionTracksData const& pionTracks) + { + processPhiPionME(collisions, phiCandidates, pionTracks); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, 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) + { + processPhiPionME(collisions, phiCandidates, pionTracks); + } + + PROCESS_SWITCH(PhiStrangenessCorrelation, 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, aod::K0sReducedCandidatesMcReco const& k0sReduced, aod::PionTracksMcReco const& pionTracks, aod::McParticles const& mcParticles) { - // std::vector> collsGrouped(mcCollisions.size()); + const bool applyK0sMassCut = (analysisMode == kDeltaYvsDeltaPhi) && k0sConfigs.selectK0sInSigRegion; + const auto& [minMassK0s, maxMassK0s] = k0sConfigs.rangeMK0sSignal.value; + auto isK0sValid = [&](const auto& k0s) { + return !applyK0sMassCut || k0s.inMassRegion(minMassK0s, maxMassK0s); + }; + + const bool applyPionNSigmaCut = (analysisMode == kDeltaYvsDeltaPhi) && pionConfigs.selectPionInSigRegion; + const float& pidTPCMax = pionConfigs.pidTPCMax; + const float& pidTOFMax = pionConfigs.pidTOFMax; + const float& tofPIDThreshold = pionConfigs.tofPIDThreshold; + + auto isPionValid = [&](const auto& pion) { + return !applyPionNSigmaCut || pion.inNSigmaRegion(pidTPCMax, tofPIDThreshold, pidTOFMax); + }; + std::unordered_map> collsGrouped; collsGrouped.reserve(mcCollisions.size()); @@ -488,10 +719,16 @@ struct PhiStrangenessCorrelation { const auto pionTracksThisColl = pionTracks.sliceBy(preslices.pionTrackMcRecoPerCollision, collision.globalIndex()); for (const auto& k0s : k0sThisColl) { + if (!isK0sValid(k0s)) + continue; + histos.fill(HIST("k0s/h4K0SMCReco"), collision.posZ(), mcCollision.centFT0M(), k0s.pt(), k0s.y()); } for (const auto& pionTrack : pionTracksThisColl) { + if (!isPionValid(pionTrack)) + continue; + histos.fill(HIST("pi/h4PiMCReco"), collision.posZ(), mcCollision.centFT0M(), pionTrack.pt(), pionTrack.y()); }