CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
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)
 
 ~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::Candidate
CandidateView
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT
< CandidateView
srcOriginalToken_
 
const edm::EDGetTokenT
< CandidateView
srcShiftedToken_
 
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
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< B > consumes (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 () noexcept
 
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...
 
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

Definition at line 31 of file ShiftedParticleMETcorrInputProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file ShiftedParticleMETcorrInputProducer.cc.

References edm::EDConsumerBase::consumes(), edm::ParameterSet::getParameter(), edm::InputTag::label(), HLT_FULL_cff::srcWeights, and weightsToken_.

41  : srcOriginalToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcOriginal"))),
42  srcShiftedToken_(consumes<CandidateView>(cfg.getParameter<edm::InputTag>("srcShifted"))) {
44  if (!srcWeights.label().empty())
46 
47  produces<CorrMETData>();
48 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
std::string const & label() const
Definition: InputTag.h:36
const edm::EDGetTokenT< CandidateView > srcOriginalToken_
ShiftedParticleMETcorrInputProducer::~ShiftedParticleMETcorrInputProducer ( )
override

Definition at line 50 of file ShiftedParticleMETcorrInputProducer.cc.

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

Member Function Documentation

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 reco::Candidate::et(), Exception, edm::Event::getByToken(), mps_fire::i, edm::Ptr< T >::id(), edm::EDGetTokenT< T >::isUninitialized(), eostools::move(), edm::Event::put(), reco::Candidate::px(), reco::Candidate::py(), srcOriginalToken_, srcShiftedToken_, histoStyle::weight, HLT_FULL_cff::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 
63  evt.getByToken(weightsToken_, weights);
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual double et() const =0
transverse energy
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
def move
Definition: eostools.py:511
virtual double py() const =0
y coordinate of momentum vector
virtual double px() const =0
x coordinate of momentum vector
const edm::EDGetTokenT< CandidateView > srcShiftedToken_
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
const edm::EDGetTokenT< CandidateView > srcOriginalToken_
int weight
Definition: histoStyle.py:51

Member Data Documentation

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

Definition at line 35 of file ShiftedParticleMETcorrInputProducer.cc.

Referenced by produce().

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

Definition at line 36 of file ShiftedParticleMETcorrInputProducer.cc.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<float> > ShiftedParticleMETcorrInputProducer::weightsToken_
private