CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
reco::PFMETProducerMVA Class Reference

#include <PFMETProducerMVA.h>

Inheritance diagram for reco::PFMETProducerMVA:
edm::stream::EDProducer<>

Public Member Functions

 PFMETProducerMVA (const edm::ParameterSet &)
 
 ~PFMETProducerMVA () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef std::vector< edm::InputTagvInputTag
 

Private Member Functions

double chargedEnFrac (const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex)
 
double chargedFracInCone (const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
 
std::vector< reco::PUSubMETCandInfocomputeJetInfo (const reco::PFJetCollection &, const edm::Handle< reco::PFJetCollection > &, const edm::ValueMap< float > &, const reco::VertexCollection &, const reco::Vertex *, const reco::JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< reco::PUSubMETCandInfo > &iLeptons, std::vector< reco::PUSubMETCandInfo > &iCands)
 
std::vector< reco::PUSubMETCandInfocomputeLeptonInfo (const std::vector< edm::EDGetTokenT< reco::CandidateView > > &srcLeptons_, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, int &lId, bool &lHasPhotons, edm::Event &iEvent)
 
std::vector< reco::PUSubMETCandInfocomputePFCandidateInfo (const reco::CandidateView &, const reco::Vertex *)
 
std::vector< reco::Vertex::PointcomputeVertexInfo (const reco::VertexCollection &)
 
bool istau (const reco::Candidate *iCand)
 
bool passPFLooseId (const reco::PFJet *iJet)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double globalThreshold_
 
METAlgo metAlgo_
 
double minCorrJetPt_
 
int minNumLeptons_
 
edm::EDGetTokenT< reco::JetCorrectormJetCorrector_
 
PFMETAlgorithmMVA mvaMEtAlgo_
 
bool mvaMEtAlgo_isInitialized_
 
PFSpecificAlgo pfMEtSpecificAlgo_
 
edm::EDGetTokenT< reco::PFJetCollectionsrcCorrJets_
 
edm::EDGetTokenT< edm::ValueMap< float > > srcJetIds_
 
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
 
edm::EDGetTokenT< reco::PFJetCollectionsrcUncorrJets_
 
edm::EDGetTokenT< reco::VertexCollectionsrcVertices_
 
bool useType1_
 
int verbosity_
 

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

Definition at line 43 of file PFMETProducerMVA.h.

Member Typedef Documentation

◆ vInputTag

typedef std::vector<edm::InputTag> reco::PFMETProducerMVA::vInputTag
private

Definition at line 92 of file PFMETProducerMVA.h.

Constructor & Destructor Documentation

◆ PFMETProducerMVA()

PFMETProducerMVA::PFMETProducerMVA ( const edm::ParameterSet cfg)

Definition at line 9 of file PFMETProducerMVA.cc.

10  srcCorrJets_ = consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcCorrJets"));
11  srcUncorrJets_ = consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcUncorrJets"));
12  srcJetIds_ = consumes<edm::ValueMap<float> >(cfg.getParameter<edm::InputTag>("srcMVAPileupJetId"));
13  srcPFCandidatesView_ = consumes<reco::CandidateView>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
14  srcVertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("srcVertices"));
15  vInputTag srcLeptonsTags = cfg.getParameter<vInputTag>("srcLeptons");
16  for (vInputTag::const_iterator it = srcLeptonsTags.begin(); it != srcLeptonsTags.end(); it++) {
17  srcLeptons_.push_back(consumes<reco::CandidateView>(*it));
18  }
19  mJetCorrector_ = consumes<reco::JetCorrector>(cfg.getParameter<edm::InputTag>("corrector"));
20  minNumLeptons_ = cfg.getParameter<int>("minNumLeptons");
21 
22  globalThreshold_ = cfg.getParameter<double>("globalThreshold");
23 
24  minCorrJetPt_ = cfg.getParameter<double>("minCorrJetPt");
25  useType1_ = cfg.getParameter<bool>("useType1");
26 
27  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
28 
29  produces<reco::PFMETCollection>();
30 }

References looper::cfg, globalThreshold_, minCorrJetPt_, minNumLeptons_, mJetCorrector_, srcCorrJets_, srcJetIds_, srcLeptons_, srcPFCandidatesView_, srcUncorrJets_, srcVertices_, useType1_, and verbosity_.

◆ ~PFMETProducerMVA()

PFMETProducerMVA::~PFMETProducerMVA ( )
override

Definition at line 32 of file PFMETProducerMVA.cc.

32 {}

Member Function Documentation

◆ chargedEnFrac()

double PFMETProducerMVA::chargedEnFrac ( const reco::Candidate iCand,
const reco::CandidateView pfCandidates,
const reco::Vertex hardScatterVertex 
)
private

Definition at line 333 of file PFMETProducerMVA.cc.

