CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedParticleMETcorrInputProducer Class Reference

#include <ShiftedParticleMETcorrInputProducer.h>

Inheritance diagram for ShiftedParticleMETcorrInputProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShiftedParticleMETcorrInputProducer (const edm::ParameterSet &)
 
 ~ShiftedParticleMETcorrInputProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef edm::View< reco::CandidateCandidateView
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT< CandidateViewsrcOriginalToken_
 
const edm::EDGetTokenT< CandidateViewsrcShiftedToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Propagate energy variations of electrons/muons/tau-jets to MET

Author
Christian Veelken, LLR

Definition at line 28 of file ShiftedParticleMETcorrInputProducer.h.

Member Typedef Documentation

◆ CandidateView

Definition at line 34 of file ShiftedParticleMETcorrInputProducer.h.

Constructor & Destructor Documentation

◆ ShiftedParticleMETcorrInputProducer()

ShiftedParticleMETcorrInputProducer::ShiftedParticleMETcorrInputProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 3 of file ShiftedParticleMETcorrInputProducer.cc.

4  : srcOriginalToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcOriginal"))),
5  srcShiftedToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShifted"))) {
6  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
7  if (!srcWeights.label().empty())
9 
10  produces<CorrMETData>();
11 }

References looper::cfg, edm::EDConsumerBase::consumes(), HLT_2018_cff::srcWeights, and weightsToken_.

◆ ~ShiftedParticleMETcorrInputProducer()

ShiftedParticleMETcorrInputProducer::~ShiftedParticleMETcorrInputProducer ( )
override

Definition at line 13 of file ShiftedParticleMETcorrInputProducer.cc.

13  {
14  // nothing to be done yet...
15 }

Member Function Documentation

◆ produce()

void ShiftedParticleMETcorrInputProducer::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup es 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 17 of file ShiftedParticleMETcorrInputProducer.cc.

17  {
18  edm::Handle<CandidateView> originalParticles;
19  evt.getByToken(srcOriginalToken_, originalParticles);
20 
21  edm::Handle<CandidateView> shiftedParticles;
22  evt.getByToken(srcShiftedToken_, shiftedParticles);
23 
27 
28  auto metCorrection = std::make_unique<CorrMETData>();
29  if ((!weightsToken_.isUninitialized()) && (originalParticles->size() != shiftedParticles->size()))
30  throw cms::Exception("InvalidInput")
31  << "Original collection and shifted collection are of different size in ShiftedParticleMETcorrInputProducer\n";
32  for (unsigned i = 0; i < originalParticles->size(); ++i) {
33  float weight = 1.0;
35  edm::Ptr<reco::Candidate> particlePtr = originalParticles->ptrAt(i);
36  while (!weights->contains(particlePtr.id()) && (particlePtr->numberOfSourceCandidatePtrs() > 0))
37  particlePtr = particlePtr->sourceCandidatePtr(0);
38  weight = (*weights)[particlePtr];
39  }
40  const reco::Candidate& originalParticle = originalParticles->at(i);
41  metCorrection->mex += originalParticle.px() * weight;
42  metCorrection->mey += originalParticle.py() * weight;
43  metCorrection->sumet -= originalParticle.et() * weight;
44  }
45  for (unsigned i = 0; i < shiftedParticles->size(); ++i) {
46  float weight = 1.0;
48  edm::Ptr<reco::Candidate> particlePtr = originalParticles->ptrAt(i);
49  while (!weights->contains(particlePtr.id()) && (particlePtr->numberOfSourceCandidatePtrs() > 0))
50  particlePtr = particlePtr->sourceCandidatePtr(0);
51  weight = (*weights)[particlePtr];
52  }
53  const reco::Candidate& shiftedParticle = shiftedParticles->at(i);
54  metCorrection->mex -= shiftedParticle.px() * weight;
55  metCorrection->mey -= shiftedParticle.py() * weight;
56  metCorrection->sumet += shiftedParticle.et() * weight;
57  }
58 
59  evt.put(std::move(metCorrection));
60 }

References edm::View< T >::at(), reco::Candidate::et(), Exception, edm::Event::getByToken(), mps_fire::i, edm::Ptr< T >::id(), edm::EDGetTokenT< T >::isUninitialized(), eostools::move(), reco::Candidate::numberOfSourceCandidatePtrs(), edm::View< T >::ptrAt(), edm::Event::put(), reco::Candidate::px(), reco::Candidate::py(), edm::View< T >::size(), reco::Candidate::sourceCandidatePtr(), srcOriginalToken_, srcShiftedToken_, mps_merge::weight, HLT_2018_cff::weights, and weightsToken_.

Member Data Documentation

◆ srcOriginalToken_

const edm::EDGetTokenT<CandidateView> ShiftedParticleMETcorrInputProducer::srcOriginalToken_
private

Definition at line 38 of file ShiftedParticleMETcorrInputProducer.h.

Referenced by produce().

◆ srcShiftedToken_

const edm::EDGetTokenT<CandidateView> ShiftedParticleMETcorrInputProducer::srcShiftedToken_
private

Definition at line 39 of file ShiftedParticleMETcorrInputProducer.h.

Referenced by produce().

◆ weightsToken_

edm::EDGetTokenT<edm::ValueMap<float> > ShiftedParticleMETcorrInputProducer::weightsToken_
private
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
mps_fire.i
i
Definition: mps_fire.py:355
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::Handle
Definition: AssociativeIterator.h:50
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
HLT_2018_cff.srcWeights
srcWeights
Definition: HLT_2018_cff.py:7335
edm::View::size
size_type size() const
reco::Candidate::py
virtual double py() const =0
y coordinate of momentum vector
edm::View::at
const_reference at(size_type pos) const
ShiftedParticleMETcorrInputProducer::weightsToken_
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Definition: ShiftedParticleMETcorrInputProducer.h:40
edm::Ptr::id
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
ShiftedParticleMETcorrInputProducer::srcShiftedToken_
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
Definition: ShiftedParticleMETcorrInputProducer.h:39
edm::Ptr< reco::Candidate >
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Candidate::sourceCandidatePtr
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:169
reco::Candidate::px
virtual double px() const =0
x coordinate of momentum vector
edm::ValueMap< float >
Exception
Definition: hltDiff.cc:246
ShiftedParticleMETcorrInputProducer::srcOriginalToken_
const edm::EDGetTokenT< CandidateView > srcOriginalToken_
Definition: ShiftedParticleMETcorrInputProducer.h:38
reco::Candidate::numberOfSourceCandidatePtrs
virtual size_t numberOfSourceCandidatePtrs() const =0
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
edm::View::ptrAt
Ptr< value_type > ptrAt(size_type i) const
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
reco::Candidate::et
virtual double et() const =0
transverse energy