Skip to content

Commit 2c3fe41

Browse files
committed
Fix linter errors
1 parent 2a5ffc7 commit 2c3fe41

File tree

1 file changed

+47
-51
lines changed

1 file changed

+47
-51
lines changed

PWGEM/PhotonMeson/Tasks/photonhbt.cxx

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ enum class PairTruthType : uint8_t {
120120
Pi0Daughters,
121121
};
122122

123-
struct photonhbt {
123+
static constexpr float kMinMagnitude = 1e-12f;
124+
static constexpr float kMinCosine = 1e-12f;
125+
static constexpr float kMinSigma = 1e-9;
126+
127+
struct Photonhbt {
124128

125129
template <is_iterator TGamma, is_table TSubInfos>
126130
static inline V0Combo classifyV0Combo(TGamma const& g)
@@ -231,10 +235,10 @@ struct photonhbt {
231235
Configurable<int> cfgOccupancyEstimator{"cfgOccupancyEstimator", 0, "FT0C:0, Track:1"};
232236
Configurable<int> cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"};
233237

234-
ConfigurableAxis ConfVtxBins{"ConfVtxBins", {VARIABLE_WIDTH, -10.f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"};
235-
ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.f, 5.f, 10.f, 20.f, 30.f, 40.f, 50.f, 60.f, 70.f, 80.f, 90.f, 100.f, 999.f}, "Mixing bins - centrality"};
236-
ConfigurableAxis ConfEPBins{"ConfEPBins", {16, -o2::constants::math::PIHalf, +o2::constants::math::PIHalf}, "Mixing bins - EP angle"};
237-
ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"};
238+
ConfigurableAxis confVtxBins{"confVtxBins", {VARIABLE_WIDTH, -10.f, -8.f, -6.f, -4.f, -2.f, 0.f, 2.f, 4.f, 6.f, 8.f, 10.f}, "Mixing bins - z-vertex"};
239+
ConfigurableAxis confCentBins{"confCentBins", {VARIABLE_WIDTH, 0.f, 5.f, 10.f, 20.f, 30.f, 40.f, 50.f, 60.f, 70.f, 80.f, 90.f, 100.f, 999.f}, "Mixing bins - centrality"};
240+
ConfigurableAxis confEPBinsBins{"confEPBinsBins", {16, -o2::constants::math::PIHalf, +o2::constants::math::PIHalf}, "Mixing bins - EP angle"};
241+
ConfigurableAxis confOccupancyBins{"confOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"};
238242
} mixing;
239243

240244
// ─── Centrality slection ─────────────────────────────────────────────────
@@ -340,7 +344,7 @@ struct photonhbt {
340344
Configurable<float> cfgMaxTPCNsigmaEl{"cfgMaxTPCNsigmaEl", +3.5, "max TPC nsigma electron"};
341345
} pcmcuts;
342346

343-
~photonhbt()
347+
~Photonhbt()
344348
{
345349
delete emh1;
346350
emh1 = nullptr;
@@ -372,7 +376,7 @@ struct photonhbt {
372376
return false;
373377
const float sE = ggpaircuts.cfgEllipseSigEta.value;
374378
const float sP = ggpaircuts.cfgEllipseSigPhi.value;
375-
if (sE < 1e-9f || sP < 1e-9f)
379+
if (sE < kMinSigma || sP < kMinSigma)
376380
return false;
377381
return (deta / sE) * (deta / sE) + (dphi / sP) * (dphi / sP) < ggpaircuts.cfgEllipseR2.value;
378382
}
@@ -388,12 +392,15 @@ struct photonhbt {
388392

389393
inline bool passAsymmetryCut(float pt1, float pt2) const
390394
{
391-
if (ggpaircuts.cfgMaxAsymmetry.value < 0.f) // ← .value hinzufügen
395+
if (ggpaircuts.cfgMaxAsymmetry.value < 0.f) {
392396
return true;
397+
}
398+
393399
const float sum = pt1 + pt2;
394-
if (sum < 1e-9f)
400+
if (sum < kMinSigma) {
395401
return false;
396-
return std::fabs(pt1 - pt2) / sum < ggpaircuts.cfgMaxAsymmetry.value; // ← hier auch
402+
}
403+
return std::fabs(pt1 - pt2) / sum < ggpaircuts.cfgMaxAsymmetry.value;
397404
}
398405

399406
inline bool passQinvQAGate(float qinv) const
@@ -423,7 +430,7 @@ struct photonhbt {
423430
ROOT::Math::PxPyPzEVector p1cm = boost(p1);
424431
ROOT::Math::XYZVector pairDir(pair.Px(), pair.Py(), pair.Pz());
425432
ROOT::Math::XYZVector p1cmDir(p1cm.Px(), p1cm.Py(), p1cm.Pz());
426-
if (pairDir.R() < 1e-9 || p1cmDir.R() < 1e-9)
433+
if (pairDir.R() < kMinSigma || p1cmDir.R() < kMinSigma)
427434
return -1.f;
428435
return static_cast<float>(pairDir.Unit().Dot(p1cmDir.Unit()));
429436
}
@@ -450,7 +457,7 @@ struct photonhbt {
450457
const int b = static_cast<int>(
451458
std::lower_bound(edges.begin(), edges.end(), val) - edges.begin()) -
452459
1;
453-
return clampBin(b, static_cast<int>(edges.size()) - 2);
460+
return clampBin(b, static_cast<int>(edges.size()) - 2); //
454461
}
455462

456463
template <int ev_id, int step_id>
@@ -461,15 +468,15 @@ struct photonhbt {
461468
return "Pair/same/QA/Before/";
462469
if constexpr (step_id == 1)
463470
return "Pair/same/QA/AfterDRCosOA/";
464-
if constexpr (step_id == 2)
471+
if constexpr (step_id == 2) // o2-linter: disable=magic-number (just counting the step of a cut)
465472
return "Pair/same/QA/AfterRZ/";
466473
return "Pair/same/QA/AfterEllipse/";
467474
} else {
468475
if constexpr (step_id == 0)
469476
return "Pair/mix/QA/Before/";
470477
if constexpr (step_id == 1)
471478
return "Pair/mix/QA/AfterDRCosOA/";
472-
if constexpr (step_id == 2)
479+
if constexpr (step_id == 2) // o2-linter: disable=magic-number (just counting the step of a cut)
473480
return "Pair/mix/QA/AfterRZ/";
474481
return "Pair/mix/QA/AfterEllipse/";
475482
}
@@ -486,10 +493,10 @@ struct photonhbt {
486493
void init(InitContext& /*context*/)
487494
{
488495
mRunNumber = 0;
489-
parseBins(mixing.ConfVtxBins, ztxBinEdges);
490-
parseBins(mixing.ConfCentBins, centBinEdges);
491-
parseBins(mixing.ConfEPBins, epBinEgdes);
492-
parseBins(mixing.ConfOccupancyBins, occBinEdges);
496+
parseBins(mixing.confVtxBins, ztxBinEdges);
497+
parseBins(mixing.confCentBins, centBinEdges);
498+
parseBins(mixing.confEPBinsBins, epBinEgdes);
499+
parseBins(mixing.confOccupancyBins, occBinEdges);
493500
emh1 = new MyEMH(mixing.ndepth);
494501
emh2 = new MyEMH(mixing.ndepth);
495502
o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry);
@@ -601,7 +608,7 @@ struct photonhbt {
601608
fRegistryPairQA.add((path + "hDeltaPhiPhiKt").c_str(), "#Delta#phi,#phi_{pair},k_{T}", kTHnSparseD, {axisDeltaPhi, axisPhi, axisKt}, true);
602609
fRegistryPairQA.add((path + "hDeltaPhiEtaKt").c_str(), "#Delta#phi,#eta_{pair},k_{T}", kTHnSparseD, {axisDeltaPhi, axisEta, axisKt}, true);
603610

604-
// Delta Eta Dleta Phi Stuff
611+
// Delta Eta Delta Phi Diagnostics
605612
fRegistryPairQA.add((path + "hPhiVsEtaKt").c_str(), "#phi_{pair},#eta_{pair},k_{T}", kTHnSparseD, {axisPhi, axisEta, axisKt}, true);
606613
fRegistryPairQA.add((path + "hSparseDeltaRDeltaZKt").c_str(), "|R_{1}-R_{2}|,#Delta z,k_{T}", kTHnSparseD, {axisDeltaR, axisDeltaZ, axisKt}, true);
607614
}
@@ -725,7 +732,7 @@ struct photonhbt {
725732
return "SinglePhoton/Before/";
726733
if constexpr (step_id == 1)
727734
return "SinglePhoton/AfterDRCosOA/";
728-
if constexpr (step_id == 2)
735+
if constexpr (step_id == 2) // o2-linter: disable=magic-number (just counting the step of a cut)
729736
return "SinglePhoton/AfterRZ/";
730737
return "SinglePhoton/AfterEllipse/";
731738
}
@@ -775,10 +782,7 @@ struct photonhbt {
775782
}
776783
float deta_pair = v1.Eta() - v2.Eta();
777784
float dphi_pair = v1.Phi() - v2.Phi();
778-
while (dphi_pair > o2::constants::math::PI)
779-
dphi_pair -= o2::constants::math::TwoPI;
780-
while (dphi_pair < -o2::constants::math::PI)
781-
dphi_pair += o2::constants::math::TwoPI;
785+
dphi_pair = RecoDecay::constrainAngle(dphi_pair, -o2::constants::math::PI);
782786
if constexpr (ev_id == 0) {
783787
fRegistry.fill(HIST("Pair/same/hSparse_DEtaDPhi_qinv_kT"), deta_pair, dphi_pair, qinv, kt, weight);
784788
} else {
@@ -845,10 +849,7 @@ struct photonhbt {
845849
}
846850
float deta_pair = v1.Eta() - v2.Eta();
847851
float dphi_pair = v1.Phi() - v2.Phi();
848-
while (dphi_pair > o2::constants::math::PI)
849-
dphi_pair -= o2::constants::math::TwoPI;
850-
while (dphi_pair < -o2::constants::math::PI)
851-
dphi_pair += o2::constants::math::TwoPI;
852+
dphi_pair = RecoDecay::constrainAngle(dphi_pair, -o2::constants::math::PI);
852853
if constexpr (ev_id == 0) {
853854
fRegistry.fill(HIST("Pair/same/hSparse_DEtaDPhi_qinv_kT"), deta_pair, dphi_pair, qinv, kt, weight);
854855
} else {
@@ -877,7 +878,7 @@ struct photonhbt {
877878
o.deltaR3D = std::sqrt(o.dx * o.dx + o.dy * o.dy + o.dz * o.dz);
878879
ROOT::Math::XYZVector cp1(o.x1, o.y1, o.z1), cp2(o.x2, o.y2, o.z2);
879880
const float mag1 = std::sqrt(cp1.Mag2()), mag2 = std::sqrt(cp2.Mag2());
880-
if (mag1 < 1e-12f || mag2 < 1e-12f) {
881+
if (mag1 < kMinMagnitude || mag2 < kMinMagnitude) {
881882
o.valid = false;
882883
return o;
883884
}
@@ -888,7 +889,7 @@ struct photonhbt {
888889
if (o.opa > o2::constants::math::PI)
889890
o.opa -= o2::constants::math::PI;
890891
o.cosOA = std::cos(o.opa / 2.f);
891-
o.drOverCosOA = (std::fabs(o.cosOA) < 1e-12f) ? 1e12f : (o.deltaR3D / o.cosOA);
892+
o.drOverCosOA = (std::fabs(o.cosOA) < kMinCosine) ? 1e12f : (o.deltaR3D / o.cosOA);
892893
o.v1 = ROOT::Math::PtEtaPhiMVector(g1.pt(), g1.eta(), g1.phi(), 0.f);
893894
o.v2 = ROOT::Math::PtEtaPhiMVector(g2.pt(), g2.eta(), g2.phi(), 0.f);
894895
o.k12 = 0.5f * (o.v1 + o.v2);
@@ -937,7 +938,7 @@ struct photonhbt {
937938
fRegistryPairQA.fill(HIST(base) + HIST("hDeltaR3DKt"), o.deltaR3D, o.kt);
938939

939940
const float sE = ggpaircuts.cfgEllipseSigEta.value, sP = ggpaircuts.cfgEllipseSigPhi.value;
940-
if (sE > 1e-9f && sP > 1e-9f)
941+
if (sE > kMinSigma && sP > kMinSigma)
941942
fRegistryPairQA.fill(HIST(base) + HIST("hEllipseVal"), (o.deta / sE) * (o.deta / sE) + (o.dphi / sP) * (o.dphi / sP));
942943
}
943944

@@ -963,7 +964,7 @@ struct photonhbt {
963964
info.motherId = mothIdPos;
964965
const auto mother = mcParticles.iteratorAt(mothIdPos);
965966
info.motherPdg = mother.pdgCode();
966-
info.isTruePhoton = (info.motherPdg == 22);
967+
info.isTruePhoton = (info.motherPdg == kGamma);
967968
info.isPhysicalPrimary = mother.isPhysicalPrimary();
968969
return info;
969970
}
@@ -1049,7 +1050,7 @@ struct photonhbt {
10491050
const int gm1 = ph1.mothersIds()[0], gm2 = ph2.mothersIds()[0];
10501051
if (gm1 != gm2)
10511052
return false;
1052-
return (std::abs(mcParticles.iteratorAt(gm1).pdgCode()) == 111);
1053+
return (std::abs(mcParticles.iteratorAt(gm1).pdgCode()) == kPi0);
10531054
}
10541055

10551056
static constexpr std::string_view pairTruthLabel(PairTruthType t)
@@ -1073,7 +1074,6 @@ struct photonhbt {
10731074
}
10741075
void addMCHistograms()
10751076
{
1076-
// ─── Achsen die nur hier gebraucht werden ────────────────────────────────
10771077
const AxisSpec axisTruthType{{0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5},
10781078
"truth type (1=TrueTrueDistinct,2=TrueTrueSamePhoton,3=SharedMcLeg,"
10791079
"4=TrueFake,5=FakeFake,6=Pi0Daughters)"};
@@ -1214,17 +1214,16 @@ struct photonhbt {
12141214
"#Delta#eta_{#gamma#gamma};#Delta#phi_{#gamma#gamma} (rad)",
12151215
kTH2D, {axisDeltaEta, axisDeltaPhi}, true);
12161216

1217-
// ─── Efficiency: stage vs observables ──────────────────────────
12181217
auto addStageHistos = [&](const char* suffix, const char* title, auto... axes) {
1219-
for (const char* stage : {"truthConverted", "all4LegsThisColl",
1218+
for (const auto& stage : {"truthConverted", "all4LegsThisColl",
12201219
"bothPhotonsBuilt", "bothPhotonsSelected"}) {
12211220
const std::string name = std::string("MC/TruthAO2D/") + suffix + std::string("_") + stage;
12221221
const std::string ttl = std::string(title) + std::string(" [") + stage + "]";
12231222
fRegistryMC.add(name.c_str(), ttl.c_str(), kTHnD, {axes...}, true);
12241223
}
12251224
};
12261225
auto addStageHistos2D = [&](const char* suffix, const char* title, auto ax1, auto ax2) {
1227-
for (const char* stage : {"truthConverted", "all4LegsThisColl",
1226+
for (const auto& stage : {"truthConverted", "all4LegsThisColl",
12281227
"bothPhotonsBuilt", "bothPhotonsSelected"}) {
12291228
const std::string name = std::string("MC/TruthAO2D/") + suffix + std::string("_") + stage;
12301229
fRegistryMC.add(name.c_str(), title, kTH2D, {ax1, ax2}, true);
@@ -1930,14 +1929,14 @@ struct photonhbt {
19301929
if (posMotherId != negMotherId) {
19311930
const auto posMother = emmcParticles.iteratorAt(posMotherId);
19321931
const auto negMother = emmcParticles.iteratorAt(negMotherId);
1933-
if (posMother.pdgCode() == 22 && negMother.pdgCode() == 22) {
1932+
if (posMother.pdgCode() == kGamma && negMother.pdgCode() == kGamma) {
19341933
crossBuildMap[posMotherId].insert(negMotherId);
19351934
crossBuildMap[negMotherId].insert(posMotherId);
19361935
}
19371936
continue;
19381937
}
19391938
const int gammaId = posMotherId;
1940-
if (emmcParticles.iteratorAt(gammaId).pdgCode() != 22)
1939+
if (emmcParticles.iteratorAt(gammaId).pdgCode() != kGamma)
19411940
continue;
19421941
const bool passes = cut.template IsSelected<std::decay_t<decltype(g)>, TLegs>(g);
19431942
auto& info = gammaRecoMap[gammaId];
@@ -1950,7 +1949,7 @@ struct photonhbt {
19501949
trueGammas.reserve(32);
19511950

19521951
for (const auto& g : emmcPartsColl) {
1953-
if (g.pdgCode() != 22)
1952+
if (g.pdgCode() != kGamma)
19541953
continue;
19551954
if (!g.isPhysicalPrimary() && !g.producedByGenerator())
19561955
continue;
@@ -1966,14 +1965,14 @@ struct photonhbt {
19661965

19671966
int posId = -1, negId = -1;
19681967
float rTrue = -1.f;
1969-
for (const int dId : g.daughtersIds()) {
1968+
for (const auto& dId : g.daughtersIds()) {
19701969
if (dId < 0)
19711970
continue;
19721971
const auto d = emmcParticles.iteratorAt(dId);
1973-
if (d.pdgCode() == -11) {
1972+
if (d.pdgCode() == kElectron) {
19741973
posId = dId;
19751974
rTrue = std::sqrt(d.vx() * d.vx() + d.vy() * d.vy());
1976-
} else if (d.pdgCode() == 11)
1975+
} else if (d.pdgCode() == kPositron)
19771976
negId = dId;
19781977
}
19791978
if (posId < 0 || negId < 0)
@@ -1991,13 +1990,11 @@ struct photonhbt {
19911990
const float dpTrE = wrapPhi(static_cast<float>(mcPosE.phi() - mcNegE.phi()));
19921991
const float legDRt = std::sqrt(deTrE * deTrE + dpTrE * dpTrE);
19931992

1994-
// ─── Armenteros-α auf Truth-Niveau ────────────────────────────────────
1995-
// pL = longitudinal momentum of each leg along photon direction
19961993
const float pxG = static_cast<float>(g.px()), pyG = static_cast<float>(g.py()),
19971994
pzG = static_cast<float>(g.pz());
19981995
const float magG = std::sqrt(pxG * pxG + pyG * pyG + pzG * pzG);
19991996
float alphaTrue = 0.f;
2000-
if (magG > 1e-9f) {
1997+
if (magG > kMinSigma) {
20011998
const float ux = pxG / magG, uy = pyG / magG, uz = pzG / magG;
20021999
const float pLpos = static_cast<float>(mcPosE.px()) * ux +
20032000
static_cast<float>(mcPosE.py()) * uy +
@@ -2006,7 +2003,7 @@ struct photonhbt {
20062003
static_cast<float>(mcNegE.py()) * uy +
20072004
static_cast<float>(mcNegE.pz()) * uz;
20082005
const float sumPL = pLpos + pLneg;
2009-
if (std::fabs(sumPL) > 1e-9f)
2006+
if (std::fabs(sumPL) > kMinSigma)
20102007
alphaTrue = (pLpos - pLneg) / sumPL;
20112008
}
20122009

@@ -2018,7 +2015,6 @@ struct photonhbt {
20182015
alphaTrue});
20192016
}
20202017

2021-
// ─── Stage consistency check ──────────────────────────────────────────────
20222018
{
20232019
int nBad = 0;
20242020
for (const auto& tg : trueGammas) {
@@ -2270,7 +2266,7 @@ struct photonhbt {
22702266
perCollisionPCM, perCollisionPCM, fV0PhotonCut, fV0PhotonCut);
22712267
ndf++;
22722268
}
2273-
PROCESS_SWITCH(photonhbt, processAnalysis, "pairing for analysis", true);
2269+
PROCESS_SWITCH(Photonhbt, processAnalysis, "pairing for analysis", true);
22742270

22752271
void processMC(FilteredMyCollisions const& collisions,
22762272
MyV0Photons const& v0photons,
@@ -2286,10 +2282,10 @@ struct photonhbt {
22862282

22872283
ndf++;
22882284
}
2289-
PROCESS_SWITCH(photonhbt, processMC, "MC CF + truth efficiency maps for CF correction", false);
2285+
PROCESS_SWITCH(Photonhbt, processMC, "MC CF + truth efficiency maps for CF correction", false);
22902286
};
22912287

22922288
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
22932289
{
2294-
return WorkflowSpec{adaptAnalysisTask<photonhbt>(cfgc, TaskName{"photonhbt"})};
2290+
return WorkflowSpec{adaptAnalysisTask<Photonhbt>(cfgc)};
22952291
}

0 commit comments

Comments
 (0)