335  {
336  if (iCand->isMuon()) {
337  return 1;
338  }
339  if (iCand->isElectron()) {
340  return 1.;
341  }
342  if (iCand->isPhoton()) {
343  return chargedFracInCone(iCand, pfCandidates, hardScatterVertex);
344  }
345  double lPtTot = 0;
346  double lPtCharged = 0;
347  const reco::PFTau* lPFTau = nullptr;
348  lPFTau = dynamic_cast<const reco::PFTau*>(iCand);
349  if (lPFTau != nullptr) {
350  for (UInt_t i0 = 0; i0 < lPFTau->signalCands().size(); i0++) {
351  lPtTot += (lPFTau->signalCands())[i0]->pt();
352  if ((lPFTau->signalCands())[i0]->charge() == 0)
353  continue;
354  lPtCharged += (lPFTau->signalCands())[i0]->pt();
355  }
356  } else {
357  const pat::Tau* lPatPFTau = nullptr;
358  lPatPFTau = dynamic_cast<const pat::Tau*>(iCand);
359  if (lPatPFTau != nullptr) {
360  for (UInt_t i0 = 0; i0 < lPatPFTau->signalCands().size(); i0++) {
361  lPtTot += (lPatPFTau->signalCands())[i0]->pt();
362  if ((lPatPFTau->signalCands())[i0]->charge() == 0)
363  continue;
364  lPtCharged += (lPatPFTau->signalCands())[i0]->pt();
365  }
366  }
367  }
368  if (lPtTot == 0)
369  lPtTot = 1.;
370  return lPtCharged / lPtTot;
371 }

References ALCARECOTkAlJpsiMuMu_cff::charge, chargedFracInCone(), reco::Candidate::isElectron(), reco::Candidate::isMuon(), reco::Candidate::isPhoton(), zmumugammaAnalyzer_cfi::pfCandidates, DiDispStaMuonMonitor_cfi::pt, reco::PFTau::signalCands(), pat::Tau::signalCands(), and edm::PtrVectorBase::size().

Referenced by computeLeptonInfo().

◆ chargedFracInCone()

double PFMETProducerMVA::chargedFracInCone ( const reco::Candidate iCand,
const reco::CandidateView pfCandidates,
const reco::Vertex hardScatterVertex,
double  iDRMax = 0.2 
)
private

Definition at line 400 of file PFMETProducerMVA.cc.

403  {
404  double iDR2Max = iDRMax * iDRMax;
405  reco::Candidate::LorentzVector lVis(0, 0, 0, 0);
406  for (reco::CandidateView::const_iterator pfCandidate = pfCandidates.begin(); pfCandidate != pfCandidates.end();
407  ++pfCandidate) {
408  if (deltaR2(iCand->p4(), pfCandidate->p4()) > iDR2Max)
409  continue;
410  double dZ = -999.; // PH: If no vertex is reconstructed in the event
411  // or PFCandidate has no track, set dZ to -999
412  if (hardScatterVertex) {
413  const reco::PFCandidate* pfc = dynamic_cast<const reco::PFCandidate*>((&(*pfCandidate)));
414  if (pfc != nullptr) { //PF candidate for RECO and PAT levels
415  if (pfc->trackRef().isNonnull())
416  dZ = std::abs(pfc->trackRef()->dz(hardScatterVertex->position()));
417  else if (pfc->gsfTrackRef().isNonnull())
418  dZ = std::abs(pfc->gsfTrackRef()->dz(hardScatterVertex->position()));
419  } else { //if not, then packedCandidate for miniAOD level
420  const pat::PackedCandidate* pfc = dynamic_cast<const pat::PackedCandidate*>(&(*pfCandidate));
421  dZ = std::abs(pfc->dz(hardScatterVertex->position()));
422  }
423  }
424  if (std::abs(dZ) > 0.1)
425  continue;
426  lVis += pfCandidate->p4();
427  }
428  return lVis.pt() / iCand->pt();
429 }

References funct::abs(), reco::deltaR2(), pat::PackedCandidate::dz(), reco::PFCandidate::gsfTrackRef(), edm::Ref< C, T, F >::isNonnull(), reco::Candidate::p4(), zmumugammaAnalyzer_cfi::pfCandidates, reco::Vertex::position(), reco::Candidate::pt(), and reco::PFCandidate::trackRef().

Referenced by chargedEnFrac().

◆ computeJetInfo()

std::vector< reco::PUSubMETCandInfo > PFMETProducerMVA::computeJetInfo ( const reco::PFJetCollection uncorrJets,
const edm::Handle< reco::PFJetCollection > &  corrJets,
const edm::ValueMap< float > &  jetIds,
const reco::VertexCollection vertices,
const reco::Vertex hardScatterVertex,
const reco::JetCorrector iCorr,
edm::Event iEvent,
const edm::EventSetup iSetup,
std::vector< reco::PUSubMETCandInfo > &  iLeptons,
std::vector< reco::PUSubMETCandInfo > &  iCands 
)
private

Definition at line 204 of file PFMETProducerMVA.cc.

