Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions PWGCF/Femto/Core/pairHistManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -233,7 +234,8 @@ constexpr std::array<histmanager::HistInfo<PairHist>, 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} (%)"},
}};
Expand Down Expand Up @@ -276,7 +278,8 @@ constexpr std::array<histmanager::HistInfo<PairHist>, 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}},

Expand Down Expand Up @@ -599,7 +602,9 @@ class PairHistManager
void resetTrackedParticlesPerEvent()
{
mParticles1PerEvent.clear();
mParticles1PerEvent.reserve(100);
mParticles2PerEvent.clear();
mParticles2PerEvent.reserve(100);
}

void fillMixingQaSe()
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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) {
Expand Down
139 changes: 90 additions & 49 deletions PWGCF/Femto/Core/pairProcessHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void processSameEvent(T1 const& SliceParticle1,
PairHistManager.fillMixingQaSe();
}

// process mixed event
// mixed event in data
template <modes::Mode mode,
typename T1,
typename T2,
Expand All @@ -304,54 +304,79 @@ void processMixedEvent(T1 const& Collisions,
T9& CprManager,
T10& PcManager)
{
bool firstBin = true;
int windowSize = 0;
PairHistManager.resetTrackedParticlesPerEvent();
auto pairGenerator = o2::soa::selfCombinations(policy, depth, -1, Collisions, Collisions);
for (auto pairIterator = pairGenerator.begin(); pairIterator != pairGenerator.end(); pairIterator++) {
auto const& [collision1, collision2] = *pairIterator;
if (pairIterator.isNewWindow()) { // is true for the first bin, so we skip
if (!firstBin) {
// we fill histograms after we finish processing one mixing bin
// the very first bin is considered a new window, so we skp it
PairHistManager.fillMixingQaMePerMixingBin(windowSize);
int64_t lastCollisionIndex = -1;
int windowSizeRaw = 0;
int windowSizeEffective = 0;

for (auto const& [collision1, collision2] : o2::soa::selfCombinations(policy, depth, -1, Collisions, Collisions)) {

// --- new window ---
if (collision1.globalIndex() != lastCollisionIndex) {
if (lastCollisionIndex != -1) {
PairHistManager.fillMixingQaMePerMixingBin(windowSizeRaw, windowSizeEffective);
}
windowSize = pairIterator.currentWindowNeighbours();
firstBin = false;
windowSizeRaw = 0;
windowSizeEffective = 0;
lastCollisionIndex = collision1.globalIndex();
}

++windowSizeRaw;

if (collision1.magField() != collision2.magField()) {
LOG(warn) << "Tried to mixng to events with different magntic field. This should not happen...";
LOG(warn) << "Tried mixing events with different magnetic field.";
continue;
}

CprManager.setMagField(collision1.magField());

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))) {
// 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<mode>();
hasValidPair = true;
PairHistManager.trackParticlesPerEvent(p1, p2);
PairHistManager.template fill<mode>();
}
}

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 <modes::Mode mode,
typename T1,
typename T2,
Expand Down Expand Up @@ -386,64 +411,80 @@ void processMixedEvent(T1 const& Collisions,
T15& CprManager,
T16& PcManager)
{
bool firstBin = true;
int windowSize = 0;
PairHistManager.resetTrackedParticlesPerEvent();
auto pairGenerator = o2::soa::selfCombinations(policy, depth, -1, Collisions, Collisions);
for (auto pairIterator = pairGenerator.begin(); pairIterator != pairGenerator.end(); ++pairIterator) {
auto const& [collision1, collision2] = *pairIterator;
// handle mixing windows (same as data)
if (pairIterator.isNewWindow()) {
if (!firstBin) {
PairHistManager.fillMixingQaMePerMixingBin(windowSize);
int64_t lastCollisionIndex = -1;
int windowSizeRaw = 0;
int windowSizeEffective = 0;

for (auto const& [collision1, collision2] : o2::soa::selfCombinations(policy, depth, -1, Collisions, Collisions)) {
if (collision1.globalIndex() != lastCollisionIndex) {
if (lastCollisionIndex != -1) {
PairHistManager.fillMixingQaMePerMixingBin(windowSizeRaw, windowSizeEffective);
}
windowSize = pairIterator.currentWindowNeighbours();
firstBin = false;
windowSizeRaw = 0;
windowSizeEffective = 0;
lastCollisionIndex = collision1.globalIndex();
}

++windowSizeRaw;

if (collision1.magField() != collision2.magField()) {
LOG(warn) << "Tried to mixng to events with different magntic field. This should not happen...";
LOG(warn) << "Tried mixing events with different magnetic field.";
continue;
}

CprManager.setMagField(collision1.magField());

auto sliceParticle1 = Partition1->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<mode>();
hasValidPair = true;
PairHistManager.trackParticlesPerEvent(p1, p2);
PairHistManager.template fill<mode>();
}
}

if (hasValidPair) {
++windowSizeEffective;
}

PairHistManager.fillMixingQaMePerEvent();
}
// final window
PairHistManager.fillMixingQaMePerMixingBin(windowSize);

if (windowSizeRaw > 0) {
PairHistManager.fillMixingQaMePerMixingBin(windowSizeRaw, windowSizeEffective);
}
}

} // namespace pairprocesshelpers
Expand Down
5 changes: 2 additions & 3 deletions PWGCF/Femto/Macros/cutculatorGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import argparse
import sys

try:
import ROOT
Expand Down Expand Up @@ -128,11 +127,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 ──
Expand Down
Loading