From 396f34bc52119ceb1f3bd2d4bcc83c6969cda0e5 Mon Sep 17 00:00:00 2001 From: Andrea Date: Sun, 19 Mar 2023 18:17:54 +0100 Subject: [PATCH] Replace DeltaR with DeltaR2 in RecoTauTag/HLTProducers --- .../HLTProducers/src/CaloTowerCreatorForTauHLT.cc | 4 ++-- .../src/CaloTowerFromL1TCreatorForTauHLT.cc | 4 ++-- RecoTauTag/HLTProducers/src/L1HLTJetsMatching.cc | 11 +++++------ RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc | 12 ++++++------ RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc | 7 +++---- RecoTauTag/HLTProducers/src/L2TauJetsMerger.cc | 4 ++-- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc b/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc index c046a84a97930..09c6276403988 100644 --- a/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc +++ b/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc @@ -57,9 +57,9 @@ void CaloTowerCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSet } if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) { math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy()); - double delta = ROOT::Math::VectorUtil::DeltaR((*myL1Jet).p4().Vect(), p); + double delta2 = ROOT::Math::VectorUtil::DeltaR2((*myL1Jet).p4().Vect(), p); - if (delta < mCone) { + if (delta2 < mCone * mCone) { isAccepted = true; cands->push_back(*cal); } diff --git a/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc b/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc index 6cbcbc95c7604..92c3ffa06da7a 100644 --- a/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc +++ b/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc @@ -57,8 +57,8 @@ void CaloTowerFromL1TCreatorForTauHLT::produce(StreamID sid, Event& evt, const E } if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) { math::PtEtaPhiELorentzVector p(cal->et(), cal->eta(), cal->phi(), cal->energy()); - double delta = ROOT::Math::VectorUtil::DeltaR((*myL1Jet).p4().Vect(), p); - if (delta < mCone) { + double delta2 = ROOT::Math::VectorUtil::DeltaR2((*myL1Jet).p4().Vect(), p); + if (delta2 < mCone * mCone) { isAccepted = true; cands->push_back(*cal); } diff --git a/RecoTauTag/HLTProducers/src/L1HLTJetsMatching.cc b/RecoTauTag/HLTProducers/src/L1HLTJetsMatching.cc index cff5a8d07b1eb..30675cbb712c1 100644 --- a/RecoTauTag/HLTProducers/src/L1HLTJetsMatching.cc +++ b/RecoTauTag/HLTProducers/src/L1HLTJetsMatching.cc @@ -33,8 +33,7 @@ void L1HLTJetsMatching::produce(edm::StreamID, edm::Event& iEvent, const edm::Ev unique_ptr tauL2jets(new CaloJetCollection); - double deltaR = 1.0; - double matchingR = 0.5; + constexpr double matchingR = 0.5 * 0.5; //Getting HLT jets to be matched edm::Handle > tauJets; iEvent.getByToken(jetSrc, tauJets); @@ -56,8 +55,8 @@ void L1HLTJetsMatching::produce(edm::StreamID, edm::Event& iEvent, const edm::Ev for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) { //Find the relative L2TauJets, to see if it has been reconstructed const Candidate& myJet = (*tauJets)[iJet]; - deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); - if (deltaR < matchingR) { + double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); + if (deltaR2 < matchingR) { // LeafCandidate myLC(myJet); CaloJet myCaloJet(myJet.p4(), a, f); if (myJet.pt() > mEt_Min) { @@ -73,8 +72,8 @@ void L1HLTJetsMatching::produce(edm::StreamID, edm::Event& iEvent, const edm::Ev for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) { const Candidate& myJet = (*tauJets)[iJet]; //Find the relative L2TauJets, to see if it has been reconstructed - deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect()); - if (deltaR < matchingR) { + double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect()); + if (deltaR2 < matchingR) { // LeafCandidate myLC(myJet); CaloJet myCaloJet(myJet.p4(), a, f); if (myJet.pt() > mEt_Min) { diff --git a/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc b/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc index 3da2d4d6b3caa..43c7246cc4a50 100644 --- a/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc +++ b/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc @@ -31,8 +31,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm unique_ptr tauL2jets(new PFTauCollection); - double deltaR = 1.0; - double matchingR = 0.5; + constexpr double matchingR = 0.5; + //Getting HLT jets to be matched edm::Handle tauJets; iEvent.getByToken(jetSrc, tauJets); @@ -53,8 +53,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) { //Find the relative L2TauJets, to see if it has been reconstructed const PFTau& myJet = (*tauJets)[iJet]; - deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); - if (deltaR < matchingR) { + double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); + if (deltaR2 < matchingR) { // LeafCandidate myLC(myJet); if (myJet.leadChargedHadrCand().isNonnull()) { a = myJet.leadChargedHadrCand()->vertex(); @@ -73,8 +73,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) { const PFTau& myJet = (*tauJets)[iJet]; //Find the relative L2TauJets, to see if it has been reconstructed - deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect()); - if (deltaR < matchingR) { + double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect()); + if (deltaR2 < matchingR) { // LeafCandidate myLC(myJet); if (myJet.leadChargedHadrCand().isNonnull()) { a = myJet.leadChargedHadrCand()->vertex(); diff --git a/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc b/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc index e7f78da243219..d8979ba97e56e 100644 --- a/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc +++ b/RecoTauTag/HLTProducers/src/L1THLTTauMatching.cc @@ -26,8 +26,7 @@ L1THLTTauMatching::~L1THLTTauMatching() {} void L1THLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm::EventSetup& iES) const { unique_ptr tauL2jets(new PFTauCollection); - double deltaR = 1.0; - double matchingR = 0.5; + constexpr double matchingR = 0.5 * 0.5; // Getting HLT jets to be matched edm::Handle tauJets; @@ -45,8 +44,8 @@ void L1THLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const ed for (unsigned int iJet = 0; iJet < tauJets->size(); iJet++) { // Find the relative L2TauJets, to see if it has been reconstructed const PFTau& myJet = (*tauJets)[iJet]; - deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); - if (deltaR < matchingR) { + double deltaR2 = ROOT::Math::VectorUtil::DeltaR2(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect()); + if (deltaR2 < matchingR) { if (myJet.leadChargedHadrCand().isNonnull()) { a = myJet.leadChargedHadrCand()->vertex(); } diff --git a/RecoTauTag/HLTProducers/src/L2TauJetsMerger.cc b/RecoTauTag/HLTProducers/src/L2TauJetsMerger.cc index fbc838409ac70..13d9c9773aeff 100644 --- a/RecoTauTag/HLTProducers/src/L2TauJetsMerger.cc +++ b/RecoTauTag/HLTProducers/src/L2TauJetsMerger.cc @@ -58,8 +58,8 @@ void L2TauJetsMerger::produce(edm::StreamID iSId, edm::Event& iEvent, const edm: tauL2jets->push_back(myTmpJets[0]); CaloJetCollection tmp; for (unsigned int i = 1; i < myTmpJets.size(); ++i) { - double DR = ROOT::Math::VectorUtil::DeltaR(myTmpJets[0].p4(), myTmpJets[i].p4()); - if (DR > 0.1) + double DR2 = ROOT::Math::VectorUtil::DeltaR2(myTmpJets[0].p4(), myTmpJets[i].p4()); + if (DR2 > 0.1 * 0.1) tmp.push_back(myTmpJets[i]); } myTmpJets.swap(tmp);