Skip to content

Commit e908043

Browse files
committed
Feat: add Mixing Qa
1 parent 9c5f4d4 commit e908043

File tree

8 files changed

+184
-56
lines changed

8 files changed

+184
-56
lines changed

PWGCF/Femto/Core/closePairRejection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ class CloseTrackRejection
367367
{
368368
double arg = 0.3 * (0.1 * magfield) * (0.01 * radius) / (2. * signedPt);
369369
if (std::fabs(arg) <= 1.) {
370-
double phistar = phi - std::asin(arg);
371-
return static_cast<float>(RecoDecay::constrainAngle(phistar));
370+
double angle = phi - std::asin(arg);
371+
return static_cast<float>(RecoDecay::constrainAngle(angle));
372372
}
373373
return std::nullopt;
374374
}

PWGCF/Femto/Core/mcBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ class McBuilder
134134
// Not yet created → create it
135135
auto mcCol = col.template mcCollision_as<T3>();
136136
this->fillMcCollision<system>(mcCol, mcProducts);
137-
it = mCollisionMap.find(originalIndex);
138137
}
139138
// Add label
140-
mcProducts.producedCollisionLabels(it->second);
139+
mcProducts.producedCollisionLabels(mCollisionMap.at(originalIndex)); // mc collsions has been added so we can now safely retrieve the index
141140
} else {
142141
// If no MC collision associated, fill empty label
143142
mcProducts.producedCollisionLabels(-1);

PWGCF/Femto/Core/pairBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,15 @@ class PairTrackV0Builder
604604
int pdgCodePosDau = 0;
605605
int pdgCodeNegDau = 0;
606606
if (modes::isEqual(v0Type, modes::V0::kK0short)) {
607-
pdgCodeNegDau = kPiPlus;
607+
pdgCodePosDau = kPiPlus;
608608
pdgCodeNegDau = kPiMinus;
609609
} else if (modes::isEqual(v0Type, modes::V0::kLambda) || modes::isEqual(v0Type, modes::V0::kAntiLambda)) {
610610
if (confV0Selection.sign.value > 0) {
611-
pdgCodeNegDau = kProton;
611+
pdgCodePosDau = kProton;
612612
pdgCodeNegDau = kPiMinus;
613613
} else {
614+
pdgCodePosDau = kPiPlus;
614615
pdgCodeNegDau = kProtonBar;
615-
pdgCodeNegDau = kPiPlus;
616616
}
617617
}
618618

PWGCF/Femto/Core/pairHistManager.h

Lines changed: 98 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
#include <array>
3333
#include <cmath>
3434
#include <map>
35+
#include <set>
3536
#include <string>
3637
#include <string_view>
38+
#include <unordered_map>
3739
#include <vector>
3840

3941
namespace o2::analysis::femto
@@ -98,9 +100,10 @@ enum PairHist {
98100

99101
// mixing qa
100102
kSeNpart1VsNpart2, // number of particles 1 vs number of particles 2 in each same event
103+
kMeMixingDepth, // mixing depth
104+
kMeNpart1VsNpart2, // number of particles 1 vs number of particles 2 in each mixed event
101105
kMeNpart1, // number of unique particles 1 in each mixing bin
102106
kMeNpart2, // number of unique particles 2 in each mixing bin
103-
kMeAverageNpart1VsAverageNpart2, // average number of particles 1 vs average number of particles 2 in each mixing bin
104107
kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, // correlation of event properties in each mixing bin
105108

106109
kPairHistogramLast
@@ -123,8 +126,8 @@ struct ConfMixing : o2::framework::ConfigurableGroup {
123126
o2::framework::Configurable<int> policy{"policy", 0, "Binning policy for mixing (alywas in combination with z-vertex) -> 0: multiplicity, -> 1: centrality, -> 2: both"};
124127
o2::framework::Configurable<bool> sameSpecies{"sameSpecies", false, "Enable if particle 1 and particle 2 are the same"};
125128
o2::framework::Configurable<int> seed{"seed", -1, "Seed to randomize particle 1 and particle 2 (if they are identical). Set to negative value to deactivate. Set to 0 to generate unique seed in time."};
126-
o2::framework::Configurable<bool> enableSameEventQa{"enableSameEventQa", false, "Enable qa plots for same event"};
127-
o2::framework::Configurable<bool> enableMixedEventQa{"enableMixedEventQa", false, "Enable qa plots for mixed event"};
129+
o2::framework::Configurable<bool> enablePairCorrelationQa{"enablePairCorrelationQa", true, "Enable pair-level correlation QA (same-event + mixed-event)"};
130+
o2::framework::Configurable<bool> enableEventMixingQa{"enableEventMixingQa", false, "Enable QA of event properties used in event mixing (vtx, multiplicity, centrality)"};
128131
o2::framework::ConfigurableAxis particleBinning{"particleBinning", {50, -0.5f, 49.5f}, "Binning for particle number correlation in pairs"};
129132
};
130133

@@ -225,10 +228,11 @@ constexpr std::array<histmanager::HistInfo<PairHist>, kPairHistogramLast>
225228
{kTrueMinvVsMinv, o2::framework::kTH2F, "hTrueMinvVsMinv", "m_{Inv,True} vs m_{Inv}; m_{Inv,True} (GeV/#it{c}^{2}); m_{Inv} (GeV/#it{c}^{2})"},
226229
{kTrueMultVsMult, o2::framework::kTH2F, "hTrueMultVsMult", "Multiplicity_{True} vs Multiplicity; Multiplicity_{True} ; Multiplicity"},
227230
{kTrueCentVsCent, o2::framework::kTH2F, "hTrueCentVsCent", "Centrality_{True} vs Centrality; Centrality_{True} (%); Centrality (%)"},
228-
{kSeNpart1VsNpart2, o2::framework::kTH2F, "hSeNpart1VsNpart2", "# particle 1 vs # particle in SE; # partilce 1; #particle 2"},
231+
{kSeNpart1VsNpart2, o2::framework::kTH2F, "hSeNpart1VsNpart2", "# particle 1 vs # particle 2 in each same event; # partilce 1; # particle 2"},
232+
{kMeMixingDepth, o2::framework::kTH1F, "hMeMixingDepth", "Mixing Depth; Mixing Depth ; Entries"},
233+
{kMeNpart1VsNpart2, o2::framework::kTH2F, "hMeNpart1VsNpart2", "# particle 1 vs # particle 2 in each mixed event pair; # partilce 1; # particle 2"},
229234
{kMeNpart1, o2::framework::kTH1F, "hMeNpart1", "# particle 1 in each mixing bin; # partilce 1; Entries"},
230235
{kMeNpart2, o2::framework::kTH1F, "hMeNpart2", "# particle 2 in each mixing bin; # particle 2; Entries"},
231-
{kMeAverageNpart1VsAverageNpart2, o2::framework::kTH2F, "hMeAverageNpart1VsAverageNpart2", "average # particle 1 vs average # particle in ME; Average # partilce 1; Average #particle 2"},
232236
{kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, o2::framework::kTHnSparseF, "hVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2", "Mixing bins; V_{z,1} (cm); multiplicity_{1}; centrality_{1} (%); V_{z,2} (cm); multiplicity_{2}; centrality_{2} (%)"},
233237
}};
234238

