From 096458d7176fb54b10fed7685db0de51f24a48b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Brochet?= Date: Thu, 1 Oct 2015 10:57:22 +0200 Subject: [PATCH] Store jetid for jets and fat jets --- interface/FatJetsProducer.h | 4 ++++ interface/JetsProducer.h | 5 +++++ interface/Tools.h | 26 ++++++++++++++++++++++++++ src/FatJetsProducer.cc | 6 +++++- src/JetsProducer.cc | 6 +++++- src/Tools.cc | 37 +++++++++++++++++++++++++++++++++++++ 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 interface/Tools.h create mode 100644 src/Tools.cc diff --git a/interface/FatJetsProducer.h b/interface/FatJetsProducer.h index 66101b0..4a62f5f 100644 --- a/interface/FatJetsProducer.h +++ b/interface/FatJetsProducer.h @@ -64,6 +64,10 @@ class FatJetsProducer: public CandidatesProducer, public BTaggingScale std::vector& hadronFlavor = tree["hadronFlavor"].write>(); std::vector& jecFactor = tree["jecFactor"].write>(); + BRANCH(passLooseID, std::vector); + BRANCH(passTightID, std::vector); + BRANCH(passTightLeptonVetoID, std::vector); + BRANCH(tau1, std::vector); BRANCH(tau2, std::vector); BRANCH(tau3, std::vector); diff --git a/interface/JetsProducer.h b/interface/JetsProducer.h index 7625d06..91eeae4 100644 --- a/interface/JetsProducer.h +++ b/interface/JetsProducer.h @@ -6,6 +6,7 @@ #include + class JetsProducer: public CandidatesProducer, public BTaggingScaleFactors { public: JetsProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config): @@ -49,6 +50,10 @@ class JetsProducer: public CandidatesProducer, public BTaggingScaleFac std::vector& jecFactor = tree["jecFactor"].write>(); std::vector& puJetID = tree["puJetID"].write>(); std::vector& vtxMass = tree["vtxMass"].write>(); + + BRANCH(passLooseID, std::vector); + BRANCH(passTightID, std::vector); + BRANCH(passTightLeptonVetoID, std::vector); }; #endif diff --git a/interface/Tools.h b/interface/Tools.h new file mode 100644 index 0000000..45c19ea --- /dev/null +++ b/interface/Tools.h @@ -0,0 +1,26 @@ +#pragma once + +namespace pat { + class Jet; +} + +namespace Tools { + namespace Jets { + + // Jet id: https://twiki.cern.ch/twiki/bin/view/CMS/JetID#Recommendations_for_13_TeV_data +#define DECLARE_QUANTITIES(jet) \ + float eta = jet.eta(); \ + float NHF = jet.neutralHadronEnergyFraction(); \ + float NEMF = jet.neutralEmEnergyFraction(); \ + float CHF = jet.chargedHadronEnergyFraction(); \ + float MUF = jet.muonEnergyFraction(); \ + float CEMF = jet.chargedEmEnergyFraction(); \ + size_t NumConst = jet.chargedMultiplicity() + jet.neutralMultiplicity(); \ + size_t NumNeutralParticles = jet.neutralMultiplicity(); \ + size_t CHM = jet.chargedMultiplicity(); + + bool passLooseId(const pat::Jet& jet); + bool passTightId(const pat::Jet& jet); + bool passTightLeptonVetoId(const pat::Jet& jet); + }; +}; diff --git a/src/FatJetsProducer.cc b/src/FatJetsProducer.cc index 04e239a..25c5cd2 100644 --- a/src/FatJetsProducer.cc +++ b/src/FatJetsProducer.cc @@ -1,7 +1,7 @@ #include +#include #include - void FatJetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) { edm::Handle> jets; @@ -18,6 +18,10 @@ void FatJetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSet partonFlavor.push_back(jet.partonFlavour()); hadronFlavor.push_back(jet.hadronFlavour()); + passLooseID.push_back(Tools::Jets::passLooseId(jet)); + passTightID.push_back(Tools::Jets::passTightId(jet)); + passTightLeptonVetoID.push_back(Tools::Jets::passTightLeptonVetoId(jet)); + tau1.push_back(jet.userFloat("NjettinessAK8:tau1")); tau2.push_back(jet.userFloat("NjettinessAK8:tau2")); tau3.push_back(jet.userFloat("NjettinessAK8:tau3")); diff --git a/src/JetsProducer.cc b/src/JetsProducer.cc index 3380234..c4f2093 100644 --- a/src/JetsProducer.cc +++ b/src/JetsProducer.cc @@ -1,5 +1,5 @@ - #include +#include void JetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) { @@ -17,6 +17,10 @@ void JetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) partonFlavor.push_back(jet.partonFlavour()); hadronFlavor.push_back(jet.hadronFlavour()); + passLooseID.push_back(Tools::Jets::passLooseId(jet)); + passTightID.push_back(Tools::Jets::passTightId(jet)); + passTightLeptonVetoID.push_back(Tools::Jets::passTightLeptonVetoId(jet)); + if (jet.hasUserFloat("pileupJetId:fullDiscriminant")) puJetID.push_back(jet.userFloat("pileupJetId:fullDiscriminant")); diff --git a/src/Tools.cc b/src/Tools.cc new file mode 100644 index 0000000..ad9335f --- /dev/null +++ b/src/Tools.cc @@ -0,0 +1,37 @@ +#include +#include + +namespace Tools { + namespace Jets { + + // Jet id: https://twiki.cern.ch/twiki/bin/view/CMS/JetID#Recommendations_for_13_TeV_data +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" + bool passLooseId(const pat::Jet& jet) { + DECLARE_QUANTITIES(jet); + + if (fabs(eta) <= 3.0) { + return (NHF < 0.99 && NEMF < 0.99 && NumConst > 1) && ((fabs(eta) <= 2.4 && CHF > 0 && CHM > 0 && CEMF < 0.99) || fabs(eta) > 2.4); + } else { + return (NEMF < 0.90 && NumNeutralParticles > 10); + } + } + + bool passTightId(const pat::Jet& jet) { + DECLARE_QUANTITIES(jet); + + if (fabs(eta) <= 3.0) { + return (NHF < 0.90 && NEMF < 0.90 && NumConst > 1) && ((fabs(eta) <= 2.4 && CHF > 0 && CHM > 0 && CEMF < 0.99) || fabs(eta) > 2.4); + } else { + return (NEMF < 0.90 && NumNeutralParticles > 10); + } + } + + bool passTightLeptonVetoId(const pat::Jet& jet) { + DECLARE_QUANTITIES(jet); + + return (NHF < 0.90 && NEMF < 0.90 && NumConst > 1 && MUF < 0.8) && ((fabs(eta) <= 2.4 && CHF > 0 && CHM > 0 && CEMF < 0.90) || fabs(eta) > 2.4) && fabs(eta) <= 3.0; + } +#pragma GCC diagnostic pop + }; +};