CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PFJetMETcorrInputProducerT< T, Textractor > Class Template Reference

#include <PFJetMETcorrInputProducerT.h>

Inheritance diagram for PFJetMETcorrInputProducerT< T, Textractor >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  type2BinningEntryType
 

Public Member Functions

 PFJetMETcorrInputProducerT (const edm::ParameterSet &cfg)
 
 ~PFJetMETcorrInputProducerT ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

double jetCorrEtaMax_
 
Textractor jetCorrExtractor_
 
std::string jetCorrLabel_
 
std::string moduleLabel_
 
std::string offsetCorrLabel_
 
bool skipEM_
 
double skipEMfractionThreshold_
 
bool skipMuons_
 
StringCutObjectSelector
< reco::Muon > * 
skipMuonSelection_
 
edm::InputTag src_
 
double type1JetPtThreshold_
 
std::vector
< type2BinningEntryType * > 
type2Binning_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 PFJetMETcorrInputProducerT< T, Textractor >

Produce Type 1 + 2 MET corrections corresponding to differences between raw PFJets and PFJets with jet energy corrections (JECs) applied

NOTE: class is templated to that it works with reco::PFJets as well as with pat::Jets of PF-type as input

Authors
Michael Schmitt, Richard Cavanaugh, The University of Florida Florent Lacroix, University of Illinois at Chicago Christian Veelken, LLR
Version
Revision:
1.8
Id:
PFJetMETcorrInputProducerT.h,v 1.8 2012/04/19 17:56:29 veelken Exp

Definition at line 66 of file PFJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 70 of file PFJetMETcorrInputProducerT.h.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), PFJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_, PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_, PFJetMETcorrInputProducerT< T, Textractor >::skipEM_, PFJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_, PFJetMETcorrInputProducerT< T, Textractor >::skipMuons_, PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_, PFJetMETcorrInputProducerT< T, Textractor >::src_, AlCaHLTBitMon_QueryRunRegistry::string, PFJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_, and PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_.

71  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
73  {
74  src_ = cfg.getParameter<edm::InputTag>("src");
75 
76  offsetCorrLabel_ = ( cfg.exists("offsetCorrLabel") ) ?
77  cfg.getParameter<std::string>("offsetCorrLabel") : "";
78  jetCorrLabel_ = cfg.getParameter<std::string>("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  skipMuons_ = cfg.getParameter<bool>("skipMuons");
91  if ( skipMuons_ ) {
92  std::string skipMuonSelection_string = cfg.getParameter<std::string>("skipMuonSelection");
93  skipMuonSelection_ = new StringCutObjectSelector<reco::Muon>(skipMuonSelection_string);
94  }
95 
96  if ( cfg.exists("type2Binning") ) {
97  typedef std::vector<edm::ParameterSet> vParameterSet;
98  vParameterSet cfgType2Binning = cfg.getParameter<vParameterSet>("type2Binning");
99  for ( vParameterSet::const_iterator cfgType2BinningEntry = cfgType2Binning.begin();
100  cfgType2BinningEntry != cfgType2Binning.end(); ++cfgType2BinningEntry ) {
101  type2Binning_.push_back(new type2BinningEntryType(*cfgType2BinningEntry));
102  }
103  } else {
104  type2Binning_.push_back(new type2BinningEntryType());
105  }
106 
107  produces<CorrMETData>("type1");
108  for ( typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry = type2Binning_.begin();
109  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
110  produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full("type2"));
111  produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full("offset"));
112  }
113  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< type2BinningEntryType * > type2Binning_
StringCutObjectSelector< reco::Muon > * skipMuonSelection_
template<typename T , typename Textractor >
PFJetMETcorrInputProducerT< T, Textractor >::~PFJetMETcorrInputProducerT ( )
inline

Definition at line 114 of file PFJetMETcorrInputProducerT.h.

References PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_, and PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_.

115  {
116  delete skipMuonSelection_;
117 
118  for ( typename std::vector<type2BinningEntryType*>::const_iterator it = type2Binning_.begin();
119  it != type2Binning_.end(); ++it ) {
120  delete (*it);
121  }
122  }
std::vector< type2BinningEntryType * > type2Binning_
StringCutObjectSelector< reco::Muon > * skipMuonSelection_

Member Function Documentation

template<typename T , typename Textractor >
void PFJetMETcorrInputProducerT< T, Textractor >::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlineprivatevirtual

Implements edm::EDProducer.

Definition at line 126 of file PFJetMETcorrInputProducerT.h.

References edm::Event::getByLabel(), PFJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrExtractor_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_, fwrapper::jets, PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_, edm::Event::put(), PFJetMETcorrInputProducerT< T, Textractor >::skipEM_, PFJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_, PFJetMETcorrInputProducerT< T, Textractor >::skipMuons_, PFJetMETcorrInputProducerT< T, Textractor >::src_, PFJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_, and PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_.

