CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SysShiftMETcorrInputProducer Class Reference

#include <SysShiftMETcorrInputProducer.h>

Inheritance diagram for SysShiftMETcorrInputProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 SysShiftMETcorrInputProducer (const edm::ParameterSet &)
 
 ~SysShiftMETcorrInputProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

TFormula * corrPx_
 
TFormula * corrPy_
 
std::string moduleLabel_
 
edm::InputTag src_
 
edm::InputTag srcVertices_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Compute MET correction to compensate systematic shift of MET in x/y-direction (cf. https://indico.cern.ch/getFile.py/access?contribId=1&resId=0&materialId=slides&confId=174318 )

Authors
Christian Veelken, LLR
Version
Revision:
1.2
Id:
SysShiftMETcorrInputProducer.h,v 1.2 2012/04/09 14:19:01 veelken Exp

Definition at line 27 of file SysShiftMETcorrInputProducer.h.

Constructor & Destructor Documentation

SysShiftMETcorrInputProducer::SysShiftMETcorrInputProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 13 of file SysShiftMETcorrInputProducer.cc.

References cms::Exception::append(), corrPx_, corrPy_, data, edm::ParameterSet::getParameter(), edm::InputTag::label(), moduleLabel_, src_, and srcVertices_.

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 }
T getParameter(std::string const &) const
void append(Exception const &another)
Definition: Exception.cc:203
std::string const & label() const
Definition: InputTag.h:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
SysShiftMETcorrInputProducer::~SysShiftMETcorrInputProducer ( )

Definition at line 43 of file SysShiftMETcorrInputProducer.cc.

44 {
45 // nothing to be done yet...
46 }

Member Function Documentation

void SysShiftMETcorrInputProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 48 of file SysShiftMETcorrInputProducer.cc.

References corrPx_, corrPy_, edm::Event::getByLabel(), edm::InputTag::label(), CaloMET_cfi::met, edm::Event::put(), src_, and srcVertices_.

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 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string const & label() const
Definition: InputTag.h:25
Structure containing data common to all types of MET.
Definition: CorrMETData.h:20

Member Data Documentation

TFormula* SysShiftMETcorrInputProducer::corrPx_
private

Definition at line 43 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

TFormula* SysShiftMETcorrInputProducer::corrPy_
private

Definition at line 44 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

std::string SysShiftMETcorrInputProducer::moduleLabel_
private
edm::InputTag SysShiftMETcorrInputProducer::src_
private

Definition at line 40 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

edm::InputTag SysShiftMETcorrInputProducer::srcVertices_
private

Definition at line 41 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().