Skip to content

Commit 8a33aaf

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

23 files changed

Lines changed: 84 additions & 83 deletions

PWGDQ/Core/MCProng.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ MCProng::MCProng(int n, int m) : fNGenerations(n),
9292
}
9393

9494
//________________________________________________________________________________________________________________
95-
MCProng::MCProng(int n, const std::vector<int> pdgs, const std::vector<bool> checkBothCharges, const std::vector<bool> excludePDG,
96-
const std::vector<uint64_t> sourceBits, const std::vector<uint64_t> excludeSource,
97-
const std::vector<bool> useANDonSourceBitMap, bool checkGenerationsInTime,
98-
const std::vector<int> checkIfPDGInHistory, const std::vector<bool> excludePDGInHistory) : fNGenerations(n),
99-
fPDGcodes(pdgs),
100-
fCheckBothCharges(checkBothCharges),
101-
fExcludePDG(excludePDG),
102-
fSourceBits(sourceBits),
103-
fExcludeSource(excludeSource),
104-
fUseANDonSourceBitMap(useANDonSourceBitMap),
105-
fCheckGenerationsInTime(checkGenerationsInTime),
106-
fPDGInHistory(checkIfPDGInHistory),
107-
fExcludePDGInHistory(excludePDGInHistory) {}
95+
MCProng::MCProng(int n, const std::vector<int>& pdgs, const std::vector<bool>& checkBothCharges, const std::vector<bool>& excludePDG,
96+
const std::vector<uint64_t>& sourceBits, const std::vector<uint64_t>& excludeSource,
97+
const std::vector<bool>& useANDonSourceBitMap, bool checkGenerationsInTime,
98+
const std::vector<int>& checkIfPDGInHistory, const std::vector<bool>& excludePDGInHistory) : fNGenerations(n),
99+
fPDGcodes(pdgs),
100+
fCheckBothCharges(checkBothCharges),
101+
fExcludePDG(excludePDG),
102+
fSourceBits(sourceBits),
103+
fExcludeSource(excludeSource),
104+
fUseANDonSourceBitMap(useANDonSourceBitMap),
105+
fCheckGenerationsInTime(checkGenerationsInTime),
106+
fPDGInHistory(checkIfPDGInHistory),
107+
fExcludePDGInHistory(excludePDGInHistory) {}
108108

109109
//________________________________________________________________________________________________________________
110110
void MCProng::SetPDGcode(int generation, int code, bool checkBothCharges /*= false*/, bool exclude /*= false*/)

PWGDQ/Core/MCProng.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ class MCProng
8989
MCProng();
9090
explicit MCProng(int n);
9191
MCProng(int n, int m);
92-
MCProng(int n, std::vector<int> pdgs, std::vector<bool> checkBothCharges, std::vector<bool> excludePDG,
93-
std::vector<uint64_t> sourceBits, std::vector<uint64_t> excludeSource, std::vector<bool> useANDonSourceBitMap,
94-
bool checkGenerationsInTime = false, std::vector<int> checkIfPDGInHistory = {}, std::vector<bool> excludePDGInHistory = {});
92+
MCProng(int n, const std::vector<int>& pdgs, const std::vector<bool>& checkBothCharges, const std::vector<bool>& excludePDG,
93+
const std::vector<uint64_t>& sourceBits, const std::vector<uint64_t>& excludeSource, const std::vector<bool>& useANDonSourceBitMap,
94+
bool checkGenerationsInTime = false, const std::vector<int>& checkIfPDGInHistory = {}, const std::vector<bool>& excludePDGInHistory = {});
9595
MCProng(const MCProng& c) = default;
9696
virtual ~MCProng() = default;
9797

PWGDQ/Core/MCSignal.cxx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <cstdint>
2121
#include <iostream>
22+
#include <utility>
2223
#include <vector>
2324

