Skip to content

Commit 46afdd0

Browse files
author
Bong-Hwi Lim
committed
[PWGLF] Fix clang-tidy findings in the Omega(2012) analysis and ML exporter
1 parent a24fd98 commit 46afdd0

4 files changed

Lines changed: 41 additions & 39 deletions

File tree

‎PWGLF/Core/Omega2012AnalysisCore.h‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include "PWGLF/Core/Omega2012MlFeatures.h"
2626
#include "PWGLF/Core/ResoAnalysisSelectionCore.h"
27-
#include "PWGLF/DataModel/LFResonanceTables.h"
2827

2928
#include <CommonConstants/PhysicsConstants.h>
3029
#include <Framework/Configurable.h>
@@ -35,6 +34,7 @@
3534

3635
#include <Math/GenVector/VectorUtil.h>
3736
#include <Math/Vector4D.h> // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h)
37+
#include <Math/Vector4Dfwd.h>
3838
#include <TH1.h>
3939
#include <TH2.h>
4040
#include <TPDGCode.h>
@@ -74,27 +74,27 @@ inline constexpr int NGeneratedChannels = 3;
7474

7575
// Last stage passed by a cascade (Xi selection, common to both modes).
7676
enum XiStage : int {
77-
kXiInput = 0, // failed |eta| or pT
78-
kXiKinematics, // passed |eta| and pT
79-
kXiDCA, // passed the cascade DCA to PV
80-
kXiV0Topology, // passed the Lambda topology and mass window
81-
kXiCascTopology, // passed the cascade topology
82-
kXiMass, // passed the Xi mass window
77+
kXiInput = 0, // failed |eta| or pT
78+
kXiKinematics = 1, // passed |eta| and pT
79+
kXiDCA = 2, // passed the cascade DCA to PV
80+
kXiV0Topology = 3, // passed the Lambda topology and mass window
81+
kXiCascTopology = 4, // passed the cascade topology
82+
kXiMass = 5, // passed the Xi mass window
8383
kXiSelected = kXiMass,
84-
kXiNStages
84+
kXiNStages = 6
8585
};
8686

8787
// Last stage passed by a V0 (K0S selection of mode A).
8888
enum K0sStage : int {
89-
kK0sInput = 0, // failed |eta| or pT
90-
kK0sKinematics, // passed |eta| and pT
91-
kK0sTopology, // passed cosPA, daughter DCAs, radius and DCA to PV
92-
kK0sLifetime, // passed the proper lifetime and the minimum qT
93-
kK0sMass, // passed the K0S mass window and the (anti)Lambda rejection
94-
kK0sDaughters, // passed the daughter pion TPC nSigma and crossed rows
95-
kK0sArmenteros, // passed the Armenteros qT > coefficient * |alpha| cut
89+
kK0sInput = 0, // failed |eta| or pT
90+
kK0sKinematics = 1, // passed |eta| and pT
91+
kK0sTopology = 2, // passed cosPA, daughter DCAs, radius and DCA to PV
92+
kK0sLifetime = 3, // passed the proper lifetime and the minimum qT
93+
kK0sMass = 4, // passed the K0S mass window and the (anti)Lambda rejection
94+
kK0sDaughters = 5, // passed the daughter pion TPC nSigma and crossed rows
95+
kK0sArmenteros = 6, // passed the Armenteros qT > coefficient * |alpha| cut
9696
kK0sSelected = kK0sArmenteros,
97-
kK0sNStages
97+
kK0sNStages = 7
9898
};
9999

100100
// The value is the species index of the PID configuration in ResoAnalysisSelectionCore.

‎PWGLF/Core/Omega2012MlFeatures.h‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <Math/GenVector/Boost.h>
2929
#include <Math/GenVector/VectorUtil.h>
3030
#include <Math/Vector4D.h> // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h)
31+
#include <Math/Vector4Dfwd.h>
3132