213  {
214  std::vector<reco::PUSubMETCandInfo> retVal;
215  for (reco::PFJetCollection::const_iterator uncorrJet = uncorrJets.begin(); uncorrJet != uncorrJets.end();
216  ++uncorrJet) {
217  // for ( reco::PFJetCollection::const_iterator corrJet = corrJets.begin();
218  // corrJet != corrJets.end(); ++corrJet ) {
219  auto corrJet = corrJets->begin();
220  for (size_t cjIdx = 0; cjIdx < corrJets->size(); ++cjIdx, ++corrJet) {
221  reco::PFJetRef corrJetRef(corrJets, cjIdx);
222 
223  // match corrected and uncorrected jets
224  if (uncorrJet->jetArea() != corrJet->jetArea())
225  continue;
226  if (deltaR2(corrJet->p4(), uncorrJet->p4()) > dR2Min)
227  continue;
228 
229  // check that jet passes loose PFJet id.
230  if (!passPFLooseId(&(*uncorrJet)))
231  continue;
232 
233  // compute jet energy correction factor
234  // (= ratio of corrected/uncorrected jet Pt)
235  //double jetEnCorrFactor = corrJet->pt()/uncorrJet->pt();
236  reco::PUSubMETCandInfo jetInfo;
237 
238  // PH: apply jet energy corrections for all Jets ignoring recommendations
239  jetInfo.setP4(corrJet->p4());
240  double lType1Corr = 0;
241  if (useType1_) { //Compute the type 1 correction ===> This code is crap
242  double pCorr = iCorrector.correction(*uncorrJet);
243  lType1Corr = std::abs(corrJet->pt() - pCorr * uncorrJet->pt());
244  TLorentzVector pVec;
245  pVec.SetPtEtaPhiM(lType1Corr, 0, corrJet->phi(), 0);
247  pType1Corr.SetCoordinates(pVec.Px(), pVec.Py(), pVec.Pz(), pVec.E());
248  //Filter to leptons
249  bool pOnLepton = false;
250  for (unsigned int i0 = 0; i0 < iLeptons.size(); i0++) {
251  if (deltaR2(iLeptons[i0].p4(), corrJet->p4()) < dR2Max) {
252  pOnLepton = true;
253  break;
254  }
255  }
256  //Add it to PF Collection
257  if (corrJet->pt() > 10 && !pOnLepton) {
258  reco::PUSubMETCandInfo pfCandidateInfo;
259  pfCandidateInfo.setP4(pType1Corr);
260  pfCandidateInfo.setDZ(-999);
261  iCands.push_back(pfCandidateInfo);
262  }
263  //Scale
264  lType1Corr = (pCorr * uncorrJet->pt() - uncorrJet->pt());
265  lType1Corr /= corrJet->pt();
266  }
267 
268  // check that jet Pt used to compute MVA based jet id. is above threshold
269  if (!(jetInfo.p4().pt() > minCorrJetPt_))
270  continue;
271 
272  jetInfo.setMvaVal(jetIds[corrJetRef]);
273  float chEnF = (uncorrJet->chargedEmEnergy() + uncorrJet->chargedHadronEnergy() + uncorrJet->chargedMuEnergy()) /
274  uncorrJet->energy();
275  if (useType1_)
276  chEnF += lType1Corr * (1 - jetInfo.chargedEnFrac());
277  jetInfo.setChargedEnFrac(chEnF);
278  retVal.push_back(jetInfo);
279  break;
280  }
281  }
282 
283  //order jets per pt
284  std::sort(retVal.begin(), retVal.end());
285 
286  return retVal;
287 }

References funct::abs(), reco::PUSubMETCandInfo::chargedEnFrac(), reco::JetCorrector::correction(), reco::deltaR2(), dR2Max, dR2Min, minCorrJetPt_, reco::PUSubMETCandInfo::p4(), p4, passPFLooseId(), reco::PUSubMETCandInfo::setChargedEnFrac(), reco::PUSubMETCandInfo::setDZ(), reco::PUSubMETCandInfo::setMvaVal(), reco::PUSubMETCandInfo::setP4(), and useType1_.

Referenced by produce().

◆ computeLeptonInfo()

std::vector< reco::PUSubMETCandInfo > PFMETProducerMVA::computeLeptonInfo ( const std::vector< edm::EDGetTokenT< reco::CandidateView > > &  srcLeptons_,
const reco::CandidateView pfCandidates,
const reco::Vertex hardScatterVertex,
int &  lId,
bool &  lHasPhotons,
edm::Event iEvent 
)
private

Definition at line 138 of file PFMETProducerMVA.cc.

144  {
145  std::vector<reco::PUSubMETCandInfo> leptonInfo;
146 
147  for (std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator srcLeptons_i = srcLeptons_.begin();
148  srcLeptons_i != srcLeptons_.end();
149  ++srcLeptons_i) {
151  evt.getByToken(*srcLeptons_i, leptons);
152  for (reco::CandidateView::const_iterator lepton1 = leptons->begin(); lepton1 != leptons->end(); ++lepton1) {
153  bool pMatch = false;
154  for (std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator srcLeptons_j = srcLeptons_.begin();
155  srcLeptons_j != srcLeptons_.end();
156  ++srcLeptons_j) {
158  evt.getByToken(*srcLeptons_j, leptons2);
159  for (reco::CandidateView::const_iterator lepton2 = leptons2->begin(); lepton2 != leptons2->end(); ++lepton2) {
160  if (&(*lepton1) == &(*lepton2)) {
161  continue;
162  }
163  if (deltaR2(lepton1->p4(), lepton2->p4()) < dR2Max) {
164  pMatch = true;
165  }
166  if (pMatch && !istau(&(*lepton1)) && istau(&(*lepton2))) {
167  pMatch = false;
168  }
169  if (pMatch && ((istau(&(*lepton1)) && istau(&(*lepton2))) || (!istau(&(*lepton1)) && !istau(&(*lepton2)))) &&
170  lepton1->pt() > lepton2->pt()) {
171  pMatch = false;
172  }
173  if (pMatch && lepton1->pt() == lepton2->pt()) {
174  pMatch = false;
175  for (unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
176  if (std::abs(lepton1->pt() - leptonInfo[i0].p4().pt()) < dPtMatch) {
177  pMatch = true;
178  break;
179  }
180  }
181  }
182  if (pMatch)
183  break;
184  }
185  if (pMatch)
186  break;
187  }
188  if (pMatch)
189  continue;
190  reco::PUSubMETCandInfo pLeptonInfo;
191  pLeptonInfo.setP4(lepton1->p4());
192  pLeptonInfo.setChargedEnFrac(chargedEnFrac(&(*lepton1), pfCandidates_view, hardScatterVertex));
193  leptonInfo.push_back(pLeptonInfo);
194  if (lepton1->isPhoton()) {
195  lHasPhotons = true;
196  }
197  }
198  lId++;
199  }
200 
201  return leptonInfo;
202 }

