CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  binningEntryType
 

Public Member Functions

 ShiftedParticleProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedParticleProducerT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef std::vector< TParticleCollection
 

Private Member Functions

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

Private Attributes

std::vector< binningEntryType * > binning_
 
std::string moduleLabel_
 
double shiftBy_
 
edm::InputTag src_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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
Version
Revision:
1.2
Id:
ShiftedParticleProducerT.h,v 1.2 2011/11/02 14:03:07 veelken Exp

Definition at line 32 of file ShiftedParticleProducerT.h.

Member Typedef Documentation

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

Definition at line 34 of file ShiftedParticleProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::src_.

39  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
40  {
41  src_ = cfg.getParameter<edm::InputTag>("src");
42 
43  shiftBy_ = cfg.getParameter<double>("shiftBy");
44 
45  if ( cfg.exists("binning") ) {
46  typedef std::vector<edm::ParameterSet> vParameterSet;
47  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
48  for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
49  cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
50  binning_.push_back(new binningEntryType(*cfgBinningEntry));
51  }
52  } else {
53  double uncertainty = cfg.getParameter<double>("uncertainty");
54  binning_.push_back(new binningEntryType(uncertainty));
55  }
56 
57  produces<ParticleCollection>();
58  }
T getParameter(std::string const &) const
std::vector< binningEntryType * > binning_
bool exists(std::string const &parameterName) const
checks if a parameter exists
template<typename T >
ShiftedParticleProducerT< T >::~ShiftedParticleProducerT ( )
inline

Definition at line 59 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_.

60  {
61  for ( typename std::vector<binningEntryType*>::const_iterator it = binning_.begin();
62  it != binning_.end(); ++it ) {
63  delete (*it);
64  }
65  }
std::vector< binningEntryType * > binning_

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 69 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_, edm::Event::getByLabel(), edm::Event::put(), edm::shift, ShiftedParticleProducerT< T >::shiftBy_, and ShiftedParticleProducerT< T >::src_.

70  {
71  edm::Handle<ParticleCollection> originalParticles;
72  evt.getByLabel(src_, originalParticles);
73 
74  std::auto_ptr<ParticleCollection> shiftedParticles(new ParticleCollection);
75 
76  for ( typename ParticleCollection::const_iterator originalParticle = originalParticles->begin();
77  originalParticle != originalParticles->end(); ++originalParticle ) {
78 
79  double uncertainty = 0.;
80  for ( typename std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
81  binningEntry != binning_.end(); ++binningEntry ) {
82  if ( (!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(*originalParticle) ) {
83  uncertainty = (*binningEntry)->binUncertainty_;
84  break;
85  }
86  }
87 
88  double shift = shiftBy_*uncertainty;
89 
90  reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
91  shiftedParticleP4 *= (1. + shift);
92 
93  T shiftedParticle(*originalParticle);
94  shiftedParticle.setP4(shiftedParticleP4);
95 
96  shiftedParticles->push_back(shiftedParticle);
97  }
98 
99  evt.put(shiftedParticles);
100  }
std::vector< binningEntryType * > binning_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
static unsigned int const shift
long double T

Member Data Documentation

template<typename T >
std::vector<binningEntryType*> ShiftedParticleProducerT< T >::binning_
private
template<typename T >
std::string ShiftedParticleProducerT< T >::moduleLabel_
private
template<typename T >
double ShiftedParticleProducerT< T >::shiftBy_
private
template<typename T >
edm::InputTag ShiftedParticleProducerT< T >::src_
private