Permalink
Browse files

Keep puid and deep flavor by doing shitty dR matching.

  • Loading branch information...
dabercro committed Nov 13, 2017
1 parent 6d45403 commit 8d11a8ac667a693168b2a9b252a692c3ad68a2b2
View
@@ -309,7 +309,7 @@
### QG TAGGING
process.load('RecoJets.JetProducers.QGTagger_cfi')
process.QGTagger.srcJets = 'slimmedJetsDeepFlavor'
process.QGTagger.srcJets = 'slimmedJets'
### Pileup ID
@@ -7,6 +7,7 @@
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
#include <functional>
@@ -30,6 +31,7 @@ class JetsFiller : public FillerBase {
typedef edm::ValueMap<float> FloatMap;
NamedToken<JetView> jetsToken_;
NamedToken<edm::View<pat::Jet>> flavoredJetsToken_;
NamedToken<GenJetView> genJetsToken_;
NamedToken<FloatMap> qglToken_;
NamedToken<double> rhoToken_;
@@ -23,7 +23,8 @@
chsAK4Jets = cms.untracked.PSet(
enabled = cms.untracked.bool(True),
filler = cms.untracked.string('Jets'),
jets = cms.untracked.string('slimmedJetsDeepFlavor'),
jets = cms.untracked.string('slimmedJets'),
flavoredJets = cms.untracked.string('slimmedJetsDeepFlavor'),
genJets = cms.untracked.string('slimmedGenJets'),
pandaGenJets = cms.untracked.string('ak4GenJets'),
jec = cms.untracked.string('AK4PFchs'),
@@ -32,7 +33,7 @@
cmva = cms.untracked.string('pfCombinedMVAV2BJetTags'),
deepCSV = cms.untracked.string('pfDeepCSVJetTags'),
deepCMVA = cms.untracked.string('pfDeepCMVAJetTags'),
# puid = cms.untracked.string('pileupJetId:fullDiscriminant'),
puid = cms.untracked.string('pileupJetId:fullDiscriminant'),
qgl = cms.untracked.string('QGTagger:qgLikelihood'),
R = cms.untracked.double(0.4),
fillConstituents = cms.untracked.bool(True),
@@ -115,7 +115,7 @@ def makeIvfTagInfos(ipTagInfosName, vsuffix, deltaR = 0.3):
# Give the list of btag discriminators (see below for names) in tags to run only a part of the full menu.
# vsuffix is the suffix given to initBTag that defines the secondary vertexing sequence.
# The optional argument addedTagInfos can be used to retrieve back the TagInfo modules added in order to compute the specified btag discriminators.
def setupBTag(process, jetCollection, suffix, vsuffix, muons = 'muons', electrons = 'gedGsfElectrons', tags = [], addedTagInfos = []):
def setupBTag(process, jetCollection, suffix, vsuffix, muons = 'slimmedMuons', electrons = 'slimmedElectrons', tags = [], addedTagInfos = []):
"""
Configure the BTag sequence for the given jet collection.
The suffix will be appended to the CMSSW module names to
View
@@ -57,6 +57,7 @@ JetsFiller::JetsFiller(std::string const& _name, edm::ParameterSet const& _cfg,
throw edm::Exception(edm::errors::Configuration, "Unknown JetCollection output");
getToken_(jetsToken_, _cfg, _coll, "jets");
getToken_(flavoredJetsToken_, _cfg, _coll, "flavoredJets", false);
getToken_(qglToken_, _cfg, _coll, "qgl", false);
if (!isRealData_) {
getToken_(genJetsToken_, _cfg, _coll, "genJets", false);
@@ -149,6 +150,8 @@ JetsFiller::fill(panda::Event& _outEvent, edm::Event const& _inEvent, edm::Event
if (!qglToken_.second.isUninitialized())
inQGL = &getProduct_(_inEvent, qglToken_);
auto* flavoredJets(flavoredJetsToken_.second.isUninitialized() ? nullptr : &getProduct_(_inEvent, flavoredJetsToken_));
std::vector<edm::Ptr<reco::Jet>> ptrList;
std::vector<edm::Ptr<reco::GenJet>> matchedGenJets;
@@ -169,6 +172,16 @@ JetsFiller::fill(panda::Event& _outEvent, edm::Event const& _inEvent, edm::Event
if (dynamic_cast<pat::Jet const*>(&inJet)) {
auto& patJet(static_cast<pat::Jet const&>(inJet));
const pat::Jet* flavoredJet(flavoredJets == nullptr ? &patJet : nullptr);
if (flavoredJet == nullptr) {
for (auto& inFlavored : *flavoredJets) {
if (reco::deltaR(patJet, inFlavored) < 0.2) {
flavoredJet = &inFlavored;
break;
}
}
}
double nhf(patJet.neutralHadronEnergyFraction());
double nef(patJet.neutralEmEnergyFraction());
double chf(patJet.chargedHadronEnergyFraction());
@@ -259,15 +272,17 @@ JetsFiller::fill(panda::Event& _outEvent, edm::Event const& _inEvent, edm::Event
if (!cmvaTag_.empty())
outJet.cmva = patJet.bDiscriminator(cmvaTag_);
if (!deepCsvTag_.empty()) {
for (auto prob : deepProbs) {
fillDeepBySwitch_(outJet, prob.second, patJet.bDiscriminator(deepCsvTag_ + ":prob" + prob.first));
if (flavoredJet != nullptr) { // If hacky matching failed, don't try to fill deep flavor
if (!deepCsvTag_.empty()) {
for (auto prob : deepProbs) {
fillDeepBySwitch_(outJet, prob.second, flavoredJet->bDiscriminator(deepCsvTag_ + ":prob" + prob.first));
}
}
}
if (!deepCmvaTag_.empty()) {
for (auto prob : deepProbs) {
fillDeepBySwitch_(outJet, prob.second + deepSuff::DEEP_SIZE, patJet.bDiscriminator(deepCmvaTag_ + ":prob" + prob.first));
if (!deepCmvaTag_.empty()) {
for (auto prob : deepProbs) {
fillDeepBySwitch_(outJet, prob.second + deepSuff::DEEP_SIZE, flavoredJet->bDiscriminator(deepCmvaTag_ + ":prob" + prob.first));
}
}
}

0 comments on commit 8d11a8a

Please sign in to comment.