CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RecoMETExtractor.cc
Go to the documentation of this file.
1 
22 
23 #include <memory>
24 
25 namespace pat {
26 
28  public:
30  ~RecoMETExtractor() override;
31 
32  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
33 
34  private:
36 
38  };
39 
40 } // namespace pat
41 
42 using namespace pat;
43 
45  edm::InputTag metIT = iConfig.getParameter<edm::InputTag>("metSource");
46  metSrcToken_ = consumes<pat::METCollection>(metIT);
47 
48  std::string corLevel = iConfig.getParameter<std::string>("correctionLevel");
49 
50  //all possible met flavors
51  if (corLevel == "raw") {
53  } else if (corLevel == "type1") {
55  } else if (corLevel == "type01") {
57  } else if (corLevel == "typeXY") {
59  } else if (corLevel == "type1XY") {
61  } else if (corLevel == "type01XY") {
63  } else if (corLevel == "type1Smear") {
65  } else if (corLevel == "type01Smear") {
67  } else if (corLevel == "type1SmearXY") {
69  } else if (corLevel == "type01SmearXY") {
71  } else if (corLevel == "rawCalo") {
73  } else if (corLevel == "rawDeepResponseTune") {
75  } else if (corLevel == "rawDeepResolutionTune") {
77  } else {
78  //throw exception
79  }
80 
81  // produces vector of recoMet
82  produces<std::vector<reco::MET> >();
83 }
84 
86 
89  iEvent.getByToken(metSrcToken_, src);
90  if (src->empty())
91  edm::LogError("RecoMETExtractor::produce") << "input reco MET collection is empty";
92 
93  std::vector<reco::MET>* metCol = new std::vector<reco::MET>();
94 
95  reco::MET met(src->front().corSumEt(corLevel_), src->front().corP4(corLevel_), src->front().vertex());
96 
97  metCol->push_back(met);
98 
99  std::unique_ptr<std::vector<reco::MET> > recoMETs(metCol);
100  iEvent.put(std::move(recoMETs));
101 }
102 
pat::MET::METCorrectionLevel corLevel_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Retrieves the recoMET from a pat::MET.
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
int iEvent
Definition: GenABIO.cc:224
Definition: MET.h:41
def move
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
METCorrectionLevel
Definition: MET.h:173
RecoMETExtractor(const edm::ParameterSet &iConfig)