Skip to content

Commit 2044255

Browse files
authored
[Common] Use const& and std::move to avoid copies (#17703)
1 parent b6fc150 commit 2044255

29 files changed

Lines changed: 67 additions & 65 deletions

Common/CCDB/macros/ctpRateF.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
struct ctpRateFetcher {
3131
ctpRateFetcher() = default;
32-
double fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName);
32+
double fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, const std::string& sourceName);
3333
void getCTPconfig(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber);
3434
void getCTPscalers(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber);
3535
void getLHCIFdata(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber);
3636
double fetchCTPratesInputs(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, int input);
37-
double fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string className, int inputType = 1);
37+
double fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, const std::string& className, int inputType = 1);
3838
double pileUpCorrection(double rate);
3939

4040
int mRunNumber = -1;
@@ -104,7 +104,7 @@ double ctpRateFetcher::fetchCTPratesInputs(o2::ccdb::BasicCCDBManager* ccdb, uin
104104
return -1.;
105105
}
106106
}
107-
double ctpRateFetcher::fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string className, int inputType)
107+
double ctpRateFetcher::fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, const std::string& className, int inputType)
108108
{
109109
getCTPscalers(ccdb, timeStamp, runNumber);
110110
getCTPconfig(ccdb, timeStamp, runNumber);
@@ -125,7 +125,7 @@ double ctpRateFetcher::fetchCTPratesClasses(o2::ccdb::BasicCCDBManager* ccdb, ui
125125
getLHCIFdata(ccdb, timeStamp, runNumber);
126126
return pileUpCorrection(rate.second);
127127
}
128-
double ctpRateFetcher::fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, std::string sourceName)
128+
double ctpRateFetcher::fetch(o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, int runNumber, const std::string& sourceName)
129129
{
130130
if (sourceName.find("ZNC") != std::string::npos) {
131131
if (runNumber < 544448) {

Common/Core/EventPlaneHelper.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ void EventPlaneHelper::DoRescale(float& qx, float& qy, float ap, float am)
164164
qy /= am;
165165
}
166166

167-
void EventPlaneHelper::GetCorrRecentering(const std::shared_ptr<TH2> histQ, float& meanX, float& meanY)
167+
void EventPlaneHelper::GetCorrRecentering(const std::shared_ptr<TH2>& histQ, float& meanX, float& meanY)
168168
{
169169
meanX = histQ->GetMean(1);
170170
meanY = histQ->GetMean(2);
171171
}
172172

173-
void EventPlaneHelper::GetCorrWidth(const std::shared_ptr<TH2> histQ, float& stdX, float& stdY)
173+
void EventPlaneHelper::GetCorrWidth(const std::shared_ptr<TH2>& histQ, float& stdX, float& stdY)
174174
{
175175
stdX = histQ->GetStdDev(1);
176176
stdY = histQ->GetStdDev(2);
177177
}
178178

179-
void EventPlaneHelper::GetCorrTwistRecale(const std::shared_ptr<TH2> histQ,
179+
void EventPlaneHelper::GetCorrTwistRecale(const std::shared_ptr<TH2>& histQ,
180180
float& aPlus, float& aMinus,
181181
float& lambdaPlus, float& lambdaMinus)
182182
{

Common/Core/EventPlaneHelper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ class EventPlaneHelper
8181
void DoRescale(float& qx, float& qy, float ap, float am);
8282

8383
// Method to get the recentering correction on the Qx-Qy distribution.
84-
void GetCorrRecentering(const std::shared_ptr<TH2> histQ, float& meanX, float& meanY);
84+
void GetCorrRecentering(const std::shared_ptr<TH2>& histQ, float& meanX, float& meanY);
8585

8686
// Method to get the std. deviation on the Qx-Qy distribution.
87-
void GetCorrWidth(const std::shared_ptr<TH2> histQ, float& stdX, float& stdY);
87+
void GetCorrWidth(const std::shared_ptr<TH2>& histQ, float& stdX, float& stdY);
8888

8989
// Method to get the twist and rescale correction on the Qx-Qy distribution.
90-
void GetCorrTwistRecale(const std::shared_ptr<TH2> histQ,
90+
void GetCorrTwistRecale(const std::shared_ptr<TH2>& histQ,
9191
float& aPlus, float& aMinus,
9292
float& lambdaPlus, float& lambdaMinus);
9393

Common/Core/PID/PIDTOFParamService.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ o2::common::core::MetadataHelper o2::pid::tof::TOFResponseImpl::metadataInfo;
4646
bool o2::pid::tof::TOFResponseImpl::mIsInit = false;
4747
int o2::pid::tof::TOFResponseImpl::mLastRunNumber = -1;
4848

49-
void o2::pid::tof::TOFResponseImpl::inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string task)
49+
void o2::pid::tof::TOFResponseImpl::inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string& task)
5050
{
5151
if (mIsInit) {
5252
LOG(fatal) << "TOFResponseImpl already initialized, cannot re-initialize";
@@ -70,7 +70,7 @@ void o2::pid::tof::TOFResponseImpl::inheritFromBaseTask(o2::framework::InitConte
7070

7171
void o2::pid::tof::TOFResponseImpl::initSetup(o2::ccdb::BasicCCDBManager* ccdb,
7272
o2::framework::InitContext& initContext,
73-
const std::string task)
73+
const std::string& task)
7474
{
7575
if (mIsInit) {
7676
LOG(fatal) << "TOFResponseImpl already initialized, cannot re-initialize";

Common/Core/PID/PIDTOFParamService.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct TOFResponseImpl {
4949
/// \note This function should be called in the init function of each task that uses the TOF response
5050
/// \note The parameters are loaded from the CCDB and stored in the static variable `parameters`
5151
/// \note The metadata information is also initialized in this function
52-
void initSetup(o2::ccdb::BasicCCDBManager* ccdb, o2::framework::InitContext& initContext, const std::string task = "tof-signal");
52+
void initSetup(o2::ccdb::BasicCCDBManager* ccdb, o2::framework::InitContext& initContext, const std::string& task = "tof-signal");
5353

5454
/// Initialize the TOF response parameters in the init function of each task
5555
/// \param ccdb Service pointer to the CCDB manager
@@ -163,7 +163,7 @@ struct TOFResponseImpl {
163163
o2::common::core::CollisionSystemType::collType cfgCollisionType() const { return mCollisionSystem; }
164164

165165
private:
166-
void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string task = "tof-signal");
166+
void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string& task = "tof-signal");
167167

168168
static bool mIsInit; //! Flag to check if the parameters are initialized
169169
static int mLastRunNumber; //! Last run number for which the calibration was loaded

Common/Core/TrackSelection.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ void TrackSelection::SetMaxDcaZ(float maxDcaZ)
119119

120120
void TrackSelection::SetMaxDcaXYPtDep(std::function<float(float)> ptDepCut)
121121
{
122-
mMaxDcaXYPtDep = ptDepCut;
122+
mMaxDcaXYPtDep = std::move(ptDepCut);
123123
LOG(info) << "Track selection, set max DCA xy pt dep: " << mMaxDcaXYPtDep(1.0);
124124
}
125125

126-
void TrackSelection::SetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set<uint8_t> requiredLayers)
126+
void TrackSelection::SetRequireHitsInITSLayers(int8_t minNRequiredHits, const std::set<uint8_t>& requiredLayers)
127127
{
128128
// layer 0 corresponds to the the innermost ITS layer
129129
uint8_t mask = 0;
@@ -133,7 +133,7 @@ void TrackSelection::SetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set
133133
mRequiredITSHits.push_back(std::make_pair(minNRequiredHits, mask));
134134
LOG(info) << "Track selection, set require hits in ITS layers: " << static_cast<int>(minNRequiredHits);
135135
}
136-
void TrackSelection::SetRequireNoHitsInITSLayers(std::set<uint8_t> excludedLayers)
136+
void TrackSelection::SetRequireNoHitsInITSLayers(const std::set<uint8_t>& excludedLayers)
137137
{
138138
uint8_t mask = 0;
139139
for (const auto& layer : excludedLayers) {

Common/Core/TrackSelection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ class TrackSelection
249249
void SetMaxDcaXY(float maxDcaXY);
250250
void SetMaxDcaZ(float maxDcaZ);
251251
void SetMaxDcaXYPtDep(std::function<float(float)> ptDepCut);
252-
void SetRequireHitsInITSLayers(int8_t minNRequiredHits, std::set<uint8_t> requiredLayers);
253-
void SetRequireNoHitsInITSLayers(std::set<uint8_t> excludedLayers);
252+
void SetRequireHitsInITSLayers(int8_t minNRequiredHits, const std::set<uint8_t>& requiredLayers);
253+
void SetRequireNoHitsInITSLayers(const std::set<uint8_t>& excludedLayers);
254254
/// @brief Reset ITS requirements
255255
void ResetITSRequirements() { mRequiredITSHits.clear(); }
256256
void SetMaxTPCFractionSharedCls(float maxTPCFractionSharedCls);

Common/Core/Zorro.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int findBin(TH1* hist, const std::string& label)
5252
}
5353
} // namespace
5454

55-
void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName)
55+
void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, const std::string& folderName)
5656
{
5757
int runId{-1};
5858
for (size_t i{0}; i < mRunNumberHistos.size(); ++i) {
@@ -176,7 +176,7 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto)
176176
mRunNumberHistos.push_back(runNumber);
177177
}
178178

179-
std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange)
179+
std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, const std::string& tois, int bcRange)
180180
{
181181
if (mRunNumber == runNumber) {
182182
return mTOIidx;

Common/Core/Zorro.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class Zorro
4646
{
4747
public:
4848
Zorro() = default;
49-
std::vector<int> initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcTolerance = 500);
49+
std::vector<int> initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, const std::string& tois, int bcTolerance = 500);
5050
std::bitset<128> fetch(uint64_t bcGlobalId, uint64_t tolerance = 100);
5151
bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100, TH2* toiHisto = nullptr);
5252
bool isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance = 100);
5353

54-
void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName = "Zorro");
54+
void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, const std::string& folderName = "Zorro");
5555
void populateExternalHists(int runNumber, TH2* zorroHisto = nullptr, TH2* toiHisto = nullptr);
5656

