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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  type2BinningEntryType
 

Public Member Functions

 PFJetMETcorrInputProducerT (const edm::ParameterSet &cfg)
 
 ~PFJetMETcorrInputProducerT ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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_
 
edm::InputTag jetCorrLabel_
 
edm::InputTag jetCorrLabelRes_
 
edm::EDGetTokenT
< reco::JetCorrector
jetCorrResToken_
 
edm::EDGetTokenT
< reco::JetCorrector
jetCorrToken_
 
std::string moduleLabel_
 
edm::InputTag offsetCorrLabel_
 
edm::EDGetTokenT
< reco::JetCorrector
offsetCorrToken_
 
bool skipEM_
 
double skipEMfractionThreshold_
 
bool skipMuons_
 
StringCutObjectSelector
< reco::Candidate > * 
skipMuonSelection_
 
edm::EDGetTokenT< std::vector
< T > > 
token_
 
double type1JetPtThreshold_
 
std::vector
< type2BinningEntryType * > 
type2Binning_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::stream::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 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

Definition at line 72 of file PFJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 76 of file PFJetMETcorrInputProducerT.h.

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

77  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
78  offsetCorrLabel_(""),
80  {
81  token_ = consumes<std::vector<T> >(cfg.getParameter<edm::InputTag>("src"));
82 
83  if ( cfg.exists("offsetCorrLabel") ) {
84  offsetCorrLabel_ = cfg.getParameter<edm::InputTag>("offsetCorrLabel");
85  offsetCorrToken_ = consumes<reco::JetCorrector>(offsetCorrLabel_);
86  }
87  jetCorrLabel_ = cfg.getParameter<edm::InputTag>("jetCorrLabel"); //for MC
88  jetCorrLabelRes_ = cfg.getParameter<edm::InputTag>("jetCorrLabelRes"); //for data
89  jetCorrToken_ = mayConsume<reco::JetCorrector>(jetCorrLabel_);
90  jetCorrResToken_ = mayConsume<reco::JetCorrector>(jetCorrLabelRes_);
91 
92  jetCorrEtaMax_ = ( cfg.exists("jetCorrEtaMax") ) ?
93  cfg.getParameter<double>("jetCorrEtaMax") : 9.9;
94 
95  type1JetPtThreshold_ = cfg.getParameter<double>("type1JetPtThreshold");
96 
97  skipEM_ = cfg.getParameter<bool>("skipEM");
98  if ( skipEM_ ) {
99  skipEMfractionThreshold_ = cfg.getParameter<double>("skipEMfractionThreshold");
100  }
101 
102  skipMuons_ = cfg.getParameter<bool>("skipMuons");
103  if ( skipMuons_ ) {
104  std::string skipMuonSelection_string = cfg.getParameter<std::string>("skipMuonSelection");
105  skipMuonSelection_ = new StringCutObjectSelector<reco::Candidate>(skipMuonSelection_string,true);
106  }
107 
108  if ( cfg.exists("type2Binning") ) {
109  typedef std::vector<edm::ParameterSet> vParameterSet;
110  vParameterSet cfgType2Binning = cfg.getParameter<vParameterSet>("type2Binning");
111  for ( vParameterSet::const_iterator cfgType2BinningEntry = cfgType2Binning.begin();
112  cfgType2BinningEntry != cfgType2Binning.end(); ++cfgType2BinningEntry ) {
113  type2Binning_.push_back(new type2BinningEntryType(*cfgType2BinningEntry));
114  }
115  } else {
116  type2Binning_.push_back(new type2BinningEntryType());
117  }
118 
119  produces<CorrMETData>("type1");
120  for ( typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry = type2Binning_.begin();
121  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
122  produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full("type2"));
123  produces<CorrMETData>((*type2BinningEntry)->getInstanceLabel_full("offset"));
124  }
125  }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::JetCorrector > jetCorrResToken_
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
StringCutObjectSelector< reco::Candidate > * skipMuonSelection_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
std::vector< type2BinningEntryType * > type2Binning_
edm::EDGetTokenT< std::vector< T > > token_
template<typename T , typename Textractor >
PFJetMETcorrInputProducerT< T, Textractor >::~PFJetMETcorrInputProducerT ( )
inline

Definition at line 126 of file PFJetMETcorrInputProducerT.h.

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

127  {
128  delete skipMuonSelection_;
129 
130  for ( typename std::vector<type2BinningEntryType*>::const_iterator it = type2Binning_.begin();
131  it != type2Binning_.end(); ++it ) {
132  delete (*it);
133  }
134  }
StringCutObjectSelector< reco::Candidate > * skipMuonSelection_
std::vector< type2BinningEntryType * > type2Binning_

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 138 of file PFJetMETcorrInputProducerT.h.

References reco::LeafCandidate::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), edm::Ref< C, T, F >::isNonnull(), edm::EventBase::isRealData(), metsig::jet, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrEtaMax_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrExtractor_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabelRes_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrResToken_, PFJetMETcorrInputProducerT< T, Textractor >::jetCorrToken_, fwrapper::jets, edm::InputTag::label(), RPCpg::mu, reco::PFCandidate::muonRef(), PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_, PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrToken_, edm::Handle< T >::product(), edm::Event::put(), PFJetMETcorrInputProducerT< T, Textractor >::skipEM_, PFJetMETcorrInputProducerT< T, Textractor >::skipEMfractionThreshold_, PFJetMETcorrInputProducerT< T, Textractor >::skipMuons_, PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_, PFJetMETcorrInputProducerT< T, Textractor >::token_, PFJetMETcorrInputProducerT< T, Textractor >::type1JetPtThreshold_, and PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_.

