Skip to content

Commit 2f72f4b

Browse files
committed
[PWGLF] Fix O2 linter warnings in K1 micro analysis
- Use const references in range-based loops over configured PID cuts - Replace magic numbers in init checks with named constants
1 parent abdac64 commit 2f72f4b

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎PWGLF/Tasks/Resonances/k1AnalysisMicro.cxx‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ struct K1AnalysisMicro {
122122
static constexpr double PIDGridStep = 0.25;
123123
static constexpr double PIDGridMax = 3.5;
124124
static constexpr double GridTolerance = 1e-4;
125+
static constexpr std::size_t MinPtBinEdges = 2; // a pT dependent PID table needs at least one bin
126+
static constexpr float ProducerDCAPtP0 = 0.004f; // resonanceModuleInitializer cfgTightDCAOffset default
127+
static constexpr float ProducerDCAPtCoeff = 0.013f; // resonanceModuleInitializer cfgTightDCAPtCoefficient default
128+
static constexpr float ProducerDCAPtPower = 1.f; // resonanceModuleInitializer cfgTightDCAPtPower default
129+
static constexpr float ConfigTolerance = 1e-6f;
125130
static constexpr int NCandidateStages = 12;
126131

127132
SliceCache cache;
@@ -297,14 +302,14 @@ struct K1AnalysisMicro {
297302
// Consistency of the pT dependent PID configuration
298303
if (pionPID.cPionUsePtDepPID) {
299304
const auto& bins = pionPID.cPionPIDPtBins.value;
300-
if (bins.size() < 2 || pionPID.cPionTPCNSigmaCuts.value.size() != bins.size() - 1 ||
305+
if (bins.size() < MinPtBinEdges || pionPID.cPionTPCNSigmaCuts.value.size() != bins.size() - 1 ||
301306
pionPID.cPionTOFNSigmaCuts.value.size() != bins.size() - 1 || pionPID.cPionTOFRequired.value.size() != bins.size() - 1) {
302307
LOG(fatal) << "Pion pT dependent PID vectors must have (number of pT bin edges - 1) entries";
303308
}
304309
}
305310
if (kaonPID.cKaonUsePtDepPID) {
306311
const auto& bins = kaonPID.cKaonPIDPtBins.value;
307-
if (bins.size() < 2 || kaonPID.cKaonTPCNSigmaCuts.value.size() != bins.size() - 1 ||
312+
if (bins.size() < MinPtBinEdges || kaonPID.cKaonTPCNSigmaCuts.value.size() != bins.size() - 1 ||
308313
kaonPID.cKaonTOFNSigmaCuts.value.size() != bins.size() - 1 || kaonPID.cKaonTOFRequired.value.size() != bins.size() - 1) {
309314
LOG(fatal) << "Kaon pT dependent PID vectors must have (number of pT bin edges - 1) entries";
310315
}
@@ -329,7 +334,7 @@ struct K1AnalysisMicro {
329334
};
330335
if (trackCuts.cfgUsePtDepDCA) {
331336
LOG(info) << "Micro tracks use the producer pT dependent DCA flags (0.004 + 0.013 / pT); cDCAToPVByPt* are ignored";
332-
if (std::abs(trackCuts.cDCAToPVByPtP0 - 0.004f) > 1e-6f || std::abs(trackCuts.cDCAToPVByPtCoeff - 0.013f) > 1e-6f || std::abs(trackCuts.cDCAToPVByPtPower - 1.f) > 1e-6f) {
337+
if (std::abs(trackCuts.cDCAToPVByPtP0 - ProducerDCAPtP0) > ConfigTolerance || std::abs(trackCuts.cDCAToPVByPtCoeff - ProducerDCAPtCoeff) > ConfigTolerance || std::abs(trackCuts.cDCAToPVByPtPower - ProducerDCAPtPower) > ConfigTolerance) {
333338
LOG(warning) << "cDCAToPVByPt* differ from the producer defaults, but micro tracks always use the producer formula";
334339
}
335340
} else {
@@ -356,24 +361,24 @@ struct K1AnalysisMicro {
356361
checkPIDGrid("cMaxTOFnSigmaKaon", kaonPID.cMaxTOFnSigmaKaon);
357362
}
358363
if (pionPID.cPionUsePtDepPID) {
359-
for (const auto cut : pionPID.cPionTPCNSigmaCuts.value) {
364+
for (const auto& cut : pionPID.cPionTPCNSigmaCuts.value) {
360365
if (isCutEnabled(cut)) {
361366
checkPIDGrid("cPionTPCNSigmaCuts", cut);
362367
}
363368
}
364-
for (const auto cut : pionPID.cPionTOFNSigmaCuts.value) {
369+
for (const auto& cut : pionPID.cPionTOFNSigmaCuts.value) {
365370
if (isCutEnabled(cut)) {
366371
checkPIDGrid("cPionTOFNSigmaCuts", cut);
367372
}
368373
}
369374
}
370375
if (kaonPID.cKaonUsePtDepPID) {
371-
for (const auto cut : kaonPID.cKaonTPCNSigmaCuts.value) {
376+
for (const auto& cut : kaonPID.cKaonTPCNSigmaCuts.value) {
372377
if (isCutEnabled(cut)) {
373378
checkPIDGrid("cKaonTPCNSigmaCuts", cut);
374379
}
375380
}
376-
for (const auto cut : kaonPID.cKaonTOFNSigmaCuts.value) {
381+
for (const auto& cut : kaonPID.cKaonTOFNSigmaCuts.value) {
377382
if (isCutEnabled(cut)) {
378383
checkPIDGrid("cKaonTOFNSigmaCuts", cut);
379384
}

0 commit comments

Comments
 (0)