3233
#include <algorithm>
3334
#include <array>
@@ -368,31 +369,31 @@ struct EncodedValue {
368369
inline EncodedValue encodeNSigma10(int8_t code)
369370
{
370371
if (code == SaturatedLow || code == SaturatedHigh) {
371-
return {0.f, 0.f, 0.f};
372+
return {.value = 0.f, .valid = 0.f, .overflow = 0.f};
372373
}
373-
return {static_cast<float>(code) / NSigmaScale, 1.f, 0.f};
374+
return {.value = static_cast<float>(code) / NSigmaScale, .valid = 1.f, .overflow = 0.f};
374375
}
375376

376377
// micro001 nSigma, as the K1 contract
377378
inline EncodedValue encodePID(float decoded)
378379
{
379380
if (std::isnan(decoded)) {
380-
return {0.f, 0.f, 0.f};
381+
return {.value = 0.f, .valid = 0.f, .overflow = 0.f};
381382
}
382383
if (std::isinf(decoded)) {
383-
return {std::signbit(decoded) ? -MicroPidOverflow : MicroPidOverflow, 1.f, 1.f};
384+
return {.value = std::signbit(decoded) ? -MicroPidOverflow : MicroPidOverflow, .valid = 1.f, .overflow = 1.f};
384385
}
385-
return {decoded, 1.f, 0.f};
386+
return {.value = decoded, .valid = 1.f, .overflow = 0.f};
386387
}
387388

388389
// micro001 DCA, as the K1 contract
389390
inline EncodedValue encodeDCA(float decoded)
390391
{
391392
if (!std::isfinite(decoded)) {
392-
return {0.f, 0.f, 0.f};
393+
return {.value = 0.f, .valid = 0.f, .overflow = 0.f};
393394
}
394395
const bool overflow = decoded == o2::aod::resomicrodaughter001::DCAEncoding::MaxDCA;
395-
return {decoded, 1.f, overflow ? 1.f : 0.f};
396+
return {.value = decoded, .valid = 1.f, .overflow = overflow ? 1.f : 0.f};
396397
}
397398

398399
template <std::size_t N>
@@ -501,7 +502,7 @@ void appendTrack(Writer<N>& w, TrackSnapshot const& track)
501502
w.addFull(encodePID(decoded));
502503
}
503504
for (const float& decoded : track.tofNSigma) {
504-
w.addFull(track.hasTOF ? encodePID(decoded) : EncodedValue{0.f, 0.f, 0.f});
505+
w.addFull(track.hasTOF ? encodePID(decoded) : EncodedValue{.value = 0.f, .valid = 0.f, .overflow = 0.f});
505506
}
506507
w.addFull(encodeDCA(track.dcaXY));
507508
w.addFull(encodeDCA(track.dcaZ));

‎PWGLF/Tasks/Resonances/omega2012Analysis.cxx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include <TPDGCode.h>
5656

5757
#include <cmath>
58-
#include <cstdint>
5958
#include <tuple>
6059