139  {
140 
141  std::auto_ptr<CorrMETData> type1Correction(new CorrMETData());
142  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
143  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
144  (*type2BinningEntry)->binUnclEnergySum_ = CorrMETData();
145  (*type2BinningEntry)->binOffsetEnergySum_ = CorrMETData();
146  }
147 
149  //automatic switch for residual corrections
150  if(evt.isRealData() ) {
152  evt.getByToken(jetCorrResToken_, jetCorr);
153  } else {
154  evt.getByToken(jetCorrToken_, jetCorr);
155  }
156 
157  typedef std::vector<T> JetCollection;
159  evt.getByToken(token_, jets);
160 
161  int numJets = jets->size();
162  for ( int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
163  const T& jet = jets->at(jetIndex);
164 
166  checkInputType(jet);
167 
168  double emEnergyFraction = jet.chargedEmEnergyFraction() + jet.neutralEmEnergyFraction();
169  if ( skipEM_ && emEnergyFraction > skipEMfractionThreshold_ ) continue;
170 
171  const static PFJetMETcorrInputProducer_namespace::RawJetExtractorT<T> rawJetExtractor {};
172  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(jet);
173 
174  if ( skipMuons_ ) {
175  const std::vector<reco::CandidatePtr> & cands = jet.daughterPtrVector();
176  for ( std::vector<reco::CandidatePtr>::const_iterator cand = cands.begin();
177  cand != cands.end(); ++cand ) {
178  const reco::PFCandidate *pfcand = dynamic_cast<const reco::PFCandidate *>(cand->get());
179  const reco::Candidate *mu = (pfcand != 0 ? ( pfcand->muonRef().isNonnull() ? pfcand->muonRef().get() : 0) : cand->get());
180  if ( mu != 0 && (*skipMuonSelection_)(*mu) ) {
181  reco::Candidate::LorentzVector muonP4 = (*cand)->p4();
182  rawJetP4 -= muonP4;
183  }
184  }
185  }
186 
188  if ( checkInputType.isPatJet(jet) )
189  corrJetP4 = jetCorrExtractor_(jet, jetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
190  else
191  corrJetP4 = jetCorrExtractor_(jet, jetCorr.product(), jetCorrEtaMax_, &rawJetP4);
192 
193  if ( corrJetP4.pt() > type1JetPtThreshold_ ) {
194 
195  reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
196  if ( !offsetCorrLabel_.label().empty() ) {
198  evt.getByToken(offsetCorrToken_, offsetCorr);
199  if ( checkInputType.isPatJet(jet) )
200  rawJetP4offsetCorr = jetCorrExtractor_(jet, offsetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
201  else
202  rawJetP4offsetCorr = jetCorrExtractor_(jet, offsetCorr.product(), jetCorrEtaMax_, &rawJetP4);
203 
204  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
205  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
206  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
207  (*type2BinningEntry)->binOffsetEnergySum_.mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
208  (*type2BinningEntry)->binOffsetEnergySum_.mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
209  (*type2BinningEntry)->binOffsetEnergySum_.sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
210  }
211  }
212  }
213 
214 //--- MET balances momentum of reconstructed particles,
215 // hence correction to jets and corresponding Type 1 MET correction are of opposite sign
216  type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
217  type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
218  type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
219  } else {
220  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
221  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
222  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
223  (*type2BinningEntry)->binUnclEnergySum_.mex += rawJetP4.px();
224  (*type2BinningEntry)->binUnclEnergySum_.mey += rawJetP4.py();
225  (*type2BinningEntry)->binUnclEnergySum_.sumet += rawJetP4.Et();
226  }
227  }
228  }
229  }
230 
231 //--- add
232 // o Type 1 MET correction (difference corrected-uncorrected jet energy for jets of (corrected) Pt > 10 GeV)
233 // o momentum sum of "unclustered energy" (jets of (corrected) Pt < 10 GeV)
234 // o momentum sum of "offset energy" (sum of energy attributed to pile-up/underlying event)
235 // to the event
236  evt.put(type1Correction, "type1");
237  for ( typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry = type2Binning_.begin();
238  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
239  evt.put(std::auto_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binUnclEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("type2"));
240  evt.put(std::auto_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binOffsetEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("offset"));
241  }
242  }
edm::EDGetTokenT< reco::JetCorrector > jetCorrResToken_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::vector< Jet > JetCollection
Definition: Jet.h:52
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
StringCutObjectSelector< reco::Candidate > * skipMuonSelection_
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
bool isRealData() const
Definition: EventBase.h:63
std::vector< type2BinningEntryType * > type2Binning_
edm::EDGetTokenT< std::vector< T > > token_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
vector< PseudoJet > jets
T get() const
get a component
const int mu
Definition: Constants.h:22
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
T const * product() const
Definition: Handle.h:81
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
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
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 >
edm::InputTag PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabel_
private
template<typename T , typename Textractor >
edm::InputTag PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabelRes_
private
template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> PFJetMETcorrInputProducerT< T, Textractor >::jetCorrResToken_
private
template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> PFJetMETcorrInputProducerT< T, Textractor >::jetCorrToken_
private
template<typename T , typename Textractor >
std::string PFJetMETcorrInputProducerT< T, Textractor >::moduleLabel_
private
template<typename T , typename Textractor >
edm::InputTag PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrLabel_
private
template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> PFJetMETcorrInputProducerT< T, Textractor >::offsetCorrToken_
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::Candidate>* PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_
private
template<typename T , typename Textractor >
edm::EDGetTokenT<std::vector<T> > PFJetMETcorrInputProducerT< T, Textractor >::token_
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