diff --git a/DPGAnalysis/SiStripTools/plugins/ByMultiplicityEventFilter.cc b/DPGAnalysis/SiStripTools/plugins/ByMultiplicityEventFilter.cc index afa7b39706fe1..eb651516e88a3 100644 --- a/DPGAnalysis/SiStripTools/plugins/ByMultiplicityEventFilter.cc +++ b/DPGAnalysis/SiStripTools/plugins/ByMultiplicityEventFilter.cc @@ -100,7 +100,7 @@ bool ByMultiplicityEventFilter::filter(edm::Event& iEvent, const edm::EventSe m_multiplicities.getEvent(iEvent, iSetup); bool value = m_selector(m_multiplicities); - iEvent.put(std::unique_ptr(new bool(value))); + iEvent.put(std::make_unique(value)); if (m_taggedMode) return m_forcedValue; diff --git a/DPGAnalysis/SiStripTools/plugins/TrackerDpgAnalysis.cc b/DPGAnalysis/SiStripTools/plugins/TrackerDpgAnalysis.cc index 7b2c9b19f7b48..99e42aa4ce09e 100644 --- a/DPGAnalysis/SiStripTools/plugins/TrackerDpgAnalysis.cc +++ b/DPGAnalysis/SiStripTools/plugins/TrackerDpgAnalysis.cc @@ -1508,12 +1508,12 @@ std::map TrackerDpgAnalysis::delay(const std::vector> std::hex >> dcuid; // decode delay pos = line.find("difpll"); - std::string diffs = line.substr(pos + 8, line.find(" ", pos) - pos - 9); + std::string diffs = line.substr(pos + 8, line.find(' ', pos) - pos - 9); std::istringstream diffstr(diffs); diffstr >> delay; // fill the map diff --git a/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc b/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc index fb3b58d7f5556..ec0c60640453e 100644 --- a/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc +++ b/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc @@ -16,9 +16,11 @@ #include "EgammaAnalysis/ElectronTools/interface/EpCombinationTool.h" #include "EgammaAnalysis/ElectronTools/interface/ElectronEnergyCalibratorRun2.h" -#include -#include +#include + #include +#include +#include template class CalibratedElectronProducerRun2T : public edm::stream::EDProducer<> { @@ -47,7 +49,7 @@ CalibratedElectronProducerRun2T::CalibratedElectronProducerRun2T(const edm::P conf.getParameter("isSynchronization"), conf.getParameter("correctionFile")) { if (conf.existsAs("semiDeterministic") && conf.getParameter("semiDeterministic")) { - theSemiDeterministicRng.reset(new TRandom2()); + theSemiDeterministicRng = std::make_unique(); theEnCorrectorRun2.initPrivateRng(theSemiDeterministicRng.get()); } produces >(); diff --git a/EgammaAnalysis/ElectronTools/plugins/CalibratedPhotonProducersRun2.cc b/EgammaAnalysis/ElectronTools/plugins/CalibratedPhotonProducersRun2.cc index b90030a8667ee..65c614a71c4ba 100644 --- a/EgammaAnalysis/ElectronTools/plugins/CalibratedPhotonProducersRun2.cc +++ b/EgammaAnalysis/ElectronTools/plugins/CalibratedPhotonProducersRun2.cc @@ -12,9 +12,11 @@ #include "DataFormats/PatCandidates/interface/Photon.h" #include "EgammaAnalysis/ElectronTools/interface/PhotonEnergyCalibratorRun2.h" -#include -#include +#include + #include +#include +#include template class CalibratedPhotonProducerRun2T : public edm::stream::EDProducer<> { @@ -36,7 +38,7 @@ CalibratedPhotonProducerRun2T::CalibratedPhotonProducerRun2T(const edm::Param conf.getParameter("isSynchronization"), conf.getParameter("correctionFile")) { if (conf.existsAs("semiDeterministic") && conf.getParameter("semiDeterministic")) { - theSemiDeterministicRng.reset(new TRandom2()); + theSemiDeterministicRng = std::make_unique(); theEnCorrectorRun2.initPrivateRng(theSemiDeterministicRng.get()); } produces >(); diff --git a/EgammaAnalysis/ElectronTools/src/EnergyScaleCorrection_class.cc b/EgammaAnalysis/ElectronTools/src/EnergyScaleCorrection_class.cc index 5528a77a72af3..c6a0aa5f2fde9 100644 --- a/EgammaAnalysis/ElectronTools/src/EnergyScaleCorrection_class.cc +++ b/EgammaAnalysis/ElectronTools/src/EnergyScaleCorrection_class.cc @@ -445,11 +445,11 @@ correctionCategory_class::correctionCategory_class(TString category_) { etamax = 3; } else { if (p1 != std::string::npos) { - p1 = category.find("_", p1); - p2 = category.find("_", p1 + 1); + p1 = category.find('_', p1); + p2 = category.find('_', p1 + 1); etamin = TString(category.substr(p1 + 1, p2 - p1 - 1)).Atof(); p1 = p2; - p2 = category.find("-", p1); + p2 = category.find('-', p1); etamax = TString(category.substr(p1 + 1, p2 - p1 - 1)).Atof(); } } @@ -477,11 +477,11 @@ correctionCategory_class::correctionCategory_class(TString category_) { // std::cout << "p1 = " << p1 << "\t" << std::string::npos << "\t" << category.size() << std::endl; //std::cout << etmin << "\t" << etmax << "\t" << category.substr(p1+1, p2-p1-1) << "\t" << p1 << "\t" << p2 << std::endl; if (p1 != std::string::npos) { - p1 = category.find("_", p1); - p2 = category.find("_", p1 + 1); + p1 = category.find('_', p1); + p2 = category.find('_', p1 + 1); etmin = TString(category.substr(p1 + 1, p2 - p1 - 1)).Atof(); p1 = p2; - p2 = category.find("-", p1); + p2 = category.find('-', p1); etmax = TString(category.substr(p1 + 1, p2 - p1 - 1)).Atof(); // std::cout << etmin << "\t" << etmax << "\t" << category.substr(p1 + 1, p2 - p1 - 1) << std::endl; } diff --git a/ElectroWeakAnalysis/Utilities/src/DistortedMuonProducerFromDB.cc b/ElectroWeakAnalysis/Utilities/src/DistortedMuonProducerFromDB.cc index a8b9e992c52b3..6709f7928d129 100644 --- a/ElectroWeakAnalysis/Utilities/src/DistortedMuonProducerFromDB.cc +++ b/ElectroWeakAnalysis/Utilities/src/DistortedMuonProducerFromDB.cc @@ -67,17 +67,17 @@ DistortedMuonProducerFromDB::~DistortedMuonProducerFromDB() {} void DistortedMuonProducerFromDB::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { edm::ESHandle dbObject1; iSetup.get().get(dbScaleLabel_, dbObject1); - momCorrector_.reset(new MomentumScaleCorrector(dbObject1.product())); + momCorrector_ = std::make_unique(dbObject1.product()); LogTrace("") << ">>> Using database for momentum scale corrections !!"; edm::ESHandle dbObject2; iSetup.get().get(dbDataResolutionLabel_, dbObject2); - momResolutionData_.reset(new ResolutionFunction(dbObject2.product())); + momResolutionData_ = std::make_unique(dbObject2.product()); edm::ESHandle dbObject3; iSetup.get().get(dbMCResolutionLabel_, dbObject3); - momResolutionMC_.reset(new ResolutionFunction(dbObject3.product())); + momResolutionMC_ = std::make_unique(dbObject3.product()); LogTrace("") << ">>> Using database for momentum resolution corrections !!"; } diff --git a/ElectroWeakAnalysis/ZMuMu/plugins/dimuonHLTFilterCheck.cc b/ElectroWeakAnalysis/ZMuMu/plugins/dimuonHLTFilterCheck.cc index 4eeb24633f060..f168e85063021 100644 --- a/ElectroWeakAnalysis/ZMuMu/plugins/dimuonHLTFilterCheck.cc +++ b/ElectroWeakAnalysis/ZMuMu/plugins/dimuonHLTFilterCheck.cc @@ -199,6 +199,7 @@ vector dimuonHLTFilterCheck::nDimuonsByType(const Handle d) int nCat = 10; // number of dimuon categories (0 = glb-glb, 1 = glb-trkSta, 2 = glb-sta, 3 = glb-trk, 4 = trkSta-trkSta, 5 = trkSta-sta, 6 = trkSta-trk, 7 = sta-sta, 8 = sta-trk, 9 trk-trk) // reset vector + n_.reserve(nCat); for (int i = 0; i < nCat; i++) n_.push_back(0); for (unsigned int i = 0; i < d->size(); ++i) { //loop on candidates @@ -259,6 +260,7 @@ vector dimuonHLTFilterCheck::nMuonsByType(const Handle d) { vector n_; int nCat = 4; // number of muon categories (0 = glb, 1 = trkSta, 2 = sta, 3 = trk) // reset vector + n_.reserve(nCat); for (int i = 0; i < nCat; i++) n_.push_back(0); for (unsigned int i = 0; i < d->size(); ++i) { //loop on candidates diff --git a/HeavyFlavorAnalysis/Onia2MuMu/src/OniaVtxReProducer.cc b/HeavyFlavorAnalysis/Onia2MuMu/src/OniaVtxReProducer.cc index 1358b09cf935c..5dd5d3d6660f3 100644 --- a/HeavyFlavorAnalysis/Onia2MuMu/src/OniaVtxReProducer.cc +++ b/HeavyFlavorAnalysis/Onia2MuMu/src/OniaVtxReProducer.cc @@ -1,12 +1,14 @@ -#include "HeavyFlavorAnalysis/Onia2MuMu/interface/OniaVtxReProducer.h" +#include + +#include "DataFormats/Provenance/interface/ProductProvenance.h" +#include "FWCore/Common/interface/Provenance.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/Registry.h" +#include "HeavyFlavorAnalysis/Onia2MuMu/interface/OniaVtxReProducer.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "FWCore/ParameterSet/interface/Registry.h" -#include "FWCore/Common/interface/Provenance.h" -#include "DataFormats/Provenance/interface/ProductProvenance.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" OniaVtxReProducer::OniaVtxReProducer(const edm::Handle &handle, const edm::Event &iEvent) { const edm::Provenance *prov = handle.provenance(); @@ -66,7 +68,7 @@ void OniaVtxReProducer::configure(const edm::ParameterSet &iConfig) { config_ = iConfig; tracksTag_ = iConfig.getParameter("TrackLabel"); beamSpotTag_ = iConfig.getParameter("beamSpotLabel"); - algo_.reset(new PrimaryVertexProducerAlgorithm(iConfig)); + algo_ = std::make_unique(iConfig); } std::vector OniaVtxReProducer::makeVertices(const reco::TrackCollection &tracks, diff --git a/HeavyFlavorAnalysis/RecoDecay/src/BPHDecayMomentum.cc b/HeavyFlavorAnalysis/RecoDecay/src/BPHDecayMomentum.cc index d6382890fe8c5..97f717e2be5d7 100644 --- a/HeavyFlavorAnalysis/RecoDecay/src/BPHDecayMomentum.cc +++ b/HeavyFlavorAnalysis/RecoDecay/src/BPHDecayMomentum.cc @@ -94,7 +94,7 @@ const vector& BPHDecayMomentum::daughComp() const { const reco::Candidate* BPHDecayMomentum::getDaug(const string& name) const { // return a simple particle from the name // return null pointer if not found - string::size_type pos = name.find("/"); + string::size_type pos = name.find('/'); if (pos != string::npos) { const BPHRecoCandidate* comp = getComp(name.substr(0, pos)).get(); return (comp == nullptr ? nullptr : comp->getDaug(name.substr(pos + 1))); @@ -106,7 +106,7 @@ const reco::Candidate* BPHDecayMomentum::getDaug(const string& name) const { BPHRecoConstCandPtr BPHDecayMomentum::getComp(const string& name) const { // return a previously reconstructed particle from the name // return null pointer if not found - string::size_type pos = name.find("/"); + string::size_type pos = name.find('/'); if (pos != string::npos) { const BPHRecoCandidate* comp = getComp(name.substr(0, pos)).get(); return (comp == nullptr ? nullptr : comp->getComp(name.substr(pos + 1))); diff --git a/HeavyFlavorAnalysis/RecoDecay/src/BPHKinematicFit.cc b/HeavyFlavorAnalysis/RecoDecay/src/BPHKinematicFit.cc index e35926c294468..26baac239606c 100644 --- a/HeavyFlavorAnalysis/RecoDecay/src/BPHKinematicFit.cc +++ b/HeavyFlavorAnalysis/RecoDecay/src/BPHKinematicFit.cc @@ -102,7 +102,7 @@ double BPHKinematicFit::constrSigma() const { return massSigma; } /// set a decaying daughter as an unique particle fitted independently void BPHKinematicFit::setIndependentFit(const string& name, bool flag, double mass, double sigma) { - string::size_type pos = name.find("/"); + string::size_type pos = name.find('/'); if (pos != string::npos) { edm::LogPrint("WrongRequest") << "BPHKinematicFit::setIndependentFit: " << "cascade decay specification not admitted " << name; @@ -147,7 +147,7 @@ vector BPHKinematicFit::kinParticles(const vector //////////////////////////////////////////////////////////////////////////////// -#include "JetMETCorrections/Algorithms/interface/L1FastjetCorrectorImpl.h" +#include + #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h" +#include "JetMETCorrections/Algorithms/interface/L1FastjetCorrectorImpl.h" #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h" #include "FWCore/Utilities/interface/Exception.h" @@ -39,7 +41,7 @@ std::unique_ptr L1FastjetCorrectorImplMaker::make(edm::E edm::Handle hRho; fEvent.getByToken(rhoToken_, hRho); - return std::unique_ptr(new L1FastjetCorrectorImpl(corrector, *hRho)); + return std::make_unique(corrector, *hRho); } void L1FastjetCorrectorImplMaker::fillDescriptions(edm::ConfigurationDescriptions& iDescriptions) { diff --git a/MuonAnalysis/MomentumScaleCalibration/bin/ZntupleToTreeConverter.cc b/MuonAnalysis/MomentumScaleCalibration/bin/ZntupleToTreeConverter.cc index 9e9ff821ae563..6647c7eba3318 100644 --- a/MuonAnalysis/MomentumScaleCalibration/bin/ZntupleToTreeConverter.cc +++ b/MuonAnalysis/MomentumScaleCalibration/bin/ZntupleToTreeConverter.cc @@ -147,7 +147,7 @@ int main(int argc, char* argv[]) { MuonPair(fromPtEtaPhiToPxPyPz(muon1), fromPtEtaPhiToPxPyPz(muon2), MuScleFitEvent(0, 0, 0, 0, 0, 0))); } } - size_t namePos = fileName.find_last_of("/"); + size_t namePos = fileName.find_last_of('/'); treeHandler.writeTree(("tree_" + fileName.substr(namePos + 1, fileName.size())).c_str(), &pairVector); // close input file diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/DBWriter.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/DBWriter.cc index 887f75aa5de46..0909f69070d25 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/DBWriter.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/DBWriter.cc @@ -20,11 +20,12 @@ DBWriter::DBWriter(const edm::ParameterSet& ps) { std::string type(ps.getUntrackedParameter("Type")); // Create the corrector and set the parameters if (type == "scale") - corrector_.reset(new MomentumScaleCorrector(ps.getUntrackedParameter("CorrectionsIdentifier"))); + corrector_ = + std::make_unique(ps.getUntrackedParameter("CorrectionsIdentifier")); else if (type == "resolution") - corrector_.reset(new ResolutionFunction(ps.getUntrackedParameter("CorrectionsIdentifier"))); + corrector_ = std::make_unique(ps.getUntrackedParameter("CorrectionsIdentifier")); else if (type == "background") - corrector_.reset(new BackgroundFunction(ps.getUntrackedParameter("CorrectionsIdentifier"))); + corrector_ = std::make_unique(ps.getUntrackedParameter("CorrectionsIdentifier")); else { std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl; exit(1); diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFit.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFit.cc index 7d83e57afac7e..99ad35dcaf635 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFit.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFit.cc @@ -112,6 +112,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include +#include + #include #include "FWCore/Framework/interface/EventSetup.h" @@ -556,16 +558,16 @@ MuScleFit::MuScleFit(const edm::ParameterSet& pset) : MuScleFitBase(pset), total MuScleFitUtils::massWindowHalfWidth[2][4] = 0.2; MuScleFitUtils::massWindowHalfWidth[2][5] = 0.2; - muonSelector_.reset(new MuScleFitMuonSelector(theMuonLabel_, - theMuonType_, - PATmuons_, - MuScleFitUtils::resfind, - MuScleFitUtils::speedup, - genParticlesName_, - compareToSimTracks_, - simTracksCollection_, - MuScleFitUtils::sherpa_, - debug_)); + muonSelector_ = std::make_unique(theMuonLabel_, + theMuonType_, + PATmuons_, + MuScleFitUtils::resfind, + MuScleFitUtils::speedup, + genParticlesName_, + compareToSimTracks_, + simTracksCollection_, + MuScleFitUtils::sherpa_, + debug_); MuScleFitUtils::backgroundHandler = new BackgroundHandler(pset.getParameter >("BgrFitType"), @@ -1219,6 +1221,7 @@ void MuScleFit::duringFastLoop() { double deltalike; if (loopCounter == 0) { std::vector initpar; + initpar.reserve((int)(MuScleFitUtils::parResol.size())); for (int i = 0; i < (int)(MuScleFitUtils::parResol.size()); i++) { initpar.push_back(MuScleFitUtils::parResol[i]); } diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.cc index 45dbfdec641d6..1c4805a9e8f3a 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.cc @@ -155,11 +155,14 @@ TestCorrection::TestCorrection(const edm::ParameterSet& iConfig) correctedPtVsEta_ = new TProfile("correctedPtVsEta", "corrected pt vs eta", 1000, 0, 100, -3., 3.); eventCounter_ = 0; // Create the corrector and set the parameters - corrector_.reset(new MomentumScaleCorrector(iConfig.getUntrackedParameter("CorrectionsIdentifier"))); + corrector_ = + std::make_unique(iConfig.getUntrackedParameter("CorrectionsIdentifier")); std::cout << "corrector_ = " << &*corrector_ << std::endl; - resolution_.reset(new ResolutionFunction(iConfig.getUntrackedParameter("ResolutionsIdentifier"))); + resolution_ = + std::make_unique(iConfig.getUntrackedParameter("ResolutionsIdentifier")); std::cout << "resolution_ = " << &*resolution_ << std::endl; - background_.reset(new BackgroundFunction(iConfig.getUntrackedParameter("BackgroundIdentifier"))); + background_ = + std::make_unique(iConfig.getUntrackedParameter("BackgroundIdentifier")); // Initialize the parameters of MuScleFitUtils from those saved in the functions. // MuScleFitUtils::parScale = corrector_.getFunction(0)->parameters(); diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/TestResolution.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/TestResolution.cc index e00d6b33247f6..e4e2a49b1a65e 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/TestResolution.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/TestResolution.cc @@ -3,6 +3,8 @@ #include "TestResolution.h" +#include + #include "TCanvas.h" #include "TLegend.h" @@ -30,8 +32,8 @@ TestResolution::TestResolution(const edm::ParameterSet& iConfig) sigmaPt_ = new TProfile("sigmaPtOverPt", "sigmaPt/Pt vs muon Pt", 1000, 0, 100); eventCounter_ = 0; // Create the corrector and set the parameters - resolutionFunction_.reset( - new ResolutionFunction(iConfig.getUntrackedParameter("ResolutionsIdentifier"))); + resolutionFunction_ = + std::make_unique(iConfig.getUntrackedParameter("ResolutionsIdentifier")); std::cout << "resolutionFunction_ = " << &*resolutionFunction_ << std::endl; } diff --git a/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc b/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc index 72fbc1f7065ee..20a09c07061ee 100644 --- a/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc +++ b/MuonAnalysis/MuonAssociators/plugins/MuonFSRProducer.cc @@ -191,7 +191,7 @@ double MuonFSRProducer::computeRelativeIsolation(const pat::PackedCandidate& pho const double& isoConeMin) const { double ptsum = 0; - for (auto pfcand : pfcands) { + for (const auto& pfcand : pfcands) { // Isolation cone requirement double dRIsoCone = deltaR(photon.eta(), photon.phi(), pfcand.eta(), pfcand.phi()); if (dRIsoCone > isoConeMax) diff --git a/MuonAnalysis/MuonAssociators/plugins/MuonMCClassifier.cc b/MuonAnalysis/MuonAssociators/plugins/MuonMCClassifier.cc index 59cf45ebb50a2..2b086f298ae2d 100644 --- a/MuonAnalysis/MuonAssociators/plugins/MuonMCClassifier.cc +++ b/MuonAnalysis/MuonAssociators/plugins/MuonMCClassifier.cc @@ -260,7 +260,7 @@ void MuonMCClassifier::produce(edm::Event &iEvent, const edm::EventSetup &iSetup std::map tpToSecondaries; // map from tp to (index+1) in output collection std::vector muToPrimary(nmu, -1), muToSecondary(nmu, -1); // map from input into (index) in output, -1 for null if (linkToGenParticles_) - secondaries.reset(new reco::GenParticleCollection()); + secondaries = std::make_unique(); // loop on reco muons for (size_t i = 0; i < nmu; ++i) { diff --git a/PhysicsTools/FWLite/src/CommandLineParser.cc b/PhysicsTools/FWLite/src/CommandLineParser.cc index 52c6f198be73a..6e8bcca9b52a3 100644 --- a/PhysicsTools/FWLite/src/CommandLineParser.cc +++ b/PhysicsTools/FWLite/src/CommandLineParser.cc @@ -50,7 +50,7 @@ void CommandLineParser::parseArguments(int argc, char **argv, bool returnArgs) { for (int loop = 1; loop < argc; ++loop) { string arg = argv[loop]; m_fullArgVec.push_back(arg); - string::size_type where = arg.find_first_of("="); + string::size_type where = arg.find_first_of('='); if (string::npos != where) { if (_setVariableFromString(arg)) { continue; @@ -62,7 +62,7 @@ void CommandLineParser::parseArguments(int argc, char **argv, bool returnArgs) { exit(0); } // tag=value strings else if (arg.at(0) == '-') { - string::size_type where = arg.find_first_not_of("-"); + string::size_type where = arg.find_first_not_of('-'); if (string::npos == where) { // a poorly formed option cerr << "Don't understand: " << arg << endl; @@ -147,7 +147,7 @@ void CommandLineParser::split(SVec &retval, string line, string match, bool igno } void CommandLineParser::removeComment(string &line) { - string::size_type location = line.find("#"); + string::size_type location = line.find('#'); if (string::npos != location) { // we've got a comment. Strip it out line = line.substr(0, location - 1); @@ -311,7 +311,7 @@ void CommandLineParser::printOptionValues() { } bool CommandLineParser::_setVariableFromString(const string &arg, bool dontOverrideChange, int offset) { - string::size_type where = arg.find_first_of("=", offset + 1); + string::size_type where = arg.find_first_of('=', offset + 1); string varname = arg.substr(offset, where - offset); string value = arg.substr(where + 1); lowercaseString(varname); diff --git a/PhysicsTools/HepMCCandAlgos/plugins/GenPlusSimParticleProducer.cc b/PhysicsTools/HepMCCandAlgos/plugins/GenPlusSimParticleProducer.cc index 096bc18a6cbe0..54a3625e29aa5 100644 --- a/PhysicsTools/HepMCCandAlgos/plugins/GenPlusSimParticleProducer.cc +++ b/PhysicsTools/HepMCCandAlgos/plugins/GenPlusSimParticleProducer.cc @@ -34,6 +34,7 @@ process.genParticlePlusGEANT = cms.EDProducer("GenPlusSimParticleProducer", #include "SimGeneral/HepPDTRecord/interface/PdtEntry.h" #include +#include namespace pat { class GenPlusSimParticleProducer : public edm::EDProducer { @@ -203,7 +204,7 @@ void GenPlusSimParticleProducer::produce(Event &event, const EventSetup &iSetup) std::unique_ptr simtracksTmp; const SimTrackContainer *simtracksSorted = &*simtracks; if (!__gnu_cxx::is_sorted(simtracks->begin(), simtracks->end(), LessById())) { - simtracksTmp.reset(new SimTrackContainer(*simtracks)); + simtracksTmp = std::make_unique(*simtracks); std::sort(simtracksTmp->begin(), simtracksTmp->end(), LessById()); simtracksSorted = &*simtracksTmp; } diff --git a/PhysicsTools/HepMCCandAlgos/plugins/ModelFilter.cc b/PhysicsTools/HepMCCandAlgos/plugins/ModelFilter.cc index fb2c185a53d3f..7b5081dd827b2 100644 --- a/PhysicsTools/HepMCCandAlgos/plugins/ModelFilter.cc +++ b/PhysicsTools/HepMCCandAlgos/plugins/ModelFilter.cc @@ -29,7 +29,7 @@ bool ModelFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { for (comment = product->comments_begin(); comment != product->comments_end(); comment++) { if (comment->find(modelTag_) != string::npos) { tempString = comment->substr(comment->find(modelTag_), comment->size()); - tempString = tempString.substr(0, tempString.find(" ")); + tempString = tempString.substr(0, tempString.find(' ')); parameters = split(tempString, "_"); if (parameters.size() - 1 != parameterMins_.size()) { diff --git a/PhysicsTools/Heppy/src/EGammaMvaEleEstimatorFWLite.cc b/PhysicsTools/Heppy/src/EGammaMvaEleEstimatorFWLite.cc index fe346a5b9a96c..a359f7c472340 100644 --- a/PhysicsTools/Heppy/src/EGammaMvaEleEstimatorFWLite.cc +++ b/PhysicsTools/Heppy/src/EGammaMvaEleEstimatorFWLite.cc @@ -22,6 +22,7 @@ namespace heppy { delete estimatorCSA14_; estimatorCSA14_ = nullptr; std::vector weightspaths; + weightspaths.reserve(weightsfiles.size()); for (const std::string& s : weightsfiles) { weightspaths.push_back(edm::FileInPath(s).fullPath()); } diff --git a/PhysicsTools/Heppy/src/ReclusterJets.cc b/PhysicsTools/Heppy/src/ReclusterJets.cc index 71a5e6c4e57d2..e797ed12dbc3e 100644 --- a/PhysicsTools/Heppy/src/ReclusterJets.cc +++ b/PhysicsTools/Heppy/src/ReclusterJets.cc @@ -46,6 +46,7 @@ namespace heppy { std::vector ReclusterJets::makeP4s(const std::vector &jets) { std::vector JetObjectsAll; + JetObjectsAll.reserve(jets.size()); for (const fastjet::PseudoJet &pj : jets) { JetObjectsAll.push_back(LorentzVector(pj.px(), pj.py(), pj.pz(), pj.e())); } diff --git a/PhysicsTools/Heppy/src/TriggerBitChecker.cc b/PhysicsTools/Heppy/src/TriggerBitChecker.cc index 624d154c75d4c..fbf658129b8e3 100644 --- a/PhysicsTools/Heppy/src/TriggerBitChecker.cc +++ b/PhysicsTools/Heppy/src/TriggerBitChecker.cc @@ -88,7 +88,7 @@ namespace heppy { void TriggerBitChecker::rmstar() { std::vector::iterator itp, bgp = paths_.begin(), edp = paths_.end(); for (itp = bgp; itp != edp; ++itp) { - std::string::size_type idx = itp->pathName.find("*"); + std::string::size_type idx = itp->pathName.find('*'); if (idx != std::string::npos) itp->pathName.erase(idx); } diff --git a/PhysicsTools/JetMCAlgos/plugins/CandOneToOneDeltaRMatcher.cc b/PhysicsTools/JetMCAlgos/plugins/CandOneToOneDeltaRMatcher.cc index a895e8df2b90e..1e74d90727cee 100644 --- a/PhysicsTools/JetMCAlgos/plugins/CandOneToOneDeltaRMatcher.cc +++ b/PhysicsTools/JetMCAlgos/plugins/CandOneToOneDeltaRMatcher.cc @@ -214,8 +214,10 @@ vector CandOneToOneDeltaRMatcher::AlgoBruteForce(int nMin, int nMax) { float totalDeltaR = 0; float BestTotalDeltaR = 1000; + ca.reserve(nMax); for (int i1 = 0; i1 < nMax; i1++) ca.push_back(i1); + cb.reserve(nMin); for (int i1 = 0; i1 < nMin; i1++) cb.push_back(i1); diff --git a/PhysicsTools/MVAComputer/plugins/ProcTMVA.cc b/PhysicsTools/MVAComputer/plugins/ProcTMVA.cc index 9e832f181917c..e7527ffc37ed9 100644 --- a/PhysicsTools/MVAComputer/plugins/ProcTMVA.cc +++ b/PhysicsTools/MVAComputer/plugins/ProcTMVA.cc @@ -14,6 +14,8 @@ // Created: Sat Apr 24 15:18 CEST 2007 // +#include + #include #include #include @@ -66,7 +68,7 @@ namespace { // anonymous ProcTMVA::ProcTMVA(const char *name, const Calibration::ProcExternal *calib, const MVAComputer *computer) : VarProcessor(name, calib, computer) { - reader = std::unique_ptr(new TMVA::Reader("!Color:Silent")); + reader = std::make_unique("!Color:Silent"); ext::imemstream is(reinterpret_cast(&calib->store.front()), calib->store.size()); ext::izstream izs(&is); diff --git a/PhysicsTools/MVAComputer/src/MVAComputerCache.cc b/PhysicsTools/MVAComputer/src/MVAComputerCache.cc index e9f1509d7b937..02fe50be4d286 100644 --- a/PhysicsTools/MVAComputer/src/MVAComputerCache.cc +++ b/PhysicsTools/MVAComputer/src/MVAComputerCache.cc @@ -19,7 +19,7 @@ namespace PhysicsTools { return false; if (computer) { - this->computer.reset(new MVAComputer(computer)); + this->computer = std::make_unique(computer); computerCacheId = computer->getCacheId(); } else { this->computer.reset(); diff --git a/PhysicsTools/RecoAlgos/src/MassKinFitterCandProducer.cc b/PhysicsTools/RecoAlgos/src/MassKinFitterCandProducer.cc index 90c4fa15d855a..12de819e90c56 100644 --- a/PhysicsTools/RecoAlgos/src/MassKinFitterCandProducer.cc +++ b/PhysicsTools/RecoAlgos/src/MassKinFitterCandProducer.cc @@ -1,13 +1,15 @@ -#include "PhysicsTools/RecoAlgos/interface/MassKinFitterCandProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include + #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "PhysicsTools/RecoAlgos/interface/MassKinFitterCandProducer.h" MassKinFitterCandProducer::MassKinFitterCandProducer(const edm::ParameterSet& cfg, CandMassKinFitter* f) : srcToken_(consumes(cfg.getParameter("src"))), fitter_(f) { if (f == nullptr) - fitter_.reset(new CandMassKinFitter(cfg.getParameter("mass"))); + fitter_ = std::make_unique(cfg.getParameter("mass")); produces(); } diff --git a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc index 7baf173bb5375..73de7d0ce0d8a 100644 --- a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc +++ b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc @@ -112,7 +112,7 @@ TagProbeFitTreeProducer::TagProbeFitTreeProducer(const edm::ParameterSet& iConfi // For unbiased efficiency we also need the collection of all probes if (makeMCUnbiasTree_) { allProbesToken_ = consumes(iConfig.getParameter("allProbes")); - mcUnbiasFiller_.reset(new tnp::BaseTreeFiller("mcUnbias_tree", iConfig, consumesCollector())); + mcUnbiasFiller_ = std::make_unique("mcUnbias_tree", iConfig, consumesCollector()); } } @@ -122,7 +122,7 @@ TagProbeFitTreeProducer::TagProbeFitTreeProducer(const edm::ParameterSet& iConfi if (iConfig.existsAs("tagFlags")) tagPSet.addParameter("flags", iConfig.getParameter("tagFlags")); if (!tagPSet.empty()) { - tagFiller_.reset(new tnp::BaseTreeFiller(*treeFiller_, tagPSet, consumesCollector(), "tag_")); + tagFiller_ = std::make_unique(*treeFiller_, tagPSet, consumesCollector(), "tag_"); } edm::ParameterSet mcPSet; if (iConfig.existsAs("mcVariables")) @@ -130,7 +130,7 @@ TagProbeFitTreeProducer::TagProbeFitTreeProducer(const edm::ParameterSet& iConfi if (iConfig.existsAs("mcFlags")) mcPSet.addParameter("flags", iConfig.getParameter("mcFlags")); if (!mcPSet.empty()) { - mcFiller_.reset(new tnp::BaseTreeFiller(*treeFiller_, mcPSet, consumesCollector(), "mc_")); + mcFiller_ = std::make_unique(*treeFiller_, mcPSet, consumesCollector(), "mc_"); } edm::ParameterSet pairPSet; if (iConfig.existsAs("pairVariables")) @@ -138,7 +138,7 @@ TagProbeFitTreeProducer::TagProbeFitTreeProducer(const edm::ParameterSet& iConfi if (iConfig.existsAs("pairFlags")) pairPSet.addParameter("flags", iConfig.getParameter("pairFlags")); if (!pairPSet.empty()) { - pairFiller_.reset(new tnp::BaseTreeFiller(*treeFiller_, pairPSet, consumesCollector(), "pair_")); + pairFiller_ = std::make_unique(*treeFiller_, pairPSet, consumesCollector(), "pair_"); } } diff --git a/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc b/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc index aa51c91d5c5b7..1173ad14bbc28 100644 --- a/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc +++ b/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc @@ -1,4 +1,6 @@ #include "PhysicsTools/TagAndProbe/interface/TagProbeFitter.h" +#include + #include //#include "TagProbeFitter.h" @@ -570,7 +572,7 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar const RooArgSet* dataObs = data->get(0); // remove everything which is not a dependency of the pdf RooArgSet* obs = w->pdf("simPdf")->getObservables(dataObs); - bdata.reset(new RooDataHist("data_binned", "data_binned", *obs, *data)); + bdata = std::make_unique("data_binned", "data_binned", *obs, *data); w->import(*bdata); data = w->data("data_binned"); delete obs; diff --git a/PhysicsTools/UtilAlgos/src/StringBasedNTupler.cc b/PhysicsTools/UtilAlgos/src/StringBasedNTupler.cc index de10b1fa15773..6ea736fab0b3c 100644 --- a/PhysicsTools/UtilAlgos/src/StringBasedNTupler.cc +++ b/PhysicsTools/UtilAlgos/src/StringBasedNTupler.cc @@ -29,6 +29,8 @@ #include #include +#include + //-------------------------------------------------------------------------------- //just define here a list of objects you would like to be able to have a branch of //-------------------------------------------------------------------------------- @@ -69,7 +71,7 @@ TreeBranch::value TreeBranch::branch(const edm::Event& iEvent) { else ANOTHER_VECTOR_CLASS(reco::CaloCluster); else { edm::LogError("TreeBranch") << branchName() << " failed to recognized class type: " << class_; - return TreeBranch::value(new std::vector()); + return std::make_unique>(); } } #undef ANOTHER_CLASS diff --git a/TopQuarkAnalysis/TopEventProducers/src/PseudoTopProducer.cc b/TopQuarkAnalysis/TopEventProducers/src/PseudoTopProducer.cc index 777e8831ba53b..1782742406d1b 100644 --- a/TopQuarkAnalysis/TopEventProducers/src/PseudoTopProducer.cc +++ b/TopQuarkAnalysis/TopEventProducers/src/PseudoTopProducer.cc @@ -363,7 +363,7 @@ void PseudoTopProducer::produce(edm::Event& event, const edm::EventSetup& eventS // Calculate MET double metX = 0, metY = 0; - for (auto neutrino : *neutrinos) { + for (const auto& neutrino : *neutrinos) { metX += neutrino.px(); metY += neutrino.py(); } diff --git a/TopQuarkAnalysis/TopJetCombination/src/TtFullHadHypothesis.cc b/TopQuarkAnalysis/TopJetCombination/src/TtFullHadHypothesis.cc index ca5119c05f983..2df96d060365f 100644 --- a/TopQuarkAnalysis/TopJetCombination/src/TtFullHadHypothesis.cc +++ b/TopQuarkAnalysis/TopJetCombination/src/TtFullHadHypothesis.cc @@ -166,8 +166,8 @@ void TtFullHadHypothesis::setCandidate(const edm::Handle > edm::Ptr ptr = edm::Ptr(handle, idx); // disentangle the correction from the potential flavor tag // by the separating ':'; the flavor tag can be empty though - std::string step = correctionLevel.substr(0, correctionLevel.find(":")); - std::string flavor = correctionLevel.substr(1 + correctionLevel.find(":")); + std::string step = correctionLevel.substr(0, correctionLevel.find(':')); + std::string flavor = correctionLevel.substr(1 + correctionLevel.find(':')); float corrFactor = 1.; if (flavor == "wMix") corrFactor = 0.75 * ptr->jecFactor(step, "uds") + 0.25 * ptr->jecFactor(step, "charm"); diff --git a/TopQuarkAnalysis/TopJetCombination/src/TtSemiLepHypothesis.cc b/TopQuarkAnalysis/TopJetCombination/src/TtSemiLepHypothesis.cc index abeb3f9116161..06597a9a20516 100644 --- a/TopQuarkAnalysis/TopJetCombination/src/TtSemiLepHypothesis.cc +++ b/TopQuarkAnalysis/TopJetCombination/src/TtSemiLepHypothesis.cc @@ -213,8 +213,8 @@ void TtSemiLepHypothesis::setCandidate(const edm::Handle > edm::Ptr ptr = edm::Ptr(handle, idx); // disentangle the correction from the potential flavor tag // by the separating ':'; the flavor tag can be empty though - std::string step = correctionLevel.substr(0, correctionLevel.find(":")); - std::string flavor = correctionLevel.substr(1 + correctionLevel.find(":")); + std::string step = correctionLevel.substr(0, correctionLevel.find(':')); + std::string flavor = correctionLevel.substr(1 + correctionLevel.find(':')); float corrFactor = 1.; if (flavor == "wMix") corrFactor = 0.75 * ptr->jecFactor(step, "uds") + 0.25 * ptr->jecFactor(step, "charm");