Skip to content

Commit 94f97e2

Browse files
author
Preet Pati
committed
Fixing the cpp-check errors
1 parent 4fcf97d commit 94f97e2

2 files changed

Lines changed: 99 additions & 74 deletions

File tree

PWGCF/TwoParticleCorrelations/Tasks/corrFit.cxx

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ using namespace o2::framework::expressions;
6565
using namespace o2::aod::rctsel;
6666
using namespace constants::math;
6767

68-
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
69-
static constexpr float LongArrayFloat[3][20] = {{1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}, {2.1, 2.2, 2.3, -2.1, -2.2, -2.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}, {3.1, 3.2, 3.3, -3.1, -3.2, -3.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2, 1.3, -1.1, -1.2, -1.3, 1.1, 1.2}};
70-
static constexpr int LongArrayInt[3][20] = {{1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1}, {2, 2, 2, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1}, {3, 3, 3, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1}};
68+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, (DEFAULT), (HELP)}; // NOLINT(bugprone-macro-parentheses)
69+
static constexpr std::array<std::array<float, 3>, 20> LongArrayFloat = {{{{1.1, 2.1, 3.1}}, {{1.2, 2.2, 3.2}}, {{1.3, 2.3, 3.3}}, {{-1.1, -2.1, -3.1}}, {{-1.2, -2.2, -3.2}}, {{-1.3, -2.3, -3.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}}};
70+
static constexpr std::array<std::array<int, 3>, 20> LongArrayInt = {{{{1, 2, 3}}, {{1, 2, 3}}, {{1, 2, 3}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}}};
7171

7272
struct CorrFit {
7373
o2::aod::ITSResponse itsResponse;
74-
Service<ccdb::BasicCCDBManager> ccdb;
74+
Service<ccdb::BasicCCDBManager> ccdb{};
7575

7676
O2_DEFINE_CONFIGURABLE(cfgUseAdditionalEventCut, bool, true, "Use additional event cut on mult correlations")
7777
O2_DEFINE_CONFIGURABLE(cfgZVtxCut, float, 10.0f, "Accepted z-vertex range")
@@ -100,7 +100,7 @@ struct CorrFit {
100100
O2_DEFINE_CONFIGURABLE(cfgCutOccupancyHigh, int, 2000, "High cut on TPC occupancy")
101101
O2_DEFINE_CONFIGURABLE(cfgCutOccupancyLow, int, 0, "Low cut on TPC occupancy")} cfgEventSelection;
102102

103-
Configurable<LabeledArray<int>> cfgUseEventCuts{"cfgUseEventCuts", {LongArrayInt[0], 14, 1, {"Filtered Events", "Sel8", "kNoTimeFrameBorder", "kNoITSROFrameBorder", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "kNoCollInTimeRangeStandard", "kIsGoodITSLayersAll", "kIsGoodITSLayer0123", "kNoCollInRofStandard", "kNoHighMultCollInPrevRof", "Occupancy", "Multcorrelation", "T0AV0ACut"}, {"EvCuts"}}, "Labeled array (int) for various cuts on resonances"};
103+
Configurable<LabeledArray<int>> cfgUseEventCuts{"cfgUseEventCuts", {LongArrayInt.front().data(), 14, 1, {"Filtered Events", "Sel8", "kNoTimeFrameBorder", "kNoITSROFrameBorder", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "kNoCollInTimeRangeStandard", "kIsGoodITSLayersAll", "kIsGoodITSLayer0123", "kNoCollInRofStandard", "kNoHighMultCollInPrevRof", "Occupancy", "Multcorrelation", "T0AV0ACut"}, {"EvCuts"}}, "Labeled array (int) for various cuts on resonances"};
104104

105105
O2_DEFINE_CONFIGURABLE(cfgMinMixEventNum, int, 5, "Minimum number of events to mix")
106106
O2_DEFINE_CONFIGURABLE(cfgMergingCut, float, 0.02, "Merging cut on track merge")
@@ -155,7 +155,7 @@ struct CorrFit {
155155
O2_DEFINE_CONFIGURABLE(cfgGetNsigmaQA, bool, false, "Get QA histograms for selection of pions, kaons, and protons")
156156
O2_DEFINE_CONFIGURABLE(cfgGetdEdx, bool, false, "Get dEdx histograms for pions, kaons, and protons")
157157
O2_DEFINE_CONFIGURABLE(cfgPIDUseRejection, bool, true, "True: use exclusion exclusion criteria for PID determination, false: don't use exclusion")
158-
Configurable<LabeledArray<float>> nSigmas{"nSigmas", {LongArrayFloat[0], 6, 3, {"UpCut_pi", "UpCut_ka", "UpCut_pr", "LowCut_pi", "LowCut_ka", "LowCut_pr"}, {"TPC", "TOF", "ITS"}}, "Labeled array for n-sigma values for TPC, TOF, ITS for pions, kaons, protons (positive and negative)"};
158+
Configurable<LabeledArray<float>> nSigmas{"nSigmas", {LongArrayFloat.front().data(), 6, 3, {"UpCut_pi", "UpCut_ka", "UpCut_pr", "LowCut_pi", "LowCut_ka", "LowCut_pr"}, {"TPC", "TOF", "ITS"}}, "Labeled array for n-sigma values for TPC, TOF, ITS for pions, kaons, protons (positive and negative)"};
159159
} cfgPIDConfigs;
160160

161161
Configurable<float> cfgCutFV0{"cfgCutFV0", 50., "FV0A threshold"};
@@ -348,32 +348,32 @@ struct CorrFit {
348348
}
349349

350350
// Multiplicity correlation cuts
351-
if (cfgUseEventCuts->getData()[kUseMultCorrCut][kEvCut1]) {
351+
if (cfgUseEventCuts->getData()[kUseMultCorrCut][kEvCut1] != 0) {
352352
cfgFuncParas.multT0CCutPars = cfgFuncParas.cfgMultT0CCutPars;
353353
cfgFuncParas.multPVT0CCutPars = cfgFuncParas.cfgMultPVT0CCutPars;
354354
cfgFuncParas.multGlobalPVCutPars = cfgFuncParas.cfgMultGlobalPVCutPars;
355355
cfgFuncParas.multMultV0ACutPars = cfgFuncParas.cfgMultMultV0ACutPars;
356356
cfgFuncParas.fMultPVT0CCutLow = new TF1("fMultPVT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100);
357-
cfgFuncParas.fMultPVT0CCutLow->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0]));
357+
cfgFuncParas.fMultPVT0CCutLow->SetParameters(cfgFuncParas.multPVT0CCutPars.data());
358358
cfgFuncParas.fMultPVT0CCutHigh = new TF1("fMultPVT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100);
359-
cfgFuncParas.fMultPVT0CCutHigh->SetParameters(&(cfgFuncParas.multPVT0CCutPars[0]));
359+
cfgFuncParas.fMultPVT0CCutHigh->SetParameters(cfgFuncParas.multPVT0CCutPars.data());
360360

361361
cfgFuncParas.fMultT0CCutLow = new TF1("fMultT0CCutLow", cfgFuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100);
362-
cfgFuncParas.fMultT0CCutLow->SetParameters(&(cfgFuncParas.multT0CCutPars[0]));
362+
cfgFuncParas.fMultT0CCutLow->SetParameters(cfgFuncParas.multT0CCutPars.data());
363363
cfgFuncParas.fMultT0CCutHigh = new TF1("fMultT0CCutHigh", cfgFuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100);
364-
cfgFuncParas.fMultT0CCutHigh->SetParameters(&(cfgFuncParas.multT0CCutPars[0]));
364+
cfgFuncParas.fMultT0CCutHigh->SetParameters(cfgFuncParas.multT0CCutPars.data());
365365

366366
cfgFuncParas.fMultGlobalPVCutLow = new TF1("fMultGlobalPVCutLow", cfgFuncParas.cfgMultMultPVLowCutFunction->c_str(), 0, 4000);
367-
cfgFuncParas.fMultGlobalPVCutLow->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0]));
367+
cfgFuncParas.fMultGlobalPVCutLow->SetParameters(cfgFuncParas.multGlobalPVCutPars.data());
368368
cfgFuncParas.fMultGlobalPVCutHigh = new TF1("fMultGlobalPVCutHigh", cfgFuncParas.cfgMultMultPVHighCutFunction->c_str(), 0, 4000);
369-
cfgFuncParas.fMultGlobalPVCutHigh->SetParameters(&(cfgFuncParas.multGlobalPVCutPars[0]));
369+
cfgFuncParas.fMultGlobalPVCutHigh->SetParameters(cfgFuncParas.multGlobalPVCutPars.data());
370370

