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

Classes

struct  binningEntryType
 

Public Member Functions

 ShiftedParticleProducerT (const edm::ParameterSet &cfg)
 
 ~ShiftedParticleProducerT () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 31 of file ShiftedParticleProducerT.h.

Member Typedef Documentation

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

Definition at line 33 of file ShiftedParticleProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file ShiftedParticleProducerT.h.

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

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

Definition at line 58 of file ShiftedParticleProducerT.h.

References ShiftedParticleProducerT< T >::binning_.

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

Member Function Documentation

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

Definition at line 68 of file ShiftedParticleProducerT.h.

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

69  {
70  edm::Handle<ParticleCollection> originalParticles;
71  evt.getByToken(srcToken_, originalParticles);
72 
73  auto shiftedParticles = std::make_unique<ParticleCollection>();
74 
75  for ( typename ParticleCollection::const_iterator originalParticle = originalParticles->begin();
76  originalParticle != originalParticles->end(); ++originalParticle ) {
77 
78  double uncertainty = 0.;
79  for ( typename std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
80  binningEntry != binning_.end(); ++binningEntry ) {
81  if ( (!(*binningEntry)->binSelection_) || (*(*binningEntry)->binSelection_)(*originalParticle) ) {
82  uncertainty = (*binningEntry)->binUncertainty_;
83  break;
84  }
85  }
86 
87  double shift = shiftBy_*uncertainty;
88 
89  reco::Candidate::LorentzVector shiftedParticleP4 = originalParticle->p4();
90  //leave 0*nan = 0
91  if (! (edm::isNotFinite(shift) && shiftedParticleP4.mag2()==0)) shiftedParticleP4 *= (1. + shift);
92 
93  T shiftedParticle(*originalParticle);
94  shiftedParticle.setP4(shiftedParticleP4);
95 
96  shiftedParticles->push_back(shiftedParticle);
97  }
98 
99  evt.put(std::move(shiftedParticles));
100  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
edm::EDGetTokenT< ParticleCollection > srcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< binningEntryType * > binning_
bool isNotFinite(T x)
Definition: isFinite.h:10
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
static unsigned int const shift
long double T
def move(src, dest)
Definition: eostools.py:510

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