CMS 3D CMS Logo

GenMETExtractor.cc
Go to the documentation of this file.
5 
6 #include <memory>
7 
8 using namespace pat;
9 
11 
12  edm::InputTag metIT = iConfig.getParameter<edm::InputTag>("metSource");
13  metSrcToken_ = consumes<pat::METCollection>(metIT);
14 
15  // produces vector of genMet
16  produces<std::vector<reco::GenMET> >();
17 }
18 
19 
21 
22 }
23 
24 
26  const edm::EventSetup & iSetup) const {
27 
29  iEvent.getByToken(metSrcToken_, src);
30  if(src->size()==0) edm::LogError("GenMETExtractor::produce") << "input genMET collection is empty" ;
31 
32  const reco::GenMET *genMet = src->front().genMET();
33 
34  std::vector<reco::GenMET> *genMetCol = new std::vector<reco::GenMET>();
35  genMetCol->push_back( (*genMet) );
36 
37  std::unique_ptr<std::vector<reco::GenMET> > genMETs(genMetCol);
38  iEvent.put(std::move(genMETs));
39 }
40 
41 
43 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Retrieves the genMET from a pat::MET.
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:230
GenMETExtractor(const edm::ParameterSet &iConfig)
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
virtual void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_