CMS 3D CMS Logo

GenJetFlavourInfoPreserver.cc
Go to the documentation of this file.
1 
15 
20 
23 
24 
25 namespace pat {
26 
28  public:
29  explicit GenJetFlavourInfoPreserver(const edm::ParameterSet & iConfig);
31 
32  void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
33 
34  private:
37 
40  };
41 
42 } // namespace
43 
45  genJetsToken_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("genJets"))),
46  slimmedGenJetsToken_(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("slimmedGenJets"))),
47  genJetFlavourInfosToken_(consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("genJetFlavourInfos"))),
48  slimmedGenJetAssociationToken_(consumes<edm::Association<std::vector<reco::GenJet> > >(iConfig.getParameter<edm::InputTag>("slimmedGenJetAssociation")))
49 {
50  produces<reco::JetFlavourInfoMatchingCollection>();
51 }
52 
53 void
55  using namespace edm;
56  using namespace std;
57 
59  iEvent.getByToken(genJetsToken_, genJets);
60 
62  iEvent.getByToken(slimmedGenJetsToken_, slimmedGenJets);
63 
65  iEvent.getByToken(genJetFlavourInfosToken_, genJetFlavourInfos);
66 
68  iEvent.getByToken(slimmedGenJetAssociationToken_, slimmedGenJetAssociation);
69 
70  auto jetFlavourInfos = std::make_unique<reco::JetFlavourInfoMatchingCollection>(reco::JetRefBaseProd(slimmedGenJets));
71  assert(genJets->size() == genJetFlavourInfos->size());
72 
73  edm::Ref<std::vector<reco::GenJet> > slimmedGenJetRef;
74 
75 
76  for (unsigned int i=0; i<genJets->size();++i){
77 
78  slimmedGenJetRef = (*slimmedGenJetAssociation)[genJets->refAt(i)];
79  if(!slimmedGenJetRef) continue;
80  (*jetFlavourInfos)[reco::JetBaseRef(slimmedGenJetRef)] = (*genJetFlavourInfos)[i].second;
81 
82  }
83 
84  iEvent.put(std::move(jetFlavourInfos));
85 }
86 
88 using namespace pat;
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const edm::EDGetTokenT< edm::View< reco::Jet > > slimmedGenJetsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Transfers the JetFlavourInfos from the original GenJets to the slimmedGenJets in MiniAOD.
Definition: HeavyIon.h:7
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:14
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GenJetFlavourInfoPreserver(const edm::ParameterSet &iConfig)
Definition: Jet.py:1
edm::RefToBase< Jet > JetBaseRef
Definition: JetCollection.h:13
const edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > genJetFlavourInfosToken_
const edm::EDGetTokenT< edm::View< reco::GenJet > > genJetsToken_
fixed size matrix
HLT enums.
const edm::EDGetTokenT< edm::Association< std::vector< reco::GenJet > > > slimmedGenJetAssociationToken_
def move(src, dest)
Definition: eostools.py:511
size_type size() const