Skip to content

Commit 2e5cb24

Browse files
authored
[PWGCF] Fixes in femto frame work (#18578)
1 parent ccb326e commit 2e5cb24

18 files changed

Lines changed: 828 additions & 525 deletions

‎PWGCF/Femto/Core/closePairRejection.h‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define PWGCF_FEMTO_CORE_CLOSEPAIRREJECTION_H_
1818

1919
#include "PWGCF/Femto/Core/histManager.h"
20+
#include "PWGCF/Femto/Core/modes.h"
2021

2122
#include "Common/Core/RecoDecay.h"
2223

@@ -61,7 +62,8 @@ enum CprHist {
6162

6263
// template configurable group for Cpr
6364
// DefaultCutAverage: default of cutAverage (e.g. false for pairs of generated particles, where no detector effects are present)
64-
template <auto& Prefix, bool DefaultCutAverage = true>
65+
// DefaultKinematicVariable: default of kinematicVariable (e.g. Q3 for triplets, kstar for pairs)
66+
template <auto& Prefix, bool DefaultCutAverage = true, modes::KinematicVariable DefaultKinematicVariable = modes::KinematicVariable::kKstar>
6567
struct ConfCpr : o2::framework::ConfigurableGroup {
6668
std::string prefix = std::string(Prefix);
6769
o2::framework::Configurable<bool> cutAverage{"cutAverage", DefaultCutAverage, "Apply CPR if the average deta-dphistar is below the configured values"};
@@ -71,6 +73,7 @@ struct ConfCpr : o2::framework::ConfigurableGroup {
7173
o2::framework::Configurable<bool> plotAverage{"plotAverage", true, "Plot average deta dphi distribution"};
7274
o2::framework::Configurable<bool> plotAngularCorrelation{"plotAngularCorrelation", false, "Plot angular correlation of particles (eta1 vs eta2 & phi1 vs phi2)"};
7375
o2::framework::Configurable<bool> plotKinematic{"plotKinematic", true, "Plot kinematic (kstar/Q3) distribution of blocked pairs/triplets"};
76+
o2::framework::Configurable<int> kinematicVariable{"kinematicVariable", static_cast<int>(DefaultKinematicVariable), "Type of kinematic variable (0->kstar, 1->kT, 2->mT, 3->Q3) reported by the kinematic plot"};
7477
o2::framework::Configurable<float> detaMax{"detaMax", 0.01f, "Maximium deta"};
7578
o2::framework::Configurable<float> dphistarMax{"dphistarMax", 0.01f, "Maximum dphistar"};
7679
o2::framework::Configurable<float> detaCenter{"detaCenter", 0.f, "Center of deta cut"};
@@ -241,6 +244,7 @@ class CloseTrackRejection
241244

242245
mPlotAngularCorrelation = confCpr.plotAngularCorrelation.value;
243246
mPlotKinematic = confCpr.plotKinematic.value;
247+
mKinematicVariable = static_cast<modes::KinematicVariable>(confCpr.kinematicVariable.value);
244248

245249
if (confCpr.seed.value >= 0) {
246250
uint64_t randomSeed = 0;
@@ -259,7 +263,8 @@ class CloseTrackRejection
259263
mHistogramRegistry = registry;
260264

261265
if (mPlotKinematic) {
262-
mHistogramRegistry->add(std::string(prefix) + getHistNameV2(kKinematic, HistTable), getHistDesc(kKinematic, HistTable), getHistType(kKinematic, HistTable), {specs.at(kKinematic)});
266+
std::string kinematicDesc = histmanager::replaceFirstAxisTitle(getHistDesc(kKinematic, HistTable), modes::kinematicVariableToAxisTitle(mKinematicVariable));
267+
mHistogramRegistry->add(std::string(prefix) + getHistNameV2(kKinematic, HistTable), kinematicDesc.c_str(), getHistType(kKinematic, HistTable), {specs.at(kKinematic)});
263268
}
264269

265270
if (mPlotAverage) {
@@ -301,9 +306,9 @@ class CloseTrackRejection
301306
bool isClose = mUseEpisoidalCut ? isClosePairEpisoidalCut() : isClosePairRectengularCut();
302307

303308
if (isClose) {
304-
fillBlocked(pairHistManager.getKinematic());
309+
fillBlocked(pairHistManager.getKinematic(mKinematicVariable));
305310
} else {
306-
fillPassed(pairHistManager.getKinematic());
311+
fillPassed(pairHistManager.getKinematic(mKinematicVariable));
307312
}
308313

309314
return isClose;
@@ -493,6 +498,7 @@ class CloseTrackRejection
493498
bool mPlotAverage = false;
494499
bool mPlotAngularCorrelation = false;
495500
bool mPlotKinematic = false;
501+
modes::KinematicVariable mKinematicVariable = modes::KinematicVariable::kKstar;
496502

497503
float mKinematicMin = -1.f;
498504
float mKinematicMax = -1.f;
@@ -531,10 +537,10 @@ template <auto& prefix>
531537
class ClosePairRejectionTrackTrack
532538
{
533539
public:
534-
template <typename T>
540+
template <typename T1>
535541
void init(o2::framework::HistogramRegistry* registry,
536542
std::map<CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
537-
T const& confCpr,
543+
T1 const& confCpr,
538544
int absChargeTrack1,
539545
int absChargeTrack2)
540546
{
@@ -597,10 +603,10 @@ template <auto& prefixTrackV0>
597603
class ClosePairRejectionTrackV0 // can also be used for any particle type that has pos/neg daughters, like resonances
598604
{
599605
public:
600-
template <typename T>
606+
template <typename T1>
601607
void init(o2::framework::HistogramRegistry* registry,
602608
std::map<CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
603-
T const& confCpr,
609+
T1 const& confCpr,
604610
int absChargeTrack)
605611
{
606612
mCtr.init(registry, specs, confCpr, absChargeTrack, 1);
@@ -719,10 +725,10 @@ template <auto& prefix>
719725
class ClosePairRejectionTrackKink
720726
{
721727
public:
722-
template <typename T>
728+
template <typename T1>
723729
void init(o2::framework::HistogramRegistry* registry,
724730
std::map<CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
725-
T const& confCpr,
731+
T1 const& confCpr,
726732
int absChargeTrack)
727733
{
728734
mCtr.init(registry, specs, confCpr, absChargeTrack, 1);
@@ -753,10 +759,10 @@ template <auto& prefix>
753759
class ClosePairRejectionTrackTwoPhotonResonance
754760
{
755761
public:
756-
template <typename T>
762+
template <typename T1>
757763
void init(o2::framework::HistogramRegistry* /*registry*/,
758764
std::map<CprHist, std::vector<o2::framework::AxisSpec>> const& /*specs*/,
759-
T const& /*confCpr*/,
765+
T1 const& /*confCpr*/,
760766
int /*absChargeTrack*/)
761767
{
762768
}
@@ -774,10 +780,10 @@ template <auto& prefix>
774780
class ClosePairRejectionMcParticleMcParticle
775781
{
776782
public:
777-
template <typename T>
783+
template <typename T1>
778784
void init(o2::framework::HistogramRegistry* registry,
779785
std::map<CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
780-
T const& confCpr)
786+
T1 const& confCpr)
781787
{
782788
mCtr.init(registry, specs, confCpr, 1, 1);
783789
mCtr.setMagField(confCpr.magField.value);

‎PWGCF/Femto/Core/closeTripletRejection.h‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define PWGCF_FEMTO_CORE_CLOSETRIPLETREJECTION_H_
1818

1919
#include "PWGCF/Femto/Core/closePairRejection.h"
20+
#include "PWGCF/Femto/Core/modes.h"
2021

2122
#include <Framework/HistogramRegistry.h>
2223
#include <Framework/HistogramSpec.h>
@@ -31,11 +32,12 @@ constexpr const char PrefixCtrTrackTrackV0[] = "CtrTrackTrackV0";
3132
constexpr const char PrefixCtrTrackTrackCascade[] = "CtrTrackTrackCascade";
3233
constexpr const char PrefixCtrMcParticleMcParticleMcParticle[] = "CtrMcParticleMcParticleMcParticle";
3334

34-
using ConfCtrTrackTrackTrack = closepairrejection::ConfCpr<PrefixCtrTrackTrackTrack>;
35-
using ConfCtrTrackTrackV0 = closepairrejection::ConfCpr<PrefixCtrTrackTrackV0>;
36-
using ConfCtrTrackTrackCascade = closepairrejection::ConfCpr<PrefixCtrTrackTrackCascade>;
35+
// Q3 (not kstar) is the natural kinematic variable for triplets, so it is the default here
36+
using ConfCtrTrackTrackTrack = closepairrejection::ConfCpr<PrefixCtrTrackTrackTrack, true, modes::KinematicVariable::kQ3>;
37+
using ConfCtrTrackTrackV0 = closepairrejection::ConfCpr<PrefixCtrTrackTrackV0, true, modes::KinematicVariable::kQ3>;
38+
using ConfCtrTrackTrackCascade = closepairrejection::ConfCpr<PrefixCtrTrackTrackCascade, true, modes::KinematicVariable::kQ3>;
3739
// generated particles, no cut by default (close triplet rejection corrects a detector effect)
38-
using ConfCtrMcParticleMcParticleMcParticle = closepairrejection::ConfCpr<PrefixCtrMcParticleMcParticleMcParticle, false>;
40+
using ConfCtrMcParticleMcParticleMcParticle = closepairrejection::ConfCpr<PrefixCtrMcParticleMcParticleMcParticle, false, modes::KinematicVariable::kQ3>;
3941

4042
// directory names
4143
constexpr char PrefixTrack1Track2Se[] = "CPR_Track1Track2/SE/";
@@ -81,10 +83,10 @@ class CloseTripletRejectionTrackTrackTrack
8183
CloseTripletRejectionTrackTrackTrack() = default;
8284
~CloseTripletRejectionTrackTrackTrack() = default;
8385

84-
template <typename T>
86+
template <typename T1>
8587
void init(o2::framework::HistogramRegistry* registry,
8688
std::map<closepairrejection::CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
87-
T const& confCpr,
89+
T1 const& confCpr,
8890
int absChargeTrack1,
8991
int absChargeTrack2,
9092
int absChargeTrack3)
@@ -128,10 +130,10 @@ class CloseTripletRejectionTrackTrackV0
128130
CloseTripletRejectionTrackTrackV0() = default;
129131
~CloseTripletRejectionTrackTrackV0() = default;
130132

131-
template <typename T>
133+
template <typename T1>
132134
void init(o2::framework::HistogramRegistry* registry,
133135
std::map<closepairrejection::CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
134-
T const& confCpr,
136+
T1 const& confCpr,
135137
int absChargeTrack1,
136138
int absChargeTrack2)
137139
{
@@ -225,10 +227,10 @@ class CloseTripletRejectionMcParticleMcParticleMcParticle
225227
CloseTripletRejectionMcParticleMcParticleMcParticle() = default;
226228
~CloseTripletRejectionMcParticleMcParticleMcParticle() = default;
227229

228-
template <typename T>
230+
template <typename T1>
229231
void init(o2::framework::HistogramRegistry* registry,
230232
std::map<closepairrejection::CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
231-
T const& confCpr)
233+
T1 const& confCpr)
232234
{
233235
mCtr12.init(registry, specs, confCpr);
234236
mCtr23.init(registry, specs, confCpr);

‎PWGCF/Femto/Core/histManager.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,19 @@ constexpr const char* getHistDesc(EnumType variable, const ArrayType& array)
8585

8686
return it != array.end() ? it->histdesc.data() : "";
8787
}
88+
89+
// Replace the x-axis segment of a "title; x axis; y axis[; z axis...]" histogram description
90+
// with newTitle. Used to patch a static HistTable description at runtime once the actual axis
91+
// quantity (e.g. which momentum type, which kinematic variable) is resolved from a Configurable.
92+
inline std::string replaceFirstAxisTitle(std::string_view desc, std::string_view newTitle)
93+
{
94+
std::string result(desc);
95+
const auto first = result.find(';');
96+
const auto second = (first == std::string::npos) ? std::string::npos : result.find(';', first + 1);
97+
if (second != std::string::npos) {
98+
result.replace(first + 1, second - first - 1, " " + std::string(newTitle) + " ");
99+
}
100+
return result;
101+
}
88102
} // namespace o2::analysis::femto::histmanager
89103
#endif // PWGCF_FEMTO_CORE_HISTMANAGER_H_

‎PWGCF/Femto/Core/mcBuilder.h‎

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -673,25 +673,11 @@ class McBuilder
673673
if (!mcParticle.has_mothers()) {
674674
return -1;
675675
}
676-
auto motherIds = mcParticle.mothersIds();
677-
// adapted these checks from MCUtils in PWGEM
678-
const int defaultMotherSize = 2;
679-
std::vector<int> allMotherIds;
680-
if (motherIds.size() == defaultMotherSize && motherIds[1] > motherIds[0]) {
681-
// keep for now, might be needed later
682-
// && ((80 < std::abs(o2::mcgenstatus::getGenStatusCode(p.statusCode())) && std::abs(o2::mcgenstatus::getGenStatusCode(p.statusCode())) < 90) || (100 < std::abs(o2::mcgenstatus::getGenStatusCode(p.statusCode())) && std::abs(o2::mcgenstatus::getGenStatusCode(p.statusCode())) < 110))) {
683-
// Pythia: mother range
684-
for (int i = motherIds[0]; i <= motherIds[1]; i++) {
685-
allMotherIds.push_back(i);
686-
}
687-
} else {
688-
// Otherwise just use them as given
689-
for (const int& id : motherIds) {
690-
allMotherIds.push_back(id);
691-
}
692-
}
676+
// RecoDecay::getOrderedMotherIds() implements the Pythia mother-id-range expansion (gated on the particle's gen status code)
677+
std::vector<int64_t> allMotherIds;
678+
RecoDecay::getOrderedMotherIds(mcParticle, allMotherIds, /*searchUpToQuark=*/true);
693679
// Loop over all mothers
694-
for (const int& i : allMotherIds) {
680+
for (const int64_t& i : allMotherIds) {
695681

696682
if (i < 0 || i >= mcParticles.size()) {
697683
continue;
@@ -722,19 +708,12 @@ class McBuilder
722708
if (!current.has_mothers()) {
723709
break;
724710
}
725-
auto motherIds = current.mothersIds();
726-
int nextIndex = -1;
727-
const int defaultMotherSize = 2;
728-
if (motherIds.size() == defaultMotherSize && motherIds[1] > motherIds[0]) {
729-
nextIndex = motherIds[0];
730-
} else {
731-
for (const int& id : motherIds) {
732-
if (id >= 0 && id < mcParticles.size()) {
733-
nextIndex = id;
734-
break;
735-
}
736-
}
737-
}
711+
// RecoDecay::getOrderedMotherIds() implements the Pythia mother-id-range expansion (gated on
712+
// the particle's gen status code). This function only ever follows a single branch upward,
713+
// so just the first ordered id is used.
714+
std::vector<int64_t> motherIdsOrdered;
715+
RecoDecay::getOrderedMotherIds(current, motherIdsOrdered, /*searchUpToQuark=*/true);
716+
int64_t nextIndex = motherIdsOrdered.empty() ? -1 : motherIdsOrdered.front();
738717

739718
if (nextIndex < 0 || nextIndex >= mcParticles.size()) {
740719
break;

‎PWGCF/Femto/Core/modes.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,22 @@ enum class KinematicVariable : o2::analysis::femto::datatypes::KinematicVariable
282282
kKinematicVariableLast = 4
283283
};
284284

285+
/// axis title for the kinematic variable plotted by CPR / pair- and triplet-cleaner QA histograms
286+
constexpr const char* kinematicVariableToAxisTitle(KinematicVariable type)
287+
{
288+
switch (type) {
289+
case KinematicVariable::kKstar:
290+
return "k* (GeV/#it{c})";
291+
case KinematicVariable::kKt:
292+
return "k_{T} (GeV/#it{c})";
293+
case KinematicVariable::kMt:
294+
return "m_{T} (GeV/#it{c}^{2})";
295+
case KinematicVariable::kQ3:
296+
return "Q_{3} (GeV/#it{c})";
297+
default:
298+
return "kinematic variable (GeV/#it{c})";
299+
}
300+
}
301+
285302
}; // namespace o2::analysis::femto::modes
286303
#endif // PWGCF_FEMTO_CORE_MODES_H_

‎PWGCF/Femto/Core/pairBuilder.h‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ class PairTrackTrackBuilder
9191
std::map<T12, std::vector<o2::framework::AxisSpec>> const& trackHistSpec2,
9292
std::map<T13, std::vector<o2::framework::AxisSpec>> const& pairHistSpec,
9393
std::map<T14, std::vector<o2::framework::AxisSpec>> const& cprHistSpec,
94-
std::map<T15, std::vector<o2::framework::AxisSpec>> const& pairCleanerHistSpec,
95-
int puritySlotMask1 = 1,
96-
int puritySlotMask2 = 1)
94+
std::map<T15, std::vector<o2::framework::AxisSpec>> const& pairCleanerHistSpec)
9795
{
9896

9997
// check if correlate the same tracks or not
@@ -108,8 +106,8 @@ class PairTrackTrackBuilder
108106
if (mSameSpecies) {
109107
mTrackCleaner1.init(confTrackCleaner1);
110108

111-
mTrackHistManagerSe1.template init<modeSe>(registry, trackHistSpec1, confTrackSelection1, puritySlotMask1);
112-
mTrackHistManagerMe1.template init<modeMe>(registry, trackHistSpec1, confTrackSelection1, puritySlotMask1);
109+
mTrackHistManagerSe1.template init<modeSe>(registry, trackHistSpec1, confTrackSelection1);
110+
mTrackHistManagerMe1.template init<modeMe>(registry, trackHistSpec1, confTrackSelection1);
113111

114112
mPairHistManagerSe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection1.pdgCodeAbs.value);
115113
mPairHistManagerSe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection1.chargeAbs.value);
@@ -121,10 +119,10 @@ class PairTrackTrackBuilder
121119
} else {
122120
mTrackCleaner1.init(confTrackCleaner1);
123121
mTrackCleaner2.init(confTrackCleaner2);
124-
mTrackHistManagerSe1.template init<modeSe>(registry, trackHistSpec1, confTrackSelection1, puritySlotMask1);
125-
mTrackHistManagerSe2.template init<modeSe>(registry, trackHistSpec2, confTrackSelection2, puritySlotMask2);
126-
mTrackHistManagerMe1.template init<modeMe>(registry, trackHistSpec1, confTrackSelection1, puritySlotMask1);
127-
mTrackHistManagerMe2.template init<modeMe>(registry, trackHistSpec2, confTrackSelection2, puritySlotMask2);
122+
mTrackHistManagerSe1.template init<modeSe>(registry, trackHistSpec1, confTrackSelection1);
123+
mTrackHistManagerSe2.template init<modeSe>(registry, trackHistSpec2, confTrackSelection2);
124+
mTrackHistManagerMe1.template init<modeMe>(registry, trackHistSpec1, confTrackSelection1);
125+
mTrackHistManagerMe2.template init<modeMe>(registry, trackHistSpec2, confTrackSelection2);
128126

129127
mPairHistManagerSe.setMass(confTrackSelection1.pdgCodeAbs.value, confTrackSelection2.pdgCodeAbs.value);
130128
mPairHistManagerSe.setCharge(confTrackSelection1.chargeAbs.value, confTrackSelection2.chargeAbs.value);

0 commit comments

Comments
 (0)