CMS 3D CMS Logo

GenMETExtractor.cc
Go to the documentation of this file.
1 
22 
23 #include <memory>
24 
25 namespace pat {
26 
28  public:
29  explicit GenMETExtractor(const edm::ParameterSet &iConfig);
30  ~GenMETExtractor() override;
31 
32  void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
33 
34  private:
36  };
37 
38 } // namespace pat
39 
40 using namespace pat;
41 
43  edm::InputTag metIT = iConfig.getParameter<edm::InputTag>("metSource");
44  metSrcToken_ = consumes<pat::METCollection>(metIT);
45 
46  // produces vector of genMet
47  produces<std::vector<reco::GenMET> >();
48 }
49 
51 
54  iEvent.getByToken(metSrcToken_, src);
55  if (src->empty())
56  edm::LogError("GenMETExtractor::produce") << "input genMET collection is empty";
57 
58  const reco::GenMET *genMet = src->front().genMET();
59 
60  std::vector<reco::GenMET> *genMetCol = new std::vector<reco::GenMET>();
61  genMetCol->push_back((*genMet));
62 
63  std::unique_ptr<std::vector<reco::GenMET> > genMETs(genMetCol);
64  iEvent.put(std::move(genMETs));
65 }
66 
68 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Retrieves the genMET from a pat::MET.
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
GenMETExtractor(const edm::ParameterSet &iConfig)
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override