Skip to content

Commit 5925580

Browse files
committed
Use const& and std::move to avoid copies
Mostly done automatically by Clang-Tidy.
1 parent b7efad9 commit 5925580

111 files changed

Lines changed: 450 additions & 439 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PWGCF/EbyEFluctuations/Tasks/NetProtonCumulants.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct NetProtonCumulants_Table_QA {
126126
//! centrality cut
127127
if (cent > 0.0f && cent < 90.0f) {
128128

129-
for (auto track : inputTracks) { //! Loop over tracks
129+
for (const auto& track : inputTracks) { //! Loop over tracks
130130
histos.fill(HIST("hPtAll"), track.pt());
131131
histos.fill(HIST("hEtaAll"), track.eta());
132132
histos.fill(HIST("hPhiAll"), track.phi());

PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ struct RobustFluctuationObservables {
23092309
} // end of processRobustFluctuationObservables()
23102310

23112311
// shortcut function to fill 2D histograms
2312-
void fillHistForThisCut(string cutName, int multNTracksPV, int multTrk, int nTracksGlobalAccepted, double multT0A, double multT0C, double multV0A, double /*t0cCentr*/, int bc)
2312+
void fillHistForThisCut(const string& cutName, int multNTracksPV, int multTrk, int nTracksGlobalAccepted, double multT0A, double multT0C, double multV0A, double /*t0cCentr*/, int bc)
23132313
{
23142314
// registry.get<TH1>(HIST("eta"))->Fill(track.eta());
23152315
// arrPointers[histId][cutId]->Fill(xval, yval, weight);
@@ -2348,7 +2348,7 @@ struct RobustFluctuationObservables {
23482348
// }
23492349
}
23502350

2351-
void fillPtHistos(string strTrackType, float pt, int charge, float w, bool noTF, bool noROF)
2351+
void fillPtHistos(const string& strTrackType, float pt, int charge, float w, bool noTF, bool noROF)
23522352
{
23532353
fillPtHistosThisCut(strTrackType, "allBC", pt, charge, w);
23542354

@@ -2369,7 +2369,7 @@ struct RobustFluctuationObservables {
23692369
fillPtHistosThisCut(strTrackType, "noTFandROFborder", pt, charge, w);
23702370
}
23712371

2372-
void fillPtHistosThisCut(string strTrackType, string strEvSelType, float pt, int charge, float w)
2372+
void fillPtHistosThisCut(const string& strTrackType, const string& strEvSelType, float pt, int charge, float w)
23732373
{
23742374
string strPre = strTrackType + "/" + strEvSelType;
23752375

PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ struct KaonIsospinFluctuations {
10161016
//_______________________________Identification Funtions Depending on the tpcInnerParam _______________________________
10171017
// tpc Selections
10181018
template <typename T>
1019-
bool selPionTPCInnerParam(T track)
1019+
bool selPionTPCInnerParam(const T& track)
10201020
{
10211021
if (vetoIdOthersTPC<kPi>(track)) {
10221022
if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 0.70 && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCLowP) {
@@ -1030,7 +1030,7 @@ struct KaonIsospinFluctuations {
10301030
}
10311031

10321032
template <typename T>
1033-
bool selKaonTPCInnerParam(T track)
1033+
bool selKaonTPCInnerParam(const T& track)
10341034
{
10351035
if (vetoIdOthersTPC<kKa>(track)) {
10361036
if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 0.70 && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCLowP) {
@@ -1044,7 +1044,7 @@ struct KaonIsospinFluctuations {
10441044
}
10451045

10461046
template <typename T>
1047-
bool selProtonTPCInnerParam(T track)
1047+
bool selProtonTPCInnerParam(const T& track)
10481048
{
10491049
if (vetoIdOthersTPC<kPr>(track)) {
10501050
if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 1.60 && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCLowP) {
@@ -1058,7 +1058,7 @@ struct KaonIsospinFluctuations {
10581058
}
10591059

10601060
template <typename T>
1061-
bool selDeuteronTPCInnerParam(T track)
1061+
bool selDeuteronTPCInnerParam(const T& track)
10621062
{
10631063
if (vetoIdOthersTPC<kDe>(track)) {
10641064
if (0.05 <= track.tpcInnerParam() && track.tpcInnerParam() < 1.80 && std::abs(track.tpcNSigmaDe()) < 3.0) {
@@ -1072,7 +1072,7 @@ struct KaonIsospinFluctuations {
10721072
}
10731073

10741074
template <typename T>
1075-
bool selElectronTPCInnerParam(T track)
1075+
bool selElectronTPCInnerParam(const T& track)
10761076
{
10771077
if (track.tpcNSigmaEl() < 3.0 && track.tpcNSigmaPi() > 3.0 && track.tpcNSigmaKa() > 3.0 && track.tpcNSigmaPr() > 3.0 && track.tpcNSigmaDe() > 3.0) {
10781078
return true;
@@ -1084,7 +1084,7 @@ struct KaonIsospinFluctuations {
10841084
// TOF Selections
10851085
// Pion
10861086
template <typename T>
1087-
bool selPionTOF(T track)
1087+
bool selPionTOF(const T& track)
10881088
{
10891089
if (vetoIdOthersTOF<kPi>(track)) {
10901090
if (track.p() <= 0.75 && std::abs(track.tpcNSigmaPi()) < cfgPiNSigmaTPCLowP && std::abs(track.tofNSigmaPi()) < cfgPiNSigmaTOFLowP) {
@@ -1099,7 +1099,7 @@ struct KaonIsospinFluctuations {
10991099

11001100
// Kaon
11011101
template <typename T>
1102-
bool selKaonTOF(T track)
1102+
bool selKaonTOF(const T& track)
11031103
{
11041104
if (vetoIdOthersTOF<kKa>(track)) {
11051105
if (track.p() <= 0.75 && std::abs(track.tpcNSigmaKa()) < cfgKaNSigmaTPCLowP && std::abs(track.tofNSigmaKa()) < cfgKaNSigmaTOFLowP) {
@@ -1119,7 +1119,7 @@ struct KaonIsospinFluctuations {
11191119

11201120
// Proton
11211121
template <typename T>
1122-
bool selProtonTOF(T track)
1122+
bool selProtonTOF(const T& track)
11231123
{
11241124
if (vetoIdOthersTOF<kPr>(track)) {
11251125
if (track.p() <= 1.30 && std::abs(track.tpcNSigmaPr()) < cfgPrNSigmaTPCLowP && std::abs(track.tofNSigmaPr()) < cfgPrNSigmaTOFLowP) {
@@ -1140,7 +1140,7 @@ struct KaonIsospinFluctuations {
11401140

11411141
// Deuteron
11421142
template <typename T>
1143-
bool selDeuteronTOF(T track)
1143+
bool selDeuteronTOF(const T& track)
11441144
{
11451145
if (vetoIdOthersTOF<kDe>(track)) {
11461146
if (track.p() <= 3.10 && std::abs(track.tpcNSigmaDe()) < 3.0 && std::abs(track.tofNSigmaDe()) < 3.0) {
@@ -1156,7 +1156,7 @@ struct KaonIsospinFluctuations {
11561156

11571157
// Electron
11581158
template <typename T>
1159-
bool selElectronTOF(T track)
1159+
bool selElectronTOF(const T& track)
11601160
{
11611161
if ((std::pow(track.tpcNSigmaEl(), 2) + std::pow(track.tofNSigmaEl(), 2)) < 9.00 && vetoIdOthersTOF<kEl>(track)) {
11621162
return true;
@@ -1168,7 +1168,7 @@ struct KaonIsospinFluctuations {
11681168
//______________________________Identification Functions________________________________________________________________
11691169
// Pion
11701170
template <typename T>
1171-
bool selPion(T track, int& IdMethod)
1171+
bool selPion(const T& track, int& IdMethod)
11721172
{
11731173
if (cfgDoPdependentId) {
11741174
return selPiPdependent(track, IdMethod);
@@ -1187,7 +1187,7 @@ struct KaonIsospinFluctuations {
11871187

11881188
// Kaon
11891189
template <typename T>
1190-
bool selKaon(T track, int& IdMethod)
1190+
bool selKaon(const T& track, int& IdMethod)
11911191
{
11921192
if (cfgDoPdependentId) {
11931193
return selKaPdependent(track, IdMethod);
@@ -1206,7 +1206,7 @@ struct KaonIsospinFluctuations {
12061206

12071207
// Proton
12081208
template <typename T>
1209-
bool selProton(T track, int& IdMethod)
1209+
bool selProton(const T& track, int& IdMethod)
12101210
{
12111211
if (cfgDoPdependentId) {
12121212
return selPrPdependent(track, IdMethod);
@@ -1225,7 +1225,7 @@ struct KaonIsospinFluctuations {
12251225

12261226
// Deuteron
12271227
template <typename T>
1228-
bool selDeuteron(T track, int& IdMethod)
1228+
bool selDeuteron(const T& track, int& IdMethod)
12291229
{
12301230
if (cfgDoPdependentId) {
12311231
return false;
@@ -1244,7 +1244,7 @@ struct KaonIsospinFluctuations {
12441244

12451245
// Electron
12461246
template <typename T>
1247-
bool selElectron(T track, int& IdMethod)
1247+
bool selElectron(const T& track, int& IdMethod)
12481248
{
12491249
if (cfgDoPdependentId) {
12501250
return false;
@@ -1310,7 +1310,7 @@ struct KaonIsospinFluctuations {
13101310
}
13111311

13121312
template <typename T>
1313-
bool selK0s(T v0)
1313+
bool selK0s(const T& v0)
13141314
{
13151315
if (k0sSelCut.cfgK0sMLow < v0.mK0Short() && v0.mK0Short() < k0sSelCut.cfgK0sMHigh &&
13161316
k0sSelCut.cfgK0sLowPt < v0.pt() && v0.pt() < k0sSelCut.cfgK0sHighPt &&
@@ -1323,7 +1323,7 @@ struct KaonIsospinFluctuations {
13231323
}
13241324

13251325
template <typename T>
1326-
void findRepeatedEntries(std::vector<int64_t> ParticleList, T hist)
1326+
void findRepeatedEntries(std::vector<int64_t> ParticleList, const T& hist)
13271327
{
13281328
for (uint ii = 0; ii < ParticleList.size(); ii++) {
13291329
int nCommonCount = 0; // checking the repeat number of track
@@ -1441,7 +1441,7 @@ struct KaonIsospinFluctuations {
14411441
}
14421442

14431443
template <int Mode, typename T>
1444-
void fillTrackQA(T track)
1444+
void fillTrackQA(const T& track)
14451445
{
14461446
// FullTrack
14471447
recoTracks.fill(HIST(HistRegDire[Mode]) + HIST("h01_p"), track.p());

PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ struct RadialFlowDecorr {
12051205
LOGF(info, "Loading Eff/Fake maps from TList for all species...");
12061206

12071207
auto loadEffFakeForPID = [&](PIDIdx pidType) {
1208-
std::string suffix = pidSuffix[pidType];
1208+
const std::string& suffix = pidSuffix[pidType];
12091209
std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix;
12101210
std::string hEffDenName = "h3_AllPrimary" + suffix;
12111211
std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix;
@@ -1262,7 +1262,7 @@ struct RadialFlowDecorr {
12621262
}
12631263
LOGF(info, "Performing 2D Gaussian fits on PID maps from CCDB...");
12641264
auto loadPIDMeans = [&](PIDIdx pidType) {
1265-
std::string suffix = pidSuffix[pidType];
1265+
const std::string& suffix = pidSuffix[pidType];
12661266
std::string hName = "h3DnsigmaTpcVsTofBefCut_Cent" + suffix;
12671267
auto* h3 = reinterpret_cast<TH3F*>(pidList->FindObject(hName.c_str()));
12681268
if (!h3) {
@@ -1327,7 +1327,7 @@ struct RadialFlowDecorr {
13271327

13281328
if (lstDataFlat) {
13291329
for (int i = 0; i < KNsp; ++i) {
1330-
std::string suffix = pidSuffix[i];
1330+
const std::string& suffix = pidSuffix[i];
13311331
std::string hName;
13321332

13331333
if (cfgEff && cfgFlat) {
@@ -1356,7 +1356,7 @@ struct RadialFlowDecorr {
13561356

13571357
if (lstMCFlat) {
13581358
auto loadFlatForPID = [&](PIDIdx pidType) {
1359-
std::string suffix = pidSuffix[pidType];
1359+
const std::string& suffix = pidSuffix[pidType];
13601360
std::string hFlatSrcName;
13611361
if (cfgEff && cfgFlat) {
13621362
hFlatSrcName = "MCReco/hEtaPhiRecoWtd" + suffix;

PWGCF/EbyEFluctuations/Tasks/v0ptHadPiKaProt.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ struct V0ptHadPiKaProt {
990990
}
991991

992992
template <typename TTrack>
993-
int getNsigmaPID(TTrack track)
993+
int getNsigmaPID(const TTrack& track)
994994
{
995995
// Computing Nsigma arrays for pion, kaon, and protons
996996
std::array<float, 3> nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()};
@@ -1041,7 +1041,7 @@ struct V0ptHadPiKaProt {
10411041

10421042
// additional multiplicity correlation based event selection cuts
10431043
template <typename TCollision>
1044-
bool eventSelectedSmallion(TCollision collision, const int multTrk, const float centrality)
1044+
bool eventSelectedSmallion(const TCollision& collision, const int multTrk, const float centrality)
10451045
{
10461046
auto multNTracksPV = collision.multNTracksPV();
10471047

@@ -1083,7 +1083,7 @@ struct V0ptHadPiKaProt {
10831083
}
10841084

10851085
template <typename TCollision>
1086-
bool eventSelectionDefaultCuts(TCollision coll)
1086+
bool eventSelectionDefaultCuts(const TCollision& coll)
10871087
{
10881088
histos.fill(HIST("hEventStatData"), 0.5);
10891089
if (!coll.sel8()) {

PWGCF/Femto3D/Tasks/femto3dPairTask.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ struct FemtoCorrelations {
356356
if (_fill3dCF && multBin > SEhistos_3D.size())
357357
LOGF(fatal, "multBin value passed to the mixTracks function exceeds the configured number of Cent. bins (3D)");
358358

359-
for (auto ii : tracks1) {
360-
for (auto iii : tracks2) {
359+
for (const auto& ii : tracks1) {
360+
for (const auto& iii : tracks2) {
361361

362362
Pair->SetPair(ii, iii);
363363
float pair_kT = Pair->GetKt();

PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ struct FemtoCorrelationsMC {
118118
using FilteredTracks = soa::Join<aod::SingleTrackSels, aod::SingleTrkMCs, aod::SinglePIDPrs, aod::SinglePIDDes>;
119119
// using FilteredTracks = soa::Join<aod::SingleTrackSels, aod::SingleTrkMCs, aod::SinglePIDPis, aod::SinglePIDKas, aod::SinglePIDPrs, aod::SinglePIDDes, aod::SinglePIDTrs, aod::SinglePIDHes>;
120120

121-
typedef std::shared_ptr<soa::Filtered<FilteredTracks>::iterator> trkType;
122-
typedef std::shared_ptr<soa::Filtered<FilteredCollisions>::iterator> colType;
121+
using TrackType = const soa::Filtered<FilteredTracks>::iterator;
122+
using TrackTypePtr = std::shared_ptr<TrackType>;
123+
using ColType = const soa::Filtered<FilteredCollisions>::iterator;
124+
using ColTypePtr = std::shared_ptr<ColType>;
123125

124-
std::map<int64_t, std::vector<trkType>> selectedtracks_1;
125-
std::map<int64_t, std::vector<trkType>> selectedtracks_2;
126-
std::map<std::pair<int, float>, std::vector<colType>> mixbins;
126+
std::map<int64_t, std::vector<TrackTypePtr>> selectedtracks_1;
127+
std::map<int64_t, std::vector<TrackTypePtr>> selectedtracks_2;
128+
std::map<std::pair<int, float>, std::vector<ColTypePtr>> mixbins;
127129

128-
std::unique_ptr<o2::aod::singletrackselector::FemtoPair<trkType>> Pair = std::make_unique<o2::aod::singletrackselector::FemtoPair<trkType>>();
130+
std::unique_ptr<o2::aod::singletrackselector::FemtoPair<TrackTypePtr>> Pair = std::make_unique<o2::aod::singletrackselector::FemtoPair<TrackTypePtr>>();
129131

130132
Filter pFilter = o2::aod::singletrackselector::p > _min_P&& o2::aod::singletrackselector::p < _max_P;
131133
Filter etaFilter = nabs(o2::aod::singletrackselector::eta) < _eta;
@@ -283,8 +285,8 @@ struct FemtoCorrelationsMC {
283285
template <typename Type>
284286
void fillEtaPhi(Type const& tracks1, Type const& tracks2, unsigned int centBin)
285287
{ // template for particles from the same collision non-identical
286-
for (auto ii : tracks1) {
287-
for (auto iii : tracks2) {
288+
for (const auto& ii : tracks1) {
289+
for (const auto& iii : tracks2) {
288290

289291
Pair->SetPair(ii, iii);
290292
float pair_kT = Pair->GetKt();
@@ -307,8 +309,8 @@ struct FemtoCorrelationsMC {
307309
template <typename Type>
308310
void fillResMatrix(Type const& tracks1, Type const& tracks2, unsigned int centBin)
309311
{ // template for ME
310-
for (auto ii : tracks1) {
311-
for (auto iii : tracks2) {
312+
for (const auto& ii : tracks1) {
313+
for (const auto& iii : tracks2) {
312314

313315
Pair->SetPair(ii, iii);
314316
float pair_kT = Pair->GetKt();
@@ -344,7 +346,7 @@ struct FemtoCorrelationsMC {
344346

345347
int trackPDG, trackOrigin;
346348

347-
for (auto track : tracks) {
349+
for (const auto& track : tracks) {
348350
if (std::fabs(track.template singleCollSel_as<soa::Filtered<FilteredCollisions>>().posZ()) > _vertexZ)
349351
continue;
350352
if (track.tpcFractionSharedCls() > _tpcFractionSharedCls || track.itsNCls() < _itsNCls)
@@ -385,7 +387,7 @@ struct FemtoCorrelationsMC {
385387
if (trackPDG == 11 || trackPDG == 13 || trackPDG == 211 || trackPDG == 321 || trackPDG == 2212 || trackPDG == 1000010020)
386388
Purity_histos_1[centBin][trackPDG]->Fill(track.p());
387389

388-
selectedtracks_1[track.singleCollSelId()].push_back(std::make_shared<decltype(track)>(track)); // filling the map: eventID <-> selected particles1
390+
selectedtracks_1[track.singleCollSelId()].push_back(std::make_shared<TrackType>(track)); // filling the map: eventID <-> selected particles1
389391
}
390392

391393
if (IsIdentical) {
@@ -406,11 +408,11 @@ struct FemtoCorrelationsMC {
406408
if (trackPDG == 11 || trackPDG == 13 || trackPDG == 211 || trackPDG == 321 || trackPDG == 2212 || trackPDG == 1000010020)
407409
Purity_histos_2[centBin][trackPDG]->Fill(track.p());
408410

409-
selectedtracks_2[track.singleCollSelId()].push_back(std::make_shared<decltype(track)>(track)); // filling the map: eventID <-> selected particles2
411+
selectedtracks_2[track.singleCollSelId()].push_back(std::make_shared<TrackType>(track)); // filling the map: eventID <-> selected particles2
410412
}
411413
}
412414

413-
for (auto collision : collisions) {
415+
for (const auto& collision : collisions) {
414416
if (collision.multPerc() < *_centBins.value.begin() || collision.multPerc() >= *(_centBins.value.end() - 1))
415417
continue;
416418
if (collision.hadronicRate() < _IRcut.value.first || collision.hadronicRate() >= _IRcut.value.second)
@@ -440,7 +442,7 @@ struct FemtoCorrelationsMC {
440442
int vertexBinToMix = std::floor((collision.posZ() + _vertexZ) / (2 * _vertexZ / _vertexNbinsToMix));
441443
float centBinToMix = o2::aod::singletrackselector::getBinIndex<float>(collision.multPerc(), _centBins, _multNsubBins);
442444

443-
mixbins[std::pair<int, float>{vertexBinToMix, centBinToMix}].push_back(std::make_shared<decltype(collision)>(collision));
445+
mixbins[std::pair<int, float>{vertexBinToMix, centBinToMix}].push_back(std::make_shared<ColType>(collision));
444446
}
445447

446448
//====================================== filling deta(dphi*) & res. matrix starts here ======================================

PWGCF/Femto3D/Tools/checkPacking.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
using namespace o2;
3131

3232
template <typename T>
33-
bool process(const TString outputName, const int nevents = 100000)
33+
bool process(const TString& outputName, const int nevents = 100000)
3434
{
3535
class Container
3636
{

PWGCF/FemtoDream/Core/femtoDreamCollisionSelection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <cstddef>
3232
#include <memory>
3333
#include <string>
34+
#include <utility>
3435
#include <vector>
3536

3637
namespace o2::analysis::femtoDream
@@ -420,7 +421,7 @@ class FemtoDreamCollisionSelection
420421
// add a param : bool doFillHisto ?
421422
int myqnBin(float centrality, float centMax, bool doFillCent, std::vector<float> qnBinSeparator, float qn, const int numQnBins, float centBinWidth = 1.f)
422423
{
423-
auto twoDSeparator = getQnBinSeparator2D(qnBinSeparator, numQnBins);
424+
auto twoDSeparator = getQnBinSeparator2D(std::move(qnBinSeparator), numQnBins);
424425
if (twoDSeparator.empty() || twoDSeparator[0][0] == -999.) {
425426
LOGP(warning, "ConfQnBinSeparator not set, using default fallback!");
426427
return -999; // safe fallback

0 commit comments

Comments
 (0)