CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static 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<>

Classes

struct  type2BinningEntryType
 

Public Member Functions

 PFJetMETcorrInputProducerT (const edm::ParameterSet &cfg)
 
 ~PFJetMETcorrInputProducerT () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

double jetCorrEtaMax_
 
Textractor jetCorrExtractor_
 
edm::InputTag jetCorrLabel_
 
edm::InputTag jetCorrLabelRes_
 
edm::EDGetTokenT< reco::JetCorrectorjetCorrResToken_
 
edm::EDGetTokenT< reco::JetCorrectorjetCorrToken_
 
std::string moduleLabel_
 
edm::InputTag offsetCorrLabel_
 
edm::EDGetTokenT< reco::JetCorrectoroffsetCorrToken_
 
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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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 76 of file PFJetMETcorrInputProducerT.h.

Constructor & Destructor Documentation

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

Definition at line 80 of file PFJetMETcorrInputProducerT.h.

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

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

Definition at line 130 of file PFJetMETcorrInputProducerT.h.

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

Member Function Documentation

template<typename T , typename Textractor >
static void PFJetMETcorrInputProducerT< T, Textractor >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 140 of file PFJetMETcorrInputProducerT.h.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), defaultModuleLabel(), and AlCaHLTBitMon_QueryRunRegistry::string.

140  {
142  desc.add<edm::InputTag>("src",edm::InputTag("ak4PFJetsCHS"));
143  desc.add<edm::InputTag>("offsetCorrLabel",edm::InputTag("ak4PFCHSL1FastjetCorrector"));
144  desc.add<edm::InputTag>("jetCorrLabel",edm::InputTag("ak4PFCHSL1FastL2L3Corrector"));
145  desc.add<edm::InputTag>("jetCorrLabelRes",edm::InputTag("ak4PFCHSL1FastL2L3ResidualCorrector"));
146  desc.add<double>("jetCorrEtaMax",9.9);
147  desc.add<double>("type1JetPtThreshold",15);
148  desc.add<bool>("skipEM",true);
149  desc.add<double>("skipEMfractionThreshold",0.90);
150  desc.add<bool>("skipMuons",true);
151  desc.add<std::string>("skipMuonSelection","isGlobalMuon | isStandAloneMuon");
153  }
std::string defaultModuleLabel()
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename T , typename Textractor >
void PFJetMETcorrInputProducerT< T, Textractor >::produce ( edm::Event evt,
const edm::EventSetup es 
)
inlineoverrideprivate

Definition at line 158 of file PFJetMETcorrInputProducerT.h.

References egammaForCoreTracking_cff::cands, edm::Ref< C, T, F >::get(), edm::Event::getByToken(), edm::Ref< C, T, F >::isNonnull(), edm::EventBase::isRealData(), metsig::jet, fwrapper::jets, eostools::move(), RPCpg::mu, reco::PFCandidate::muonRef(), pfDeepBoostedJetPreprocessParams_cfi::pfcand, edm::Handle< T >::product(), and edm::Event::put().

