From 2ccf1897ae02caab61a299dff6eab2b991de3d81 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 20 Mar 2023 09:59:05 +0100 Subject: [PATCH] Consider possible negative values of the parameter as a way to skip comparisons --- .../interface/CaloTowerCreatorForTauHLT.h | 2 +- .../CaloTowerFromL1TCreatorForTauHLT.h | 2 +- .../HLTProducers/interface/L1TJetsMatching.h | 38 +++++++++---------- .../src/CaloTowerCreatorForTauHLT.cc | 5 ++- .../src/CaloTowerFromL1TCreatorForTauHLT.cc | 5 ++- .../src/HLTPFDiJetCorrCheckerWithDiTau.cc | 7 ++-- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/RecoTauTag/HLTProducers/interface/CaloTowerCreatorForTauHLT.h b/RecoTauTag/HLTProducers/interface/CaloTowerCreatorForTauHLT.h index 99a3f1ff12f5f..cba2120c81810 100644 --- a/RecoTauTag/HLTProducers/interface/CaloTowerCreatorForTauHLT.h +++ b/RecoTauTag/HLTProducers/interface/CaloTowerCreatorForTauHLT.h @@ -34,7 +34,7 @@ class CaloTowerCreatorForTauHLT : public edm::global::EDProducer<> { /// constructor from parameter set CaloTowerCreatorForTauHLT(const edm::ParameterSet&); /// destructor - ~CaloTowerCreatorForTauHLT() override; + ~CaloTowerCreatorForTauHLT() override = default; /// static void fillDescriptions(edm::ConfigurationDescriptions& desc); diff --git a/RecoTauTag/HLTProducers/interface/CaloTowerFromL1TCreatorForTauHLT.h b/RecoTauTag/HLTProducers/interface/CaloTowerFromL1TCreatorForTauHLT.h index 1cf69475c8ee6..13bf368390680 100644 --- a/RecoTauTag/HLTProducers/interface/CaloTowerFromL1TCreatorForTauHLT.h +++ b/RecoTauTag/HLTProducers/interface/CaloTowerFromL1TCreatorForTauHLT.h @@ -33,7 +33,7 @@ class CaloTowerFromL1TCreatorForTauHLT : public edm::global::EDProducer<> { /// constructor from parameter set CaloTowerFromL1TCreatorForTauHLT(const edm::ParameterSet&); /// destructor - ~CaloTowerFromL1TCreatorForTauHLT() override; + ~CaloTowerFromL1TCreatorForTauHLT() override = default; /// static void fillDescriptions(edm::ConfigurationDescriptions& desc); diff --git a/RecoTauTag/HLTProducers/interface/L1TJetsMatching.h b/RecoTauTag/HLTProducers/interface/L1TJetsMatching.h index e9ec408a4c2ed..f2373f3ca6196 100644 --- a/RecoTauTag/HLTProducers/interface/L1TJetsMatching.h +++ b/RecoTauTag/HLTProducers/interface/L1TJetsMatching.h @@ -52,15 +52,15 @@ template class L1TJetsMatching : public edm::global::EDProducer<> { public: explicit L1TJetsMatching(const edm::ParameterSet&); - ~L1TJetsMatching() override; + ~L1TJetsMatching() override = default; void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: std::pair, std::vector> categorise( const std::vector& pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const; std::tuple, std::vector, std::vector> categoriseVBFPlus2CentralJets( const std::vector& pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const; - -private: const edm::EDGetTokenT> jetSrc_; const edm::EDGetTokenT jetTrigger_; const std::string matchingMode_; @@ -68,7 +68,6 @@ class L1TJetsMatching : public edm::global::EDProducer<> { const double pt2Min_; const double pt3Min_; const double mjjMin_; - const double matchingR_; const double matchingR2_; }; // @@ -80,7 +79,7 @@ std::pair, std::vector> L1TJetsMatching::categorise( std::pair, std::vector> output; unsigned int i1 = 0; unsigned int i2 = 0; - double mjj = 0; + double m2jj = 0; if (pfMatchedJets.size() > 1) { for (unsigned int i = 0; i < pfMatchedJets.size() - 1; i++) { const T& myJet1 = (pfMatchedJets)[i]; @@ -88,10 +87,10 @@ std::pair, std::vector> L1TJetsMatching::categorise( for (unsigned int j = i + 1; j < pfMatchedJets.size(); j++) { const T& myJet2 = (pfMatchedJets)[j]; - const double mjj_test = (myJet1.p4() + myJet2.p4()).M(); + const double m2jj_test = (myJet1.p4() + myJet2.p4()).M2(); - if (mjj_test > mjj) { - mjj = mjj_test; + if (m2jj_test > m2jj) { + m2jj = m2jj_test; i1 = i; i2 = j; } @@ -100,13 +99,14 @@ std::pair, std::vector> L1TJetsMatching::categorise( const T& myJet1 = (pfMatchedJets)[i1]; const T& myJet2 = (pfMatchedJets)[i2]; + const double M2jj = (Mjj > 0. ? Mjj * Mjj : -1.); - if ((mjj > Mjj) && (myJet1.pt() >= pt1) && (myJet2.pt() > pt2)) { + if ((m2jj > M2jj) && (myJet1.pt() >= pt1) && (myJet2.pt() > pt2)) { output.first.push_back(myJet1); output.first.push_back(myJet2); } - if ((mjj > Mjj) && (myJet1.pt() < pt3) && (myJet1.pt() > pt2) && (myJet2.pt() > pt2)) { + if ((m2jj > M2jj) && (myJet1.pt() < pt3) && (myJet1.pt() > pt2) && (myJet2.pt() > pt2)) { const T& myJetTest = (pfMatchedJets)[0]; if (myJetTest.pt() > pt3) { output.second.push_back(myJet1); @@ -125,7 +125,7 @@ std::tuple, std::vector, std::vector> L1TJetsMatching::c unsigned int i1 = 0; unsigned int i2 = 0; - double mjj = 0; + double m2jj = 0; if (pfMatchedJets.size() > 1) { for (unsigned int i = 0; i < pfMatchedJets.size() - 1; i++) { const T& myJet1 = (pfMatchedJets)[i]; @@ -133,10 +133,10 @@ std::tuple, std::vector, std::vector> L1TJetsMatching::c for (unsigned int j = i + 1; j < pfMatchedJets.size(); j++) { const T& myJet2 = (pfMatchedJets)[j]; - const double mjj_test = (myJet1.p4() + myJet2.p4()).M(); + const double m2jj_test = (myJet1.p4() + myJet2.p4()).M2(); - if (mjj_test > mjj) { - mjj = mjj_test; + if (m2jj_test > m2jj) { + m2jj = m2jj_test; i1 = i; i2 = j; } @@ -145,6 +145,7 @@ std::tuple, std::vector, std::vector> L1TJetsMatching::c const T& myJet1 = (pfMatchedJets)[i1]; const T& myJet2 = (pfMatchedJets)[i2]; + const double M2jj = (Mjj > 0. ? Mjj * Mjj : -1.); std::vector vec4jets; vec4jets.reserve(4); @@ -153,7 +154,7 @@ std::tuple, std::vector, std::vector> L1TJetsMatching::c std::vector vec6jets; vec6jets.reserve(6); if (pfMatchedJets.size() > 3) { - if ((mjj > Mjj) && (myJet1.pt() >= pt3) && (myJet2.pt() > pt2)) { + if ((m2jj > M2jj) && (myJet1.pt() >= pt3) && (myJet2.pt() > pt2)) { vec4jets.push_back(myJet1); vec4jets.push_back(myJet2); @@ -166,7 +167,7 @@ std::tuple, std::vector, std::vector> L1TJetsMatching::c } } - if ((mjj > Mjj) && (myJet1.pt() < pt1) && (myJet1.pt() < pt3) && (myJet1.pt() > pt2) && + if ((m2jj > M2jj) && (myJet1.pt() < pt1) && (myJet1.pt() < pt3) && (myJet1.pt() > pt2) && (myJet2.pt() > pt2)) { //60, 30, 50, 500 std::vector idx_jets; @@ -212,8 +213,7 @@ L1TJetsMatching::L1TJetsMatching(const edm::ParameterSet& iConfig) pt2Min_(iConfig.getParameter("pt2Min")), pt3Min_(iConfig.getParameter("pt3Min")), mjjMin_(iConfig.getParameter("mjjMin")), - matchingR_(iConfig.getParameter("matchingR")), - matchingR2_(matchingR_ * matchingR_) { + matchingR2_(iConfig.getParameter("matchingR") * iConfig.getParameter("matchingR")) { if (matchingMode_ == "VBF") { // Default produces>("TwoJets"); produces>("ThreeJets"); @@ -226,8 +226,6 @@ L1TJetsMatching::L1TJetsMatching(const edm::ParameterSet& iConfig) << " (valid values are \"VBF\" and \"VBFPlus2CentralJets\")"; } } -template -L1TJetsMatching::~L1TJetsMatching() {} template void L1TJetsMatching::produce(edm::StreamID iSId, edm::Event& iEvent, const edm::EventSetup& iES) const { diff --git a/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc b/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc index 09c6276403988..e6f24c30f3057 100644 --- a/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc +++ b/RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc @@ -29,9 +29,10 @@ CaloTowerCreatorForTauHLT::CaloTowerCreatorForTauHLT(const ParameterSet& p) produces(); } -CaloTowerCreatorForTauHLT::~CaloTowerCreatorForTauHLT() {} - void CaloTowerCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const { + if (mCone < 0.) + return; + edm::Handle caloTowers; evt.getByToken(mtowers_token, caloTowers); diff --git a/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc b/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc index 92c3ffa06da7a..89053652196f3 100644 --- a/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc +++ b/RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc @@ -29,9 +29,10 @@ CaloTowerFromL1TCreatorForTauHLT::CaloTowerFromL1TCreatorForTauHLT(const Paramet produces(); } -CaloTowerFromL1TCreatorForTauHLT::~CaloTowerFromL1TCreatorForTauHLT() {} - void CaloTowerFromL1TCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const { + if (mCone < 0.) + return; + edm::Handle caloTowers; evt.getByToken(mtowers_token, caloTowers); diff --git a/RecoTauTag/HLTProducers/src/HLTPFDiJetCorrCheckerWithDiTau.cc b/RecoTauTag/HLTProducers/src/HLTPFDiJetCorrCheckerWithDiTau.cc index 5da223bfad6f4..856dcf645d8ae 100644 --- a/RecoTauTag/HLTProducers/src/HLTPFDiJetCorrCheckerWithDiTau.cc +++ b/RecoTauTag/HLTProducers/src/HLTPFDiJetCorrCheckerWithDiTau.cc @@ -38,7 +38,7 @@ class HLTPFDiJetCorrCheckerWithDiTau : public edm::global::EDProducer<> { const edm::EDGetTokenT tauSrc_; const edm::EDGetTokenT pfJetSrc_; const double extraTauPtCut_; - const double m2jjMin_; + const double mjjMin_, m2jjMin_; const double dRmin_, dRmin2_; // pt comparator GreaterByPt pTComparator_; @@ -51,7 +51,8 @@ HLTPFDiJetCorrCheckerWithDiTau::HLTPFDiJetCorrCheckerWithDiTau(const edm::Parame : tauSrc_(consumes(iConfig.getParameter("tauSrc"))), pfJetSrc_(consumes(iConfig.getParameter("pfJetSrc"))), extraTauPtCut_(iConfig.getParameter("extraTauPtCut")), - m2jjMin_(iConfig.getParameter("mjjMin") * iConfig.getParameter("mjjMin")), + mjjMin_(iConfig.getParameter("mjjMin")), + m2jjMin_(mjjMin_ * mjjMin_), dRmin_(iConfig.getParameter("dRmin")), dRmin2_(dRmin_ * dRmin_) { if (dRmin_ <= 0.) { @@ -78,7 +79,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()).M2() < m2jjMin_) + if (mjjMin_ <= 0. || (myPFJet1.p4() + myPFJet2.p4()).M2() < m2jjMin_) continue; for (unsigned int iTau1 = 0; iTau1 < taus.size(); iTau1++) {