Skip to content

Commit ea3acba

Browse files
committed
linter
1 parent 94a2d16 commit ea3acba

4 files changed

Lines changed: 41 additions & 52 deletions

File tree

‎PWGCF/GenericFramework/Core/GFW.cxx‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void GFW::AddRegion(const string& refName, double lEtaMin, double lEtaMax, int l
7272
lOneRegion.BitMask = BitMask; // Bit mask
7373
AddRegion(lOneRegion);
7474
};
75-
void GFW::AddRegion(string refName, std::vector<int> lNparVec, double lEtaMin, double lEtaMax, int lNpT, int BitMask)
75+
void GFW::AddRegion(const string& refName, const std::vector<int>& lNparVec, double lEtaMin, double lEtaMax, int lNpT, int BitMask)
7676
{
7777
const auto oldSize = fRegions.size();
7878
AddRegion(refName, lEtaMin, lEtaMax, lNpT, BitMask);
@@ -201,8 +201,6 @@ GFW::CorrConfig GFW::GetCorrelatorConfig(string config, string head, bool ptdif)
201201
// Then make sure we don't have any double-spaces:
202202
while (s_index(config, " ") > -1)
203203
s_replace_all(config, " ", " ");
204-
std::vector<int> regs;
205-
std::vector<int> hars;
206204
int sz1 = 0;
207205
int szend = 0;
208206
string ts, ts2;
@@ -371,13 +369,14 @@ int GFW::FindRegionByName(const string& refName)
371369
return -1;
372370
};
373371
// String processing:
374-
int GFW::s_index(string& instr, const string& pattern, const int& spos)
372+
int GFW::s_index(const string& instr, const string& pattern, const int& spos)
375373
{
376-
return instr.find(pattern, spos);
374+
const auto position = instr.find(pattern, spos);
375+
return position == string::npos ? -1 : static_cast<int>(position);
377376
};
378-
bool GFW::s_contains(string& instr, const string& pattern)
377+
bool GFW::s_contains(const string& instr, const string& pattern)
379378
{
380-
return (s_index(instr, pattern) > -1);
379+
return instr.find(pattern) != string::npos;
381380
};
382381
void GFW::s_replace(string& instr, const string& pattern1, const string& pattern2, const int& spos)
383382
{

‎PWGCF/GenericFramework/Core/GFW.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class GFW
2727
{
2828
public:
2929
struct Region {
30-
int Nhar, NpT;
30+
int Nhar = 0;
31+
int NpT = 0;
3132
std::vector<int> NparVec{};
3233
double EtaMin = -999;
3334
double EtaMax = -999;
@@ -80,8 +81,8 @@ class GFW
8081
std::complex<double> Calculate(int poi, int ref, std::vector<int> hars, int ptbin = 0); // For differential, need POI and reference
8182
std::complex<double> Calculate(int poi, std::vector<int> hars); // For integrated case
8283
// Operations on strings. Equivalent to TString operations, but one to rid of root dependence
83-
int s_index(std::string& instr, const std::string& pattern, const int& spos = 0);
84-
bool s_contains(std::string& instr, const std::string& pattern);
84+
int s_index(const std::string& instr, const std::string& pattern, const int& spos = 0);
85+
bool s_contains(const std::string& instr, const std::string& pattern);
8586
void s_replace(std::string& instr, const std::string& pattern1, const std::string& pattern2, const int& spos = 0);
8687
void s_replace_all(std::string& instr, const std::string& pattern1, const std::string& pattern2);
8788
bool s_tokenize(std::string& instr, std::string& substr, int& spos, const std::string& delim);

‎PWGCF/GenericFramework/Core/GFWPowerArray.cxx‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,8 @@ HarSet GFWPowerArray::trimVec(const HarSet& hars, int ind)
4848
};
4949
HarSet GFWPowerArray::addConstant(const HarSet& hars, int offset)
5050
{
51-
<<<<<<< HEAD
52-
HarSet retVec = std::move(hars);
53-
for (int& val : retVec)
54-
=======
5551
HarSet retVec = hars;
5652
for (int& val : retVec) // o2-linter: disable=const-ref-in-for-loop (updates each harmonic)
57-
>>>>>>> d563a1043 (more linter cleanup in GFW)
5853
val += offset;
5954
return retVec;
6055
};

‎PWGCF/GenericFramework/Core/GFWWeights.cxx‎

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -333,33 +333,30 @@ void GFWWeights::createNUA(bool IntegrateOverCentAndPt)
333333
TH1D* h1;
334334
if (!fW_data || fW_data->GetEntries() < 1)
335335
return;
336-
if (IntegrateOverCentAndPt) {
337-
if (fAccInt)
338-
delete fAccInt;
339-
fAccInt = reinterpret_cast<TH3D*>(fW_data->At(0)->Clone("IntegratedAcceptance"));
340-
fAccInt->SetDirectory(0);
341-
fAccInt->Sumw2();
342-
for (int etai = 1; etai <= fAccInt->GetNbinsY(); etai++) {
343-
fAccInt->GetYaxis()->SetRange(etai, etai);
336+
if (fAccInt)
337+
delete fAccInt;
338+
fAccInt = reinterpret_cast<TH3D*>(fW_data->At(0)->Clone("IntegratedAcceptance"));
339+
fAccInt->SetDirectory(0);
340+
fAccInt->Sumw2();
341+
for (int etai = 1; etai <= fAccInt->GetNbinsY(); etai++) {
342+
fAccInt->GetYaxis()->SetRange(etai, etai);
343+
if (fAccInt->Integral() < 1)
344+
continue;
345+
for (int vzi = 1; vzi <= fAccInt->GetNbinsZ(); vzi++) {
346+
fAccInt->GetZaxis()->SetRange(vzi, vzi);
344347
if (fAccInt->Integral() < 1)
345348
continue;
346-
for (int vzi = 1; vzi <= fAccInt->GetNbinsZ(); vzi++) {
347-
fAccInt->GetZaxis()->SetRange(vzi, vzi);
348-
if (fAccInt->Integral() < 1)
349-
continue;
350-
h1 = reinterpret_cast<TH1D*>(fAccInt->Project3D("x"));
351-
double maxv = h1->GetMaximum();
352-
for (int phii = 1; phii <= h1->GetNbinsX(); phii++) {
353-
fAccInt->SetBinContent(phii, etai, vzi, fAccInt->GetBinContent(phii, etai, vzi) / maxv);
354-
fAccInt->SetBinError(phii, etai, vzi, fAccInt->GetBinError(phii, etai, vzi) / maxv);
355-
}
356-
delete h1;
349+
h1 = reinterpret_cast<TH1D*>(fAccInt->Project3D("x"));
350+
double maxv = h1->GetMaximum();
351+
for (int phii = 1; phii <= h1->GetNbinsX(); phii++) {
352+
fAccInt->SetBinContent(phii, etai, vzi, fAccInt->GetBinContent(phii, etai, vzi) / maxv);
353+
fAccInt->SetBinError(phii, etai, vzi, fAccInt->GetBinError(phii, etai, vzi) / maxv);
357354
}
358-
fAccInt->GetZaxis()->SetRange(1, fAccInt->GetNbinsZ());
355+
delete h1;
359356
}
360-
fAccInt->GetYaxis()->SetRange(1, fAccInt->GetNbinsY());
361-
return;
357+
fAccInt->GetZaxis()->SetRange(1, fAccInt->GetNbinsZ());
362358
}
359+
fAccInt->GetYaxis()->SetRange(1, fAccInt->GetNbinsY());
363360
};
364361
TH1D* GFWWeights::getdNdPhi()
365362
{
@@ -393,21 +390,18 @@ void GFWWeights::createNUE(bool IntegrateOverCentrality)
393390
TH3D* den = 0;
394391
if (!fW_mcrec || !fW_mcgen || fW_mcrec->GetEntries() < 1 || fW_mcgen->GetEntries() < 1)
395392
return;
396-
if (IntegrateOverCentrality) {
397-
num = reinterpret_cast<TH3D*>(fW_mcrec->At(0));
398-
den = reinterpret_cast<TH3D*>(fW_mcgen->At(0));
399-
num->Sumw2();
400-
den->Sumw2();
401-
num->RebinY(2);
402-
den->RebinY(2);
403-
num->RebinZ(5);
404-
den->RebinZ(5);
405-
delete fEffInt;
406-
fEffInt = reinterpret_cast<TH3D*>(num->Clone("Efficiency_Integrated"));
407-
fEffInt->SetDirectory(0);
408-
fEffInt->Divide(den);
409-
return;
410-
}
393+
num = reinterpret_cast<TH3D*>(fW_mcrec->At(0));
394+
den = reinterpret_cast<TH3D*>(fW_mcgen->At(0));
395+
num->Sumw2();
396+
den->Sumw2();
397+
num->RebinY(2);
398+
den->RebinY(2);
399+
num->RebinZ(5);
400+
den->RebinZ(5);
401+
delete fEffInt;
402+
fEffInt = reinterpret_cast<TH3D*>(num->Clone("Efficiency_Integrated"));
403+
fEffInt->SetDirectory(0);
404+
fEffInt->Divide(den);
411405
};
412406
void GFWWeights::readAndMerge(const TString& filelinks, const TString& listName, bool addData, bool addRec, bool addGen)
413407
{

0 commit comments

Comments
 (0)