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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 33 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.

4  {
5  moduleLabel_ = cfg.getParameter<std::string>("@module_label");
6  srcToken_ = consumes<CandidateView>(cfg.getParameter<edm::InputTag>("src"));
7  shiftBy_ = cfg.getParameter<double>("shiftBy");
8 
9  if (cfg.exists("binning")) {
10  typedef std::vector<edm::ParameterSet> vParameterSet;
11  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
12  for (vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin(); cfgBinningEntry != cfgBinning.end();
13  ++cfgBinningEntry) {
14  binning_.push_back(new binningEntryType(*cfgBinningEntry, moduleLabel_));
15  }
16  } else {
17  std::string uncertainty = cfg.getParameter<std::string>("uncertainty");
18  binning_.push_back(new binningEntryType(uncertainty, moduleLabel_));
19  }
20 
21  produces<reco::CandidateCollection>();
22 }
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 24 of file ShiftedParticleProducer.cc.

References binning_.

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

Member Function Documentation

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

Definition at line 56 of file ShiftedParticleProducer.cc.

References binning_, and DEFINE_FWK_MODULE.

Referenced by produce().

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

Definition at line 30 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_.

30  {
31  edm::Handle<CandidateView> originalParticles;
32  evt.getByToken(srcToken_, originalParticles);
33 
34  auto shiftedParticles = std::make_unique<reco::CandidateCollection>();
35 
36  for (CandidateView::const_iterator originalParticle = originalParticles->begin();
37  originalParticle != originalParticles->end();
38  ++originalParticle) {
39  double uncertainty = getUncShift(originalParticle);
40  double shift = shiftBy_ * uncertainty;
41 
42  reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
43  //leave 0*nan = 0
44  if (!(edm::isNotFinite(shift) && shiftedParticleP4.mag2() == 0))
45  shiftedParticleP4 *= (1. + shift);
46 
47  std::unique_ptr<reco::Candidate> shiftedParticle = std::make_unique<reco::LeafCandidate>(*originalParticle);
48  shiftedParticle->setP4(shiftedParticleP4);
49 
50  shiftedParticles->push_back(shiftedParticle.release());
51  }
52 
53  evt.put(std::move(shiftedParticles));
54 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
edm::EDGetTokenT< CandidateView > srcToken_
const_iterator begin() const
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:511

Member Data Documentation

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

Definition at line 73 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().

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

Definition at line 46 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().