From 1d95f5695c1447bfbcf825a07ada49bb17e0d0c5 Mon Sep 17 00:00:00 2001 From: jmunozme Date: Thu, 2 Oct 2025 19:35:06 -0600 Subject: [PATCH 1/2] Add INEL flag --- PWGMM/UE/Tasks/uecharged.cxx | 124 ++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 32 deletions(-) diff --git a/PWGMM/UE/Tasks/uecharged.cxx b/PWGMM/UE/Tasks/uecharged.cxx index 1e17615ca8a..3974c31a5f8 100644 --- a/PWGMM/UE/Tasks/uecharged.cxx +++ b/PWGMM/UE/Tasks/uecharged.cxx @@ -13,7 +13,8 @@ /// \file uecharged.cxx /// \brief Underlying event analysis task /// \since November 2021 -/// \last update: September 2025 +/// \last update: October 2025 + #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" @@ -29,6 +30,7 @@ #include "Framework/StaticFor.h" #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" +#include "PWGLF/Utils/inelGt.h" #include "TDatabasePDG.h" #include @@ -45,8 +47,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using BCsRun3 = soa::Join; +using BCsRun3 = soa::Join; struct ueCharged { @@ -80,8 +81,7 @@ struct ueCharged { selectedTracks.SetMaxChi2PerClusterTPC(4.f); selectedTracks.SetRequireHitsInITSLayers(1, {0, 1}); // one hit in any SPD layer selectedTracks.SetMaxChi2PerClusterITS(36.f); - // selectedTracks.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / - // pow(pt, 1.1f); }); + // selectedTracks.SetMaxDcaXYPtDep([](float pt) { return 0.0105f + 0.0350f / pow(pt, 1.1f); }); selectedTracks.SetMaxDcaZ(2.f); return selectedTracks; } @@ -91,6 +91,7 @@ struct ueCharged { Service pdg; float deltaPhi(float phia, float phib, float rangeMin, float rangeMax); + // Configurable for event selection Configurable isRun3{"isRun3", true, "is Run3 dataset"}; Configurable piluprejection{"piluprejection", true, "Pileup rejection"}; @@ -98,7 +99,7 @@ struct ueCharged { Configurable sel8{"sel8", true, "Apply the sel8 event selection"}; Configurable removeITSROFBorder{"removeITSROFBorder", false, "Remove ITS Read-Out Frame border and only apply kIsTriggerTVX & kNoTimeFrameBorder (recommended for MC)"}; Configurable analyzeEvandTracksel{"analyzeEvandTracksel", true, "Analyze the event and track selection"}; - + Configurable cfgINELCut{"cfgINELCut", 0, "INEL event selection: 0 no sel, 1 INEL>0, 2 INEL>1"}; // acceptance cuts Configurable cfgTrkEtaCut{"cfgTrkEtaCut", 0.8f, "Eta range for tracks"}; Configurable cfgTrkLowPtCut{"cfgTrkLowPtCut", 0.15f, "Minimum constituent pT"}; @@ -130,6 +131,9 @@ struct ueCharged { static constexpr std::string_view hPtVsPtLeadingTrue[3] = { "hPtVsPtLeadingTrue_NS", "hPtVsPtLeadingTrue_AS", "hPtVsPtLeadingTrue_TS"}; + static constexpr std::string_view hPtVsPtLeadingTruePS[3] = { + "hPtVsPtLeadingTruePS_NS", "hPtVsPtLeadingTruePS_AS", + "hPtVsPtLeadingTruePS_TS"}; // all wo detector effects static constexpr std::string_view pNumDenTrueAll[3] = { "pNumDenTrueAll_NS", "pNumDenTrueAll_AS", "pNumDenTrueAll_TS"}; @@ -140,7 +144,6 @@ struct ueCharged { "pNumDenTrue_NS", "pNumDenTrue_AS", "pNumDenTrue_TS"}; static constexpr std::string_view pSumPtTrue[3] = { "pSumPtTrue_NS", "pSumPtTrue_AS", "pSumPtTrue_TS"}; - // this must have all event selection effects, but it has not been implemented // 50% static constexpr std::string_view pNumDenTruePS[3] = { @@ -165,16 +168,11 @@ struct ueCharged { template void analyzeEventAndTrackSelection(const C& collision, const T& tracks); - Filter trackFilter = (nabs(aod::track::eta) < cfgTrkEtaCut) && - (aod::track::pt > cfgTrkLowPtCut); + Filter trackFilter = (nabs(aod::track::eta) < cfgTrkEtaCut) && (aod::track::pt > cfgTrkLowPtCut); using CollisionTableMCTrue = aod::McCollisions; - using CollisionTableMC = - soa::SmallGroups>; - using TrackTableMC = - soa::Filtered>; + using CollisionTableMC = soa::SmallGroups>; + using TrackTableMC = soa::Filtered>; using ParticleTableMC = aod::McParticles; Preslice perCollision = aod::track::collisionId; void processMC(CollisionTableMCTrue::iterator const& mcCollision, @@ -183,23 +181,16 @@ struct ueCharged { BCsRun3 const&); PROCESS_SWITCH(ueCharged, processMC, "process MC", false); - using CollisionTableMCData = - soa::Join; - using TrackTableMCData = - soa::Filtered>; + using CollisionTableMCData = soa::Join; + using TrackTableMCData = soa::Filtered>; void processDataMC(CollisionTableMCData::iterator const& collision, TrackTableMCData const& tracks, ParticleTableMC const& particles, aod::McCollisions const& mcCollisions); PROCESS_SWITCH(ueCharged, processDataMC, "process data MC", false); - using CollisionTableData = - soa::Join; - using TrackTableData = - soa::Filtered>; + using CollisionTableData = soa::Join; + using TrackTableData = soa::Filtered>; void processData(CollisionTableData::iterator const& collision, TrackTableData const& tracks, aod::FT0s const&, BCsRun3 const&); @@ -207,12 +198,14 @@ struct ueCharged { // add new method }; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{}; workflow.push_back(adaptAnalysisTask(cfgc)); return workflow; } + // implementation float ueCharged::deltaPhi(float phia, float phib, float rangeMin = -o2::constants::math::PI / 2.0, @@ -289,7 +282,6 @@ void ueCharged::init(InitContext const&) {{ptAxis}, {121, -3.025, 3.025, "#it{DCA}_{xy} (cm)"}}); ue.add("hPtDCAMat", "Material; DCA_xy; Nch", HistType::kTH2D, {{ptAxis}, {121, -3.025, 3.025, "#it{DCA}_{xy} (cm)"}}); - ue.add("hmultTrue", "mult true", HistType::kTH1F, {{200, -0.5, 199.5, " "}}); ue.add("hmultTrueGen", "mult true all Gen", HistType::kTH1F, @@ -299,8 +291,8 @@ void ueCharged::init(InitContext const&) HistType::kTH1D, {ptAxist}); for (int i = 0; i < 3; ++i) { - ue.add(hPtVsPtLeadingTrue[i].data(), " ", HistType::kTH2D, - {{ptAxist}, {ptAxis}}); + ue.add(hPtVsPtLeadingTrue[i].data(), " ", HistType::kTH2D, {{ptAxist}, {ptAxis}}); + ue.add(hPtVsPtLeadingTruePS[i].data(), " ", HistType::kTH2D, {{ptAxist}, {ptAxis}}); ue.add(pNumDenTrueAll[i].data(), "", HistType::kTProfile, {ptAxist}); ue.add(pSumPtTrueAll[i].data(), "", HistType::kTProfile, {ptAxist}); ue.add(pNumDenTrue[i].data(), "", HistType::kTProfile, {ptAxist}); @@ -324,7 +316,6 @@ void ueCharged::init(InitContext const&) ue.add("phiEta", ";#eta;#varphi", HistType::kTH2F, {{50, -2.5, 2.5}, {200, 0., 2 * o2::constants::math::PI, " "}}); ue.add("hvtxZ", "vtxZ", HistType::kTH1F, {{40, -20.0, 20.0, " "}}); - ue.add("hCounter", "Counter; sel; Nev", HistType::kTH1D, {{7, 0, 7, " "}}); ue.add("hPtLeadingRecPS", "rec pTleading after physics selection", HistType::kTH1D, {ptAxist}); @@ -332,6 +323,14 @@ void ueCharged::init(InitContext const&) HistType::kTH1D, {ptAxist}); ue.add("hPtLeadingVsTracks", "", HistType::kTProfile, {{ptAxist}}); + auto h = ue.get(HIST("hCounter")); + h->GetXaxis()->SetBinLabel(1, "Events read"); + h->GetXaxis()->SetBinLabel(2, "INEL"); + h->GetXaxis()->SetBinLabel(3, "Sel8"); + h->GetXaxis()->SetBinLabel(4, "NoSameBunchPileup"); + h->GetXaxis()->SetBinLabel(5, "IsGoodZvtxFT0vsPV"); + h->GetXaxis()->SetBinLabel(6, "posZ passed"); + for (int i = 0; i < 3; ++i) { ue.add(pNumDenMeasuredPS[i].data(), "Number Density; ; #LT #it{N}_{trk} #GT", HistType::kTProfile, @@ -534,7 +533,16 @@ void ueCharged::processTrue(const C& mcCollision, const P& particles) ue.fill(HIST("hPtInPrimGen"), particle.pt()); } ue.fill(HIST("hmultTrueGen"), multTrue); - if (std::abs(mcCollision.posZ()) > 10.f && multTrueINEL <= 0) { + + if (cfgINELCut == 1 && !o2::pwglf::isINELgt0mc(particles, pdg)) { + return; + } + + if (cfgINELCut == 2 && !o2::pwglf::isINELgt1mc(particles, pdg)) { + return; + } + + if (std::abs(mcCollision.posZ()) > 10.f) { return; } @@ -648,6 +656,14 @@ void ueCharged::processMeas(const C& collision, const T& tracks) ue.fill(HIST("hCounter"), 0); + if (cfgINELCut == 1 && !collision.isInelGt0()) { + return; + } + + if (cfgINELCut == 2 && !collision.isInelGt1()) { + return; + } + ue.fill(HIST("hCounter"), 1); if (sel8 && !collision.sel8()) { @@ -668,6 +684,7 @@ void ueCharged::processMeas(const C& collision, const T& tracks) } ue.fill(HIST("hCounter"), 3); + if (goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { return; @@ -860,6 +877,14 @@ void ueCharged::processMeasMC(const C& collision, const T& tracks, const P& particles) { + if (cfgINELCut == 1 && !o2::pwglf::isINELgt0mc(particles, pdg)) { + return; + } + + if (cfgINELCut == 2 && !o2::pwglf::isINELgt1mc(particles, pdg)) { + return; + } + ue.fill(HIST("hStat"), collision.size()); auto vtxZ = collision.posZ(); @@ -960,6 +985,14 @@ void ueCharged::processMeasMC(const C& collision, const T& tracks, ue.fill(HIST("hCounter"), 0); + if (cfgINELCut == 1 && !collision.isInelGt0()) { + return; + } + + if (cfgINELCut == 2 && !collision.isInelGt1()) { + return; + } + ue.fill(HIST("hCounter"), 1); if (sel8 && !collision.sel8()) { @@ -978,18 +1011,20 @@ void ueCharged::processMeasMC(const C& collision, const T& tracks, !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { return; } + ue.fill(HIST("hCounter"), 3); if (goodzvertex && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { return; } + ue.fill(HIST("hCounter"), 4); - // only PS if ((std::abs(collision.posZ()) >= 10.f)) { return; } + ue.fill(HIST("hCounter"), 5); ue.fill(HIST(pNumDenTruePS[0]), flPtTrue, ueTrue[0]); @@ -1020,7 +1055,24 @@ void ueCharged::processMeasMC(const C& collision, const T& tracks, continue; } ue.fill(HIST("hPtInPrim"), particle.pt()); + + // remove the autocorrelation + if (flIndexTrue == particle.globalIndex()) { + continue; + } + double dPhi = deltaPhi(particle.phi(), flPhiTrue); + + // definition of the topological regions + if (std::abs(dPhi) < o2::constants::math::PI / 3.0) { // near side + ue.fill(HIST(hPtVsPtLeadingTruePS[0]), flPtTrue, particle.pt()); + } else if (std::abs(dPhi - o2::constants::math::PI) < + o2::constants::math::PI / 3.0) { // away side + ue.fill(HIST(hPtVsPtLeadingTruePS[1]), flPtTrue, particle.pt()); + } else { // transverse side + ue.fill(HIST(hPtVsPtLeadingTruePS[2]), flPtTrue, particle.pt()); + } } + ue.fill(HIST("hmultTrue"), multTrue); // loop over selected tracks @@ -1229,6 +1281,14 @@ void ueCharged::analyzeEventAndTrackSelection(const C& collision, const T& tracks) { + if (cfgINELCut == 1 && !collision.isInelGt0()) { + return; + } + + if (cfgINELCut == 2 && !collision.isInelGt1()) { + return; + } + // z-vertex from FT0 vs PV analysis const auto& foundBC = collision.template foundBC_as(); From 93b633f65053f99ba9ea088a0b1c52b47dceb97a Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 3 Oct 2025 01:37:33 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGMM/UE/Tasks/uecharged.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGMM/UE/Tasks/uecharged.cxx b/PWGMM/UE/Tasks/uecharged.cxx index 3974c31a5f8..5b7ddd1b06e 100644 --- a/PWGMM/UE/Tasks/uecharged.cxx +++ b/PWGMM/UE/Tasks/uecharged.cxx @@ -15,6 +15,7 @@ /// \since November 2021 /// \last update: October 2025 +#include "PWGLF/Utils/inelGt.h" #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" @@ -30,7 +31,6 @@ #include "Framework/StaticFor.h" #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/Track.h" -#include "PWGLF/Utils/inelGt.h" #include "TDatabasePDG.h" #include