References funct::abs(), edm::View< T >::begin(), chargedEnFrac(), reco::deltaR2(), dPtMatch, dR2Max, edm::View< T >::end(), edm::Event::getByToken(), istau(), AK4CaloJetsMCFlavour_cff::leptonInfo, HLT_FULL_cff::leptons, reco::PUSubMETCandInfo::setChargedEnFrac(), reco::PUSubMETCandInfo::setP4(), srcLeptons_, and trackerHitRTTI::vector.

Referenced by produce().

◆ computePFCandidateInfo()

std::vector< reco::PUSubMETCandInfo > PFMETProducerMVA::computePFCandidateInfo ( const reco::CandidateView pfCandidates,
const reco::Vertex hardScatterVertex 
)
private

Definition at line 289 of file PFMETProducerMVA.cc.

290  {
291  std::vector<reco::PUSubMETCandInfo> retVal;
292  for (reco::CandidateView::const_iterator pfCandidate = pfCandidates.begin(); pfCandidate != pfCandidates.end();
293  ++pfCandidate) {
294  double dZ = -999.; // PH: If no vertex is reconstructed in the event
295  // or PFCandidate has no track, set dZ to -999
296  if (hardScatterVertex) {
297  const reco::PFCandidate* pfc = dynamic_cast<const reco::PFCandidate*>(&(*pfCandidate));
298  if (pfc != nullptr) { //PF candidate for RECO and PAT levels
299  if (pfc->trackRef().isNonnull())
300  dZ = std::abs(pfc->trackRef()->dz(hardScatterVertex->position()));
301  else if (pfc->gsfTrackRef().isNonnull())
302  dZ = std::abs(pfc->gsfTrackRef()->dz(hardScatterVertex->position()));
303  } else { //if not, then packedCandidate for miniAOD level
304  const pat::PackedCandidate* pfc = dynamic_cast<const pat::PackedCandidate*>(&(*pfCandidate));
305  dZ = std::abs(pfc->dz(hardScatterVertex->position()));
306  //exact dz=zero corresponds to the -999 case for pfcandidate
307  if (dZ == 0) {
308  dZ = -999;
309  }
310  }
311  }
312  reco::PUSubMETCandInfo pfCandidateInfo;
313  pfCandidateInfo.setP4(pfCandidate->p4());
314  pfCandidateInfo.setDZ(dZ);
315  retVal.push_back(pfCandidateInfo);
316  }
317  return retVal;
318 }

References funct::abs(), pat::PackedCandidate::dz(), reco::PFCandidate::gsfTrackRef(), edm::Ref< C, T, F >::isNonnull(), zmumugammaAnalyzer_cfi::pfCandidates, reco::Vertex::position(), reco::PUSubMETCandInfo::setDZ(), reco::PUSubMETCandInfo::setP4(), and reco::PFCandidate::trackRef().

Referenced by produce().

◆ computeVertexInfo()

std::vector< reco::Vertex::Point > PFMETProducerMVA::computeVertexInfo ( const reco::VertexCollection vertices)
private

Definition at line 320 of file PFMETProducerMVA.cc.

320  {
321  std::vector<reco::Vertex::Point> retVal;
322  for (reco::VertexCollection::const_iterator vertex = vertices.begin(); vertex != vertices.end(); ++vertex) {
323  if (std::abs(vertex->z()) > 24.)
324  continue;
325  if (vertex->ndof() < 4.)
326  continue;
327  if (vertex->position().Rho() > 2.)
328  continue;
329  retVal.push_back(vertex->position());
330  }
331  return retVal;
332 }

References funct::abs(), bphysicsOniaDQM_cfi::vertex, and pwdgSkimBPark_cfi::vertices.

Referenced by produce().

◆ istau()

bool PFMETProducerMVA::istau ( const reco::Candidate iCand)
private

Definition at line 373 of file PFMETProducerMVA.cc.

373  {
374  if (iCand->isMuon())
375  return false;
376  if (iCand->isElectron())
377  return false;
378  if (iCand->isPhoton())
379  return false;
380  return true;
381 }

References reco::Candidate::isElectron(), reco::Candidate::isMuon(), and reco::Candidate::isPhoton().