127  {
128  std::auto_ptr<CorrMETData> type1Correction(new CorrMETData());
129  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
130  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
131  (*type2BinningEntry)->binUnclEnergySum_ = CorrMETData();
132  (*type2BinningEntry)->binOffsetEnergySum_ = CorrMETData();
133  }
134 
135  typedef std::vector<T> JetCollection;
137  evt.getByLabel(src_, jets);
138 
139  int numJets = jets->size();
140  for ( int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
141  const T& rawJet = jets->at(jetIndex);
142 
144  checkInputType(rawJet);
145 
146  double emEnergyFraction = rawJet.chargedEmEnergyFraction() + rawJet.neutralEmEnergyFraction();
147  if ( skipEM_ && emEnergyFraction > skipEMfractionThreshold_ ) continue;
148 
150  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(rawJet);
151  if ( skipMuons_ ) {
152  std::vector<reco::PFCandidatePtr> cands = rawJet.getPFConstituents();
153  for ( std::vector<reco::PFCandidatePtr>::const_iterator cand = cands.begin();
154  cand != cands.end(); ++cand ) {
155  if ( (*cand)->muonRef().isNonnull() && (*skipMuonSelection_)(*(*cand)->muonRef()) ) {
156  reco::Candidate::LorentzVector muonP4 = (*cand)->p4();
157  rawJetP4 -= muonP4;
158  }
159  }
160  }
161 
162  reco::Candidate::LorentzVector corrJetP4 = jetCorrExtractor_(rawJet, jetCorrLabel_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
163 
164  if ( corrJetP4.pt() > type1JetPtThreshold_ ) {
165 
166  reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
167  if ( offsetCorrLabel_ != "" ) {
168  rawJetP4offsetCorr = jetCorrExtractor_(rawJet, offsetCorrLabel_, &evt, &es, jetCorrEtaMax_, &rawJetP4);
169 
170  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
171  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
172  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
173  (*type2BinningEntry)->binOffsetEnergySum_.mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
174  (*type2BinningEntry)->binOffsetEnergySum_.mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
175  (*type2BinningEntry)->binOffsetEnergySum_.sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
176  }
177  }
178  }
179 
180 //--- MET balances momentum of reconstructed particles,
181 // hence correction to jets and corresponding Type 1 MET correction are of opposite sign
182  type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
183  type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
184  type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
185  } else {
186  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
187  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
188  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
189  (*type2BinningEntry)->binUnclEnergySum_.mex += rawJetP4.px();
190  (*type2BinningEntry)->binUnclEnergySum_.mey += rawJetP4.py();
191  (*type2BinningEntry)->binUnclEnergySum_.sumet += rawJetP4.Et();
192  }
193  }
194  }
195  }
196 
197 //--- add
198 // o Type 1 MET correction (difference corrected-uncorrected jet energy for jets of (corrected) Pt > 10 GeV)
199 // o momentum sum of "unclustered energy" (jets of (corrected) Pt < 10 GeV)
200 // o momentum sum of "offset energy" (sum of energy attributed to pile-up/underlying event)
201 // to the event
202  evt.put(type1Correction, "type1");
203  for ( typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry = type2Binning_.begin();
204  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
205  evt.put(std::auto_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binUnclEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("type2"));
206  evt.put(std::auto_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binOffsetEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("offset"));
207  }
208  }
std::vector< Jet > JetCollection
Definition: Jet.h:49
std::vector< type2BinningEntryType * > type2Binning_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
a MET correction term
Definition: CorrMETData.h:15
long double T

Member Data Documentation

template<typename T , typename Textractor >
double PFJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_
private
template<typename T , typename Textractor >
Textractor PFJetMETcorrInputProducerT< T, Textractor >::jetCorrExtractor_
private
template<typename T , typename Textractor >
std::string PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_
private
template<typename T , typename Textractor >
std::string PFJetMETcorrInputProducerT< T, Textractor >::moduleLabel_
private
template<typename T , typename Textractor >
std::string PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_
private
template<typename T , typename Textractor >
bool PFJetMETcorrInputProducerT< T, Textractor >::skipEM_
private
template<typename T , typename Textractor >
double PFJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_
private
template<typename T , typename Textractor >
bool PFJetMETcorrInputProducerT< T, Textractor >::skipMuons_
private
template<typename T , typename Textractor >
StringCutObjectSelector<reco::Muon>* PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_
private
template<typename T , typename Textractor >
edm::InputTag PFJetMETcorrInputProducerT< T, Textractor >::src_
private
template<typename T , typename Textractor >
double PFJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_
private
template<typename T , typename Textractor >
std::vector<type2BinningEntryType*> PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_
private