CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PFCandMETcorrInputProducer Class Reference

#include <PFCandMETcorrInputProducer.h>

Inheritance diagram for PFCandMETcorrInputProducer:
edm::stream::EDProducer<>

Classes

struct  binningEntryType
 

Public Member Functions

 PFCandMETcorrInputProducer (const edm::ParameterSet &)
 
 ~PFCandMETcorrInputProducer () override
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

std::vector< std::unique_ptr< binningEntryType > > binning_
 
std::string moduleLabel_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > token_
 
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Sum PFCandidates not within jets ("unclustered energy"), needed as input for Type 2 MET corrections

Authors
Michael Schmitt, Richard Cavanaugh, The University of Florida Florent Lacroix, University of Illinois at Chicago Christian Veelken, LLR

Definition at line 31 of file PFCandMETcorrInputProducer.h.

Constructor & Destructor Documentation

◆ PFCandMETcorrInputProducer()

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

Definition at line 7 of file PFCandMETcorrInputProducer.cc.

References binning_, looper::cfg, HLT_2023v12_cff::srcWeights, token_, and weightsToken_.

8  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
9  token_ = consumes<edm::View<reco::Candidate>>(cfg.getParameter<edm::InputTag>("src"));
10  edm::InputTag srcWeights = cfg.getParameter<edm::InputTag>("srcWeights");
11  if (!srcWeights.label().empty())
13 
14  if (cfg.exists("binning")) {
15  typedef std::vector<edm::ParameterSet> vParameterSet;
16  vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
17  for (vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin(); cfgBinningEntry != cfgBinning.end();
18  ++cfgBinningEntry) {
19  binning_.emplace_back(new binningEntryType(*cfgBinningEntry));
20  }
21  } else {
22  binning_.emplace_back(new binningEntryType());
23  }
24 
25  for (auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry) {
26  produces<CorrMETData>((*binningEntry)->binLabel_);
27  }
28 }
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > token_
std::vector< std::unique_ptr< binningEntryType > > binning_

◆ ~PFCandMETcorrInputProducer()

PFCandMETcorrInputProducer::~PFCandMETcorrInputProducer ( )
override

Definition at line 30 of file PFCandMETcorrInputProducer.cc.

30 {}

Member Function Documentation

◆ produce()

void PFCandMETcorrInputProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 32 of file PFCandMETcorrInputProducer.cc.

References binning_, HLT_2023v12_cff::cands, edm::Event::getByToken(), edm::EDGetTokenT< T >::isUninitialized(), edm::Event::put(), token_, mps_merge::weight, hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights, and weightsToken_.

32  {
33  for (auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry) {
34  (*binningEntry)->binUnclEnergySum_ = CorrMETData();
35  }
36 
39  evt.getByToken(token_, cands);
40 
44 
45  for (edm::View<reco::Candidate>::const_iterator cand = cands->begin(); cand != cands->end(); ++cand) {
46  float weight = (!weightsToken_.isUninitialized()) ? (*weights)[cands->ptrAt(cand - cands->begin())] : 1.0;
47  for (auto binningEntry = binning_.begin(); binningEntry != binning_.end(); ++binningEntry) {
48  if (!(*binningEntry)->binSelection_ || (*(*binningEntry)->binSelection_)(cand->p4() * weight)) {
49  (*binningEntry)->binUnclEnergySum_.mex += cand->px() * weight;
50  (*binningEntry)->binUnclEnergySum_.mey += cand->py() * weight;
51  (*binningEntry)->binUnclEnergySum_.sumet += cand->et() * weight;
52  }
53  }
54  }
55 
56  //--- add momentum sum of PFCandidates not within jets ("unclustered energy") to the event
57  for (auto binningEntry = binning_.cbegin(); binningEntry != binning_.cend(); ++binningEntry) {
58  evt.put(std::make_unique<CorrMETData>((*binningEntry)->binUnclEnergySum_), (*binningEntry)->binLabel_);
59  }
60 }
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > token_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
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
std::vector< std::unique_ptr< binningEntryType > > binning_
a MET correction term
Definition: CorrMETData.h:14
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23

Member Data Documentation

◆ binning_

std::vector<std::unique_ptr<binningEntryType> > PFCandMETcorrInputProducer::binning_
private

Definition at line 55 of file PFCandMETcorrInputProducer.h.

Referenced by PFCandMETcorrInputProducer(), and produce().

◆ moduleLabel_

std::string PFCandMETcorrInputProducer::moduleLabel_
private

◆ token_

edm::EDGetTokenT<edm::View<reco::Candidate> > PFCandMETcorrInputProducer::token_
private

Definition at line 41 of file PFCandMETcorrInputProducer.h.

Referenced by PFCandMETcorrInputProducer(), and produce().

◆ weightsToken_

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

Definition at line 42 of file PFCandMETcorrInputProducer.h.

Referenced by PFCandMETcorrInputProducer(), and produce().