2425
using std::cout;
@@ -52,28 +53,28 @@ MCSignal::MCSignal(int nProngs, const char* name /*= ""*/, const char* title /*=
5253
}
5354

5455
//________________________________________________________________________________________________
55-
MCSignal::MCSignal(const char* name, const char* title, std::vector<MCProng> prongs, std::vector<int8_t> commonAncestors, bool excludeCommonAncestor) : TNamed(name, title),
56-
fProngs(prongs),
57-
fNProngs(prongs.size()),
58-
fCommonAncestorIdxs(commonAncestors),
59-
fExcludeCommonAncestor(excludeCommonAncestor),
60-
fDecayChannelIsExclusive(false),
61-
fDecayChannelIsNotExclusive(false),
62-
fNAncestorDirectProngs(0),
63-
fTempAncestorLabel(-1)
56+
MCSignal::MCSignal(const char* name, const char* title, const std::vector<MCProng>& prongs, std::vector<int8_t> commonAncestors, bool excludeCommonAncestor) : TNamed(name, title),
57+
fProngs(prongs),
58+
fNProngs(prongs.size()),
59+
fCommonAncestorIdxs(std::move(commonAncestors)),
60+
fExcludeCommonAncestor(excludeCommonAncestor),
61+
fDecayChannelIsExclusive(false),
62+
fDecayChannelIsNotExclusive(false),
63+
fNAncestorDirectProngs(0),
64+
fTempAncestorLabel(-1)
6465
{
6566
}
6667

6768
//________________________________________________________________________________________________
6869
void MCSignal::SetProngs(std::vector<MCProng> prongs, std::vector<int8_t> commonAncestors)
6970
{
70-
fProngs = prongs;
71+
fProngs = std::move(prongs);
7172
fNProngs = fProngs.size();
72-
fCommonAncestorIdxs = commonAncestors;
73+
fCommonAncestorIdxs = std::move(commonAncestors);
7374
}
7475

7576
//________________________________________________________________________________________________
76-
void MCSignal::AddProng(MCProng prong, int8_t commonAncestor)
77+
void MCSignal::AddProng(const MCProng& prong, int8_t commonAncestor)
7778
{
7879
if (fProngs.size() < fNProngs) {
7980
fProngs.push_back(prong);

PWGDQ/Core/MCSignal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ class MCSignal : public TNamed
6868
public:
6969
MCSignal();
7070
MCSignal(int nProngs, const char* name = "", const char* title = ""); // NOLINT
71-
MCSignal(const char* name, const char* title, std::vector<MCProng> prongs, std::vector<int8_t> commonAncestors, bool excludeCommonAncestor = false);
71+
MCSignal(const char* name, const char* title, const std::vector<MCProng>& prongs, std::vector<int8_t> commonAncestors, bool excludeCommonAncestor = false);
7272
MCSignal(const MCSignal& c) = default;
7373
~MCSignal() override = default;
7474

7575
void SetProngs(std::vector<MCProng> prongs, std::vector<int8_t> commonAncestors);
76-
void AddProng(MCProng prong, int8_t commonAncestor = -1);
76+
void AddProng(const MCProng& prong, int8_t commonAncestor = -1);
7777
void SetDecayChannelIsExclusive(int nProngs, bool option = true)
7878
{
7979
fDecayChannelIsExclusive = option;

PWGDQ/Core/MixingHandler.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ MixingHandler::~MixingHandler()
5858
}
5959

6060
//_________________________________________________________________________
61-
void MixingHandler::AddMixingVariable(int var, std::vector<float> binLims)
61+
void MixingHandler::AddMixingVariable(int var, const std::vector<float>& binLims)
6262
{
6363
fVariables[var] = fVariableLimits.size();
6464
fVariableLimits.push_back(binLims);

PWGDQ/Core/MixingHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class MixingHandler : public TNamed
174174
virtual ~MixingHandler();
175175

176176
// setters
177-
void AddMixingVariable(int var, std::vector<float> binLims);
177+
void AddMixingVariable(int var, const std::vector<float>& binLims);
178178
void SetPoolDepth(int16_t depth) { fPoolDepth = depth; }
179179

180180
// getters

PWGDQ/Macros/dqFlowAccWeights.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
using namespace o2;
3333
using namespace std;
3434

35-
void dqFlowAccWeights(int64_t tmin = 1546300800000, int64_t tmax = 1577833200000, std::string Period = "LHC23zzh_pass2", std::string SubDir = "d-q-event-qvector", std::string FileName = "AnalysisResults.root")
35+
void dqFlowAccWeights(int64_t tmin = 1546300800000, int64_t tmax = 1577833200000, const std::string& Period = "LHC23zzh_pass2", const std::string& SubDir = "d-q-event-qvector", const std::string& FileName = "AnalysisResults.root")
3636
{
3737
if (tmax < tmin) {
3838
LOG(fatal) << "Wrong validity syntax!";

PWGDQ/TableProducer/tableMaker.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ struct TableMaker {
12461246
} // end if constexpr (TMuonFillMap)
12471247
} // end fullSkimming()
12481248

1249-
void DefineHistograms(TString histClasses)
1249+
void DefineHistograms(const TString& histClasses)
12501250
{
12511251
std::unique_ptr<TObjArray> objArray(histClasses.Tokenize(";"));
12521252
for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) {

PWGDQ/TableProducer/tableMakerMC.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ struct TableMakerMC {
15341534
fEventLabels.clear();
15351535
}
15361536

1537-
void DefineHistograms(TString histClasses)
1537+
void DefineHistograms(const TString& histClasses)
15381538
{
15391539
std::unique_ptr<TObjArray> objArray(histClasses.Tokenize(";"));
15401540
for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) {

PWGDQ/TableProducer/tableMakerMuonMchTrkEfficiency.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct tableMakerMuonMchTrkEfficiency {
246246

247247
/// extrapolate tracks to a given r value (spherical coordinates)
248248
/// to mimic the (x,y) position in a given chamber
249-
void extrapolate(TLorentzVector vec, int ich, double& x, double& y)
249+
void extrapolate(const TLorentzVector& vec, int ich, double& x, double& y)
250250
{ // i = 0..9
251251
double zposCh[10] = {5, 5, 7, 7, 10, 10, 12.5, 12.5, 14.5, 14.5};
252252
double theta = vec.Theta();
@@ -396,7 +396,7 @@ struct tableMakerMuonMchTrkEfficiency {
396396

397397
/// Event selection
398398
template <uint32_t TEventFillMap, typename TEvent>
399-
void runEventSelection(TEvent event)
399+
void runEventSelection(const TEvent& event)
400400
{
401401
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
402402
VarManager::FillEvent<TEventFillMap>(event); // extract event information and place it in the fValues array

0 commit comments

Comments
 (0)