CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedMETcorrInputProducer Class Reference

#include <ShiftedMETcorrInputProducer.h>

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

Classes

struct  binningEntryType
 

Public Member Functions

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

Private Types

typedef std::vector< edm::InputTagvInputTag
 

Private Member Functions

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

Private Attributes

std::vector< binningEntryType * > binning_
 
double shiftBy_
 
vInputTag src_
 
std::vector< edm::EDGetTokenT< CorrMETData > > srcTokens_
 

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

Vary px, py and sumEt of "unclustered energy" (PFJets of Pt < 10 GeV plus PFCandidates not within jets) by +/- 1 standard deviation, in order to estimate resulting uncertainty on MET

Author
Christian Veelken, LLR

Definition at line 25 of file ShiftedMETcorrInputProducer.h.

Member Typedef Documentation

Definition at line 36 of file ShiftedMETcorrInputProducer.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file ShiftedMETcorrInputProducer.cc.

References binning_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), shiftBy_, src_, and srcTokens_.

6 {
7  src_ = cfg.getParameter<vInputTag>("src");
8 
9 //--- check that all InputTags refer to the same module label
10 // (i.e. differ by instance label only)
11  for ( vInputTag::const_iterator src_ref = src_.begin();
12  src_ref != src_.end(); ++src_ref ) {
13  for ( vInputTag::const_iterator src_test = src_ref;
14  src_test != src_.end(); ++src_test ) {
15  if ( src_test->label() != src_ref->label() )
16  throw cms::Exception("ShiftedMETcorrInputProducer")
17  << "InputTags specified by 'src' Configuration parameter must not refer to different module labels !!\n";
18  }
19  }
20 
21  shiftBy_ = cfg.getParameter<double>("shiftBy");
22 
23  if ( cfg.exists("binning") ) {
24  typedef std::vector<edm::ParameterSet> vParameterSet;
25  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
26  for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
27  cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
28  binning_.push_back(new binningEntryType(*cfgBinningEntry));
29  }
30  } else {
31  double uncertainty = cfg.getParameter<double>("uncertainty");
32  binning_.push_back(new binningEntryType(uncertainty));
33  }
34 
35  for ( vInputTag::const_iterator src_i = src_.begin();
36  src_i != src_.end(); ++src_i ) {
37  for ( std::vector<binningEntryType*>::const_iterator binningEntry = binning_.begin();
38  binningEntry != binning_.end(); ++binningEntry ) {
39  srcTokens_.push_back(consumes<CorrMETData>(edm::InputTag(src_i->label(), (*binningEntry)->getInstanceLabel_full(src_i->instance()))));
40  produces<CorrMETData>((*binningEntry)->getInstanceLabel_full(src_i->instance()));
41  }
42  }
43 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::EDGetTokenT< CorrMETData > > srcTokens_
std::vector< binningEntryType * > binning_
std::vector< edm::InputTag > vInputTag
ShiftedMETcorrInputProducer::~ShiftedMETcorrInputProducer ( )
override

Definition at line 45 of file ShiftedMETcorrInputProducer.cc.

References binning_.

46 {
47  for ( std::vector<binningEntryType*>::const_iterator it = binning_.begin();
48  it != binning_.end(); ++it ) {
49  delete (*it);
50  }
51 }
std::vector< binningEntryType * > binning_

Member Function Documentation

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

Definition at line 53 of file ShiftedMETcorrInputProducer.cc.

References binning_, DEFINE_FWK_MODULE, edm::Event::getByToken(), eostools::move(), edm::Event::put(), edm::shift, shiftBy_, src_, and srcTokens_.

54 {
55  unsigned countToken(0);
56  for ( vInputTag::const_iterator src_i = src_.begin();
57  src_i != src_.end(); ++src_i ) {
58  for ( std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
59  binningEntry != binning_.end(); ++binningEntry ) {
60  edm::Handle<CorrMETData> originalObject;
61  evt.getByToken(srcTokens_.at(countToken), originalObject);
62  ++countToken;
63 
64  double shift = shiftBy_*(*binningEntry)->binUncertainty_;
65 
66  auto shiftedObject = std::make_unique<CorrMETData>(*originalObject);
67 //--- MET balances momentum of reconstructed particles,
68 // hence variations of "unclustered energy" and MET are opposite in sign
69  shiftedObject->mex = -shift*originalObject->mex;
70  shiftedObject->mey = -shift*originalObject->mey;
71  shiftedObject->sumet = shift*originalObject->sumet;
72 
73  evt.put(std::move(shiftedObject), (*binningEntry)->getInstanceLabel_full(src_i->instance()));
74  }
75  }
76 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< edm::EDGetTokenT< CorrMETData > > srcTokens_
std::vector< binningEntryType * > binning_
static unsigned int const shift
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::vector<binningEntryType*> ShiftedMETcorrInputProducer::binning_
private
double ShiftedMETcorrInputProducer::shiftBy_
private

Definition at line 63 of file ShiftedMETcorrInputProducer.h.

Referenced by produce(), and ShiftedMETcorrInputProducer().

vInputTag ShiftedMETcorrInputProducer::src_
private

Definition at line 37 of file ShiftedMETcorrInputProducer.h.

Referenced by produce(), and ShiftedMETcorrInputProducer().

std::vector<edm::EDGetTokenT<CorrMETData> > ShiftedMETcorrInputProducer::srcTokens_
private

Definition at line 38 of file ShiftedMETcorrInputProducer.h.

Referenced by produce(), and ShiftedMETcorrInputProducer().