diff --git a/DataFormats/JetReco/src/CaloJet.cc b/DataFormats/JetReco/src/CaloJet.cc index cbb87c6ea77fd..5f73068ab7ef1 100644 --- a/DataFormats/JetReco/src/CaloJet.cc +++ b/DataFormats/JetReco/src/CaloJet.cc @@ -77,6 +77,7 @@ CaloTowerPtr CaloJet::getCaloConstituent(unsigned fIndex) const { std::vector CaloJet::getCaloConstituents() const { std::vector result; + result.reserve(numberOfDaughters()); for (unsigned i = 0; i < numberOfDaughters(); i++) result.push_back(getCaloConstituent(i)); return result; @@ -115,6 +116,7 @@ std::string CaloJet::print() const { std::vector CaloJet::getTowerIndices() const { std::vector result; std::vector towers = getCaloConstituents(); + result.reserve(towers.size()); for (unsigned i = 0; i < towers.size(); ++i) { result.push_back(towers[i]->id()); } diff --git a/DataFormats/JetReco/src/GenJet.cc b/DataFormats/JetReco/src/GenJet.cc index 7cbab4f9ec78e..84f067ceb3838 100644 --- a/DataFormats/JetReco/src/GenJet.cc +++ b/DataFormats/JetReco/src/GenJet.cc @@ -50,6 +50,7 @@ const GenParticle* GenJet::getGenConstituent(unsigned fIndex) const { std::vector GenJet::getGenConstituents() const { std::vector result; + result.reserve(numberOfDaughters()); for (unsigned i = 0; i < numberOfDaughters(); i++) result.push_back(getGenConstituent(i)); return result; diff --git a/DataFormats/JetReco/src/PFJet.cc b/DataFormats/JetReco/src/PFJet.cc index 8756c09c38dbc..e5f0c62839870 100644 --- a/DataFormats/JetReco/src/PFJet.cc +++ b/DataFormats/JetReco/src/PFJet.cc @@ -40,6 +40,7 @@ reco::PFCandidatePtr PFJet::getPFConstituent(unsigned fIndex) const { std::vector PFJet::getPFConstituents() const { std::vector result; + result.reserve(numberOfDaughters()); for (unsigned i = 0; i < numberOfDaughters(); i++) result.push_back(getPFConstituent(i)); return result; diff --git a/DataFormats/JetReco/src/TrackJet.cc b/DataFormats/JetReco/src/TrackJet.cc index 1e6d885d4c118..88a15c31d0bd2 100644 --- a/DataFormats/JetReco/src/TrackJet.cc +++ b/DataFormats/JetReco/src/TrackJet.cc @@ -41,6 +41,7 @@ edm::Ptr reco::TrackJet::track(size_t i) const { std::vector > reco::TrackJet::tracks() const { std::vector > result; + result.reserve(numberOfDaughters()); for (unsigned i = 0; i < numberOfDaughters(); i++) result.push_back(track(i)); return result; diff --git a/DataFormats/ParticleFlowCandidate/src/PFCandidate.cc b/DataFormats/ParticleFlowCandidate/src/PFCandidate.cc index 467ac284eea93..8763e0a2324c2 100644 --- a/DataFormats/ParticleFlowCandidate/src/PFCandidate.cc +++ b/DataFormats/ParticleFlowCandidate/src/PFCandidate.cc @@ -332,7 +332,7 @@ ostream& reco::operator<<(ostream& out, const PFCandidate& c) { out << ", blocks/iele: "; - PFCandidate::ElementsInBlocks eleInBlocks = c.elementsInBlocks(); + const PFCandidate::ElementsInBlocks& eleInBlocks = c.elementsInBlocks(); for (unsigned i = 0; i < eleInBlocks.size(); i++) { PFBlockRef blockRef = eleInBlocks[i].first; unsigned indexInBlock = eleInBlocks[i].second; diff --git a/DataFormats/TauReco/src/PFTauDecayMode.cc b/DataFormats/TauReco/src/PFTauDecayMode.cc index fa56445923d16..33ce83ced83fa 100644 --- a/DataFormats/TauReco/src/PFTauDecayMode.cc +++ b/DataFormats/TauReco/src/PFTauDecayMode.cc @@ -45,6 +45,7 @@ namespace reco { std::vector PFTauDecayMode::chargedPionCandidates() const { size_type numberOfChargedPions = chargedPions_.numberOfDaughters(); std::vector output; + output.reserve(numberOfChargedPions); for (size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand) output.push_back(chargedPions_.daughter(iterCand)); return output; @@ -53,6 +54,7 @@ namespace reco { std::vector PFTauDecayMode::neutralPionCandidates() const { size_type numberOfChargedPions = piZeroes_.numberOfDaughters(); std::vector output; + output.reserve(numberOfChargedPions); for (size_type iterCand = 0; iterCand < numberOfChargedPions; ++iterCand) output.push_back(piZeroes_.daughter(iterCand)); return output; diff --git a/EventFilter/CSCRawToDigi/src/CSCCFEBData.cc b/EventFilter/CSCRawToDigi/src/CSCCFEBData.cc index 335d768028014..b0638c2db7821 100644 --- a/EventFilter/CSCRawToDigi/src/CSCCFEBData.cc +++ b/EventFilter/CSCRawToDigi/src/CSCCFEBData.cc @@ -80,7 +80,7 @@ CSCCFEBData::CSCCFEBData(unsigned number, bool sixteenSamples, uint16_t format_v } void CSCCFEBData::add(const CSCStripDigi &digi, int layer) { - std::vector scaCounts = digi.getADCCounts(); + const std::vector &scaCounts = digi.getADCCounts(); for (unsigned itime = 0; itime < theNumberOfSamples; ++itime) { unsigned channel = (digi.getStrip() - 1) % 16 + 1; unsigned value = scaCounts[itime] & 0xFFF; // 12-bit diff --git a/JetMETCorrections/Modules/plugins/JetResolutionDemo.cc b/JetMETCorrections/Modules/plugins/JetResolutionDemo.cc index 7d302ee797c0a..b262d503aea00 100644 --- a/JetMETCorrections/Modules/plugins/JetResolutionDemo.cc +++ b/JetMETCorrections/Modules/plugins/JetResolutionDemo.cc @@ -120,6 +120,7 @@ void JetResolutionDemo::analyze(const edm::Event& iEvent, const edm::EventSetup& } std::vector res; + res.reserve(40); for (std::size_t i = 0; i < 40; i++) { res.push_back(i * 0.005); } diff --git a/MagneticField/GeomBuilder/src/bLayer.cc b/MagneticField/GeomBuilder/src/bLayer.cc index 7df2216eedcff..aba5a9aa706d2 100644 --- a/MagneticField/GeomBuilder/src/bLayer.cc +++ b/MagneticField/GeomBuilder/src/bLayer.cc @@ -141,6 +141,7 @@ MagBLayer* bLayer::buildMagBLayer() const { // If we have several sectors, create the MagBSector std::vector mSectors; + mSectors.reserve(sectors.size()); for (unsigned int i = 0; i < sectors.size(); ++i) { mSectors.push_back(sectors[i].buildMagBSector()); } diff --git a/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc b/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc index b3668635770ce..e69e46983c337 100644 --- a/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc +++ b/RecoBTag/SecondaryVertex/plugins/TemplatedSecondaryVertexProducer.cc @@ -546,6 +546,7 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con std::vector dR2toSubjets; + dR2toSubjets.reserve(subjetIndices.at(i).size()); for (size_t sj = 0; sj < subjetIndices.at(i).size(); ++sj) dR2toSubjets.push_back(Geom::deltaR2(p.rapidity(), p.phi_std(), @@ -671,6 +672,7 @@ void TemplatedSecondaryVertexProducer::produce(edm::Event &event, con std::vector dR2toSubjets; + dR2toSubjets.reserve(subjetIndices.at(i).size()); for (size_t sj = 0; sj < subjetIndices.at(i).size(); ++sj) dR2toSubjets.push_back(Geom::deltaR2(p.rapidity(), p.phi_std(), diff --git a/RecoEcal/EgammaClusterAlgos/src/HybridClusterAlgo.cc b/RecoEcal/EgammaClusterAlgos/src/HybridClusterAlgo.cc index f50042c2c9fbf..403f4ea789afa 100644 --- a/RecoEcal/EgammaClusterAlgos/src/HybridClusterAlgo.cc +++ b/RecoEcal/EgammaClusterAlgos/src/HybridClusterAlgo.cc @@ -390,7 +390,7 @@ void HybridClusterAlgo::mainSearch(const EcalRecHitCollection* hits, const CaloS int nhits = 0; for (int j = 0; j < int(dominoEnergy.size()); ++j) { if (OwnerShip[j] == i) { - std::vector temp = dominoCells[j]; + const std::vector& temp = dominoCells[j]; for (int k = 0; k < int(temp.size()); ++k) { dets.push_back(std::pair(temp[k].id(), 1.)); // by default energy fractions are 1 if (temp[k].id() == itID) @@ -471,7 +471,7 @@ reco::SuperClusterCollection HybridClusterAlgo::makeSuperClusters(const reco::Ca //supercluster. This could be somehow more efficient. for (int i = 0; i < int(thiscoll.size()); ++i) { - reco::BasicCluster thisclus = thiscoll[i]; //The Cluster in question. + const reco::BasicCluster& thisclus = thiscoll[i]; //The Cluster in question. for (int j = 0; j < int(clustersCollection.size()); ++j) { //Find the appropriate cluster from the list of references reco::BasicCluster cluster_p = *clustersCollection[j]; diff --git a/RecoEcal/EgammaClusterProducers/src/EcalBasicClusterLocalContCorrection.cc b/RecoEcal/EgammaClusterProducers/src/EcalBasicClusterLocalContCorrection.cc index d4c6f319e541c..eb21378d8566f 100644 --- a/RecoEcal/EgammaClusterProducers/src/EcalBasicClusterLocalContCorrection.cc +++ b/RecoEcal/EgammaClusterProducers/src/EcalBasicClusterLocalContCorrection.cc @@ -54,7 +54,7 @@ float EcalBasicClusterLocalContCorrection::operator()(const reco::BasicCluster & //search which crystal is closest to the cluster position and call it crystalseed: //std::vector crystals_vector = *scRef.getHitsByDetId(); //deprecated - std::vector > crystals_vector = basicCluster.hitsAndFractions(); + const std::vector > &crystals_vector = basicCluster.hitsAndFractions(); float dphimin = 999.; float detamin = 999.; int ietaclosest = 0; diff --git a/RecoEcal/EgammaClusterProducers/src/EcalDigiSelector.cc b/RecoEcal/EgammaClusterProducers/src/EcalDigiSelector.cc index b5d5eb92d46b0..f6be8c8351632 100644 --- a/RecoEcal/EgammaClusterProducers/src/EcalDigiSelector.cc +++ b/RecoEcal/EgammaClusterProducers/src/EcalDigiSelector.cc @@ -155,7 +155,7 @@ void EcalDigiSelector::produce(edm::Event& evt, const edm::EventSetup& es) { std::vector saveTheseDetIds; //pick out the detids for the 3x3 in each of the selected superclusters for (int loop = 0; loop < int(saveBarrelSuperClusters.size()); loop++) { - SuperCluster clus1 = saveBarrelSuperClusters[loop]; + const SuperCluster& clus1 = saveBarrelSuperClusters[loop]; const CaloClusterPtr& bcref = clus1.seed(); const BasicCluster* bc = bcref.get(); //Get the maximum detid @@ -206,7 +206,7 @@ void EcalDigiSelector::produce(edm::Event& evt, const edm::EventSetup& es) { std::set saveTheseDetIds; //pick out the digis for the 3x3 in each of the selected superclusters for (int loop = 0; loop < int(saveEndcapSuperClusters.size()); loop++) { - SuperCluster clus1 = saveEndcapSuperClusters[loop]; + const SuperCluster& clus1 = saveEndcapSuperClusters[loop]; const CaloClusterPtr& bcref = clus1.seed(); const BasicCluster* bc = bcref.get(); //Get the maximum detid diff --git a/RecoEcal/EgammaClusterProducers/src/UncleanSCRecoveryProducer.cc b/RecoEcal/EgammaClusterProducers/src/UncleanSCRecoveryProducer.cc index 42e16a819b095..87a2c7ded9300 100644 --- a/RecoEcal/EgammaClusterProducers/src/UncleanSCRecoveryProducer.cc +++ b/RecoEcal/EgammaClusterProducers/src/UncleanSCRecoveryProducer.cc @@ -220,7 +220,7 @@ void UncleanSCRecoveryProducer::produce(edm::StreamID, edm::Event& evt, const ed // the new collection LogTrace("EcalCleaning") << "The new SC clean collection with size " << superClusters.size(); for (unsigned int i = 0; i < superClusters.size(); ++i) { - const reco::SuperCluster nsc = superClusters[i]; + const reco::SuperCluster& nsc = superClusters[i]; LogTrace("EcalCleaning") << " >>> newSC #" << i << "; Energy: " << nsc.energy() << " eta: " << nsc.eta() << " isClean=" << nsc.isInClean() << " isUnclean=" << nsc.isInUnclean() << " sc seed detid: " << nsc.seed()->seed().rawId(); diff --git a/RecoEcal/EgammaClusterProducers/src/UnifiedSCCollectionProducer.cc b/RecoEcal/EgammaClusterProducers/src/UnifiedSCCollectionProducer.cc index 719e8cac7c429..07c784b73eae9 100644 --- a/RecoEcal/EgammaClusterProducers/src/UnifiedSCCollectionProducer.cc +++ b/RecoEcal/EgammaClusterProducers/src/UnifiedSCCollectionProducer.cc @@ -432,7 +432,7 @@ void UnifiedSCCollectionProducer::produce(edm::Event& evt, const edm::EventSetup } LogTrace("UnifiedSC") << "The new SC unclean only collection with size " << superClustersUncleanOnly.size(); for (int i = 0; i < (int)superClustersUncleanOnly.size(); ++i) { - const reco::SuperCluster nsc = superClustersUncleanOnly[i]; + const reco::SuperCluster& nsc = superClustersUncleanOnly[i]; LogTrace("UnifiedSC") << " >>> newSC #" << i << "; Energy: " << nsc.energy() << " eta: " << nsc.eta() << " isClean=" << nsc.isInClean() << " isUnclean=" << nsc.isInUnclean() << " sc seed detid: " << nsc.seed()->seed().rawId(); diff --git a/RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrection.cc b/RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrection.cc index b29889ed6b1a5..866eb6b5b7743 100644 --- a/RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrection.cc +++ b/RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrection.cc @@ -95,7 +95,7 @@ float EcalClusterCrackCorrection::getValue(const reco::CaloCluster &seedbclus) c //search which crystal is closest to the cluster position and call it crystalseed: //std::vector crystals_vector = seedbclus.getHitsByDetId(); //deprecated - std::vector > crystals_vector = seedbclus.hitsAndFractions(); + const std::vector > &crystals_vector = seedbclus.hitsAndFractions(); float dphimin = 999.; float detamin = 999.; int ietaclosest = 0; diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedValueMapsProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedValueMapsProducer.cc index 876b71a6a143b..5e206f5453c70 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedValueMapsProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedValueMapsProducer.cc @@ -80,6 +80,7 @@ void LowPtGsfElectronSeedValueMapsProducer::produce(edm::Event& event, const edm // Iterate through GsfTracks, extract BDT output, and store result in ValueMap for each model std::vector > output; + output.reserve(names_.size()); for (unsigned int iname = 0; iname < names_.size(); ++iname) { output.push_back(std::vector(gsfTracks->size(), -999.)); } diff --git a/RecoEgamma/EgammaIsolationAlgos/src/ElectronTkIsolation.cc b/RecoEgamma/EgammaIsolationAlgos/src/ElectronTkIsolation.cc index 83603acd1a847..8e35620f167c4 100644 --- a/RecoEgamma/EgammaIsolationAlgos/src/ElectronTkIsolation.cc +++ b/RecoEgamma/EgammaIsolationAlgos/src/ElectronTkIsolation.cc @@ -47,7 +47,7 @@ std::pair ElectronTkIsolation::getIso(const reco::Track* tmpTrack) int counter = 0; double ptSum = 0.; //Take the electron track - math::XYZVector tmpElectronMomentumAtVtx = (*tmpTrack).momentum(); + const math::XYZVector& tmpElectronMomentumAtVtx = (*tmpTrack).momentum(); double tmpElectronEtaAtVertex = (*tmpTrack).eta(); for (reco::TrackCollection::const_iterator itrTr = (*trackCollection_).begin(); itrTr != (*trackCollection_).end(); diff --git a/RecoEgamma/EgammaPhotonAlgos/src/ConversionVertexFinder.cc b/RecoEgamma/EgammaPhotonAlgos/src/ConversionVertexFinder.cc index 97dc951596ced..1ae9094bc2167 100644 --- a/RecoEgamma/EgammaPhotonAlgos/src/ConversionVertexFinder.cc +++ b/RecoEgamma/EgammaPhotonAlgos/src/ConversionVertexFinder.cc @@ -34,7 +34,7 @@ ConversionVertexFinder::~ConversionVertexFinder() { } bool ConversionVertexFinder::run(const std::vector& _pair, reco::Vertex& the_vertex) { - std::vector pair = _pair; + const std::vector& pair = _pair; bool found = false; if (pair.size() < 2) diff --git a/RecoEgamma/EgammaPhotonProducers/src/ConversionTrackMerger.cc b/RecoEgamma/EgammaPhotonProducers/src/ConversionTrackMerger.cc index e18b6ae845c82..e4b21cdb7e084 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/ConversionTrackMerger.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/ConversionTrackMerger.cc @@ -111,10 +111,12 @@ void ConversionTrackMerger::produce(edm::Event& e, const edm::EventSetup& es) { int i; std::vector selected1; + selected1.reserve(tC1.size()); for (unsigned int i = 0; i < tC1.size(); ++i) { selected1.push_back(1); } std::vector selected2; + selected2.reserve(tC2.size()); for (unsigned int i = 0; i < tC2.size(); ++i) { selected2.push_back(1); } diff --git a/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc b/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc index b049226a61ab5..f096910e25a13 100644 --- a/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc +++ b/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc @@ -35,7 +35,7 @@ namespace egammaTools { double depth = X0 * (T0 + log(bclus.energy())); //find max energy crystal - std::vector > crystals_vector = bclus.hitsAndFractions(); + const std::vector > &crystals_vector = bclus.hitsAndFractions(); float drmin = 999.; EBDetId crystalseed; //printf("starting loop over crystals, etot = %5f:\n",bclus.energy()); @@ -115,7 +115,7 @@ namespace egammaTools { double depth = X0 * (T0 + log(bclus.energy())); //find max energy crystal - std::vector > crystals_vector = bclus.hitsAndFractions(); + const std::vector > &crystals_vector = bclus.hitsAndFractions(); float drmin = 999.; EEDetId crystalseed; //printf("starting loop over crystals, etot = %5f:\n",bclus.energy()); diff --git a/RecoHGCal/TICL/plugins/TICLDumper.cc b/RecoHGCal/TICL/plugins/TICLDumper.cc index d5ade9074b4d0..c714ab4f66bdd 100644 --- a/RecoHGCal/TICL/plugins/TICLDumper.cc +++ b/RecoHGCal/TICL/plugins/TICLDumper.cc @@ -391,6 +391,7 @@ class TracksterDumperHelper { } std::vector id_probs; + id_probs.reserve(8); for (size_t i = 0; i < 8; i++) id_probs.push_back(trackster_iterator->id_probabilities(i)); trackster_id_probabilities.push_back(id_probs); diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc index 0619053e48663..f8f3ab424ef16 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc @@ -448,6 +448,7 @@ void TracksterLinkingbySkeletons::linkTracksters( std::vector isRootTracksters(tracksters.size(), 1); std::vector allNodes; + allNodes.reserve(tracksters.size()); for (size_t it = 0; it < tracksters.size(); ++it) { allNodes.emplace_back(it); } diff --git a/RecoHI/HiJetAlgos/plugins/HiPuRhoProducer.cc b/RecoHI/HiJetAlgos/plugins/HiPuRhoProducer.cc index f249f5d13b82f..3dc65b7d3421c 100644 --- a/RecoHI/HiJetAlgos/plugins/HiPuRhoProducer.cc +++ b/RecoHI/HiJetAlgos/plugins/HiPuRhoProducer.cc @@ -501,6 +501,7 @@ void HiPuRhoProducer::putRho(edm::Event& iEvent, const edm::EventSetup& iSetup) std::size_t size = etaEdgeLow_.size(); std::vector> order; + order.reserve(size); for (std::size_t i = 0; i < size; ++i) { order.emplace_back(i, etaEdgeLow_[i]); } diff --git a/RecoJets/JetAlgorithms/src/CATopJetAlgorithm.cc b/RecoJets/JetAlgorithms/src/CATopJetAlgorithm.cc index ddbed8c43464f..844d7cf89ee14 100644 --- a/RecoJets/JetAlgorithms/src/CATopJetAlgorithm.cc +++ b/RecoJets/JetAlgorithms/src/CATopJetAlgorithm.cc @@ -116,7 +116,7 @@ void CATopJetAlgorithm::run(const vector& cell_particles, if (verbose_) cout << "\nJet " << i << endl; i++; - fastjet::PseudoJet localJet = *jetIt; + const fastjet::PseudoJet& localJet = *jetIt; // Get the 4-vector for this jet p4_hardJets.push_back(math::XYZTLorentzVector(localJet.px(), localJet.py(), localJet.pz(), localJet.e())); diff --git a/RecoJets/JetAlgorithms/src/CATopJetHelper.cc b/RecoJets/JetAlgorithms/src/CATopJetHelper.cc index 3543c405c6365..5b64403ad993a 100644 --- a/RecoJets/JetAlgorithms/src/CATopJetHelper.cc +++ b/RecoJets/JetAlgorithms/src/CATopJetHelper.cc @@ -23,13 +23,13 @@ reco::CATopJetProperties CATopJetHelper::operator()(reco::Jet const& ihardJet) c // Now look at the subjets that were formed for (int isub = 0; isub < 2; ++isub) { // Get this subjet - reco::Jet::Constituent icandJet = subjets[isub]; + const reco::Jet::Constituent& icandJet = subjets[isub]; // Now look at the "other" subjets than this one, form the minimum invariant mass // pairing, as well as the "closest" combination to the W mass for (int jsub = isub + 1; jsub < 3; ++jsub) { // Get the second subjet - reco::Jet::Constituent jcandJet = subjets[jsub]; + const reco::Jet::Constituent& jcandJet = subjets[jsub]; reco::Candidate::LorentzVector wCand = icandJet->p4() + jcandJet->p4(); diff --git a/RecoJets/JetProducers/src/JetMatchingTools.cc b/RecoJets/JetProducers/src/JetMatchingTools.cc index 5247595ac3bee..cfa23032810ce 100644 --- a/RecoJets/JetProducers/src/JetMatchingTools.cc +++ b/RecoJets/JetProducers/src/JetMatchingTools.cc @@ -155,6 +155,7 @@ const reco::CandidateCollection* JetMatchingTools::getGenParticlesCollection() { std::vector JetMatchingTools::getConstituents(const reco::CaloJet& fJet) { std::vector result; std::vector constituents = fJet.getCaloConstituents(); + result.reserve(constituents.size()); for (unsigned i = 0; i < constituents.size(); ++i) result.push_back(&*(constituents[i])); return result; diff --git a/RecoJets/JetProducers/src/PileupJPTJetIdAlgo.cc b/RecoJets/JetProducers/src/PileupJPTJetIdAlgo.cc index 707fdf4d0c7fe..51e88e17bcfdb 100644 --- a/RecoJets/JetProducers/src/PileupJPTJetIdAlgo.cc +++ b/RecoJets/JetProducers/src/PileupJPTJetIdAlgo.cc @@ -108,7 +108,7 @@ namespace cms { std::cout << "================ jetEta = " << (*jet).eta() << std::endl; } - const edm::RefToBase jptjetRef = jet->getCaloJetRef(); + const edm::RefToBase& jptjetRef = jet->getCaloJetRef(); reco::CaloJet const* rawcalojet = dynamic_cast(&*jptjetRef); int ncalotowers = 0.; @@ -196,7 +196,7 @@ namespace cms { double detatr1 = 0.; double dphidetatr = 0.; - const reco::TrackRefVector pioninin = (*jet).getPionsInVertexInCalo(); + const reco::TrackRefVector& pioninin = (*jet).getPionsInVertexInCalo(); for (reco::TrackRefVector::const_iterator it = pioninin.begin(); it != pioninin.end(); it++) { if ((*it)->pt() > 0.5 && ((*it)->ptError() / (*it)->pt()) < 0.05) { @@ -221,7 +221,7 @@ namespace cms { } } // pioninin - const reco::TrackRefVector pioninout = (*jet).getPionsInVertexOutCalo(); + const reco::TrackRefVector& pioninout = (*jet).getPionsInVertexOutCalo(); for (reco::TrackRefVector::const_iterator it = pioninout.begin(); it != pioninout.end(); it++) { if ((*it)->pt() > 0.5 && ((*it)->ptError() / (*it)->pt()) < 0.05) { diff --git a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc index 0babbd435bb58..44fd60f664950 100644 --- a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc +++ b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc @@ -526,6 +526,7 @@ void CaloTowersCreationAlgo::rescaleTowers(const CaloTowerCollection& ctc, CaloT theTowerTopology->lastHORing()); std::vector contains; + contains.reserve(ctcItr->constituentsSize()); for (unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) { contains.push_back(ctcItr->constituent(iConst)); } diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index 7115427a53809..3c2b53e487d86 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -608,6 +608,7 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, } else if (timealgo_ == weightsMethod) { // weights method on the PU subtracted pulse shape std::vector amplitudes; + amplitudes.reserve(activeBX.size()); for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx) amplitudes.push_back(uncalibRecHit.outOfTimeAmplitude(ibx)); diff --git a/RecoLocalCalo/HcalLaserReco/src/HcalLaserUnpacker.cc b/RecoLocalCalo/HcalLaserReco/src/HcalLaserUnpacker.cc index 2bc4b056ff141..f8e48836269ad 100644 --- a/RecoLocalCalo/HcalLaserReco/src/HcalLaserUnpacker.cc +++ b/RecoLocalCalo/HcalLaserReco/src/HcalLaserUnpacker.cc @@ -22,6 +22,7 @@ void HcalLaserUnpacker::unpack(const FEDRawData& raw, HcalLaserDigi& digi) const // first, we do the QADC std::vector qadcvals; + qadcvals.reserve(qdctdc->n_qdc_hits); for (unsigned int i = 0; i < qdctdc->n_qdc_hits; i++) { qadcvals.push_back(qdctdc->qdc_values[i] & 0xFFF); } diff --git a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc index 44040d96b24ed..4f4b9872e0aff 100644 --- a/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc +++ b/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc @@ -1559,7 +1559,7 @@ TrajectoryStateOnSurface CSCEfficiency::propagate(FreeTrajectoryState &ftsStart, // bool CSCEfficiency::applyTrigger(edm::Handle &hltR, const edm::TriggerNames &triggerNames) { bool triggerPassed = true; - std::vector hlNames = triggerNames.triggerNames(); + const std::vector &hlNames = triggerNames.triggerNames(); pointToTriggers.clear(); for (size_t imyT = 0; imyT < myTriggers.size(); ++imyT) { for (size_t iT = 0; iT < hlNames.size(); ++iT) { diff --git a/RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco4D.cc b/RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco4D.cc index af7a851adf615..1378bcacbaaa9 100644 --- a/RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco4D.cc +++ b/RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco4D.cc @@ -297,7 +297,7 @@ DTRecSegment4D* DTCombinatorialPatternReco4D::segmentSpecialZed(const DTRecSegme // pick up a hit "in the middle", where the single hit will be put. int nHits = hits.size(); - DTRecHit1D middle = hits[static_cast(nHits / 2.)]; + const DTRecHit1D& middle = hits[static_cast(nHits / 2.)]; // Need to extrapolate pos to the middle layer z LocalPoint posInSL = zedSeg->localPosition(); diff --git a/RecoLuminosity/LumiProducer/plugins/CMSRunSummary2DB.cc b/RecoLuminosity/LumiProducer/plugins/CMSRunSummary2DB.cc index 15b830d4222dc..60817aeedbc50 100644 --- a/RecoLuminosity/LumiProducer/plugins/CMSRunSummary2DB.cc +++ b/RecoLuminosity/LumiProducer/plugins/CMSRunSummary2DB.cc @@ -85,7 +85,7 @@ namespace lumi { std::string fillnum = record[0]; if (fillnum == result.fillnumber) { result.fillscheme = record[1]; - std::string ncollidingbunchesStr = record[2]; + const std::string& ncollidingbunchesStr = record[2]; result.ncollidingbunches = str2int(ncollidingbunchesStr); break; } diff --git a/RecoMET/METPUSubtraction/src/PFMETAlgorithmMVA.cc b/RecoMET/METPUSubtraction/src/PFMETAlgorithmMVA.cc index 0902c7c8c1aac..6320934cc51b5 100644 --- a/RecoMET/METPUSubtraction/src/PFMETAlgorithmMVA.cc +++ b/RecoMET/METPUSubtraction/src/PFMETAlgorithmMVA.cc @@ -84,6 +84,7 @@ const GBRForest* PFMETAlgorithmMVA::loadMVAfromFile(const edm::FileInPath& input } std::vector variableNames; + variableNames.reserve(lVec->size()); for (unsigned int i = 0; i < lVec->size(); ++i) { variableNames.push_back(updateVariableNames(lVec->at(i))); } diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index bcac07e345461..4fd119600c4c6 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -1410,9 +1410,9 @@ void MuonIdProducer::fillMuonIsolation(edm::Event& iEvent, return; } - reco::IsoDeposit depEcal = caloDeps.at(0); - reco::IsoDeposit depHcal = caloDeps.at(1); - reco::IsoDeposit depHo = caloDeps.at(2); + const reco::IsoDeposit& depEcal = caloDeps.at(0); + const reco::IsoDeposit& depHcal = caloDeps.at(1); + const reco::IsoDeposit& depHo = caloDeps.at(2); //no need to copy outside if we don't write them if (writeIsoDeposits_) { diff --git a/RecoMuon/MuonSeedGenerator/src/RPCSeedGenerator.cc b/RecoMuon/MuonSeedGenerator/src/RPCSeedGenerator.cc index 687f2c605e16b..d54ad90f2bfe1 100644 --- a/RecoMuon/MuonSeedGenerator/src/RPCSeedGenerator.cc +++ b/RecoMuon/MuonSeedGenerator/src/RPCSeedGenerator.cc @@ -190,14 +190,14 @@ void RPCSeedGenerator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup MuonDetLayerGeometry const& muonLayers = iSetup.getData(muonLayersToken); // Get the RPC layers - vector RPCBarrelLayers = muonLayers.barrelRPCLayers(); + const vector& RPCBarrelLayers = muonLayers.barrelRPCLayers(); const DetLayer* RB4L = RPCBarrelLayers[5]; const DetLayer* RB3L = RPCBarrelLayers[4]; const DetLayer* RB22L = RPCBarrelLayers[3]; const DetLayer* RB21L = RPCBarrelLayers[2]; const DetLayer* RB12L = RPCBarrelLayers[1]; const DetLayer* RB11L = RPCBarrelLayers[0]; - vector RPCEndcapLayers = muonLayers.endcapRPCLayers(); + const vector& RPCEndcapLayers = muonLayers.endcapRPCLayers(); const DetLayer* REM3L = RPCEndcapLayers[0]; const DetLayer* REM2L = RPCEndcapLayers[1]; const DetLayer* REM1L = RPCEndcapLayers[2]; diff --git a/RecoMuon/TrackingTools/src/MuonTrajectoryUpdator.cc b/RecoMuon/TrackingTools/src/MuonTrajectoryUpdator.cc index 80929deb2d9f3..32148c87ced2f 100644 --- a/RecoMuon/TrackingTools/src/MuonTrajectoryUpdator.cc +++ b/RecoMuon/TrackingTools/src/MuonTrajectoryUpdator.cc @@ -101,7 +101,7 @@ pair MuonTrajectoryUpdator::update(const Traject const DetLayer* detLayer = measurement->layer(); // these are the 4D segment for the CSC/DT and a point for the RPC - TransientTrackingRecHit::ConstRecHitPointer muonRecHit = measurement->recHit(); + const TransientTrackingRecHit::ConstRecHitPointer& muonRecHit = measurement->recHit(); // The KFUpdator takes TransientTrackingRecHits as arg. TransientTrackingRecHit::ConstRecHitContainer recHitsForFit = diff --git a/RecoPPS/Local/plugins/CTPPSPixelLocalTrackProducer.cc b/RecoPPS/Local/plugins/CTPPSPixelLocalTrackProducer.cc index 1917a9566a4f4..f7d5fe6bd73c0 100644 --- a/RecoPPS/Local/plugins/CTPPSPixelLocalTrackProducer.cc +++ b/RecoPPS/Local/plugins/CTPPSPixelLocalTrackProducer.cc @@ -100,6 +100,7 @@ CTPPSPixelLocalTrackProducer::CTPPSPixelLocalTrackProducer(const edm::ParameterS } std::vector listOfAllPlanes; + listOfAllPlanes.reserve(numberOfPlanesPerPot_); for (uint32_t i = 0; i < numberOfPlanesPerPot_; ++i) { listOfAllPlanes.push_back(i); } diff --git a/RecoPPS/Local/src/RPixPlaneCombinatoryTracking.cc b/RecoPPS/Local/src/RPixPlaneCombinatoryTracking.cc index 761ecfa07cf58..0fdf100d553e3 100644 --- a/RecoPPS/Local/src/RPixPlaneCombinatoryTracking.cc +++ b/RecoPPS/Local/src/RPixPlaneCombinatoryTracking.cc @@ -648,7 +648,7 @@ bool RPixPlaneCombinatoryTracking::calculatePointOnDetector(CTPPSPixelLocalTrack CTPPSPixelDetId planeId, GlobalPoint &planeLineIntercept) { double z0 = track->z0(); - CTPPSPixelLocalTrack::ParameterVector parameters = track->parameterVector(); + const CTPPSPixelLocalTrack::ParameterVector ¶meters = track->parameterVector(); math::Vector<3>::type pointOnLine(parameters[0], parameters[1], z0); GlobalVector tmpLineUnitVector = track->directionVector(); diff --git a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc index 860614dea52c4..98d83b26e12ef 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc @@ -59,6 +59,7 @@ class Basic2DGenericPFlowPositionCalc : public PFCPositionCalculatorBase { logWeightDenom.push_back(conf.getParameter("logWeightDenominator")); } + logWeightDenomInv.reserve(depths.size()); for (unsigned int i = 0; i < depths.size(); ++i) { logWeightDenomInv.push_back(1. / logWeightDenom[i]); } diff --git a/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc b/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc index 86bccb6dbaf7b..f376d1a3fcd59 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc @@ -78,6 +78,7 @@ LocalMaximumSeedFinder::LocalMaximumSeedFinder(const edm::ParameterSet& conf) thresh_pT.push_back(pset.getParameter("seedingThresholdPt")); } + thresh_pT2.reserve(thresh_pT.size()); for (unsigned int i = 0; i < thresh_pT.size(); ++i) { thresh_pT2.push_back(thresh_pT[i] * thresh_pT[i]); } diff --git a/RecoParticleFlow/PFProducer/src/MLPFModel.cc b/RecoParticleFlow/PFProducer/src/MLPFModel.cc index f4460c2c96ad4..ee6ad2cd58b3b 100644 --- a/RecoParticleFlow/PFProducer/src/MLPFModel.cc +++ b/RecoParticleFlow/PFProducer/src/MLPFModel.cc @@ -66,7 +66,7 @@ namespace reco::mlpf { charge = ref->charge(); num_hits = ref->recHitsSize(); - reco::MuonRef muonRef = orig.muonRef(); + const reco::MuonRef& muonRef = orig.muonRef(); if (muonRef.isNonnull()) { reco::TrackRef standAloneMu = muonRef->standAloneMuon(); if (standAloneMu.isNonnull()) { diff --git a/RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc b/RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc index bd6d300fd5a44..c5e3b8483e316 100644 --- a/RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc @@ -790,7 +790,7 @@ bool PFEGammaAlgo::unwrapSuperCluster(const PFSCElement* thesc, << " This is a bug we should fix this!" << std::endl; return false; } - reco::SuperClusterRef scref = thesc->superClusterRef(); + const reco::SuperClusterRef& scref = thesc->superClusterRef(); const bool is_pf_sc = thesc->fromPFSuperCluster(); if (!(scref.isAvailable() && scref.isNonnull())) { throw cms::Exception("PFEGammaAlgo::unwrapSuperCluster()") diff --git a/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc b/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc index a205ce060e49d..c55b616885a65 100644 --- a/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFMuonAlgo.cc @@ -829,6 +829,7 @@ std::pair PFMuonAlgo::getMinMaxMET2(const reco::PFCandidate& pfc double METXNO = METX_ - pfc.px(); double METYNO = METY_ - pfc.py(); std::vector met2; + met2.reserve(tracks.size()); for (unsigned int i = 0; i < tracks.size(); ++i) { met2.push_back(pow(METXNO + tracks.at(i).first->px(), 2) + pow(METYNO + tracks.at(i).first->py(), 2)); } diff --git a/RecoParticleFlow/PFTracking/plugins/PFElecTkProducer.cc b/RecoParticleFlow/PFTracking/plugins/PFElecTkProducer.cc index 81220949e667d..2ddb659ced858 100644 --- a/RecoParticleFlow/PFTracking/plugins/PFElecTkProducer.cc +++ b/RecoParticleFlow/PFTracking/plugins/PFElecTkProducer.cc @@ -869,8 +869,8 @@ bool PFElecTkProducer::resolveGsfTracks(const vector& GsfPF float PFElecTkProducer::minTangDist(const reco::GsfPFRecTrack& primGsf, const reco::GsfPFRecTrack& secGsf) { float minDphi = 1000.; - std::vector primPFBrem = primGsf.PFRecBrem(); - std::vector secPFBrem = secGsf.PFRecBrem(); + const std::vector& primPFBrem = primGsf.PFRecBrem(); + const std::vector& secPFBrem = secGsf.PFRecBrem(); unsigned int cbrem = 0; for (unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) { @@ -994,7 +994,7 @@ bool PFElecTkProducer::isSharingEcalEnergyWithEgSC(const reco::GsfPFRecTrack& nG } // check if it touch the Brem-tangents else { - vector primPFBrem = gsfPfTrack.PFRecBrem(); + const vector& primPFBrem = gsfPfTrack.PFRecBrem(); for (unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) { if (primPFBrem[ipbrem].indTrajPoint() == 99) continue; @@ -1081,7 +1081,7 @@ bool PFElecTkProducer::isSharingEcalEnergyWithEgSC(const reco::GsfPFRecTrack& nG iPFCluster.push_back(clust); iEnergy += clust.energy(); } else { - vector primPFBrem = iGsfPFRecTrack.PFRecBrem(); + const vector& primPFBrem = iGsfPFRecTrack.PFRecBrem(); for (unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) { if (primPFBrem[ipbrem].indTrajPoint() == 99) continue; diff --git a/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc b/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc index 9e1bf530ac664..74218afa05727 100644 --- a/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc +++ b/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc @@ -57,7 +57,7 @@ void ConvBremPFTrackFinder::runConvBremFinder(const Handle float refGsfPtMode = refGsf->ptMode(); const reco::PFRecTrackRef& pfTrackRef = gsfpfrectk.kfPFRecTrackRef(); - vector primPFBrem = gsfpfrectk.PFRecBrem(); + const vector& primPFBrem = gsfpfrectk.PFRecBrem(); const PFRecTrackCollection& PfRTkColl = *(thePfRecTrackCol.product()); reco::PFRecTrackCollection::const_iterator pft = PfRTkColl.begin(); diff --git a/RecoParticleFlow/PFTracking/src/PFDisplacedVertexFinder.cc b/RecoParticleFlow/PFTracking/src/PFDisplacedVertexFinder.cc index 10705052ed890..a2d374a28c52a 100644 --- a/RecoParticleFlow/PFTracking/src/PFDisplacedVertexFinder.cc +++ b/RecoParticleFlow/PFTracking/src/PFDisplacedVertexFinder.cc @@ -659,8 +659,8 @@ reco::PFDisplacedVertex::VertexTrackType PFDisplacedVertexFinder::getVertexTrack } unsigned PFDisplacedVertexFinder::commonTracks(const PFDisplacedVertex& v1, const PFDisplacedVertex& v2) const { - vector vt1 = v1.refittedTracks(); - vector vt2 = v2.refittedTracks(); + const vector& vt1 = v1.refittedTracks(); + const vector& vt2 = v2.refittedTracks(); unsigned commonTracks = 0; diff --git a/RecoParticleFlow/PFTracking/src/PFDisplacedVertexHelper.cc b/RecoParticleFlow/PFTracking/src/PFDisplacedVertexHelper.cc index 4893154b25cc7..8049731193aaa 100644 --- a/RecoParticleFlow/PFTracking/src/PFDisplacedVertexHelper.cc +++ b/RecoParticleFlow/PFTracking/src/PFDisplacedVertexHelper.cc @@ -214,13 +214,13 @@ reco::PFDisplacedVertex::VertexType PFDisplacedVertexHelper::identifyVertex(cons int PFDisplacedVertexHelper::lambdaCP(const PFDisplacedVertex& v) const { int lambdaCP = 0; - vector refittedTracks = v.refittedTracks(); + const vector& refittedTracks = v.refittedTracks(); math::XYZTLorentzVector totalMomentumDcaRefit_lambda; math::XYZTLorentzVector totalMomentumDcaRefit_lambdabar; - reco::Track tMomentumDcaRefit_0 = refittedTracks[0]; - reco::Track tMomentumDcaRefit_1 = refittedTracks[1]; + const reco::Track& tMomentumDcaRefit_0 = refittedTracks[0]; + const reco::Track& tMomentumDcaRefit_1 = refittedTracks[1]; double mass2_0 = 0, mass2_1 = 0; diff --git a/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc b/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc index 8c2a41f2fef84..daa84b8295f36 100644 --- a/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc +++ b/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc @@ -95,7 +95,7 @@ bool PFTrackTransformer::addPoints(reco::PFRecTrack& pftrack, if (!onlyprop_) { bool direction = (traj.direction() == alongMomentum); - vector measurements = traj.measurements(); + const vector& measurements = traj.measurements(); int iTrajFirst = (direction) ? 0 : measurements.size() - 1; int increment = (direction) ? +1 : -1; int iTrajLast = (direction) ? int(measurements.size()) : -1; @@ -239,7 +239,7 @@ bool PFTrackTransformer::addPointsAndBrems(reco::GsfPFRecTrack& pftrack, // Trajectory for each trajectory point bool direction = (traj.direction() == alongMomentum); - vector measurements = traj.measurements(); + const vector& measurements = traj.measurements(); int iTrajFirst = (direction) ? 0 : measurements.size() - 1; int increment = (direction) ? +1 : -1; int iTrajLast = (direction) ? int(measurements.size()) : -1; diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index caad1ad96a63b..395f2ab34708c 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -148,7 +148,7 @@ namespace reco { for (size_t candId = 0; candId < numCands; ++candId) { if ((!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end()) { // do not include same cand twice - reco::CandidatePtr cand = cands[candId]; + const reco::CandidatePtr& cand = cands[candId]; if (fabs(strip.eta() - cand->eta()) < etaAssociationDistance_ && // check if cand is within eta-phi window centered on strip fabs(strip.phi() - cand->phi()) < phiAssociationDistance_) { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 167d4f9b86dab..4f3aa4bff1808 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -169,7 +169,7 @@ namespace reco { for (size_t candId = 0; candId < numCands; ++candId) { if ((!candFlags[candId]) && candIdsCurrentStrip.find(candId) == candIdsCurrentStrip.end()) { // do not include same cand twice - reco::CandidatePtr cand = cands[candId]; + const reco::CandidatePtr& cand = cands[candId]; double etaAssociationDistance_value = etaAssociationDistance_->Eval(strip.pt()) + etaAssociationDistance_->Eval(cand->pt()); double phiAssociationDistance_value = diff --git a/RecoTracker/DeDx/src/DeDxTools.cc b/RecoTracker/DeDx/src/DeDxTools.cc index cef8b43fcbbf1..2464ac856a18a 100644 --- a/RecoTracker/DeDx/src/DeDxTools.cc +++ b/RecoTracker/DeDx/src/DeDxTools.cc @@ -432,7 +432,7 @@ namespace deDxTools { LocalPoint HitLocalPos = trajState.localPosition(); LocalError HitLocalError = trajState.localError().positionError(); - const BoundPlane plane = it->surface(); + const BoundPlane& plane = it->surface(); const TrapezoidalPlaneBounds* trapezoidalBounds(dynamic_cast(&(plane.bounds()))); const RectangularPlaneBounds* rectangularBounds(dynamic_cast(&(plane.bounds()))); diff --git a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc index 62fc22e978c58..c5c96b18072bd 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc @@ -572,7 +572,7 @@ namespace reco { } bool TrackerTrackHitFilter::isFirstValidHitInLayer(const reco::Track &tk, std::vector isNotValidVec) { - reco::HitPattern hp = tk.hitPattern(); + const reco::HitPattern &hp = tk.hitPattern(); int vecSize = static_cast(isNotValidVec.size()); // If hit is not valid, it will not count as a tracker layer with measurement -> don't increase sequLayers diff --git a/RecoTracker/PixelTrackFitting/src/PixelTrackBuilder.cc b/RecoTracker/PixelTrackFitting/src/PixelTrackBuilder.cc index 29f4f049cab5f..2d26d19ce131c 100644 --- a/RecoTracker/PixelTrackFitting/src/PixelTrackBuilder.cc +++ b/RecoTracker/PixelTrackFitting/src/PixelTrackBuilder.cc @@ -70,7 +70,7 @@ namespace { float phi_v = state.globalMomentum().phi(); float theta_v = state.globalMomentum().theta(); - CurvilinearTrajectoryError curv = state.curvilinearError(); + const CurvilinearTrajectoryError& curv = state.curvilinearError(); float errPhi2 = curv.matrix()(3, 3); float errLambda2 = curv.matrix()(2, 2); float errInvP2 = curv.matrix()(1, 1); diff --git a/RecoTracker/SingleTrackPattern/src/CRackTrajectoryBuilder.cc b/RecoTracker/SingleTrackPattern/src/CRackTrajectoryBuilder.cc index 4b12219fbcf01..b5ed95ee8982b 100644 --- a/RecoTracker/SingleTrackPattern/src/CRackTrajectoryBuilder.cc +++ b/RecoTracker/SingleTrackPattern/src/CRackTrajectoryBuilder.cc @@ -794,7 +794,7 @@ std::pair CRackTrajectoryBuilder::inne if (nhits < lastFitted + 1) lastFitted = nhits - 1; - std::vector measvec = traj.measurements(); + const std::vector& measvec = traj.measurements(); TransientTrackingRecHit::ConstRecHitContainer firstHits; bool foundLast = false; diff --git a/RecoTracker/SpecialSeedGenerators/src/SeedFromGenericPairOrTriplet.cc b/RecoTracker/SpecialSeedGenerators/src/SeedFromGenericPairOrTriplet.cc index 0e41624ed639b..5a8c5628f47c0 100644 --- a/RecoTracker/SpecialSeedGenerators/src/SeedFromGenericPairOrTriplet.cc +++ b/RecoTracker/SpecialSeedGenerators/src/SeedFromGenericPairOrTriplet.cc @@ -295,6 +295,7 @@ bool SeedFromGenericPairOrTriplet::qualityFilter(const SeedingHitSet& hits) cons if (hits.size() == 3) { std::vector gPoints; unsigned int nHits = hits.size(); + gPoints.reserve(nHits); for (unsigned int iHit = 0; iHit < nHits; ++iHit) gPoints.push_back(hits[iHit]->globalPosition()); unsigned int subid = (*hits[0]).geographicalId().subdetId(); diff --git a/RecoTracker/TkDetLayers/src/PixelBarrelLayerBuilder.cc b/RecoTracker/TkDetLayers/src/PixelBarrelLayerBuilder.cc index 887221fc485c5..f9bcf0c3e539a 100644 --- a/RecoTracker/TkDetLayers/src/PixelBarrelLayerBuilder.cc +++ b/RecoTracker/TkDetLayers/src/PixelBarrelLayerBuilder.cc @@ -9,7 +9,7 @@ PixelBarrelLayer* PixelBarrelLayerBuilder::build(const GeometricDet* aPixelBarre // This builder is very similar to TOBLayer one. Most of the code should be put in a // common place. - vector theGeometricDetRods = aPixelBarrelLayer->components(); + const vector& theGeometricDetRods = aPixelBarrelLayer->components(); //edm::LogInfo(TkDetLayers) << "theGeometricDetRods has size: " << theGeometricDetRods.size() ; PixelRodBuilder myPixelRodBuilder; diff --git a/RecoTracker/TkSeedGenerator/plugins/DeepCoreSeedGenerator.cc b/RecoTracker/TkSeedGenerator/plugins/DeepCoreSeedGenerator.cc index 6f16fc276af37..a6b460994eba8 100644 --- a/RecoTracker/TkSeedGenerator/plugins/DeepCoreSeedGenerator.cc +++ b/RecoTracker/TkSeedGenerator/plugins/DeepCoreSeedGenerator.cc @@ -250,7 +250,7 @@ void DeepCoreSeedGenerator::produce(edm::Event& iEvent, const edm::EventSetup& i } } //end of TensorFlow tensors init - GlobalVector bigClustDir = splitClustDirSet[cc]; + const GlobalVector& bigClustDir = splitClustDirSet[cc]; jetEta_ = jet.eta(); jetPt_ = jet.pt(); diff --git a/RecoTracker/TrackProducer/src/DAFTrackProducerAlgorithm.cc b/RecoTracker/TrackProducer/src/DAFTrackProducerAlgorithm.cc index 23289bb5637b6..616dcaea25426 100644 --- a/RecoTracker/TrackProducer/src/DAFTrackProducerAlgorithm.cc +++ b/RecoTracker/TrackProducer/src/DAFTrackProducerAlgorithm.cc @@ -396,7 +396,7 @@ float DAFTrackProducerAlgorithm::calculateNdof(const Trajectory vtraj) const { //------------------------------------------------------------------------------------------------ int DAFTrackProducerAlgorithm::checkHits(Trajectory iInitTraj, const Trajectory iFinalTraj) const { std::vector initmeasurements = iInitTraj.measurements(); - std::vector finalmeasurements = iFinalTraj.measurements(); + const std::vector& finalmeasurements = iFinalTraj.measurements(); std::vector::iterator jmeas; int nSame = 0; int ihit = 0; @@ -419,7 +419,7 @@ int DAFTrackProducerAlgorithm::checkHits(Trajectory iInitTraj, const Trajectory continue; if (initHit->isValid()) { - TrajectoryMeasurement imeas = finalmeasurements.at(ihit); + const TrajectoryMeasurement& imeas = finalmeasurements.at(ihit); const TrackingRecHit* finalHit = imeas.recHit()->hit(); const TrackingRecHit* MaxWeightHit = nullptr; float maxweight = 0; @@ -458,7 +458,7 @@ int DAFTrackProducerAlgorithm::checkHits(Trajectory iInitTraj, const Trajectory } } } else { - TrajectoryMeasurement imeas = finalmeasurements.at(ihit); + const TrajectoryMeasurement& imeas = finalmeasurements.at(ihit); const TrackingRecHit* finalHit = imeas.recHit()->hit(); if (!finalHit->isValid()) { nSame++; diff --git a/RecoVertex/KinematicFit/plugins/KineExample.cc b/RecoVertex/KinematicFit/plugins/KineExample.cc index 2caaed72f9eaa..0c7e69a671fad 100644 --- a/RecoVertex/KinematicFit/plugins/KineExample.cc +++ b/RecoVertex/KinematicFit/plugins/KineExample.cc @@ -157,10 +157,10 @@ void KineExample::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu else edm::LogPrint("KineExample") << "KVF fit Position: " << Vertex::Point(tv.position()) << "\n"; - TransientTrack ttMuPlus = t_tks[0]; - TransientTrack ttMuMinus = t_tks[1]; - TransientTrack ttKPlus = t_tks[2]; - TransientTrack ttKMinus = t_tks[3]; + const TransientTrack& ttMuPlus = t_tks[0]; + const TransientTrack& ttMuMinus = t_tks[1]; + const TransientTrack& ttKPlus = t_tks[2]; + const TransientTrack& ttKMinus = t_tks[3]; //the final state muons and kaons from the Bs->J/PsiPhi->mumuKK decay //Creating a KinematicParticleFactory diff --git a/RecoVertex/LinearizationPointFinders/src/CrossingPtBasedLinearizationPointFinder.cc b/RecoVertex/LinearizationPointFinders/src/CrossingPtBasedLinearizationPointFinder.cc index 8fb9aa9a671c5..bc9d6dde5e6c4 100644 --- a/RecoVertex/LinearizationPointFinders/src/CrossingPtBasedLinearizationPointFinder.cc +++ b/RecoVertex/LinearizationPointFinders/src/CrossingPtBasedLinearizationPointFinder.cc @@ -233,8 +233,8 @@ GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint( bool dir = false; while (vgp.size() < ((unsigned int)(theNPairs))) { - reco::TransientTrack rt1 = goodtracks[t_first]; - reco::TransientTrack rt2 = goodtracks[t_first + t_interval]; + const reco::TransientTrack& rt1 = goodtracks[t_first]; + const reco::TransientTrack& rt2 = goodtracks[t_first + t_interval]; // std::cout << "Considering now: " << t_first << ", " << t_first+t_interval << std::endl; if (useMatrix) { PointAndDistance v(theMatrix->crossingPoint(rt1, rt2), theMatrix->distance(rt1, rt2)); diff --git a/RecoVertex/PrimaryVertexProducer/src/AdaptiveChisquarePrimaryVertexFitter.cc b/RecoVertex/PrimaryVertexProducer/src/AdaptiveChisquarePrimaryVertexFitter.cc index 199e0918e6380..035fcdb5ee3df 100644 --- a/RecoVertex/PrimaryVertexProducer/src/AdaptiveChisquarePrimaryVertexFitter.cc +++ b/RecoVertex/PrimaryVertexProducer/src/AdaptiveChisquarePrimaryVertexFitter.cc @@ -515,6 +515,7 @@ TransientVertex AdaptiveChisquarePrimaryVertexFitter::refit(const TransientVerte // put the result into a transient vertex std::vector> vertex_track_weights; + vertex_track_weights.reserve(nt); for (unsigned int i = 0; i < nt; i++) { vertex_track_weights.emplace_back(i, tkweight_[i]); } diff --git a/RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZ_vect.cc b/RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZ_vect.cc index 39e6ccb652711..26974a87b4314 100644 --- a/RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZ_vect.cc +++ b/RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZ_vect.cc @@ -937,6 +937,7 @@ vector DAClusterizerInZ_vect::vertices_no_blocks(const vector DAClusterizerInZ_vect::vertices_in_blocks(const vector& tracks) const { vector sorted_tracks; vector> vertices_tot; // z, rho for each vertex + sorted_tracks.reserve(tracks.size()); for (unsigned int i = 0; i < tracks.size(); i++) { sorted_tracks.push_back(tracks[i]); } diff --git a/TrackingTools/TrackRefitter/src/TrackTransformerForGlobalCosmicMuons.cc b/TrackingTools/TrackRefitter/src/TrackTransformerForGlobalCosmicMuons.cc index d3ff9a8a5f244..b68bcfa098c90 100644 --- a/TrackingTools/TrackRefitter/src/TrackTransformerForGlobalCosmicMuons.cc +++ b/TrackingTools/TrackRefitter/src/TrackTransformerForGlobalCosmicMuons.cc @@ -227,7 +227,7 @@ vector TrackTransformerForGlobalCosmicMuons::transform(const reco::T return vector(); } - Trajectory trajectoryBW = trajectories.front(); + const Trajectory& trajectoryBW = trajectories.front(); vector trajectoriesSM = smoother(up)->trajectories(trajectoryBW); diff --git a/TrackingTools/TrajectoryState/src/PerigeeConversions.cc b/TrackingTools/TrajectoryState/src/PerigeeConversions.cc index 1689df714462c..67db1e5cf5502 100644 --- a/TrackingTools/TrajectoryState/src/PerigeeConversions.cc +++ b/TrackingTools/TrajectoryState/src/PerigeeConversions.cc @@ -62,7 +62,7 @@ CurvilinearTrajectoryError PerigeeConversions::curvilinearError(const PerigeeTra GlobalPoint PerigeeConversions::positionFromPerigee(const PerigeeTrajectoryParameters& parameters, const GlobalPoint& referencePoint) { - AlgebraicVector5 theVector = parameters.vector(); + const AlgebraicVector5& theVector = parameters.vector(); return GlobalPoint(theVector[3] * vdt::fast_sin(theVector[2]) + referencePoint.x(), -theVector[3] * vdt::fast_cos(theVector[2]) + referencePoint.y(), theVector[4] + referencePoint.z());