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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  binningEntryType
 

Public Member Functions

 ShiftedParticleProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedParticleProducerT ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EDGetTokenT
< ParticleCollection
srcToken_
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 30 of file ShiftedParticleProducerT.h.

Member Typedef Documentation

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

Definition at line 32 of file ShiftedParticleProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file ShiftedParticleProducerT.h.

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

37  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
38  {
39  srcToken_ = consumes<ParticleCollection>(cfg.getParameter<edm::InputTag>("src"));
40 
41  shiftBy_ = cfg.getParameter<double>("shiftBy");
42 
43  if ( cfg.exists("binning") ) {
44  typedef std::vector<edm::ParameterSet> vParameterSet;
45  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
46  for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
47  cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
48  binning_.push_back(new binningEntryType(*cfgBinningEntry));
49  }
50  } else {
51  double uncertainty = cfg.getParameter<double>("uncertainty");
52  binning_.push_back(new binningEntryType(uncertainty));
53  }
54 
55  produces<ParticleCollection>();
56  }
T getParameter(std::string const &) const
edm::EDGetTokenT< ParticleCollection > srcToken_
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 57 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_.

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

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 67 of file ShiftedParticleProducerT.h.

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

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

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::EDGetTokenT<ParticleCollection> ShiftedParticleProducerT< T >::srcToken_
private