Skip to content

Commit 1d58b83

Browse files
Eloviyosmonira
andauthored
[PWGCF] FemtoUniverse V0 and Cascade Task -- added matrix table for per daughter cpr cuts (#18774)
Co-authored-by: smonira <shirajum.monira@cern.ch>
1 parent 678570f commit 1d58b83

3 files changed

Lines changed: 247 additions & 65 deletions

File tree

‎PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h‎

Lines changed: 209 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "PWGCF/FemtoUniverse/DataModel/FemtoDerived.h"
2525

2626
#include <CommonConstants/PhysicsConstants.h>
27+
#include <Framework/Array2D.h>
2728
#include <Framework/HistogramRegistry.h>
2829
#include <Framework/HistogramSpec.h>
2930
#include <Framework/Logger.h>
@@ -45,10 +46,108 @@
4546
#include <string_view>
4647
#include <vector>
4748

48-
namespace o2::analysis
49+
namespace o2::analysis::femto_universe
4950
{
50-
namespace femto_universe
51+
52+
/// \namespace cpr_track_cascade_cuts
53+
/// \brief Default per-daughter CPR cut table for the track-cascade combination.
54+
/// Rows correspond to the cascade daughters in the order used by FemtoUniverseDetaDphiStar
55+
/// (posChild, negChild, bachelor); columns to the DeltaPhi*/DeltaEta cut values.
56+
namespace cpr_track_cascade_cuts
57+
{
58+
static constexpr int NDaughters = 3;
59+
static constexpr int NCutVars = 4;
60+
61+
// default values for the cuts (all 0.0: rows fall back to the scalar CPR cuts)
62+
constexpr std::array<std::array<double, NCutVars>, NDaughters> Cuts = {{
63+
{0.0, 0.0, 0.0, 0.0}, /* posChild */
64+
{0.0, 0.0, 0.0, 0.0}, /* negChild */
65+
{0.0, 0.0, 0.0, 0.0} /* bachelor */
66+
}};
67+
68+
// row labels
69+
static const std::vector<std::string> labelsDaughter = {"posChild", "negChild", "bachelor"};
70+
71+
// column labels
72+
static const std::vector<std::string> labelsCutVar = {"dPhiStarMin", "dPhiStarMax", "dEtaMin", "dEtaMax"};
73+
} // namespace cpr_track_cascade_cuts
74+
75+
/// \namespace cpr_cascade_cascade_cuts
76+
/// \brief Default per-pair CPR cut table for the cascade-cascade combination.
77+
/// Rows correspond to the daughter pairs in the order of CascChildTable
78+
/// (offsets relative to the cascade index: -3 posChild, -2 negChild, -1 bachelor);
79+
/// columns to the DeltaPhi*/DeltaEta cut values.
80+
namespace cpr_cascade_cascade_cuts
81+
{
82+
static constexpr int NPairs = 7;
83+
static constexpr int NCutVars = 4;
84+
85+
// daughter pair table: row i = {offset of daughter of cascade 1, offset of daughter of cascade 2}
86+
// ordered from pos to bach (both indices sorted pos < neg < bach)
87+
constexpr std::array<std::array<int, 2>, NPairs> CascChildTable = {{{-3, -3}, {-3, -1}, {-2, -2}, {-2, -1}, {-1, -1}, {-1, -2}, {-1, -3}}};
88+
89+
// default values for the cuts (all 0.0: rows fall back to the scalar CPR cuts)
90+
constexpr std::array<std::array<double, NCutVars>, NPairs> Cuts = {{
91+
{0.0, 0.0, 0.0, 0.0}, /* pos-pos */
92+
{0.0, 0.0, 0.0, 0.0}, /* pos-bach */
93+
{0.0, 0.0, 0.0, 0.0}, /* neg-neg */
94+
{0.0, 0.0, 0.0, 0.0}, /* neg-bach */
95+
{0.0, 0.0, 0.0, 0.0}, /* bach-bach */
96+
{0.0, 0.0, 0.0, 0.0}, /* bach-neg */
97+
{0.0, 0.0, 0.0, 0.0} /* bach-pos */
98+
}};
99+
100+
// row labels
101+
static const std::vector<std::string> labelsPair = {"pos-pos", "pos-bach", "neg-neg", "neg-bach", "bach-bach", "bach-neg", "bach-pos"};
102+
103+
// column labels
104+
static const std::vector<std::string> labelsCutVar = {"dPhiStarMin", "dPhiStarMax", "dEtaMin", "dEtaMax"};
105+
} // namespace cpr_cascade_cascade_cuts
106+
107+
/// \namespace cpr_track_v0_cuts
108+
/// \brief Default per-daughter CPR cut table for the track-V0 combination.
109+
/// Rows correspond to the V0 daughters in the order used by FemtoUniverseDetaDphiStar
110+
/// (posChild, negChild); columns to the DeltaPhi*/DeltaEta cut values.
111+
/// Note: the track-V0 branch applies an elliptic cut, so only dPhiStarMax and dEtaMax are used.
112+
namespace cpr_track_v0_cuts
51113
{
114+
static constexpr int NDaughters = 2;
115+
static constexpr int NCutVars = 4;
116+
117+
// default values for the cuts (all 0.0: rows fall back to the scalar CPR cuts)
118+
constexpr std::array<std::array<double, NCutVars>, NDaughters> Cuts = {{
119+
{0.0, 0.0, 0.0, 0.0}, /* posChild */
120+
{0.0, 0.0, 0.0, 0.0} /* negChild */
121+
}};
122+
123+
// row labels
124+
static const std::vector<std::string> labelsDaughter = {"posChild", "negChild"};
125+
126+
// column labels
127+
static const std::vector<std::string> labelsCutVar = {"dPhiStarMin", "dPhiStarMax", "dEtaMin", "dEtaMax"};
128+
} // namespace cpr_track_v0_cuts
129+
130+
/// \namespace cpr_v0_v0_cuts
131+
/// \brief Default per-pair CPR cut table for the V0-V0 combination.
132+
/// Rows correspond to the daughter pairs checked by FemtoUniverseDetaDphiStar
133+
/// (pos-pos, neg-neg); columns to the DeltaPhi*/DeltaEta cut values.
134+
namespace cpr_v0_v0_cuts
135+
{
136+
static constexpr int NPairs = 2;
137+
static constexpr int NCutVars = 4;
138+
139+
// default values for the cuts (all 0.0: rows fall back to the scalar CPR cuts)
140+
constexpr std::array<std::array<double, NCutVars>, NPairs> Cuts = {{
141+
{0.0, 0.0, 0.0, 0.0}, /* pos-pos */
142+
{0.0, 0.0, 0.0, 0.0} /* neg-neg */
143+
}};
144+
145+
// row labels
146+
static const std::vector<std::string> labelsPair = {"pos-pos", "neg-neg"};
147+
148+
// column labels
149+
static const std::vector<std::string> labelsCutVar = {"dPhiStarMin", "dPhiStarMax", "dEtaMin", "dEtaMax"};
150+
} // namespace cpr_v0_v0_cuts
52151

53152
/// \class FemtoUniverseDetaDphiStar
54153
/// \brief Class to check particles for the close pair rejection.
@@ -200,6 +299,19 @@ class FemtoUniverseDetaDphiStar
200299
}
201300
}
202301

