Skip to content

Commit f6fd7c3

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

19 files changed

Lines changed: 85 additions & 83 deletions

PWGEM/Dilepton/Core/DielectronCut.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void DielectronCut::SetPairOpAng(float minOpAng, float maxOpAng)
6363
}
6464
void DielectronCut::SetMaxMeePhiVDep(std::function<float(float)> phivDepCut, float min_phiv, float max_phiv)
6565
{
66-
mMaxMeePhiVDep = phivDepCut;
66+
mMaxMeePhiVDep = std::move(phivDepCut);
6767
mMinPhivPair = min_phiv;
6868
mMaxPhivPair = max_phiv;
6969
LOG(info) << "Dielectron Cut, set max mee phiv dep: " << mMaxMeePhiVDep(2.5);
@@ -194,7 +194,7 @@ void DielectronCut::SetTrackMaxDcaZ(float maxDcaZ)
194194

195195
void DielectronCut::SetTrackMaxDcaXYPtDep(std::function<float(float)> ptDepCut)
196196
{
197-
mMaxDcaXYPtDep = ptDepCut;
197+
mMaxDcaXYPtDep = std::move(ptDepCut);
198198
LOG(info) << "Dielectron Cut, set max DCA xy pt dep: " << mMaxDcaXYPtDep(1.0);
199199
}
200200
void DielectronCut::ApplyPhiV(bool flag)

PWGEM/Dilepton/Core/DielectronCut.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class DielectronCut : public TNamed
537537
// mPIDMlResponse = mlResponse;
538538
// }
539539

540-
void SetMLThresholds(const std::vector<float> bins, const std::vector<float> cuts)
540+
void SetMLThresholds(const std::vector<float>& bins, const std::vector<float>& cuts)
541541
{
542542
if (bins.size() != cuts.size() + 1) {
543543
LOG(fatal) << "cuts.size() + 1 mutst be exactly the same as bins.size(). Check your bins and thresholds.";

PWGEM/Dilepton/Core/Dilepton.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ struct Dilepton {
881881
}
882882

883883
template <int ev_id, typename TCollision, typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks>
884-
bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&, const std::vector<float> weightvector)
884+
bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&, const std::vector<float>& weightvector)
885885
{
886886
if constexpr (ev_id == 0) {
887887
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {

PWGEM/Dilepton/Core/DileptonSV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ struct DileptonSV {
11071107
}
11081108

11091109
template <int ev_id, typename TCollision, typename TTrack1, typename TTrack2, typename TCut, typename TAllTracks>
1110-
bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&, const std::vector<float> weightvector)
1110+
bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TAllTracks const&, const std::vector<float>& weightvector)
11111111
{
11121112
dileptonSV candidate;
11131113
if constexpr (ev_id == 0) {

PWGEM/Dilepton/Core/DimuonCut.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <Rtypes.h>
2121

2222
#include <functional>
23+
#include <utility>
2324
#include <vector>
2425

2526
ClassImp(DimuonCut);
@@ -98,7 +99,7 @@ void DimuonCut::SetMatchingChi2MCHMFT(float min, float max)
9899
}
99100
void DimuonCut::SetMaxMatchingChi2MCHMFTPtDep(std::function<float(float)> PtDepCut)
100101
{
101-
mMaxMatchingChi2MCHMFTPtDep = PtDepCut;
102+
mMaxMatchingChi2MCHMFTPtDep = std::move(PtDepCut);
102103
LOG(info) << "Dimuon Cut, set matching chi2 MFT-MCH range: " << mMaxMatchingChi2MCHMFTPtDep(0.5);
103104
}
104105
void DimuonCut::SetMaxDiffMatchingChi2MCHMFT(float diff)
@@ -143,13 +144,13 @@ void DimuonCut::EnableTTCA(const bool flag)
143144
}
144145
void DimuonCut::SetMaxPDCARabsDep(std::function<float(float)> RabsDepCut)
145146
{
146-
mMaxPDCARabsDep = RabsDepCut;
147+
mMaxPDCARabsDep = std::move(RabsDepCut);
147148
LOG(info) << "Dimuon Cut, set max pDCA as a function of Rabs: " << mMaxPDCARabsDep(10.0);
148149
}
149150
void DimuonCut::SetMFTHitMap(bool flag, std::vector<int> hitMap)
150151
{
151152
mApplyMFTHitMap = flag;
152-
mRequiredMFTDisks = hitMap;
153+
mRequiredMFTDisks = std::move(hitMap);
153154
if (mApplyMFTHitMap) {
154155
for (const auto& iDisk : mRequiredMFTDisks) {
155156
LOG(info) << "Dimuon Cut, require MFT hit on Disk: " << iDisk;

PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct skimmerPrimaryMuon {
269269
}
270270

271271
template <bool isMC, bool withMFTCov, typename TFwdTracks, typename TMFTTracks, bool fillTable, typename TCollision, typename TFwdTrack, typename TMFTTracksCov>
272-
bool fillFwdTrackTable(TCollision const& collision, TFwdTrack fwdtrack, TMFTTracksCov const& mftCovs, const bool isAmbiguous)
272+
bool fillFwdTrackTable(TCollision const& collision, const TFwdTrack& fwdtrack, TMFTTracksCov const& mftCovs, const bool isAmbiguous)
273273
{
274274
if (fwdtrack.chi2MatchMCHMID() < 0.f) { // this should never happen. only for protection.
275275
return false;

PWGEM/Dilepton/TableProducer/skimmerPrimaryMuonQC.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ struct skimmerPrimaryMuonQC {
344344
}
345345

346346
template <bool isMC, typename TFwdTracks, typename TMFTTracks, typename TCollision, typename TFwdTrack>
347-
bool fillMuonInfo(TCollision const& collision, TFwdTrack fwdtrack)
347+
bool fillMuonInfo(TCollision const& collision, const TFwdTrack& fwdtrack)
348348
{
349349
if (fwdtrack.trackType() != static_cast<uint8_t>(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && fwdtrack.trackType() != static_cast<uint8_t>(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) {
350350
return false;

PWGEM/Dilepton/Tasks/MCtemplates.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::ReducedTrack |
109109
constexpr static uint32_t gkTrackFillMapWithCov = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelCov | VarManager::ObjTypes::ReducedTrackBarrelPID;
110110
constexpr static uint32_t gkParticleMCFillMap = VarManager::ObjTypes::ParticleMC;
111111

112-
void DefineHistograms(HistogramManager* histMan, TString histClasses, Configurable<std::string> configVar); // defines histograms for all tasks
112+
void DefineHistograms(HistogramManager* histMan, const TString& histClasses, const Configurable<std::string>& configVar); // defines histograms for all tasks
113113

114114
struct AnalysisEventSelection {
115115
Produces<aod::EventCuts> eventSel;
@@ -698,7 +698,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
698698
adaptAnalysisTask<AnalysisSameEventPairing>(cfgc)};
699699
}
700700

701-
void DefineHistograms(HistogramManager* histMan, TString histClasses, Configurable<std::string> configVar)
701+
void DefineHistograms(HistogramManager* histMan, const TString& histClasses, const Configurable<std::string>& configVar)
702702
{
703703
//
704704
// Define here the histograms for all the classes required in analysis.

PWGEM/Dilepton/Tasks/emEfficiencyEE.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ constexpr static uint32_t gkMCEventFillMap = VarManager::ObjTypes::ReducedEventM
118118
constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelCov | VarManager::ObjTypes::ReducedTrackBarrelPID;
119119
constexpr static uint32_t gkParticleMCFillMap = VarManager::ObjTypes::ParticleMC;
120120

121-
void DefineHistograms(HistogramManager* histMan, TString histClasses, Configurable<std::string> configVar); // defines histograms for all tasks
121+
void DefineHistograms(HistogramManager* histMan, const TString& histClasses, const Configurable<std::string>& configVar); // defines histograms for all tasks
122122
void SetBinsLinear(std::vector<double>& fBins, const double min, const double max, const unsigned int steps);
123123

124124
struct AnalysisEventSelection {
@@ -324,7 +324,7 @@ struct AnalysisEventQa {
324324
{
325325

326326
Int_t midrap = 0;
327-
for (auto mctrack : groupedMCTracks) {
327+
for (const auto& mctrack : groupedMCTracks) {
328328
if (TMath::Abs(mctrack.eta()) < 0.5 && mctrack.isPhysicalPrimary() && (TMath::Abs(mctrack.pdgCode()) == 211 || mctrack.pdgCode() == 111)) {
329329
midrap++;
330330
}
@@ -779,7 +779,7 @@ struct AnalysisTrackSelection {
779779
}
780780

781781
template <uint32_t TEventFillMap, uint32_t TTrackFillMap, uint32_t TTrackMCFillMap, typename TEvents, typename TEventsMC, typename TTracks, typename TTracksMC, typename TAmbigTracks>
782-
void runDataFillMore(TEvents const& events, TEventsMC eventsMC, TTracks const& tracks, TTracksMC const& tracksMC, TAmbigTracks const& ambiTracksMid)
782+
void runDataFillMore(TEvents const& events, const TEventsMC& eventsMC, TTracks const& tracks, TTracksMC const& tracksMC, TAmbigTracks const& ambiTracksMid)
783783
{
784784

785785
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
@@ -2012,7 +2012,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
20122012
adaptAnalysisTask<AnalysisSameEventPairing>(cfgc)};
20132013
}
20142014

2015-
void DefineHistograms(HistogramManager* histMan, TString histClasses, Configurable<std::string> configVar)
2015+
void DefineHistograms(HistogramManager* histMan, const TString& histClasses, const Configurable<std::string>& configVar)
20162016
{
20172017
//
20182018
// Define here the histograms for all the classes required in analysis.

PWGEM/Dilepton/Tasks/lmeeLFCocktail.cxx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct lmeelfcocktail {
127127
return true;
128128
}
129129

130-
bool isAcceptedSingle(ROOT::Math::PtEtaPhiMVector p1)
130+
bool isAcceptedSingle(const ROOT::Math::PtEtaPhiMVector& p1)
131131
{
132132
if (p1.Pt() < fConfigMinPt)
133133
return false;
@@ -138,7 +138,7 @@ struct lmeelfcocktail {
138138
return true;
139139
}
140140

141-
bool isAcceptedPair(ROOT::Math::PtEtaPhiMVector p1, ROOT::Math::PtEtaPhiMVector p2)
141+
bool isAcceptedPair(const ROOT::Math::PtEtaPhiMVector& p1, const ROOT::Math::PtEtaPhiMVector& p2)
142142
{
143143
if (!isAcceptedSingle(p1)) {
144144
return false;
@@ -167,21 +167,21 @@ struct lmeelfcocktail {
167167
}
168168

169169
template <typename T>
170-
bool isAcceptedPair(T& p1, T& p2)
170+
bool isAcceptedPair(const T& p1, const T& p2)
171171
{
172172
ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron);
173173
ROOT::Math::PtEtaPhiMVector v2(p2.ptSmeared(), p2.etaSmeared(), p2.phiSmeared(), o2::constants::physics::MassElectron);
174174
return isAcceptedPair(v1, v2);
175175
}
176176

177177
template <typename T>
178-
bool isAcceptedSingle(T& p1)
178+
bool isAcceptedSingle(const T& p1)
179179
{
180180
ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron);
181181
return isAcceptedSingle(v1);
182182
}
183183

184-
void addHistogram1D_stage(TString histname, AxisSpec axis, int& i, TString s)
184+
void addHistogram1D_stage(const TString& histname, const AxisSpec& axis, int& i, const TString& s)
185185
{
186186
i++;
187187
TString name = s + histname;
@@ -201,14 +201,14 @@ struct lmeelfcocktail {
201201
}
202202
}
203203

204-
void addHistogram1D(TString histname, AxisSpec axis, int& i)
204+
void addHistogram1D(const TString& histname, const AxisSpec& axis, int& i)
205205
{
206-
for (auto s : stage) {
206+
for (const auto& s : stage) {
207207
addHistogram1D_stage(histname, axis, i, s);
208208
}
209209
}
210210

211-
void addHistogram1D_mother(TString histname, AxisSpec axis, int& i) // mother histograms only for gen. level, no decay channels
211+
void addHistogram1D_mother(const TString& histname, const AxisSpec& axis, int& i) // mother histograms only for gen. level, no decay channels
212212
{
213213
i++;
214214
TString name = stage[0] + histname;
@@ -222,7 +222,7 @@ struct lmeelfcocktail {
222222
}
223223
}
224224

225-
void addHistogram2D_stage(TString histname, AxisSpec axis1, AxisSpec axis2, int& i, TString s)
225+
void addHistogram2D_stage(const TString& histname, const AxisSpec& axis1, const AxisSpec& axis2, int& i, const TString& s)
226226
{
227227
i++;
228228
TString name = s + histname;
@@ -242,15 +242,15 @@ struct lmeelfcocktail {
242242
}
243243
}
244244

245-
void addHistogram2D(TString histname, AxisSpec axis1, AxisSpec axis2, int& i)
245+
void addHistogram2D(const TString& histname, const AxisSpec& axis1, const AxisSpec& axis2, int& i)
246246
{
247-
for (auto s : stage) {
247+
for (const auto& s : stage) {
248248
addHistogram2D_stage(histname, axis1, axis2, i, s);
249249
}
250250
}
251251

252252
template <typename TAxes>
253-
void addHistogramND_stage(TString histname, TAxes const& axes, int& i, TString s)
253+
void addHistogramND_stage(const TString& histname, TAxes const& axes, int& i, const TString& s)
254254
{
255255
i++;
256256
TString name = s + histname;
@@ -271,34 +271,34 @@ struct lmeelfcocktail {
271271
}
272272

273273
template <typename TAxes>
274-
void addHistogramND(TString histname, TAxes const& axes, int& i)
274+
void addHistogramND(const TString& histname, TAxes const& axes, int& i)
275275
{
276-
for (auto s : stage) {
276+
for (const auto& s : stage) {
277277
addHistogramND_stage(histname, axes, i, s);
278278
}
279279
}
280280

281-
void fillHistogram1D(TString histname, int s, int pdg, int other_daughter_pdg, float value, float weight)
281+
void fillHistogram1D(const TString& histname, int s, int pdg, int other_daughter_pdg, float value, float weight)
282282
{
283283
histograms1D[histogramId[stage[s] + histname]]->Fill(value, weight);
284284
histograms1D[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(value, weight);
285285
histograms1D[histogramId[stage[s] + mesons[pdg].name + decays[other_daughter_pdg] + histname]]->Fill(value, weight);
286286
}
287287

288-
void fillHistogram1D_mother(TString histname, int pdg, float value, float weight)
288+
void fillHistogram1D_mother(const TString& histname, int pdg, float value, float weight)
289289
{
290290
histograms1D[histogramId[stage[0] + histname]]->Fill(value, weight);
291291
histograms1D[histogramId[stage[0] + mesons[pdg].name + histname]]->Fill(value, weight);
292292
}
293293

294-
void fillHistogram2D(TString histname, int s, int pdg, int other_daughter_pdg, float value1, float value2, float weight)
294+
void fillHistogram2D(const TString& histname, int s, int pdg, int other_daughter_pdg, float value1, float value2, float weight)
295295
{
296296
histograms2D[histogramId[stage[s] + histname]]->Fill(value1, value2, weight);
297297
histograms2D[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(value1, value2, weight);
298298
histograms2D[histogramId[stage[s] + mesons[pdg].name + decays[other_daughter_pdg] + histname]]->Fill(value1, value2, weight);
299299
}
300300

301-
void fillHistogramND(TString histname, int s, int pdg, int other_daughter_pdg, double* values, double weight)
301+
void fillHistogramND(const TString& histname, int s, int pdg, int other_daughter_pdg, double* values, double weight)
302302
{
303303
histogramsND[histogramId[stage[s] + histname]]->Fill(values, weight);
304304
histogramsND[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(values, weight);

0 commit comments

Comments
 (0)