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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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::SysShiftMETcorrInputProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 11 of file SysShiftMETcorrInputProducer.cc.

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

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

◆ ~SysShiftMETcorrInputProducer()

SysShiftMETcorrInputProducer::~SysShiftMETcorrInputProducer ( )
override

Definition at line 35 of file SysShiftMETcorrInputProducer.cc.

35  {
36  // nothing to be done yet...
37 }

Member Function Documentation

◆ produce()

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

Definition at line 39 of file SysShiftMETcorrInputProducer.cc.

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

39  {
40  //std::cout << "<SysShiftMETcorrInputProducer::produce>:" << std::endl;
41 
42  typedef edm::View<reco::MET> METView;
44  evt.getByToken(token_, met);
45  if (met->size() != 1)
46  throw cms::Exception("SysShiftMETcorrInputProducer::produce") << "Failed to find unique MET object !!\n";
47 
48  double sumEt = met->front().sumEt();
49  //std::cout << " sumEt = " << sumEt << std::endl;
50 
51  size_t Nvtx = 0;
52  if (useNvtx) {
55  Nvtx = vertices->size();
56  }
57  //std::cout << " Nvtx = " << Nvtx << std::endl;
58 
59  std::unique_ptr<CorrMETData> metCorr(new CorrMETData());
60  metCorr->mex = -corrPx_->Eval(sumEt, Nvtx);
61  metCorr->mey = -corrPy_->Eval(sumEt, Nvtx);
62  //std::cout << "--> metCorr: Px = " << metCorr->mex << ", Py = " << metCorr->mey << std::endl;
63 
64  evt.put(std::move(metCorr));
65 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< reco::VertexCollection > verticesToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
edm::EDGetTokenT< edm::View< reco::MET > > token_
a MET correction term
Definition: CorrMETData.h:14
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ corrPx_

TFormula* SysShiftMETcorrInputProducer::corrPx_
private

Definition at line 43 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

◆ corrPy_

TFormula* SysShiftMETcorrInputProducer::corrPy_
private

Definition at line 44 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

◆ moduleLabel_

std::string SysShiftMETcorrInputProducer::moduleLabel_
private

◆ token_

edm::EDGetTokenT<edm::View<reco::MET> > SysShiftMETcorrInputProducer::token_
private

Definition at line 38 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

◆ useNvtx

bool SysShiftMETcorrInputProducer::useNvtx
private

Definition at line 41 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().

◆ verticesToken_

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

Definition at line 39 of file SysShiftMETcorrInputProducer.h.

Referenced by produce(), and SysShiftMETcorrInputProducer().