Skip to content

Commit aed1e1d

Browse files
authored
Merge pull request cms-sw#34035 from smuzaffar/12_0-code-checks-ANALYSIS
[ANALYSIS] Apply code-checks/format with misc-definitions-in-headers
2 parents 9d3afb0 + eedda6e commit aed1e1d

File tree

8 files changed

+52
-43
lines changed

8 files changed

+52
-43
lines changed

JetMETCorrections/MCJet/bin/Utilities.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ std::vector<T> CommandLine::getVector(const std::string& name) {
146146
std::string::size_type pos;
147147
if (!tmp.empty()) {
148148
do {
149-
pos = tmp.find(",");
149+
pos = tmp.find(',');
150150
std::stringstream ss;
151151
ss << tmp.substr(0, pos);
152152
tmp.erase(0, pos + 1);
@@ -189,7 +189,7 @@ bool CommandLine::parse(int argc, char** argv) {
189189

190190
for (int i = 1; i < argc; i++) {
191191
std::string opt = argv[i];
192-
if (0 != opt.find("-")) {
192+
if (0 != opt.find('-')) {
193193
if (i == 1) {
194194
bool success = parse_file(opt);
195195
if (!success)
@@ -210,7 +210,7 @@ bool CommandLine::parse(int argc, char** argv) {
210210
i++;
211211
if (i < argc - 1) {
212212
next = argv[i + 1];
213-
while (next.find("-") != 0) {
213+
while (next.find('-') != 0) {
214214
_options[opt].first += "," + next;
215215
i++;
216216
next = (i < argc - 1) ? argv[i + 1] : "-";
@@ -254,7 +254,7 @@ void CommandLine::print() {
254254
std::string::size_type length = tmp.length();
255255
std::string::size_type pos;
256256
do {
257-
pos = tmp.find(",");
257+
pos = tmp.find(',');
258258
if (tmp.length() == length) {
259259
std::cout << std::setiosflags(std::ios::left) << std::setw(22) << it->first
260260
<< std::resetiosflags(std::ios::left) << std::setw(3) << "=" << std::setiosflags(std::ios::right)
@@ -308,8 +308,8 @@ bool CommandLine::parse_file(const std::string& file_name) {
308308
last_token = "";
309309
value = "";
310310
} else if (!last_token.empty()) {
311-
if (last_token.find("\"") == 0) {
312-
if (last_token.rfind("\"") == last_token.length() - 1) {
311+
if (last_token.find('\"') == 0) {
312+
if (last_token.rfind('\"') == last_token.length() - 1) {
313313
last_token = last_token.substr(1, last_token.length() - 2);
314314
value += (!value.empty()) ? "," + last_token : last_token;
315315
last_token = token;
@@ -324,7 +324,7 @@ bool CommandLine::parse_file(const std::string& file_name) {
324324
ss >> token;
325325
}
326326
if (!last_token.empty()) {
327-
if (last_token.find("\"") == 0 && last_token.rfind("\"") == last_token.length() - 1)
327+
if (last_token.find('\"') == 0 && last_token.rfind('\"') == last_token.length() - 1)
328328
last_token = last_token.substr(1, last_token.length() - 2);
329329
value += (!value.empty()) ? "," + last_token : last_token;
330330
}

MuonAnalysis/MomentumScaleCalibration/plugins/Histograms.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
#include "TCanvas.h"
2929

3030
#include "TLorentzVector.h"
31-
#include <vector>
32-
#include <string>
33-
#include <iostream>
31+
#include <memory>
32+
3433
#include "TMath.h"
34+
#include <iostream>
35+
#include <string>
36+
#include <vector>
3537

3638
class Histograms {
3739
public:
@@ -2288,8 +2290,8 @@ class HMassResolutionVSPart : public Histograms {
22882290
}
22892291

22902292
// single particles histograms
2291-
muMinus.reset(new HDelta("muMinus"));
2292-
muPlus.reset(new HDelta("muPlus"));
2293+
muMinus = std::make_unique<HDelta>("muMinus");
2294+
muPlus = std::make_unique<HDelta>("muPlus");
22932295
}
22942296

22952297
~HMassResolutionVSPart() override {

PhysicsTools/UtilAlgos/interface/CachingVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class ExpressionVariable : public CachingVariable {
333333
//do something fancy for multiple variable from one PSet
334334
std::vector<std::string> vars = arg.iConfig.getParameter<std::vector<std::string> >("vars");
335335
for (unsigned int v = 0; v != vars.size(); ++v) {
336-
unsigned int sep = vars[v].find(":");
336+
unsigned int sep = vars[v].find(':');
337337
std::string name = vars[v].substr(0, sep);
338338
std::string expr = vars[v].substr(sep + 1);
339339

PhysicsTools/UtilAlgos/interface/StringBasedNTupler.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TreeBranch {
6666
}
6767
const std::string& branchAlias() const { return branchAlias_; }
6868
const std::string& branchTitle() const { return branchTitle_; }
69-
typedef std::unique_ptr<std::vector<float> > value;
69+
typedef std::unique_ptr<std::vector<float>> value;
7070
value branch(const edm::Event& iEvent);
7171

7272
std::vector<float>** dataHolderPtrAdress() { return &dataHolderPtr_; }
@@ -100,12 +100,12 @@ class StringLeaveHelper {
100100
//empty vector if product not found
101101
if (oH.failedToGet()) {
102102
edm::LogError("StringBranchHelper") << "cannot open: " << B.src();
103-
value_.reset(new std::vector<float>(0));
103+
value_ = std::make_unique<std::vector<float>>(0);
104104
} else {
105105
//parser for the object expression
106106
StringObjectFunction<Object> expr(B.expr());
107107
//allocate enough memory for the data holder
108-
value_.reset(new std::vector<float>(1));
108+
value_ = std::make_unique<std::vector<float>>(1);
109109
try {
110110
(*value_)[0] = (expr)(*oH);
111111
} catch (...) {
@@ -120,7 +120,7 @@ class StringLeaveHelper {
120120
value value_;
121121
};
122122

123-
template <typename Object, typename Collection = std::vector<Object> >
123+
template <typename Object, typename Collection = std::vector<Object>>
124124
class StringBranchHelper {
125125
public:
126126
typedef TreeBranch::value value;
@@ -138,12 +138,12 @@ class StringBranchHelper {
138138
if (!(iEvent.isRealData() && B.className() == "reco::GenParticle")) { //don't output genparticle error in data
139139
edm::LogError("StringBranchHelper") << "cannot open: " << B.src() << " " << B.className();
140140
}
141-
value_.reset(new std::vector<float>());
141+
value_ = std::make_unique<std::vector<float>>();
142142
} else {
143143
//parser for the object expression
144144
StringObjectFunction<Object> expr(B.expr());
145145
//allocate enough memory for the data holder
146-
value_.reset(new std::vector<float>());
146+
value_ = std::make_unique<std::vector<float>>();
147147
value_->reserve(oH->size());
148148

149149
StringCutObjectSelector<Object>* selection = nullptr;
@@ -233,17 +233,17 @@ class StringBasedNTupler : public NTupler {
233233

234234
//do it once with configuration [vstring vars = { "x:x" ,... } ] where ":"=separator
235235
if (leavesPSet.exists("vars")) {
236-
std::vector<std::string> leavesS = leavesPSet.getParameter<std::vector<std::string> >("vars");
236+
std::vector<std::string> leavesS = leavesPSet.getParameter<std::vector<std::string>>("vars");
237237
for (uint l = 0; l != leavesS.size(); ++l) {
238238
uint sep = leavesS[l].find(separator);
239239
std::string name = leavesS[l].substr(0, sep);
240240
//removes spaces from the variable name
241-
/*uint*/ int space = name.find(" ");
241+
/*uint*/ int space = name.find(' ');
242242
while (space != -1 /*std::string::npos*/) {
243243
std::string first = name.substr(0, space);
244244
std::string second = name.substr(space + 1);
245245
name = first + second;
246-
space = name.find(" ");
246+
space = name.find(' ');
247247
}
248248
std::string expr = leavesS[l].substr(sep + 1);
249249
std::string branchAlias = branches[b] + "_" + name;
@@ -347,7 +347,7 @@ class StringBasedNTupler : public NTupler {
347347
for (; iL != iL_end; ++iL) {
348348
TreeBranch& b = *iL;
349349
//a vector of float for each leave
350-
producesCollector.produces<std::vector<float> >(b.branchName()).setBranchAlias(b.branchAlias());
350+
producesCollector.produces<std::vector<float>>(b.branchName()).setBranchAlias(b.branchAlias());
351351
nLeaves++;
352352
}
353353
}
@@ -371,7 +371,7 @@ class StringBasedNTupler : public NTupler {
371371
for (; iL != iL_end; ++iL) {
372372
TreeBranch& b = *iL;
373373
// grab the vector of values from the interpretation of expression for the associated collection
374-
std::unique_ptr<std::vector<float> > branch(b.branch(iEvent));
374+
std::unique_ptr<std::vector<float>> branch(b.branch(iEvent));
375375
// calculate the maximum index size.
376376
if (branch->size() > maxS)
377377
maxS = branch->size();
@@ -430,7 +430,7 @@ class StringBasedNTupler : public NTupler {
430430
uint maxS = 0;
431431
for (; iL != iL_end; ++iL) {
432432
TreeBranch& b = *iL;
433-
std::unique_ptr<std::vector<float> > branch(b.branch(iEvent));
433+
std::unique_ptr<std::vector<float>> branch(b.branch(iEvent));
434434
if (branch->size() > maxS)
435435
maxS = branch->size();
436436
iEvent.put(std::move(branch), b.branchName());
@@ -470,7 +470,7 @@ class StringBasedNTupler : public NTupler {
470470
}
471471

472472
protected:
473-
typedef std::map<std::string, std::vector<TreeBranch> > Branches;
473+
typedef std::map<std::string, std::vector<TreeBranch>> Branches;
474474
Branches branches_;
475475

476476
bool ownTheTree_;

PhysicsTools/Utilities/interface/NumericalIntegration.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* Gauss Legendre and Gauss algorithms based on ROOT implementation
88
*
99
*/
10+
#include "Math/AllIntegrationTypes.h"
1011
#include "Math/Functor.h"
1112
#include "Math/Integrator.h"
12-
#include "Math/AllIntegrationTypes.h"
13-
#include <vector>
1413
#include <cmath>
1514
#include <memory>
15+
#include <vector>
1616

1717
namespace funct {
1818

@@ -142,15 +142,15 @@ namespace funct {
142142
relTol_ = o.relTol_;
143143
size_ = o.size_;
144144
rule_ = o.rule_;
145-
integrator_.reset(new ROOT::Math::Integrator(type_, absTol_, relTol_, size_, rule_));
145+
integrator_ = std::make_unique<ROOT::Math::Integrator>(type_, absTol_, relTol_, size_, rule_);
146146
}
147147
RootIntegrator& operator=(const RootIntegrator& o) {
148148
type_ = o.type_;
149149
absTol_ = o.absTol_;
150150
relTol_ = o.relTol_;
151151
size_ = o.size_;
152152
rule_ = o.rule_;
153-
integrator_.reset(new ROOT::Math::Integrator(type_, absTol_, relTol_, size_, rule_));
153+
integrator_ = std::make_unique<ROOT::Math::Integrator>(type_, absTol_, relTol_, size_, rule_);
154154
return *this;
155155
}
156156
template <typename F>

PhysicsTools/Utilities/interface/Primitive.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ namespace funct {
155155
// /
156156

157157
template <TYPXT2,
158-
bool bint = not::std::is_same<PRIMIT(X, B), UndefinedIntegral>::value,
159-
bool aint = not::std::is_same<PRIMIT(X, A), UndefinedIntegral>::value>
158+
bool bint = not ::std::is_same<PRIMIT(X, B), UndefinedIntegral>::value,
159+
bool aint = not ::std::is_same<PRIMIT(X, A), UndefinedIntegral>::value>
160160
struct PartIntegral {
161161
typedef UndefinedIntegral type;
162162
GET(PROD_S(A, B), type());
@@ -213,8 +213,8 @@ namespace funct {
213213
// /
214214

215215
template <TYPXT2,
216-
bool bint = not::std::is_same<PRIMIT(X, RATIO(NUM(1), B)), UndefinedIntegral>::value,
217-
bool aint = not::std::is_same<PRIMIT(X, A), UndefinedIntegral>::value>
216+
bool bint = not ::std::is_same<PRIMIT(X, RATIO(NUM(1), B)), UndefinedIntegral>::value,
217+
bool aint = not ::std::is_same<PRIMIT(X, A), UndefinedIntegral>::value>
218218
struct PartIntegral2 {
219219
typedef UndefinedIntegral type;
220220
GET(RATIO_S(A, B), type());

TopQuarkAnalysis/TopEventSelection/interface/TtFullHadSignalSel.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ class TtFullHadSignalSel {
5656
double pt(unsigned short i) const { return (pts_.size() >= i) ? pts_.at(i - 1) : -1.; }
5757

5858
double EtSin2Theta(unsigned short i, bool boosted = false) const {
59-
return boosted ? ((EtStars_.size() >= i) ? EtStars_.at(i - 1) : -1.)
60-
: (EtSin2Thetas_.size() >= i) ? EtSin2Thetas_.at(i - 1) : -1.;
59+
return boosted ? ((EtStars_.size() >= i) ? EtStars_.at(i - 1) : -1.)
60+
: (EtSin2Thetas_.size() >= i) ? EtSin2Thetas_.at(i - 1)
61+
: -1.;
6162
}
6263
double theta(unsigned short i, bool boosted = false) const {
63-
return boosted ? ((thetaStars_.size() >= i) ? thetaStars_.at(i - 1) : -1.)
64-
: (thetas_.size() >= i) ? thetas_.at(i - 1) : -1.;
64+
return boosted ? ((thetaStars_.size() >= i) ? thetaStars_.at(i - 1) : -1.)
65+
: (thetas_.size() >= i) ? thetas_.at(i - 1)
66+
: -1.;
6567
}
6668
double sinTheta(unsigned short i, bool boosted = false) const {
67-
return boosted ? ((thetaStars_.size() >= i) ? sin(thetaStars_.at(i - 1)) : -1.)
68-
: (thetas_.size() >= i) ? sin(thetas_.at(i - 1)) : -1.;
69+
return boosted ? ((thetaStars_.size() >= i) ? sin(thetaStars_.at(i - 1)) : -1.)
70+
: (thetas_.size() >= i) ? sin(thetas_.at(i - 1))
71+
: -1.;
6972
}
7073

7174
double EtSin2Theta3jet(bool boosted = false) const { return boosted ? EtStar3jet_ : EtSin2Theta3jet_; }
@@ -78,15 +81,18 @@ class TtFullHadSignalSel {
7881

7982
double jet_etaetaMoment(unsigned short i, bool noB = false) const {
8083
return noB ? ((etaetaMomentsNoB_.size() >= i) ? etaetaMomentsNoB_.at(etaetaMomentsNoB_.size() - i) : -100.)
81-
: (etaetaMoments_.size() >= i) ? etaetaMoments_.at(etaetaMoments_.size() - i) : -100.;
84+
: (etaetaMoments_.size() >= i) ? etaetaMoments_.at(etaetaMoments_.size() - i)
85+
: -100.;
8286
}
8387
double jet_etaphiMoment(unsigned short i, bool noB = false) const {
8488
return noB ? ((etaphiMomentsNoB_.size() >= i) ? etaphiMomentsNoB_.at(etaphiMomentsNoB_.size() - i) : -100.)
85-
: (etaphiMoments_.size() >= i) ? etaphiMoments_.at(etaphiMoments_.size() - i) : -100.;
89+
: (etaphiMoments_.size() >= i) ? etaphiMoments_.at(etaphiMoments_.size() - i)
90+
: -100.;
8691
}
8792
double jet_phiphiMoment(unsigned short i, bool noB = false) const {
8893
return noB ? ((phiphiMomentsNoB_.size() >= i) ? phiphiMomentsNoB_.at(phiphiMomentsNoB_.size() - i) : -100.)
89-
: (phiphiMoments_.size() >= i) ? phiphiMoments_.at(phiphiMoments_.size() - i) : -100.;
94+
: (phiphiMoments_.size() >= i) ? phiphiMoments_.at(phiphiMoments_.size() - i)
95+
: -100.;
9096
}
9197

9298
double jet_etaetaMomentMoment(unsigned short i) const {

TopQuarkAnalysis/TopKinFitter/plugins/TtFullLepKinSolutionProducer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ void TtFullLepKinSolutionProducer::produce(edm::Event& evt, const edm::EventSetu
408408
if (weightsV.empty()) {
409409
//create dmummy vector
410410
std::vector<int> idcs;
411+
idcs.reserve(6);
411412
for (int i = 0; i < 6; ++i)
412413
idcs.push_back(-1);
413414

0 commit comments

Comments
 (0)