CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SysShiftMETcorrInputProducer.cc
Go to the documentation of this file.
2 
4 
10 
11 #include <TString.h>
12 
14  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
15  corrPx_(0),
16  corrPy_(0)
17 {
18  src_ = cfg.getParameter<edm::InputTag>("src");
19 
20  edm::ParameterSet cfgCorrParameter = cfg.getParameter<edm::ParameterSet>("parameter");
21  TString corrPxFormula = cfgCorrParameter.getParameter<std::string>("px");
22  TString corrPyFormula = cfgCorrParameter.getParameter<std::string>("py").data();
23  if ( corrPxFormula.Contains("Nvtx") || corrPyFormula.Contains("Nvtx") ) {
24  srcVertices_ = cfg.getParameter<edm::InputTag>("srcVertices");
25  if ( srcVertices_.label() == "" )
26  throw cms::Exception("SysShiftMETcorrInputProducer")
27  << "Configuration Parameter 'srcVertices' must be non-empty !!\n";
28  }
29 
30  corrPxFormula.ReplaceAll("sumEt", "x");
31  corrPxFormula.ReplaceAll("Nvtx", "y");
32  std::string corrPxName = std::string(moduleLabel_).append("_corrPx");
33  corrPx_ = new TFormula(corrPxName.data(), corrPxFormula.Data());
34 
35  corrPyFormula.ReplaceAll("sumEt", "x");
36  corrPyFormula.ReplaceAll("Nvtx", "y");
37  std::string corrPyName = std::string(moduleLabel_).append("_corrPy");
38  corrPy_ = new TFormula(corrPyName.data(), corrPyFormula.Data());
39 
40  produces<CorrMETData>();
41 }
42 
44 {
45 // nothing to be done yet...
46 }
47 
49 {
50  //std::cout << "<SysShiftMETcorrInputProducer::produce>:" << std::endl;
51 
52  typedef edm::View<reco::MET> METView;
54  evt.getByLabel(src_, met);
55  if ( met->size() != 1 )
56  throw cms::Exception("SysShiftMETcorrInputProducer::produce")
57  << "Failed to find unique MET object !!\n";
58 
59  double sumEt = met->front().sumEt();
60  //std::cout << " sumEt = " << sumEt << std::endl;
61 
62  size_t Nvtx = 0;
63  if ( srcVertices_.label() != "" ) {
65  evt.getByLabel(srcVertices_, vertices);
66  Nvtx = vertices->size();
67  }
68  //std::cout << " Nvtx = " << Nvtx << std::endl;
69 
70  std::auto_ptr<CorrMETData> metCorr(new CorrMETData());
71  metCorr->mex = -corrPx_->Eval(sumEt, Nvtx);
72  metCorr->mey = -corrPy_->Eval(sumEt, Nvtx);
73  //std::cout << "--> metCorr: Px = " << metCorr->mex << ", Py = " << metCorr->mey << std::endl;
74 
75  evt.put(metCorr);
76 }
77 
79 
T getParameter(std::string const &) const
void append(Exception const &another)
Definition: Exception.cc:203
SysShiftMETcorrInputProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void produce(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string const & label() const
Definition: InputTag.h:25
a MET correction term
Definition: CorrMETData.h:14
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82