CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CaloJetMETcorrInputProducerT< T, Textractor > Class Template Referencefinal

#include <CaloJetMETcorrInputProducerT.h>

Inheritance diagram for CaloJetMETcorrInputProducerT< T, Textractor >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CaloJetMETcorrInputProducerT (const edm::ParameterSet &cfg)
 
 ~CaloJetMETcorrInputProducerT () 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 Member Functions

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

Private Attributes

double jetCorrEtaMax_
 
Textractor jetCorrExtractor_
 
edm::InputTag jetCorrLabel_
 
edm::EDGetTokenT< reco::JetCorrectorjetCorrToken_
 
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
 
std::string moduleLabel_
 
edm::InputTag offsetCorrLabel_
 
edm::EDGetTokenT< reco::JetCorrectoroffsetCorrToken_
 
bool skipEM_
 
double skipEMfractionThreshold_
 
edm::InputTag srcMET_
 
edm::EDGetTokenT< std::vector< T > > token_
 
double type1JetPtThreshold_
 

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

template<typename T, typename Textractor>
class CaloJetMETcorrInputProducerT< T, Textractor >

Definition at line 56 of file CaloJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

◆ CaloJetMETcorrInputProducerT()

template<typename T , typename Textractor >
CaloJetMETcorrInputProducerT< T, Textractor >::CaloJetMETcorrInputProducerT ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 58 of file CaloJetMETcorrInputProducerT.h.

59  : moduleLabel_(cfg.getParameter<std::string>("@module_label")), offsetCorrLabel_("") {
60  token_ = consumes<std::vector<T> >(cfg.getParameter<edm::InputTag>("src"));
61 
62  if (cfg.exists("offsetCorrLabel")) {
63  offsetCorrLabel_ = cfg.getParameter<edm::InputTag>("offsetCorrLabel");
64  offsetCorrToken_ = consumes<reco::JetCorrector>(offsetCorrLabel_);
65  }
66  jetCorrLabel_ = cfg.getParameter<edm::InputTag>("jetCorrLabel");
67  jetCorrToken_ = consumes<reco::JetCorrector>(jetCorrLabel_);
68 
69  jetCorrEtaMax_ = (cfg.exists("jetCorrEtaMax")) ? cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
70 
71  type1JetPtThreshold_ = cfg.getParameter<double>("type1JetPtThreshold");
72 
73  skipEM_ = cfg.getParameter<bool>("skipEM");
74  if (skipEM_) {
75  skipEMfractionThreshold_ = cfg.getParameter<double>("skipEMfractionThreshold");
76  }
77 
78  if (cfg.exists("srcMET")) {
79  srcMET_ = cfg.getParameter<edm::InputTag>("srcMET");
80  metToken_ = consumes<edm::View<reco::MET> >(cfg.getParameter<edm::InputTag>("srcMET"));
81  }
82 
83  produces<CorrMETData>("type1");
84  produces<CorrMETData>("type2");
85  produces<CorrMETData>("offset");
86  }

References looper::cfg, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrToken_, CaloJetMETcorrInputProducerT< T, Textractor >::metToken_, CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_, CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrToken_, CaloJetMETcorrInputProducerT< T, Textractor >::skipEM_, CaloJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_, CaloJetMETcorrInputProducerT< T, Textractor >::srcMET_, CaloJetMETcorrInputProducerT< T, Textractor >::token_, and CaloJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_.

◆ ~CaloJetMETcorrInputProducerT()

template<typename T , typename Textractor >
CaloJetMETcorrInputProducerT< T, Textractor >::~CaloJetMETcorrInputProducerT ( )
inlineoverride

Definition at line 87 of file CaloJetMETcorrInputProducerT.h.

87 {}

Member Function Documentation

◆ produce()

template<typename T , typename Textractor >
void CaloJetMETcorrInputProducerT< T, Textractor >::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup es 
) const
inlineoverrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 90 of file CaloJetMETcorrInputProducerT.h.

