Skip to content

Commit

Permalink
Merge pull request #69 from blinkseb/jetid
Browse files Browse the repository at this point in the history
Store jetid for jets and fat jets
  • Loading branch information
OlivierBondu committed Oct 1, 2015
2 parents 9b7931e + 096458d commit 6c5e8d1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
4 changes: 4 additions & 0 deletions interface/FatJetsProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class FatJetsProducer: public CandidatesProducer<pat::Jet>, public BTaggingScale
std::vector<int8_t>& hadronFlavor = tree["hadronFlavor"].write<std::vector<int8_t>>();
std::vector<float>& jecFactor = tree["jecFactor"].write<std::vector<float>>();

BRANCH(passLooseID, std::vector<bool>);
BRANCH(passTightID, std::vector<bool>);
BRANCH(passTightLeptonVetoID, std::vector<bool>);

BRANCH(tau1, std::vector<float>);
BRANCH(tau2, std::vector<float>);
BRANCH(tau3, std::vector<float>);
Expand Down
5 changes: 5 additions & 0 deletions interface/JetsProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <DataFormats/PatCandidates/interface/Jet.h>


class JetsProducer: public CandidatesProducer<pat::Jet>, public BTaggingScaleFactors {
public:
JetsProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
Expand Down Expand Up @@ -49,6 +50,10 @@ class JetsProducer: public CandidatesProducer<pat::Jet>, public BTaggingScaleFac
std::vector<float>& jecFactor = tree["jecFactor"].write<std::vector<float>>();
std::vector<float>& puJetID = tree["puJetID"].write<std::vector<float>>();
std::vector<float>& vtxMass = tree["vtxMass"].write<std::vector<float>>();

BRANCH(passLooseID, std::vector<bool>);
BRANCH(passTightID, std::vector<bool>);
BRANCH(passTightLeptonVetoID, std::vector<bool>);
};

#endif
26 changes: 26 additions & 0 deletions interface/Tools.h
Original file line number Diff line number Diff line change
@@ -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);
};
};
6 changes: 5 additions & 1 deletion src/FatJetsProducer.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <cp3_llbb/Framework/interface/FatJetsProducer.h>
#include <cp3_llbb/Framework/interface/Tools.h>
#include <DataFormats/BTauReco/interface/CATopJetTagInfo.h>


void FatJetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {

edm::Handle<std::vector<pat::Jet>> jets;
Expand All @@ -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"));
Expand Down
6 changes: 5 additions & 1 deletion src/JetsProducer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include <cp3_llbb/Framework/interface/JetsProducer.h>
#include <cp3_llbb/Framework/interface/Tools.h>

void JetsProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {

Expand All @@ -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"));

Expand Down
37 changes: 37 additions & 0 deletions src/Tools.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cp3_llbb/Framework/interface/Tools.h>
#include <DataFormats/PatCandidates/interface/Jet.h>

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
};
};

0 comments on commit 6c5e8d1

Please sign in to comment.