CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SysShiftMETcorrInputProducer Class Reference

#include <SysShiftMETcorrInputProducer.h>

Inheritance diagram for SysShiftMETcorrInputProducer:
edm::stream::EDProducer<>

Public Member Functions

 SysShiftMETcorrInputProducer (const edm::ParameterSet &)
 
 ~SysShiftMETcorrInputProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

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

Private Attributes

TFormula * corrPx_
 
TFormula * corrPy_
 
std::string moduleLabel_
 
edm::EDGetTokenT< edm::View< reco::MET > > token_
 
bool useNvtx
 
edm::EDGetTokenT< reco::VertexCollectionverticesToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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

Definition at line 28 of file SysShiftMETcorrInputProducer.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file SysShiftMETcorrInputProducer.cc.

References corrPx_, corrPy_, data, edm::ParameterSet::getParameter(), moduleLabel_, AlCaHLTBitMon_QueryRunRegistry::string, token_, useNvtx, and verticesToken_.

12  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
13  useNvtx(false),
14  corrPx_(nullptr),
15  corrPy_(nullptr)
16 {
17  token_ = consumes<edm::View<reco::MET> >(cfg.getParameter<edm::InputTag>("src"));
18 
19  edm::ParameterSet cfgCorrParameter = cfg.getParameter<edm::ParameterSet>("parameter");
20  TString corrPxFormula = cfgCorrParameter.getParameter<std::string>("px");
21  TString corrPyFormula = cfgCorrParameter.getParameter<std::string>("py").data();
22  if ( corrPxFormula.Contains("Nvtx") || corrPyFormula.Contains("Nvtx") )
23  {
24  useNvtx = true,
25  verticesToken_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("srcVertices"));
26  }
27 
28  corrPxFormula.ReplaceAll("sumEt", "x");
29  corrPxFormula.ReplaceAll("Nvtx", "y");
30  std::string corrPxName = std::string(moduleLabel_).append("_corrPx");
31  corrPx_ = new TFormula(corrPxName.data(), corrPxFormula.Data());
32 
33  corrPyFormula.ReplaceAll("sumEt", "x");
34  corrPyFormula.ReplaceAll("Nvtx", "y");
35  std::string corrPyName = std::string(moduleLabel_).append("_corrPy");
36  corrPy_ = new TFormula(corrPyName.data(), corrPyFormula.Data());
37 
38  produces<CorrMETData>();
39 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
edm::EDGetTokenT< edm::View< reco::MET > > token_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
SysShiftMETcorrInputProducer::~SysShiftMETcorrInputProducer ( )
override

Definition at line 41 of file SysShiftMETcorrInputProducer.cc.

42 {
43 // nothing to be done yet...
44 }

Member Function Documentation

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

Definition at line 46 of file SysShiftMETcorrInputProducer.cc.

References corrPx_, corrPy_, DEFINE_FWK_MODULE, edm::Event::getByToken(), RazorAnalyzer::met, eostools::move(), edm::Event::put(), objects.METAnalyzer::sumEt, token_, useNvtx, electrons_cff::vertices, and verticesToken_.

47 {
48  //std::cout << "<SysShiftMETcorrInputProducer::produce>:" << std::endl;
49 
50  typedef edm::View<reco::MET> METView;
52  evt.getByToken(token_, met);
53  if ( met->size() != 1 )
54  throw cms::Exception("SysShiftMETcorrInputProducer::produce")
55  << "Failed to find unique MET object !!\n";
56 
57  double sumEt = met->front().sumEt();
58  //std::cout << " sumEt = " << sumEt << std::endl;
59 
60  size_t Nvtx = 0;
61  if ( useNvtx )
62  {
64  evt.getByToken(verticesToken_, vertices);
65  Nvtx = vertices->size();
66  }
67  //std::cout << " Nvtx = " << Nvtx << std::endl;
68 
69  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
70  metCorr->mex = -corrPx_->Eval(sumEt, Nvtx);
71  metCorr->mey = -corrPy_->Eval(sumEt, Nvtx);
72  //std::cout << "--> metCorr: Px = " << metCorr->mex << ", Py = " << metCorr->mey << std::endl;
73 
74  evt.put(std::move(metCorr));
75 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
edm::EDGetTokenT< edm::View< reco::MET > > token_
met
===> hadronic RAZOR
a MET correction term
Definition: CorrMETData.h:14
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

TFormula* SysShiftMETcorrInputProducer::corrPx_
private

Definition at line 46 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

TFormula* SysShiftMETcorrInputProducer::corrPy_
private

Definition at line 47 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

std::string SysShiftMETcorrInputProducer::moduleLabel_
private
edm::EDGetTokenT<edm::View<reco::MET> > SysShiftMETcorrInputProducer::token_
private

Definition at line 41 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

bool SysShiftMETcorrInputProducer::useNvtx
private

Definition at line 44 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

edm::EDGetTokenT<reco::VertexCollection> SysShiftMETcorrInputProducer::verticesToken_
private

Definition at line 42 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().