Skip to content

Commit

Permalink
Merge pull request #34140 from smuzaffar/12_0-codechecks-RECONSTRUCTION
Browse files Browse the repository at this point in the history
[RECONSTRUCTION] code-checks/format; clean code to remove global functions
  • Loading branch information
cmsbuild authored Jun 23, 2021
2 parents 356e27e + 3eb8cb5 commit 97ed514
Show file tree
Hide file tree
Showing 32 changed files with 848 additions and 1,346 deletions.
13 changes: 7 additions & 6 deletions CommonTools/RecoAlgos/plugins/PrimaryVertexSorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,27 +301,28 @@ void PrimaryVertexSorter<ParticlesCollection>::produce(edm::Event& iEvent, const
}

template <>
void PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::doConsumesForTiming(
inline void PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::doConsumesForTiming(
const edm::ParameterSet& iConfig) {
tokenTrackTimeTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeTag"));
tokenTrackTimeResoTag_ = consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("trackTimeResoTag"));
}

template <>
void PrimaryVertexSorter<std::vector<reco::PFCandidate>>::doConsumesForTiming(const edm::ParameterSet& iConfig) {}
inline void PrimaryVertexSorter<std::vector<reco::PFCandidate>>::doConsumesForTiming(const edm::ParameterSet& iConfig) {
}