371371
cfgFuncParas.fMultMultV0ACutLow = new TF1("fMultMultV0ACutLow", cfgFuncParas.cfgMultMultV0ALowCutFunction->c_str(), 0, 4000);
372-
cfgFuncParas.fMultMultV0ACutLow->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0]));
372+
cfgFuncParas.fMultMultV0ACutLow->SetParameters(cfgFuncParas.multMultV0ACutPars.data());
373373
cfgFuncParas.fMultMultV0ACutHigh = new TF1("fMultMultV0ACutHigh", cfgFuncParas.cfgMultMultV0AHighCutFunction->c_str(), 0, 4000);
374-
cfgFuncParas.fMultMultV0ACutHigh->SetParameters(&(cfgFuncParas.multMultV0ACutPars[0]));
374+
cfgFuncParas.fMultMultV0ACutHigh->SetParameters(cfgFuncParas.multMultV0ACutPars.data());
375375
}
376-
if (cfgUseEventCuts->getData()[kUseT0AV0ACut][kEvCut1]) {
376+
if (cfgUseEventCuts->getData()[kUseT0AV0ACut][kEvCut1] != 0) {
377377
cfgFuncParas.fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000);
378378
cfgFuncParas.fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01);
379379
cfgFuncParas.fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000);
@@ -504,7 +504,7 @@ struct CorrFit {
504504
}
505505

