From fb3bc8844bc48aec109067bb52177deb041c2aa7 Mon Sep 17 00:00:00 2001 From: Lakshitha Fernando Date: Tue, 1 Dec 2026 21:27:58 -0500 Subject: [PATCH] PWGCF: q-space task, fix clang-tidy code-check errors --- .../Tasks/qSpaceBalanceFunction.cxx | 80 ++++++++++--------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx index 7429f1c842b..3b9a304d71b 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/qSpaceBalanceFunction.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -86,6 +85,13 @@ const std::array chargeTags{"P", "M"}; constexpr int chargeIndexOf(int sign) { return sign > 0 ? 0 : 1; } /// Charge sign (+1, -1) from the accepted id of the dpt-dpt filter (even = positive, odd = negative), as its Sign column constexpr int8_t signOf(int trackAcceptedId) { return trackAcceptedId % NCharges == 0 ? 1 : -1; } +/// Histogram name prefix + path + tag, appended in place (no temporary strings in the booking loops) +std::string histName(const std::string& prefix, const char* path, const std::string& tag) +{ + std::string name{prefix}; + name.append(path).append(tag); + return name; +} enum IdCheckBin { kIdCheckGood = 1, kIdCheckNotKaonId, @@ -108,12 +114,12 @@ enum PairTruthBin { kPairSameMcParticle }; /// PDG codes above this value are hadrons; below are quarks, leptons, gauge bosons and generator-internal codes -static constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code) +constexpr int KPdgHadronThreshold = 100; // o2-linter: disable=pdg/explicit-code (not a PDG code) /// Generator status codes of beam and event-setup entries (PYTHIA 11-19) and the HepMC beam status (4). /// Same criterion as PWGCF/TwoParticleCorrelations/Tasks/particleOriginAnalysis.cxx (V. Gonzalez) -static constexpr int KBeamStatusCodeMin = 11; -static constexpr int KBeamStatusCodeMax = 19; -static constexpr int KHepMCBeamStatusCode = 4; +constexpr int KBeamStatusCodeMin = 11; +constexpr int KBeamStatusCodeMax = 19; +constexpr int KHepMCBeamStatusCode = 4; /// Mother of a particle: global index (-1 if none) and PDG code (0 if none) struct MotherInfo { int64_t index = -1; @@ -212,8 +218,8 @@ struct QSpaceBalanceFunction { PairHistos genHistos; ///< generator level, top-level folders (as before the detector level existed) PairHistos recHistos; ///< detector level, folder rec/ - Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == uint8_t(true)); - Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= int8_t(0)); + Filter onlyAcceptedCollisions = (aod::dptdptfilter::collisionaccepted == static_cast(true)); + Filter onlyAcceptedTracks = (aod::dptdptfilter::trackacceptedid >= static_cast(0)); /// Books the histograms of one level under the folder prefix ("" or "rec/") void bookHistos(PairHistos& histos, const std::string& prefix, bool withResolution) @@ -239,39 +245,39 @@ struct QSpaceBalanceFunction { histos.fhIdCheck->GetXaxis()->SetBinLabel(kIdCheckNoMcTruth, "no MC label"); for (int charge1 = 0; charge1 < NCharges; ++charge1) { const std::string& tag1 = chargeTags[charge1]; - histos.fhPtVsCent[charge1] = registry.add((prefix + "singles/hPtVsCent_" + tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt}); - histos.fhEta[charge1] = registry.add((prefix + "singles/hEta_" + tag1).c_str(), "kaon #eta", kTH1D, {axisEta}); - histos.fhPhi[charge1] = registry.add((prefix + "singles/hPhi_" + tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi}); - histos.fhPtFromPhi[charge1] = registry.add((prefix + "singles/hPtFromPhi_" + tag1).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt}); + histos.fhPtVsCent[charge1] = registry.add(histName(prefix, "singles/hPtVsCent_", tag1).c_str(), "kaon #it{p}_{T}", kTH2D, {axisCent, axisPt}); + histos.fhEta[charge1] = registry.add(histName(prefix, "singles/hEta_", tag1).c_str(), "kaon #eta", kTH1D, {axisEta}); + histos.fhPhi[charge1] = registry.add(histName(prefix, "singles/hPhi_", tag1).c_str(), "kaon #varphi", kTH1D, {axisPhi}); + histos.fhPtFromPhi[charge1] = registry.add(histName(prefix, "singles/hPtFromPhi_", tag1).c_str(), "kaons whose mother is a #phi(1020)", kTH1D, {axisPt}); for (int charge2 = 0; charge2 < NCharges; ++charge2) { const std::string tag = tag1 + chargeTags[charge2]; - histos.fhQinv[charge1][charge2] = registry.add((prefix + "pairs/hQinv_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); - histos.fhQlong[charge1][charge2] = registry.add((prefix + "pairs/hQlong_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); - histos.fhQout[charge1][charge2] = registry.add((prefix + "pairs/hQout_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); - histos.fhQside[charge1][charge2] = registry.add((prefix + "pairs/hQside_" + tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); - histos.fhMass[charge1][charge2] = registry.add((prefix + "pairs/hMass_" + tag).c_str(), "ordered pairs", kTH1F, {axisMass}); - histos.fhSumRuleResidual[charge1][charge2] = registry.add((prefix + "checks/hSumRuleResidual_" + tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); - histos.fhMassRuleResidual[charge1][charge2] = registry.add((prefix + "checks/hMassRuleResidual_" + tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + histos.fhQinv[charge1][charge2] = registry.add(histName(prefix, "pairs/hQinv_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + histos.fhQlong[charge1][charge2] = registry.add(histName(prefix, "pairs/hQlong_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + histos.fhQout[charge1][charge2] = registry.add(histName(prefix, "pairs/hQout_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + histos.fhQside[charge1][charge2] = registry.add(histName(prefix, "pairs/hQside_", tag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + histos.fhMass[charge1][charge2] = registry.add(histName(prefix, "pairs/hMass_", tag).c_str(), "ordered pairs", kTH1F, {axisMass}); + histos.fhSumRuleResidual[charge1][charge2] = registry.add(histName(prefix, "checks/hSumRuleResidual_", tag).c_str(), "Q_{long}^{2}+Q_{out}^{2}+Q_{side}^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); + histos.fhMassRuleResidual[charge1][charge2] = registry.add(histName(prefix, "checks/hMassRuleResidual_", tag).c_str(), "M^{2}-4m^{2}-Q_{inv}^{2}", kTH1D, {axisResidual}); for (int origin = 0; origin < NPairOrigins; ++origin) { const std::string originTag = tag + "_" + pairOriginTags[origin]; - histos.fhQinvOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQinv_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); - histos.fhQlongOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQlong_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); - histos.fhQoutOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQout_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); - histos.fhQsideOrigin[origin][charge1][charge2] = registry.add((prefix + "pairsByOrigin/hQside_" + originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); + histos.fhQinvOrigin[origin][charge1][charge2] = registry.add(histName(prefix, "pairsByOrigin/hQinv_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQinv}); + histos.fhQlongOrigin[origin][charge1][charge2] = registry.add(histName(prefix, "pairsByOrigin/hQlong_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQlong}); + histos.fhQoutOrigin[origin][charge1][charge2] = registry.add(histName(prefix, "pairsByOrigin/hQout_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQout}); + histos.fhQsideOrigin[origin][charge1][charge2] = registry.add(histName(prefix, "pairsByOrigin/hQside_", originTag).c_str(), "ordered pairs", kTH2F, {axisCent, axisQside}); } if (withResolution) { const AxisSpec axisQinvTrue{cfgBinsQinvTrue, "true Q_{inv} (GeV/#it{c})"}; const AxisSpec axisQComponentTrue{cfgBinsQComponentTrue, "true Q component (GeV/#it{c})"}; const AxisSpec axisResolution{cfgBinsQResolution, "Q_{rec} - Q_{true} (GeV/#it{c})"}; - histos.fhPairTruth[charge1][charge2] = registry.add((prefix + "resolution/hPairTruth_" + tag).c_str(), "ordered pairs by MC truth", kTH1D, {{4, 0.5, 4.5}}); + histos.fhPairTruth[charge1][charge2] = registry.add(histName(prefix, "resolution/hPairTruth_", tag).c_str(), "ordered pairs by MC truth", kTH1D, {{4, 0.5, 4.5}}); histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairBothTrueKaons, "both true kaons, right charge"); histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairMisidentified, "at least one misidentified"); histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairUnmatched, "at least one without MC label"); histos.fhPairTruth[charge1][charge2]->GetXaxis()->SetBinLabel(kPairSameMcParticle, "both tracks from one MC particle"); - histos.fhResQinv[charge1][charge2] = registry.add((prefix + "resolution/hResQinv_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQinvTrue, axisResolution}); - histos.fhResQlong[charge1][charge2] = registry.add((prefix + "resolution/hResQlong_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); - histos.fhResQout[charge1][charge2] = registry.add((prefix + "resolution/hResQout_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); - histos.fhResQside[charge1][charge2] = registry.add((prefix + "resolution/hResQside_" + tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + histos.fhResQinv[charge1][charge2] = registry.add(histName(prefix, "resolution/hResQinv_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQinvTrue, axisResolution}); + histos.fhResQlong[charge1][charge2] = registry.add(histName(prefix, "resolution/hResQlong_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + histos.fhResQout[charge1][charge2] = registry.add(histName(prefix, "resolution/hResQout_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); + histos.fhResQside[charge1][charge2] = registry.add(histName(prefix, "resolution/hResQside_", tag).c_str(), "pairs of two true kaons", kTH2F, {axisQComponentTrue, axisResolution}); } } } @@ -294,14 +300,14 @@ struct QSpaceBalanceFunction { for (int charge1 = 0; charge1 < NCharges; ++charge1) { for (int charge2 = 0; charge2 < NCharges; ++charge2) { const std::string tag = chargeTags[charge1] + chargeTags[charge2]; - bf.fhSameQinv[charge1][charge2] = registry.add((prefix + "same/hQinv_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQinv}); - bf.fhSameQlong[charge1][charge2] = registry.add((prefix + "same/hQlong_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQlong}); - bf.fhSameQout[charge1][charge2] = registry.add((prefix + "same/hQout_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQout}); - bf.fhSameQside[charge1][charge2] = registry.add((prefix + "same/hQside_" + tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQside}); - bf.fhMixedQinv[charge1][charge2] = registry.add((prefix + "mixed/hQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQinv}); - bf.fhMixedQlong[charge1][charge2] = registry.add((prefix + "mixed/hQlong_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQlong}); - bf.fhMixedQout[charge1][charge2] = registry.add((prefix + "mixed/hQout_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQout}); - bf.fhMixedQside[charge1][charge2] = registry.add((prefix + "mixed/hQside_" + tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside}); + bf.fhSameQinv[charge1][charge2] = registry.add(histName(prefix, "same/hQinv_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQinv}); + bf.fhSameQlong[charge1][charge2] = registry.add(histName(prefix, "same/hQlong_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQlong}); + bf.fhSameQout[charge1][charge2] = registry.add(histName(prefix, "same/hQout_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQout}); + bf.fhSameQside[charge1][charge2] = registry.add(histName(prefix, "same/hQside_", tag).c_str(), "same-event ordered pairs", kTH2F, {axisClass, axisQside}); + bf.fhMixedQinv[charge1][charge2] = registry.add(histName(prefix, "mixed/hQinv_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQinv}); + bf.fhMixedQlong[charge1][charge2] = registry.add(histName(prefix, "mixed/hQlong_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQlong}); + bf.fhMixedQout[charge1][charge2] = registry.add(histName(prefix, "mixed/hQout_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQout}); + bf.fhMixedQside[charge1][charge2] = registry.add(histName(prefix, "mixed/hQside_", tag).c_str(), "mixed-event ordered pairs, both orders of each event pair", kTH2F, {axisClass, axisQside}); } } if (cfgNSubsamples.value > 0) { @@ -315,8 +321,8 @@ struct QSpaceBalanceFunction { for (int charge1 = 0; charge1 < NCharges; ++charge1) { for (int charge2 = 0; charge2 < NCharges; ++charge2) { const std::string tag = chargeTags[charge1] + chargeTags[charge2]; - bf.fhSubSameQinv[charge1][charge2] = registry.add((prefix + "sub/hSameQinv_" + tag).c_str(), "same-event ordered pairs", kTH3F, {axisClass, axisSub, axisQinvSub}); - bf.fhSubMixedQinv[charge1][charge2] = registry.add((prefix + "sub/hMixedQinv_" + tag).c_str(), "mixed-event ordered pairs, both orders", kTH3F, {axisClass, axisSub, axisQinvSub}); + bf.fhSubSameQinv[charge1][charge2] = registry.add(histName(prefix, "sub/hSameQinv_", tag).c_str(), "same-event ordered pairs", kTH3F, {axisClass, axisSub, axisQinvSub}); + bf.fhSubMixedQinv[charge1][charge2] = registry.add(histName(prefix, "sub/hMixedQinv_", tag).c_str(), "mixed-event ordered pairs, both orders", kTH3F, {axisClass, axisSub, axisQinvSub}); } } }