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

Classes

struct  binningEntryType
 

Public Member Functions

 ShiftedParticleProducer (const edm::ParameterSet &cfg)
 
 ~ShiftedParticleProducer ()
 
- 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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

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 34 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.

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

Definition at line 25 of file ShiftedParticleProducer.cc.

References binning_.

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

Member Function Documentation

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

Definition at line 61 of file ShiftedParticleProducer.cc.

References binning_, and DEFINE_FWK_MODULE.

Referenced by produce().

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

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

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

Member Data Documentation

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

Definition at line 81 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().

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

Definition at line 50 of file ShiftedParticleProducer.h.

Referenced by produce(), and ShiftedParticleProducer().