Referenced by computeLeptonInfo().

◆ passPFLooseId()

bool PFMETProducerMVA::passPFLooseId ( const reco::PFJet iJet)
private

Definition at line 382 of file PFMETProducerMVA.cc.

382  {
383  if (iJet->energy() == 0)
384  return false;
385  if (iJet->neutralHadronEnergy() / iJet->energy() > 0.99)
386  return false;
387  if (iJet->neutralEmEnergy() / iJet->energy() > 0.99)
388  return false;
389  if (iJet->nConstituents() < 2)
390  return false;
391  if (iJet->chargedHadronEnergy() / iJet->energy() <= 0 && std::abs(iJet->eta()) < 2.4)
392  return false;
393  if (iJet->chargedEmEnergy() / iJet->energy() > 0.99 && std::abs(iJet->eta()) < 2.4)
394  return false;
395  if (iJet->chargedMultiplicity() < 1 && std::abs(iJet->eta()) < 2.4)
396  return false;
397  return true;
398 }

References funct::abs(), reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::Jet::nConstituents(), reco::PFJet::neutralEmEnergy(), and reco::PFJet::neutralHadronEnergy().

Referenced by computeJetInfo().

◆ produce()

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

Definition at line 34 of file PFMETProducerMVA.cc.

34  {
35  // CV: check if the event is to be skipped
36  if (minNumLeptons_ > 0) {
37  int numLeptons = 0;
38  for (std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator srcLeptons_i = srcLeptons_.begin();
39  srcLeptons_i != srcLeptons_.end();
40  ++srcLeptons_i) {
42  evt.getByToken(*srcLeptons_i, leptons);
43  numLeptons += leptons->size();
44  }
45  if (!(numLeptons >= minNumLeptons_)) {
46  LogDebug("produce") << "<PFMETProducerMVA::produce>:" << std::endl
47  << "Run: " << evt.id().run() << ", LS: " << evt.luminosityBlock()
48  << ", Event: " << evt.id().event() << std::endl
49  << " numLeptons = " << numLeptons << ", minNumLeptons = " << minNumLeptons_
50  << " --> skipping !!" << std::endl;
51 
52  reco::PFMET pfMEt;
53  auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
54  pfMEtCollection->push_back(pfMEt);
55  evt.put(std::move(pfMEtCollection));
56  return;
57  }
58  }
59 
60  //get jet IDs
62  evt.getByToken(srcJetIds_, jetIds);
63 
64  // get jets (corrected and uncorrected)
66  evt.getByToken(srcCorrJets_, corrJets);
67 
69  evt.getByToken(srcUncorrJets_, uncorrJets);
70 
72  if (useType1_) {
74  }
75 
76  edm::Handle<reco::CandidateView> pfCandidates_view;
77  evt.getByToken(srcPFCandidatesView_, pfCandidates_view);
78 
79  // get vertices
82  // take vertex with highest sum(trackPt) as the vertex of the "hard scatter" interaction
83  // (= first entry in vertex collection)
84  const reco::Vertex* hardScatterVertex = (!vertices->empty()) ? &(vertices->front()) : nullptr;
85 
86  // get leptons
87  // (excluded from sum over PFCandidates when computing hadronic recoil)
88  int lId = 0;
89  bool lHasPhotons = false;
90  std::vector<reco::PUSubMETCandInfo> leptonInfo =
91  computeLeptonInfo(srcLeptons_, *pfCandidates_view, hardScatterVertex, lId, lHasPhotons, evt);
92 
93  // initialize MVA MET algorithm
94  // (this will load the BDTs, stored as GBRForrest objects;
95  // either in input ROOT files or in SQL-lite files/the Conditions Database)
99  }
100 
101  // reconstruct "standard" particle-flow missing Et
102  CommonMETData pfMEt_data = metAlgo_.run((*pfCandidates_view), globalThreshold_);
103  SpecificPFMETData specificPfMET = pfMEtSpecificAlgo_.run((*pfCandidates_view));
104  const reco::Candidate::LorentzVector p4(pfMEt_data.mex, pfMEt_data.mey, 0.0, pfMEt_data.met);
105  const reco::Candidate::Point vtx(0.0, 0.0, 0.0);
106  reco::PFMET pfMEt(specificPfMET, pfMEt_data.sumet, p4, vtx);
107  reco::Candidate::LorentzVector pfMEtP4_original = pfMEt.p4();
108 
109  // compute objects specific to MVA based MET reconstruction
110  std::vector<reco::PUSubMETCandInfo> pfCandidateInfo = computePFCandidateInfo(*pfCandidates_view, hardScatterVertex);
111  std::vector<reco::PUSubMETCandInfo> jetInfo = computeJetInfo(
112  *uncorrJets, corrJets, *jetIds, *vertices, hardScatterVertex, *corrector, evt, es, leptonInfo, pfCandidateInfo);
113  std::vector<reco::Vertex::Point> vertexInfo = computeVertexInfo(*vertices);
114  // compute MVA based MET and estimate of its uncertainty
115  mvaMEtAlgo_.setInput(leptonInfo, jetInfo, pfCandidateInfo, vertexInfo);
116  mvaMEtAlgo_.setHasPhotons(lHasPhotons);
118  pfMEt.setP4(mvaMEtAlgo_.getMEt());
120 
121  LogDebug("produce") << "Run: " << evt.id().run() << ", LS: " << evt.luminosityBlock()
122  << ", Event: " << evt.id().event() << std::endl
123  << " PFMET: Pt = " << pfMEtP4_original.pt() << ", phi = " << pfMEtP4_original.phi() << " "
124  << "(Px = " << pfMEtP4_original.px() << ", Py = " << pfMEtP4_original.py() << ")" << std::endl
125  << " MVA MET: Pt = " << pfMEt.pt() << " phi = " << pfMEt.phi() << " (Px = " << pfMEt.px()
126  << ", Py = " << pfMEt.py() << ")" << std::endl
127  << " Cov:" << std::endl
128  << (mvaMEtAlgo_.getMEtCov())(0, 0) << " " << (mvaMEtAlgo_.getMEtCov())(0, 1) << std::endl
129  << (mvaMEtAlgo_.getMEtCov())(1, 0) << " " << (mvaMEtAlgo_.getMEtCov())(1, 1) << std::endl
130  << std::endl;
131 
132  // add PFMET object to the event
133  auto pfMEtCollection = std::make_unique<reco::PFMETCollection>();
134  pfMEtCollection->push_back(pfMEt);
135  evt.put(std::move(pfMEtCollection));
136 }

