CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ShiftedParticleMETcorrInputProducer Class Reference
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 25 of file ShiftedParticleMETcorrInputProducer.cc.

Member Typedef Documentation

◆ CandidateView

Definition at line 31 of file ShiftedParticleMETcorrInputProducer.cc.

Constructor & Destructor Documentation

◆ ShiftedParticleMETcorrInputProducer()

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

Definition at line 40 of file ShiftedParticleMETcorrInputProducer.cc.

41  : srcOriginalToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcOriginal"))),
42  srcShiftedToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShifted"))) {
43  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
44  if (!srcWeights.label().empty())
46 
47  produces<CorrMETData>();
48 }

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

◆ ~ShiftedParticleMETcorrInputProducer()

ShiftedParticleMETcorrInputProducer::~ShiftedParticleMETcorrInputProducer ( )
override

Definition at line 50 of file ShiftedParticleMETcorrInputProducer.cc.

50  {
51  // nothing to be done yet...
52 }

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 54 of file ShiftedParticleMETcorrInputProducer.cc.

54  {
55  edm::Handle<CandidateView> originalParticles;
56  evt.getByToken(srcOriginalToken_, originalParticles);
57 
58  edm::Handle<CandidateView> shiftedParticles;
59  evt.getByToken(srcShiftedToken_, shiftedParticles);
60 
64 
65  auto metCorrection = std::make_unique<CorrMETData>();
66  if ((!weightsToken_.isUninitialized()) && (originalParticles->size() != shiftedParticles->size()))
67  throw cms::Exception("InvalidInput")
68  << "Original collection and shifted collection are of different size in ShiftedParticleMETcorrInputProducer\n";
69  for (unsigned i = 0; i < originalParticles->size(); ++i) {
70  float weight = 1.0;
72  edm::Ptr<reco::Candidate> particlePtr = originalParticles->ptrAt(i);
73  while (!weights->contains(particlePtr.id()) && (particlePtr->numberOfSourceCandidatePtrs() > 0))
74  particlePtr = particlePtr->sourceCandidatePtr(0);
75  weight = (*weights)[particlePtr];
76  }
77  const reco::Candidate& originalParticle = originalParticles->at(i);
78  metCorrection->mex += originalParticle.px() * weight;
79  metCorrection->mey += originalParticle.py() * weight;
80  metCorrection->sumet -= originalParticle.et() * weight;
81  }
82  for (unsigned i = 0; i < shiftedParticles->size(); ++i) {
83  float weight = 1.0;
85  edm::Ptr<reco::Candidate> particlePtr = originalParticles->ptrAt(i);
86  while (!weights->contains(particlePtr.id()) && (particlePtr->numberOfSourceCandidatePtrs() > 0))
87  particlePtr = particlePtr->sourceCandidatePtr(0);
88  weight = (*weights)[particlePtr];
89  }
90  const reco::Candidate& shiftedParticle = shiftedParticles->at(i);
91  metCorrection->mex -= shiftedParticle.px() * weight;
92  metCorrection->mey -= shiftedParticle.py() * weight;
93  metCorrection->sumet += shiftedParticle.et() * weight;
94  }
95 
96  evt.put(std::move(metCorrection));
97 }

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_FULL_cff::weights, and weightsToken_.

Member Data Documentation

◆ srcOriginalToken_

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

Definition at line 35 of file ShiftedParticleMETcorrInputProducer.cc.

Referenced by produce().

◆ srcShiftedToken_

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

Definition at line 36 of file ShiftedParticleMETcorrInputProducer.cc.

Referenced by produce().

◆ weightsToken_

edm::EDGetTokenT<edm::ValueMap<float> > ShiftedParticleMETcorrInputProducer::weightsToken_
private
mps_fire.i
i
Definition: mps_fire.py:428
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::Handle
Definition: AssociativeIterator.h:50
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99207
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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.cc:37
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:133
HLT_FULL_cff.srcWeights
srcWeights
Definition: HLT_FULL_cff.py:8709
ShiftedParticleMETcorrInputProducer::srcShiftedToken_
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
Definition: ShiftedParticleMETcorrInputProducer.cc:36
edm::Ptr< reco::Candidate >
looper.cfg
cfg
Definition: looper.py:296
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:245
ShiftedParticleMETcorrInputProducer::srcOriginalToken_
const edm::EDGetTokenT< CandidateView > srcOriginalToken_
Definition: ShiftedParticleMETcorrInputProducer.cc:35
reco::Candidate::numberOfSourceCandidatePtrs
virtual size_t numberOfSourceCandidatePtrs() const =0
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
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