From 4e05083d278da7c1d42be28dc5fed93f179cc4e1 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Wed, 29 Apr 2020 14:09:37 +0200 Subject: [PATCH 1/2] [LLVM10] PhysicsTools fix clang warnings --- PhysicsTools/NanoAOD/plugins/LeptonInJetProducer.cc | 2 +- PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc | 2 +- PhysicsTools/ONNXRuntime/test/testONNXRuntime.cc | 2 +- .../ShiftedPFCandidateProducerForPFNoPUMEt.cc | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PhysicsTools/NanoAOD/plugins/LeptonInJetProducer.cc b/PhysicsTools/NanoAOD/plugins/LeptonInJetProducer.cc index 5a29eb9898598..6f326449554fe 100644 --- a/PhysicsTools/NanoAOD/plugins/LeptonInJetProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LeptonInJetProducer.cc @@ -90,7 +90,7 @@ void LeptonInJetProducer::produce(edm::StreamID streamID, edm::Event &iEvent, std::vector lClusterParticles; float lepPt(-1), lepEta(-1), lepPhi(-1); int lepId(-1); - for (auto const d : itJet.daughterPtrVector()) { + for (auto const &d : itJet.daughterPtrVector()) { fastjet::PseudoJet p(d->px(), d->py(), d->pz(), d->energy()); lClusterParticles.emplace_back(p); } diff --git a/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc b/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc index f7064880119c0..ea2709eaff437 100644 --- a/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/LeptonJetVarProducer.cc @@ -162,7 +162,7 @@ std::tuple LeptonJetVarProducer::calculatePtRatioRel(edm auto ptrel = lepp4.Vect().Cross((jetp4 - lepp4).Vect().Unit()).R(); unsigned int jndau = 0; - for (const auto _d : jet->daughterPtrVector()) { + for (const auto& _d : jet->daughterPtrVector()) { const auto d = dynamic_cast(_d.get()); if (d->charge() == 0) continue; diff --git a/PhysicsTools/ONNXRuntime/test/testONNXRuntime.cc b/PhysicsTools/ONNXRuntime/test/testONNXRuntime.cc index 1aac5bbcb4dde..8e0df6e5df501 100644 --- a/PhysicsTools/ONNXRuntime/test/testONNXRuntime.cc +++ b/PhysicsTools/ONNXRuntime/test/testONNXRuntime.cc @@ -22,7 +22,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(testONNXRuntime); void testONNXRuntime::checkAll() { std::string model_path = edm::FileInPath("PhysicsTools/ONNXRuntime/test/data/model.onnx").fullPath(); ONNXRuntime rt(model_path); - for (const unsigned &batch_size : {1, 2, 4}) { + for (const unsigned batch_size : {1, 2, 4}) { FloatArrays input_values{ std::vector(batch_size * 2, 1), }; diff --git a/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc b/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc index 15b5286610b15..b5f7164ffbed3 100644 --- a/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc +++ b/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc @@ -72,12 +72,12 @@ void ShiftedPFCandidateProducerForPFNoPUMEt::produce(edm::Event& evt, const edm: originalPFCandidate != originalPFCandidates->end(); ++originalPFCandidate) { const reco::PFJet* jet_matched = nullptr; - for (std::vector::iterator jet = selectedJets.begin(); jet != selectedJets.end(); ++jet) { - for (std::vector::const_iterator jetConstituent = (*jet)->getPFConstituents().begin(); - jetConstituent != (*jet)->getPFConstituents().end() && jet_matched == nullptr; - ++jetConstituent) { - if (deltaR2(originalPFCandidate->p4(), (*jetConstituent)->p4()) < dR2Match) - jet_matched = (*jet); + for (auto jet : selectedJets) { + for (auto jetc : jet->getPFConstituents()) { + if (jet_matched) + break; + if (deltaR2(originalPFCandidate->p4(), jetc->p4()) < dR2Match) + jet_matched = jet; } } From d683d55a6c0ab456297de286ae0397c77abf9e6e Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 4 May 2020 15:32:51 +0300 Subject: [PATCH 2/2] applying latest solution --- .../plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc b/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc index b5f7164ffbed3..e3dad704fab39 100644 --- a/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc +++ b/PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.cc @@ -74,11 +74,13 @@ void ShiftedPFCandidateProducerForPFNoPUMEt::produce(edm::Event& evt, const edm: const reco::PFJet* jet_matched = nullptr; for (auto jet : selectedJets) { for (auto jetc : jet->getPFConstituents()) { - if (jet_matched) - break; - if (deltaR2(originalPFCandidate->p4(), jetc->p4()) < dR2Match) + if (deltaR2(originalPFCandidate->p4(), jetc->p4()) < dR2Match) { jet_matched = jet; + break; + } } + if (jet_matched) + break; } double shift = 0.;