CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
pat::GenJetFlavourInfoPreserver Class Reference

Transfers the JetFlavourInfos from the original GenJets to the slimmedGenJets in MiniAOD. More...

Inheritance diagram for pat::GenJetFlavourInfoPreserver:
edm::stream::EDProducer<>

Public Member Functions

 GenJetFlavourInfoPreserver (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~GenJetFlavourInfoPreserver () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

const edm::EDGetTokenT
< reco::JetFlavourInfoMatchingCollection
genJetFlavourInfosToken_
 
const edm::EDGetTokenT
< edm::View< reco::GenJet > > 
genJetsToken_
 
const edm::EDGetTokenT
< edm::Association
< std::vector< reco::GenJet > > > 
slimmedGenJetAssociationToken_
 
const edm::EDGetTokenT
< edm::View< reco::Jet > > 
slimmedGenJetsToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Transfers the JetFlavourInfos from the original GenJets to the slimmedGenJets in MiniAOD.

Author
Andrej Saibel, andre.nosp@m.j.sa.nosp@m.ibel@.nosp@m.cern.nosp@m..ch

Definition at line 25 of file GenJetFlavourInfoPreserver.cc.

Constructor & Destructor Documentation

pat::GenJetFlavourInfoPreserver::GenJetFlavourInfoPreserver ( const edm::ParameterSet iConfig)
explicit

Definition at line 42 of file GenJetFlavourInfoPreserver.cc.

43  : genJetsToken_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("genJets"))),
44  slimmedGenJetsToken_(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("slimmedGenJets"))),
46  consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("genJetFlavourInfos"))),
47  slimmedGenJetAssociationToken_(consumes<edm::Association<std::vector<reco::GenJet> > >(
48  iConfig.getParameter<edm::InputTag>("slimmedGenJetAssociation"))) {
49  produces<reco::JetFlavourInfoMatchingCollection>();
50 }
const edm::EDGetTokenT< edm::View< reco::Jet > > slimmedGenJetsToken_
const edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > genJetFlavourInfosToken_
const edm::EDGetTokenT< edm::View< reco::GenJet > > genJetsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< edm::Association< std::vector< reco::GenJet > > > slimmedGenJetAssociationToken_
pat::GenJetFlavourInfoPreserver::~GenJetFlavourInfoPreserver ( )
inlineoverride

Definition at line 28 of file GenJetFlavourInfoPreserver.cc.

28 {}

Member Function Documentation

void pat::GenJetFlavourInfoPreserver::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 52 of file GenJetFlavourInfoPreserver.cc.

References cms::cuda::assert(), edm::Event::getByToken(), mps_fire::i, eostools::move(), edm::Event::put(), and slimmedGenJets_cfi::slimmedGenJets.

52  {
53  using namespace edm;
54  using namespace std;
55 
56  Handle<View<reco::GenJet> > genJets;
57  iEvent.getByToken(genJetsToken_, genJets);
58 
61 
63  iEvent.getByToken(genJetFlavourInfosToken_, genJetFlavourInfos);
64 
65  Handle<edm::Association<std::vector<reco::GenJet> > > slimmedGenJetAssociation;
66  iEvent.getByToken(slimmedGenJetAssociationToken_, slimmedGenJetAssociation);
67 
68  auto jetFlavourInfos = std::make_unique<reco::JetFlavourInfoMatchingCollection>(reco::JetRefBaseProd(slimmedGenJets));
69  assert(genJets->size() == genJetFlavourInfos->size());
70 
71  edm::Ref<std::vector<reco::GenJet> > slimmedGenJetRef;
72 
73  for (unsigned int i = 0; i < genJets->size(); ++i) {
74  slimmedGenJetRef = (*slimmedGenJetAssociation)[genJets->refAt(i)];
75  if (!slimmedGenJetRef)
76  continue;
77  (*jetFlavourInfos)[reco::JetBaseRef(slimmedGenJetRef)] = (*genJetFlavourInfos)[i].second;
78  }
79 
80  iEvent.put(std::move(jetFlavourInfos));
81 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDGetTokenT< edm::View< reco::Jet > > slimmedGenJetsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
assert(be >=bs)
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:13
def move
Definition: eostools.py:511
edm::RefToBase< Jet > JetBaseRef
Definition: JetCollection.h:12
const edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > genJetFlavourInfosToken_
const edm::EDGetTokenT< edm::View< reco::GenJet > > genJetsToken_
const edm::EDGetTokenT< edm::Association< std::vector< reco::GenJet > > > slimmedGenJetAssociationToken_

Member Data Documentation

const edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> pat::GenJetFlavourInfoPreserver::genJetFlavourInfosToken_
private

Definition at line 36 of file GenJetFlavourInfoPreserver.cc.

const edm::EDGetTokenT<edm::View<reco::GenJet> > pat::GenJetFlavourInfoPreserver::genJetsToken_
private

Definition at line 33 of file GenJetFlavourInfoPreserver.cc.

const edm::EDGetTokenT<edm::Association<std::vector<reco::GenJet> > > pat::GenJetFlavourInfoPreserver::slimmedGenJetAssociationToken_
private

Definition at line 37 of file GenJetFlavourInfoPreserver.cc.

const edm::EDGetTokenT<edm::View<reco::Jet> > pat::GenJetFlavourInfoPreserver::slimmedGenJetsToken_
private

Definition at line 34 of file GenJetFlavourInfoPreserver.cc.