References computeJetInfo(), computeLeptonInfo(), computePFCandidateInfo(), computeVertexInfo(), pfClustersFromHGC3DClusters_cfi::corrector, PFMETAlgorithmMVA::evaluateMVA(), edm::EventID::event(), edm::Event::getByToken(), PFMETAlgorithmMVA::getMEt(), PFMETAlgorithmMVA::getMEtCov(), globalThreshold_, edm::EventBase::id(), PFMETAlgorithmMVA::initialize(), AK4CaloJetsMCFlavour_cff::leptonInfo, HLT_FULL_cff::leptons, LogDebug, edm::EventBase::luminosityBlock(), CommonMETData::met, metAlgo_, CommonMETData::mex, CommonMETData::mey, minNumLeptons_, mJetCorrector_, eostools::move(), mvaMEtAlgo_, mvaMEtAlgo_isInitialized_, HLT_FULL_cff::numLeptons, p4, reco::LeafCandidate::p4(), pfMEtSpecificAlgo_, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), PFSpecificAlgo::run(), METAlgo::run(), edm::EventID::run(), PFMETAlgorithmMVA::setHasPhotons(), PFMETAlgorithmMVA::setInput(), reco::LeafCandidate::setP4(), reco::MET::setSignificanceMatrix(), srcCorrJets_, srcJetIds_, srcLeptons_, srcPFCandidatesView_, srcUncorrJets_, srcVertices_, CommonMETData::sumet, useType1_, trackerHitRTTI::vector, pwdgSkimBPark_cfi::vertices, and extraflags_cff::vtx.

Member Data Documentation

◆ globalThreshold_

double reco::PFMETProducerMVA::globalThreshold_
private

Definition at line 98 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ metAlgo_

METAlgo reco::PFMETProducerMVA::metAlgo_
private

Definition at line 102 of file PFMETProducerMVA.h.

Referenced by produce().

◆ minCorrJetPt_

double reco::PFMETProducerMVA::minCorrJetPt_
private

Definition at line 100 of file PFMETProducerMVA.h.

Referenced by computeJetInfo(), and PFMETProducerMVA().

◆ minNumLeptons_

int reco::PFMETProducerMVA::minNumLeptons_
private

Definition at line 94 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ mJetCorrector_

edm::EDGetTokenT<reco::JetCorrector> reco::PFMETProducerMVA::mJetCorrector_
private

Definition at line 91 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ mvaMEtAlgo_

PFMETAlgorithmMVA reco::PFMETProducerMVA::mvaMEtAlgo_
private

Definition at line 104 of file PFMETProducerMVA.h.

Referenced by produce().

◆ mvaMEtAlgo_isInitialized_

bool reco::PFMETProducerMVA::mvaMEtAlgo_isInitialized_
private

Definition at line 105 of file PFMETProducerMVA.h.

Referenced by produce().

◆ pfMEtSpecificAlgo_

PFSpecificAlgo reco::PFMETProducerMVA::pfMEtSpecificAlgo_
private

Definition at line 103 of file PFMETProducerMVA.h.

Referenced by produce().

◆ srcCorrJets_

edm::EDGetTokenT<reco::PFJetCollection> reco::PFMETProducerMVA::srcCorrJets_
private

Definition at line 85 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ srcJetIds_

edm::EDGetTokenT<edm::ValueMap<float> > reco::PFMETProducerMVA::srcJetIds_
private

Definition at line 87 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ srcLeptons_

std::vector<edm::EDGetTokenT<reco::CandidateView> > reco::PFMETProducerMVA::srcLeptons_
private

Definition at line 93 of file PFMETProducerMVA.h.

Referenced by computeLeptonInfo(), PFMETProducerMVA(), and produce().

◆ srcPFCandidatesView_

edm::EDGetTokenT<edm::View<reco::Candidate> > reco::PFMETProducerMVA::srcPFCandidatesView_
private

Definition at line 89 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ srcUncorrJets_

