From c59a7412b837216381f3b469bb0bd9e19ce12a58 Mon Sep 17 00:00:00 2001 From: Giovanni Malfattore Date: Tue, 21 Oct 2025 11:25:04 +0200 Subject: [PATCH 1/5] NucleiTask - Fix O2linter errors --- PWGLF/Tasks/Nuspex/CMakeLists.txt | 2 +- PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx | 32 +++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/PWGLF/Tasks/Nuspex/CMakeLists.txt b/PWGLF/Tasks/Nuspex/CMakeLists.txt index 3242c18130c..2f1c6cce281 100644 --- a/PWGLF/Tasks/Nuspex/CMakeLists.txt +++ b/PWGLF/Tasks/Nuspex/CMakeLists.txt @@ -10,7 +10,7 @@ # or submit itself to any jurisdiction. o2physics_add_dpl_workflow(nuclei-batask - SOURCES LFNucleiBATask.cxx + SOURCES lfNucleiBATask.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx index c1e8d8d01cb..cb6e8607fc8 100644 --- a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx +++ b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// -/// \file LFNucleiBATask.cxx +/// \file lfNucleiBATask.cxx /// /// \brief Analysis task for the measurement of the coalescence parameter B2/B3 in pp collisions for (anti)deuteron/(anti)helium-3 /// @@ -54,7 +54,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct LFNucleiBATask { +struct lfNucleiBATask { Service ccdb; Zorro zorro; @@ -2086,7 +2086,7 @@ struct LFNucleiBATask { } // To be optimised if (!doprocessMCGen && !doprocessMCReco && !doprocessMCRecoLfPid && !doprocessMCRecoFiltered && !doprocessMCRecoFilteredLight) { - LOG(info) << "Histograms of LFNucleiBATask:"; + LOG(info) << "Histograms of lfNucleiBATask:"; histos.print(); return; } @@ -2209,7 +2209,7 @@ struct LFNucleiBATask { spectraGen.add("alpha/histGenPtantiAlSec", "generated particles", HistType::kTH1F, {ptAxis}); spectraGen.add("alpha/histSecTransportPtantiAl", "generated particles", HistType::kTH1F, {ptAxis}); } - LOG(info) << "Histograms of LFNucleiBATask:"; + LOG(info) << "Histograms of lfNucleiBATask:"; histos.print(); if (doprocessMCGen) spectraGen.print(); @@ -5975,7 +5975,7 @@ struct LFNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(LFNucleiBATask, processData, "process data", true); + PROCESS_SWITCH(lfNucleiBATask, processData, "process data", true); // Process function that runs on the original AO2D void processDataLfPid(EventCandidates::iterator const& event, @@ -5984,7 +5984,7 @@ struct LFNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(LFNucleiBATask, processDataLfPid, "process data with LF PID", false); + PROCESS_SWITCH(lfNucleiBATask, processDataLfPid, "process data with LF PID", false); // Process function that runs on the filtered data void processDataFiltered(o2::aod::LfNuclEvents::iterator const& event, @@ -5995,7 +5995,7 @@ struct LFNucleiBATask { // Takes as input full AO2Ds fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(LFNucleiBATask, processDataFiltered, "process data on the filtered data", false); + PROCESS_SWITCH(lfNucleiBATask, processDataFiltered, "process data on the filtered data", false); void processDataLight(o2::aod::LfNuclEvents::iterator const& event, o2::aod::LfCandNucleusDummy const& tracks, @@ -6005,7 +6005,7 @@ struct LFNucleiBATask { // Takes as input derived trees fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(LFNucleiBATask, processDataLight, "process data on the derived trees", false); + PROCESS_SWITCH(lfNucleiBATask, processDataLight, "process data on the derived trees", false); ///////////// // MC Reco // @@ -6024,7 +6024,7 @@ struct LFNucleiBATask { } fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(LFNucleiBATask, processMCReco, "process mc reco", false); + PROCESS_SWITCH(lfNucleiBATask, processMCReco, "process mc reco", false); // Process function that runs on the original AO2D (for the MC) with the LfPIDcalibration void processMCRecoLfPid(EventCandidatesMC::iterator const& event, @@ -6039,7 +6039,7 @@ struct LFNucleiBATask { } fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(LFNucleiBATask, processMCRecoLfPid, "process mc reco with LfPid", false); + PROCESS_SWITCH(lfNucleiBATask, processMCRecoLfPid, "process mc reco with LfPid", false); Preslice perMCCol = aod::mcparticle::mcCollisionId; SliceCache cache; @@ -6153,7 +6153,7 @@ struct LFNucleiBATask { } } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(LFNucleiBATask, processMCRecoLfPidEv, "process mc reco with LfPid w/ Event", false); + PROCESS_SWITCH(lfNucleiBATask, processMCRecoLfPidEv, "process mc reco with LfPid w/ Event", false); // Process function that runs on the filtered AO2D (for the MC) void processMCRecoFiltered(o2::aod::LfNuclEvents::iterator const& event, @@ -6162,7 +6162,7 @@ struct LFNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA - PROCESS_SWITCH(LFNucleiBATask, processMCRecoFiltered, "process mc reco on the filtered data", false); + PROCESS_SWITCH(lfNucleiBATask, processMCRecoFiltered, "process mc reco on the filtered data", false); void processMCRecoFilteredLight(o2::aod::LfNuclEvents::iterator const& event, soa::Join const& tracks, @@ -6170,7 +6170,7 @@ struct LFNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA - PROCESS_SWITCH(LFNucleiBATask, processMCRecoFilteredLight, "process mc reco on the derived trees", false); + PROCESS_SWITCH(lfNucleiBATask, processMCRecoFilteredLight, "process mc reco on the derived trees", false); //////////// // MC Gen // @@ -6429,7 +6429,7 @@ struct LFNucleiBATask { } } } // Close processMCGen - PROCESS_SWITCH(LFNucleiBATask, processMCGen, "process MC Generated", true); + PROCESS_SWITCH(lfNucleiBATask, processMCGen, "process MC Generated", true); void processEvSgLossMC(soa::Join::iterator const& mcCollision, aod::McParticles const& mcParticles, @@ -6515,10 +6515,10 @@ struct LFNucleiBATask { } } } - PROCESS_SWITCH(LFNucleiBATask, processEvSgLossMC, "process MC SignLoss", false); + PROCESS_SWITCH(lfNucleiBATask, processEvSgLossMC, "process MC SignLoss", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } From 5b6f8e9aa4c1cf4a1f327018592bdaa172051c66 Mon Sep 17 00:00:00 2001 From: Giovanni Malfattore Date: Tue, 21 Oct 2025 11:32:57 +0200 Subject: [PATCH 2/5] NucleiTask - Fix error --- PWGLF/Tasks/Nuspex/{LFNucleiBATask.cxx => lfNucleiBATask.cxx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename PWGLF/Tasks/Nuspex/{LFNucleiBATask.cxx => lfNucleiBATask.cxx} (100%) diff --git a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/lfNucleiBATask.cxx similarity index 100% rename from PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx rename to PWGLF/Tasks/Nuspex/lfNucleiBATask.cxx From dc1794ef9d9263061a691bc7b6081fcb325379a3 Mon Sep 17 00:00:00 2001 From: Giovanni Malfattore Date: Tue, 21 Oct 2025 11:39:26 +0200 Subject: [PATCH 3/5] NucleiTask - Fix bugs in mult dependent histos --- PWGLF/Tasks/Nuspex/CMakeLists.txt | 2 +- ...{lfNucleiBATask.cxx => LFNucleiBATask.cxx} | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) rename PWGLF/Tasks/Nuspex/{lfNucleiBATask.cxx => LFNucleiBATask.cxx} (99%) diff --git a/PWGLF/Tasks/Nuspex/CMakeLists.txt b/PWGLF/Tasks/Nuspex/CMakeLists.txt index 2f1c6cce281..3242c18130c 100644 --- a/PWGLF/Tasks/Nuspex/CMakeLists.txt +++ b/PWGLF/Tasks/Nuspex/CMakeLists.txt @@ -10,7 +10,7 @@ # or submit itself to any jurisdiction. o2physics_add_dpl_workflow(nuclei-batask - SOURCES lfNucleiBATask.cxx + SOURCES LFNucleiBATask.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Nuspex/lfNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx similarity index 99% rename from PWGLF/Tasks/Nuspex/lfNucleiBATask.cxx rename to PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx index cb6e8607fc8..c1e8d8d01cb 100644 --- a/PWGLF/Tasks/Nuspex/lfNucleiBATask.cxx +++ b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// -/// \file lfNucleiBATask.cxx +/// \file LFNucleiBATask.cxx /// /// \brief Analysis task for the measurement of the coalescence parameter B2/B3 in pp collisions for (anti)deuteron/(anti)helium-3 /// @@ -54,7 +54,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct lfNucleiBATask { +struct LFNucleiBATask { Service ccdb; Zorro zorro; @@ -2086,7 +2086,7 @@ struct lfNucleiBATask { } // To be optimised if (!doprocessMCGen && !doprocessMCReco && !doprocessMCRecoLfPid && !doprocessMCRecoFiltered && !doprocessMCRecoFilteredLight) { - LOG(info) << "Histograms of lfNucleiBATask:"; + LOG(info) << "Histograms of LFNucleiBATask:"; histos.print(); return; } @@ -2209,7 +2209,7 @@ struct lfNucleiBATask { spectraGen.add("alpha/histGenPtantiAlSec", "generated particles", HistType::kTH1F, {ptAxis}); spectraGen.add("alpha/histSecTransportPtantiAl", "generated particles", HistType::kTH1F, {ptAxis}); } - LOG(info) << "Histograms of lfNucleiBATask:"; + LOG(info) << "Histograms of LFNucleiBATask:"; histos.print(); if (doprocessMCGen) spectraGen.print(); @@ -5975,7 +5975,7 @@ struct lfNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(lfNucleiBATask, processData, "process data", true); + PROCESS_SWITCH(LFNucleiBATask, processData, "process data", true); // Process function that runs on the original AO2D void processDataLfPid(EventCandidates::iterator const& event, @@ -5984,7 +5984,7 @@ struct lfNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(lfNucleiBATask, processDataLfPid, "process data with LF PID", false); + PROCESS_SWITCH(LFNucleiBATask, processDataLfPid, "process data with LF PID", false); // Process function that runs on the filtered data void processDataFiltered(o2::aod::LfNuclEvents::iterator const& event, @@ -5995,7 +5995,7 @@ struct lfNucleiBATask { // Takes as input full AO2Ds fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(lfNucleiBATask, processDataFiltered, "process data on the filtered data", false); + PROCESS_SWITCH(LFNucleiBATask, processDataFiltered, "process data on the filtered data", false); void processDataLight(o2::aod::LfNuclEvents::iterator const& event, o2::aod::LfCandNucleusDummy const& tracks, @@ -6005,7 +6005,7 @@ struct lfNucleiBATask { // Takes as input derived trees fillHistograms(event, tracks, true /*dummy*/); } - PROCESS_SWITCH(lfNucleiBATask, processDataLight, "process data on the derived trees", false); + PROCESS_SWITCH(LFNucleiBATask, processDataLight, "process data on the derived trees", false); ///////////// // MC Reco // @@ -6024,7 +6024,7 @@ struct lfNucleiBATask { } fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(lfNucleiBATask, processMCReco, "process mc reco", false); + PROCESS_SWITCH(LFNucleiBATask, processMCReco, "process mc reco", false); // Process function that runs on the original AO2D (for the MC) with the LfPIDcalibration void processMCRecoLfPid(EventCandidatesMC::iterator const& event, @@ -6039,7 +6039,7 @@ struct lfNucleiBATask { } fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(lfNucleiBATask, processMCRecoLfPid, "process mc reco with LfPid", false); + PROCESS_SWITCH(LFNucleiBATask, processMCRecoLfPid, "process mc reco with LfPid", false); Preslice perMCCol = aod::mcparticle::mcCollisionId; SliceCache cache; @@ -6153,7 +6153,7 @@ struct lfNucleiBATask { } } // CLOSING PROCESS MC RECO - PROCESS_SWITCH(lfNucleiBATask, processMCRecoLfPidEv, "process mc reco with LfPid w/ Event", false); + PROCESS_SWITCH(LFNucleiBATask, processMCRecoLfPidEv, "process mc reco with LfPid w/ Event", false); // Process function that runs on the filtered AO2D (for the MC) void processMCRecoFiltered(o2::aod::LfNuclEvents::iterator const& event, @@ -6162,7 +6162,7 @@ struct lfNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA - PROCESS_SWITCH(lfNucleiBATask, processMCRecoFiltered, "process mc reco on the filtered data", false); + PROCESS_SWITCH(LFNucleiBATask, processMCRecoFiltered, "process mc reco on the filtered data", false); void processMCRecoFilteredLight(o2::aod::LfNuclEvents::iterator const& event, soa::Join const& tracks, @@ -6170,7 +6170,7 @@ struct lfNucleiBATask { { fillHistograms(event, tracks, true /*dummy*/); } // CLOSING PROCESS MC RECO ON FILTERED DATA - PROCESS_SWITCH(lfNucleiBATask, processMCRecoFilteredLight, "process mc reco on the derived trees", false); + PROCESS_SWITCH(LFNucleiBATask, processMCRecoFilteredLight, "process mc reco on the derived trees", false); //////////// // MC Gen // @@ -6429,7 +6429,7 @@ struct lfNucleiBATask { } } } // Close processMCGen - PROCESS_SWITCH(lfNucleiBATask, processMCGen, "process MC Generated", true); + PROCESS_SWITCH(LFNucleiBATask, processMCGen, "process MC Generated", true); void processEvSgLossMC(soa::Join::iterator const& mcCollision, aod::McParticles const& mcParticles, @@ -6515,10 +6515,10 @@ struct lfNucleiBATask { } } } - PROCESS_SWITCH(lfNucleiBATask, processEvSgLossMC, "process MC SignLoss", false); + PROCESS_SWITCH(LFNucleiBATask, processEvSgLossMC, "process MC SignLoss", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } From 0eb4c4418e97d57ffa10d5d0c0e51ce309914fe6 Mon Sep 17 00:00:00 2001 From: Giovanni Malfattore Date: Fri, 7 Nov 2025 11:31:55 +0100 Subject: [PATCH 4/5] NucleiTask - Add process function for losses --- PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx | 302 ++++++++++++++++++++++++-- 1 file changed, 280 insertions(+), 22 deletions(-) diff --git a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx index c1e8d8d01cb..dcbd9a53b55 100644 --- a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx +++ b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx @@ -20,6 +20,7 @@ #include "PWGLF/DataModel/LFNucleiTables.h" #include "PWGLF/DataModel/LFParticleIdentification.h" #include "PWGLF/DataModel/mcCentrality.h" +#include "PWGLF/Utils/inelGt.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/Core/trackUtilities.h" @@ -38,6 +39,7 @@ #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/PID.h" #include "ReconstructionDataFormats/Track.h" @@ -56,6 +58,7 @@ using namespace o2::framework::expressions; struct LFNucleiBATask { Service ccdb; + Service pdgDB; Zorro zorro; OutputObj zorroSummary{"zorroSummary"}; @@ -70,6 +73,7 @@ struct LFNucleiBATask { HistogramRegistry debugHistos{"debugHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; HistogramRegistry evtimeHistos{"evtimeHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; HistogramRegistry evLossHistos{"evLossHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + HistogramRegistry histoGen{"histoGen", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; // Enable particle for analysis Configurable enablePr{"enablePr", true, "Flag to enable proton analysis."}; @@ -392,6 +396,57 @@ struct LFNucleiBATask { spectraGen.add("LfEv/helium/prim/pT_MCsel8_antiHe", "Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c}); counts", HistType::kTH1F, {{ptHeAxis}}); } + if (doprocessMCGenLosses) { + histoGen.add("events/hMCGen", "hMCGen", {HistType::kTH1D, {{3, 0.f, 3.f}}}); + histoGen.get(HIST("events/hMCGen"))->GetXaxis()->SetBinLabel(1, "All"); + histoGen.get(HIST("events/hMCGen"))->GetXaxis()->SetBinLabel(2, "Vtz"); + histoGen.get(HIST("events/hMCGen"))->GetXaxis()->SetBinLabel(3, "INELgt0"); + + histoGen.add("events/hMCGenReco", "hMCGenReco", {HistType::kTH1D, {{2, 0.f, 2.f}}}); + histoGen.get(HIST("events/hMCGenReco"))->GetXaxis()->SetBinLabel(1, "INEL"); + histoGen.get(HIST("events/hMCGenReco"))->GetXaxis()->SetBinLabel(2, "INELgt0"); + + histoGen.add("events/hMCReco", "hMCReco", {HistType::kTH1D, {{3, 0.f, 3.f}}}); + histoGen.get(HIST("events/hMCReco"))->GetXaxis()->SetBinLabel(1, "All"); + histoGen.get(HIST("events/hMCReco"))->GetXaxis()->SetBinLabel(2, "Ev sel passed"); + histoGen.get(HIST("events/hMCReco"))->GetXaxis()->SetBinLabel(3, "INELgt0"); + + histoGen.add("helium/MCGen/ptGen_INEL_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCGen/ptGen_INEL_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + histoGen.add("helium/MCGen/ptGen_INELgt0_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCGen/ptGen_INELgt0_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + histoGen.add("helium/MCGenReco/ptGen_INEL_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCGenReco/ptGen_INEL_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + histoGen.add("helium/MCGenReco/ptGen_INELgt0_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCGenReco/ptGen_INELgt0_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + histoGen.add("helium/MCReco/ptGen_INEL_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCReco/ptGen_INEL_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + histoGen.add("helium/MCReco/ptGen_INELgt0_Prim_He", "generated particles", HistType::kTH1F, {ptHeAxis}); + histoGen.add("helium/MCReco/ptGen_INELgt0_Prim_antiHe", "generated particles", HistType::kTH1F, {ptHeAxis}); + + if (enableCentrality) { + histoGen.add("helium/MCGen/ptGenVsMult_INEL_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGen/ptGenVsMult_INEL_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGen/ptGenVsMult_INELgt0_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGen/ptGenVsMult_INELgt0_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + + histoGen.add("helium/MCGenReco/ptGenVsMult_INEL_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGenReco/ptGenVsMult_INEL_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGenReco/ptGenVsMult_INELgt0_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCGenReco/ptGenVsMult_INELgt0_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + + histoGen.add("helium/MCReco/ptGenVsMult_INEL_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCReco/ptGenVsMult_INEL_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCReco/ptGenVsMult_INELgt0_Prim_He", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + histoGen.add("helium/MCReco/ptGenVsMult_INELgt0_Prim_antiHe", "generated particles", HistType::kTH2F, {{ptHeAxis}, {binsPercentile}}); + } + } + if (enableDebug) { debugHistos.add("qa/h1VtxZ_nocut", "V_{z};V_{z} (in cm); counts", HistType::kTH1F, {{1500, -15, 15}}); debugHistos.add("qa/h1VtxZ_TVXtrigger", "V_{z};V_{z} (in cm); counts", HistType::kTH1F, {{1500, -15, 15}}); @@ -714,11 +769,11 @@ struct LFNucleiBATask { } if (doprocessMCReco || doprocessMCRecoLfPid || doprocessMCRecoFiltered || doprocessMCRecoFilteredLight) { - histos.add("hItsDeHeChecker", "d and {}^{3}He counters", HistType::kTH1F, {{4, -0.5, 3.5}}); - histos.get(HIST("hItsDeHeChecker"))->GetXaxis()->SetBinLabel(1, "totDe"); - histos.get(HIST("hItsDeHeChecker"))->GetXaxis()->SetBinLabel(2, "totHe"); - histos.get(HIST("hItsDeHeChecker"))->GetXaxis()->SetBinLabel(3, "keptDe"); - histos.get(HIST("hItsDeHeChecker"))->GetXaxis()->SetBinLabel(4, "keptHe"); + histos.add("tracks/hItsDeHeChecker", "d and {}^{3}He counters", HistType::kTH1F, {{4, -0.5, 3.5}}); + histos.get(HIST("tracks/hItsDeHeChecker"))->GetXaxis()->SetBinLabel(1, "totDe"); + histos.get(HIST("tracks/hItsDeHeChecker"))->GetXaxis()->SetBinLabel(2, "totHe"); + histos.get(HIST("tracks/hItsDeHeChecker"))->GetXaxis()->SetBinLabel(3, "keptDe"); + histos.get(HIST("tracks/hItsDeHeChecker"))->GetXaxis()->SetBinLabel(4, "keptHe"); // inclusive production if (enableTrackingEff) { @@ -2609,9 +2664,9 @@ struct LFNucleiBATask { if constexpr (IsMC && !IsFilteredData) { int pdgCheck = track.mcParticle().pdgCode(); if (std::abs(pdgCheck) == PDGDeuteron) - histos.fill(HIST("hItsDeHeChecker"), 0); + histos.fill(HIST("tracks/hItsDeHeChecker"), 0); if (std::abs(pdgCheck) == PDGHelium) - histos.fill(HIST("hItsDeHeChecker"), 1); + histos.fill(HIST("tracks/hItsDeHeChecker"), 1); } // nSigmaITSHe cut @@ -2626,9 +2681,9 @@ struct LFNucleiBATask { if constexpr (IsMC && !IsFilteredData) { int pdgCheck = track.mcParticle().pdgCode(); if (std::abs(pdgCheck) == PDGDeuteron) - histos.fill(HIST("hItsDeHeChecker"), 2); + histos.fill(HIST("tracks/hItsDeHeChecker"), 2); if (std::abs(pdgCheck) == PDGHelium) - histos.fill(HIST("hItsDeHeChecker"), 3); + histos.fill(HIST("tracks/hItsDeHeChecker"), 3); } isHe = isHelium && track.sign() > 0; @@ -6011,6 +6066,9 @@ struct LFNucleiBATask { // MC Reco // ///////////// + Preslice perMCCol = aod::mcparticle::mcCollisionId; + SliceCache cache; + // Process function that runs on the original AO2D (for the MC) void processMCReco(EventCandidatesMC::iterator const& event, soa::Join const&, @@ -6018,10 +6076,31 @@ struct LFNucleiBATask { aod::McParticles const& mcParticles, o2::aod::BCsWithTimestamps const&) { - if (event.mcCollisionId() >= 0) { - effEvtSet.insert(event.mcCollisionId()); - effEvtSetReady = true; + bool doRecoSep = true; + + const bool hasTVX = event.selection_bit(aod::evsel::kIsTriggerTVX); + const bool hasNoTFB = event.selection_bit(aod::evsel::kNoTimeFrameBorder); + const bool hasNoItsRofFB = event.selection_bit(aod::evsel::kNoITSROFrameBorder); + + if (evselOptions.useSel8) { + doRecoSep = (hasTVX && hasNoTFB); + } else { + if (evselOptions.useTVXtrigger && !hasTVX) + doRecoSep = false; + if (evselOptions.removeTFBorder && !hasNoTFB) + doRecoSep = false; + if (evselOptions.removeITSROFBorder && !hasNoItsRofFB) + doRecoSep = false; } + + if (doRecoSep && event.has_mcCollision()) { + const int mcIdx = event.mcCollisionId(); + if (mcIdx >= 0) { + effEvtSet.insert(mcIdx); + effEvtSetReady = true; + } + } + fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO PROCESS_SWITCH(LFNucleiBATask, processMCReco, "process mc reco", false); @@ -6033,16 +6112,35 @@ struct LFNucleiBATask { aod::McParticles const& mcParticles, o2::aod::BCsWithTimestamps const&) { - if (event.mcCollisionId() >= 0) { - effEvtSet.insert(event.mcCollisionId()); - effEvtSetReady = true; + bool doRecoSep = true; + + const bool hasTVX = event.selection_bit(aod::evsel::kIsTriggerTVX); + const bool hasNoTFB = event.selection_bit(aod::evsel::kNoTimeFrameBorder); + const bool hasNoItsRofFB = event.selection_bit(aod::evsel::kNoITSROFrameBorder); + + if (evselOptions.useSel8) { + doRecoSep = (hasTVX && hasNoTFB); + } else { + if (evselOptions.useTVXtrigger && !hasTVX) + doRecoSep = false; + if (evselOptions.removeTFBorder && !hasNoTFB) + doRecoSep = false; + if (evselOptions.removeITSROFBorder && !hasNoItsRofFB) + doRecoSep = false; } + + if (doRecoSep && event.has_mcCollision()) { + const int mcIdx = event.mcCollisionId(); + if (mcIdx >= 0) { + effEvtSet.insert(mcIdx); + effEvtSetReady = true; + } + } + fillHistograms(event, tracks, mcParticles); } // CLOSING PROCESS MC RECO PROCESS_SWITCH(LFNucleiBATask, processMCRecoLfPid, "process mc reco with LfPid", false); - Preslice perMCCol = aod::mcparticle::mcCollisionId; - SliceCache cache; // Process function that runs on the original AO2D (for the MC) with the LfPIDcalibration void processMCRecoLfPidEv(EventCandidatesMC const& collisions, soa::Join const&, @@ -6181,10 +6279,11 @@ struct LFNucleiBATask { aod::McParticles const& mcParticles) { // Only events that are reconstructed + const int mcIdx = mcCollision.globalIndex(); if (enableEffEvtSet) { if (!effEvtSetReady) return; - if (!effEvtSet.count(mcCollision.globalIndex())) + if (!effEvtSet.count(mcIdx)) return; } @@ -6196,17 +6295,22 @@ struct LFNucleiBATask { else spectraGen.fill(HIST("histGenVetxZ"), mcCollision.posZ()); - for (auto const& mcParticleGen : mcParticles) { + // const auto& particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcIdx, cache); + // const auto particlesInCollision = mcParticles.sliceBy(perMCCol, mcIdx); + + for (const auto& mcParticleGen : mcParticles) { + if (mcParticleGen.mcCollisionId() != mcIdx) + continue; + if (mcParticleGen.y() > kinemOptions.cfgRapidityCutHigh || mcParticleGen.y() < kinemOptions.cfgRapidityCutLow) continue; + const int pdgCode = mcParticleGen.pdgCode(); + const float ptMC = mcParticleGen.pt(); bool isPhysPrim = mcParticleGen.isPhysicalPrimary(); bool isProdByGen = mcParticleGen.producedByGenerator(); bool isWeakDecay = (mcParticleGen.getProcess() == TMCProcess::kPDecay); - const int pdgCode = mcParticleGen.pdgCode(); - const float ptMC = mcParticleGen.pt(); - if (pdgCode == PDGPion) { spectraGen.fill(HIST("pion/histGenPtPion"), ptMC); if (isPhysPrim) @@ -6516,6 +6620,160 @@ struct LFNucleiBATask { } } PROCESS_SWITCH(LFNucleiBATask, processEvSgLossMC, "process MC SignLoss", false); + + // EVENT LOSS, SIGNAL LOSS and EFFICIENCY CHECKER process function + void processMCGenLosses( + soa::Join::iterator const& mcCollision, + const soa::SmallGroups>& collisions, + soa::Join const& tracks, + o2::aod::McParticles const& mcParticles) + { + bool isINELgt0true = pwglf::isINELgtNmc(mcParticles, 0, pdgDB); + + // EVENT LOSS DENOMINATOR + // No cuts + histoGen.fill(HIST("events/hMCGen"), 0.5); + // Vtz cut + if (mcCollision.posZ() < cfgVzCutLow || mcCollision.posZ() > cfgVzCutHigh) + return; + histoGen.fill(HIST("events/hMCGen"), 1.5); + // INEL > 0 + if (isINELgt0true) + histoGen.fill(HIST("events/hMCGen"), 2.5); + + // SIGNAL LOSS DENOMINATOR + for (const auto& mcParticle : mcParticles) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) + continue; + + int pdg = mcParticle.pdgCode(); + float pt = mcParticle.pt(); + bool isPhysPrim = mcParticle.isPhysicalPrimary(); + + if (enableHe && isPhysPrim && (std::abs(pdg) == PDGHelium)) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCGen/ptGen_INEL_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGen/ptGenVsMult_INEL_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCGen/ptGen_INEL_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGen/ptGenVsMult_INEL_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + if (isINELgt0true) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCGen/ptGen_INELgt0_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGen/ptGenVsMult_INELgt0_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCGen/ptGen_INELgt0_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGen/ptGenVsMult_INELgt0_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + } + } + } + + int recoIdxINEL = 0; + int recoIdxINELgt0 = 0; + for (const auto& collision : collisions) { + bool hasTVX = collision.selection_bit(aod::evsel::kIsTriggerTVX); + bool hasNoTFB = collision.selection_bit(aod::evsel::kNoTimeFrameBorder); + bool hasNoItsRofFB = collision.selection_bit(aod::evsel::kNoITSROFrameBorder); + + // Check event selection + histoGen.fill(HIST("events/hMCReco"), 0.5); + if (evselOptions.useTVXtrigger && !hasTVX) + continue; + if (evselOptions.removeTFBorder && !hasNoTFB) + continue; + if (evselOptions.removeITSROFBorder && !hasNoItsRofFB) + continue; + histoGen.fill(HIST("events/hMCReco"), 1.5); + + recoIdxINEL++; + + if (collision.isInelGt0() && isINELgt0true) { + histoGen.fill(HIST("events/hMCReco"), 2.5); + recoIdxINELgt0++; + } + + for (const auto& mcParticle : mcParticles) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) + continue; + + int pdg = mcParticle.pdgCode(); + float pt = mcParticle.pt(); + bool isPhysPrim = mcParticle.isPhysicalPrimary(); + + if (enableHe && isPhysPrim && (std::abs(pdg) == PDGHelium)) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCReco/ptGen_INEL_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCReco/ptGenVsMult_INEL_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCReco/ptGen_INEL_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCReco/ptGenVsMult_INEL_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + if (recoIdxINELgt0 > 0) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCReco/ptGen_INELgt0_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCReco/ptGenVsMult_INELgt0_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCReco/ptGen_INELgt0_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCReco/ptGenVsMult_INELgt0_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + } + } + } + } + + if (recoIdxINEL < 1) { + return; + } + + // EVENT LOSS NUMERATOR + histoGen.fill(HIST("events/hMCGenReco"), 0.5); + if (recoIdxINELgt0 > 0) + histoGen.fill(HIST("events/hMCGenReco"), 1.5); + + // SIGNAL LOSS NUMERATOR + for (const auto& mcParticle : mcParticles) { + if (mcParticle.y() > kinemOptions.cfgRapidityCutHigh || mcParticle.y() < kinemOptions.cfgRapidityCutLow) + continue; + + int pdg = mcParticle.pdgCode(); + float pt = mcParticle.pt(); + bool isPhysPrim = mcParticle.isPhysicalPrimary(); + + if (enableHe && isPhysPrim && (std::abs(pdg) == PDGHelium)) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCGenReco/ptGen_INEL_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGenReco/ptGenVsMult_INEL_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCGenReco/ptGen_INEL_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGenReco/ptGenVsMult_INEL_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + if (recoIdxINELgt0 > 0) { + if (pdg > 0) { + histoGen.fill(HIST("helium/MCGenReco/ptGen_INELgt0_Prim_He"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGenReco/ptGenVsMult_INELgt0_Prim_He"), pt, mcCollision.centFT0M()); + } else { + histoGen.fill(HIST("helium/MCGenReco/ptGen_INELgt0_Prim_antiHe"), pt); + if (enableCentrality) + histoGen.fill(HIST("helium/MCGenReco/ptGenVsMult_INELgt0_Prim_antiHe"), pt, mcCollision.centFT0M()); + } + } + } + } + } + PROCESS_SWITCH(LFNucleiBATask, processMCGenLosses, "process MCGen losses", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 3c37c73984e6d14e55a6e81219a6fef48e0485ed Mon Sep 17 00:00:00 2001 From: Giovanni Malfattore Date: Fri, 7 Nov 2025 23:09:54 +0100 Subject: [PATCH 5/5] NucleiTask - Remove unused variable --- PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx index dcbd9a53b55..e3fd30e0fda 100644 --- a/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx +++ b/PWGLF/Tasks/Nuspex/LFNucleiBATask.cxx @@ -6625,7 +6625,6 @@ struct LFNucleiBATask { void processMCGenLosses( soa::Join::iterator const& mcCollision, const soa::SmallGroups>& collisions, - soa::Join const& tracks, o2::aod::McParticles const& mcParticles) { bool isINELgt0true = pwglf::isINELgtNmc(mcParticles, 0, pdgDB);