Skip to content

Commit 1ca779b

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

84 files changed

Lines changed: 292 additions & 288 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.

PWGLF/TableProducer/Common/epvector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ struct epvector {
210210
}
211211

212212
template <typename TCollision>
213-
bool eventSelected(TCollision collision, const float& centrality)
213+
bool eventSelected(const TCollision& collision, const float& centrality)
214214
{
215215
if (collision.alias_bit(kTVXinTRD)) {
216216
// TRD triggered // return 0;

PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ struct DeuteronInTriggeredEvents {
355355

356356
HistogramRegistry spectra{"spectra", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
357357

358-
double computeAbsoDecL(aod::McParticles::iterator particle)
358+
double computeAbsoDecL(const aod::McParticles::iterator& particle)
359359
{
360360
if (!particle.has_daughters())
361361
return -1.f;

PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct DaughterParticle {
198198
std::array<float, nBetheParams> betheParams;
199199
std::array<float, nTrkSettings> trkSettings;
200200
bool active;
201-
DaughterParticle(std::string name_, int pdgCode_, double mass_, int charge_, LabeledArray<double> bethe, LabeledArray<double> settings) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false)
201+
DaughterParticle(const std::string& name_, int pdgCode_, double mass_, int charge_, const LabeledArray<double>& bethe, const LabeledArray<double>& settings) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false)
202202
{
203203
for (unsigned int i = 0; i < betheParams.size(); i++) {
204204
betheParams[i] = bethe.get(name, i);
@@ -220,19 +220,19 @@ struct HyperNucleus {
220220
bool active, savePrimary;
221221
std::vector<int> daughters, daughterTrackSigns, v0DaughterVec;
222222
std::vector<float> primSettings;
223-
HyperNucleus(std::string name_, int pdgCode_, bool active_, std::vector<int> daughters_, std::vector<int> daughterTrackSigns_, std::vector<int> v0DaughterVec_, LabeledArray<double> primSettings_) : pdgCode(pdgCode_), active(active_), savePrimary(active_)
223+
HyperNucleus(const std::string& name_, int pdgCode_, bool active_, const std::vector<int>& daughters_, const std::vector<int>& daughterTrackSigns_, const std::vector<int>& v0DaughterVec_, const LabeledArray<double>& primSettings_) : pdgCode(pdgCode_), active(active_), savePrimary(active_)
224224
{
225-
init(name_, daughters_, daughterTrackSigns_, v0DaughterVec_);
225+
init(std::move(name_), std::move(daughters_), std::move(daughterTrackSigns_), std::move(v0DaughterVec_));
226226
for (unsigned int i = 0; i < nSelPrim; i++) {
227227
primSettings.push_back(primSettings_.get(name, i));
228228
}
229229
}
230-
HyperNucleus(std::string name_, int pdgCode_, bool active_, int hypDaughter, std::vector<int> daughters_, std::vector<int> daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_)
230+
HyperNucleus(const std::string& name_, int pdgCode_, bool active_, int hypDaughter, const std::vector<int>& daughters_, const std::vector<int>& daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_)
231231
{
232232
daughters.push_back(hypDaughter);
233-
init(name_, daughters_, daughterTrackSigns_);
233+
init(std::move(name_), std::move(daughters_), std::move(daughterTrackSigns_));
234234
}
235-
void init(std::string name_, std::vector<int> daughters_, std::vector<int> daughterTrackSigns_, std::vector<int> v0DaughterVec_ = {})
235+
void init(const std::string& name_, const std::vector<int>& daughters_, const std::vector<int>& daughterTrackSigns_, const std::vector<int>& v0DaughterVec_ = {})
236236
{
237237
name = TString(name_);
238238
for (const int& d : daughters_)
@@ -265,8 +265,8 @@ struct DaughterKf {
265265
float dcaToPv, dcaToPvXY, dcaToPvZ, tpcNsigma, tpcNsigmaNLP, tpcNsigmaNHP;
266266
bool active;
267267
std::vector<float> vtx;
268-
DaughterKf(int species_, int64_t daughterTrackId_, int sign_, std::vector<float> vtx_, float tpcNsigma_, float tpcNsigmaNLP_, float tpcNsigmaNHP_) : daughterTrackId(daughterTrackId_), id(uniqueId++), species(species_), sign(sign_), hypNucId(-1), tpcNsigma(tpcNsigma_), tpcNsigmaNLP(tpcNsigmaNLP_), tpcNsigmaNHP(tpcNsigmaNHP_), vtx(vtx_) {}
269-
void addKfp(KFParticle daughterKfp_)
268+
DaughterKf(int species_, int64_t daughterTrackId_, int sign_, std::vector<float> vtx_, float tpcNsigma_, float tpcNsigmaNLP_, float tpcNsigmaNHP_) : daughterTrackId(daughterTrackId_), id(uniqueId++), species(species_), sign(sign_), hypNucId(-1), tpcNsigma(tpcNsigma_), tpcNsigmaNLP(tpcNsigmaNLP_), tpcNsigmaNHP(tpcNsigmaNHP_), vtx(std::move(vtx_)) {}
269+
void addKfp(const KFParticle& daughterKfp_)
270270
{
271271
daughterKfp = daughterKfp_;
272272
dcaToPvXY = daughterKfp.GetDistanceFromVertexXY(&vtx[0]);
@@ -290,7 +290,7 @@ struct HyperNucCandidate {
290290
bool mcTrue, isPhysPrimary, isPrimaryCandidate, isSecondaryCandidate, isUsedSecondary;
291291
int64_t mcParticleId;
292292
int tableId;
293-
HyperNucCandidate(int species_, HyperNucCandidate* hypNucDaughter_, std::vector<DaughterKf*> daughters_) : species(species_), hypNucDaughter(hypNucDaughter_), devToPvXY(-999), dcaToPvXY(-999), dcaToPvZ(-999), dcaToVtxXY(-999), dcaToVtxZ(-999), chi2(-999), itsMeanClsSize(-1), mcTrue(false), isPhysPrimary(false), isPrimaryCandidate(false), isSecondaryCandidate(false), isUsedSecondary(false), mcParticleId(-1), tableId(-1)
293+
HyperNucCandidate(int species_, HyperNucCandidate* hypNucDaughter_, const std::vector<DaughterKf*>& daughters_) : species(species_), hypNucDaughter(hypNucDaughter_), devToPvXY(-999), dcaToPvXY(-999), dcaToPvZ(-999), dcaToVtxXY(-999), dcaToVtxZ(-999), chi2(-999), itsMeanClsSize(-1), mcTrue(false), isPhysPrimary(false), isPrimaryCandidate(false), isSecondaryCandidate(false), isUsedSecondary(false), mcParticleId(-1), tableId(-1)
294294
{
295295
for (const auto& d : daughters_)
296296
daughters.push_back(d);
@@ -402,7 +402,7 @@ struct HyperNucCandidate {
402402
}
403403
return calcSubDaughterMass(daughters.at(d1)->daughterKfp, hypNucDaughter->daughters.at(d2)->daughterKfp);
404404
}
405-
float calcSubDaughterMass(KFParticle d1, KFParticle d2)
405+
float calcSubDaughterMass(const KFParticle& d1, const KFParticle& d2)
406406
{
407407
KFParticle subDaughter;
408408
subDaughter.SetConstructMethod(2);
@@ -475,7 +475,7 @@ struct DaughterCombinations {
475475
int nVecs, nCombinations;
476476
bool end;
477477
std::vector<int> nonV0daughters;
478-
DaughterCombinations(std::vector<std::vector<DaughterKf>*>& vecs, std::vector<int> nonV0daughters_) : nVecs(0), nCombinations(1), end(false), nonV0daughters(nonV0daughters_)
478+
DaughterCombinations(std::vector<std::vector<DaughterKf>*>& vecs, std::vector<int> nonV0daughters_) : nVecs(0), nCombinations(1), end(false), nonV0daughters(std::move(nonV0daughters_))
479479
{
480480
for (const auto& vec : vecs) {
481481
nVecs++;
@@ -1311,15 +1311,15 @@ struct HypKfRecoTask {
13111311
}
13121312
//----------------------------------------------------------------------------------------------------------------
13131313

1314-
int getHypDaughterVec(unsigned int cascade, LabeledArray<std::string> cfg)
1314+
int getHypDaughterVec(unsigned int cascade, const LabeledArray<std::string>& cfg)
13151315
{
13161316
std::string daughter = cfg.get(cascade, 0u);
13171317
if (std::find(hyperNucNames.begin(), hyperNucNames.end(), daughter) == hyperNucNames.end())
13181318
return -1;
13191319
return std::find(hyperNucNames.begin(), hyperNucNames.end(), daughter) - hyperNucNames.begin();
13201320
}
13211321
//----------------------------------------------------------------------------------------------------------------
1322-
std::vector<int> getDaughterVec(unsigned int hypNuc, LabeledArray<std::string> cfg)
1322+
std::vector<int> getDaughterVec(unsigned int hypNuc, const LabeledArray<std::string>& cfg)
13231323
{
13241324
std::vector<int> vec;
13251325
for (unsigned int i = kD1; i <= kD4; i++) {
@@ -1332,7 +1332,7 @@ struct HypKfRecoTask {
13321332
}
13331333
//----------------------------------------------------------------------------------------------------------------
13341334

1335-
std::vector<int> getDaughterSignVec(unsigned int hypNuc, LabeledArray<std::string> cfg)
1335+
std::vector<int> getDaughterSignVec(unsigned int hypNuc, const LabeledArray<std::string>& cfg)
13361336
{
13371337
std::vector<int> vec;
13381338
std::string signs = cfg.get(hypNuc, "daughterSigns");
@@ -1345,7 +1345,7 @@ struct HypKfRecoTask {
13451345
return vec;
13461346
}
13471347
//----------------------------------------------------------------------------------------------------------------
1348-
std::vector<int> getV0DaughterVec(unsigned int hypNuc, LabeledArray<std::string> cfg)
1348+
std::vector<int> getV0DaughterVec(unsigned int hypNuc, const LabeledArray<std::string>& cfg)
13491349
{
13501350
std::vector<int> vec;
13511351
std::string v0ds = cfg.get(hypNuc, "useV0for");

PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ struct HypKfTreeCreator {
438438
PROCESS_SWITCH(HypKfTreeCreator, processMC, "MC tree", false);
439439

440440
//___________________________________________________________________________________________________________________________________________________________
441-
std::vector<float> dcaTracksAll(std::vector<arr3>& posVec, TString opt = "")
441+
std::vector<float> dcaTracksAll(std::vector<arr3>& posVec, const TString& opt = "")
442442
{
443443
std::vector<float> vec;
444444
int n = posVec.size();
@@ -450,7 +450,7 @@ struct HypKfTreeCreator {
450450
return vec;
451451
}
452452
template <class T>
453-
std::vector<float> dcaTrackSvAll(std::vector<arr3>& posVec, T const& hypNuc, TString opt = "")
453+
std::vector<float> dcaTrackSvAll(std::vector<arr3>& posVec, T const& hypNuc, const TString& opt = "")
454454
{
455455
std::vector<float> vec;
456456
for (size_t i = 0; i < posVec.size(); i++) {
@@ -463,22 +463,22 @@ struct HypKfTreeCreator {
463463
{
464464
return *max_element(vec.begin(), vec.end());
465465
}
466-
float meanValue(std::vector<float> vec)
466+
float meanValue(const std::vector<float>& vec)
467467
{
468468
float sum = 0;
469469
for (const auto& value : vec)
470470
sum += value;
471471
return sum / vec.size();
472472
}
473-
float mean2Value(std::vector<float> vec)
473+
float mean2Value(const std::vector<float>& vec)
474474
{
475475
float sum = 0;
476476
for (const auto& value : vec)
477477
sum += (value * value);
478478
return std::sqrt(sum / vec.size());
479479
}
480480

481-
float dcaTracks(std::vector<arr3> v, int track1, int track2, TString opt = "XY")
481+
float dcaTracks(std::vector<arr3> v, int track1, int track2, const TString& opt = "XY")
482482
{
483483
if (opt == "XY")
484484
return RecoDecay::distanceXY(v.at(track1), v.at(track2));
@@ -488,7 +488,7 @@ struct HypKfTreeCreator {
488488
return RecoDecay::distance(v.at(track1), v.at(track2));
489489
}
490490
template <class T>
491-
float dcaTrackSv(std::vector<arr3>& v, int track, T const& hypNuc, TString opt = "")
491+
float dcaTrackSv(std::vector<arr3>& v, int track, T const& hypNuc, const TString& opt = "")
492492
{
493493
if (opt == "XY")
494494
return RecoDecay::distanceXY(v.at(track), decayVtx(hypNuc));

PWGLF/TableProducer/Nuspex/hyperkinkRecoTask.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ struct HyperkinkQa {
11621162

11631163
// QA for mother track selection
11641164
template <typename TTrack>
1165-
bool motherTrackCheck(const TTrack& track, const std::shared_ptr<TH1> hist)
1165+
bool motherTrackCheck(const TTrack& track, const std::shared_ptr<TH1>& hist)
11661166
{
11671167
hist->Fill(1);
11681168

@@ -1206,7 +1206,7 @@ struct HyperkinkQa {
12061206

12071207
// qa for daughter track selection
12081208
template <typename TTrack>
1209-
bool daughterTrackCheck(const TTrack& track, const std::shared_ptr<TH1> hist, float tpcNSigma)
1209+
bool daughterTrackCheck(const TTrack& track, const std::shared_ptr<TH1>& hist, float tpcNSigma)
12101210
{
12111211
hist->Fill(1);
12121212

PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ struct nucleiSpectra {
394394

395395
HistogramRegistry spectra{"spectra", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
396396

397-
double computeAbsoDecL(aod::McParticles::iterator particle)
397+
double computeAbsoDecL(const aod::McParticles::iterator& particle)
398398
{
399399
if (!particle.has_daughters())
400400
return -1.f;

PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ struct TrackedHypertritonRecoTask {
780780
}
781781

782782
template <class TTracksTo, typename TTracked3body>
783-
std::array<float, 2> getItsTrackDCAToSV(TTracked3body tracked3Body)
783+
std::array<float, 2> getItsTrackDCAToSV(const TTracked3body& tracked3Body)
784784
{
785785
const auto itsTrack = tracked3Body.template itsTrack_as<TTracksTo>();
786786
auto itsTrackParCov = getTrackParCov(itsTrack);

PWGLF/TableProducer/Resonances/HeptaQuarktable.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ struct heptaquarktable {
262262

263263
auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache);
264264
auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache);
265-
for (auto track1 : posThisColl) {
265+
for (const auto& track1 : posThisColl) {
266266
if (!selectionTrack(track1))
267267
continue;
268268

@@ -279,7 +279,7 @@ struct heptaquarktable {
279279
}
280280
*/
281281
auto track1ID = track1.globalIndex();
282-
for (auto track2 : negThisColl) {
282+
for (const auto& track2 : negThisColl) {
283283
if (!selectionTrack(track2))
284284
continue;
285285

PWGLF/TableProducer/Resonances/doublephitable.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ struct doublephitable {
264264
hProcessedEvents->Fill(2.5);
265265
auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache);
266266
auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache);
267-
for (auto track1 : posThisColl) {
267+
for (const auto& track1 : posThisColl) {
268268
// track selection
269269
if (!selectionTrack(track1)) {
270270
continue;
@@ -283,7 +283,7 @@ struct doublephitable {
283283
qaRegistry.fill(HIST("hNsigmaPtkaonTOF"), track1.tofNSigmaKa(), track1.pt());
284284
}
285285
auto track1ID = track1.globalIndex();
286-
for (auto track2 : negThisColl) {
286+
for (const auto& track2 : negThisColl) {
287287
auto track2ID = track2.globalIndex();
288288
if (track2ID == track1ID) {
289289
continue;
@@ -600,7 +600,7 @@ struct doublephitable {
600600
selectedNeg.reserve(negThisColl.size());
601601
selectedPosITS.reserve(posThisColl.size());
602602
selectedNegITS.reserve(negThisColl.size());
603-
for (auto track : posThisColl) {
603+
for (const auto& track : posThisColl) {
604604
if (!selectionTrack(track)) {
605605
continue;
606606
}
@@ -622,7 +622,7 @@ struct doublephitable {
622622
}
623623
}
624624

625-
for (auto track : negThisColl) {
625+
for (const auto& track : negThisColl) {
626626
if (!selectionTrack(track)) {
627627
continue;
628628
}

PWGLF/TableProducer/Resonances/f1protonInitializer.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ struct f1protoninitializer {
222222
bool triggerF1 = false;
223223
bool triggerF1Proton = false;
224224
bool triggerF1ProtonFemto = false;
225-
for (auto track1 : tracks) {
225+
for (const auto& track1 : tracks) {
226226
if (!SelectionTrack(track1)) {
227227
continue;
228228
}
@@ -242,7 +242,7 @@ struct f1protoninitializer {
242242
qaRegistry.fill(HIST("hNsigmaPtpionTOF"), track1.tofNSigmaPi(), track1.pt());
243243
}
244244
auto track1ID = track1.globalIndex();
245-
for (auto track2 : tracks) {
245+
for (const auto& track2 : tracks) {
246246
if (!SelectionTrack(track2)) {
247247
continue;
248248
}
@@ -273,7 +273,7 @@ struct f1protoninitializer {
273273
int track2Sign = track2.sign();
274274
numberPiKpair = numberPiKpair + 1;
275275

276-
for (auto track3 : V0s) {
276+
for (const auto& track3 : V0s) {
277277
if (!SelectionV0(collision, track3)) {
278278
continue;
279279
}
@@ -308,7 +308,7 @@ struct f1protoninitializer {
308308
F1Vector.SetXYZM(track1.px() + track2.px() + track3.px(), track1.py() + track2.py() + track3.py(), track1.pz() + track2.pz() + track3.pz(), massF1);
309309

310310
////////////// proton loop for F1-proton trigger/////////////////
311-
for (auto track4 : tracks) {
311+
for (const auto& track4 : tracks) {
312312
auto collisionId4 = track4.collisionId();
313313
if (collisionId1 != collisionId4) {
314314
continue;

0 commit comments

Comments
 (0)