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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
const edm::EDGetTokenT< CandidateView > srcOriginalToken_

◆ ~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.

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

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Ptr< value_type > ptrAt(size_type i) const
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
virtual double et() const =0
transverse energy
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
Definition: weight.py:1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
size_type size() const
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
virtual double py() const =0
y coordinate of momentum vector
const_reference at(size_type pos) const
virtual double px() const =0
x coordinate of momentum vector
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
const edm::EDGetTokenT< CandidateView > srcOriginalToken_
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:169
virtual size_t numberOfSourceCandidatePtrs() const =0
def move(src, dest)
Definition: eostools.py:511

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