CMS 3D CMS Logo

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

#include <ShiftedParticleProducer.h>

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

Classes

struct  binningEntryType
 

Public Member Functions

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

Private Types

typedef edm::View< reco::CandidateCandidateView
 

Private Member Functions

double getUncShift (const CandidateView::const_iterator &originalParticle)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 

Private Attributes

std::vector< binningEntryType * > binning_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::EDGetTokenT< CandidateViewsrcToken_
 

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 energy of electrons/muons/tau-jets by +/- 1 standard deviation, in order to estimate resulting uncertainty on MET

NOTE: energy scale uncertainties need to be specified in python config

Author
Matthieu marionneau ETH

Definition at line 32 of file ShiftedParticleProducer.h.

Member Typedef Documentation

Definition at line 34 of file ShiftedParticleProducer.h.

Constructor & Destructor Documentation

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

Definition at line 4 of file ShiftedParticleProducer.cc.

References binning_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), moduleLabel_, shiftBy_, srcToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

5 {
6  moduleLabel_=cfg.getParameter<std::string>("@module_label");
7  srcToken_ = consumes<CandidateView>(cfg.getParameter<edm::InputTag>("src"));
8  shiftBy_ = cfg.getParameter<double>("shiftBy");
9 
10  if ( cfg.exists("binning") ) {
11  typedef std::vector<edm::ParameterSet> vParameterSet;
12  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
13  for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
14  cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
15  binning_.push_back(new binningEntryType(*cfgBinningEntry,moduleLabel_));
16  }
17  } else {
18  std::string uncertainty = cfg.getParameter<std::string>("uncertainty");
19  binning_.push_back(new binningEntryType(uncertainty, moduleLabel_));
20  }
21 
22  produces<reco::CandidateCollection>();
23 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CandidateView > srcToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< binningEntryType * > binning_
ShiftedParticleProducer::~ShiftedParticleProducer ( )
override

Definition at line 25 of file ShiftedParticleProducer.cc.

References binning_.

26 {
27  for(std::vector<binningEntryType*>::const_iterator it = binning_.begin();
28  it != binning_.end(); ++it ) {
29  delete (*it);
30  }
31 }
std::vector< binningEntryType * > binning_

Member Function Documentation

double ShiftedParticleProducer::getUncShift ( const CandidateView::const_iterator originalParticle)
private

Definition at line 61 of file ShiftedParticleProducer.cc.

References binning_, and DEFINE_FWK_MODULE.

Referenced by produce().

61  {
62  double valx=0;
63  double valy=0;
64  for(std::vector<binningEntryType*>::iterator binningEntry=binning_.begin();
65  binningEntry!=binning_.end(); ++binningEntry ) {
66  if( (!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(*originalParticle) ) {
67 
68  if( (*binningEntry)->energyDep_ ) valx=originalParticle->energy();
69  else valx=originalParticle->pt();
70 
71  valy=originalParticle->eta();
72  return (*binningEntry)->binUncFormula_->Eval(valx, valy);
73  }
74  }
75  return 0;
76 }
std::vector< binningEntryType * > binning_
void ShiftedParticleProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 34 of file ShiftedParticleProducer.cc.

References edm::View< T >::begin(), edm::View< T >::end(), edm::Event::getByToken(), getUncShift(), edm::isNotFinite(), eostools::move(), edm::Event::put(), edm::shift, shiftBy_, and srcToken_.

35 {
36  edm::Handle<CandidateView> originalParticles;
37  evt.getByToken(srcToken_, originalParticles);
38 
39  auto shiftedParticles = std::make_unique<reco::CandidateCollection>();
40 
41  for(CandidateView::const_iterator originalParticle = originalParticles->begin();
42  originalParticle != originalParticles->end(); ++originalParticle ) {
43 
44  double uncertainty = getUncShift(originalParticle);
45  double shift = shiftBy_*uncertainty;
46 
47  reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
48  //leave 0*nan = 0
49  if (! (edm::isNotFinite(shift) && shiftedParticleP4.mag2()==0)) shiftedParticleP4 *= (1. + shift);
50 
51  std::unique_ptr<reco::Candidate> shiftedParticle = std::make_unique<reco::LeafCandidate>(*originalParticle);
52  shiftedParticle->setP4(shiftedParticleP4);
53 
54  shiftedParticles->push_back( shiftedParticle.release() );
55  }
56 
57  evt.put(std::move(shiftedParticles));
58 }
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< CandidateView > srcToken_
const_iterator begin() const
bool isNotFinite(T x)
Definition: isFinite.h:10
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
double getUncShift(const CandidateView::const_iterator &originalParticle)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
static unsigned int const shift
const_iterator end() const
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::vector<binningEntryType*> ShiftedParticleProducer::binning_
private
std::string ShiftedParticleProducer::moduleLabel_
private
double ShiftedParticleProducer::shiftBy_
private

Definition at line 81 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().

edm::EDGetTokenT<CandidateView> ShiftedParticleProducer::srcToken_
private

Definition at line 50 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().