@@ -267,9 +271,10 @@ constexpr std::array<histmanager::HistInfo<PairHist>, kPairHistogramLast>
267271
{kKstarVsMtVsMass1VsMass2VsPt1VsPt2VsMultVsCent, {confAnalysis.kstar, confAnalysis.mt, confAnalysis.mass1, confAnalysis.mass2, confAnalysis.pt1, confAnalysis.pt2, confAnalysis.multiplicity, confAnalysis.centrality}}, \
268272
{kDalitz, {confAnalysis.kstar, confAnalysis.dalitzMtot, confAnalysis.dalitzM12, confAnalysis.dalitzM13}}, \
269273
{kSeNpart1VsNpart2, {confMixing.particleBinning, confMixing.particleBinning}}, \
274+
{kMeMixingDepth, {confMixing.particleBinning}}, \
275+
{kMeNpart1VsNpart2, {confMixing.particleBinning, confMixing.particleBinning}}, \
270276
{kMeNpart1, {confMixing.particleBinning}}, \
271277
{kMeNpart2, {confMixing.particleBinning}}, \
272-
{kMeAverageNpart1VsAverageNpart2, {confMixing.particleBinning, confMixing.particleBinning}}, \
273278
{kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, {confMixing.vtxBins, confMixing.multBins, confMixing.centBins, confMixing.vtxBins, confMixing.multBins, confMixing.centBins}},
274279

275280
#define PAIR_HIST_MC_MAP(conf) \
@@ -373,15 +378,8 @@ class PairHistManager
373378
mMassInvMin = ConfPairCuts.massInvMin.value;
374379
mMassInvMax = ConfPairCuts.massInvMax.value;
375380

