Skip to content

Commit

Permalink
Merge pull request cms-sw#15 from astakia/add_leptonic_b
Browse files Browse the repository at this point in the history
Changes to include leptonic b (and c inside b) decays
  • Loading branch information
jkiesele authored Mar 22, 2017
2 parents ae7d89d + d794257 commit 2b59d69
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 124 deletions.
4 changes: 2 additions & 2 deletions DeepNtuplizer/interface/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "DataFormats/PatCandidates/interface/Jet.h"

namespace deep_ntuples {
enum JetFlavor {UNDEFINED, G, L, C, B, BB};
JetFlavor jet_flavour(const pat::Jet& jet);
enum JetFlavor {UNDEFINED, G, L, C, B, BB, LeptonicB, LeptonicB_C};
JetFlavor jet_flavour(const pat::Jet& jet, std::vector<reco::GenParticle> neutrinosLepB, std::vector<reco::GenParticle> neutrinosLepB_C);
}

#endif //DEEPNTUPLES_DEEPNTUPLIZER_INTERFACE_HELPERS_H_
14 changes: 13 additions & 1 deletion DeepNtuplizer/interface/ntuple_JetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ class ntuple_JetInfo: public ntuple_content{
genJetMatchWithNuToken_ = genJetMatchWithNuToken;
}


void setGenParticlesToken(
edm::EDGetTokenT<reco::GenParticleCollection> genParticlesToken) {
genParticlesToken_ = genParticlesToken;
}

//private:

Expand All @@ -80,12 +83,19 @@ class ntuple_JetInfo: public ntuple_content{
edm::EDGetTokenT<edm::Association<reco::GenJetCollection> > genJetMatchReclusterToken_;
edm::EDGetTokenT<edm::Association<reco::GenJetCollection> > genJetMatchWithNuToken_;

edm::EDGetTokenT<reco::GenParticleCollection> genParticlesToken_;

edm::Handle<edm::Association<reco::GenJetCollection> > genJetMatchRecluster;
edm::Handle<edm::Association<reco::GenJetCollection> > genJetMatchWithNu;

edm::Handle<reco::GenParticleCollection> genParticlesHandle;

TRandom3 TRandom_;
float gluonReduction_;

std::vector < reco::GenParticle> neutrinosLepB;
std::vector < reco::GenParticle> neutrinosLepB_C;

// labels (MC truth)
// regressions pt, Deta, Dphi
float gen_pt_;
Expand All @@ -95,6 +105,8 @@ class ntuple_JetInfo: public ntuple_content{
int isC_;
int isUDS_;
int isG_;
int isLeptonicB_;
int isLeptonicB_C_;

// global variables
float npv_;
Expand Down
6 changes: 5 additions & 1 deletion DeepNtuplizer/plugins/DeepNtuplizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ DeepNtuplizer::DeepNtuplizer(const edm::ParameterSet& iConfig):
jetinfo->setGenJetMatchWithNuToken(
consumes<edm::Association<reco::GenJetCollection> >(
iConfig.getParameter<edm::InputTag>( "genJetMatchWithNu" )));
addModule(jetinfo);

jetinfo->setGenParticlesToken(
consumes<reco::GenParticleCollection>(
iConfig.getParameter<edm::InputTag>("pruned")));

addModule(jetinfo);

ntuple_pfCands * pfcands = new ntuple_pfCands();
addModule(pfcands);
Expand Down
1 change: 1 addition & 0 deletions DeepNtuplizer/python/DeepNtuplizer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
SVs = cms.InputTag("slimmedSecondaryVertices"),
genJetMatchWithNu = cms.InputTag("patGenJetMatchWithNu"),
genJetMatchRecluster = cms.InputTag("patGenJetMatchRecluster"),
pruned = cms.InputTag("prunedGenParticles"),
jetPtMin = cms.double(20.0),
jetPtMax = cms.double(100),
jetAbsEtaMin = cms.double(0.0),
Expand Down
22 changes: 17 additions & 5 deletions DeepNtuplizer/src/helpers.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
#include "../interface/helpers.h"

namespace deep_ntuples {
JetFlavor jet_flavour(const pat::Jet& jet) {
JetFlavor jet_flavour(const pat::Jet& jet, std::vector<reco::GenParticle> neutrinosLepB, std::vector<reco::GenParticle> neutrinosLepB_C) {
int hflav = abs(jet.hadronFlavour());
int pflav = abs(jet.partonFlavour());
size_t nbs = jet.jetFlavourInfo().getbHadrons().size();
size_t ncs = jet.jetFlavourInfo().getcHadrons().size();

if(hflav == 5) { //B jet
if(nbs > 1) return JetFlavor::BB;
else if(nbs == 1) return JetFlavor::B;
else return JetFlavor::UNDEFINED;
}
if(nbs > 1) return JetFlavor::BB;
else if(nbs == 1) {
for (std::vector<reco::GenParticle>::iterator it = neutrinosLepB.begin(); it != neutrinosLepB.end(); ++it){
if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) {
return JetFlavor::LeptonicB;
}
}
for (std::vector<reco::GenParticle>::iterator it = neutrinosLepB_C.begin(); it != neutrinosLepB_C.end(); ++it){
if(reco::deltaR(it->eta(),it->phi(),jet.eta(),jet.phi()) < 0.4) {
return JetFlavor::LeptonicB_C;
}
}
return JetFlavor::B;
}
else return JetFlavor::UNDEFINED;
}
else if(hflav == 4) { //C jet
return JetFlavor::C;
}
Expand Down
Loading

0 comments on commit 2b59d69

Please sign in to comment.