506506
if (!cfgEvSelRCTflags.value.empty()) {
507-
rctChecker.init(cfgEvSelRCTflags.value.c_str()); // override initialzation
507+
rctChecker.init(cfgEvSelRCTflags.value); // override initialzation
508508
}
509509

510510
LOGF(info, "End of init");
@@ -513,7 +513,7 @@ struct CorrFit {
513513
template <typename TCollision>
514514
float getCentrality(TCollision const& collision)
515515
{
516-
float cent;
516+
float cent = 0.0;
517517
switch (cfgCentEstimator) {
518518
case kCentFT0C:
519519
cent = collision.centFT0C();
@@ -789,7 +789,6 @@ struct CorrFit {
789789
void loadGain(aod::BCsWithTimestamps::iterator const& bc)
790790
{
791791
cstFT0RelGain.clear();
792-
cstFT0RelGain = {};
793792
std::string fullPath;
794793

795794
auto timestamp = bc.timestamp();
@@ -840,7 +839,7 @@ struct CorrFit {
840839
}
841840

842841
template <typename TTrack>
843-
int getNsigmaPID(TTrack track, bool fillYields)
842+
int getNsigmaPID(const TTrack& track, bool fillYields)
844843
{
845844
// Computing Nsigma arrays for pion, kaon, and protons
846845
std::array<float, 3> nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()};
@@ -851,7 +850,9 @@ struct CorrFit {
851850
std::array<float, 3> nSigmaToUse = cfgPIDConfigs.cfgUseItsPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS
852851
int kIndexDetector = cfgPIDConfigs.cfgUseItsPID ? kITS : kTPC; // Choose which nSigma to use: TPC or ITS
853852

854-
bool isPion, isKaon, isProton;
853+
bool isPion = false;
854+
bool isKaon = false;
855+
bool isProton = false;
855856
bool isDetectedPion = nSigmaToUse[iPionUp] < cfgPIDConfigs.nSigmas->getData()[iPionUp][kIndexDetector] && nSigmaToUse[iPionUp] > cfgPIDConfigs.nSigmas->getData()[iPionLow][kIndexDetector];
856857
bool isDetectedKaon = nSigmaToUse[iKaonUp] < cfgPIDConfigs.nSigmas->getData()[iKaonUp][kIndexDetector] && nSigmaToUse[iKaonUp] > cfgPIDConfigs.nSigmas->getData()[iKaonLow][kIndexDetector];
857858
bool isDetectedProton = nSigmaToUse[iProtonUp] < cfgPIDConfigs.nSigmas->getData()[iProtonUp][kIndexDetector] && nSigmaToUse[iProtonUp] > cfgPIDConfigs.nSigmas->getData()[iProtonLow][kIndexDetector];
@@ -862,7 +863,8 @@ struct CorrFit {
862863

863864
if (track.pt() > cfgPIDConfigs.cfgTofPtCut && !track.hasTOF()) {
864865
return -1;
865-
} else if (track.pt() > cfgPIDConfigs.cfgTofPtCut && track.hasTOF()) {
866+
}
867+
if (track.pt() > cfgPIDConfigs.cfgTofPtCut && track.hasTOF()) {
866868
isPion = isTofPion && isDetectedPion;
867869
isKaon = isTofKaon && isDetectedKaon;
868870
isProton = isTofProton && isDetectedProton;
@@ -903,10 +905,10 @@ struct CorrFit {
903905
if (correctionsLoaded) {
904906
return;
905907
}
906-
if (cfgEfficiency.value.empty() == false) {
908+
if (!cfgEfficiency.value.empty()) {
907909
if (cfgLocalEfficiency) {
908910
TFile* fEfficiencyTrigger = TFile::Open(cfgEfficiency.value.c_str(), "READ");
909-
mEfficiency = reinterpret_cast<TH3D*>(fEfficiencyTrigger->Get("ccdb_object"));
911+
mEfficiency = dynamic_cast<TH3D*>(fEfficiencyTrigger->Get("ccdb_object"));
910912

911913
} else {
912914
mEfficiency = ccdb->getForTimeStamp<TH3D>(cfgEfficiency, timestamp);
@@ -916,10 +918,10 @@ struct CorrFit {
916918
}
917919
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), static_cast<void*>(mEfficiency));
918920
}
919-
if (cfgEfficiencyNch.value.empty() == false) {
921+
if (!cfgEfficiencyNch.value.empty()) {
920922
if (cfgLocalEfficiencyNch) {
921923
TFile* fEfficiencyTrigger = TFile::Open(cfgEfficiencyNch.value.c_str(), "READ");
922-
mEfficiencyNch = reinterpret_cast<TH1D*>(fEfficiencyTrigger->Get("ccdb_object"));
924+
mEfficiencyNch = dynamic_cast<TH1D*>(fEfficiencyTrigger->Get("ccdb_object"));
923925

924926
} else {
925927
mEfficiencyNch = ccdb->getForTimeStamp<TH1D>(cfgEfficiencyNch, timestamp);
@@ -929,7 +931,7 @@ struct CorrFit {
929931
}
930932
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiencyNch.value.c_str(), static_cast<void*>(mEfficiencyNch));
931933
}
932-
if (cfgCentralityWeight.value.empty() == false) {
934+
if (!cfgCentralityWeight.value.empty()) {
933935
mCentralityWeight = ccdb->getForTimeStamp<TH1D>(cfgCentralityWeight, timestamp);
934936
if (mCentralityWeight == nullptr) {
935937
LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", cfgCentralityWeight.value.c_str());
@@ -991,7 +993,7 @@ struct CorrFit {
991993
}
992994

993995
template <typename TTracks>
994-
void trackCounter(TTracks tracks, double& multiplicity) // function to count the number of tracks in the event and fill the histogram
996+
void trackCounter(const TTracks& tracks, double& multiplicity) // function to count the number of tracks in the event and fill the histogram
995997
{
996998
double nTracksCorrected = 0;
997999
float weightNch = 1.0f;
@@ -1012,7 +1014,7 @@ struct CorrFit {
10121014
}
10131015

10141016
template <typename TCollision, typename TTracks>
1015-
void fillYield(TCollision collision, TTracks tracks) // function to fill the yield and etaphi histograms.
1017+
void fillYield(const TCollision& collision, const TTracks& tracks) // function to fill the yield and etaphi histograms.
10161018
{
10171019

10181020
float weff1 = 1.0;
@@ -1040,7 +1042,7 @@ struct CorrFit {
10401042
}
10411043

10421044
template <typename TTrack>
1043-
void fillNsigmaBeforeCut(TTrack track1, int pid) // function to fill the QA before Nsigma selection
1045+
void fillNsigmaBeforeCut(const TTrack& track1, int pid) // function to fill the QA before Nsigma selection
10441046
{
10451047
switch (pid) {
10461048
case kPions: // For Pions
@@ -1088,11 +1090,14 @@ struct CorrFit {
10881090
if (cfgPIDConfigs.cfgGetNsigmaQA && cfgPIDConfigs.cfgUseItsPID)
10891091
registry.fill(HIST("TofItsNsigma_before"), itsResponse.nSigmaITS<o2::track::PID::Proton>(track1), track1.tofNSigmaPr(), track1.pt());
10901092
break;
1091-
}
1093+
default:
1094+
LOGF(info, "PID %d not recognized, skipping nSigma QA filling", pid);
1095+
break;
1096+
} // end of switch
10921097
} // end of fillNsigmaBeforeCut
10931098

10941099
template <typename TTrack>
1095-
void fillNsigmaAfterCut(TTrack track1, int pid) // function to fill the QA after Nsigma selection
1100+
void fillNsigmaAfterCut(const TTrack& track1, int pid) // function to fill the QA after Nsigma selection
10961101
{
10971102
switch (pid) {
10981103
case kPions: // For Pions
@@ -1140,11 +1145,14 @@ struct CorrFit {
11401145
if (cfgPIDConfigs.cfgUseItsPID && cfgPIDConfigs.cfgGetNsigmaQA)
11411146
registry.fill(HIST("TofItsNsigma_after"), itsResponse.nSigmaITS<o2::track::PID::Proton>(track1), track1.tofNSigmaPr(), track1.pt());
11421147
break;
1148+
default:
1149+
LOGF(info, "PID %d not recognized, skipping nSigma QA filling", pid);
1150+
break;
11431151
} // end of switch
11441152
}
11451153

11461154
template <CorrelationContainer::CFStep step, typename TTracks, typename TFT0s>
1147-
void fillCorrelationsTPCFT0(TTracks tracks1, TFT0s const& ft0, float posZ, int system, int multiplicity, int corType, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
1155+
void fillCorrelationsTPCFT0(const TTracks& tracks1, TFT0s const& ft0, float posZ, int system, int multiplicity, int corType, float eventWeight) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
11481156
{
11491157

11501158
int fSampleIndex = gRandom->Uniform(0, cfgSampleSize);
@@ -1275,7 +1283,7 @@ struct CorrFit {
12751283
}
12761284

12771285
template <CorrelationContainer::CFStep step, typename TTracks, typename TTracksAssoc>
1278-
void fillCorrelations(TTracks tracks1, TTracksAssoc tracks2, float posZ, int system, int multiplicity, int magneticField) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
1286+
void fillCorrelations(const TTracks& tracks1, const TTracksAssoc& tracks2, float posZ, int system, int multiplicity, int magneticField) // function to fill the Output functions (sparse) and the delta eta and delta phi histograms
12791287
{
12801288

12811289
int fSampleIndex = gRandom->Uniform(0, cfgSampleSize);
@@ -1602,7 +1610,7 @@ struct CorrFit {
16021610
double multiplicity = tracks1.size();
16031611

16041612
if (cfgStrictTrackCounter) {
1605-
trackCounter(tracks, multiplicity);
1613+
trackCounter(tracks1, multiplicity);
16061614
}
16071615

16081616
if (multiplicity > cfgMaxMultForCorrelations || multiplicity < cfgMinMultForCorrelations) {

0 commit comments

Comments
 (0)