Skip to content

Commit 84fa585

Browse files
committed
linter
1 parent ded3316 commit 84fa585

3 files changed

Lines changed: 42 additions & 36 deletions

File tree

PWGCF/GenericFramework/Core/FlowPtContainer.cxx

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void FlowPtContainer::initialise(const o2::framework::AxisSpec axis, const int&
161161
for (int m = 0; m < mpar; ++m) {
162162
fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nMultiBins, &multiBins[0]));
163163
}
164-
for (int m = 0; m < 4; ++m) {
164+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
165165
for (int i = 0; i <= m; ++i) {
166166
fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nMultiBins, &multiBins[0]));
167167
}
@@ -251,7 +251,7 @@ void FlowPtContainer::initialise(int nbinsx, double* xbins, const int& m, const
251251
for (int m = 0; m < mpar; ++m) {
252252
fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xbins));
253253
}
254-
for (int m = 0; m < 4; ++m) {
254+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
255255
for (int i = 0; i <= m; ++i) {
256256
fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xbins));
257257
}
@@ -339,7 +339,7 @@ void FlowPtContainer::initialise(int nbinsx, double xlow, double xhigh, const in
339339
for (int m = 0; m < mpar; ++m) {
340340
fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xlow, xhigh));
341341
}
342-
for (int m = 0; m < 4; ++m) {
342+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
343343
for (int i = 0; i <= m; ++i) {
344344
fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xlow, xhigh));
345345
}
@@ -433,7 +433,7 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con
433433
std::vector<int> current;
434434
getSubevents(m, nsubev + 1, current, subevents);
435435
// remove unused "extra" subevent
436-
for (auto& subevent : subevents)
436+
for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back())
437437
subevent.pop_back();
438438
subevents.erase(subevents.begin(), subevents.begin() + 1);
439439

