Skip to content

Commit 2bbd72e

Browse files
victor-gonzalezVictor Gonzalez
andauthored
[PWGCF] DptDpt - Fixing Megalinter cppcheck warnings (#17990)
Co-authored-by: Victor Gonzalez <victor@cern.ch>
1 parent 2d75002 commit 2bbd72e

3 files changed

Lines changed: 38 additions & 36 deletions

File tree

PWGCF/TableProducer/dptDptFilter.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ int tracktype = 1;
554554
std::vector<DptDptTrackSelection*> trackFilters = {}; // the vector of track selectors
555555

556556
struct DptDptTrackSelection {
557+
/* disable copying and assignment explicitly */
558+
DptDptTrackSelection(const DptDptTrackSelection&) = delete;
559+
DptDptTrackSelection& operator=(const DptDptTrackSelection&) = delete;
560+
557561
DptDptTrackSelection(TrackSelection* stdTs, TList* outputList, const char* name) : stdTrackSelection(stdTs)
558562
{
559563
passedHistogram = new TH1F(name, name, ptbins, ptlow, ptup);
@@ -836,7 +840,7 @@ float particleMaxDCAxy = 999.9f;
836840
float particleMaxDCAZ = 999.9f;
837841
bool traceCollId0 = false;
838842

839-
inline TList* getCCDBInput(auto& ccdb, const char* ccdbpath, const char* ccdbdate, bool periodInPath = false, const std::string& suffix = "")
843+
inline TList* getCCDBInput(const auto& ccdb, const char* ccdbpath, const char* ccdbdate, bool periodInPath = false, const std::string& suffix = "")
840844
{
841845
std::tm cfgtm = {};
842846
std::stringstream ss(ccdbdate);
@@ -1107,7 +1111,7 @@ template <typename CollisionObject>
11071111
inline bool triggerSelection(CollisionObject const&)
11081112
{
11091113
LOGF(fatal, "Trigger selection not implemented for this kind of collisions");
1110-
return false;
1114+
return true;
11111115
}
11121116

11131117
/// \brief Trigger selection for reconstructed collision tables without centrality/multiplicity
@@ -1280,7 +1284,7 @@ template <typename CollisionObject>
12801284
inline bool centralitySelection(CollisionObject const&, float&)
12811285
{
12821286
LOGF(fatal, "Centrality selection not implemented for this kind of collisions");
1283-
return false;
1287+
return true;
12841288
}
12851289

12861290
/// \brief Centrality selection for reconstructed and detector level collision tables with centrality/multiplicity information
@@ -1396,7 +1400,7 @@ template <typename CollisionObject>
13961400
inline bool occupancySelection(CollisionObject const&)
13971401
{
13981402
LOGF(fatal, "Occupancy selection not implemented for this kind of collisions");
1399-
return false;
1403+
return true;
14001404
}
14011405

14021406
/// \brief Occupancy selection for reconstructed and detector level collision tables with centrality/multiplicity information
@@ -1561,7 +1565,7 @@ struct TpcExcludeTrack {
15611565
switch (method) {
15621566
case kNOEXCLUSION: {
15631567
return false;
1564-
} break;
1568+
}
15651569
case kSTATIC: {
15661570
int phiBinIx = getPhiBinIx(track);
15671571
/* bins multiple of four have got sector border */
@@ -1570,15 +1574,15 @@ struct TpcExcludeTrack {
15701574
} else {
15711575
return true;
15721576
}
1573-
} break;
1577+
}
15741578
case kDYNAMIC: {
15751579
float phiInTpcSector = std::fmod(track.phi(), TpcPhiSectorWidth);
15761580
if (track.sign() > 0) {
15771581
return (phiInTpcSector < positiveUpCut->Eval(track.pt())) && (positiveLowCut->Eval(track.pt()) < phiInTpcSector);
15781582
} else {
15791583
return (phiInTpcSector < negativeUpCut->Eval(track.pt())) && (negativeLowCut->Eval(track.pt()) < phiInTpcSector);
15801584
}
1581-
} break;
1585+
}
15821586
default:
15831587
return false;
15841588
}
@@ -1836,14 +1840,14 @@ struct PIDSpeciesSelection {
18361840
/* out debug if needed */
18371841
outnsigmasdebug();
18381842

1839-
auto closeTo = [](auto& values, auto& mindet, auto& maxdet, uint8_t sp) {
1843+
auto closeTo = [](const auto& values, const auto& mindet, const auto& maxdet, uint8_t sp) {
18401844
if (mindet[sp] <= values[sp] && values[sp] < maxdet[sp]) {
18411845
return true;
18421846
} else {
18431847
return false;
18441848
}
18451849
};
1846-
auto awayFrom = [&](auto& values, auto& mindet, auto& maxdet, uint8_t sp) {
1850+
auto awayFrom = [&](const auto& values, const auto& mindet, const auto& maxdet, uint8_t sp) {
18471851
for (size_t ix = 0; ix < pdgcodes.size(); ix++) {
18481852
if (ix != sp) {
18491853
if (mindet[ix] <= values[ix] && values[ix] < maxdet[ix]) {
@@ -1889,7 +1893,7 @@ struct PIDSpeciesSelection {
18891893
}
18901894
return true;
18911895
};
1892-
auto aboveThreshold = [&](auto& config) {
1896+
auto aboveThreshold = [&](const auto& config) {
18931897
return ((config->mPThreshold > 0.0) && (config->mPThreshold < track.p()));
18941898
};
18951899
auto isA = [&](auto& config, uint8_t sp) {

PWGCF/Tasks/dptDptCorrelations.cxx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct DptDptCorrelations {
112112
// The DptDptCorrelationsAnalysisTask output objects
113113
//============================================================================================
114114
/* histograms */
115-
TH1F* fhVertexZA; //!<! the z vertex distribution for the current multiplicity/centrality class
115+
TH1F* fhVertexZA = nullptr; //!<! the z vertex distribution for the current multiplicity/centrality class
116116
std::vector<TH1F*> fhN1VsPt{nch, nullptr}; //!<! weighted single particle distribution vs \f$p_T\f$, for the different species
117117
std::vector<TH2F*> fhN1VsPtEta{nch, nullptr}; //!<! weighted single particle distribution vs \f$p_T,\;\eta\f$, for the different species
118118
std::vector<TH2F*> fhN1VsEtaPhi{nch, nullptr}; //!<! weighted single particle distribution vs \f$\eta,\;\phi\f$, for the different species
@@ -352,7 +352,7 @@ struct DptDptCorrelations {
352352
ccdbstored = true;
353353
}
354354

355-
void storePtAverages(std::vector<TH2*> ptavgs)
355+
void storePtAverages(const std::vector<TH2*>& ptavgs)
356356
{
357357
LOGF(info, "Stored pT average for %d track ids", ptavgs.size());
358358
for (uint i = 0; i < ptavgs.size(); ++i) {
@@ -905,9 +905,9 @@ struct DptDptCorrelations {
905905
float* fCentMultMax = nullptr;
906906

907907
/* the data collecting engine instances */
908-
DataCollectingEngine<false>** dataCE;
909-
DataCollectingEngine<true>** dataCEsmall;
910-
DataCollectingEngine<false>** dataCEME;
908+
DataCollectingEngine<false>** dataCE = nullptr;
909+
DataCollectingEngine<true>** dataCEsmall = nullptr;
910+
DataCollectingEngine<false>** dataCEME = nullptr;
911911

912912
/* the input file structure from CCDB */
913913
TList* ccdblst = nullptr;
@@ -1248,14 +1248,14 @@ struct DptDptCorrelations {
12481248
return dataCE[ixDCE]->isCCDBstored();
12491249
}
12501250
};
1251-
auto storePtAverages = [&](auto& ptavgs) {
1251+
auto storePtAverages = [&](const auto& ptavgs) {
12521252
if (cfgSmallDCE.value) {
12531253
dataCEsmall[ixDCE]->storePtAverages(ptavgs);
12541254
} else {
12551255
dataCE[ixDCE]->storePtAverages(ptavgs);
12561256
}
12571257
};
1258-
auto storeTrackCorrections = [&](auto& corrs) {
1258+
auto storeTrackCorrections = [&](const auto& corrs) {
12591259
if (cfgSmallDCE.value) {
12601260
dataCEsmall[ixDCE]->storeTrackCorrections(corrs);
12611261
} else {
@@ -1583,6 +1583,7 @@ struct DptDptCorrelations {
15831583
LOGF(DPTDPTLOGCOLLISIONS, "Received generated collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s",
15841584
collision1.globalIndex(), collision1.posZ(), collision1.centmult(), collision1.collisionaccepted() ? "accepted" : "not accepted",
15851585
collision2.globalIndex(), collision2.posZ(), collision2.centmult(), collision2.collisionaccepted() ? "accepted" : "not accepted");
1586+
logcomb++;
15861587
}
15871588
if (!collision1.collisionaccepted() || !collision2.collisionaccepted()) {
15881589
LOGF(error, "Received collision pair: %ld (%f, %f): %s, %ld (%f, %f): %s",
@@ -1621,6 +1622,7 @@ struct DptDptCorrelations {
16211622
collision2.posZ(),
16221623
collision2.centmult(),
16231624
collision2.collisionaccepted() ? "accepted" : "not accepted");
1625+
logcomb++;
16241626
}
16251627
if (!collision1.collisionaccepted() || !collision2.collisionaccepted()) {
16261628
LOGF(error,

PWGCF/TwoParticleCorrelations/Tasks/dptDptEfficiencyAndQc.cxx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -514,23 +514,23 @@ struct QADataCollectingEngine {
514514
fhTruePvsP->Fill(track.p(), mcparticle.p());
515515
fhTruePvsInnerP->Fill(track.tpcInnerParam(), mcparticle.p());
516516

517-
auto fillhisto = [](auto& h, float pt, float eta, bool cond1, bool cond2) {
517+
auto fillmchisto = [](auto& h, float pt, float eta, bool cond1, bool cond2) {
518518
if (cond1 && cond2) {
519519
h->Fill(eta, pt);
520520
}
521521
};
522522
std::vector<float> tPt = {track.pt(), mcparticle.pt()};
523523
std::vector<float> tEta = {track.eta(), mcparticle.eta()};
524524
for (uint ix = 0; ix < tPt.size(); ++ix) {
525-
fillhisto(fhPtVsEtaPrimItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, isprimary);
526-
fillhisto(fhPtVsEtaPrimItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, isprimary);
527-
fillhisto(fhPtVsEtaPrimItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, isprimary);
528-
fillhisto(fhPtVsEtaSecItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, issecdecay);
529-
fillhisto(fhPtVsEtaSecItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, issecdecay);
530-
fillhisto(fhPtVsEtaSecItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, issecdecay);
531-
fillhisto(fhPtVsEtaMatItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, isfrommaterial);
532-
fillhisto(fhPtVsEtaMatItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, isfrommaterial);
533-
fillhisto(fhPtVsEtaMatItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, isfrommaterial);
525+
fillmchisto(fhPtVsEtaPrimItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, isprimary);
526+
fillmchisto(fhPtVsEtaPrimItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, isprimary);
527+
fillmchisto(fhPtVsEtaPrimItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, isprimary);
528+
fillmchisto(fhPtVsEtaSecItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, issecdecay);
529+
fillmchisto(fhPtVsEtaSecItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, issecdecay);
530+
fillmchisto(fhPtVsEtaSecItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, issecdecay);
531+
fillmchisto(fhPtVsEtaMatItsA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits, isfrommaterial);
532+
fillmchisto(fhPtVsEtaMatItsTpcA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastpc, isfrommaterial);
533+
fillmchisto(fhPtVsEtaMatItsTpcTofA[ix][track.trackacceptedid()], tPt[ix], tEta[ix], hasits && hastof, isfrommaterial);
534534
}
535535
}
536536
}
@@ -879,13 +879,10 @@ struct PidExtraDataCollectingEngine {
879879
/* only after track selection */
880880
std::vector<std::shared_ptr<TH2>> fhIdTPCdEdxSignalVsP{nsp, nullptr};
881881
std::vector<std::shared_ptr<TProfile2D>> fpIdTPCdEdxSignalVsPSigmas{nsp, nullptr};
882-
std::vector<std::vector<std::shared_ptr<TH2>>> fhIdTPCdEdxSignalDiffVsP{nsp, {nmainsp, nullptr}};
883882
std::vector<std::vector<std::shared_ptr<TH2>>> fhIdTPCnSigmasVsP{nsp, {nallmainsp, nullptr}};
884883
std::vector<std::shared_ptr<TH2>> fhIdTOFSignalVsP{nsp, nullptr};
885884
std::vector<std::shared_ptr<TProfile2D>> fpIdTOFSignalVsPSigmas{nsp, nullptr};
886-
std::vector<std::vector<std::shared_ptr<TH2>>> fhIdTOFSignalDiffVsP{nsp, {nmainsp, nullptr}};
887885
std::vector<std::vector<std::shared_ptr<TH2>>> fhIdTOFnSigmasVsP{nsp, {nallmainsp, nullptr}};
888-
std::vector<std::shared_ptr<TH2>> fhIdPvsTOFSqMass{nsp, nullptr};
889886

890887
template <efficiencyandqatask::KindOfData kindOfData>
891888
void init(HistogramRegistry& registry, const char* dirname)
@@ -1005,10 +1002,10 @@ struct DptDptEfficiencyAndQc {
10051002
float* fCentMultMax = nullptr;
10061003

10071004
/* the data collecting engine instances */
1008-
QADataCollectingEngine** qaDataCE;
1009-
QAExtraDataCollectingEngine** qaExtraDataCE;
1010-
PidDataCollectingEngine** pidDataCE;
1011-
PidExtraDataCollectingEngine** pidExtraDataCE;
1005+
QADataCollectingEngine** qaDataCE = nullptr;
1006+
QAExtraDataCollectingEngine** qaExtraDataCE = nullptr;
1007+
PidDataCollectingEngine** pidDataCE = nullptr;
1008+
PidExtraDataCollectingEngine** pidExtraDataCE = nullptr;
10121009

10131010
/* the histogram registries */
10141011
HistogramRegistry registryOne{"registryOne", {}, OutputObjHandlingPolicy::AnalysisObject};
@@ -1179,7 +1176,6 @@ struct DptDptEfficiencyAndQc {
11791176
if (doPidExtraAnalysis) {
11801177
pidExtraDataCE = new PidExtraDataCollectingEngine*[ncmranges];
11811178
}
1182-
std::string recogen;
11831179
if (ncmranges > registryBank.size()) {
11841180
LOGF(fatal, "There are more centrality ranges configured than registries in the bank. Please fix it!");
11851181
}
@@ -1434,7 +1430,7 @@ using BCsWithTimestamps = soa::Join<aod::BCs, aod::Timestamps>;
14341430
struct CheckTimestamp {
14351431

14361432
o2::ccdb::CcdbApi ccdbApi;
1437-
int mRunNumber;
1433+
int mRunNumber = 0;
14381434
uint64_t runsor = 0;
14391435
uint64_t runeor = 0;
14401436
std::shared_ptr<TH2> hTimeStampDiffNegative = nullptr;

0 commit comments

Comments
 (0)