CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CorrectedCaloMETProducer2.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 //____________________________________________________________________________||
12 
14 
16 
17 #include <vector>
18 
19 //____________________________________________________________________________||
21 {
22 
23 public:
24 
26  : src_(cfg.getParameter<edm::InputTag>("src")),
27  srcCorrections_(cfg.getParameter<std::vector<edm::InputTag> >("srcCorrections"))
28  {
29  produces<METCollection>("");
30  }
31 
33 
34 private:
35 
36  typedef std::vector<reco::CaloMET> METCollection;
37 
39  std::vector<edm::InputTag> srcCorrections_;
40 
41  void produce(edm::Event& evt, const edm::EventSetup& es)
42  {
43  edm::Handle<METCollection> srcMETCollection;
44  evt.getByLabel(src_, srcMETCollection);
45 
46  const reco::CaloMET& srcMET = (*srcMETCollection)[0];
47 
48  CorrMETData correction = readAndSumCorrections(evt, es);
49 
50  reco::CaloMET outMET = applyCorrection(srcMET, correction);
51 
52  std::auto_ptr<METCollection> product(new METCollection);
53  product->push_back(outMET);
54  evt.put(product);
55  }
56 
58  {
60 
62  for (std::vector<edm::InputTag>::const_iterator inputTag = srcCorrections_.begin(); inputTag != srcCorrections_.end(); ++inputTag)
63  {
64  evt.getByLabel(*inputTag, corr);
65  ret += (*corr);
66  }
67  return ret;
68  }
69 
70  reco::CaloMET applyCorrection(const reco::CaloMET& srcMET, const CorrMETData& correction)
71  {
72  std::vector<CorrMETData> corrections = srcMET.mEtCorr();
73  corrections.push_back(correction);
74  return reco::CaloMET(srcMET.getSpecific(), srcMET.sumEt() + correction.sumet, corrections, constructP4From(srcMET, correction), srcMET.vertex());
75  }
76 
78  {
79  double px = met.px() + correction.mex;
80  double py = met.py() + correction.mey;
81  double pt = sqrt(px*px + py*py);
82  return reco::Candidate::LorentzVector(px, py, 0., pt);
83  }
84 };
85 
86 //____________________________________________________________________________||
87 
virtual const Point & vertex() const
vertex position
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CorrMETData readAndSumCorrections(edm::Event &evt, const edm::EventSetup &es)
SpecificCaloMETData getSpecific() const
Definition: CaloMET.h:79
double sumEt() const
Definition: MET.h:48
void produce(edm::Event &evt, const edm::EventSetup &es)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< edm::InputTag > srcCorrections_
Collection of MET.
reco::CaloMET applyCorrection(const reco::CaloMET &srcMET, const CorrMETData &correction)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double sumet
Definition: CorrMETData.h:20
JetCorrectorParameters corr
Definition: classes.h:9
std::vector< CorrMETData > mEtCorr() const
Definition: MET.h:63
virtual double px() const
x coordinate of momentum vector
CorrectedCaloMETProducer2(const edm::ParameterSet &cfg)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::vector< reco::CaloMET > METCollection
a MET correction term
Definition: CorrMETData.h:14
reco::Candidate::LorentzVector constructP4From(const reco::CaloMET &met, const CorrMETData &correction)
double mey
Definition: CorrMETData.h:18
double mex
Definition: CorrMETData.h:17
virtual double py() const
y coordinate of momentum vector