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
 
 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 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<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

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.

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_.

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  }
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_

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

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_.

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  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< Jet > JetCollection
Definition: Jet.h:53
T const * product() const
Definition: Handle.h:70
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
a MET correction term
Definition: CorrMETData.h:14
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
long double T
def move(src, dest)
Definition: eostools.py:511

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