90  {
91  std::unique_ptr<CorrMETData> type1Correction(new CorrMETData());
92  std::unique_ptr<CorrMETData> unclEnergySum(new CorrMETData());
93  std::unique_ptr<CorrMETData> offsetEnergySum(new CorrMETData());
94 
96  evt.getByToken(jetCorrToken_, jetCorr);
97 
98  typedef std::vector<T> JetCollection;
100  evt.getByToken(token_, jets);
101 
102  typedef edm::View<reco::MET> METView;
104  if (!srcMET_.label().empty()) {
105  evt.getByToken(metToken_, met);
106  if (met->size() != 1)
107  throw cms::Exception("CaloJetMETcorrInputProducer::produce")
108  << "Failed to find unique MET in the event, src = " << srcMET_.label() << " !!\n";
109 
110  //--- compute "unclustered energy" by sutracting from the reconstructed MET
111  // (i.e. from the negative vectorial sum of all particles reconstructed in the event)
112  // the momenta of (high Pt) jets which enter Type 1 MET corrections
113  //
114  // NOTE: MET = -(jets + muons + "unclustered energy"),
115  // so "unclustered energy" = -(MET + jets + muons),
116  // i.e. (high Pt) jets enter the sum of "unclustered energy" with negative sign.
117  //
118  unclEnergySum->mex = -met->front().px();
119  unclEnergySum->mey = -met->front().py();
120  unclEnergySum->sumet = met->front().sumEt();
121  }
122 
123  int numJets = jets->size();
124  for (int jetIndex = 0; jetIndex < numJets; ++jetIndex) {
125  const T& rawJet = jets->at(jetIndex);
126 
128  checkInputType(rawJet);
129 
131  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(rawJet);
132 
134  if (checkInputType.isPatJet(rawJet))
135  corrJetP4 = jetCorrExtractor_(rawJet, jetCorrLabel_.label(), jetCorrEtaMax_);
136  else
137  corrJetP4 = jetCorrExtractor_(rawJet, jetCorr.product(), jetCorrEtaMax_);
138 
139  if (corrJetP4.pt() > type1JetPtThreshold_) {
140  unclEnergySum->mex -= rawJetP4.px();
141  unclEnergySum->mey -= rawJetP4.py();
142  unclEnergySum->sumet -= rawJetP4.Et();
143 
144  if (skipEM_ && rawJet.emEnergyFraction() > skipEMfractionThreshold_)
145  continue;
146 
147  reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
148  if (!offsetCorrLabel_.label().empty()) {
150  evt.getByToken(offsetCorrToken_, offsetCorr);
151  if (checkInputType.isPatJet(rawJet))
152  rawJetP4offsetCorr = jetCorrExtractor_(rawJet, offsetCorrLabel_.label(), jetCorrEtaMax_);
153  else
154  rawJetP4offsetCorr = jetCorrExtractor_(rawJet, offsetCorr.product(), jetCorrEtaMax_);
155 
156  offsetEnergySum->mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
157  offsetEnergySum->mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
158  offsetEnergySum->sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
159  }
160 
161  //--- MET balances momentum of reconstructed particles,
162  // hence correction to jets and corresponding Type 1 MET correction are of opposite sign
163  type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
164  type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
165  type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
166  }
167  }
168 
169  //--- add
170  // o Type 1 MET correction (difference corrected-uncorrected jet energy for jets of (corrected) Pt > 20 GeV)
171  // o momentum sum of "unclustered energy" (jets of (corrected) Pt < 20 GeV)
172  // o momentum sum of "offset energy" (sum of energy attributed to pile-up/underlying event)
173  // to the event
174  evt.put(std::move(type1Correction), "type1");
175  evt.put(std::move(unclEnergySum), "type2");
176  evt.put(std::move(offsetEnergySum), "offset");
177  }

References edm::Event::getByToken(), CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrExtractor_, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_, CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrToken_, singleTopDQM_cfi::jets, edm::InputTag::label(), BTaggingMonitor_cfi::met, CaloJetMETcorrInputProducerT< T, Textractor >::metToken_, eostools::move(), CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_, CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrToken_, edm::Handle< T >::product(), edm::Event::put(), CaloJetMETcorrInputProducerT< T, Textractor >::skipEM_, CaloJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_, CaloJetMETcorrInputProducerT< T, Textractor >::srcMET_, CaloJetMETcorrInputProducerT< T, Textractor >::token_, and CaloJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_.

Member Data Documentation

◆ jetCorrEtaMax_

template<typename T , typename Textractor >
double CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_
private

◆ jetCorrExtractor_

