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 ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
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::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 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 63 of file CaloJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 67 of file CaloJetMETcorrInputProducerT.h.

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

68  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
70  {
71  token_ = consumes<std::vector<T> >(cfg.getParameter<edm::InputTag>("src"));
72 
73  if ( cfg.exists("offsetCorrLabel") ) {
74  offsetCorrLabel_ = cfg.getParameter<edm::InputTag>("offsetCorrLabel");
75  offsetCorrToken_ = consumes<reco::JetCorrector>(offsetCorrLabel_);
76  }
77  jetCorrLabel_ = cfg.getParameter<edm::InputTag>("jetCorrLabel");
78  jetCorrToken_ = consumes<reco::JetCorrector>(jetCorrLabel_);
79 
80  jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
81  cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
82 
83  type1JetPtThreshold_ = cfg.getParameter<double>("type1JetPtThreshold");
84 
85  skipEM_ = cfg.getParameter<bool>("skipEM");
86  if ( skipEM_ ) {
87  skipEMfractionThreshold_ = cfg.getParameter<double>("skipEMfractionThreshold");
88  }
89 
90  if(cfg.exists("srcMET"))
91  {
92  srcMET_ = cfg.getParameter<edm::InputTag>("srcMET");
93  metToken_ = consumes<edm::View<reco::MET> >(cfg.getParameter<edm::InputTag>("srcMET"));
94  }
95 
96  produces<CorrMETData>("type1");
97  produces<CorrMETData>("type2");
98  produces<CorrMETData>("offset");
99  }
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 ( )
inline

Definition at line 100 of file CaloJetMETcorrInputProducerT.h.

100 {}

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 104 of file CaloJetMETcorrInputProducerT.h.

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

105  {
106  std::unique_ptr<CorrMETData> type1Correction(new CorrMETData());
107  std::unique_ptr<CorrMETData> unclEnergySum(new CorrMETData());
108  std::unique_ptr<CorrMETData> offsetEnergySum(new CorrMETData());
109 
111  evt.getByToken(jetCorrToken_, jetCorr);
112 
113  typedef std::vector<T> JetCollection;
115  evt.getByToken(token_, jets);
116 
117  typedef edm::View<reco::MET> METView;
119  if ( srcMET_.label() != "" ) {
120  evt.getByToken(metToken_, met);
121  if ( met->size() != 1 )
122  throw cms::Exception("CaloJetMETcorrInputProducer::produce")
123  << "Failed to find unique MET in the event, src = " << srcMET_.label() << " !!\n";
124 
125 //--- compute "unclustered energy" by sutracting from the reconstructed MET
126 // (i.e. from the negative vectorial sum of all particles reconstructed in the event)
127 // the momenta of (high Pt) jets which enter Type 1 MET corrections
128 //
129 // NOTE: MET = -(jets + muons + "unclustered energy"),
130 // so "unclustered energy" = -(MET + jets + muons),
131 // i.e. (high Pt) jets enter the sum of "unclustered energy" with negative sign.
132 //
133  unclEnergySum->mex = -met->front().px();
134  unclEnergySum->mey = -met->front().py();
135  unclEnergySum->sumet = met->front().sumEt();
136  }
137 
138  int numJets = jets->size();
139  for ( int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
140  const T& rawJet = jets->at(jetIndex);
141 
143  checkInputType(rawJet);
144 
146  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(rawJet);
147 
149  if ( checkInputType.isPatJet(rawJet) )
150  corrJetP4 = jetCorrExtractor_(rawJet, jetCorrLabel_.label(), jetCorrEtaMax_);
151  else
152  corrJetP4 = jetCorrExtractor_(rawJet, jetCorr.product(), jetCorrEtaMax_);
153 
154  if ( corrJetP4.pt() > type1JetPtThreshold_ ) {
155 
156  unclEnergySum->mex -= rawJetP4.px();
157  unclEnergySum->mey -= rawJetP4.py();
158  unclEnergySum->sumet -= rawJetP4.Et();
159 
160  if ( skipEM_ && rawJet.emEnergyFraction() > skipEMfractionThreshold_ ) continue;
161 
162  reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
163  if ( !offsetCorrLabel_.label().empty() ) {
165  evt.getByToken(offsetCorrToken_, offsetCorr);
166  if ( checkInputType.isPatJet(rawJet) )
167  rawJetP4offsetCorr = jetCorrExtractor_(rawJet, offsetCorrLabel_.label(), jetCorrEtaMax_);
168  else
169  rawJetP4offsetCorr = jetCorrExtractor_(rawJet, offsetCorr.product(), jetCorrEtaMax_);
170 
171  offsetEnergySum->mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
172  offsetEnergySum->mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
173  offsetEnergySum->sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
174  }
175 
176 //--- MET balances momentum of reconstructed particles,
177 // hence correction to jets and corresponding Type 1 MET correction are of opposite sign
178  type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
179  type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
180  type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
181  }
182  }
183 
184 //--- add
185 // o Type 1 MET correction (difference corrected-uncorrected jet energy for jets of (corrected) Pt > 20 GeV)
186 // o momentum sum of "unclustered energy" (jets of (corrected) Pt < 20 GeV)
187 // o momentum sum of "offset energy" (sum of energy attributed to pile-up/underlying event)
188 // to the event
189  evt.put(std::move(type1Correction), "type1");
190  evt.put(std::move(unclEnergySum), "type2");
191  evt.put(std::move(offsetEnergySum), "offset");
192  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
std::vector< Jet > JetCollection
Definition: Jet.h:53
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
vector< PseudoJet > jets
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
edm::EDGetTokenT< std::vector< T > > token_
T const * product() const
Definition: Handle.h:81
met
===> hadronic RAZOR
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:510

Member Data Documentation

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

Definition at line 204 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 202 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 200 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 201 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 219 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 198 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 199 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 214 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 216 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 218 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 196 of file CaloJetMETcorrInputProducerT.h.

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

Definition at line 210 of file CaloJetMETcorrInputProducerT.h.