Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang tidy] Apply checks for analysis-reconstruction #30784

Merged
merged 2 commits into from
Jul 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions CommonTools/CandUtils/src/makeCompositeCandidate.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include <memory>

#include "CommonTools/CandUtils/interface/makeCompositeCandidate.h"
using namespace reco;
using namespace std;

helpers::CompositeCandidateMaker makeCompositeCandidate(const Candidate& c1, const Candidate& c2) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
return cmp;
}

helpers::CompositeCandidateMaker makeCompositeCandidate(const Candidate& c1, const Candidate& c2, const Candidate& c3) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
cmp.addDaughter(c3);
Expand All @@ -21,7 +23,7 @@ helpers::CompositeCandidateMaker makeCompositeCandidate(const Candidate& c1,
const Candidate& c2,
const Candidate& c3,
const Candidate& c4) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
cmp.addDaughter(c3);
Expand All @@ -31,7 +33,7 @@ helpers::CompositeCandidateMaker makeCompositeCandidate(const Candidate& c1,

helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef& c1,
const reco::CandidateRef& c2) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)));
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)));
return cmp;
Expand All @@ -40,7 +42,7 @@ helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const re
helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef& c1,
const reco::CandidateRef& c2,
const reco::CandidateRef& c3) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)));
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)));
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c3)));
Expand All @@ -51,7 +53,7 @@ helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const re
const reco::CandidateRef& c2,
const reco::CandidateRef& c3,
const reco::CandidateRef& c4) {
helpers::CompositeCandidateMaker cmp(unique_ptr<CompositeCandidate>(new CompositeCandidate));
helpers::CompositeCandidateMaker cmp(std::make_unique<CompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)));
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)));
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c3)));
Expand All @@ -60,7 +62,7 @@ helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const re
}

