From 7486cf23c60915857ee73aa9e47beac4c0d1c7ac Mon Sep 17 00:00:00 2001 From: Anton Riedel Date: Thu, 23 Apr 2026 17:12:28 +0200 Subject: [PATCH 1/4] Fix: fix slow event mixing --- PWGCF/Femto/Core/pairHistManager.h | 21 ++-- PWGCF/Femto/Core/pairProcessHelpers.h | 139 +++++++++++++++++--------- 2 files changed, 104 insertions(+), 56 deletions(-) diff --git a/PWGCF/Femto/Core/pairHistManager.h b/PWGCF/Femto/Core/pairHistManager.h index aebd65579ea..7c9ead67aaa 100644 --- a/PWGCF/Femto/Core/pairHistManager.h +++ b/PWGCF/Femto/Core/pairHistManager.h @@ -100,7 +100,8 @@ enum PairHist { // mixing qa kSeNpart1VsNpart2, // number of unique particles 1 vs unique number of particles 2 in each same event - kMeMixingWindow, // mixing window size + kMeMixingWindowRaw, // mixing window size + kMeMixingWindowEffective, // mixing window size, counting event pairs with particle pairs kMeNpart1VsNpart2, // number of unique particles 1 vs number of unique particles 2 in each mixed event kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, // correlation of event properties in each mixing bin @@ -233,7 +234,8 @@ constexpr std::array, kPairHistogramLast> {kTrueMultVsMult, o2::framework::HistType::kTH2F, "hTrueMultVsMult", "Multiplicity_{True} vs Multiplicity; Multiplicity_{True} ; Multiplicity"}, {kTrueCentVsCent, o2::framework::HistType::kTH2F, "hTrueCentVsCent", "Centrality_{True} vs Centrality; Centrality_{True} (%); Centrality (%)"}, {kSeNpart1VsNpart2, o2::framework::HistType::kTH2F, "hSeNpart1VsNpart2", "# unique particle 1 vs # unique particle 2 in each same event; # partilce 1; # particle 2"}, - {kMeMixingWindow, o2::framework::HistType::kTH1F, "hMeMixingWindow", "Mixing Window; Mixing Windown ; Entries"}, + {kMeMixingWindowRaw, o2::framework::HistType::kTH1F, "hMeMixingWindowRaw", "Raw Mixing Window; Raw Mixing Window ; Entries"}, + {kMeMixingWindowEffective, o2::framework::HistType::kTH1F, "hMeMixingWindowEffective", "Effective Mixing Window; Effective Mixing Windown ; Entries"}, {kMeNpart1VsNpart2, o2::framework::HistType::kTH2F, "hMeNpart1VsNpart2", "# unique particle 1 vs # unique partilce 2 in each mixing bin; # partilce 1; # particle 2"}, {kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, o2::framework::HistType::kTHnSparseF, "hVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2", "Mixing bins; V_{z,1} (cm); multiplicity_{1}; centrality_{1} (%); V_{z,2} (cm); multiplicity_{2}; centrality_{2} (%)"}, }}; @@ -276,7 +278,8 @@ constexpr std::array, kPairHistogramLast> {kKstarVsMtVsMinvVsPt1VsPt2VsMultVsCent, {confAnalysis.kstar, confAnalysis.mt, confAnalysis.massInv, confAnalysis.pt1, confAnalysis.pt2, confAnalysis.multiplicity, confAnalysis.centrality}}, \ {kDalitz, {confAnalysis.kstar, confAnalysis.dalitzMtot, confAnalysis.dalitzM12, confAnalysis.dalitzM13}}, \ {kSeNpart1VsNpart2, {confMixing.particleBinning, confMixing.particleBinning}}, \ - {kMeMixingWindow, {confMixing.particleBinning}}, \ + {kMeMixingWindowRaw, {confMixing.particleBinning}}, \ + {kMeMixingWindowEffective, {confMixing.particleBinning}}, \ {kMeNpart1VsNpart2, {confMixing.particleBinning, confMixing.particleBinning}}, \ {kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, {confMixing.vtxBins, confMixing.multBins, confMixing.centBins, confMixing.vtxBins, confMixing.multBins, confMixing.centBins}}, @@ -599,7 +602,9 @@ class PairHistManager void resetTrackedParticlesPerEvent() { mParticles1PerEvent.clear(); + mParticles1PerEvent.reserve(100); mParticles2PerEvent.clear(); + mParticles2PerEvent.reserve(100); } void fillMixingQaSe() @@ -616,10 +621,11 @@ class PairHistManager } } - void fillMixingQaMePerMixingBin(int windowSize) + void fillMixingQaMePerMixingBin(int windowSizeRaw, int windowSizeEffective) { - if (mEventMixingQa) { - mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeMixingWindow, HistTable)), windowSize); + if (mPairCorrelationQa) { + mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeMixingWindowRaw, HistTable)), windowSizeRaw); + mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeMixingWindowEffective, HistTable)), windowSizeEffective); } } @@ -732,7 +738,8 @@ class PairHistManager { std::string mcDir = std::string(prefix) + std::string(MixingQaDir); if (mPairCorrelationQa) { - mHistogramRegistry->add(mcDir + getHistNameV2(kMeMixingWindow, HistTable), getHistDesc(kMeMixingWindow, HistTable), getHistType(kMeMixingWindow, HistTable), {Specs.at(kMeMixingWindow)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kMeMixingWindowRaw, HistTable), getHistDesc(kMeMixingWindowRaw, HistTable), getHistType(kMeMixingWindowRaw, HistTable), {Specs.at(kMeMixingWindowRaw)}); + mHistogramRegistry->add(mcDir + getHistNameV2(kMeMixingWindowEffective, HistTable), getHistDesc(kMeMixingWindowEffective, HistTable), getHistType(kMeMixingWindowEffective, HistTable), {Specs.at(kMeMixingWindowEffective)}); mHistogramRegistry->add(mcDir + getHistNameV2(kMeNpart1VsNpart2, HistTable), getHistDesc(kMeNpart1VsNpart2, HistTable), getHistType(kMeNpart1VsNpart2, HistTable), {Specs.at(kMeNpart1VsNpart2)}); } if (mEventMixingQa) { diff --git a/PWGCF/Femto/Core/pairProcessHelpers.h b/PWGCF/Femto/Core/pairProcessHelpers.h index 48b330b1be9..1c29bf8524a 100644 --- a/PWGCF/Femto/Core/pairProcessHelpers.h +++ b/PWGCF/Femto/Core/pairProcessHelpers.h @@ -281,7 +281,7 @@ void processSameEvent(T1 const& SliceParticle1, PairHistManager.fillMixingQaSe(); } -// process mixed event +// mixed event in data template sliceByCached(o2::aod::femtobase::stored::fColId, collision1.globalIndex(), cache); + auto sliceParticle2 = Partition2->sliceByCached(o2::aod::femtobase::stored::fColId, collision2.globalIndex(), cache); PairHistManager.resetTrackedParticlesPerEvent(); + + if (sliceParticle1.size() == 0 || sliceParticle2.size() == 0) { + PairHistManager.fillMixingQaMePerEvent(); + continue; + } + + bool hasValidPair = false; PairHistManager.fillMixingQaMe(collision1, collision2); for (auto const& [p1, p2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(sliceParticle1, sliceParticle2))) { - // pair cleaning + if (!PcManager.isCleanPair(p1, p2, TrackTable)) { continue; } - // Close pair rejection + CprManager.setPair(p1, p2, TrackTable); if (CprManager.isClosePair()) { continue; } + PairHistManager.setPair(p1, p2, TrackTable, collision1, collision2); CprManager.fill(PairHistManager.getKstar()); + if (PairHistManager.checkPairCuts()) { - PairHistManager.template fill(); + hasValidPair = true; PairHistManager.trackParticlesPerEvent(p1, p2); + PairHistManager.template fill(); } } + + if (hasValidPair) { + ++windowSizeEffective; + } + PairHistManager.fillMixingQaMePerEvent(); } - PairHistManager.fillMixingQaMePerMixingBin(windowSize); // fill last window + + // --- final window --- + if (windowSizeRaw > 0) { + PairHistManager.fillMixingQaMePerMixingBin(windowSizeRaw, windowSizeEffective); + } } -// process mixed event with mc information +// process mixed event in mc template sliceByCached( - o2::aod::femtobase::stored::fColId, - collision1.globalIndex(), - cache); - auto sliceParticle2 = Partition2->sliceByCached( - o2::aod::femtobase::stored::fColId, - collision2.globalIndex(), - cache); + auto sliceParticle1 = Partition1->sliceByCached(o2::aod::femtobase::stored::fColId, collision1.globalIndex(), cache); + + auto sliceParticle2 = Partition2->sliceByCached(o2::aod::femtobase::stored::fColId, collision2.globalIndex(), cache); PairHistManager.resetTrackedParticlesPerEvent(); + + if (sliceParticle1.size() == 0 || sliceParticle2.size() == 0) { + PairHistManager.fillMixingQaMePerEvent(); + continue; + } + + bool hasValidPair = false; PairHistManager.fillMixingQaMe(collision1, collision2); - for (auto const& [p1, p2] : - o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(sliceParticle1, sliceParticle2))) { - // particle cleaning (MC-specific) + + for (auto const& [p1, p2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(sliceParticle1, sliceParticle2))) { + if (!ParticleCleaner1.isClean(p1, mcParticles, mcMothers, mcPartonicMothers) || !ParticleCleaner2.isClean(p2, mcParticles, mcMothers, mcPartonicMothers)) { continue; } - // pair cleaning + if (!PcManager.isCleanPair(p1, p2, TrackTable)) { continue; } - // close pair rejection + CprManager.setPair(p1, p2, TrackTable); if (CprManager.isClosePair()) { continue; } + PairHistManager.setPairMc(p1, p2, TrackTable, mcParticles, collision1, collision2, mcCollisions); + CprManager.fill(PairHistManager.getKstar()); + if (PairHistManager.checkPairCuts()) { - PairHistManager.template fill(); + hasValidPair = true; PairHistManager.trackParticlesPerEvent(p1, p2); + PairHistManager.template fill(); } } + + if (hasValidPair) { + ++windowSizeEffective; + } + PairHistManager.fillMixingQaMePerEvent(); } - // final window - PairHistManager.fillMixingQaMePerMixingBin(windowSize); + + if (windowSizeRaw > 0) { + PairHistManager.fillMixingQaMePerMixingBin(windowSizeRaw, windowSizeEffective); + } } } // namespace pairprocesshelpers From 9a14a29095b73d9914cd43f111b43b7eeee304f7 Mon Sep 17 00:00:00 2001 From: Anton Riedel Date: Fri, 24 Apr 2026 09:42:44 +0200 Subject: [PATCH 2/4] Fix: fix data type --- PWGCF/Femto/Core/pairProcessHelpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGCF/Femto/Core/pairProcessHelpers.h b/PWGCF/Femto/Core/pairProcessHelpers.h index 1c29bf8524a..da40ff73a7c 100644 --- a/PWGCF/Femto/Core/pairProcessHelpers.h +++ b/PWGCF/Femto/Core/pairProcessHelpers.h @@ -304,7 +304,7 @@ void processMixedEvent(T1 const& Collisions, T9& CprManager, T10& PcManager) { - int lastCollisionIndex = -1; + int64_t lastCollisionIndex = -1; int windowSizeRaw = 0; int windowSizeEffective = 0; @@ -411,7 +411,7 @@ void processMixedEvent(T1 const& Collisions, T15& CprManager, T16& PcManager) { - int lastCollisionIndex = -1; + int64_t lastCollisionIndex = -1; int windowSizeRaw = 0; int windowSizeEffective = 0; From 6daf5a826e97624b694183d246e33c394c0aac86 Mon Sep 17 00:00:00 2001 From: Anton Riedel Date: Fri, 24 Apr 2026 09:42:57 +0200 Subject: [PATCH 3/4] Fix: remove emojis --- PWGCF/Femto/Macros/cutculatorGui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGCF/Femto/Macros/cutculatorGui.py b/PWGCF/Femto/Macros/cutculatorGui.py index db776251e77..0a5f25fe946 100755 --- a/PWGCF/Femto/Macros/cutculatorGui.py +++ b/PWGCF/Femto/Macros/cutculatorGui.py @@ -128,11 +128,11 @@ def _build_ui(self): top = tk.Frame(self, bg=BG, pady=10, padx=18) top.pack(fill="x") - tk.Label(top, text="✂ CutCulator", font=FONT_TITLE, bg=BG, fg=ACCENT).pack(side="left") + tk.Label(top, text="CutCulator", font=FONT_TITLE, bg=BG, fg=ACCENT).pack(side="left") btn_frame = tk.Frame(top, bg=BG) btn_frame.pack(side="right") - self._btn_open = self._make_button(btn_frame, "📂 Open ROOT file", self._open_file_dialog, ACCENT) + self._btn_open = self._make_button(btn_frame, "Open ROOT file", self._open_file_dialog, ACCENT) self._btn_open.pack(side="left", padx=4) # ── file + histogram selector bar ── From aa01a3b6769beaba2a7c336b810f58fc77b04390 Mon Sep 17 00:00:00 2001 From: Anton Riedel Date: Fri, 24 Apr 2026 09:49:28 +0200 Subject: [PATCH 4/4] Fix: fix include --- PWGCF/Femto/Macros/cutculatorGui.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PWGCF/Femto/Macros/cutculatorGui.py b/PWGCF/Femto/Macros/cutculatorGui.py index 0a5f25fe946..6fc210f0ed2 100755 --- a/PWGCF/Femto/Macros/cutculatorGui.py +++ b/PWGCF/Femto/Macros/cutculatorGui.py @@ -19,7 +19,6 @@ import tkinter as tk from tkinter import ttk, filedialog, messagebox import argparse -import sys try: import ROOT