159  {
160 
161  std::unique_ptr<CorrMETData> type1Correction(new CorrMETData());
162  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
163  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
164  (*type2BinningEntry)->binUnclEnergySum_ = CorrMETData();
165  (*type2BinningEntry)->binOffsetEnergySum_ = CorrMETData();
166  }
167 
169  //automatic switch for residual corrections
170  if(evt.isRealData() ) {
172  evt.getByToken(jetCorrResToken_, jetCorr);
173  } else {
174  evt.getByToken(jetCorrToken_, jetCorr);
175  }
176 
177  typedef std::vector<T> JetCollection;
179  evt.getByToken(token_, jets);
180 
181  int numJets = jets->size();
182  for ( int jetIndex = 0; jetIndex < numJets; ++jetIndex ) {
183  const T& jet = jets->at(jetIndex);
184 
186  checkInputType(jet);
187 
188  double emEnergyFraction = jet.chargedEmEnergyFraction() + jet.neutralEmEnergyFraction();
189  if ( skipEM_ && emEnergyFraction > skipEMfractionThreshold_ ) continue;
190 
191  const static PFJetMETcorrInputProducer_namespace::RawJetExtractorT<T> rawJetExtractor {};
192  reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(jet);
193 
194  if ( skipMuons_ ) {
195  const std::vector<reco::CandidatePtr> & cands = jet.daughterPtrVector();
196  for ( std::vector<reco::CandidatePtr>::const_iterator cand = cands.begin();
197  cand != cands.end(); ++cand ) {
198  const reco::PFCandidate *pfcand = dynamic_cast<const reco::PFCandidate *>(cand->get());
199  const reco::Candidate *mu = (pfcand != nullptr ? ( pfcand->muonRef().isNonnull() ? pfcand->muonRef().get() : nullptr) : cand->get());
200  if ( mu != nullptr && (*skipMuonSelection_)(*mu) ) {
201  reco::Candidate::LorentzVector muonP4 = (*cand)->p4();
202  rawJetP4 -= muonP4;
203  }
204  }
205  }
206 
208  if ( checkInputType.isPatJet(jet) )
209  corrJetP4 = jetCorrExtractor_(jet, jetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
210  else
211  corrJetP4 = jetCorrExtractor_(jet, jetCorr.product(), jetCorrEtaMax_, &rawJetP4);
212 
213  if ( corrJetP4.pt() > type1JetPtThreshold_ ) {
214 
215  reco::Candidate::LorentzVector rawJetP4offsetCorr = rawJetP4;
216  if ( !offsetCorrLabel_.label().empty() ) {
218  evt.getByToken(offsetCorrToken_, offsetCorr);
219  if ( checkInputType.isPatJet(jet) )
220  rawJetP4offsetCorr = jetCorrExtractor_(jet, offsetCorrLabel_.label(), jetCorrEtaMax_, &rawJetP4);
221  else
222  rawJetP4offsetCorr = jetCorrExtractor_(jet, offsetCorr.product(), jetCorrEtaMax_, &rawJetP4);
223 
224  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
225  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
226  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
227  (*type2BinningEntry)->binOffsetEnergySum_.mex += (rawJetP4.px() - rawJetP4offsetCorr.px());
228  (*type2BinningEntry)->binOffsetEnergySum_.mey += (rawJetP4.py() - rawJetP4offsetCorr.py());
229  (*type2BinningEntry)->binOffsetEnergySum_.sumet += (rawJetP4.Et() - rawJetP4offsetCorr.Et());
230  }
231  }
232  }
233 
234 //--- MET balances momentum of reconstructed particles,
235 // hence correction to jets and corresponding Type 1 MET correction are of opposite sign
236  type1Correction->mex -= (corrJetP4.px() - rawJetP4offsetCorr.px());
237  type1Correction->mey -= (corrJetP4.py() - rawJetP4offsetCorr.py());
238  type1Correction->sumet += (corrJetP4.Et() - rawJetP4offsetCorr.Et());
239  } else {
240  for ( typename std::vector<type2BinningEntryType*>::iterator type2BinningEntry = type2Binning_.begin();
241  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
242  if ( !(*type2BinningEntry)->binSelection_ || (*(*type2BinningEntry)->binSelection_)(corrJetP4) ) {
243  (*type2BinningEntry)->binUnclEnergySum_.mex += rawJetP4.px();
244  (*type2BinningEntry)->binUnclEnergySum_.mey += rawJetP4.py();
245  (*type2BinningEntry)->binUnclEnergySum_.sumet += rawJetP4.Et();
246  }
247  }
248  }
249  }
250 
251 //--- add
252 // o Type 1 MET correction (difference corrected-uncorrected jet energy for jets of (corrected) Pt > 10 GeV)
253 // o momentum sum of "unclustered energy" (jets of (corrected) Pt < 10 GeV)
254 // o momentum sum of "offset energy" (sum of energy attributed to pile-up/underlying event)
255 // to the event
256  evt.put(std::move(type1Correction), "type1");
257  for ( typename std::vector<type2BinningEntryType*>::const_iterator type2BinningEntry = type2Binning_.begin();
258  type2BinningEntry != type2Binning_.end(); ++type2BinningEntry ) {
259  evt.put(std::unique_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binUnclEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("type2"));
260  evt.put(std::unique_ptr<CorrMETData>(new CorrMETData((*type2BinningEntry)->binOffsetEnergySum_)), (*type2BinningEntry)->getInstanceLabel_full("offset"));
261  }
262  }
edm::EDGetTokenT< reco::JetCorrector > jetCorrResToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
std::vector< Jet > JetCollection
Definition: Jet.h:55
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< reco::JetCorrector > jetCorrToken_
StringCutObjectSelector< reco::Candidate > * skipMuonSelection_
edm::EDGetTokenT< reco::JetCorrector > offsetCorrToken_
bool isRealData() const
Definition: EventBase.h:62
std::vector< type2BinningEntryType * > type2Binning_
edm::EDGetTokenT< std::vector< T > > token_
vector< PseudoJet > jets
const int mu
Definition: Constants.h:22
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
T const * product() const
Definition: Handle.h:74
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:40
long double T
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 276 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 274 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 270 of file PFJetMETcorrInputProducerT.h.

template<typename T , typename Textractor >
edm::InputTag PFJetMETcorrInputProducerT< T, Textractor >::jetCorrLabelRes_
private

Definition at line 271 of file PFJetMETcorrInputProducerT.h.

template<typename T , typename Textractor >
edm::EDGetTokenT<reco::JetCorrector> PFJetMETcorrInputProducerT< T, Textractor >::jetCorrResToken_
private

Definition at line 273 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 272 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 268 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 269 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 282 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 284 of file PFJetMETcorrInputProducerT.h.

template<typename T , typename Textractor >
bool PFJetMETcorrInputProducerT< T, Textractor >::skipMuons_
private

Definition at line 286 of file PFJetMETcorrInputProducerT.h.

template<typename T , typename Textractor >
StringCutObjectSelector<reco::Candidate>* PFJetMETcorrInputProducerT< T, Textractor >::skipMuonSelection_
private

Definition at line 288 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 266 of file PFJetMETcorrInputProducerT.h.

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

Definition at line 278 of file PFJetMETcorrInputProducerT.h.

template<typename T , typename Textractor >
std::vector<type2BinningEntryType*> PFJetMETcorrInputProducerT< T, Textractor >::type2Binning_
private

Definition at line 316 of file PFJetMETcorrInputProducerT.h.