template <>
bool PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::needsProductsForTiming() {
inline bool PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::needsProductsForTiming() {
return true;
}

template <>
bool PrimaryVertexSorter<std::vector<reco::PFCandidate>>::needsProductsForTiming() {
inline bool PrimaryVertexSorter<std::vector<reco::PFCandidate>>::needsProductsForTiming() {
return false;
}

template <>
std::pair<int, PrimaryVertexAssignment::Quality>
inline std::pair<int, PrimaryVertexAssignment::Quality>
PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::runAlgo(const reco::VertexCollection& vertices,
const reco::RecoChargedRefCandidate& pf,
const edm::ValueMap<float>* trackTimeTag,
Expand All @@ -332,7 +333,7 @@ PrimaryVertexSorter<std::vector<reco::RecoChargedRefCandidate>>::runAlgo(const r
}

template <>
std::pair<int, PrimaryVertexAssignment::Quality> PrimaryVertexSorter<std::vector<reco::PFCandidate>>::runAlgo(
inline std::pair<int, PrimaryVertexAssignment::Quality> PrimaryVertexSorter<std::vector<reco::PFCandidate>>::runAlgo(
const reco::VertexCollection& vertices,
const reco::PFCandidate& pf,
const edm::ValueMap<float>* trackTimeTag,
Expand Down
29 changes: 15 additions & 14 deletions DataFormats/DTRecHit/interface/DTDriftTimeParameters.icc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ const double THIS_CLASS::fun_sigma_t[N_alpha][N_By][N_Bz][N_Sigma_t] = {

/*** Auxiliary functions ***/

unsigned short THIS_CLASS::MB_DT_Check_boundaries(double distime, double alpha, double by, double bz, short ifl) const {
inline unsigned short THIS_CLASS::MB_DT_Check_boundaries(
double distime, double alpha, double by, double bz, short ifl) const {
unsigned short status = 1;
std::string name = "MB_DT_drift_time";

Expand Down Expand Up @@ -458,7 +459,7 @@ unsigned short THIS_CLASS::MB_DT_Check_boundaries(double distime, double alpha,
return (status);
}

void THIS_CLASS::MB_DT_Get_grid_values(
inline void THIS_CLASS::MB_DT_Get_grid_values(
double Var, unsigned short *pi, unsigned short *pj, short Initial, unsigned short N, const double *Values) const {
unsigned short i, iValue, jValue;

Expand All @@ -482,15 +483,15 @@ void THIS_CLASS::MB_DT_Get_grid_values(
}
}

void THIS_CLASS::MB_DT_Get_grid_points(double alpha,
double by,
double bz,
unsigned short *p_alpha,
unsigned short *p_By,
unsigned short *p_Bz,
unsigned short *q_alpha,
unsigned short *q_By,
unsigned short *q_Bz) const {
inline void THIS_CLASS::MB_DT_Get_grid_points(double alpha,
double by,
double bz,
unsigned short *p_alpha,
unsigned short *p_By,
unsigned short *p_Bz,
unsigned short *q_alpha,
unsigned short *q_By,
unsigned short *q_Bz) const {
MB_DT_Get_grid_values(fabs(alpha), p_alpha, q_alpha, 4, N_alpha, alpha_value);
MB_DT_Get_grid_values(by, p_By, q_By, 0, N_By, By_value);
MB_DT_Get_grid_values(bz, p_Bz, q_Bz, 0, N_Bz, Bz_value);
Expand All @@ -503,7 +504,7 @@ void THIS_CLASS::MB_DT_Get_grid_points(double alpha,

/*** Multidimensional linear interpolation ***/

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

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

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

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

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

if (x > 20.5)
Expand Down
8 changes: 4 additions & 4 deletions EventFilter/HcalRawToDigi/plugins/PackerHelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ class UHTRpacker {

// converts HE QIE digies to HB data format

QIE11DataFrame convertHB(QIE11DataFrame qiehe,
std::vector<int> const& tdc1,
std::vector<int> const& tdc2,
const int tdcmax) {
inline QIE11DataFrame convertHB(QIE11DataFrame qiehe,
std::vector<int> const& tdc1,
std::vector<int> const& tdc2,
const int tdcmax) {
QIE11DataFrame qiehb = qiehe;
HcalDetId did = HcalDetId(qiehb.detid());
int adc, tdc;
Expand Down
2 changes: 1 addition & 1 deletion MagneticField/GeomBuilder/src/buildBox.icc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* \author N. Amapane - INFN Torino
*/

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

// Global vectors of the normals to X, Y, Z axes
Expand Down
14 changes: 7 additions & 7 deletions MagneticField/GeomBuilder/src/buildCons.icc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

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

void volumeHandle::buildCons(double zhalf,
double rInMinusZ,
double rOutMinusZ,
double rInPlusZ,
double rOutPlusZ,
double startPhi,
double deltaPhi) {
inline void volumeHandle::buildCons(double zhalf,
double rInMinusZ,
double rOutMinusZ,
double rInPlusZ,
double rOutPlusZ,
double startPhi,
double deltaPhi) {
LogTrace("MagGeoBuilder") << "Building cons surfaces...: ";
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rInMinusZ " << rInMinusZ << newln << "rOutMinusZ "
<< rOutMinusZ << newln << "rInPlusZ " << rInPlusZ << newln << "rOutPlusZ " << rOutPlusZ
Expand Down
2 changes: 1 addition & 1 deletion MagneticField/GeomBuilder/src/buildPseudoTrap.icc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* \author N. Amapane - INFN Torino
*/

void volumeHandle::buildPseudoTrap(
inline void volumeHandle::buildPseudoTrap(
double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ) {
LogTrace("MagGeoBuilder") << "Building PseudoTrap surfaces...: ";
LogTrace("MagGeoBuilder") << "halfZ " << halfZ << newln << "x1 " << x1 << newln << "x2 " << x2
Expand Down
22 changes: 11 additions & 11 deletions MagneticField/GeomBuilder/src/buildTrap.icc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
* \author N. Amapane - INFN Torino
*/

void volumeHandle::buildTrap(double x1,
double x2,
double x3,
double x4,
double y1,
double y2,
double theta,
double phi,
double halfZ,
double alpha1,
double alpha2) {
inline void volumeHandle::buildTrap(double x1,
double x2,
double x3,
double x4,
double y1,
double y2,
double theta,
double phi,
double halfZ,
double alpha1,
double alpha2) {
LogTrace("MagGeoBuilder") << "Building trapezoid surfaces...: ";
LogTrace("MagGeoBuilder") << "x1 " << x1 << newln << "x2 " << x2 << newln << "x3 " << x3 << newln << "x4 " << x4
<< newln << "y1 " << y1 << newln << "y2 " << y2 << newln << "theta " << theta << newln
Expand Down
16 changes: 8 additions & 8 deletions MagneticField/GeomBuilder/src/buildTruncTubs.icc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* \author N. Amapane - INFN Torino
*/

void volumeHandle::buildTruncTubs(double zhalf,
double rIn,
double rOut,
double startPhi,
double deltaPhi,
double cutAtStart,
double cutAtDelta,
bool cutInside) {
inline void volumeHandle::buildTruncTubs(double zhalf,
double rIn,
double rOut,
double startPhi,
double deltaPhi,
double cutAtStart,
double cutAtDelta,
bool cutInside) {
LogTrace("MagGeoBuilder") << "Building TruncTubs surfaces...: ";
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rIn " << rIn << newln << "rOut " << rOut
<< newln << "startPhi " << startPhi << newln << "deltaPhi " << deltaPhi << newln
Expand Down
2 changes: 1 addition & 1 deletion MagneticField/GeomBuilder/src/buildTubs.icc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void volumeHandle::buildTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi) {
inline void volumeHandle::buildTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi) {
LogTrace("MagGeoBuilder") << "Building tubs surfaces...: ";
LogTrace("MagGeoBuilder") << "zhalf " << zhalf << newln << "rIn " << rIn << newln << "rOut " << rOut
<< newln << "startPhi " << startPhi << newln << "deltaPhi " << deltaPhi;
Expand Down
30 changes: 10 additions & 20 deletions PhysicsTools/PatUtils/interface/PATJetCorrExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,6 @@
#include <string>
#include <vector>

namespace {
std::string format_vstring(const std::vector<std::string>& v) {
std::string retVal;

retVal.append("{ ");

unsigned numEntries = v.size();
for (unsigned iEntry = 0; iEntry < numEntries; ++iEntry) {
retVal.append(v[iEntry]);
if (iEntry < (numEntries - 1))
retVal.append(", ");
}

retVal.append(" }");

return retVal;
}
} // namespace

class PATJetCorrExtractor {
public:
reco::Candidate::LorentzVector operator()(
Expand Down Expand Up @@ -83,11 +64,20 @@ class PATJetCorrExtractor {
} catch (cms::Exception const&) {
throw cms::Exception("InvalidRequest")
<< "The JEC level " << jetCorrLabel << " does not exist !!\n"
<< "Available levels = " << format_vstring(jet.availableJECLevels()) << ".\n";
<< "Available levels = { " << format_vstring(jet.availableJECLevels()) << " }.\n";
}

return corrJetP4;
}

private:
static std::string format_vstring(const std::vector<std::string>& v) {
std::string retVal;
auto ss = std::accumulate(v.begin(), v.end(), 0, [](int a, std::string const& s) { return a + s.length() + 2; });
retVal.reserve(ss);
for_each(v.begin(), v.end(), [&](std::string const& s) { retVal += (retVal.empty() ? "" : ", ") + s; });
return retVal;
}
};

#endif
2 changes: 1 addition & 1 deletion RecoBTag/FeatureTools/interface/SeedingTracksConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace btagbtvdeep {
bool computeProbabilities,
std::vector<btagbtvdeep::SeedingTrackFeatures>& seedingT_features_vector);

float logWithOffset(float v, float logOffset = 0) {
inline float logWithOffset(float v, float logOffset = 0) {
if (v == 0.)
return 0.;
return logOffset + log(std::fabs(v)) * std::copysign(1.f, v);
Expand Down
5 changes: 3 additions & 2 deletions RecoBTag/ImpactParameter/plugins/IPProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void IPProducer<Container, Base, Helper>::checkEventSetup(const edm::EventSetup&
// Specialized templates used to fill 'descriptions'
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
template <>
void IPProducer<reco::TrackRefVector, reco::JTATagInfo, IPProducerHelpers::FromJTA>::fillDescriptions(
inline void IPProducer<reco::TrackRefVector, reco::JTATagInfo, IPProducerHelpers::FromJTA>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<double>("maximumTransverseImpactParameter", 0.2);
Expand All @@ -462,7 +462,8 @@ void IPProducer<reco::TrackRefVector, reco::JTATagInfo, IPProducerHelpers::FromJ
}

template <>
void IPProducer<std::vector<reco::CandidatePtr>, reco::JetTagInfo, IPProducerHelpers::FromJetAndCands>::fillDescriptions(
inline void
IPProducer<std::vector<reco::CandidatePtr>, reco::JetTagInfo, IPProducerHelpers::FromJetAndCands>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<double>("maximumTransverseImpactParameter", 0.2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class CombinedSVSoftLeptonComputer : public CombinedSVComputer {
bool SoftLeptonFlip;
};

double CombinedSVSoftLeptonComputer::flipSoftLeptonValue(double value) const { return SoftLeptonFlip ? -value : value; }
inline double CombinedSVSoftLeptonComputer::flipSoftLeptonValue(double value) const {
return SoftLeptonFlip ? -value : value;
}

template <class IPTI, class SVTI>
reco::TaggingVariableList CombinedSVSoftLeptonComputer::operator()(const IPTI &ipInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void EGXtraModFromVMObjFiller<int>::addValueToObject(

template <>
template <>
void EGXtraModFromVMObjFiller<egmodifier::EGID>::addValuesToObject(
inline void EGXtraModFromVMObjFiller<egmodifier::EGID>::addValuesToObject(
pat::Electron& obj,
const edm::Ptr<reco::Candidate>& ptr,
const std::unordered_map<std::string, edm::EDGetTokenT<edm::ValueMap<float>>>& vmaps_token,
Expand All @@ -299,7 +299,7 @@ void EGXtraModFromVMObjFiller<egmodifier::EGID>::addValuesToObject(

template <>
template <>
void EGXtraModFromVMObjFiller<egmodifier::EGID>::addValuesToObject(
inline void EGXtraModFromVMObjFiller<egmodifier::EGID>::addValuesToObject(
pat::Photon& obj,
const edm::Ptr<reco::Candidate>& ptr,
const std::unordered_map<std::string, edm::EDGetTokenT<edm::ValueMap<float>>>& vmaps_token,
Expand Down
Loading

0 comments on commit 97ed514

Please sign in to comment.