Skip to content

Commit 97ed514

Browse files
authored
Merge pull request cms-sw#34140 from smuzaffar/12_0-codechecks-RECONSTRUCTION
[RECONSTRUCTION] code-checks/format; clean code to remove global functions
2 parents 356e27e + 3eb8cb5 commit 97ed514

File tree

32 files changed

+848
-1346
lines changed

32 files changed

+848
-1346
lines changed

CommonTools/RecoAlgos/plugins/PrimaryVertexSorter.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,27 +301,28 @@ void PrimaryVertexSorter<ParticlesCollection>::produce(edm::Event& iEvent, const
301301
}
302302

303303
template <>
304-
void PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::doConsumesForTiming(
304+
inline void PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::doConsumesForTiming(
305305
const edm::ParameterSet& iConfig) {
306306
tokenTrackTimeTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeTag"));
307307
tokenTrackTimeResoTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeResoTag"));
308308
}
309309

310310
template <>
311-
void PrimaryVertexSorter<std::vector<reco::PFCandidate>>::doConsumesForTiming(const edm::ParameterSet& iConfig) {}
311+
inline void PrimaryVertexSorter<std::vector<reco::PFCandidate>>::doConsumesForTiming(const edm::ParameterSet& iConfig) {
312+
}
312313

313314
template <>
314-
bool PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::needsProductsForTiming() {
315+
inline bool PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::needsProductsForTiming() {
315316
return true;
316317
}
317318

318319
template <>
319-
bool PrimaryVertexSorter<std::vector<reco::PFCandidate>>::needsProductsForTiming() {
320+
inline bool PrimaryVertexSorter<std::vector<reco::PFCandidate>>::needsProductsForTiming() {
320321
return false;
321322
}
322323

323324
template <>
324-
std::pair<int, PrimaryVertexAssignment::Quality>
325+
inline std::pair<int, PrimaryVertexAssignment::Quality>
325326
PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::runAlgo(const reco::VertexCollection& vertices,
326327
const reco::RecoChargedRefCandidate& pf,
327328
const edm::ValueMap<float>* trackTimeTag,
@@ -332,7 +333,7 @@ PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::runAlgo(const r
332333
}
333334

334335
template <>
335-
std::pair<int, PrimaryVertexAssignment::Quality> PrimaryVertexSorter<std::vector<reco::PFCandidate>>::runAlgo(
336+
inline std::pair<int, PrimaryVertexAssignment::Quality> PrimaryVertexSorter<std::vector<reco::PFCandidate>>::runAlgo(
336337
const reco::VertexCollection& vertices,
337338
const reco::PFCandidate& pf,
338339
const edm::ValueMap<float>* trackTimeTag,

DataFormats/DTRecHit/interface/DTDriftTimeParameters.icc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ const double THIS_CLASS::fun_sigma_t[N_alpha][N_By][N_Bz][N_Sigma_t] = {
404404

405405
/*** Auxiliary functions ***/
406406

407-
unsigned short THIS_CLASS::MB_DT_Check_boundaries(double distime, double alpha, double by, double bz, short ifl) const {
407+
inline unsigned short THIS_CLASS::MB_DT_Check_boundaries(
408+
double distime, double alpha, double by, double bz, short ifl) const {
408409
unsigned short status = 1;
409410
std::string name = "MB_DT_drift_time";
410411

@@ -458,7 +459,7 @@ unsigned short THIS_CLASS::MB_DT_Check_boundaries(double distime, double alpha,
458459
return (status);
459460
}
460461

461-
void THIS_CLASS::MB_DT_Get_grid_values(
462+
inline void THIS_CLASS::MB_DT_Get_grid_values(
462463
double Var, unsigned short *pi, unsigned short *pj, short Initial, unsigned short N, const double *Values) const {
463464
unsigned short i, iValue, jValue;
464465

@@ -482,15 +483,15 @@ void THIS_CLASS::MB_DT_Get_grid_values(
482483
}
483484
}
484485

485-
void THIS_CLASS::MB_DT_Get_grid_points(double alpha,
486-
double by,
487-
double bz,
488-
unsigned short *p_alpha,
489-
unsigned short *p_By,
490-
unsigned short *p_Bz,
491-
unsigned short *q_alpha,
492-
unsigned short *q_By,
493-
unsigned short *q_Bz) const {
486+
inline void THIS_CLASS::MB_DT_Get_grid_points(double alpha,
487+
double by,
488+
double bz,
489+
unsigned short *p_alpha,
490+
unsigned short *p_By,
491+
unsigned short *p_Bz,
492+
unsigned short *q_alpha,
493+
unsigned short *q_By,
494+
unsigned short *q_Bz) const {
494495
MB_DT_Get_grid_values(fabs(alpha), p_alpha, q_alpha, 4, N_alpha, alpha_value);
495496
MB_DT_Get_grid_values(by, p_By, q_By, 0, N_By, By_value);
496497
MB_DT_Get_grid_values(bz, p_Bz, q_Bz, 0, N_Bz, Bz_value);
@@ -503,7 +504,7 @@ void THIS_CLASS::MB_DT_Get_grid_points(double alpha,
503504

504505
/*** Multidimensional linear interpolation ***/
505506

506-
double THIS_CLASS::MB_DT_MLInterpolation(double *al, double *by, double *bz, double *f) const {
507+
inline double THIS_CLASS::MB_DT_MLInterpolation(double *al, double *by, double *bz, double *f) const {
507508
double q1, q2, q3, p1, p2, p3;
508509
double fx11, fx21, fxy1, fx12, fx22, fxy2, fxyz;
509510

@@ -528,7 +529,7 @@ double THIS_CLASS::MB_DT_MLInterpolation(double *al, double *by, double *bz, dou
528529
return (fxyz);
529530
}
530531

531-
double THIS_CLASS::MB_DT_sigma_t_m(double dist, double *par) const {
532+
inline double THIS_CLASS::MB_DT_sigma_t_m(double dist, double *par) const {
532533
double x = fabs(dist); // the parametrisations are symmetric under 'distance'
533534

534535
if (x > 20.5)
@@ -537,7 +538,7 @@ double THIS_CLASS::MB_DT_sigma_t_m(double dist, double *par) const {
537538
return (par[6] * x);
538539
}
539540

540-
double THIS_CLASS::MB_DT_sigma_t_p(double dist, double *par) const {
541+
inline double THIS_CLASS::MB_DT_sigma_t_p(double dist, double *par) const {
541542
double x2, x = fabs(dist); // the parametrisations are symmetric under 'distance'
542543

543544
if (x > 20.5)

EventFilter/HcalRawToDigi/plugins/PackerHelp.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ class UHTRpacker {
617617

618618
// converts HE QIE digies to HB data format
619619

620-
QIE11DataFrame convertHB(QIE11DataFrame qiehe,
621-
std::vector<int> const& tdc1,
622-
std::vector<int> const& tdc2,
623-
const int tdcmax) {
620+
inline QIE11DataFrame convertHB(QIE11DataFrame qiehe,
621+
std::vector<int> const& tdc1,
622+
std::vector<int> const& tdc2,
623+
const int tdcmax) {
624624
QIE11DataFrame qiehb = qiehe;
625625
HcalDetId did = HcalDetId(qiehb.detid());
626626
int adc, tdc;

MagneticField/GeomBuilder/src/buildBox.icc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* \author N. Amapane - INFN Torino
55
*/
66

7-
void volumeHandle::buildBox(double halfX, double halfY, double halfZ) {
7+
inline void volumeHandle::buildBox(double halfX, double halfY, double halfZ) {
88
LogTrace("MagGeoBuilder") << "Building box surfaces...: ";
99

1010
// Global vectors of the normals to X, Y, Z axes

MagneticField/GeomBuilder/src/buildCons.icc

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

77
#include "DataFormats/GeometrySurface/interface/SimpleConeBounds.h"
88

9-
void volumeHandle::buildCons(double zhalf,
10-
double rInMinusZ,
11-
double rOutMinusZ,
12-
double rInPlusZ,
13-
double rOutPlusZ,
14-
double startPhi,
15-
double deltaPhi) {
9+
inline void volumeHandle::buildCons(double zhalf,
10+
double rInMinusZ,
11+
double rOutMinusZ,
12+
double rInPlusZ,
13+
double rOutPlusZ,
14+
double startPhi,
15+
double deltaPhi) {
1616
LogTrace("MagGeoBuilder") << "Building cons surfaces...: ";
1717
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rInMinusZ " << rInMinusZ << newln << "rOutMinusZ "
1818
<< rOutMinusZ << newln << "rInPlusZ " << rInPlusZ << newln << "rOutPlusZ " << rOutPlusZ

MagneticField/GeomBuilder/src/buildPseudoTrap.icc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* \author N. Amapane - INFN Torino
1313
*/
1414

15-
void volumeHandle::buildPseudoTrap(
15+
inline void volumeHandle::buildPseudoTrap(
1616
double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ) {
1717
LogTrace("MagGeoBuilder") << "Building PseudoTrap surfaces...: ";
1818
LogTrace("MagGeoBuilder") << "halfZ " << halfZ << newln << "x1 " << x1 << newln << "x2 " << x2

MagneticField/GeomBuilder/src/buildTrap.icc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
* \author N. Amapane - INFN Torino
55
*/
66

7-
void volumeHandle::buildTrap(double x1,
8-
double x2,
9-
double x3,
10-
double x4,
11-
double y1,
12-
double y2,
13-
double theta,
14-
double phi,
15-
double halfZ,
16-
double alpha1,
17-
double alpha2) {
7+
inline void volumeHandle::buildTrap(double x1,
8+
double x2,
9+
double x3,
10+
double x4,
11+
double y1,
12+
double y2,
13+
double theta,
14+
double phi,
15+
double halfZ,
16+
double alpha1,
17+
double alpha2) {
1818
LogTrace("MagGeoBuilder") << "Building trapezoid surfaces...: ";
1919
LogTrace("MagGeoBuilder") << "x1 " << x1 << newln << "x2 " << x2 << newln << "x3 " << x3 << newln << "x4 " << x4
2020
<< newln << "y1 " << y1 << newln << "y2 " << y2 << newln << "theta " << theta << newln

MagneticField/GeomBuilder/src/buildTruncTubs.icc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* \author N. Amapane - INFN Torino
1010
*/
1111

12-
void volumeHandle::buildTruncTubs(double zhalf,
13-
double rIn,
14-
double rOut,
15-
double startPhi,
16-
double deltaPhi,
17-
double cutAtStart,
18-
double cutAtDelta,
19-
bool cutInside) {
12+
inline void volumeHandle::buildTruncTubs(double zhalf,
13+
double rIn,
14+
double rOut,
15+
double startPhi,
16+
double deltaPhi,
17+
double cutAtStart,
18+
double cutAtDelta,
19+
bool cutInside) {
2020
LogTrace("MagGeoBuilder") << "Building TruncTubs surfaces...: ";
2121
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rIn " << rIn << newln << "rOut " << rOut
2222
<< newln << "startPhi " << startPhi << newln << "deltaPhi " << deltaPhi << newln

MagneticField/GeomBuilder/src/buildTubs.icc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void volumeHandle::buildTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi) {
1+
inline void volumeHandle::buildTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi) {
22
LogTrace("MagGeoBuilder") << "Building tubs surfaces...: ";
33
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rIn " << rIn << newln << "rOut " << rOut
44
<< newln << "startPhi " << startPhi << newln << "deltaPhi " << deltaPhi;

PhysicsTools/PatUtils/interface/PATJetCorrExtractor.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,6 @@
2929
#include <string>
3030
#include <vector>
3131

32-
namespace {
33-
std::string format_vstring(const std::vector<std::string>& v) {
34-
std::string retVal;
35-
36-
retVal.append("{ ");
37-
38-
unsigned numEntries = v.size();
39-
for (unsigned iEntry = 0; iEntry < numEntries; ++iEntry) {
40-
retVal.append(v[iEntry]);
41-
if (iEntry < (numEntries - 1))
42-
retVal.append(", ");
43-
}
44-
45-
retVal.append(" }");
46-
47-
return retVal;
48-
}
49-
} // namespace
50-
5132
class PATJetCorrExtractor {
5233
public:
5334
reco::Candidate::LorentzVector operator()(
@@ -83,11 +64,20 @@ class PATJetCorrExtractor {
8364
} catch (cms::Exception const&) {
8465
throw cms::Exception("InvalidRequest")
8566
<< "The JEC level " << jetCorrLabel << " does not exist !!\n"
86-
<< "Available levels = " << format_vstring(jet.availableJECLevels()) << ".\n";
67+
<< "Available levels = { " << format_vstring(jet.availableJECLevels()) << " }.\n";
8768
}
8869

8970
return corrJetP4;
9071
}
72+
73+
private:
74+
static std::string format_vstring(const std::vector<std::string>& v) {
75+
std::string retVal;
76+
auto ss = std::accumulate(v.begin(), v.end(), 0, [](int a, std::string const& s) { return a + s.length() + 2; });
77+
retVal.reserve(ss);
78+
for_each(v.begin(), v.end(), [&](std::string const& s) { retVal += (retVal.empty() ? "" : ", ") + s; });
79+
return retVal;
80+
}
9181
};
9282

9383
#endif

0 commit comments

Comments
 (0)