-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce non necessary sqrt computations in RecoTauTag/HLTProducers #41100
Changes from 2 commits
22933fd
396f34b
2ccf189
b8b0a9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
isAccepted = true; | ||
cands->push_back(*cal); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ The module stores j1, j2 of any (j1, j2, t1, t2) that satisfies the conditions a | |
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
|
@@ -37,7 +38,7 @@ class HLTPFDiJetCorrCheckerWithDiTau : public edm::global::EDProducer<> { | |
const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> tauSrc_; | ||
const edm::EDGetTokenT<reco::PFJetCollection> pfJetSrc_; | ||
const double extraTauPtCut_; | ||
const double mjjMin_; | ||
const double m2jjMin_; | ||
const double dRmin_, dRmin2_; | ||
// pt comparator | ||
GreaterByPt<reco::PFJet> pTComparator_; | ||
|
@@ -50,7 +51,7 @@ HLTPFDiJetCorrCheckerWithDiTau::HLTPFDiJetCorrCheckerWithDiTau(const edm::Parame | |
: tauSrc_(consumes(iConfig.getParameter<edm::InputTag>("tauSrc"))), | ||
pfJetSrc_(consumes(iConfig.getParameter<edm::InputTag>("pfJetSrc"))), | ||
extraTauPtCut_(iConfig.getParameter<double>("extraTauPtCut")), | ||
mjjMin_(iConfig.getParameter<double>("mjjMin")), | ||
m2jjMin_(iConfig.getParameter<double>("mjjMin") * iConfig.getParameter<double>("mjjMin")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs to be improved. A user might put One way to improve this is
The same argument probably applies to other plugins touched by this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct @missirol |
||
dRmin_(iConfig.getParameter<double>("dRmin")), | ||
dRmin2_(dRmin_ * dRmin_) { | ||
if (dRmin_ <= 0.) { | ||
|
@@ -77,7 +78,7 @@ void HLTPFDiJetCorrCheckerWithDiTau::produce(edm::StreamID iSId, edm::Event& iEv | |
const reco::PFJet& myPFJet1 = pfJets[iJet1]; | ||
const reco::PFJet& myPFJet2 = pfJets[iJet2]; | ||
|
||
if ((myPFJet1.p4() + myPFJet2.p4()).M() < mjjMin_) | ||
if ((myPFJet1.p4() + myPFJet2.p4()).M2() < m2jjMin_) | ||
continue; | ||
|
||
for (unsigned int iTau1 = 0; iTau1 < taus.size(); iTau1++) { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,8 +33,7 @@ void L1HLTJetsMatching::produce(edm::StreamID, edm::Event& iEvent, const edm::Ev | |||||
|
||||||
unique_ptr<CaloJetCollection> tauL2jets(new CaloJetCollection); | ||||||
|
||||||
double deltaR = 1.0; | ||||||
double matchingR = 0.5; | ||||||
constexpr double matchingR = 0.5 * 0.5; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(Clearer name.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a matter of taste... but ok |
||||||
//Getting HLT jets to be matched | ||||||
edm::Handle<edm::View<Candidate> > 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) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// 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) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// LeafCandidate myLC(myJet); | ||||||
CaloJet myCaloJet(myJet.p4(), a, f); | ||||||
if (myJet.pt() > mEt_Min) { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,8 +31,8 @@ void L1HLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm | |||||||||
|
||||||||||
unique_ptr<PFTauCollection> tauL2jets(new PFTauCollection); | ||||||||||
|
||||||||||
double deltaR = 1.0; | ||||||||||
double matchingR = 0.5; | ||||||||||
constexpr double matchingR = 0.5; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here there was another mistake of mine:
Suggested change
|
||||||||||
|
||||||||||
//Getting HLT jets to be matched | ||||||||||
edm::Handle<PFTauCollection> 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) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// 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) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
// LeafCandidate myLC(myJet); | ||||||||||
if (myJet.leadChargedHadrCand().isNonnull()) { | ||||||||||
a = myJet.leadChargedHadrCand()->vertex(); | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,8 +26,7 @@ L1THLTTauMatching::~L1THLTTauMatching() {} | |||||
void L1THLTTauMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm::EventSetup& iES) const { | ||||||
unique_ptr<PFTauCollection> tauL2jets(new PFTauCollection); | ||||||
|
||||||
double deltaR = 1.0; | ||||||
double matchingR = 0.5; | ||||||
constexpr double matchingR = 0.5 * 0.5; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
// Getting HLT jets to be matched | ||||||
edm::Handle<PFTauCollection> 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) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (myJet.leadChargedHadrCand().isNonnull()) { | ||||||
a = myJet.leadChargedHadrCand()->vertex(); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I prefer the cleaner expression of mine. For the compiler they'll be the same anyhow |
||||||
tmp.push_back(myTmpJets[i]); | ||||||
} | ||||||
myTmpJets.swap(tmp); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mCone * mCone
could be computed outside the loop. (or in the ctor)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler should be able to optimize it anyhow... But ok, why not? I will update