302+
/// Set the per-daughter/pair CPR cut table for this combination.
303+
/// For track-cascade: rows = posChild, negChild, bachelor.
304+
/// For cascade-cascade: rows = the daughter pairs of cpr_cascade_cascade_cuts::CascChildTable.
305+
/// For track-V0: rows = posChild, negChild (elliptic cut: only dPhiStarMax/dEtaMax are used).
306+
/// For V0-V0: rows = pos-pos, neg-neg (all columns used for the rectangular cut;
307+
/// only dPhiStarMax/dEtaMax for the elliptic cut).
308+
/// Columns: dPhiStarMin, dPhiStarMax, dEtaMin, dEtaMax.
309+
/// A row left at all zeros falls back to the scalar cuts set in init().
310+
void setCPRCuts(const o2::framework::LabeledArray<double>& lCPRCuts)
311+
{
312+
mCPRCuts = lCPRCuts;
313+
}
314+
203315
template <typename t1, typename t2, typename t3>
204316
void init_kT(o2::framework::HistogramRegistry* registry, t1& ktbins, t3& fDeltaEtaAxis, t3& fDeltaPhiStarAxis, t2& ldeltaphistarcutmin, t2& ldeltaphistarcutmax, t2& ldeltaetacutmin, t2& ldeltaetacutmax, t2& ldeltaphistarcutFractionmin, t2& ldeltaphistarcutFractionmax, t2& ldeltaetacutFractionmin, t2& ldeltaetacutFractionmax, bool filldEtadPhiTPCcls)
205317
{
@@ -221,7 +333,11 @@ class FemtoUniverseDetaDphiStar
221333
for (int j = 1; j < static_cast<int>(ktBins.size() - 1); j++) {
222334
std::string histSuffixkT1 = std::to_string(static_cast<int>(ktBins[j] * 100.0));
223335
std::string histSuffixkT2 = std::to_string(static_cast<int>(ktBins[j + 1] * 100.0));
224-
std::string histFolderkT = "kT_" + histSuffixkT1 + "_" + histSuffixkT2 + "/";
336+
std::string histFolderkT = "kT_";
337+
histFolderkT += histSuffixkT1;
338+
histFolderkT += "_";
339+
histFolderkT += histSuffixkT2;
340+
histFolderkT += "/";
225341
histdetadphisamebeforekT[j] = mHistogramRegistry->add<TH2>((dirName + histFolderkT + "detadphidetadphiBeforeSame").c_str(), "; #Delta #eta; #Delta #phi", o2::framework::HistType::kTH2F, {{fDeltaEtaAxis}, {fDeltaPhiStarAxis}});
226342
histdetadphimixedbeforekT[j] = mHistogramRegistry->add<TH2>((dirName + histFolderkT + "detadphidetadphiBeforeMixed").c_str(), "; #Delta #eta; #Delta #phi", o2::framework::HistType::kTH2F, {{fDeltaEtaAxis}, {fDeltaPhiStarAxis}});
227343
histdetadphisameafterkT[j] = mHistogramRegistry->add<TH2>((dirName + histFolderkT + "detadphidetadphiAfterSame").c_str(), "; #Delta #eta; #Delta #phi", o2::framework::HistType::kTH2F, {{fDeltaEtaAxis}, {fDeltaPhiStarAxis}});
@@ -261,16 +377,15 @@ class FemtoUniverseDetaDphiStar
261377

262378
if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) {
263379
return true;
380+
}
381+
if (ChosenEventType == femto_universe_container::EventType::same) {
382+
histdetadpisame[0][1]->Fill(deta, dphiAvg);
383+
} else if (ChosenEventType == femto_universe_container::EventType::mixed) {
384+
histdetadpimixed[0][1]->Fill(deta, dphiAvg);
264385
} else {
265-
if (ChosenEventType == femto_universe_container::EventType::same) {
266-
histdetadpisame[0][1]->Fill(deta, dphiAvg);
267-
} else if (ChosenEventType == femto_universe_container::EventType::mixed) {
268-
histdetadpimixed[0][1]->Fill(deta, dphiAvg);
269-
} else {
270-
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
271-
}
272-
return false;
386+
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
273387
}
388+
return false;
274389

275390
} else if constexpr (kPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && kPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kV0) {
276391
/// Track-V0 combination
@@ -294,7 +409,19 @@ class FemtoUniverseDetaDphiStar
294409
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
295410
}
296411

