CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedParticleProducerT< T > Class Template Reference

#include <ShiftedParticleProducerT.h>

Inheritance diagram for ShiftedParticleProducerT< T >:
edm::stream::EDProducer<>

Classes

struct  binningEntryType
 

Public Member Functions

 ShiftedParticleProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedParticleProducerT () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef std::vector< TParticleCollection
 

Private Member Functions

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

Private Attributes

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

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

template<typename T>
class ShiftedParticleProducerT< T >

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
Christian Veelken, LLR

Definition at line 31 of file ShiftedParticleProducerT.h.

Member Typedef Documentation

◆ ParticleCollection

template<typename T >
typedef std::vector<T> ShiftedParticleProducerT< T >::ParticleCollection
private

Definition at line 32 of file ShiftedParticleProducerT.h.

Constructor & Destructor Documentation

◆ ShiftedParticleProducerT()

template<typename T >
ShiftedParticleProducerT< T >::ShiftedParticleProducerT ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 35 of file ShiftedParticleProducerT.h.

36  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
37  srcToken_ = consumes<ParticleCollection>(cfg.getParameter<edm::InputTag>("src"));
38 
39  shiftBy_ = cfg.getParameter<double>("shiftBy");
40 
41  if (cfg.exists("binning")) {
42  typedef std::vector<edm::ParameterSet> vParameterSet;
43  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
44  for (vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin(); cfgBinningEntry != cfgBinning.end();
45  ++cfgBinningEntry) {
46  binning_.push_back(new binningEntryType(*cfgBinningEntry));
47  }
48  } else {
49  double uncertainty = cfg.getParameter<double>("uncertainty");
50  binning_.push_back(new binningEntryType(uncertainty));
51  }
52 
53  produces<ParticleCollection>();
54  }

References ShiftedParticleProducerT< T >::binning_, looper::cfg, ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::srcToken_.

◆ ~ShiftedParticleProducerT()

template<typename T >
ShiftedParticleProducerT< T >::~ShiftedParticleProducerT ( )
inlineoverride

Definition at line 55 of file ShiftedParticleProducerT.h.

55  {
56  for (typename std::vector<binningEntryType*>::const_iterator it = binning_.begin(); it != binning_.end(); ++it) {
57  delete (*it);
58  }
59  }

References ShiftedParticleProducerT< T >::binning_.

Member Function Documentation

◆ produce()

template<typename T >
void ShiftedParticleProducerT< T >::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlineoverrideprivate

Definition at line 62 of file ShiftedParticleProducerT.h.

62  {
63  edm::Handle<ParticleCollection> originalParticles;
64  evt.getByToken(srcToken_, originalParticles);
65 
66  auto shiftedParticles = std::make_unique<ParticleCollection>();
67 
68  for (typename ParticleCollection::const_iterator originalParticle = originalParticles->begin();
69  originalParticle != originalParticles->end();
70  ++originalParticle) {
71  double uncertainty = 0.;
72  for (typename std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
73  binningEntry != binning_.end();
74  ++binningEntry) {
75  if ((!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(*originalParticle)) {
76  uncertainty = (*binningEntry)->binUncertainty_;
77  break;
78  }
79  }
80 
81  double shift = shiftBy_ * uncertainty;
82 
83  reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
84  //leave 0*nan = 0
85  if (!(edm::isNotFinite(shift) && shiftedParticleP4.mag2() == 0))
86  shiftedParticleP4 *= (1. + shift);
87 
88  T shiftedParticle(*originalParticle);
89  shiftedParticle.setP4(shiftedParticleP4);
90 
91  shiftedParticles->push_back(shiftedParticle);
92  }
93 
94  evt.put(std::move(shiftedParticles));
95  }

References ShiftedParticleProducerT< T >::binning_, edm::Event::getByToken(), edm::isNotFinite(), eostools::move(), edm::Event::put(), edm::shift, ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::srcToken_.

Member Data Documentation

◆ binning_

template<typename T >
std::vector<binningEntryType*> ShiftedParticleProducerT< T >::binning_
private

◆ moduleLabel_

template<typename T >
std::string ShiftedParticleProducerT< T >::moduleLabel_
private

◆ shiftBy_

template<typename T >
double ShiftedParticleProducerT< T >::shiftBy_
private

◆ srcToken_

template<typename T >
edm::EDGetTokenT<ParticleCollection> ShiftedParticleProducerT< T >::srcToken_
private
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
edm::Handle
Definition: AssociativeIterator.h:50
ShiftedParticleProducerT::binning_
std::vector< binningEntryType * > binning_
Definition: ShiftedParticleProducerT.h:110
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
looper.cfg
cfg
Definition: looper.py:297
ShiftedParticleProducerT::shiftBy_
double shiftBy_
Definition: ShiftedParticleProducerT.h:112
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
T
long double T
Definition: Basic3DVectorLD.h:48
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
ShiftedParticleProducerT::moduleLabel_
std::string moduleLabel_
Definition: ShiftedParticleProducerT.h:97
edm::InputTag
Definition: InputTag.h:15
ShiftedParticleProducerT::srcToken_
edm::EDGetTokenT< ParticleCollection > srcToken_
Definition: ShiftedParticleProducerT.h:99