test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoMETExtractor.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  std::string corLevel = iConfig.getParameter<std::string>("correctionLevel");
16 
17  //all possible met flavors
18  if(corLevel=="raw") { corLevel_=pat::MET::Raw;}
19  else if(corLevel=="type1") { corLevel_=pat::MET::Type1;}
20  else if(corLevel=="type01") { corLevel_=pat::MET::Type01;}
21  else if(corLevel=="typeXY") { corLevel_=pat::MET::TypeXY;}
22  else if(corLevel=="type1XY") { corLevel_=pat::MET::Type1XY;}
23  else if(corLevel=="type01XY") { corLevel_=pat::MET::Type01XY;}
24  else if(corLevel=="type1Smear") { corLevel_=pat::MET::Type1Smear;}
25  else if(corLevel=="type01Smear") { corLevel_=pat::MET::Type01Smear;}
26  else if(corLevel=="type1SmearXY") { corLevel_=pat::MET::Type1SmearXY;}
27  else if(corLevel=="type01SmearXY") { corLevel_=pat::MET::Type01SmearXY;}
28  else if(corLevel=="rawCalo") { corLevel_=pat::MET::RawCalo;}
29  else {
30  //throw exception
31 
32  }
33 
34  // produces vector of recoMet
35  produces<std::vector<reco::MET> >();
36 }
37 
38 
40 
41 }
42 
43 
45  const edm::EventSetup & iSetup) const {
46 
48  iEvent.getByToken(metSrcToken_, src);
49  if(src->size()==0) edm::LogError("RecoMETExtractor::produce") << "input reco MET collection is empty" ;
50 
51  std::vector<reco::MET> *metCol = new std::vector<reco::MET>();
52 
53  reco::MET met(src->front().corP4(corLevel_), src->front().vertex() );
54  metCol->push_back( met );
55 
56  std::auto_ptr<std::vector<reco::MET> > recoMETs(metCol);
57  iEvent.put(recoMETs);
58 }
59 
60 
62 
T getParameter(std::string const &) const
pat::MET::METCorrectionLevel corLevel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Retrieves the recoMET from a pat::MET.
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
Definition: MET.h:42
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
virtual void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const
RecoMETExtractor(const edm::ParameterSet &iConfig)