New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenJetFlavourInfos in MiniAOD and Change in JetFlavour of LightJets to physicsPartons in CMSSW 92X #19048
GenJetFlavourInfos in MiniAOD and Change in JetFlavour of LightJets to physicsPartons in CMSSW 92X #19048
Changes from 14 commits
ca2abcf
649dfa8
0f4b578
9a6d45d
ea57cff
eeeaebd
632b72e
bdb574e
3ee6d5c
5355844
f3768ff
f37b635
73ee068
c783efc
eecae16
1ea8433
9a80eee
7d7b57f
9c0baa9
7914385
c5ed70c
19314ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi import ak4JetFlavourInfos | ||
|
||
ak4GenJetFlavourInfos = ak4JetFlavourInfos.clone(jets = "ak4GenJetsNoNu") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
\class pat::GenJetFlavourInfoPreserver GenJetFlavourInfoPreserver.h "PhysicsTools/JetMCAlgos/interface/GenJetFlavourInfoPreserver.h" | ||
\brief Transfers the JetFlavourInfos from the original GenJets to the slimmedGenJets in MiniAOD | ||
|
||
\author Andrej Saibel, andrej.saibel@cern.ch | ||
*/ | ||
|
||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "CommonTools/Utils/interface/StringCutObjectSelector.h" | ||
#include "DataFormats/Common/interface/Association.h" | ||
#include "DataFormats/Common/interface/RefToPtr.h" | ||
#include "DataFormats/PatCandidates/interface/PackedGenParticle.h" | ||
#include "DataFormats/JetReco/interface/GenJet.h" | ||
|
||
#include "DataFormats/JetReco/interface/Jet.h" | ||
#include "DataFormats/JetReco/interface/JetCollection.h" | ||
#include "SimDataFormats/JetMatching/interface/JetFlavourInfo.h" | ||
#include "SimDataFormats/JetMatching/interface/JetFlavourInfoMatching.h" | ||
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" | ||
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" | ||
|
||
|
||
namespace pat { | ||
|
||
class GenJetFlavourInfoPreserver : public edm::stream::EDProducer<> { | ||
public: | ||
explicit GenJetFlavourInfoPreserver(const edm::ParameterSet & iConfig); | ||
virtual ~GenJetFlavourInfoPreserver() { } | ||
|
||
virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override; | ||
|
||
private: | ||
const edm::EDGetTokenT<edm::View<reco::GenJet> > genJetsToken_; | ||
const edm::EDGetTokenT<edm::View<reco::Jet> > slimmedGenJetsToken_; | ||
|
||
const StringCutObjectSelector<reco::GenJet> cut_; | ||
|
||
const edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> genJetFlavourInfosToken_; | ||
}; | ||
|
||
} // namespace | ||
|
||
pat::GenJetFlavourInfoPreserver::GenJetFlavourInfoPreserver(const edm::ParameterSet & iConfig) : | ||
genJetsToken_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("genJets"))), | ||
slimmedGenJetsToken_(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("slimmedGenJets"))), | ||
cut_(iConfig.getParameter<std::string>("cut")), | ||
genJetFlavourInfosToken_(consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("genJetFlavourInfos"))) | ||
{ | ||
produces<reco::JetFlavourInfoMatchingCollection>(); | ||
} | ||
|
||
void | ||
pat::GenJetFlavourInfoPreserver::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { | ||
using namespace edm; | ||
using namespace std; | ||
|
||
Handle<View<reco::GenJet> > genJets; | ||
iEvent.getByToken(genJetsToken_, genJets); | ||
|
||
Handle<View<reco::Jet> > slimmedGenJets; | ||
iEvent.getByToken(slimmedGenJetsToken_, slimmedGenJets); | ||
|
||
Handle<reco::JetFlavourInfoMatchingCollection> genJetFlavourInfos; | ||
iEvent.getByToken(genJetFlavourInfosToken_, genJetFlavourInfos); | ||
|
||
auto jetFlavourInfos = std::make_unique<reco::JetFlavourInfoMatchingCollection>(reco::JetRefBaseProd(slimmedGenJets)); | ||
|
||
|
||
uint slimmedId = 0; | ||
|
||
auto jetIt = genJets->begin(), jetEnd = genJets->end(); | ||
auto jetInfoIt = genJetFlavourInfos->begin(); | ||
assert(genJets->size() == genJetFlavourInfos->size()); | ||
|
||
for(; jetIt != jetEnd; ++jetIt, ++jetInfoIt){ | ||
if (!cut_(*jetIt)) continue; | ||
|
||
(*jetFlavourInfos)[slimmedGenJets->refAt(slimmedId)] = reco::JetFlavourInfo(jetInfoIt->second.getbHadrons(), | ||
jetInfoIt->second.getcHadrons(), | ||
jetInfoIt->second.getPartons(), | ||
jetInfoIt->second.getLeptons(), | ||
jetInfoIt->second.getHadronFlavour(), | ||
jetInfoIt->second.getPartonFlavour()); | ||
slimmedId++; | ||
|
||
} | ||
|
||
|
||
iEvent.put(std::move(jetFlavourInfos)); | ||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
using namespace pat; | ||
DEFINE_FWK_MODULE(GenJetFlavourInfoPreserver); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,9 +322,20 @@ def miniAOD_customizeCommon(process): | |
|
||
|
||
def miniAOD_customizeMC(process): | ||
task = getPatAlgosToolsTask(process) | ||
#GenJetFlavourInfos | ||
process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi") | ||
process.selectedHadronsAndPartons.particles = "prunedGenParticles" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If selectedHadronsAndPartons is ran with prunedGenParticles as input, it will not get the full tree of particles, but only status=1 and status=23 particles saved on MiniAOD, but not the intermediate particles. |
||
task.add(process.selectedHadronsAndPartons) | ||
|
||
|
||
process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. selectedHadronsAndPartons and ak4GenJetFlavourInfos should be added to the task (as done below) |
||
task.add(process.ak4GenJetFlavourInfos) | ||
|
||
task.add(process.slimmedGenJetsFlavourInfos) | ||
|
||
#slimmed pileup information | ||
process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi') | ||
task = getPatAlgosToolsTask(process) | ||
task.add(process.slimmedAddPileupInfo) | ||
|
||
process.muonMatch.matched = "prunedGenParticles" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,12 @@ | |
dropSpecific = cms.bool(False), | ||
) | ||
|
||
slimmedGenJetsFlavourInfos = cms.EDProducer("GenJetFlavourInfoPreserver", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cfi files are not meant for definitions of many types of module instances. Better yet is to implement a fillDescriptions method and let the framework create this file |
||
genJets = cms.InputTag("ak4GenJetsNoNu"), | ||
slimmedGenJets = cms.InputTag("slimmedGenJets"), | ||
cut = cms.string("pt > 8"), #VERY IMPORTANT: cut needs to be the same as in slimmedGenJets above. | ||
genJetFlavourInfos = cms.InputTag("ak4GenJetFlavourInfos") | ||
) | ||
|
||
slimmedGenJetsAK8 = cms.EDProducer("PATGenJetSlimmer", | ||
src = cms.InputTag("ak8GenJetsNoNu"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the same be applied to other available instances of JetFlavourClustering in this package?
There is one in AK5