Skip to content

Commit 8244017

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

23 files changed

Lines changed: 60 additions & 59 deletions

Tutorials/PWGCF/EventPlane/src/qVectorstutorial.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct qVectorstutorial {
9898
}
9999

100100
template <typename TrackType>
101-
bool SelTrack(const TrackType track)
101+
bool SelTrack(const TrackType& track)
102102
{
103103
if (track.pt() < cfgMinPt)
104104
return false;

Tutorials/PWGEM/Cocktail/plotLFCocktail.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TString histLegends[nHists] = {
3030
"#phi#rightarrow#etae^{+}e^{-}, #phi#rightarrow#pi^{0}e^{+}e^{-}, "
3131
"#phi#rightarrowe^{+}e^{-}"};
3232

33-
void loadHistos(TFile* file, TH1F* hists[], TString name_extra, int rebin,
33+
void loadHistos(TFile* file, TH1F* hists[], const TString& name_extra, int rebin,
3434
int nEvents)
3535
{
3636
for (int i = 0; i < nHists; i++) {
@@ -42,7 +42,7 @@ void loadHistos(TFile* file, TH1F* hists[], TString name_extra, int rebin,
4242
}
4343
}
4444

45-
void plotLFCocktail(TString filename = "AnalysisResults.root", int rebin = 1)
45+
void plotLFCocktail(const TString& filename = "AnalysisResults.root", int rebin = 1)
4646
{
4747

4848
TFile* file = TFile::Open(filename.Data());

Tutorials/PWGLF/Resonance/resonancesCombine.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct ResonanceCombine {
9393
}
9494

9595
template <typename TrackType>
96-
bool trackCut(const TrackType track)
96+
bool trackCut(const TrackType& track)
9797
{
9898
if (std::abs(track.pt()) < cMinPtcut)
9999
return false;

Tutorials/PWGLF/Resonance/resonancesMicrotrack.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct ResonancesMicrotrack {
9090
}
9191

9292
template <bool IsResoMicrotrack, typename TrackType>
93-
bool trackCut(const TrackType track)
93+
bool trackCut(const TrackType& track)
9494
{
9595
if constexpr (!IsResoMicrotrack) {
9696
if (std::abs(track.pt()) < cMinPtcut)

Tutorials/PWGLF/Resonance/resonances_step0.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct resonances_tutorial {
4747

4848
// Track selection
4949
template <typename TrackType>
50-
bool trackCut(const TrackType track)
50+
bool trackCut(const TrackType& track)
5151
{
5252
// basic track cuts
5353
if (std::abs(track.pt()) < cMinPtcut)
@@ -60,7 +60,7 @@ struct resonances_tutorial {
6060
template <bool IsMC, bool IsMix, typename CollisionType, typename TracksType>
6161
void fillHistograms(const CollisionType& /*collision*/, const TracksType& dTracks1, const TracksType& /*dTracks2*/)
6262
{
63-
for (auto track1 : dTracks1) { // loop over all dTracks1
63+
for (const auto& track1 : dTracks1) { // loop over all dTracks1
6464
if (!trackCut(track1))
6565
continue; // track selection and PID selection
6666
histos.fill(HIST("hEta"), track1.eta());

Tutorials/PWGLF/Resonance/resonances_step1.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct resonances_tutorial {
8484

8585
// Track selection
8686
template <typename TrackType>
87-
bool trackCut(const TrackType track)
87+
bool trackCut(const TrackType& track)
8888
{
8989
// basic track cuts
9090
if (std::abs(track.pt()) < cMinPtcut)
@@ -121,7 +121,7 @@ struct resonances_tutorial {
121121
void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2)
122122
{
123123
auto multiplicity = collision.cent();
124-
for (auto track1 : dTracks1) { // loop over all dTracks1
124+
for (const auto& track1 : dTracks1) { // loop over all dTracks1
125125
if (!trackCut(track1) || !selectionPID(track1)) {
126126
continue; // track selection and PID selection
127127
}
@@ -133,7 +133,7 @@ struct resonances_tutorial {
133133
if (track1.hasTOF()) {
134134
histos.fill(HIST("hNsigmaKaonTOF"), track1.tofNSigmaKa());
135135
}
136-
for (auto track2 : dTracks2) { // loop over all dTracks2
136+
for (const auto& track2 : dTracks2) { // loop over all dTracks2
137137
if (!trackCut(track2) || !selectionPID(track2)) {
138138
continue; // track selection and PID selection
139139
}

Tutorials/PWGLF/Resonance/resonances_step2.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct resonances_tutorial {
9696

9797
// Track selection
9898
template <typename TrackType>
99-
bool trackCut(const TrackType track)
99+
bool trackCut(const TrackType& track)
100100
{
101101
// basic track cuts
102102
if (std::abs(track.pt()) < cMinPtcut)
@@ -133,7 +133,7 @@ struct resonances_tutorial {
133133
void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2)
134134
{
135135
auto multiplicity = collision.cent();
136-
for (auto track1 : dTracks1) { // loop over all dTracks1
136+
for (const auto& track1 : dTracks1) { // loop over all dTracks1
137137
if (!trackCut(track1) || !selectionPID(track1)) {
138138
continue; // track selection and PID selection
139139
}
@@ -145,7 +145,7 @@ struct resonances_tutorial {
145145
if (track1.hasTOF()) {
146146
histos.fill(HIST("hNsigmaKaonTOF"), track1.tofNSigmaKa());
147147
}
148-
for (auto track2 : dTracks2) { // loop over all dTracks2
148+
for (const auto& track2 : dTracks2) { // loop over all dTracks2
149149
if (!trackCut(track2) || !selectionPID(track2)) {
150150
continue; // track selection and PID selection
151151
}

Tutorials/PWGLF/Resonance/resonances_step3.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct resonances_tutorial {
4747

4848
// MC particle selection
4949
template <typename ParticleType>
50-
bool ptCut(const ParticleType resoParents)
50+
bool ptCut(const ParticleType& resoParents)
5151
{
5252
// basic pt cuts
5353
if (std::abs(resoParents.pt()) < cMinPtcut)
@@ -60,7 +60,7 @@ struct resonances_tutorial {
6060
template <typename CollisionType, typename ParticleType>
6161
void fillHistograms(const CollisionType& /*collision*/, const ParticleType& resoParents)
6262
{
63-
for (auto part : resoParents) { // loop over all resoParents
63+
for (const auto& part : resoParents) { // loop over all resoParents
6464
if (!ptCut(part))
6565
continue; // pt selection
6666

Tutorials/PWGLF/Resonance/resonances_step4.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct resonances_tutorial {
6363

6464
// MC particle selection
6565
template <typename ParticleType>
66-
bool ptCut(const ParticleType resoParents)
66+
bool ptCut(const ParticleType& resoParents)
6767
{
6868
// basic pt cuts
6969
if (std::abs(resoParents.pt()) < cMinPtcut)

Tutorials/PWGLF/Resonance/resonances_step5.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct resonances_tutorial {
8080

8181
// Track selection
8282
template <typename TrackType>
83-
bool trackCut(const TrackType track)
83+
bool trackCut(const TrackType& track)
8484
{
8585
// basic track cuts
8686
if (std::abs(track.pt()) < cMinPtcut)
@@ -113,7 +113,7 @@ struct resonances_tutorial {
113113
template <typename CollisionType, typename TracksType>
114114
void fillHistograms(const CollisionType& /* collision */, const TracksType& dTracks)
115115
{
116-
for (auto track : dTracks) { // loop over all dTracks
116+
for (const auto& track : dTracks) { // loop over all dTracks
117117
if (!trackCut(track) || !selectionPID(track)) {
118118
continue; // track selection and PID selection
119119
}

0 commit comments

Comments
 (0)