@@ -455,14 +455,15 @@ void FlowPtContainer::initialiseSubevent(const o2::framework::AxisSpec axis, con
455455
delete fSubCMList;
456456
fSubCMList = new TList();
457457
fSubCMList->SetOwner(kTRUE);
458-
for (int subEv = 0; subEv < 2; ++subEv) {
459-
for (int m = 0; m < 4; ++m) {
458+
const int maxSubEv = 2;
459+
for (int subEv = 0; subEv < maxSubEv; ++subEv) {
460+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
460461
for (int i = 0; i <= m; ++i) {
461462
fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nMultiBins, &multiBins[0]));
462463
}
463464
}
464465
}
465-
for (int m = 2; m <= 4; ++m) {
466+
for (int m = 2; m <= centralMomentMaxOrder; ++m) {
466467
for (int first = 1; first < m; ++first) {
467468
for (int second = first; second < m; ++second) {
468469
if (first > second)
@@ -504,7 +505,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m
504505
std::vector<int> current;
505506
getSubevents(m, nsubev + 1, current, subevents);
506507
// remove unused "extra" subevent
507-
for (auto& subevent : subevents)
508+
for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back())
508509
subevent.pop_back();
509510
subevents.erase(subevents.begin(), subevents.begin() + 1);
510511

@@ -526,14 +527,15 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double* xbins, const int& m
526527
delete fSubCMList;
527528
fSubCMList = new TList();
528529
fSubCMList->SetOwner(kTRUE);
529-
for (int subEv = 0; subEv < 2; ++subEv) {
530-
for (int m = 0; m < 4; ++m) {
530+
const int maxSubEv = 2;
531+
for (int subEv = 0; subEv < maxSubEv; ++subEv) {
532+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
531533
for (int i = 0; i <= m; ++i) {
532534
fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nbinsx, xbins));
533535
}
534536
}
535537
}
536-
for (int m = 2; m <= 4; ++m) {
538+
for (int m = 2; m <= centralMomentMaxOrder; ++m) {
537539
for (int first = 1; first < m; ++first) {
538540
for (int second = first; second < m; ++second) {
539541
if (first > second)
@@ -574,7 +576,7 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh,
574576
std::vector<int> current;
575577
getSubevents(mpar, nsubev + 1, current, subevents);
576578
// remove unused "extra" subevent
577-
for (auto& subevent : subevents)
579+
for (auto& subevent : subevents) // o2-linter: disable=const-ref-in-for-loop (modified through pop_back())
578580
subevent.pop_back();
579581
subevents.erase(subevents.begin(), subevents.begin() + 1);
580582

@@ -596,14 +598,15 @@ void FlowPtContainer::initialiseSubevent(int nbinsx, double xlow, double xhigh,
596598
delete fSubCMList;
597599
fSubCMList = new TList();
598600
fSubCMList->SetOwner(kTRUE);
599-
for (int subEv = 0; subEv < 2; ++subEv) {
600-
for (int m = 0; m < 4; ++m) {
601+
const int maxSubEv = 2;
602+
for (int subEv = 0; subEv < maxSubEv; ++subEv) {
603+
for (int m = 0; m < centralMomentMaxOrder; ++m) {
601604
for (int i = 0; i <= m; ++i) {
602605
fSubCMList->Add(new BootstrapProfile(Form("cm%i_sub%i_Mpt%i", m + 1, subEv + 1, i), this->GetTitle(), nbinsx, xlow, xhigh));
603606
}
604607
}
605608
}
606-
for (int m = 2; m <= 4; ++m) {
609+
for (int m = 2; m <= centralMomentMaxOrder; ++m) {
607610
for (int first = 1; first < m; ++first) {
608611
for (int second = first; second < m; ++second) {
609612
if (first > second)
@@ -669,10 +672,10 @@ void FlowPtContainer::calculateSubeventCorrelations()
669672
{
670673
corrNumSub.clear();
671674
corrNumSub.resize(nSubevents, std::vector<double>(mpar + 1, 0));
672-
for (auto& corrnum : corrNumSub)
675+
for (auto& corrnum : corrNumSub) // o2-linter: disable=const-ref-in-for-loop (assigned a value)
673676
corrnum[0] = 1.0;
674677
corrDenSub.resize(nSubevents, std::vector<double>(mpar + 1, 0));
675-
for (auto& corrden : corrDenSub)
678+
for (auto& corrden : corrDenSub) // o2-linter: disable=const-ref-in-for-loop (assigned a value)
676679
corrden[0] = 1.0;
677680

678681
for (int subIndex = 0; subIndex < nSubevents; ++subIndex) {
@@ -912,21 +915,21 @@ void FlowPtContainer::fillCMProfiles(const double& centmult, const double& rn)
912915
return;
913916
cmVal.push_back(sumP[getVectorIndex(1, 1)] / cmDen[1]);
914917
dynamic_cast<BootstrapProfile*>(fCMTermList->At(0))->FillProfile(centmult, cmVal[1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[1], rn);
915-
if (mpar < 2 || sumP[getVectorIndex(2, 0)] == 0 || cmDen[2] == 0)
918+
if (mpar < 2 || sumP[getVectorIndex(2, 0)] == 0 || cmDen[2] == 0) // o2-linter: disable=magic-number (less than order 2)
916919
return;
917920
cmVal.push_back(1 / cmDen[2] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 2)]));
918921
dynamic_cast<BootstrapProfile*>(fCMTermList->At(1))->FillProfile(centmult, cmVal[2], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn);
919922
cmVal.push_back(-2 * 1 / cmDen[2] * (sumP[getVectorIndex(1, 0)] * sumP[getVectorIndex(1, 1)] - sumP[getVectorIndex(2, 1)]));
920923
dynamic_cast<BootstrapProfile*>(fCMTermList->At(2))->FillProfile(centmult, cmVal[3], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[2], rn);
921-
if (mpar < 3 || sumP[getVectorIndex(3, 0)] == 0 || cmDen[3] == 0)
924+
if (mpar < 3 || sumP[getVectorIndex(3, 0)] == 0 || cmDen[3] == 0) // o2-linter: disable=magic-number (less than order 3)
922925
return;
923926
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)]));
924927
dynamic_cast<BootstrapProfile*>(fCMTermList->At(3))->FillProfile(centmult, cmVal[4], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn);
925928
cmVal.push_back(-3 * 1 / cmDen[3] * (sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 1)] * sumP[getVectorIndex(1, 0)] - 2 * sumP[getVectorIndex(2, 1)] * sumP[getVectorIndex(1, 1)] + 2 * sumP[getVectorIndex(3, 2)] - sumP[getVectorIndex(2, 2)] * sumP[getVectorIndex(1, 0)]));
926929
dynamic_cast<BootstrapProfile*>(fCMTermList->At(4))->FillProfile(centmult, cmVal[5], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn);
927930
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)]));
928931
dynamic_cast<BootstrapProfile*>(fCMTermList->At(5))->FillProfile(centmult, cmVal[6], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDen[3], rn);
929-
if (mpar < 4 || sumP[getVectorIndex(4, 0)] == 0 || cmDen[4] == 0)
932+
if (mpar < 4 || sumP[getVectorIndex(4, 0)] == 0 || cmDen[4] == 0) // o2-linter: disable=magic-number (less than order 4)
930933
return;
931934
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)]));
932935
dynamic_cast<BootstrapProfile*>(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
943946
// do I need to add an extra return statement here to match fillCMProfiles?
944947
if (mpar < 1)
945948
return;
946-
if (nSubevents < 2)
949+
const int minSubevents = 2;
950+
if (nSubevents < minSubevents)
947951
return;
948952

949953
int indOffset = 0;
@@ -977,7 +981,7 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl
977981
dynamic_cast<BootstrapProfile*>(fSubCMList->At(indOffset + 0))->FillProfile(centmult, cmValSub[nSubevents - 1][1], (fEventWeight == EventWeight::UnityWeight) ? 1.0 : cmDenSub[nSubevents - 1][1], rn);
978982
}
979983