6160
using namespace o2;
@@ -481,8 +480,9 @@ struct Omega2012Analysis {
481480
// Look for Omega(2012)
482481
int pdg = mcParticle.pdgCode();
483482

484-
if (std::abs(pdg) != kOmega2012Minus)
483+
if (std::abs(pdg) != kOmega2012Minus) {
485484
continue;
485+
}
486486

487487
// Fill generated level histograms
488488
auto pt = mcParticle.pt();
@@ -495,8 +495,9 @@ struct Omega2012Analysis {
495495

496496
// Get daughters
497497
auto daughters = mcParticle.daughters_as<aod::McParticles>();
498-
if (daughters.size() != NumExpectedDaughters)
498+
if (daughters.size() != NumExpectedDaughters) {
499499
continue;
500+
}
500501

501502
int daughter1PDG = 0, daughter2PDG = 0;
502503
ROOT::Math::PxPyPzEVector p1, p2, pMother;
@@ -593,7 +594,7 @@ struct Omega2012Analysis {
593594
};
594595

595596
const bool fillWrongSign = core.fillWrongSign();
596-
auto onCandidate = [&](auto const& xi, auto const& pion, auto const& kaon, Xi1530KCandidateValues const& c) {
597+
auto onCandidate = [&]([[maybe_unused]] auto const& xi, [[maybe_unused]] auto const& pion, [[maybe_unused]] auto const& kaon, Xi1530KCandidateValues const& c) {
597598
if (c.chargePattern != o2::analysis::omega2012ml::kSignalPattern) {
598599
// Charge-pattern controls: same event only, never in the signal histograms
599600
if constexpr (!IsMix) {

‎PWGLF/Tasks/Resonances/omega2012TrainingTable.cxx‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct Omega2012TrainingTable {
167167
{
168168
uint64_t hash = FnvOffsetBasis;
169169
for (const auto& value : features) {
170-
const uint32_t bits = std::bit_cast<uint32_t>(value);
170+
const auto bits = std::bit_cast<uint32_t>(value);
171171
for (unsigned int shift = 0; shift < BitsPerFloat; shift += BitsPerByte) {
172172
hash = (hash ^ ((bits >> shift) & ByteMask)) * FnvPrime;
173173
}
@@ -184,7 +184,7 @@ struct Omega2012TrainingTable {
184184
// ResoCollisions_001 carries no run number or BC; the reduced collision row identifies the event within its DF.
185185
mlEvents(static_cast<uint8_t>(mode), static_cast<int64_t>(collision.globalIndex()),
186186
collision.posZ(), collision.bMagField(), collision.cent(), collision.multiplicity(), collision.isRecINELgt0());
187-
mlEventRow = static_cast<int64_t>(mlEvents.lastIndex());
187+
mlEventRow = mlEvents.lastIndex();
188188
}
189189

190190
template <typename Cascade>
@@ -207,7 +207,7 @@ struct Omega2012TrainingTable {
207207
xi.daughterTOFNSigmaNegPi10(), xi.daughterTOFNSigmaNegKa10(), xi.daughterTOFNSigmaNegPr10(),
208208
xi.daughterTOFNSigmaBachPi10(), xi.daughterTOFNSigmaBachKa10(), xi.daughterTOFNSigmaBachPr10(),
209209
xi.nCrossedRowsPos(), xi.nCrossedRowsNeg(), xi.nCrossedRowsBach(), daughterIds.data());
210-
const auto row = static_cast<int64_t>(mlCascades.lastIndex());
210+
const auto row = mlCascades.lastIndex();
211211
mlCascadeRows.emplace(id, row);
212212
return row;
213213
}
@@ -229,7 +229,7 @@ struct Omega2012TrainingTable {
229229
v0.daughterTOFNSigmaPosPi10(), v0.daughterTOFNSigmaPosKa10(), v0.daughterTOFNSigmaPosPr10(),
230230
v0.daughterTOFNSigmaNegPi10(), v0.daughterTOFNSigmaNegKa10(), v0.daughterTOFNSigmaNegPr10(),
231231
v0.nCrossedRowsPos(), v0.nCrossedRowsNeg(), daughterIds.data());
232-
const auto row = static_cast<int64_t>(mlV0s.lastIndex());
232+
const auto row = mlV0s.lastIndex();
233233
mlV0Rows.emplace(id, row);
234234
return row;
235235
}
@@ -244,7 +244,7 @@ struct Omega2012TrainingTable {
244244
mlTracks(mlEventRow, static_cast<int64_t>(track.trackId()), track.px(), track.py(), track.pz(),
245245
track.pidNSigmaPiFlag(), track.pidNSigmaKaFlag(), track.pidNSigmaPrFlag(),
246246
track.trackSelectionFlags(), track.trackFlags(), track.tpcNClsCrossedRows(), track.itsClusterMap());
247-
const auto row = static_cast<int64_t>(mlTracks.lastIndex());
247+
const auto row = mlTracks.lastIndex();
248248
mlTrackRows.emplace(id, row);
249249
return row;
250250
}
@@ -273,7 +273,7 @@ struct Omega2012TrainingTable {
273273
static_cast<float>(values.omega.M()), static_cast<float>(values.omega.Pt()),
274274
static_cast<float>(values.omega.Rapidity()), static_cast<float>(values.omega.Eta()),
275275
static_cast<float>(values.omega.Phi()), values.alpha, static_cast<int8_t>(xi.sign()), passBits);
276-
const auto row = static_cast<int64_t>(mlXiK0sCandidates.lastIndex());
276+
const auto row = mlXiK0sCandidates.lastIndex();
277277
mlXiK0sInputs(row, pack.master.data(), static_cast<uint8_t>(pack.status));
278278
if constexpr (IsMC) {
279279
const bool matched = classifyXiK0sTruth(xi, v0) == XiK0sTruth::Matched;
@@ -316,7 +316,7 @@ struct Omega2012TrainingTable {
316316
static_cast<float>(values.omega.Pt()), static_cast<float>(values.omega.Rapidity()),
317317
static_cast<float>(values.omega.Eta()), static_cast<float>(values.omega.Phi()),
318318
values.chargePattern, passBits);
319-
const auto row = static_cast<int64_t>(mlXi1530KCandidates.lastIndex());
319+
const auto row = mlXi1530KCandidates.lastIndex();
320320
mlXi1530KInputs(row, pack.master.data(), static_cast<uint8_t>(pack.status));
321321
if constexpr (IsMC) {
322322
const bool matched = classifyXi1530KTruth(xi, pion, kaon) == Xi1530KTruth::Matched;
@@ -333,7 +333,7 @@ struct Omega2012TrainingTable {
333333
writeEvent(collision, DecayMode::XiK0s);
334334
// Selection only: the analysis histograms belong to the Omega(2012) analysis task
335335
core.forEachXiK0sCandidate<IsMC, false>(histos, collision, collision, cascades, v0s, true, nullptr, nullptr, nullptr,
336-
[this](auto const& coll, auto const& xi, auto const& v0, XiK0sCandidateValues const& values, uint16_t passBits) {
336+
[&](auto const& coll, auto const& xi, auto const& v0, XiK0sCandidateValues const& values, uint16_t passBits) {
337337
writeXiK0sCandidate<IsMC>(coll, xi, v0, values, passBits);
338338
});
339339
}
@@ -343,8 +343,8 @@ struct Omega2012TrainingTable {
343343
{
344344
writeEvent(collision, DecayMode::Xi1530K);
345345
core.forEachXi1530KCandidate<IsMC, false, true>(histos, collision, cascades, tracks, nullptr, true, nullptr, nullptr, nullptr,
346-
[this](auto const& coll, auto const& xi, auto const& pion, auto const& kaon,
347-
Xi1530KCandidateValues const& values, uint16_t passBits) {
346+
[&](auto const& coll, auto const& xi, auto const& pion, auto const& kaon,
347+
Xi1530KCandidateValues const& values, uint16_t passBits) {
348348
writeXi1530KCandidate<IsMC>(coll, xi, pion, kaon, values, passBits);
349349
});
350350
}
@@ -391,7 +391,7 @@ struct Omega2012TrainingTable {
391391
return;
392392
}
393393
core.forEachGeneratedOmega2012(histos, resoParents, [&](auto const& part, GeneratedChannel channel) {
394-
mlGenAudit(static_cast<int64_t>(collision.globalIndex()), static_cast<int64_t>(part.originalMcParticleId()),
394+
mlGenAudit(collision.globalIndex(), static_cast<int64_t>(part.originalMcParticleId()),
395395
part.pdgCode(), part.daughterPDG1(), part.daughterPDG2(), static_cast<uint8_t>(channel), part.pt(), part.y());
396396
});
397397
}

0 commit comments

Comments
 (0)