376-
if constexpr (isFlagSet(mode, modes::Mode::kSe)) {
377-
mSeMixingQa = ConfMixing.enableSameEventQa.value;
378-
initSeMixingQa(Specs);
379-
}
380-
381-
if constexpr (isFlagSet(mode, modes::Mode::kMe)) {
382-
mMeMixingQa = ConfMixing.enableMixedEventQa.value;
383-
initMeMixingQa(Specs);
384-
}
381+
mPairCorrelationQa = ConfMixing.enablePairCorrelationQa.value;
382+
mEventMixingQa = ConfMixing.enableEventMixingQa.value;
385383

386384
if constexpr (isFlagSet(mode, modes::Mode::kAnalysis)) {
387385
initAnalysis(Specs);
@@ -390,6 +388,14 @@ class PairHistManager
390388
if constexpr (isFlagSet(mode, modes::Mode::kMc)) {
391389
initMc(Specs);
392390
}
391+
392+
if constexpr (isFlagSet(mode, modes::Mode::kSe)) {
393+
initSeMixingQa(Specs);
394+
}
395+
396+
if constexpr (isFlagSet(mode, modes::Mode::kMe)) {
397+
initMeMixingQa(Specs);
398+
}
393399
}
394400

395401
void setMass(int PdgParticle1, int PdgParticle2)
@@ -565,14 +571,71 @@ class PairHistManager
565571
}
566572
}
567573

568-
template <modes::Mode mode, typename T1, typename T2>
569-
void fillMixingQa(T1 const& particles1, T2 const& particles2)
574+
template <typename T1, typename T2>
575+
void trackParticlesPerMixingBin(T1 const& particle1, T2 const& particle2)
570576
{
571-
if constexpr (isFlagSet(mode, modes::Mode::kSe)) {
572-
fillMixingQaSe(particles1, particles2);
577+
mUniqueParticles1PerMixingBin.emplace(particle1.globalIndex(), 0);
578+
mUniqueParticles1PerMixingBin.at(particle1.globalIndex())++;
579+
mUniqueParticles2PerMixingBin.emplace(particle2.globalIndex(), 0);
580+
mUniqueParticles2PerMixingBin.at(particle2.globalIndex())++;
581+
}
582+
583+
void resetTrackedParticlesPerMixingBin()
584+
{
585+
mUniqueParticles1PerMixingBin.clear();
586+
mUniqueParticles2PerMixingBin.clear();
587+
}
588+
589+
template <typename T1, typename T2>
590+
void trackParticlesPerEvent(T1 const& particle1, T2 const& particle2)
591+
{
592+
mUniqueParticles1PerEvent.insert(particle1.globalIndex());
593+
mUniqueParticles2PerEvent.insert(particle2.globalIndex());
594+
}
595+
596+
template <typename T1, typename T2>
597+
void fillMixingQaMe(T1 const& col1, T2 const& col2)
598+
{
599+
if (mEventMixingQa) {
600+
mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, HistTable)), col1.posZ(), col1.mult(), col1.cent(), col2.posZ(), col2.mult(), col2.cent());
573601
}
574-
if constexpr (isFlagSet(mode, modes::Mode::kMe)) {
575-
// fillMc();
602+
}
603+
604+
void resetTrackedParticlesPerEvent()
605+
{
606+
mUniqueParticles1PerEvent.clear();
607+
mUniqueParticles2PerEvent.clear();
608+
}
609+
610+
void fillMixingQaSe()
611+
{
612+
if (mPairCorrelationQa) {
613+
mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kSeNpart1VsNpart2, HistTable)), mUniqueParticles1PerEvent.size(), mUniqueParticles2PerEvent.size());
614+
}
615+
}
616+
617+
void fillMixingQaMePerEvent()
618+
{
619+
if (mPairCorrelationQa) {
620+
mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeNpart1VsNpart2, HistTable)), mUniqueParticles1PerEvent.size(), mUniqueParticles2PerEvent.size());
621+
}
622+
}
623+
624+
void fillMixingQaMePerMixingBin(int windowSize)
625+
{
626+
if (!mPairCorrelationQa || windowSize <= 0) {
627+
return;
628+
}
629+
mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeMixingDepth, HistTable)), windowSize);
630+
for (const auto& [_, nPart1] : mUniqueParticles1PerMixingBin) {
631+
mHistogramRegistry->fill(
632+
HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeNpart1, HistTable)),
633+
nPart1);
634+
}
635+
for (const auto& [_, nPart2] : mUniqueParticles2PerMixingBin) {
636+
mHistogramRegistry->fill(
637+
HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kMeNpart2, HistTable)),
638+
nPart2);
576639
}
577640
}
578641

