Skip to content

Commit

Permalink
Consider possible negative values of the parameter as a way to skip c…
Browse files Browse the repository at this point in the history
…omparisons
  • Loading branch information
perrotta committed Mar 20, 2023
1 parent 396f34b commit 2ccf189
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
38 changes: 18 additions & 20 deletions RecoTauTag/HLTProducers/interface/L1TJetsMatching.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,22 @@ template <typename T>
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<T>, std::vector<T>> categorise(
const std::vector<T>& pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const;
std::tuple<std::vector<T>, std::vector<T>, std::vector<T>> categoriseVBFPlus2CentralJets(
const std::vector<T>& pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const;

private:
const edm::EDGetTokenT<std::vector<T>> jetSrc_;
const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> jetTrigger_;
const std::string matchingMode_;
const double pt1Min_;
const double pt2Min_;
const double pt3Min_;
const double mjjMin_;
const double matchingR_;
const double matchingR2_;
};
//
Expand All @@ -80,18 +79,18 @@ std::pair<std::vector<T>, std::vector<T>> L1TJetsMatching<T>::categorise(
std::pair<std::vector<T>, std::vector<T>> 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];

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;
}
Expand All @@ -100,13 +99,14 @@ std::pair<std::vector<T>, std::vector<T>> L1TJetsMatching<T>::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);
Expand All @@ -125,18 +125,18 @@ std::tuple<std::vector<T>, std::vector<T>, std::vector<T>> L1TJetsMatching<T>::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];

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;
}
Expand All @@ -145,6 +145,7 @@ std::tuple<std::vector<T>, std::vector<T>, std::vector<T>> L1TJetsMatching<T>::c

const T& myJet1 = (pfMatchedJets)[i1];
const T& myJet2 = (pfMatchedJets)[i2];
const double M2jj = (Mjj > 0. ? Mjj * Mjj : -1.);

std::vector<T> vec4jets;
vec4jets.reserve(4);
Expand All @@ -153,7 +154,7 @@ std::tuple<std::vector<T>, std::vector<T>, std::vector<T>> L1TJetsMatching<T>::c
std::vector<T> 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);

Expand All @@ -166,7 +167,7 @@ std::tuple<std::vector<T>, std::vector<T>, std::vector<T>> L1TJetsMatching<T>::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<unsigned int> idx_jets;
Expand Down Expand Up @@ -212,8 +213,7 @@ L1TJetsMatching<T>::L1TJetsMatching(const edm::ParameterSet& iConfig)
pt2Min_(iConfig.getParameter<double>("pt2Min")),
pt3Min_(iConfig.getParameter<double>("pt3Min")),
mjjMin_(iConfig.getParameter<double>("mjjMin")),
matchingR_(iConfig.getParameter<double>("matchingR")),
matchingR2_(matchingR_ * matchingR_) {
matchingR2_(iConfig.getParameter<double>("matchingR") * iConfig.getParameter<double>("matchingR")) {
if (matchingMode_ == "VBF") { // Default
produces<std::vector<T>>("TwoJets");
produces<std::vector<T>>("ThreeJets");
Expand All @@ -226,8 +226,6 @@ L1TJetsMatching<T>::L1TJetsMatching(const edm::ParameterSet& iConfig)
<< " (valid values are \"VBF\" and \"VBFPlus2CentralJets\")";
}
}
template <typename T>
L1TJetsMatching<T>::~L1TJetsMatching() {}

template <typename T>
void L1TJetsMatching<T>::produce(edm::StreamID iSId, edm::Event& iEvent, const edm::EventSetup& iES) const {
Expand Down
5 changes: 3 additions & 2 deletions RecoTauTag/HLTProducers/src/CaloTowerCreatorForTauHLT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ CaloTowerCreatorForTauHLT::CaloTowerCreatorForTauHLT(const ParameterSet& p)
produces<CaloTowerCollection>();
}

CaloTowerCreatorForTauHLT::~CaloTowerCreatorForTauHLT() {}

void CaloTowerCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
if (mCone < 0.)
return;

edm::Handle<CaloTowerCollection> caloTowers;
evt.getByToken(mtowers_token, caloTowers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ CaloTowerFromL1TCreatorForTauHLT::CaloTowerFromL1TCreatorForTauHLT(const Paramet
produces<CaloTowerCollection>();
}

CaloTowerFromL1TCreatorForTauHLT::~CaloTowerFromL1TCreatorForTauHLT() {}

void CaloTowerFromL1TCreatorForTauHLT::produce(StreamID sid, Event& evt, const EventSetup& stp) const {
if (mCone < 0.)
return;

edm::Handle<CaloTowerCollection> caloTowers;
evt.getByToken(mtowers_token, caloTowers);

Expand Down
7 changes: 4 additions & 3 deletions RecoTauTag/HLTProducers/src/HLTPFDiJetCorrCheckerWithDiTau.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,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 m2jjMin_;
const double mjjMin_, m2jjMin_;
const double dRmin_, dRmin2_;
// pt comparator
GreaterByPt<reco::PFJet> pTComparator_;
Expand All @@ -51,7 +51,8 @@ HLTPFDiJetCorrCheckerWithDiTau::HLTPFDiJetCorrCheckerWithDiTau(const edm::Parame
: tauSrc_(consumes(iConfig.getParameter<edm::InputTag>("tauSrc"))),
pfJetSrc_(consumes(iConfig.getParameter<edm::InputTag>("pfJetSrc"))),
extraTauPtCut_(iConfig.getParameter<double>("extraTauPtCut")),
m2jjMin_(iConfig.getParameter<double>("mjjMin") * iConfig.getParameter<double>("mjjMin")),
mjjMin_(iConfig.getParameter<double>("mjjMin")),
m2jjMin_(mjjMin_ * mjjMin_),
dRmin_(iConfig.getParameter<double>("dRmin")),
dRmin2_(dRmin_ * dRmin_) {
if (dRmin_ <= 0.) {
Expand All @@ -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++) {
Expand Down

0 comments on commit 2ccf189

Please sign in to comment.