5757
TH1D* getScalers() const { return mScalers; }

Common/Core/macros/testMetadataHelper.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ std::map<std::string, bool> buildMapForCommitHash(const std::string& hash)
128128
return results;
129129
}
130130

131-
void populateCCDBWithCommitAvailability(std::map<std::string, bool> hasHashMap,
132-
const std::string commitHash,
133-
const std::string ccdbUrl = "http://ccdb-test.cern.ch:8080/")
131+
void populateCCDBWithCommitAvailability(const std::map<std::string, bool>& hasHashMap,
132+
const std::string& commitHash,
133+
const std::string& ccdbUrl = "http://ccdb-test.cern.ch:8080/")
134134
{
135135
// First, init the CCDB manager to test if the ccdb is already populated
136136
o2::ccdb::CcdbApi api;
@@ -157,7 +157,7 @@ void populateCCDBWithCommitAvailability(std::map<std::string, bool> hasHashMap,
157157
}
158158
}
159159

160-
void testMetadataHelper(std::string aod = "/tmp/AO2D.root")
160+
void testMetadataHelper(const std::string& aod = "/tmp/AO2D.root")
161161
{
162162
createO2VersionFile();
163163
const std::string commitHash = "63bc2e3893851ef0f849bb4c98c65eae1ba21e47";

0 commit comments

Comments
 (0)