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 all 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,5 @@ | ||
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,88 @@ | ||
/** | ||
\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 "DataFormats/Common/interface/Association.h" | ||
#include "DataFormats/Common/interface/RefToPtr.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/JetReco/interface/GenJet.h" | ||
#include "DataFormats/JetReco/interface/GenJetCollection.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 edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> genJetFlavourInfosToken_; | ||
const edm::EDGetTokenT<edm::Association<std::vector<reco::GenJet> > > slimmedGenJetAssociationToken_; | ||
}; | ||
|
||
} // 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"))), | ||
genJetFlavourInfosToken_(consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("genJetFlavourInfos"))), | ||
slimmedGenJetAssociationToken_(consumes<edm::Association<std::vector<reco::GenJet> > >(iConfig.getParameter<edm::InputTag>("slimmedGenJetAssociation"))) | ||
{ | ||
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); | ||
|
||
Handle<edm::Association<std::vector<reco::GenJet> > > slimmedGenJetAssociation; | ||
iEvent.getByToken(slimmedGenJetAssociationToken_, slimmedGenJetAssociation); | ||
|
||
auto jetFlavourInfos = std::make_unique<reco::JetFlavourInfoMatchingCollection>(reco::JetRefBaseProd(slimmedGenJets)); | ||
assert(genJets->size() == genJetFlavourInfos->size()); | ||
|
||
edm::Ref<std::vector<reco::GenJet> > slimmedGenJetRef; | ||
|
||
int i = -1; | ||
for (auto const& genJet : *genJets){ | ||
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. hi @Andrej-CMS @slava77 @perrotta - this brings a warning as genJet is not actually used. Please change to a loop over i if genJets->refAt(i) is not the same as genJet in the loop below 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. Hello @davidlange6 , I just pushed the changes to the initial branch on my repository: https://github.com/Andrej-CMS/cmssw/tree/JetFlavourMiniAOD92X Since the changes here are already merged, do I need to make a new PR? Kind regards, |
||
i++; | ||
slimmedGenJetRef = (*slimmedGenJetAssociation)[genJets->refAt(i)]; | ||
if(!slimmedGenJetRef) continue; | ||
(*jetFlavourInfos)[reco::JetBaseRef(slimmedGenJetRef)] = (*genJetFlavourInfos)[i].second; | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
slimmedGenJetsFlavourInfos = cms.EDProducer("GenJetFlavourInfoPreserver", | ||
genJets = cms.InputTag("ak4GenJetsNoNu"), | ||
slimmedGenJets = cms.InputTag("slimmedGenJets"), | ||
genJetFlavourInfos = cms.InputTag("ak4GenJetFlavourInfos"), | ||
slimmedGenJetAssociation = cms.InputTag("slimmedGenJets", "slimmedGenJetAssociation") | ||
) |
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