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
 
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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

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

Definition at line 56 of file CaloJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file CaloJetMETcorrInputProducerT.h.

References edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

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  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
template<typename T , typename Textractor >
CaloJetMETcorrInputProducerT< T, Textractor >::~CaloJetMETcorrInputProducerT ( )
inlineoverride

Definition at line 87 of file CaloJetMETcorrInputProducerT.h.

87 {}

Member Function Documentation

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

Definition at line 90 of file CaloJetMETcorrInputProducerT.h.

References edm::Event::getByToken(), singleTopDQM_cfi::jets, BTaggingMonitor_cfi::met, eostools::move(), edm::Handle< T >::product(), and edm::Event::put().

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:131
std::vector< Jet > JetCollection
Definition: Jet.h:53
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
T const * product() const
Definition: Handle.h:69
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
std::string const & label() const
Definition: InputTag.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

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

Definition at line 190 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 188 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 185 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 187 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 205 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 183 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 184 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 200 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 202 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 204 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 181 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 196 of file CaloJetMETcorrInputProducerT.h.