@@ -665,18 +728,21 @@ class PairHistManager
665728
void initSeMixingQa(std::map<PairHist, std::vector<o2::framework::AxisSpec>> const& Specs)
666729
{
667730
std::string mcDir = std::string(prefix) + std::string(MixingQaDir);
668-
if (mSeMixingQa) {
731+
if (mPairCorrelationQa) {
669732
mHistogramRegistry->add(mcDir + getHistNameV2(kSeNpart1VsNpart2, HistTable), getHistDesc(kSeNpart1VsNpart2, HistTable), getHistType(kSeNpart1VsNpart2, HistTable), {Specs.at(kSeNpart1VsNpart2)});
670733
}
671734
}
672735

673736
void initMeMixingQa(std::map<PairHist, std::vector<o2::framework::AxisSpec>> const& Specs)
674737
{
675738
std::string mcDir = std::string(prefix) + std::string(MixingQaDir);
676-
if (mMeMixingQa) {
739+
if (mPairCorrelationQa) {
740+
mHistogramRegistry->add(mcDir + getHistNameV2(kMeMixingDepth, HistTable), getHistDesc(kMeMixingDepth, HistTable), getHistType(kMeMixingDepth, HistTable), {Specs.at(kMeMixingDepth)});
741+
mHistogramRegistry->add(mcDir + getHistNameV2(kMeNpart1VsNpart2, HistTable), getHistDesc(kMeNpart1VsNpart2, HistTable), getHistType(kMeNpart1VsNpart2, HistTable), {Specs.at(kMeNpart1VsNpart2)});
677742
mHistogramRegistry->add(mcDir + getHistNameV2(kMeNpart1, HistTable), getHistDesc(kMeNpart1, HistTable), getHistType(kMeNpart1, HistTable), {Specs.at(kMeNpart1)});
678743
mHistogramRegistry->add(mcDir + getHistNameV2(kMeNpart2, HistTable), getHistDesc(kMeNpart2, HistTable), getHistType(kMeNpart2, HistTable), {Specs.at(kMeNpart2)});
679-
mHistogramRegistry->add(mcDir + getHistNameV2(kMeAverageNpart1VsAverageNpart2, HistTable), getHistDesc(kMeAverageNpart1VsAverageNpart2, HistTable), getHistType(kMeAverageNpart1VsAverageNpart2, HistTable), {Specs.at(kMeAverageNpart1VsAverageNpart2)});
744+
}
745+
if (mEventMixingQa) {
680746
mHistogramRegistry->add(mcDir + getHistNameV2(kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, HistTable), getHistDesc(kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, HistTable), getHistType(kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2, HistTable), {Specs.at(kMeVtz1VsMult1VsCent1VsVtz2VsMult2VsCent2)});
681747
}
682748
}
@@ -766,14 +832,6 @@ class PairHistManager
766832
}
767833
}
768834

769-
template <typename T1, typename T2>
770-
void fillMixingQaSe(T1 const& particles1, T2 const& particles2)
771-
{
772-
if (mSeMixingQa) {
773-
mHistogramRegistry->fill(HIST(prefix) + HIST(MixingQaDir) + HIST(getHistName(kSeNpart1VsNpart2, HistTable)), particles1.size(), particles2.size());
774-
}
775-
}
776-
777835
float getKt(ROOT::Math::PtEtaPhiMVector const& part1, ROOT::Math::PtEtaPhiMVector const& part2)
778836
{
779837
auto sum = (part1 + part2);
@@ -894,8 +952,14 @@ class PairHistManager
894952
bool mPlotDalitz = false;
895953

896954
// qa
897-
bool mSeMixingQa = false;
898-
bool mMeMixingQa = false;
955+
bool mPairCorrelationQa = false;
956+
bool mEventMixingQa = false;
957+
958+
std::set<int64_t> mUniqueParticles1PerEvent = {};
959+
std::set<int64_t> mUniqueParticles2PerEvent = {};
960+
961+
std::unordered_map<int64_t, int> mUniqueParticles1PerMixingBin = {};
962+
std::unordered_map<int64_t, int> mUniqueParticles2PerMixingBin = {};
899963
};
900964

901965
}; // namespace pairhistmanager

0 commit comments

Comments
 (0)