297-
if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) {
412+
// Per-daughter cuts from the LabeledArray; rows left at all zeros fall back to the scalar cuts
413+
// (the track-V0 branch applies an elliptic cut, so only the Max values are used)
414+
float dPhiStarMax = cutDeltaPhiStarMax;
415+
float dEtaMax = cutDeltaEtaMax;
416+
if (mCPRCuts.rows() > 0 && i < static_cast<int>(mCPRCuts.rows())) {
417+
double* cutsDaughter = mCPRCuts.getRow(i);
418+
if (cutsDaughter[0] != 0. || cutsDaughter[1] != 0. || cutsDaughter[2] != 0. || cutsDaughter[3] != 0.) {
419+
dPhiStarMax = static_cast<float>(cutsDaughter[1]);
420+
dEtaMax = static_cast<float>(cutsDaughter[3]);
421+
}
422+
}
423+
424+
if (std::pow(dphiAvg, 2) / std::pow(dPhiStarMax, 2) + std::pow(deta, 2) / std::pow(dEtaMax, 2) < 1.) {
298425
pass = true;
299426
} else {
300427
if (ChosenEventType == femto_universe_container::EventType::same) {
@@ -331,9 +458,24 @@ class FemtoUniverseDetaDphiStar
331458
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
332459
}
333460

334-
if (V0V0rect && (dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) {
335-
pass = true;
336-
} else if (!V0V0rect && std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) {
461+
// Per-pair cuts from the LabeledArray; rows left at all zeros fall back to the scalar cuts
462+
float dPhiStarMin = cutDeltaPhiStarMin;
463+
float dPhiStarMax = cutDeltaPhiStarMax;
464+
float dEtaMin = cutDeltaEtaMin;
465+
float dEtaMax = cutDeltaEtaMax;
466+
if (mCPRCuts.rows() > 0 && i < static_cast<int>(mCPRCuts.rows())) {
467+
double* cutsPair = mCPRCuts.getRow(i);
468+
if (cutsPair[0] != 0. || cutsPair[1] != 0. || cutsPair[2] != 0. || cutsPair[3] != 0.) {
469+
dPhiStarMin = static_cast<float>(cutsPair[0]);
470+
dPhiStarMax = static_cast<float>(cutsPair[1]);
471+
dEtaMin = static_cast<float>(cutsPair[2]);
472+
dEtaMax = static_cast<float>(cutsPair[3]);
473+
}
474+
}
475+
476+
const bool isClose = V0V0rect ? ((dphiAvg > dPhiStarMin) && (dphiAvg < dPhiStarMax) && (deta > dEtaMin) && (deta < dEtaMax))
477+
: (std::pow(dphiAvg, 2) / std::pow(dPhiStarMax, 2) + std::pow(deta, 2) / std::pow(dEtaMax, 2) < 1.);
478+
if (isClose) {
337479
pass = true;
338480
} else {
339481
if (ChosenEventType == femto_universe_container::EventType::same) {
@@ -354,10 +496,9 @@ class FemtoUniverseDetaDphiStar
354496
}
355497

356498
bool pass = false;
357-
static constexpr int CascChildTable[][2] = {{-1, -1}, {-1, -2}, {-1, -3}, {-2, -2}, {-3, -3}, {-2, -1}, {-3, -1}};
358-
for (int i = 0; i < 7; i++) {
359-
auto indexOfDaughterpart1 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + CascChildTable[i][0];
360-
auto indexOfDaughterpart2 = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + CascChildTable[i][1];
499+
for (int i = 0; i < cpr_cascade_cascade_cuts::NPairs; i++) {
500+
auto indexOfDaughterpart1 = (ChosenEventType == femto_universe_container::EventType::mixed ? part1.globalIndex() : part1.index()) + cpr_cascade_cascade_cuts::CascChildTable[i][0];
501+
auto indexOfDaughterpart2 = (ChosenEventType == femto_universe_container::EventType::mixed ? part2.globalIndex() : part2.index()) + cpr_cascade_cascade_cuts::CascChildTable[i][1];
361502
auto daughterpart1 = particles.begin() + indexOfDaughterpart1;
362503
auto daughterpart2 = particles.begin() + indexOfDaughterpart2;
363504
if (isSameSignCPR && (daughterpart1.mAntiLambda() != daughterpart2.mAntiLambda())) // mAntiLambda() is used here as sign getter
@@ -372,7 +513,22 @@ class FemtoUniverseDetaDphiStar
372513
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
373514
}
374515

375-
if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) {
516+
// Per-pair cuts from the LabeledArray; rows left at all zeros fall back to the scalar cuts
517+
float dPhiStarMin = cutDeltaPhiStarMin;
518+
float dPhiStarMax = cutDeltaPhiStarMax;
519+
float dEtaMin = cutDeltaEtaMin;
520+
float dEtaMax = cutDeltaEtaMax;
521+
if (mCPRCuts.rows() > 0 && i < static_cast<int>(mCPRCuts.rows())) {
522+
double* cutsPair = mCPRCuts.getRow(i);
523+
if (cutsPair[0] != 0. || cutsPair[1] != 0. || cutsPair[2] != 0. || cutsPair[3] != 0.) {
524+
dPhiStarMin = static_cast<float>(cutsPair[0]);
525+
dPhiStarMax = static_cast<float>(cutsPair[1]);
526+
dEtaMin = static_cast<float>(cutsPair[2]);
527+
dEtaMax = static_cast<float>(cutsPair[3]);
528+
}
529+
}
530+
531+
if ((dphiAvg > dPhiStarMin) && (dphiAvg < dPhiStarMax) && (deta > dEtaMin) && (deta < dEtaMax)) {
376532
pass = true;
377533
} else {
378534
if (ChosenEventType == femto_universe_container::EventType::same) {
@@ -408,7 +564,22 @@ class FemtoUniverseDetaDphiStar
408564
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
409565
}
410566

411-
if ((dphiAvg > cutDeltaPhiStarMin) && (dphiAvg < cutDeltaPhiStarMax) && (deta > cutDeltaEtaMin) && (deta < cutDeltaEtaMax)) {
567+
// Per-daughter cuts from the LabeledArray; rows left at all zeros fall back to the scalar cuts
568+
float dPhiStarMin = cutDeltaPhiStarMin;
569+
float dPhiStarMax = cutDeltaPhiStarMax;
570+
float dEtaMin = cutDeltaEtaMin;
571+
float dEtaMax = cutDeltaEtaMax;
572+
if (mCPRCuts.rows() > 0 && i < static_cast<int>(mCPRCuts.rows())) {
573+
double* cutsDaughter = mCPRCuts.getRow(i);
574+
if (cutsDaughter[0] != 0. || cutsDaughter[1] != 0. || cutsDaughter[2] != 0. || cutsDaughter[3] != 0.) {
575+
dPhiStarMin = static_cast<float>(cutsDaughter[0]);
576+
dPhiStarMax = static_cast<float>(cutsDaughter[1]);
577+
dEtaMin = static_cast<float>(cutsDaughter[2]);
578+
dEtaMax = static_cast<float>(cutsDaughter[3]);
579+
}
580+
}
581+
582+
if ((dphiAvg > dPhiStarMin) && (dphiAvg < dPhiStarMax) && (deta > dEtaMin) && (deta < dEtaMax)) {
412583
pass = true;
413584
} else {
414585
if (ChosenEventType == femto_universe_container::EventType::same) {
@@ -590,16 +761,15 @@ class FemtoUniverseDetaDphiStar
590761

591762
if (std::pow(dphiAvg, 2) / std::pow(cutDeltaPhiStarMax, 2) + std::pow(deta, 2) / std::pow(cutDeltaEtaMax, 2) < 1.) {
592763
return true;
764+
}
765+
if (ChosenEventType == femto_universe_container::EventType::same) {
766+
histdetadpisame[0][1]->Fill(deta, dphiAvg);
767+
} else if (ChosenEventType == femto_universe_container::EventType::mixed) {
768+
histdetadpimixed[0][1]->Fill(deta, dphiAvg);
593769
} else {
594-
if (ChosenEventType == femto_universe_container::EventType::same) {
595-
histdetadpisame[0][1]->Fill(deta, dphiAvg);
596-
} else if (ChosenEventType == femto_universe_container::EventType::mixed) {
597-
histdetadpimixed[0][1]->Fill(deta, dphiAvg);
598-
} else {
599-
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
600-
}
601-
return false;
770+
LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed.";
602771
}
772+
return false;
603773
} else {
604774
LOG(fatal) << "FemtoUniversePairCleaner: Combination of objects not defined - quitting!";
605775
return false;
@@ -885,11 +1055,12 @@ class FemtoUniverseDetaDphiStar
8851055
static constexpr uint32_t kSignPlusMask = 1 << 1;
8861056
static constexpr uint32_t kValue0 = 0;
8871057

888-
float chosenRadii;
889-
float cutDeltaPhiStarMax;
890-
float cutDeltaPhiStarMin;
891-
float cutDeltaEtaMax;
892-
float cutDeltaEtaMin;
1058+
float chosenRadii = 0.f;
1059+
float cutDeltaPhiStarMax = 0.f;
1060+
float cutDeltaPhiStarMin = 0.f;
1061+
float cutDeltaEtaMax = 0.f;
1062+
float cutDeltaEtaMin = 0.f;
1063+
o2::framework::LabeledArray<double> mCPRCuts{}; ///< Per-daughter/pair CPR cuts for this combination (rows: daughters or daughter pairs, cols: dPhiStarMin/dPhiStarMax/dEtaMin/dEtaMax)
8931064

8941065
std::vector<float> cutDeltaPhiStarMaxVector;
8951066
std::vector<float> cutDeltaPhiStarMinVector;
@@ -901,10 +1072,10 @@ class FemtoUniverseDetaDphiStar
9011072
std::vector<float> cutDeltaEtaFractionMaxVector;
9021073
std::vector<float> cutDeltaEtaFractionMinVector;
9031074

904-
float magfield;
1075+
float magfield = 0.f;
9051076
bool plotForEveryRadii = false;
906-
float cutPhiInvMassLow;
907-
float cutPhiInvMassHigh;
1077+
float cutPhiInvMassLow = 0.f;
1078+
float cutPhiInvMassHigh = 0.f;
9081079
bool isSameSignCPR = false;
9091080
std::vector<double> ktBins;
9101081

@@ -1050,7 +1221,6 @@ class FemtoUniverseDetaDphiStar
10501221
}
10511222
};
10521223

1053-
} /* namespace femto_universe */
1054-
} /* namespace o2::analysis */
1224+
} // namespace o2::analysis::femto_universe
10551225

10561226
#endif // PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSEDETADPHISTAR_H_

0 commit comments

Comments
 (0)