edm::EDGetTokenT<reco::PFJetCollection> reco::PFMETProducerMVA::srcUncorrJets_
private

Definition at line 86 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ srcVertices_

edm::EDGetTokenT<reco::VertexCollection> reco::PFMETProducerMVA::srcVertices_
private

Definition at line 90 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

◆ useType1_

bool reco::PFMETProducerMVA::useType1_
private

Definition at line 96 of file PFMETProducerMVA.h.

Referenced by computeJetInfo(), PFMETProducerMVA(), and produce().

◆ verbosity_

int reco::PFMETProducerMVA::verbosity_
private

Definition at line 108 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA().

reco::PFCandidate::trackRef
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
reco::PFMETProducerMVA::computeLeptonInfo
std::vector< reco::PUSubMETCandInfo > computeLeptonInfo(const std::vector< edm::EDGetTokenT< reco::CandidateView > > &srcLeptons_, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, int &lId, bool &lHasPhotons, edm::Event &iEvent)
Definition: PFMETProducerMVA.cc:138
CommonMETData::met
double met
Definition: CommonMETData.h:14
edm::View::begin
const_iterator begin() const
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
reco::PFTau::signalCands
const std::vector< reco::CandidatePtr > & signalCands() const
Candidates in signal region.
Definition: PFTau.cc:75
edm::PtrVectorBase::size
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:73
reco::PFMETProducerMVA::mJetCorrector_
edm::EDGetTokenT< reco::JetCorrector > mJetCorrector_
Definition: PFMETProducerMVA.h:91
METAlgo::run
CommonMETData run(const edm::View< reco::Candidate > &candidates, double globalThreshold=0.0, edm::ValueMap< float > const *weights=nullptr)
Definition: METAlgo.cc:16
SpecificPFMETData
MET made from Particle Flow Candidates.
Definition: SpecificPFMETData.h:12
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26346
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::EDGetTokenT
Definition: EDGetToken.h:33
reco::PUSubMETCandInfo::setDZ
void setDZ(float dZ)
Definition: PUSubMETData.h:47
pat::Tau
Analysis-level tau class.
Definition: Tau.h:53
PFMETAlgorithmMVA::initialize
void initialize(const edm::EventSetup &)
Definition: PFMETAlgorithmMVA.cc:143
PFSpecificAlgo::run
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands, edm::ValueMap< float > const *weights=nullptr)
Definition: PFSpecificAlgo.cc:15
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco::Candidate::isPhoton
virtual bool isPhoton() const =0
reco::PFTau
Definition: PFTau.h:36
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
reco::PUSubMETCandInfo::setP4
void setP4(const reco::Candidate::LorentzVector p4)
Definition: PUSubMETData.h:46
CommonMETData
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco::PFMETProducerMVA::srcPFCandidatesView_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
Definition: PFMETProducerMVA.h:89
edm::Handle
Definition: AssociativeIterator.h:50
reco::PUSubMETCandInfo::chargedEnFrac
float chargedEnFrac() const
Definition: PUSubMETData.h:41
reco::PUSubMETCandInfo::setChargedEnFrac
void setChargedEnFrac(float chEnF)
Definition: PUSubMETData.h:57
edm::Ref< PFJetCollection >
PFMETAlgorithmMVA::getMEtCov
const reco::METCovMatrix & getMEtCov() const
Definition: PFMETAlgorithmMVA.h:48
reco::PFMETProducerMVA::globalThreshold_
double globalThreshold_
Definition: PFMETProducerMVA.h:98
reco::PFMETProducerMVA::minCorrJetPt_
double minCorrJetPt_
Definition: PFMETProducerMVA.h:100
reco::PFMETProducerMVA::srcUncorrJets_
edm::EDGetTokenT< reco::PFJetCollection > srcUncorrJets_
Definition: PFMETProducerMVA.h:86
pfClustersFromHGC3DClusters_cfi.corrector
corrector
Definition: pfClustersFromHGC3DClusters_cfi.py:5
reco::PFJet::chargedHadronEnergy
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
reco::PFMETProducerMVA::chargedEnFrac
double chargedEnFrac(const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex)
Definition: PFMETProducerMVA.cc:333
pat::Tau::signalCands
reco::CandidatePtrVector signalCands() const
reco::PFMETProducerMVA::computeVertexInfo
std::vector< reco::Vertex::Point > computeVertexInfo(const reco::VertexCollection &)
Definition: PFMETProducerMVA.cc:320
reco::MET::setSignificanceMatrix
void setSignificanceMatrix(const reco::METCovMatrix &matrix)
Definition: MET.cc:142
reco::PUSubMETCandInfo
Definition: PUSubMETData.h:21
CommonMETData::mex
double mex
Definition: CommonMETData.h:15
reco::PUSubMETCandInfo::p4
const reco::Candidate::LorentzVector & p4() const
Definition: PUSubMETData.h:30
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
reco::PFMETProducerMVA::verbosity_
int verbosity_
Definition: PFMETProducerMVA.h:108
reco::PFMETProducerMVA::useType1_
bool useType1_
Definition: PFMETProducerMVA.h:96
reco::PFJet::chargedMultiplicity
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
reco::Jet::nConstituents
virtual int nConstituents() const
Definition: Jet.h:65
pat::PackedCandidate::dz
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
Definition: PackedCandidate.h:745
reco::PFMETProducerMVA::mvaMEtAlgo_
PFMETAlgorithmMVA mvaMEtAlgo_
Definition: PFMETProducerMVA.h:104
reco::PFJet::chargedEmEnergy
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
reco::PFMETProducerMVA::minNumLeptons_
int minNumLeptons_
Definition: PFMETProducerMVA.h:94
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
reco::Candidate::isMuon
virtual bool isMuon() const =0
CommonMETData::sumet
double sumet
Definition: CommonMETData.h:18
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
PFMETAlgorithmMVA::setHasPhotons
void setHasPhotons(bool hasPhotons)
Definition: PFMETAlgorithmMVA.h:38
reco::PFMET
Definition: PFMET.h:18
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
reco::PFCandidate::gsfTrackRef
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:440
reco::PFMETProducerMVA::srcJetIds_
edm::EDGetTokenT< edm::ValueMap< float > > srcJetIds_
Definition: PFMETProducerMVA.h:87
reco::PFMETProducerMVA::pfMEtSpecificAlgo_
PFSpecificAlgo pfMEtSpecificAlgo_
Definition: PFMETProducerMVA.h:103
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
edm::EventBase::luminosityBlock
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
pat::PackedCandidate
Definition: PackedCandidate.h:22
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
AK4CaloJetsMCFlavour_cff.leptonInfo
leptonInfo
Definition: AK4CaloJetsMCFlavour_cff.py:14
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
reco::PFMETProducerMVA::vInputTag
std::vector< edm::InputTag > vInputTag
Definition: PFMETProducerMVA.h:92
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
p4
double p4[4]
Definition: TauolaWrapper.h:92
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
reco::PFMETProducerMVA::srcLeptons_
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
Definition: PFMETProducerMVA.h:93
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
reco::PFMETProducerMVA::passPFLooseId
bool passPFLooseId(const reco::PFJet *iJet)
Definition: PFMETProducerMVA.cc:382
dR2Max
const double dR2Max
Definition: PFMETProducerMVA.cc:6
reco::PFMETProducerMVA::srcVertices_
edm::EDGetTokenT< reco::VertexCollection > srcVertices_
Definition: PFMETProducerMVA.h:90
PFMETAlgorithmMVA::setInput
void setInput(const std::vector< reco::PUSubMETCandInfo > &, const std::vector< reco::PUSubMETCandInfo > &, const std::vector< reco::PUSubMETCandInfo > &, const std::vector< reco::Vertex::Point > &)
Definition: PFMETAlgorithmMVA.cc:170
looper.cfg
cfg
Definition: looper.py:297
dR2Min
const double dR2Min
Definition: PFMETProducerMVA.cc:5
PFMETAlgorithmMVA::getMEt
reco::Candidate::LorentzVector getMEt() const
Definition: PFMETAlgorithmMVA.h:47
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
reco::PUSubMETCandInfo::setMvaVal
void setMvaVal(float mva)
Definition: PUSubMETData.h:56
reco::Candidate::isElectron
virtual bool isElectron() const =0
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
reco::PFJet::neutralHadronEnergy
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
reco::PFMETProducerMVA::mvaMEtAlgo_isInitialized_
bool mvaMEtAlgo_isInitialized_
Definition: PFMETProducerMVA.h:105
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
reco::PFJet::neutralEmEnergy
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
reco::PFMETProducerMVA::computePFCandidateInfo
std::vector< reco::PUSubMETCandInfo > computePFCandidateInfo(const reco::CandidateView &, const reco::Vertex *)
Definition: PFMETProducerMVA.cc:289
reco::PFMETProducerMVA::chargedFracInCone
double chargedFracInCone(const reco::Candidate *iCand, const reco::CandidateView &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
Definition: PFMETProducerMVA.cc:400
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
HLT_FULL_cff.numLeptons
numLeptons
Definition: HLT_FULL_cff.py:26345
reco::PFMETProducerMVA::computeJetInfo
std::vector< reco::PUSubMETCandInfo > computeJetInfo(const reco::PFJetCollection &, const edm::Handle< reco::PFJetCollection > &, const edm::ValueMap< float > &, const reco::VertexCollection &, const reco::Vertex *, const reco::JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< reco::PUSubMETCandInfo > &iLeptons, std::vector< reco::PUSubMETCandInfo > &iCands)
Definition: PFMETProducerMVA.cc:204
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
PFMETAlgorithmMVA::evaluateMVA
void evaluateMVA()
Definition: PFMETAlgorithmMVA.cc:236
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dPtMatch
const double dPtMatch
Definition: PFMETProducerMVA.cc:7
edm::View::end
const_iterator end() const
reco::PFMETProducerMVA::srcCorrJets_
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
Definition: PFMETProducerMVA.h:85
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
reco::Candidate::Point
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
reco::PFMETProducerMVA::metAlgo_
METAlgo metAlgo_
Definition: PFMETProducerMVA.h:102
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
CommonMETData::mey
double mey
Definition: CommonMETData.h:16
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
reco::PFMETProducerMVA::istau
bool istau(const reco::Candidate *iCand)
Definition: PFMETProducerMVA.cc:373
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7