diff --git a/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx b/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx index 2418f442bf4..e9682bdde1a 100644 --- a/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520analysisinpp.cxx @@ -13,6 +13,7 @@ /// \brief This standalone task reconstructs track-track decay of lambda(1520) resonance candidate /// \author Hirak Kumar Koley +#include "PWGLF/DataModel/mcCentrality.h" #include "PWGLF/Utils/inelGt.h" #include "Common/DataModel/Centrality.h" @@ -48,18 +49,6 @@ enum { Inel10, Inelg0, Inelg010, - Trig, - Trig10, - TrigINELg0, - TrigINELg010, - Sel8, - Sel810, - Sel8INELg0, - Sel8INELg010, - AllCuts, - AllCuts10, - AllCutsINELg0, - AllCutsINELg010, }; enum TrackSelectionType { @@ -77,10 +66,11 @@ enum PIDCutType { }; struct Lambda1520analysisinpp { - // Define slice per Resocollision - SliceCache cache; + // Define slice per collision Preslice perCollision = o2::aod::track::collisionId; + SliceCache cache; Preslice perMcCollision = o2::aod::mcparticle::mcCollisionId; + SliceCache cacheMC; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -216,9 +206,15 @@ struct Lambda1520analysisinpp { using EventCandidates = soa::Join; using TrackCandidates = soa::Filtered>; + + // for MC reco using MCEventCandidates = soa::Join; using MCTrackCandidates = soa::Filtered>; + // for MC truth + // using MCTrueEventCandidates = soa::Join; + // using MCTrueTrackCandidates = aod::McParticles; + /// Figures ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.12f, 0.14f, 0.16f, 0.18f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.45f, 0.5f, 0.55f, 0.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1.0f, 1.1f, 1.2f, 1.25f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.75f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f, 3.1f, 3.2f, 3.3f, 3.4f, 3.6f, 3.7f, 3.8f, 3.9f, 4.0f, 4.1f, 4.2f, 4.5f, 4.6f, 4.8f, 4.9f, 5.0f, 5.5f, 5.6f, 6.0f, 6.4f, 6.5f, 7.0f, 7.2f, 8.0f, 9.0f, 9.5f, 9.6f, 10.0f, 11.0f, 11.5f, 12.0f, 13.0f, 14.0f, 14.4f, 15.0f, 16.0f, 18.0f, 19.2f, 20.0f}, "Binning of the pT axis"}; ConfigurableAxis binsPtQA{"binsPtQA", {VARIABLE_WIDTH, 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.2f, 4.4f, 4.6f, 4.8f, 5.0f, 5.2f, 5.4f, 5.6f, 5.8f, 6.0f, 6.2f, 6.4f, 6.6f, 6.8f, 7.0f, 7.2f, 7.4f, 7.6f, 7.8f, 8.0f, 8.2f, 8.4f, 8.6f, 8.8f, 9.0f, 9.2f, 9.4f, 9.6f, 9.8f, 10.0f, 10.2f, 10.4f, 10.6f, 10.8f, 11.0f, 11.2f, 11.4f, 11.6f, 11.8f, 12.0f, 12.2f, 12.4f, 12.6f, 12.8f, 13.0f, 13.2f, 13.4f, 13.6f, 13.8f, 14.0f, 14.2f, 14.4f, 14.6f, 14.8f, 15.0f, 15.2f, 15.4f, 15.6f, 15.8f, 16.0f, 16.2f, 16.4f, 16.6f, 16.8f, 17.0f, 17.2f, 17.4f, 17.6f, 17.8f, 18.0f, 18.2f, 18.4f, 18.6f, 18.8f, 19.0f, 19.2f, 19.4f, 19.6f, 19.8f, 20.0f}, "Binning of the pT axis"}; @@ -396,6 +392,7 @@ struct Lambda1520analysisinpp { // MC QA histos.add("Event/hMCEventIndices", "hMCEventIndices", kTH2D, {axisMult, idxMCAxis}); + if (doprocessMCGen) { histos.add("QA/Gen", "Gen histogram", kTH1D, {{10, 0, 10, "index"}}); histos.add("QA/MC/h2GenEtaPt_beforeanycut", " #eta-#it{p}_{T} distribution of Generated #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPtQA}); @@ -407,6 +404,15 @@ struct Lambda1520analysisinpp { histos.add("Result/MC/Genlambda1520pt", "pT distribution of True MC #Lambda(1520)0", kTH3F, {axisMClabel, axisPt, axisMult}); histos.add("Result/MC/Genantilambda1520pt", "pT distribution of True MC Anti-#Lambda(1520)0", kTH3F, {axisMClabel, axisPt, axisMult}); + + histos.add("Result/SignalLoss/GenTrueprotonpt_num", "True proton (num)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genprotonpt_num", "Proton (num)", kTH2F, {axisPt, axisMult}); + + histos.add("Result/SignalLoss/GenTruelambdapt_num", "True lambda (num)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genlambdapt_num", "Lambda (num)", kTH2F, {axisPt, axisMult}); + + histos.add("Result/SignalLoss/GenTruexipt_num", "True xi (num)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genxipt_num", "Xi (num)", kTH2F, {axisPt, axisMult}); } if (doprocessMCRec) { histos.add("QA/MC/h2RecoEtaPt_after", " #eta-#it{p}_{T} distribution of Reconstructed #Lambda(1520); #eta; #it{p}_{T}; Counts;", HistType::kTHnSparseF, {axisEta, axisPt}); @@ -425,13 +431,17 @@ struct Lambda1520analysisinpp { histos.add("Result/MC/h3antilambda1520Recoinvmass", "Invariant mass of Reconstructed MC Anti-#Lambda(1520)0", kTHnSparseF, {axisMult, axisPt, axisMassLambda1520}); } if (doprocessSignalLoss) { - histos.add("Result/SignalLoss/Genprotonpt", "pT distribution of #Lambda(1520) from Proton", kTH3F, {axisMClabel, axisPt, axisMult}); - histos.add("Result/SignalLoss/Genlambdapt", "pT distribution of #Lambda(1520) from #Lambda", kTH3F, {axisMClabel, axisPt, axisMult}); - histos.add("Result/SignalLoss/Genxipt", "pT distribution of #Lambda(1520) from #Xi", kTH3F, {axisMClabel, axisPt, axisMult}); + histos.add("Result/SignalLoss/GenTruelambda1520pt_den", "True lambda1520 (den)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/GenTrueantilambda1520pt_den", "True anti-lambda1520 (den)", kTH2F, {axisPt, axisMult}); + + histos.add("Result/SignalLoss/GenTrueprotonpt_den", "True proton (den)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genprotonpt_den", "Proton (den)", kTH2F, {axisPt, axisMult}); - histos.add("Result/SignalLoss/GenTrueprotonpt", "pT distribution of True MC Proton", kTH3F, {axisMClabel, axisPt, axisMult}); - histos.add("Result/SignalLoss/GenTruelambdapt", "pT distribution of True MC #Lambda", kTH3F, {axisMClabel, axisPt, axisMult}); - histos.add("Result/SignalLoss/GenTruexipt", "pT distribution of True MC #Xi", kTH3F, {axisMClabel, axisPt, axisMult}); + histos.add("Result/SignalLoss/GenTruelambdapt_den", "True lambda (den)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genlambdapt_den", "Lambda (den)", kTH2F, {axisPt, axisMult}); + + histos.add("Result/SignalLoss/GenTruexipt_den", "True xi (den)", kTH2F, {axisPt, axisMult}); + histos.add("Result/SignalLoss/Genxipt_den", "Xi (den)", kTH2F, {axisPt, axisMult}); } // Print output histograms statistics @@ -1097,10 +1107,62 @@ struct Lambda1520analysisinpp { } PROCESS_SWITCH(Lambda1520analysisinpp, processRotational, "Process Rotational Background", false); + // Processing Event Mixing + using BinningTypeVtxZT0M = ColumnBinningPolicy; + + void processME(EventCandidates const& collision, + TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + + BinningTypeVtxZT0M colBinning{{configBkg.cfgVtxBins, configBkg.cfgMultPercentileBins}, true}; + SameKindPair pairs{colBinning, configBkg.nEvtMixing, -1, collision, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { + // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.globalIndex(), collision2.globalIndex()); + + // for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { + // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.index(), t2.index(), collision1.index(), collision2.index()); + // } + + if (!isSelected(collision1, false)) // Default event selection + continue; + + if (!isSelected(collision2, false)) // Default event selection + continue; + + if (!collision1.isInelGt0()) // <-- + continue; + + if (!collision2.isInelGt0()) // <-- + continue; + + if (cFilladditionalQAeventPlots) { + // Fill histograms for the characteristics of the *mixed* events (collision1 and collision2) + // This will show the distribution of events that are actually being mixed. + if (cFill1DQAs) { + histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision1.posZ()); + histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision1.centFT0M()); + } + histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision1.posZ(), collision1.centFT0M()); + + // You might also want to fill for collision2 if you want to see both partners' distributions + // histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision2.posZ()); + // histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision2.centFT0M()); + // histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision2.posZ(), collision2.centFT0M()); + } + fillHistograms(collision1, tracks1, tracks2); + } + } + PROCESS_SWITCH(Lambda1520analysisinpp, processME, "Process EventMixing light without partition", false); + void processMCRec(MCEventCandidates::iterator const& collision, aod::McCollisions const&, MCTrackCandidates const& tracks, aod::McParticles const&) { + if (!collision.has_mcCollision()) + return; + if (!isSelected(collision)) return; @@ -1117,22 +1179,24 @@ struct Lambda1520analysisinpp { void processMCGen(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles) { + if (!collision.has_mcCollision()) + return; + bool isInAfterAllCuts = isSelected(collision, false); bool inVtx10 = (std::abs(collision.mcCollision().posZ()) > configEvents.cfgEvtZvtx) ? false : true; bool isTriggerTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX); bool isSel8 = collision.sel8(); auto mcPartsAll = mcParticles.sliceBy(perMcCollision, collision.mcCollision().globalIndex()); - - bool isTrueINELgt0 = pwglf::isINELgt0mc(mcPartsAll, pdg); - // bool isTrueINELgt0 = collision.isInelGt0(); + // bool isTrueINELgt0 = pwglf::isINELgt0mc(mcPartsAll, pdg); + bool isTrueINELgt0 = collision.isInelGt0(); // <-- auto centrality = centEst(collision); auto mcParts = selectedMCParticles->sliceBy(perMcCollision, collision.mcCollision().globalIndex()); // Not related to the real collisions - for (const auto& part : mcParts) { // loop over all MC particles + for (const auto& part : mcParts) { // loop over all Lambda(1520) particles std::vector daughterPDGs; if (part.has_daughters()) { @@ -1230,284 +1294,198 @@ struct Lambda1520analysisinpp { } } - // QA for Trigger efficiency - histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel); - if (inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel10); - if (isTrueINELgt0) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg0); - if (inVtx10 && isTrueINELgt0) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg010); - - // TVX MB trigger - if (isTriggerTVX) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Trig); - if (isTriggerTVX && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Trig10); - if (isTriggerTVX && isTrueINELgt0) - histos.fill(HIST("Event/hMCEventIndices"), centrality, TrigINELg0); - if (isTriggerTVX && isTrueINELgt0 && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, TrigINELg010); - - // Sel8 event selection - if (isSel8) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8); - if (isSel8 && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel810); - if (isSel8 && isTrueINELgt0) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8INELg0); - if (isSel8 && isTrueINELgt0 && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, Sel8INELg010); - - // CollisionCuts selection - if (isInAfterAllCuts) - histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCuts); - if (isInAfterAllCuts && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCuts10); - if (isInAfterAllCuts && isTrueINELgt0) - histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCutsINELg0); - if (isInAfterAllCuts && isTrueINELgt0 && inVtx10) - histos.fill(HIST("Event/hMCEventIndices"), centrality, AllCutsINELg010); - } - PROCESS_SWITCH(Lambda1520analysisinpp, processMCGen, "Process Event for MC only", false); - - // Processing Event Mixing - using BinningTypeVtxZT0M = ColumnBinningPolicy; - - void processME(EventCandidates const& collision, - TrackCandidates const& tracks) - { - auto tracksTuple = std::make_tuple(tracks); - - BinningTypeVtxZT0M colBinning{{configBkg.cfgVtxBins, configBkg.cfgMultPercentileBins}, true}; - SameKindPair pairs{colBinning, configBkg.nEvtMixing, -1, collision, tracksTuple, &cache}; // -1 is the number of the bin to skip - - for (const auto& [collision1, tracks1, collision2, tracks2] : pairs) { - // LOGF(info, "Mixed event collisions: (%d, %d)", collision1.globalIndex(), collision2.globalIndex()); - - // for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(tracks1, tracks2))) { - // LOGF(info, "Mixed event tracks pair: (%d, %d) from events (%d, %d)", t1.index(), t2.index(), collision1.index(), collision2.index()); - // } - - if (!isSelected(collision1, false)) // Default event selection - continue; - - if (!isSelected(collision2, false)) // Default event selection - continue; - - if (!collision1.isInelGt0()) // <-- - continue; - - if (!collision2.isInelGt0()) // <-- - continue; - - if (cFilladditionalQAeventPlots) { - // Fill histograms for the characteristics of the *mixed* events (collision1 and collision2) - // This will show the distribution of events that are actually being mixed. - if (cFill1DQAs) { - histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision1.posZ()); - histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision1.centFT0M()); - } - histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision1.posZ(), collision1.centFT0M()); - - // You might also want to fill for collision2 if you want to see both partners' distributions - // histos.fill(HIST("QAevent/hMixPool_VtxZ"), collision2.posZ()); - // histos.fill(HIST("QAevent/hMixPool_Multiplicity"), collision2.centFT0M()); - // histos.fill(HIST("QAevent/hMixPool_VtxZ_vs_Multiplicity"), collision2.posZ(), collision2.centFT0M()); - } - fillHistograms(collision1, tracks1, tracks2); - } - } - PROCESS_SWITCH(Lambda1520analysisinpp, processME, "Process EventMixing light without partition", false); - - void processSignalLoss(MCEventCandidates::iterator const& collision, aod::McCollisions const&, aod::McParticles const& mcParticles) - { - bool isInAfterAllCuts = isSelected(collision, false); - bool inVtx10 = (std::abs(collision.mcCollision().posZ()) > configEvents.cfgEvtZvtx) ? false : true; - bool isTriggerTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX); - bool isSel8 = collision.sel8(); - - auto mcPartsAll = mcParticles.sliceBy(perMcCollision, collision.mcCollision().globalIndex()); - - bool isTrueINELgt0 = pwglf::isINELgt0mc(mcPartsAll, pdg); - // bool isTrueINELgt0 = collision.isInelGt0(); - - auto centrality = centEst(collision); - auto computePtL = [&](float pt, float m_ref) { float ptL2 = pt * pt + m_ref * m_ref - MassLambda1520 * MassLambda1520; return (ptL2 > 0) ? std::sqrt(ptL2) : -1.f; }; + // ===== NUM ===== + if (!(inVtx10 && isTrueINELgt0)) + return; + + if (!isInAfterAllCuts) + return; + for (const auto& part : mcPartsAll) { if (!part.isPhysicalPrimary()) continue; - float pt = part.pt(); - - float weight; - - if (cUseRapcutMC && std::abs(part.y()) > configTracks.cfgCutRapidity) // rapidity cut + if (cUseRapcutMC && std::abs(part.y()) > configTracks.cfgCutRapidity) continue; - if (std::abs(part.pdgCode()) == kProton) { - - // true proton - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 0, pt, centrality); - - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 1, pt, centrality); - - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 2, pt, centrality); - - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 3, pt, centrality); - - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 4, pt, centrality); + if (cUseEtacutMC && std::abs(part.eta()) > cEtacutMC) + continue; - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 5, pt, centrality); + float pt = part.pt(); - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt"), 6, pt, centrality); + // proton + if (std::abs(part.pdgCode()) == kProton) { + histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt_num"), pt, centrality); float ptL = computePtL(pt, massPr); - if (ptL < 0) - continue; - - if (useWeight) - weight = ptL / pt; - else - weight = 1.f; - - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 0, ptL, centrality, weight); - - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 1, ptL, centrality, weight); - - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 2, ptL, centrality, weight); + if (ptL > 0) { + float w = useWeight ? ptL / pt : 1.f; + histos.fill(HIST("Result/SignalLoss/Genprotonpt_num"), ptL, centrality, w); + } + } - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 3, ptL, centrality, weight); + // lambda + if (std::abs(part.pdgCode()) == kLambda0) { + histos.fill(HIST("Result/SignalLoss/GenTruelambdapt_num"), pt, centrality); - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 4, ptL, centrality, weight); + float ptL = computePtL(pt, MassLambda0); + if (ptL > 0) { + float w = useWeight ? ptL / pt : 1.f; + histos.fill(HIST("Result/SignalLoss/Genlambdapt_num"), ptL, centrality, w); + } + } - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 5, ptL, centrality, weight); + // xi + if (std::abs(part.pdgCode()) == PDG_t::kXiMinus) { + histos.fill(HIST("Result/SignalLoss/GenTruexipt_num"), pt, centrality); - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/Genprotonpt"), 6, ptL, centrality, weight); + float ptL = computePtL(pt, MassXiMinus); + if (ptL > 0) { + float w = useWeight ? ptL / pt : 1.f; + histos.fill(HIST("Result/SignalLoss/Genxipt_num"), ptL, centrality, w); + } } + } + } + PROCESS_SWITCH(Lambda1520analysisinpp, processMCGen, "Process Event for MC only", false); - if (std::abs(part.pdgCode()) == kLambda0) { - - // true lambda - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 0, pt, centrality); + void processEventFactor(soa::Join const& mcCollisions, aod::McParticles const& mcParticles) + { + // Loop on generated collisions to fill the event factor for the INEL>0 correction + for (const auto& mccolls : mcCollisions) { + float centrality = mccolls.centFT0M(); + bool inVtx10 = std::abs(mccolls.posZ()) <= configEvents.cfgEvtZvtx; + + const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolls.globalIndex(), cacheMC); + bool isTrueINELgt0 = pwglf::isINELgt0mc(particlesInCollision, pdg); // QA for Trigger efficiency + + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel); + if (inVtx10) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inel10); + if (isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg0); + if (inVtx10 && isTrueINELgt0) + histos.fill(HIST("Event/hMCEventIndices"), centrality, Inelg010); + } + } + PROCESS_SWITCH(Lambda1520analysisinpp, processEventFactor, "Process Event factor", false); - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 1, pt, centrality); + void processSignalLoss(soa::Join const& mcCollisions, aod::McParticles const& mcParticles) + { + for (const auto& mccolls : mcCollisions) { + float centrality = mccolls.centFT0M(); - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 2, pt, centrality); + bool inVtx10 = std::abs(mccolls.posZ()) <= configEvents.cfgEvtZvtx; - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 3, pt, centrality); + const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolls.globalIndex(), cacheMC); + bool isTrueINELgt0 = pwglf::isINELgt0mc(particlesInCollision, pdg); - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 4, pt, centrality); + if (!(inVtx10 && isTrueINELgt0)) + continue; - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 5, pt, centrality); + auto computePtL = [&](float pt, float m_ref) { + float ptL2 = pt * pt + m_ref * m_ref - MassLambda1520 * MassLambda1520; + return (ptL2 > 0) ? std::sqrt(ptL2) : -1.f; + }; - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTruelambdapt"), 6, pt, centrality); + for (const auto& part : particlesInCollision) { - float ptL = computePtL(pt, MassLambda0); - if (ptL < 0) + if (cUseRapcutMC && std::abs(part.y()) > configTracks.cfgCutRapidity) continue; - if (useWeight) - weight = ptL / pt; - else - weight = 1.f; - - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 0, ptL, centrality, weight); - - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 1, ptL, centrality, weight); + if (cUseEtacutMC && std::abs(part.eta()) > cEtacutMC) + continue; - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 2, ptL, centrality, weight); + // ========================= + // ===== LAMBDA(1520) ====== + // ========================= + if (std::abs(part.pdgCode()) == Pdg::kLambda1520_Py) { - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 3, ptL, centrality, weight); + std::vector daughterPDGs; + if (part.has_daughters()) { + auto daughter01 = mcParticles.rawIteratorAt(part.daughtersIds()[0] - mcParticles.offset()); + auto daughter02 = mcParticles.rawIteratorAt(part.daughtersIds()[1] - mcParticles.offset()); + daughterPDGs = {daughter01.pdgCode(), daughter02.pdgCode()}; + } else { + daughterPDGs = {-1, -1}; + } - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 4, ptL, centrality, weight); + bool pass1 = std::abs(daughterPDGs[0]) == kKPlus || std::abs(daughterPDGs[1]) == kKPlus; // At least one decay to Kaon + bool pass2 = std::abs(daughterPDGs[0]) == kProton || std::abs(daughterPDGs[1]) == kProton; // At least one decay to Proton - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 5, ptL, centrality, weight); + // Checking if we have both decay products + if (!pass1 || !pass2) + continue; - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/Genlambdapt"), 6, ptL, centrality, weight); - } + if (part.pdgCode() > 0) + histos.fill(HIST("Result/SignalLoss/GenTruelambda1520pt_den"), part.pt(), centrality); + else + histos.fill(HIST("Result/SignalLoss/GenTrueantilambda1520pt_den"), part.pt(), centrality); + } - if (std::abs(part.pdgCode()) == PDG_t::kXiMinus) { + if (!part.isPhysicalPrimary()) + continue; - // true Xi - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 0, pt, centrality); + float pt = part.pt(); + float weight = 1.f; - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 1, pt, centrality); + // ========================= + // ===== PROTON ============ + // ========================= + if (std::abs(part.pdgCode()) == kProton) { - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 2, pt, centrality); + // --- DENOMINATOR ONLY + histos.fill(HIST("Result/SignalLoss/GenTrueprotonpt_den"), pt, centrality); - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 3, pt, centrality); + float ptL = computePtL(pt, massPr); + if (ptL < 0) + continue; - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 4, pt, centrality); + if (useWeight) + weight = ptL / pt; - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 5, pt, centrality); + histos.fill(HIST("Result/SignalLoss/Genprotonpt_den"), ptL, centrality, weight); + } - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/GenTruexipt"), 6, pt, centrality); + // ========================= + // ===== LAMBDA ============ + // ========================= + if (std::abs(part.pdgCode()) == kLambda0) { - float ptL = computePtL(pt, MassXiMinus); - if (ptL < 0) - continue; + histos.fill(HIST("Result/SignalLoss/GenTruelambdapt_den"), pt, centrality); - if (useWeight) - weight = ptL / pt; - else - weight = 1.f; + float ptL = computePtL(pt, MassLambda0); + if (ptL < 0) + continue; - histos.fill(HIST("Result/SignalLoss/Genxipt"), 0, ptL, centrality, weight); + if (useWeight) + weight = ptL / pt; - if (inVtx10) // vtx10 - histos.fill(HIST("Result/SignalLoss/Genxipt"), 1, ptL, centrality, weight); + histos.fill(HIST("Result/SignalLoss/Genlambdapt_den"), ptL, centrality, weight); + } - if (inVtx10 && isSel8) // vtx10, sel8 - histos.fill(HIST("Result/SignalLoss/Genxipt"), 2, ptL, centrality, weight); + // ========================= + // ===== XI ================= + // ========================= + if (std::abs(part.pdgCode()) == PDG_t::kXiMinus) { - if (inVtx10 && isTriggerTVX) // vtx10, TriggerTVX - histos.fill(HIST("Result/SignalLoss/Genxipt"), 3, ptL, centrality, weight); + histos.fill(HIST("Result/SignalLoss/GenTruexipt_den"), pt, centrality); - if (inVtx10 && isTrueINELgt0) // vtx10, INEL>0 - histos.fill(HIST("Result/SignalLoss/Genxipt"), 4, ptL, centrality, weight); + float ptL = computePtL(pt, MassXiMinus); + if (ptL < 0) + continue; - if (isInAfterAllCuts) // after all event selection - histos.fill(HIST("Result/SignalLoss/Genxipt"), 5, ptL, centrality, weight); + if (useWeight) + weight = ptL / pt; - if (isInAfterAllCuts && isTrueINELgt0) // after all event selection && INEL>0 - histos.fill(HIST("Result/SignalLoss/Genxipt"), 6, ptL, centrality, weight); + histos.fill(HIST("Result/SignalLoss/Genxipt_den"), ptL, centrality, weight); + } } } }