Skip to content

Commit 1b58bae

Browse files
committed
o2-linter
1 parent ceac382 commit 1b58bae

File tree

1 file changed

+64
-57
lines changed

1 file changed

+64
-57
lines changed

PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ struct FlowGenericFramework {
323323
KAONS,
324324
PROTONS
325325
};
326+
enum ParticleIDs {
327+
CHARGEDID,
328+
PIONID,
329+
KAONID,
330+
PROTONID,
331+
SPECIESCOUNT
332+
};
326333
enum OutputSpecies {
327334
K0 = 0,
328335
LAMBDA = 1,
@@ -460,7 +467,7 @@ struct FlowGenericFramework {
460467
projectMatrix(cfgPIDCuts.nSigmas->getData(), tpcNsigmaCut, tofNsigmaCut, itsNsigmaCut);
461468
readMatrix(cfgPIDCuts.resonanceCuts->getData(), resoCutVals);
462469
readMatrix(cfgPIDCuts.resonanceSwitches->getData(), resoSwitchVals);
463-
PrintResoCuts();
470+
printResoCuts();
464471

465472
AxisSpec phiAxis = {o2::analysis::gfw::phibins, o2::analysis::gfw::philow, o2::analysis::gfw::phiup, "#phi"};
466473
AxisSpec phiModAxis = {100, 0, constants::math::PI / 9, "fmod(#varphi,#pi/9)"};
@@ -746,7 +753,7 @@ struct FlowGenericFramework {
746753

747754
static constexpr std::string_view FillTimeName[] = {"before/", "after/"};
748755

749-
void PrintResoCuts()
756+
void printResoCuts()
750757
{
751758
auto printTable = [](const auto& lbl, const auto& valuesMatrix, const std::string& title) {
752759
LOGF(info, "===== %s =====", title.c_str());
@@ -1007,7 +1014,7 @@ struct FlowGenericFramework {
10071014
th1sList[run][hEventSel]->Fill(kTVXinTRD);
10081015
}
10091016
// Cut on event selection flags
1010-
for (auto& cut : eventcutflags) {
1017+
for (const auto& cut : eventcutflags) {
10111018
if (!cut.enabled)
10121019
continue;
10131020
if (!collision.selection_bit(cut.flag))
@@ -1105,7 +1112,7 @@ struct FlowGenericFramework {
11051112
{
11061113
if (std::fabs(track.dcaXY()) > (0.0105f + 0.0035f / track.pt()))
11071114
return false;
1108-
return ((track.tpcNClsCrossedRows() >= 70) && (track.tpcNClsFound() >= 50) && (track.itsNCls() >= 5));
1115+
return ((track.tpcNClsCrossedRows() >= 70) && (track.tpcNClsFound() >= 50) && (track.itsNCls() >= 5)); // o2-linter: disable=magic-number (hard coded default cuts)
11091116
}
11101117

11111118
enum DataType {
@@ -1209,7 +1216,7 @@ struct FlowGenericFramework {
12091216
}
12101217

12111218
float total = 0;
1212-
unsigned int total_uncorr = 0;
1219+
unsigned int totaluncorr = 0;
12131220

12141221
std::vector<float> pidtotal;
12151222
std::vector<double> nch;
@@ -1251,13 +1258,13 @@ struct FlowGenericFramework {
12511258
}
12521259
}
12531260

1254-
double chtotal = (cfgUseNchCorrection) ? acceptedtracks.total : acceptedtracks.total_uncorr;
1261+
double chtotal = (cfgUseNchCorrection) ? acceptedtracks.total : acceptedtracks.totaluncorr;
12551262
// calculate fractions
12561263
std::vector<std::vector<double>> inputs = {acceptedtracks.nch, acceptedtracks.npi, acceptedtracks.nka, acceptedtracks.npr};
12571264
std::vector<std::vector<double>> fractions;
12581265
fractions.reserve(inputs.size());
12591266
int pidcounter = 0;
1260-
for (const auto& vec : inputs) {
1267+
for (auto& vec : inputs) { // o2-linter: disable=const-ref-in-for-loop (modified through transform)
12611268
fractions.emplace_back();
12621269
fractions.back().reserve(vec.size());
12631270

@@ -1284,10 +1291,10 @@ struct FlowGenericFramework {
12841291
for (std::size_t i = 0; i < fractions[3].size(); ++i)
12851292
registry.fill(HIST("npt_pr"), fPtAxis->GetBinCenter(i + 1), centmult, fractions[3][i]);
12861293

1287-
if (corrconfigsV02.size() < 4)
1294+
if (corrconfigsV02.size() < SPECIESCOUNT) //
12881295
return;
12891296

1290-
for (uint l_ind = 0; l_ind < 4; ++l_ind) {
1297+
for (uint l_ind = 0; l_ind < SPECIESCOUNT; ++l_ind) {
12911298
for (int i = 1; i <= fPtAxis->GetNbins(); i++) {
12921299
auto dnx = fGFW->Calculate(corrconfigsV02.at(l_ind), i - 1, kTRUE).real();
12931300
if (dnx == 0)
@@ -1298,11 +1305,11 @@ struct FlowGenericFramework {
12981305
}
12991306
}
13001307

1301-
if (corrconfigsV0.size() < 4)
1308+
if (corrconfigsV0.size() < SPECIESCOUNT)
13021309
return;
13031310
if (fFCpt->corrDen[0] == 0.)
13041311
return;
1305-
for (uint l_ind = 0; l_ind < 4; ++l_ind) {
1312+
for (uint l_ind = 0; l_ind < SPECIESCOUNT; ++l_ind) {
13061313
double mpt = fFCpt->corrNum[1] / fFCpt->corrDen[1];
13071314
for (int i = 1; i <= fPtAxis->GetNbins(); i++) {
13081315
(dt == kGen) ? fFCgen->FillProfile(Form("%s_pt_%i", corrconfigsV0.at(l_ind).Head.c_str(), i), centmult, mpt * fractions[l_ind][i - 1], 1., rndm) : fFC->FillProfile(Form("%s_pt_%i", corrconfigsV0.at(l_ind).Head.c_str(), i), centmult, mpt * fractions[l_ind][i - 1], 1., rndm);
@@ -1373,7 +1380,7 @@ struct FlowGenericFramework {
13731380
processTrack(track, vtxz, field, run, densitycorrections, acceptedTracks);
13741381
}
13751382
registry.fill(HIST("trackQA/after/Nch_corrected"), acceptedTracks.total);
1376-
registry.fill(HIST("trackQA/after/Nch_uncorrected"), acceptedTracks.total_uncorr);
1383+
registry.fill(HIST("trackQA/after/Nch_uncorrected"), acceptedTracks.totaluncorr);
13771384

13781385
int multiplicity = 0;
13791386
switch (cfgUseNchCorrection) {
@@ -1384,7 +1391,7 @@ struct FlowGenericFramework {
13841391
multiplicity = acceptedTracks.total;
13851392
break;
13861393
case 2:
1387-
multiplicity = acceptedTracks.total_uncorr;
1394+
multiplicity = acceptedTracks.totaluncorr;
13881395
break;
13891396
default:
13901397
multiplicity = tracks.size();
@@ -1394,7 +1401,7 @@ struct FlowGenericFramework {
13941401
if (!cfgFillWeights)
13951402
fillOutputContainers<dt>((cfgUseNch) ? multiplicity : centrality, lRandom, acceptedTracks);
13961403

1397-
std::vector<std::vector<float>> npt_resonances(6, std::vector<float>(o2::analysis::gfw::ptbinning.size()));
1404+
std::vector<std::vector<float>> nptResonances(6, std::vector<float>(o2::analysis::gfw::ptbinning.size()));
13981405
// Process V0s
13991406
for (const auto& v0 : v0s) {
14001407
if (resoSwitchVals[K0][kUseParticle]) {
@@ -1403,11 +1410,11 @@ struct FlowGenericFramework {
14031410
int ptBinIndex = fPtAxis->FindBin(v0.pt()) - 1;
14041411
if (!(ptBinIndex < 0 || ptBinIndex >= static_cast<int>(o2::analysis::gfw::ptbinning.size()))) {
14051412
if (v0.mK0Short() > cfgPIDCuts.cfgK0SideBand1Min && v0.mK0Short() < cfgPIDCuts.cfgK0SideBand1Max)
1406-
npt_resonances[0][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1413+
nptResonances[0][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14071414
if (v0.mK0Short() > cfgPIDCuts.cfgK0SignalMin && v0.mK0Short() < cfgPIDCuts.cfgK0SignalMax)
1408-
npt_resonances[1][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1415+
nptResonances[1][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14091416
if (v0.mK0Short() > cfgPIDCuts.cfgK0SideBand2Min && v0.mK0Short() < cfgPIDCuts.cfgK0SideBand2Max)
1410-
npt_resonances[2][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1417+
nptResonances[2][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14111418
}
14121419
}
14131420
}
@@ -1418,20 +1425,20 @@ struct FlowGenericFramework {
14181425
int ptBinIndex = fPtAxis->FindBin(v0.pt()) - 1;
14191426
if (!(ptBinIndex < 0 || ptBinIndex >= static_cast<int>(o2::analysis::gfw::ptbinning.size()))) {
14201427
if (v0.mLambda() > cfgPIDCuts.cfgLambdaSideBand1Min && v0.mLambda() < cfgPIDCuts.cfgLambdaSideBand1Max)
1421-
npt_resonances[3][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1428+
nptResonances[3][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14221429
if (v0.mLambda() > cfgPIDCuts.cfgLambdaSignalMin && v0.mLambda() < cfgPIDCuts.cfgLambdaSignalMax)
1423-
npt_resonances[4][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1430+
nptResonances[4][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14241431
if (v0.mLambda() > cfgPIDCuts.cfgLambdaSideBand2Min && v0.mLambda() < cfgPIDCuts.cfgLambdaSideBand2Max)
1425-
npt_resonances[5][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1432+
nptResonances[5][ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
14261433
}
14271434
}
14281435
}
14291436
}
1430-
double chtotal = (cfgUseNchCorrection) ? acceptedTracks.total : acceptedTracks.total_uncorr;
1437+
double chtotal = (cfgUseNchCorrection) ? acceptedTracks.total : acceptedTracks.totaluncorr;
14311438
// calculate fractions
1432-
std::vector<std::vector<float>> fractions_resonances = npt_resonances;
1439+
std::vector<std::vector<float>> fractions_resonances = nptResonances;
14331440
int pidcounter = 0;
1434-
for (auto& vec : fractions_resonances) {
1441+
for (auto& vec : fractions_resonances) { // o2-linter: disable=const-ref-in-for-loop (modified through transform)
14351442
double total = chtotal;
14361443
if (cfgUsePIDTotal)
14371444
total = (pidcounter) ? std::accumulate(vec.begin(), vec.end(), 0.f) : chtotal;
@@ -1501,7 +1508,7 @@ struct FlowGenericFramework {
15011508
if (std::abs(track.eta()) < cfgEtaNch) {
15021509
if (weffCh > 0)
15031510
acceptedTracks.total += (cfgUseNchCorrection) ? weffCh : 1.0;
1504-
++acceptedTracks.total_uncorr;
1511+
++acceptedTracks.totaluncorr;
15051512
}
15061513

15071514
if (!trackSelected(track, field))
@@ -1510,11 +1517,11 @@ struct FlowGenericFramework {
15101517
int pidIndex = 0;
15111518
if (cfgUsePID) {
15121519
if (std::abs(mcParticle.pdgCode()) == kPiPlus)
1513-
pidIndex = 1;
1520+
pidIndex = PIONID;
15141521
if (std::abs(mcParticle.pdgCode()) == kKPlus)
1515-
pidIndex = 2;
1522+
pidIndex = KAONID;
15161523
if (std::abs(mcParticle.pdgCode()) == kProton)
1517-
pidIndex = 3;
1524+
pidIndex = PROTONID;
15181525
}
15191526

15201527
if (std::abs(track.eta()) < cfgEtaNch) {
@@ -1527,19 +1534,19 @@ struct FlowGenericFramework {
15271534
if (!(ptBinIndex < 0 || ptBinIndex >= static_cast<int>(o2::analysis::gfw::ptbinning.size()))) {
15281535
if (weffCh > 0)
15291536
acceptedTracks.nch[ptBinIndex] += (cfgUseNchCorrection) ? weffCh : 1.0;
1530-
if (pidIndex == 1 && weff > 0)
1537+
if (pidIndex == PIONID && weff > 0)
15311538
acceptedTracks.npi[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1532-
if (pidIndex == 2 && weff > 0)
1539+
if (pidIndex == KAONID && weff > 0)
15331540
acceptedTracks.nka[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
1534-
if (pidIndex == 3 && weff > 0)
1541+
if (pidIndex == PROTONID && weff > 0)
15351542
acceptedTracks.npr[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
15361543
}
15371544
}
15381545

15391546
if (cfgFillWeights) {
15401547
fillWeights(mcParticle, vtxz, 0, run);
15411548
} else {
1542-
fillPtSums<kReco>(track, vtxz, pidIndex);
1549+
fillPtSums<kReco>(track, vtxz);
15431550
fillGFW<kReco>(mcParticle, vtxz, pidIndex, densitycorrections);
15441551
}
15451552

@@ -1572,24 +1579,24 @@ struct FlowGenericFramework {
15721579

15731580
if (std::abs(track.eta()) < cfgEtaNch) {
15741581
++acceptedTracks.total;
1575-
++acceptedTracks.total_uncorr;
1582+
++acceptedTracks.totaluncorr;
15761583

15771584
if (pidIndex)
15781585
acceptedTracks.pidtotal[pidIndex - 1] += 1;
15791586
int ptBinIndex = fPtAxis->FindBin(track.pt()) - 1;
15801587

15811588
if (!(ptBinIndex < 0 || ptBinIndex >= static_cast<int>(o2::analysis::gfw::ptbinning.size()))) {
15821589
acceptedTracks.nch[ptBinIndex] += 1.0;
1583-
if (pidIndex == 1)
1590+
if (pidIndex == PIONID)
15841591
acceptedTracks.npi[ptBinIndex] += 1.0;
1585-
if (pidIndex == 2)
1592+
if (pidIndex == KAONID)
15861593
acceptedTracks.nka[ptBinIndex] += 1.0;
1587-
if (pidIndex == 3)
1594+
if (pidIndex == PROTONID)
15881595
acceptedTracks.npr[ptBinIndex] += 1.0;
15891596
}
15901597
}
15911598

1592-
fillPtSums<kGen>(track, vtxz, pidIndex);
1599+
fillPtSums<kGen>(track, vtxz);
15931600
fillGFW<kGen>(track, vtxz, pidIndex, densitycorrections);
15941601

15951602
if (cfgFillQA)
@@ -1605,7 +1612,7 @@ struct FlowGenericFramework {
16051612
if (std::abs(track.eta()) < cfgEtaNch) {
16061613
if (weffCh > 0)
16071614
acceptedTracks.total += (cfgUseNchCorrection) ? weffCh : 1.0;
1608-
++acceptedTracks.total_uncorr;
1615+
++acceptedTracks.totaluncorr;
16091616
}
16101617

16111618
if (!trackSelected(track, field))
@@ -1624,13 +1631,13 @@ struct FlowGenericFramework {
16241631
if (!(ptBinIndex < 0 || ptBinIndex >= static_cast<int>(o2::analysis::gfw::ptbinning.size()))) {
16251632
if (weffCh > 0)
16261633
acceptedTracks.nch[ptBinIndex] += (cfgUseNchCorrection) ? weffCh : 1.0;
1627-
if (pidIndex == 1 && weff > 0) {
1634+
if (pidIndex == PIONID && weff > 0) {
16281635
acceptedTracks.npi[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
16291636
}
1630-
if (pidIndex == 2 && weff > 0) {
1637+
if (pidIndex == KAONID && weff > 0) {
16311638
acceptedTracks.nka[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
16321639
}
1633-
if (pidIndex == 3 && weff > 0) {
1640+
if (pidIndex == PROTONID && weff > 0) {
16341641
acceptedTracks.npr[ptBinIndex] += (cfgUseNchCorrection) ? weff : 1.0;
16351642
}
16361643
}
@@ -1639,7 +1646,7 @@ struct FlowGenericFramework {
16391646
if (cfgFillWeights) {
16401647
fillWeights(track, vtxz, pidIndex, run);
16411648
} else {
1642-
fillPtSums<kReco>(track, vtxz, pidIndex);
1649+
fillPtSums<kReco>(track, vtxz);
16431650
fillGFW<kReco>(track, vtxz, pidIndex, densitycorrections);
16441651
}
16451652
if (cfgFillQA) {
@@ -1685,7 +1692,7 @@ struct FlowGenericFramework {
16851692
bool selectK0(TCollision const& collision, TV0 const& v0, const double& centrality, double& weff)
16861693
{
16871694

1688-
double mass_K0s = v0.mK0Short();
1695+
double massK0s = v0.mK0Short();
16891696

16901697
auto postrack = v0.template posTrack_as<GFWTracks>();
16911698
auto negtrack = v0.template negTrack_as<GFWTracks>();
@@ -1694,7 +1701,7 @@ struct FlowGenericFramework {
16941701
if (postrack.pt() < resoCutVals[K0][kPosTrackPt] || negtrack.pt() < resoCutVals[K0][kNegTrackPt])
16951702
return false;
16961703
registry.fill(HIST("K0/hK0Count"), kFillDaughterPt);
1697-
if (mass_K0s < resoCutVals[K0][kMassMin] && mass_K0s > resoCutVals[K0][kMassMax])
1704+
if (massK0s < resoCutVals[K0][kMassMin] && massK0s > resoCutVals[K0][kMassMax])
16981705
return false;
16991706
registry.fill(HIST("K0/hK0Count"), kFillMassCut);
17001707
// Rapidity correction
@@ -1724,7 +1731,7 @@ struct FlowGenericFramework {
17241731
return false;
17251732
registry.fill(HIST("K0/hK0Count"), kFillDaughterTrackSelection);
17261733

1727-
registry.fill(HIST("K0/hK0Mass_sparse"), mass_K0s, v0.pt(), centrality);
1734+
registry.fill(HIST("K0/hK0Mass_sparse"), massK0s, v0.pt(), centrality);
17281735
registry.fill(HIST("K0/hK0Phi"), v0.phi());
17291736
registry.fill(HIST("K0/hK0Eta"), v0.eta());
17301737
registry.fill(HIST("K0/PiPlusTPC_K0"), postrack.pt(), postrack.tpcNSigmaKa());
@@ -1734,9 +1741,9 @@ struct FlowGenericFramework {
17341741

17351742
registry.fill(HIST("K0/hK0s"), 1);
17361743
if (cfgUsePIDEfficiencies) {
1737-
double weff_d1 = getEfficiency(postrack, 1);
1738-
double weff_d2 = getEfficiency(negtrack, 1);
1739-
weff = weff_d1 * weff_d2;
1744+
double weffDaughter1 = getEfficiency(postrack, 1);
1745+
double weffDaughter2 = getEfficiency(negtrack, 1);
1746+
weff = weffDaughter1 * weffDaughter2;
17401747
if (weff > 0)
17411748
registry.fill(HIST("K0/hK0s_corrected"), weff);
17421749
}
@@ -1822,9 +1829,9 @@ struct FlowGenericFramework {
18221829

18231830
registry.fill(HIST("Lambda/hLambdas"), 1);
18241831
if (cfgUsePIDEfficiencies) {
1825-
double weff_d1 = getEfficiency(postrack, 3);
1826-
double weff_d2 = getEfficiency(negtrack, 1);
1827-
weff = weff_d1 * weff_d2;
1832+
double weffDaughter1 = getEfficiency(postrack, 3);
1833+
double weffDaughter2 = getEfficiency(negtrack, 1);
1834+
weff = weffDaughter1 * weffDaughter2;
18281835
if (weff > 0)
18291836
registry.fill(HIST("Lambda/hLambdas_corrected"), weff);
18301837
}
@@ -1840,9 +1847,9 @@ struct FlowGenericFramework {
18401847

18411848
registry.fill(HIST("Lambda/hLambdas"), 1);
18421849
if (cfgUsePIDEfficiencies) {
1843-
double weff_d1 = getEfficiency(postrack, 1);
1844-
double weff_d2 = getEfficiency(negtrack, 3);
1845-
weff = weff_d1 * weff_d2;
1850+
double weffDaughter1 = getEfficiency(postrack, 1);
1851+
double weffDaughter2 = getEfficiency(negtrack, 3);
1852+
weff = weffDaughter1 * weffDaughter2;
18461853
if (weff > 0)
18471854
registry.fill(HIST("Lambda/hLambdas_corrected"), weff);
18481855
}
@@ -1851,7 +1858,7 @@ struct FlowGenericFramework {
18511858
}
18521859

18531860
template <DataType dt, typename TTrack>
1854-
inline void fillPtSums(TTrack track, const double& vtxz, const int pidIndex)
1861+
inline void fillPtSums(TTrack track, const double& vtxz)
18551862
{
18561863
double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0);
18571864
double weff = (dt == kGen) ? 1. : getEfficiency(track);
@@ -2057,7 +2064,7 @@ struct FlowGenericFramework {
20572064
registry.fill(HIST("eventQA/after/multiplicity"), tracks.size());
20582065

20592066
// Get magnetic field polarity
2060-
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField;
2067+
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; // o2-linter: disable=magic-number (hard coded default cut)
20612068

20622069
processCollision<kReco>(collision, tracks, v0s, centrality, field, run);
20632070
}
@@ -2107,7 +2114,7 @@ struct FlowGenericFramework {
21072114
if (!cfgFillWeights)
21082115
loadCorrections(bc);
21092116

2110-
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField;
2117+
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; // o2-linter: disable=magic-number (hard coded default cut)
21112118
processCollision<kReco>(collision, tracks, v0s, centrality, field, run);
21122119
}
21132120
PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false);
@@ -2149,7 +2156,7 @@ struct FlowGenericFramework {
21492156
if (!cfgFillWeights)
21502157
loadCorrections(bc);
21512158

2152-
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField;
2159+
auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; // o2-linter: disable=magic-number (hard coded default cut)
21532160
processCollision<kReco>(collision, tracks, v0s, centrality, field, run);
21542161
}
21552162
PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false);

0 commit comments

Comments
 (0)