From ded331697ba4258a399441629efe7b8dbc77e01f Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Fri, 7 Aug 2026 13:36:52 +0200 Subject: [PATCH 1/3] Add safeguards in vn-pt profile filling --- .../GenericFramework/Core/FlowPtContainer.cxx | 29 +++++- .../GenericFramework/Tasks/flowGfwNonflow.cxx | 97 ++++++++++++------- 2 files changed, 88 insertions(+), 38 deletions(-) diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx index 3e6c594643d..d81e737648c 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx @@ -784,15 +784,34 @@ void FlowPtContainer::fillVnDeltaPtProfiles(const int configIndex, const double& if (!mask) { return; } - int startIndex = fCovFirstIndex[configIndex]; + + if (configIndex < 0 || static_cast(configIndex) >= fCovFirstIndex.size()) { + LOGF(error, "Invalid configuration index %d", configIndex); + return; + } + int profileIndex = fCovFirstIndex[configIndex]; for (auto m(1); m <= mpar; ++m) { if (!(mask & (1 << (m - 1)))) continue; - for (auto i = 0; i <= m; ++i) { - if (cmDen[m] != 0) { - dynamic_cast(fCovList->At(startIndex))->FillProfile(centmult, flowval * ((i == m) ? cmVal[0] : cmVal[m * (m - 1) / 2 + i + 1]), (fEventWeight == UnityWeight) ? 1.0 : flowtuples * cmDen[m], rn); + for (auto i = 0; i <= m; ++i, ++profileIndex) { + const size_t cmIndex = (i == m) ? 0u : static_cast(m * (m - 1) / 2 + i + 1); + + if (static_cast(m) >= cmDen.size() || cmIndex >= cmVal.size() || cmDen[m] == 0.) { + continue; + } + + if (!fCovList || profileIndex >= fCovList->GetEntries()) { + LOGF(error, "Profile index %d out of range (entries=%d, config=%d, m=%d)", profileIndex, fCovList ? fCovList->GetEntries() : 0, configIndex, m); + continue; + } + + auto* profile = dynamic_cast(fCovList->At(profileIndex)); + + if (!profile) { + LOGF(error, "Missing BootstrapProfile at index %d for config %d", profileIndex, configIndex); + continue; } - ++startIndex; + profile->FillProfile(centmult, flowval * cmVal[cmIndex], (fEventWeight == UnityWeight) ? 1.0 : flowtuples * cmDen[m], rn); } } return; diff --git a/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx b/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx index 991d9870d1a..6b6277c032a 100644 --- a/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx @@ -348,30 +348,36 @@ struct FlowGfwNonflow { AxisSpec dcaXYAXis = {200, -1, 1, "DCA_{xy} (cm)"}; if (cfgFillQA) { - registry.add("trackQA/before/phi_eta_vtxZ", "", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); - registry.add("trackQA/before/pt_dcaXY_dcaZ", "", {HistType::kTH3D, {ptAxis, dcaXYAXis, dcaZAXis}}); - registry.add("trackQA/before/pt_phi", "", {HistType::kTH2D, {ptAxis, phiModAxis}}); - registry.add("trackQA/before/chi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); - registry.add("trackQA/before/chi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); - registry.add("trackQA/before/nTPCClusters", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); - registry.add("trackQA/before/nITSClusters", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); - registry.add("trackQA/before/nTPCCrossedRows", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); - registry.addClone("trackQA/before/", "trackQA/after/"); - registry.add("trackQA/after/pt_ref", "; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, gfwMemberCache.ptreflow, gfwMemberCache.ptrefup}}}); - registry.add("trackQA/after/pt_poi", "; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, gfwMemberCache.ptpoilow, gfwMemberCache.ptpoiup}}}); - registry.add("trackQA/after/Nch_corrected", "; N_{ch}; Counts", {HistType::kTH1D, {nchAxis}}); - registry.add("trackQA/after/Nch_uncorrected", "; N_{ch}; Counts", {HistType::kTH1D, {nchAxis}}); - registry.add("trackQA/after/etaNch", "; #eta; Counts", {HistType::kTH1D, {etaAxis}}); - registry.add("trackQA/after/etaPtPt", "; #eta; Counts", {HistType::kTH1D, {etaAxis}}); - - registry.add("eventQA/before/globalTracks_centT0C", "; FT0C centrality (%); N_{global}", {HistType::kTH2D, {centAxis, nchAxis}}); - registry.add("eventQA/before/PVTracks_centT0C", "; FT0C centrality (%); N_{PV}", {HistType::kTH2D, {centAxis, multpvAxis}}); - registry.add("eventQA/before/globalTracks_PVTracks", "; N_{PV}; N_{global}", {HistType::kTH2D, {multpvAxis, nchAxis}}); - registry.add("eventQA/before/globalTracks_multT0A", "; multT0A; N_{global}", {HistType::kTH2D, {t0aAxis, nchAxis}}); - registry.add("eventQA/before/globalTracks_multV0A", "; multV0A; N_{global}", {HistType::kTH2D, {v0aAxis, nchAxis}}); - registry.add("eventQA/before/multV0A_multT0A", "; multV0A; multT0A", {HistType::kTH2D, {t0aAxis, v0aAxis}}); - registry.add("eventQA/before/multT0C_centT0C", "; multT0C; FT0C centrality (%)", {HistType::kTH2D, {centAxis, t0cAxis}}); - registry.add("eventQA/before/occ_mult_cent", "; occupancy; N_{ch}; centrality (%)", {HistType::kTH3D, {occAxis, nchAxis, centAxis}}); + if (doprocessMCGen) { + registry.add("MCGen/before/phi_eta_vtxZ_gen", "; #varphi; #eta; V_{z}", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("MCGen/before/pt_gen", "; #it{p}_{T}", {HistType::kTH1D, {ptAxis}}); + registry.addClone("MCGen/before/", "MCGen/after/"); + } else { + registry.add("trackQA/before/phi_eta_vtxZ", "; #varphi; #eta; V_{z}", {HistType::kTH3D, {phiAxis, etaAxis, vtxAxis}}); + registry.add("trackQA/before/pt_dcaXY_dcaZ", "; #it{p}_{T}; DCA_#it{xy}; DCA_#it{z}", {HistType::kTH3D, {ptAxis, dcaXYAXis, dcaZAXis}}); + registry.add("trackQA/before/pt_phi", "; #it{p}_{T}; fmod(#varphi,#pi/9)", {HistType::kTH2D, {ptAxis, phiModAxis}}); + registry.add("trackQA/before/chi2prTPCcls", "#chi^{2}/cluster for the TPC track segment", {HistType::kTH1D, {{100, 0., 5.}}}); + registry.add("trackQA/before/chi2prITScls", "#chi^{2}/cluster for the ITS track", {HistType::kTH1D, {{100, 0., 50.}}}); + registry.add("trackQA/before/nTPCClusters", "Number of found TPC clusters", {HistType::kTH1D, {{100, 40, 180}}}); + registry.add("trackQA/before/nITSClusters", "Number of found ITS clusters", {HistType::kTH1D, {{100, 0, 20}}}); + registry.add("trackQA/before/nTPCCrossedRows", "Number of crossed TPC Rows", {HistType::kTH1D, {{100, 40, 180}}}); + registry.addClone("trackQA/before/", "trackQA/after/"); + registry.add("trackQA/after/pt_ref", "; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, gfwMemberCache.ptreflow, gfwMemberCache.ptrefup}}}); + registry.add("trackQA/after/pt_poi", "; #it{p}_{T}; Counts", {HistType::kTH1D, {{100, gfwMemberCache.ptpoilow, gfwMemberCache.ptpoiup}}}); + registry.add("trackQA/after/Nch_corrected", "; N_{ch}; Counts", {HistType::kTH1D, {nchAxis}}); + registry.add("trackQA/after/Nch_uncorrected", "; N_{ch}; Counts", {HistType::kTH1D, {nchAxis}}); + registry.add("trackQA/after/etaNch", "; #eta; Counts", {HistType::kTH1D, {etaAxis}}); + registry.add("trackQA/after/etaPtPt", "; #eta; Counts", {HistType::kTH1D, {etaAxis}}); + + registry.add("eventQA/before/globalTracks_centT0C", "; FT0C centrality (%); N_{global}", {HistType::kTH2D, {centAxis, nchAxis}}); + registry.add("eventQA/before/PVTracks_centT0C", "; FT0C centrality (%); N_{PV}", {HistType::kTH2D, {centAxis, multpvAxis}}); + registry.add("eventQA/before/globalTracks_PVTracks", "; N_{PV}; N_{global}", {HistType::kTH2D, {multpvAxis, nchAxis}}); + registry.add("eventQA/before/globalTracks_multT0A", "; multT0A; N_{global}", {HistType::kTH2D, {t0aAxis, nchAxis}}); + registry.add("eventQA/before/globalTracks_multV0A", "; multV0A; N_{global}", {HistType::kTH2D, {v0aAxis, nchAxis}}); + registry.add("eventQA/before/multV0A_multT0A", "; multT0A; multV0A", {HistType::kTH2D, {t0aAxis, v0aAxis}}); + registry.add("eventQA/before/multT0C_centT0C", "; FT0C centrality (%); multT0C", {HistType::kTH2D, {centAxis, t0cAxis}}); + registry.add("eventQA/before/occ_mult_cent", "; occupancy; N_{ch}; centrality (%)", {HistType::kTH3D, {occAxis, nchAxis, centAxis}}); + } } registry.add("eventQA/before/centrality", "; centrality (%); Counts", {HistType::kTH1D, {centAxis}}); registry.add("eventQA/before/multiplicity", "; N_{ch}; Counts", {HistType::kTH1D, {nchAxis}}); @@ -649,19 +655,44 @@ struct FlowGfwNonflow { template double getEfficiency(const TTrack& track, const float& centrality) { //-1 ref, 0 ch, 1 pi, 2 ka, 3 pr, 4 k0, 5 lambda - double eff = 1.; + if (!correctionsConfig.mEfficiency) { - return eff; + return 1; } + + int bin = 0; + if (cfgCorrections.cfgUse2DEfficiency) { - eff = dynamic_cast(correctionsConfig.mEfficiency)->GetBinContent(dynamic_cast(correctionsConfig.mEfficiency)->FindBin(track.pt(), centrality)); + auto* eff_hist = dynamic_cast(correctionsConfig.mEfficiency); + if (!eff_hist) { + LOGF(error, "Efficiency object at %s is not a TH2D", cfgCorrections.cfgEfficiencyPath.value.c_str()); + return -1.; + } + bin = eff_hist->FindBin(track.pt(), centrality); + if (!bin) { + return -1.; + } + const double eff = eff_hist->GetBinContent(bin); + if (!std::isfinite(eff) || eff <= 0.) { + return -1.; + } + return 1. / eff; } else { - eff = dynamic_cast(correctionsConfig.mEfficiency)->GetBinContent(dynamic_cast(correctionsConfig.mEfficiency)->FindBin(track.pt())); - } - if (eff == 0) { - return -1.; + auto* eff_hist = dynamic_cast(correctionsConfig.mEfficiency); + if (!eff_hist) { + LOGF(error, "Efficiency object at %s is not a TH1D", cfgCorrections.cfgEfficiencyPath.value.c_str()); + return -1.; + } + bin = eff_hist->FindBin(track.pt()); + if (!bin) { + return -1.; + } + const double eff = eff_hist->GetBinContent(bin); + if (!std::isfinite(eff) || eff <= 0.) { + return -1.; + } + return 1. / eff; } - return 1. / eff; } template @@ -844,7 +875,7 @@ struct FlowGfwNonflow { auto val = fGFW->Calculate(corrconfigs.at(l_ind), 0, false).real() / dnx; if (std::abs(val) < 1) { fFC->FillProfile(corrconfigs.at(l_ind).Head.c_str(), centmult, val, cfgUseMultiplicityFlowWeights ? dnx : 1.0, rndm); - fFCpt->fillVnPtProfiles(centmult, val, dnx, rndm, gfwMemberCache.configs.GetpTCorrMasks()[l_ind]); + fFCpt->fillVnPtProfiles(static_cast(l_ind), centmult, val, dnx, rndm, gfwMemberCache.configs.GetpTCorrMasks()[l_ind]); } continue; } From 84fa585da5b648705ef27eeb1040d3e7dbcb3df3 Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Fri, 7 Aug 2026 14:30:55 +0200 Subject: [PATCH 2/3] linter --- .../GenericFramework/Core/FlowPtContainer.cxx | 61 ++++++++++--------- PWGCF/GenericFramework/Core/FlowPtContainer.h | 1 + .../GenericFramework/Tasks/flowGfwNonflow.cxx | 16 ++--- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx index d81e737648c..52ed83d494d 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx @@ -161,7 +161,7 @@ void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& for (int m = 0; m < mpar; ++m) { fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nMultiBins, &multiBins[0])); } - for (int m = 0; m < 4; ++m) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nMultiBins, &multiBins[0])); } @@ -251,7 +251,7 @@ void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const for (int m = 0; m < mpar; ++m) { fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xbins)); } - for (int m = 0; m < 4; ++m) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xbins)); } @@ -339,7 +339,7 @@ void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const in for (int m = 0; m < mpar; ++m) { fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xlow, xhigh)); } - for (int m = 0; m < 4; ++m) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xlow, xhigh)); } @@ -433,7 +433,7 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con std::vector current; getSubevents(m, nsubev + 1, current, subevents); // remove unused "extra" subevent - for (auto& subevent : subevents) + for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back()) subevent.pop_back(); subevents.erase(subevents.begin(), subevents.begin() + 1); @@ -455,14 +455,15 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con delete fSubCMList; fSubCMList = new TList(); fSubCMList->SetOwner(kTRUE); - for (int subEv = 0; subEv < 2; ++subEv) { - for (int m = 0; m < 4; ++m) { + const int maxSubEv = 2; + for (int subEv = 0; subEv < maxSubEv; ++subEv) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nMultiBins, &multiBins[0])); } } } - for (int m = 2; m <= 4; ++m) { + for (int m = 2; m <= centralMomentMaxOrder; ++m) { for (int first = 1; first < m; ++first) { for (int second = first; second < m; ++second) { if (first > second) @@ -504,7 +505,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m std::vector current; getSubevents(m, nsubev + 1, current, subevents); // remove unused "extra" subevent - for (auto& subevent : subevents) + for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back()) subevent.pop_back(); subevents.erase(subevents.begin(), subevents.begin() + 1); @@ -526,14 +527,15 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m delete fSubCMList; fSubCMList = new TList(); fSubCMList->SetOwner(kTRUE); - for (int subEv = 0; subEv < 2; ++subEv) { - for (int m = 0; m < 4; ++m) { + const int maxSubEv = 2; + for (int subEv = 0; subEv < maxSubEv; ++subEv) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nbinsx, xbins)); } } } - for (int m = 2; m <= 4; ++m) { + for (int m = 2; m <= centralMomentMaxOrder; ++m) { for (int first = 1; first < m; ++first) { for (int second = first; second < m; ++second) { if (first > second) @@ -574,7 +576,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh, std::vector current; getSubevents(mpar, nsubev + 1, current, subevents); // remove unused "extra" subevent - for (auto& subevent : subevents) + for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back()) subevent.pop_back(); subevents.erase(subevents.begin(), subevents.begin() + 1); @@ -596,14 +598,15 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh, delete fSubCMList; fSubCMList = new TList(); fSubCMList->SetOwner(kTRUE); - for (int subEv = 0; subEv < 2; ++subEv) { - for (int m = 0; m < 4; ++m) { + const int maxSubEv = 2; + for (int subEv = 0; subEv < maxSubEv; ++subEv) { + for (int m = 0; m < centralMomentMaxOrder; ++m) { for (int i = 0; i <= m; ++i) { fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nbinsx, xlow, xhigh)); } } } - for (int m = 2; m <= 4; ++m) { + for (int m = 2; m <= centralMomentMaxOrder; ++m) { for (int first = 1; first < m; ++first) { for (int second = first; second < m; ++second) { if (first > second) @@ -669,10 +672,10 @@ void FlowPtContainer::calculateSubeventCorrelations() { corrNumSub.clear(); corrNumSub.resize(nSubevents, std::vector(mpar + 1, 0)); - for (auto& corrnum : corrNumSub) + for (auto& corrnum : corrNumSub) // o2-linter: disable=const-ref-in-for-loop (assigned a value) corrnum[0] = 1.0; corrDenSub.resize(nSubevents, std::vector(mpar + 1, 0)); - for (auto& corrden : corrDenSub) + for (auto& corrden : corrDenSub) // o2-linter: disable=const-ref-in-for-loop (assigned a value) corrden[0] = 1.0; for (int subIndex = 0; subIndex < nSubevents; ++subIndex) { @@ -912,13 +915,13 @@ void FlowPtContainer::fillCMProfiles(const double& centmult, const double& rn) return; cmVal.push_back(sumP[getVectorIndex(1, 1)] / cmDen[1]); dynamic_cast(fCMTermList->At(0))->FillProfile(centmult, cmVal[1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[1], rn); - if (mpar < 2 || sumP[getVectorIndex(2, 0)] == 0 || cmDen[2] == 0) + if (mpar < 2 || sumP[getVectorIndex(2, 0)] == 0 || cmDen[2] == 0) // o2-linter: disable=magic-number (less than order 2) return; cmVal.push_back(1 / cmDen[2] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 2)])); dynamic_cast(fCMTermList->At(1))->FillProfile(centmult, cmVal[2], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); cmVal.push_back(-2 * 1 / cmDen[2] * (sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 1)])); dynamic_cast(fCMTermList->At(2))->FillProfile(centmult, cmVal[3], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn); - if (mpar < 3 || sumP[getVectorIndex(3, 0)] == 0 || cmDen[3] == 0) + if (mpar < 3 || sumP[getVectorIndex(3, 0)] == 0 || cmDen[3] == 0) // o2-linter: disable=magic-number (less than order 3) return; cmVal.push_back(1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] + 2 * sumP[getVectorIndex(3, 3)])); dynamic_cast(fCMTermList->At(3))->FillProfile(centmult, cmVal[4], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); @@ -926,7 +929,7 @@ void FlowPtContainer::fillCMProfiles(const double& centmult, const double& rn) dynamic_cast(fCMTermList->At(4))->FillProfile(centmult, cmVal[5], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); cmVal.push_back(3 * 1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 0)] - 2 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 0)] + 2 * sumP[getVectorIndex(3, 1)] - sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(2, 0)])); dynamic_cast(fCMTermList->At(5))->FillProfile(centmult, cmVal[6], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn); - if (mpar < 4 || sumP[getVectorIndex(4, 0)] == 0 || cmDen[4] == 0) + if (mpar < 4 || sumP[getVectorIndex(4, 0)] == 0 || cmDen[4] == 0) // o2-linter: disable=magic-number (less than order 4) return; cmVal.push_back(1 / cmDen[4] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - 6 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] + 3 * sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(2, 2)] + 8 * sumP[getVectorIndex(3, 3)] * sumP[getVectorIndex(1, 1)] - 6 * sumP[getVectorIndex(4, 4)])); dynamic_cast(fCMTermList->At(6))->FillProfile(centmult, cmVal[7], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[4], rn); @@ -943,7 +946,8 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl // do I need to add an extra return statement here to match fillCMProfiles? if (mpar < 1) return; - if (nSubevents < 2) + const int minSubevents = 2; + if (nSubevents < minSubevents) return; int indOffset = 0; @@ -977,7 +981,7 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl dynamic_cast(fSubCMList->At(indOffset + 0))->FillProfile(centmult, cmValSub[nSubevents - 1][1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDenSub[nSubevents - 1][1], rn); } - if (mpar >= 2) { + if (mpar >= 2) { // o2-linter: disable=magic-number (greater than order 2) if (insub[0][getVectorIndex(2, 0)] != 0 && cmDenSub[0][2] != 0) { cmValSub[0].push_back(1 / cmDenSub[0][2] * (insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] - insub[0][getVectorIndex(2, 2)])); dynamic_cast(fSubCMList->At(1))->FillProfile(centmult, cmValSub[0][2], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDenSub[0][2], rn); @@ -993,7 +997,7 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl validMpar[0] = true; } - if (mpar >= 3) { + if (mpar >= 3) { // o2-linter: disable=magic-number (greater than order 3) if (insub[0][getVectorIndex(3, 0)] != 0 && cmDenSub[0][3] != 0) { cmValSub[0].push_back(1 / cmDenSub[0][3] * (insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] - 3 * insub[0][getVectorIndex(2, 2)] * insub[0][getVectorIndex(1, 1)] + 2 * insub[0][getVectorIndex(3, 3)])); dynamic_cast(fSubCMList->At(3))->FillProfile(centmult, cmValSub[0][4], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDenSub[0][3], rn); @@ -1012,7 +1016,7 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl } validMpar[1] = true; } - if (mpar >= 4) { + if (mpar >= 4) { // o2-linter: disable=magic-number (greater than order 4) if (insub[0][getVectorIndex(4, 0)] != 0 && cmDenSub[0][4] != 0) { cmValSub[0].push_back(1 / cmDenSub[0][4] * (insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] - 6 * insub[0][getVectorIndex(2, 2)] * insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] + 3 * insub[0][getVectorIndex(2, 2)] * insub[0][getVectorIndex(2, 2)] + 8 * insub[0][getVectorIndex(3, 3)] * insub[0][getVectorIndex(1, 1)] - 6 * insub[0][getVectorIndex(4, 4)])); dynamic_cast(fSubCMList->At(6))->FillProfile(centmult, cmValSub[0][7], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDenSub[0][4], rn); @@ -1036,7 +1040,7 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl validMpar[2] = true; } // Fill cross terms - for (int m = 2; m <= 4; ++m) { + for (int m = 2; m <= centralMomentMaxOrder; ++m) { if (!validMpar[m - 2]) continue; for (int first = 1; first < m; ++first) { @@ -1058,7 +1062,8 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl } void FlowPtContainer::fillArray(FillType a, FillType b, double c, double d) { - for (int idx = 0; idx < 225; ++idx) { + const int nTerms = 3 * 3 * 5 * 5; + for (int idx = 0; idx < nTerms; ++idx) { int i = idx % 3; int j = ((idx - i) / 3) % 3; int k = ((idx - j * 3 - i) / 9) % 5; @@ -1763,7 +1768,7 @@ void FlowPtContainer::createCentralMomentList() delete fCentralMomentList; fCentralMomentList = new TList(); fCentralMomentList->SetOwner(); - for (auto m(1); m <= 4; ++m) { + for (auto m(1); m <= centralMomentMaxOrder; ++m) { for (int i = -1; i < reinterpret_cast(fCMTermList->At(0))->getNSubs(); ++i) { TH1* hMpt = reinterpret_cast(fCMTermList->At(0))->getHist(i); std::vector hTs; @@ -1836,7 +1841,7 @@ void FlowPtContainer::calculateCumulantHists(std::vector inh, int ind) } return; } -Long64_t FlowPtContainer::Merge(TCollection* collist) +Long64_t FlowPtContainer::Merge(TCollection* collist) // o2-linter: disable=name/function-variable (Keep name consistent with ROOT streamer merging) { if (!fCorrList || !fCMTermList) return 0; diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.h b/PWGCF/GenericFramework/Core/FlowPtContainer.h index 748d4e57cb5..8c3a33a4bad 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.h +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.h @@ -221,6 +221,7 @@ class FlowPtContainer : public TNamed double getStdABDDD(T& inarr); private: + static const int centralMomentMaxOrder = 4; std::vector> subevents; void getSubevents(int k, int n, std::vector& current, std::vector>& subevents); static constexpr float FactorialArray[9] = {1., 1., 2., 6., 24., 120., 720., 5040., 40320.}; diff --git a/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx b/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx index 6b6277c032a..949724ac0ea 100644 --- a/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx @@ -663,31 +663,31 @@ struct FlowGfwNonflow { int bin = 0; if (cfgCorrections.cfgUse2DEfficiency) { - auto* eff_hist = dynamic_cast(correctionsConfig.mEfficiency); - if (!eff_hist) { + auto* effHist = dynamic_cast(correctionsConfig.mEfficiency); + if (!effHist) { LOGF(error, "Efficiency object at %s is not a TH2D", cfgCorrections.cfgEfficiencyPath.value.c_str()); return -1.; } - bin = eff_hist->FindBin(track.pt(), centrality); + bin = effHist->FindBin(track.pt(), centrality); if (!bin) { return -1.; } - const double eff = eff_hist->GetBinContent(bin); + const double eff = effHist->GetBinContent(bin); if (!std::isfinite(eff) || eff <= 0.) { return -1.; } return 1. / eff; } else { - auto* eff_hist = dynamic_cast(correctionsConfig.mEfficiency); - if (!eff_hist) { + auto* effHist = dynamic_cast(correctionsConfig.mEfficiency); + if (!effHist) { LOGF(error, "Efficiency object at %s is not a TH1D", cfgCorrections.cfgEfficiencyPath.value.c_str()); return -1.; } - bin = eff_hist->FindBin(track.pt()); + bin = effHist->FindBin(track.pt()); if (!bin) { return -1.; } - const double eff = eff_hist->GetBinContent(bin); + const double eff = effHist->GetBinContent(bin); if (!std::isfinite(eff) || eff <= 0.) { return -1.; } From 78cba9a7048d75aff4c7d6c556989e8eaec35560 Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Fri, 7 Aug 2026 15:01:01 +0200 Subject: [PATCH 3/3] linter fixes --- .../GenericFramework/Core/FlowPtContainer.cxx | 34 +++++++++---------- PWGCF/GenericFramework/Core/FlowPtContainer.h | 12 +++---- PWGCF/GenericFramework/Core/GFWConfig.h | 3 ++ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx index 52ed83d494d..b65c19b9047 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx @@ -132,12 +132,12 @@ FlowPtContainer::FlowPtContainer(const char* name, const char* title) : TNamed(n arr(), warr(), subevents() {} -void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& m, const GFWCorrConfigs& configs, const int& nsub) +void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& maxOrder, const GFWCorrConfigs& configs, const int& nsub) { arr.resize(3 * 3 * 3 * 3); warr.resize(3 * 3 * 3 * 3); if (!mpar) - mpar = m; + mpar = maxOrder; std::vector multiBins = axis.binEdges; int nMultiBins = axis.nBins.value_or(0); if (nMultiBins <= 0) @@ -230,12 +230,12 @@ void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int& LOGF(info, "Container %s initialized with m = %i\n and %i subsamples", this->GetName(), mpar, nsub); return; }; -void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const GFWCorrConfigs& configs, const int& nsub) +void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& maxOrder, const GFWCorrConfigs& configs, const int& nsub) { arr.resize(3 * 3 * 5 * 5); warr.resize(3 * 3 * 5 * 5); if (!mpar) - mpar = m; + mpar = maxOrder; if (fCMTermList) delete fCMTermList; fCMTermList = new TList(); @@ -318,12 +318,12 @@ void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const } LOGF(info, "Container %s initialized with m = %i\n", this->GetName(), mpar); }; -void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const int& m, const GFWCorrConfigs& configs, const int& nsub) +void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const int& maxOrder, const GFWCorrConfigs& configs, const int& nsub) { arr.resize(3 * 3 * 5 * 5); warr.resize(3 * 3 * 5 * 5); if (!mpar) - mpar = m; + mpar = maxOrder; if (fCMTermList) delete fCMTermList; fCMTermList = new TList(); @@ -406,7 +406,7 @@ void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const in } LOGF(info, "Container %s initialized with m = %i\n", this->GetName(), mpar); }; -void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, const int& m, const int& nsubev, const int& nsub) +void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, const int& maxOrder, const int& nsubev, const int& nsub) { if (nsubev < 1) { LOGF(fatal, "Need at least one subevent"); @@ -414,7 +414,7 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con } nSubevents = nsubev; if (!mpar) - mpar = m; + mpar = maxOrder; std::vector multiBins = axis.binEdges; int nMultiBins = axis.nBins.value_or(0); if (nMultiBins <= 0) @@ -431,7 +431,7 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con // Get all possible subevent combinations given m particles and nsubev subevents - also considering not using all m particles, e.g. all lower orders std::vector current; - getSubevents(m, nsubev + 1, current, subevents); + getSubevents(mpar, nsubev + 1, current, subevents); // remove unused "extra" subevent for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back()) subevent.pop_back(); @@ -486,7 +486,7 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con } LOGF(info, "Container %s initialized Subevents and %i subsamples", this->GetName(), nsub); } -void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m, const int& nsubev, const int& nsub) +void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& maxOrder, const int& nsubev, const int& nsub) { if (nsubev < 1) { LOGF(fatal, "Need at least one subevent"); @@ -494,7 +494,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m } nSubevents = nsubev; if (!mpar) - mpar = m; + mpar = maxOrder; if (fSubList) delete fSubList; @@ -503,7 +503,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m // Get all possible subevent combinations given m particles and nsubev subevents - also considering not using all m particles, e.g. all lower orders std::vector current; - getSubevents(m, nsubev + 1, current, subevents); + getSubevents(mpar, nsubev + 1, current, subevents); // remove unused "extra" subevent for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back()) subevent.pop_back(); @@ -558,7 +558,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m } LOGF(info, "Container %s initialized Subevents and %i subsamples", this->GetName(), nsub); } -void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh, const int& m, const int& nsubev, const int& nsub) +void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh, const int& maxOrder, const int& nsubev, const int& nsub) { if (nsubev < 1) { LOGF(fatal, "Need at least one subevent"); @@ -566,7 +566,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh, } nSubevents = nsubev; if (!mpar) - mpar = m; + mpar = maxOrder; if (fSubList) delete fSubList; fSubList = new TList(); @@ -1929,19 +1929,19 @@ TH1* FlowPtContainer::raiseHistToPower(TH1* inh, double p) } return reth; } -void FlowPtContainer::getSubevents(int k, int n, std::vector& current, std::vector>& subevents) +void FlowPtContainer::getSubevents(int k, int n, std::vector& current, std::vector>& outputSubevents) { if (n == 1) { // Last box gets all remaining objects current.push_back(k); - subevents.push_back(current); + outputSubevents.push_back(current); current.pop_back(); return; } for (int i = 0; i <= k; ++i) { current.push_back(i); - getSubevents(k - i, n - 1, current, subevents); + getSubevents(k - i, n - 1, current, outputSubevents); current.pop_back(); } } diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.h b/PWGCF/GenericFramework/Core/FlowPtContainer.h index 8c3a33a4bad..f6641d108f0 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.h +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.h @@ -49,13 +49,13 @@ class FlowPtContainer : public TNamed explicit FlowPtContainer(const char* name); ~FlowPtContainer(); FlowPtContainer(const char* name, const char* title); - void initialise(const o2::framework::AxisSpec axis, const int& m, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); - void initialise(int nbinsx, double* xbins, const int& m, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); - void initialise(int nbinsx, double xlow, double xhigh, const int& m, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); + void initialise(const o2::framework::AxisSpec axis, const int& maxOrder, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); + void initialise(int nbinsx, double* xbins, const int& maxOrder, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); + void initialise(int nbinsx, double xlow, double xhigh, const int& maxOrder, const o2::analysis::genericframework::GFWCorrConfigs& configs, const int& nsub = 10); // initial pt-pt correlations with two subevents - void initialiseSubevent(const o2::framework::AxisSpec axis, const int& m, const int& nsubev = 2, const int& nsub = 10); - void initialiseSubevent(int nbinsx, double* xbins, const int& m, const int& nsubev = 2, const int& nsub = 10); - void initialiseSubevent(int nbinsx, double xlow, double xhigh, const int& m, const int& nsubev = 2, const int& nsub = 10); + void initialiseSubevent(const o2::framework::AxisSpec axis, const int& maxOrder, const int& nsubev = 2, const int& nsub = 10); + void initialiseSubevent(int nbinsx, double* xbins, const int& maxOrder, const int& nsubev = 2, const int& nsub = 10); + void initialiseSubevent(int nbinsx, double xlow, double xhigh, const int& maxOrder, const int& nsubev = 2, const int& nsub = 10); void fill(const double& w, const double& pt); void fillSub(const double& w, const double& pt, int subIndex); void fillSub1(const double& w, const double& pt) { fillSub(w, pt, 0); } diff --git a/PWGCF/GenericFramework/Core/GFWConfig.h b/PWGCF/GenericFramework/Core/GFWConfig.h index 1bc1811c30a..41efe336efa 100644 --- a/PWGCF/GenericFramework/Core/GFWConfig.h +++ b/PWGCF/GenericFramework/Core/GFWConfig.h @@ -53,6 +53,7 @@ int CheckSameSize(const std::vector& first, const std::vector&... rest) class GFWBinningCuts { public: + // cppcheck-suppress noExplicitConstructor GFWBinningCuts(int vtxzbins_ = 40, int etabins_ = 16, int phibins_ = 72, int nchbins_ = 300, float nchmin_ = 0, float nchmax_ = 3000, float ptpoimin_ = 0.2, float ptpoimax_ = 10., float ptrefmin_ = 0.2, float ptrefmax_ = 3., std::vector ptbinning_ = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, @@ -144,6 +145,7 @@ class GFWBinningCuts class GFWRegions { public: + // cppcheck-suppress noExplicitConstructor GFWRegions(std::vector names_ = {"refN", "refP", "refFull"}, std::vector etaminvals_ = {-0.8, 0.4, -0.8}, std::vector etamaxvals_ = {-0.4, 0.8, 0.8}, std::vector pTDifs_ = {0, 0, 0}, @@ -189,6 +191,7 @@ class GFWRegions class GFWCorrConfigs { public: + // cppcheck-suppress noExplicitConstructor GFWCorrConfigs(std::vector corrs_ = {"refP {2} refN {-2}", "refP {3} refN {-3}", "refP {4} refN {-4}", "refFull {2 -2}", "refFull {2 2 -2 -2}"}, std::vector heads_ = {"ChGap22", "ChGap32", "ChGap42", "ChFull22", "ChFull24"},