Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:13

0001 #include "FWCore/Framework/interface/global/EDProducer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Utilities/interface/InputTag.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 
0006 #include "AnalysisDataFormats/TopObjects/interface/StGenEvent.h"
0007 
0008 class StGenEventReco : public edm::global::EDProducer<> {
0009 public:
0010   explicit StGenEventReco(const edm::ParameterSet&);
0011   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0012 
0013 private:
0014   edm::EDGetTokenT<reco::GenParticleCollection> srcToken_;
0015   edm::EDGetTokenT<reco::GenParticleCollection> initToken_;
0016   edm::EDPutTokenT<StGenEvent> putToken_;
0017 };
0018 
0019 StGenEventReco::StGenEventReco(const edm::ParameterSet& cfg)
0020     : srcToken_(consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("src"))),
0021       initToken_(consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("init"))),
0022       putToken_(produces<StGenEvent>()) {}
0023 
0024 void StGenEventReco::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& setup) const {
0025   //add TopDecayTree
0026   reco::GenParticleRefProd cands(evt.getHandle(srcToken_));
0027 
0028   //add InitialStatePartons
0029   reco::GenParticleRefProd initParts(evt.getHandle(initToken_));
0030 
0031   //add genEvt to the output stream
0032   evt.emplace(putToken_, cands, initParts);
0033 }
0034 
0035 #include "FWCore/Framework/interface/MakerMacros.h"
0036 DEFINE_FWK_MODULE(StGenEventReco);