template<typename T , typename Textractor >
Textractor CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrExtractor_
private

◆ jetCorrLabel_

template<typename T , typename Textractor >
edm::InputTag CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_
private

◆ jetCorrToken_

template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> CaloJetMETcorrInputProducerT< T, Textractor >::jetCorrToken_
private

◆ metToken_

template<typename T , typename Textractor >
edm::EDGetTokenT<edm::View<reco::MET> > CaloJetMETcorrInputProducerT< T, Textractor >::metToken_
private

◆ moduleLabel_

template<typename T , typename Textractor >
std::string CaloJetMETcorrInputProducerT< T, Textractor >::moduleLabel_
private

◆ offsetCorrLabel_

template<typename T , typename Textractor >
edm::InputTag CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_
private

◆ offsetCorrToken_

template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> CaloJetMETcorrInputProducerT< T, Textractor >::offsetCorrToken_
private

◆ skipEM_

template<typename T , typename Textractor >
bool CaloJetMETcorrInputProducerT< T, Textractor >::skipEM_
private

◆ skipEMfractionThreshold_

template<typename T , typename Textractor >
double CaloJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_
private

◆ srcMET_

template<typename T , typename Textractor >
edm::InputTag CaloJetMETcorrInputProducerT< T, Textractor >::srcMET_
private

◆ token_

template<typename T , typename Textractor >
edm::EDGetTokenT<std::vector<T> > CaloJetMETcorrInputProducerT< T, Textractor >::token_
private

◆ type1JetPtThreshold_

template<typename T , typename Textractor >
double CaloJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_
private
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CaloJetMETcorrInputProducerT::moduleLabel_
std::string moduleLabel_
Definition: CaloJetMETcorrInputProducerT.h:179
CaloJetMETcorrInputProducer_namespace::RawJetExtractorT
Definition: CaloJetMETcorrInputProducerT.h:45
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle< reco::JetCorrector >
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
CaloJetMETcorrInputProducerT::offsetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
Definition: CaloJetMETcorrInputProducerT.h:184
pat::JetCollection
std::vector< Jet > JetCollection
Definition: Jet.h:53
CaloJetMETcorrInputProducerT::offsetCorrLabel_
edm::InputTag offsetCorrLabel_
Definition: CaloJetMETcorrInputProducerT.h:183
CaloJetMETcorrInputProducerT::jetCorrLabel_
edm::InputTag jetCorrLabel_
Definition: CaloJetMETcorrInputProducerT.h:185
CaloJetMETcorrInputProducerT::jetCorrExtractor_
Textractor jetCorrExtractor_
Definition: CaloJetMETcorrInputProducerT.h:188
CorrMETData
a MET correction term
Definition: CorrMETData.h:14
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CaloJetMETcorrInputProducerT::srcMET_
edm::InputTag srcMET_
Definition: CaloJetMETcorrInputProducerT.h:204
edm::View
Definition: CaloClusterFwd.h:14
CaloJetMETcorrInputProducerT::token_
edm::EDGetTokenT< std::vector< T > > token_
Definition: CaloJetMETcorrInputProducerT.h:181
CaloJetMETcorrInputProducerT::skipEM_
bool skipEM_
Definition: CaloJetMETcorrInputProducerT.h:200
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
CaloJetMETcorrInputProducerT::jetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
Definition: CaloJetMETcorrInputProducerT.h:187
CaloJetMETcorrInputProducerT::skipEMfractionThreshold_
double skipEMfractionThreshold_
Definition: CaloJetMETcorrInputProducerT.h:202
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
CaloJetMETcorrInputProducerT::type1JetPtThreshold_
double type1JetPtThreshold_
Definition: CaloJetMETcorrInputProducerT.h:196
T
long double T
Definition: Basic3DVectorLD.h:48
CaloJetMETcorrInputProducer_namespace::InputTypeCheckerT
Definition: CaloJetMETcorrInputProducerT.h:38
cms::Exception
Definition: Exception.h:70
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
CaloJetMETcorrInputProducerT::jetCorrEtaMax_
double jetCorrEtaMax_
Definition: CaloJetMETcorrInputProducerT.h:190
CaloJetMETcorrInputProducerT::metToken_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
Definition: CaloJetMETcorrInputProducerT.h:205
edm::InputTag
Definition: InputTag.h:15