980-
if (mpar >= 2) {
984+
if (mpar >= 2) { // o2-linter: disable=magic-number (greater than order 2)
981985
if (insub[0][getVectorIndex(2, 0)] != 0 && cmDenSub[0][2] != 0) {
982986
cmValSub[0].push_back(1 / cmDenSub[0][2] * (insub[0][getVectorIndex(1, 1)] * insub[0][getVectorIndex(1, 1)] - insub[0][getVectorIndex(2, 2)]));
983987
dynamic_cast<BootstrapProfile*>(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
993997
validMpar[0] = true;
994998
}
995999

996-
if (mpar >= 3) {
1000+
if (mpar >= 3) { // o2-linter: disable=magic-number (greater than order 3)
9971001
if (insub[0][getVectorIndex(3, 0)] != 0 && cmDenSub[0][3] != 0) {
9981002
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)]));
9991003
dynamic_cast<BootstrapProfile*>(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
10121016
}
10131017
validMpar[1] = true;
10141018
}
1015-
if (mpar >= 4) {
1019+
if (mpar >= 4) { // o2-linter: disable=magic-number (greater than order 4)
10161020
if (insub[0][getVectorIndex(4, 0)] != 0 && cmDenSub[0][4] != 0) {
10171021
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)]));
10181022
dynamic_cast<BootstrapProfile*>(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
10361040
validMpar[2] = true;
10371041
}
10381042
// Fill cross terms
1039-
for (int m = 2; m <= 4; ++m) {
1043+
for (int m = 2; m <= centralMomentMaxOrder; ++m) {
10401044
if (!validMpar[m - 2])
10411045
continue;
10421046
for (int first = 1; first < m; ++first) {
@@ -1058,7 +1062,8 @@ void FlowPtContainer::fillCMSubeventProfiles(const double& centmult, const doubl
10581062
}
10591063
void FlowPtContainer::fillArray(FillType a, FillType b, double c, double d)
10601064
{
1061-
for (int idx = 0; idx < 225; ++idx) {
1065+
const int nTerms = 3 * 3 * 5 * 5;
1066+
for (int idx = 0; idx < nTerms; ++idx) {
10621067
int i = idx % 3;
10631068
int j = ((idx - i) / 3) % 3;
10641069
int k = ((idx - j * 3 - i) / 9) % 5;
@@ -1763,7 +1768,7 @@ void FlowPtContainer::createCentralMomentList()
17631768
delete fCentralMomentList;
17641769
fCentralMomentList = new TList();
17651770
fCentralMomentList->SetOwner();
1766-
for (auto m(1); m <= 4; ++m) {
1771+
for (auto m(1); m <= centralMomentMaxOrder; ++m) {
17671772
for (int i = -1; i < reinterpret_cast<BootstrapProfile*>(fCMTermList->At(0))->getNSubs(); ++i) {
17681773
TH1* hMpt = reinterpret_cast<BootstrapProfile*>(fCMTermList->At(0))->getHist(i);
17691774
std::vector<TH1*> hTs;
@@ -1836,7 +1841,7 @@ void FlowPtContainer::calculateCumulantHists(std::vector<TH1*> inh, int ind)
18361841
}
18371842
return;
18381843
}
1839-
Long64_t FlowPtContainer::Merge(TCollection* collist)
1844+
Long64_t FlowPtContainer::Merge(TCollection* collist) // o2-linter: disable=name/function-variable (Keep name consistent with ROOT streamer merging)
18401845
{
18411846
if (!fCorrList || !fCMTermList)
18421847
return 0;

PWGCF/GenericFramework/Core/FlowPtContainer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class FlowPtContainer : public TNamed
221221
double getStdABDDD(T& inarr);
222222

223223
private:
224+
static const int centralMomentMaxOrder = 4;
224225
std::vector<std::vector<int>> subevents;
225226
void getSubevents(int k, int n, std::vector<int>& current, std::vector<std::vector<int>>& subevents);
226227
static constexpr float FactorialArray[9] = {1., 1., 2., 6., 24., 120., 720., 5040., 40320.};

PWGCF/GenericFramework/Tasks/flowGfwNonflow.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,31 +663,31 @@ struct FlowGfwNonflow {
663663
int bin = 0;
664664

665665
if (cfgCorrections.cfgUse2DEfficiency) {
666-
auto* eff_hist = dynamic_cast<TH2D*>(correctionsConfig.mEfficiency);
667-
if (!eff_hist) {
666+
auto* effHist = dynamic_cast<TH2D*>(correctionsConfig.mEfficiency);
667+
if (!effHist) {
668668
LOGF(error, "Efficiency object at %s is not a TH2D", cfgCorrections.cfgEfficiencyPath.value.c_str());
669669
return -1.;
670670
}
671-
bin = eff_hist->FindBin(track.pt(), centrality);
671+
bin = effHist->FindBin(track.pt(), centrality);
672672
if (!bin) {
673673
return -1.;
674674
}
675-
const double eff = eff_hist->GetBinContent(bin);
675+
const double eff = effHist->GetBinContent(bin);
676676
if (!std::isfinite(eff) || eff <= 0.) {
677677
return -1.;
678678
}
679679
return 1. / eff;
680680
} else {
681-
auto* eff_hist = dynamic_cast<TH1D*>(correctionsConfig.mEfficiency);
682-
if (!eff_hist) {
681+
auto* effHist = dynamic_cast<TH1D*>(correctionsConfig.mEfficiency);
682+
if (!effHist) {
683683
LOGF(error, "Efficiency object at %s is not a TH1D", cfgCorrections.cfgEfficiencyPath.value.c_str());
684684
return -1.;
685685
}
686-
bin = eff_hist->FindBin(track.pt());
686+
bin = effHist->FindBin(track.pt());
687687
if (!bin) {
688688
return -1.;
689689
}
690-
const double eff = eff_hist->GetBinContent(bin);
690+
const double eff = effHist->GetBinContent(bin);
691691
if (!std::isfinite(eff) || eff <= 0.) {
692692
return -1.;
693693
}

0 commit comments

Comments
 (0)