helpers::CompositePtrCandidateMaker makeCompositePtrCandidate(const CandidatePtr& c1, const CandidatePtr& c2) {
helpers::CompositePtrCandidateMaker cmp(unique_ptr<CompositePtrCandidate>(new CompositePtrCandidate));
helpers::CompositePtrCandidateMaker cmp(std::make_unique<CompositePtrCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
return cmp;
Expand All @@ -69,7 +71,7 @@ helpers::CompositePtrCandidateMaker makeCompositePtrCandidate(const CandidatePtr
helpers::CompositePtrCandidateMaker makeCompositePtrCandidate(const CandidatePtr& c1,
const CandidatePtr& c2,
const CandidatePtr& c3) {
helpers::CompositePtrCandidateMaker cmp(unique_ptr<CompositePtrCandidate>(new CompositePtrCandidate));
helpers::CompositePtrCandidateMaker cmp(std::make_unique<CompositePtrCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
cmp.addDaughter(c3);
Expand All @@ -80,7 +82,7 @@ helpers::CompositePtrCandidateMaker makeCompositePtrCandidate(const CandidatePtr
const CandidatePtr& c2,
const CandidatePtr& c3,
const CandidatePtr& c4) {
helpers::CompositePtrCandidateMaker cmp(unique_ptr<CompositePtrCandidate>(new CompositePtrCandidate));
helpers::CompositePtrCandidateMaker cmp(std::make_unique<CompositePtrCandidate>());
cmp.addDaughter(c1);
cmp.addDaughter(c2);
cmp.addDaughter(c3);
Expand Down
14 changes: 8 additions & 6 deletions CommonTools/CandUtils/src/makeNamedCompositeCandidate.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <memory>

#include "CommonTools/CandUtils/interface/makeNamedCompositeCandidate.h"
using namespace reco;
using namespace std;
Expand All @@ -6,15 +8,15 @@ helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidate(const Candidat
std::string s1,
const Candidate& c2,
std::string s2) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(c1, s1);
cmp.addDaughter(c2, s2);
return cmp;
}

helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidate(
const Candidate& c1, std::string s1, const Candidate& c2, std::string s2, const Candidate& c3, std::string s3) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(c1, s1);
cmp.addDaughter(c2, s2);
cmp.addDaughter(c3, s3);
Expand All @@ -29,7 +31,7 @@ helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidate(const Candidat
std::string s3,
const Candidate& c4,
std::string s4) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(c1, s1);
cmp.addDaughter(c2, s2);
cmp.addDaughter(c3, s3);
Expand All @@ -41,7 +43,7 @@ helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidateWithRefsToMaste
std::string s1,
const reco::CandidateRef& c2,
std::string s2) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)), s1);
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)), s2);
return cmp;
Expand All @@ -53,7 +55,7 @@ helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidateWithRefsToMaste
std::string s2,
const reco::CandidateRef& c3,
std::string s3) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)), s1);
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)), s2);
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c3)), s3);
Expand All @@ -68,7 +70,7 @@ helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidateWithRefsToMaste
std::string s3,
const reco::CandidateRef& c4,
std::string s4) {
helpers::NamedCompositeCandidateMaker cmp(unique_ptr<NamedCompositeCandidate>(new NamedCompositeCandidate));
helpers::NamedCompositeCandidateMaker cmp(std::make_unique<NamedCompositeCandidate>());
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c1)), s1);
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c2)), s2);
cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(c3)), s3);
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/MVAUtils/src/GBRForestTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace {
int rootTrainingVersion(0);
if (info.find("ROOT Release") != info.end()) {
std::string s = info["ROOT Release"];
rootTrainingVersion = std::stoi(s.substr(s.find("[") + 1, s.find("]") - s.find("[") - 1));
rootTrainingVersion = std::stoi(s.substr(s.find('[') + 1, s.find(']') - s.find('[') - 1));
}

// Get the boosting weights
Expand Down
4 changes: 3 additions & 1 deletion CommonTools/MVAUtils/src/TMVAEvaluator.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <memory>

#include "CommonTools/MVAUtils/interface/GBRForestTools.h"
#include "CommonTools/MVAUtils/interface/TMVAEvaluator.h"
#include "CommonTools/MVAUtils/interface/TMVAZipReader.h"
Expand All @@ -16,7 +18,7 @@ void TMVAEvaluator::initialize(const std::string& options,
bool useGBRForest,
bool useAdaBoost) {
// initialize the TMVA reader
mReader.reset(new TMVA::Reader(options.c_str()));
mReader = std::make_unique<TMVA::Reader>(options.c_str());
mReader->SetVerbose(false);
mMethod = method;

Expand Down
16 changes: 9 additions & 7 deletions CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@

#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/Candidate/interface/CandAssociation.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
#include "DataFormats/Candidate/interface/CandAssociation.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <string>
#include <memory>

#include <regex>
#include <string>

#include "PhysicsTools/IsolationAlgos/interface/IsoDepositVetoFactory.h"

Expand Down Expand Up @@ -201,7 +203,7 @@ void PFCandIsolatorFromDeposits::produce(Event &event, const EventSetup &eventSe
const IsoDepositMap &map = begin->map();

if (map.empty()) { // !!???
event.put(std::unique_ptr<CandDoubleMap>(new CandDoubleMap()));
event.put(std::make_unique<CandDoubleMap>());
return;
}
std::unique_ptr<CandDoubleMap> ret(new CandDoubleMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PFEGammaToCandidateRemapper : public edm::global::EDProducer<> {
std::vector<std::vector<reco::PFCandidateRef>> refs(handle->size());
for (unsigned int i = 0, n = handle->size(); i < n; ++i) {
edm::Ref<std::vector<T>> egRef(handle, i);
for (reco::PFCandidateRef pfRef : (*oldmap)[egRef]) {
for (const reco::PFCandidateRef &pfRef : (*oldmap)[egRef]) {
refs[i].push_back(pf2pf[pfRef]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/PileupAlgos/plugins/PuppiPhoton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void PuppiPhoton::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
int iPF = 0;
std::vector<float> lWeights;
static const reco::PFCandidate dummySinceTranslateIsNotStatic;
corrCandidates_.reset(new PFOutputCollection);
corrCandidates_ = std::make_unique<PFOutputCollection>();
std::set<int> foundPhoIndex;
for (CandidateView::const_iterator itPF = pupCol->begin(); itPF != pupCol->end(); itPF++) {
auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(itPF->pdgId());
Expand Down
6 changes: 3 additions & 3 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) {
fClonePackedCands = iConfig.getParameter<bool>("clonePackedCands");
fVtxNdofCut = iConfig.getParameter<int>("vtxNdofCut");
fVtxZCut = iConfig.getParameter<double>("vtxZCut");
fPuppiContainer = std::unique_ptr<PuppiContainer>(new PuppiContainer(iConfig));
fPuppiContainer = std::make_unique<PuppiContainer>(iConfig);

tokenPFCandidates_ = consumes<CandidateView>(iConfig.getParameter<edm::InputTag>("candName"));
tokenVertices_ = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexName"));
Expand Down Expand Up @@ -275,11 +275,11 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
const pat::PackedCandidate* cand = dynamic_cast<const pat::PackedCandidate*>(&aCand);
if (!cand)
throw edm::Exception(edm::errors::LogicError, "PuppiProducer: inputs are not PackedCandidates");
pCand.reset(new pat::PackedCandidate(*cand));
pCand = std::make_unique<pat::PackedCandidate>(*cand);
} else {
auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(aCand.pdgId());
const reco::PFCandidate* cand = dynamic_cast<const reco::PFCandidate*>(&aCand);
pfCand.reset(new reco::PFCandidate(cand ? *cand : reco::PFCandidate(aCand.charge(), aCand.p4(), id)));
pfCand = std::make_unique<reco::PFCandidate>(cand ? *cand : reco::PFCandidate(aCand.charge(), aCand.p4(), id));
}

// Here, we are using new weights computed and putting them in the packed candidates.
Expand Down
6 changes: 4 additions & 2 deletions CommonTools/TriggerUtils/src/GenericTriggerEventFlag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "DataFormats/L1GlobalTrigger/interface/L1GtLogicParser.h"

#include <memory>

#include <vector>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand All @@ -21,7 +23,7 @@ GenericTriggerEventFlag::GenericTriggerEventFlag(const edm::ParameterSet& config
: GenericTriggerEventFlag(config, iC, false) {
if (config.exists("andOrL1")) {
if (stage2_) {
l1uGt_.reset(new l1t::L1TGlobalUtil(config, iC, use));
l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC, use);
}
}
}
Expand Down Expand Up @@ -202,7 +204,7 @@ void GenericTriggerEventFlag::initRun(const edm::Run& run, const edm::EventSetup
l1uGt_->retrieveL1Setup(setup);

const std::vector<std::pair<std::string, int> > prescales = l1uGt_->prescales();
for (auto ip : prescales)
for (const auto& ip : prescales)
algoNames.push_back(ip.first);
} else {
l1Gt_->getL1GtRunCache(run, setup, useL1EventSetup, useL1GtTriggerMenuLite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void CovarianceParameterization::load(int version) {
std::string bitString = folder + "/bit";
std::vector<float> vParams;
TVector *p = (TVector *)fileToRead.Get((folder + "/param").c_str());
vParams.reserve(p->GetNoElements());
for (int k = 0; k < p->GetNoElements(); k++) {
vParams.push_back((*p)[k]);
}
Expand Down
10 changes: 5 additions & 5 deletions DataFormats/PatCandidates/src/Flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::string Flags::maskToString(uint32_t mask) {
}

uint32_t Flags::get(const std::string &str) {
size_t idx = str.find_first_of("/");
size_t idx = str.find_first_of('/');
if (idx != std::string::npos) {
std::string set = str.substr(0, idx);
if (set == "Core")
Expand Down Expand Up @@ -78,7 +78,7 @@ const std::string &Flags::Core::bitToString(Core::Bits bit) {
}

Flags::Core::Bits Flags::Core::get(const std::string &instr) {
size_t idx = instr.find_first_of("/");
size_t idx = instr.find_first_of('/');
const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
if (str == "All")
return All;
Expand Down Expand Up @@ -148,7 +148,7 @@ Flags::Selection::Bits Flags::Selection::get(int8_t bit) {
}

Flags::Selection::Bits Flags::Selection::get(const std::string &instr) {
size_t idx = instr.find_first_of("/");
size_t idx = instr.find_first_of('/');
const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
if (str == "All")
return All;
Expand Down Expand Up @@ -219,7 +219,7 @@ const std::string &Flags::Overlap::bitToString(Overlap::Bits bit) {
}

Flags::Overlap::Bits Flags::Overlap::get(const std::string &instr) {
size_t idx = instr.find_first_of("/");
size_t idx = instr.find_first_of('/');
const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
if (str == "All")
return All;
Expand Down Expand Up @@ -287,7 +287,7 @@ const std::string &Flags::Isolation::bitToString(Isolation::Bits bit) {
}

Flags::Isolation::Bits Flags::Isolation::get(const std::string &instr) {
size_t idx = instr.find_first_of("/");
size_t idx = instr.find_first_of('/');
const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
if (str == "All")
return All;
Expand Down
8 changes: 4 additions & 4 deletions JetMETCorrections/Modules/plugins/QGLikelihoodDBWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void QGLikelihoodDBWriter::beginJob() {

// The ROOT file contains the binning for each variable, needed to set up the binning grid
std::map<TString, std::vector<float>> gridOfBins;
for (TString binVariable : {"eta", "pt", "rho"}) {
for (const TString& binVariable : {"eta", "pt", "rho"}) {
if (!getVectorFromFile(f, gridOfBins[binVariable], binVariable + "Bins")) {
edm::LogError("NoBins") << "Missing bin information for " << binVariable << " in input file" << std::endl;
return;
Expand All @@ -124,9 +124,9 @@ void QGLikelihoodDBWriter::beginJob() {
// Here we do not store the copies, but try to extend the range of the neighbouring category (will result in less comparisons during application phase)
std::map<std::vector<int>, TH1*> pdfs;
std::map<std::vector<int>, QGLikelihoodCategory> categories;
for (TString type : {"gluon", "quark"}) {
for (const TString& type : {"gluon", "quark"}) {
int qgIndex = (type == "gluon"); // Keep numbering same as in RecoJets/JetAlgorithms/src/QGLikelihoodCalculator.cc
for (TString likelihoodVar : {"mult", "ptD", "axis2"}) {
for (const TString& likelihoodVar : {"mult", "ptD", "axis2"}) {
int varIndex =
(likelihoodVar == "mult"
? 0
Expand Down Expand Up @@ -175,7 +175,7 @@ void QGLikelihoodDBWriter::beginJob() {

// Write all categories with their histograms to file
int i = 0;
for (auto category : categories) {
for (const auto& category : categories) {
QGLikelihoodObject::Entry entry;
entry.category = category.second;
entry.histogram = transformToHistogramObject(pdfs[category.first]);
Expand Down
Loading