CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFMETProducerMVA (const edm::ParameterSet &)
 
 ~PFMETProducerMVA ()
 
- 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
 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 ()
 
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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector
< edm::InputTag
vInputTag
 

Private Member Functions

double chargedFrac (const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex)
 
double chargedFracInCone (const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
 
std::vector
< mvaMEtUtilities::JetInfo
computeJetInfo (const reco::PFJetCollection &, const reco::PFJetCollection &, const reco::VertexCollection &, const reco::Vertex *, const JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< mvaMEtUtilities::leptonInfo > &iLeptons, std::vector< mvaMEtUtilities::pfCandInfo > &iCands)
 
std::vector
< mvaMEtUtilities::pfCandInfo
computePFCandidateInfo (const reco::PFCandidateCollection &, 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 &)
 

Private Attributes

std::string correctorLabel_
 
double globalThreshold_
 
bool isOld42_
 
METAlgo metAlgo_
 
double minCorrJetPt_
 
int minNumLeptons_
 
PileupJetIdAlgo mvaJetIdAlgo_
 
PFMETAlgorithmMVA mvaMEtAlgo_
 
bool mvaMEtAlgo_isInitialized_
 
PFSpecificAlgo pfMEtSpecificAlgo_
 
edm::EDGetTokenT
< reco::PFJetCollection
srcCorrJets_
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Candidate > > > 
srcLeptons_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
srcPFCandidates_
 
edm::EDGetTokenT< edm::View
< reco::Candidate > > 
srcPFCandidatesView_
 
edm::EDGetTokenT< edm::Handle
< double > > 
srcRho_
 
edm::EDGetTokenT
< reco::PFJetCollection
srcUncorrJets_
 
edm::EDGetTokenT
< reco::VertexCollection
srcVertices_
 
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, 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
 
- 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::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

Definition at line 39 of file PFMETProducerMVA.h.

Member Typedef Documentation

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

Definition at line 69 of file PFMETProducerMVA.h.

Constructor & Destructor Documentation

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

Definition at line 59 of file PFMETProducerMVA.cc.

References edm::EDConsumerBase::consumes(), correctorLabel_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), globalThreshold_, isOld42_, LogDebug, minCorrJetPt_, minNumLeptons_, srcCorrJets_, srcLeptons_, srcPFCandidates_, srcPFCandidatesView_, srcRho_, srcUncorrJets_, srcVertices_, AlCaHLTBitMon_QueryRunRegistry::string, useType1_, and verbosity_.

60  : mvaMEtAlgo_(cfg),
62  mvaJetIdAlgo_(cfg)
63 {
64  srcCorrJets_ = consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcCorrJets"));
65  srcUncorrJets_ = consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcUncorrJets"));
66  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
67  srcPFCandidatesView_ = consumes<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
68  srcVertices_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("srcVertices"));
69  vInputTag srcLeptonsTags = cfg.getParameter<vInputTag>("srcLeptons");
70  for(vInputTag::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
71  srcLeptons_.push_back( consumes<edm::View<reco::Candidate> >( *it ) );
72  }
73 
74  minNumLeptons_ = cfg.getParameter<int>("minNumLeptons");
75  srcRho_ = consumes<edm::Handle<double> >(cfg.getParameter<edm::InputTag>("srcRho"));
76 
77  globalThreshold_ = cfg.getParameter<double>("globalThreshold");
78 
79  minCorrJetPt_ = cfg.getParameter<double> ("minCorrJetPt");
80  useType1_ = cfg.getParameter<bool> ("useType1");
81  correctorLabel_ = cfg.getParameter<std::string>("corrector");
82  isOld42_ = cfg.getParameter<bool> ("useOld42");
83 
84  verbosity_ = ( cfg.exists("verbosity") ) ?
85  cfg.getParameter<int>("verbosity") : 0;
86 
87  //if ( verbosity_ ) {
88  LogDebug( "PFMETProducerMVA" )
89  << "<PFMETProducerMVA::PFMETProducerMVA>:" << std::endl;
90  // std::cout << " srcCorrJets = " << srcCorrJets_.label() << std::endl;
91  // std::cout << " srcUncorrJets = " << srcUncorrJets_.label() << std::endl;
92  // std::cout << " srcPFCandidates = " << srcPFCandidates_.label() << std::endl;
93  // std::cout << " srcVertices = " << srcVertices_.label() << std::endl;
94  // std::cout << " srcLeptons = " << format_vInputTag(srcLeptons_) << std::endl;
95  // std::cout << " srcRho = " << srcVertices_.label() << std::endl;
96 
97  produces<reco::PFMETCollection>();
98 }
#define LogDebug(id)
PFMETAlgorithmMVA mvaMEtAlgo_
T getParameter(std::string const &) const
PileupJetIdAlgo mvaJetIdAlgo_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
std::vector< edm::InputTag > vInputTag
edm::EDGetTokenT< reco::VertexCollection > srcVertices_
edm::EDGetTokenT< edm::Handle< double > > srcRho_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcLeptons_
edm::EDGetTokenT< reco::PFJetCollection > srcUncorrJets_
PFMETProducerMVA::~PFMETProducerMVA ( )

Definition at line 100 of file PFMETProducerMVA.cc.

100 {}

Member Function Documentation

double PFMETProducerMVA::chargedFrac ( const reco::Candidate iCand,
const reco::PFCandidateCollection pfCandidates,
const reco::Vertex hardScatterVertex 
)
private

Definition at line 349 of file PFMETProducerMVA.cc.

References chargedFracInCone(), reco::Candidate::isElectron(), reco::Candidate::isMuon(), reco::Candidate::isPhoton(), EnergyCorrector::pt, reco::PFTau::signalPFCands(), and pat::Tau::signalPFCands().

Referenced by produce().

350  {
351  if(iCand->isMuon()) {
352  return 1;
353  }
354  if(iCand->isElectron()) {
355  return 1.;
356  }
357  if(iCand->isPhoton() ) {return chargedFracInCone(iCand, pfCandidates,hardScatterVertex);}
358  double lPtTot = 0; double lPtCharged = 0;
359  const reco::PFTau *lPFTau = 0;
360  lPFTau = dynamic_cast<const reco::PFTau*>(iCand);//}
361  if(lPFTau != 0) {
362  for (UInt_t i0 = 0; i0 < lPFTau->signalPFCands().size(); i0++) {
363  lPtTot += (lPFTau->signalPFCands())[i0]->pt();
364  if((lPFTau->signalPFCands())[i0]->charge() == 0) continue;
365  lPtCharged += (lPFTau->signalPFCands())[i0]->pt();
366  }
367  }
368  else {
369  const pat::Tau *lPatPFTau = nullptr;
370  lPatPFTau = dynamic_cast<const pat::Tau*>(iCand);//}
371  if(lPatPFTau != nullptr) {
372  for (UInt_t i0 = 0; i0 < lPatPFTau->signalPFCands().size(); i0++) {
373  lPtTot += (lPatPFTau->signalPFCands())[i0]->pt();
374  if((lPatPFTau->signalPFCands())[i0]->charge() == 0) continue;
375  lPtCharged += (lPatPFTau->signalPFCands())[i0]->pt();
376  }
377  }
378  }
379  if(lPtTot == 0) lPtTot = 1.;
380  return lPtCharged/lPtTot;
381 }
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:74
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual bool isPhoton() const =0
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
Analysis-level tau class.
Definition: Tau.h:56
virtual bool isMuon() const =0
double chargedFracInCone(const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex, double iDRMax=0.2)
virtual bool isElectron() const =0
double PFMETProducerMVA::chargedFracInCone ( const reco::Candidate iCand,
const reco::PFCandidateCollection pfCandidates,
const reco::Vertex hardScatterVertex,
double  iDRMax = 0.2 
)
private

Definition at line 400 of file PFMETProducerMVA.cc.

References funct::abs(), reco::deltaR2(), reco::Candidate::p4(), reco::Vertex::position(), and reco::Candidate::pt().

Referenced by chargedFrac().

403 {
404 
405  double iDR2Max = iDRMax*iDRMax;
406  reco::Candidate::LorentzVector lVis(0,0,0,0);
407  for ( reco::PFCandidateCollection::const_iterator pfCandidate = pfCandidates.begin();
408  pfCandidate != pfCandidates.end(); ++pfCandidate ) {
409  if(deltaR2(iCand->p4(),pfCandidate->p4()) > iDR2Max) 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  if ( pfCandidate->trackRef().isNonnull() ) dZ = std::abs(pfCandidate->trackRef()->dz(hardScatterVertex->position()));
414  else if ( pfCandidate->gsfTrackRef().isNonnull() ) dZ = std::abs(pfCandidate->gsfTrackRef()->dz(hardScatterVertex->position()));
415  }
416  if(std::abs(dZ) > 0.1) continue;
417  lVis += pfCandidate->p4();
418  }
419  return lVis.pt()/iCand->pt();
420 }
const Point & position() const
position
Definition: Vertex.h:106
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
virtual float pt() const =0
transverse momentum
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
std::vector< mvaMEtUtilities::JetInfo > PFMETProducerMVA::computeJetInfo ( const reco::PFJetCollection uncorrJets,
const reco::PFJetCollection corrJets,
const reco::VertexCollection vertices,
const reco::Vertex hardScatterVertex,
const JetCorrector iCorr,
edm::Event iEvent,
const edm::EventSetup iSetup,
std::vector< mvaMEtUtilities::leptonInfo > &  iLeptons,
std::vector< mvaMEtUtilities::pfCandInfo > &  iCands 
)
private

Definition at line 252 of file PFMETProducerMVA.cc.

References PileupJetIdAlgo::computeIdVariables(), L1FastjetCorrector::correction(), reco::deltaR2(), dR2Max, dR2Min, mvaMEtUtilities::pfCandInfo::dZ_, minCorrJetPt_, PileupJetIdentifier::mva(), mvaMEtUtilities::JetInfo::mva_, mvaJetIdAlgo_, mvaMEtUtilities::JetInfo::neutralEnFrac_, mvaMEtUtilities::pfCandInfo::p4_, mvaMEtUtilities::JetInfo::p4_, passPFLooseId(), and useType1_.

Referenced by produce().

258 {
259 
260  const L1FastjetCorrector* lCorrector = dynamic_cast<const L1FastjetCorrector*>(&iCorrector);
261  std::vector<mvaMEtUtilities::JetInfo> retVal;
262  for ( reco::PFJetCollection::const_iterator uncorrJet = uncorrJets.begin();
263  uncorrJet != uncorrJets.end(); ++uncorrJet ) {
264  //int pIndex = uncorrJet-uncorrJets.begin();
265  //edm::RefToBase<reco::Jet> jetRef(edm::Ref<PFJetCollection>(&uncorrJets,pIndex));
266  for ( reco::PFJetCollection::const_iterator corrJet = corrJets.begin();
267  corrJet != corrJets.end(); ++corrJet ) {
268  // match corrected and uncorrected jets
269  if ( uncorrJet->jetArea() != corrJet->jetArea() ) continue;
270  if ( deltaR2(corrJet->p4(),uncorrJet->p4()) > dR2Min ) continue;
271 
272  // check that jet passes loose PFJet id.
273  //bool passesLooseJetId = (*looseJetIdAlgo_)(*corrJet);
274  //if ( !passesLooseJetId ) continue;
275  if(!passPFLooseId(&(*uncorrJet))) continue;
276 
277  // compute jet energy correction factor
278  // (= ratio of corrected/uncorrected jet Pt)
279  double jetEnCorrFactor = corrJet->pt()/uncorrJet->pt();
280  mvaMEtUtilities::JetInfo jetInfo;
281 
282  // PH: apply jet energy corrections for all Jets ignoring recommendations
283  jetInfo.p4_ = corrJet->p4();
284  double lType1Corr = 0;
285  if(useType1_) { //Compute the type 1 correction ===> This code is crap
286  double pCorr = lCorrector->correction(*uncorrJet,iEvent,iSetup); //Does not work in 42X
287  lType1Corr = (corrJet->pt()-pCorr*uncorrJet->pt());
288  TLorentzVector pVec; pVec.SetPtEtaPhiM(lType1Corr,0,corrJet->phi(),0);
289  reco::Candidate::LorentzVector pType1Corr; pType1Corr.SetCoordinates(pVec.Px(),pVec.Py(),pVec.Pz(),pVec.E());
290  //Filter to leptons
291  bool pOnLepton = false;
292  for(unsigned int i0 = 0; i0 < iLeptons.size(); i0++) if(deltaR2(iLeptons[i0].p4_,corrJet->p4()) < dR2Max) {pOnLepton = true; break;}
293  //Add it to PF Collection
294  if(corrJet->pt() > 10 && !pOnLepton) {
295  mvaMEtUtilities::pfCandInfo pfCandidateInfo;
296  pfCandidateInfo.p4_ = pType1Corr;
297  pfCandidateInfo.dZ_ = -999;
298  iCands.push_back(pfCandidateInfo);
299  }
300  //Scale
301  lType1Corr = (pCorr*uncorrJet->pt()-uncorrJet->pt());
302  lType1Corr /=corrJet->pt();
303  }
304 
305  // check that jet Pt used to compute MVA based jet id. is above threshold
306  if ( !(jetInfo.p4_.pt() > minCorrJetPt_) ) continue;
307  jetInfo.mva_ = mvaJetIdAlgo_.computeIdVariables(&(*corrJet), jetEnCorrFactor, hardScatterVertex, vertices, true).mva();
308  jetInfo.neutralEnFrac_ = (uncorrJet->neutralEmEnergy() + uncorrJet->neutralHadronEnergy())/uncorrJet->energy();
309  if(useType1_) jetInfo.neutralEnFrac_ -= lType1Corr*jetInfo.neutralEnFrac_;
310  retVal.push_back(jetInfo);
311  break;
312  }
313  }
314  return retVal;
315 }
const double dR2Max
virtual double correction(const LorentzVector &fJet) const
apply correction using Jet information only
const float & mva() const
PileupJetIdAlgo mvaJetIdAlgo_
reco::Candidate::LorentzVector p4_
reco::Candidate::LorentzVector p4_
bool passPFLooseId(const reco::PFJet *iJet)
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, bool calculateMva=false)
const double dR2Min
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
std::vector< mvaMEtUtilities::pfCandInfo > PFMETProducerMVA::computePFCandidateInfo ( const reco::PFCandidateCollection pfCandidates,
const reco::Vertex hardScatterVertex 
)
private

Definition at line 317 of file PFMETProducerMVA.cc.

References funct::abs(), mvaMEtUtilities::pfCandInfo::dZ_, mvaMEtUtilities::pfCandInfo::p4_, and reco::Vertex::position().

Referenced by produce().

319 {
320  std::vector<mvaMEtUtilities::pfCandInfo> retVal;
321  for ( reco::PFCandidateCollection::const_iterator pfCandidate = pfCandidates.begin();
322  pfCandidate != pfCandidates.end(); ++pfCandidate ) {
323  double dZ = -999.; // PH: If no vertex is reconstructed in the event
324  // or PFCandidate has no track, set dZ to -999
325  if ( hardScatterVertex ) {
326  if ( pfCandidate->trackRef().isNonnull() ) dZ = std::abs(pfCandidate->trackRef()->dz(hardScatterVertex->position()));
327  else if ( pfCandidate->gsfTrackRef().isNonnull() ) dZ = std::abs(pfCandidate->gsfTrackRef()->dz(hardScatterVertex->position()));
328  }
329  mvaMEtUtilities::pfCandInfo pfCandidateInfo;
330  pfCandidateInfo.p4_ = pfCandidate->p4();
331  pfCandidateInfo.dZ_ = dZ;
332  retVal.push_back(pfCandidateInfo);
333  }
334  return retVal;
335 }
const Point & position() const
position
Definition: Vertex.h:106
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
reco::Candidate::LorentzVector p4_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< reco::Vertex::Point > PFMETProducerMVA::computeVertexInfo ( const reco::VertexCollection vertices)
private

Definition at line 337 of file PFMETProducerMVA.cc.

References funct::abs().

Referenced by produce().

338 {
339  std::vector<reco::Vertex::Point> retVal;
340  for ( reco::VertexCollection::const_iterator vertex = vertices.begin();
341  vertex != vertices.end(); ++vertex ) {
342  if(std::abs(vertex->z()) > 24.) continue;
343  if(vertex->ndof() < 4.) continue;
344  if(vertex->position().Rho() > 2.) continue;
345  retVal.push_back(vertex->position());
346  }
347  return retVal;
348 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool PFMETProducerMVA::istau ( const reco::Candidate iCand)
private

Definition at line 383 of file PFMETProducerMVA.cc.

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

Referenced by produce().

383  {
384  if(iCand->isMuon()) return false;
385  if(iCand->isElectron()) return false;
386  if(iCand->isPhoton()) return false;
387  return true;
388 }
virtual bool isPhoton() const =0
virtual bool isMuon() const =0
virtual bool isElectron() const =0
bool PFMETProducerMVA::passPFLooseId ( const reco::PFJet iJet)
private

Definition at line 389 of file PFMETProducerMVA.cc.

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().

389  {
390  if(iJet->energy()== 0) return false;
391  if(iJet->neutralHadronEnergy()/iJet->energy() > 0.99) return false;
392  if(iJet->neutralEmEnergy()/iJet->energy() > 0.99) return false;
393  if(iJet->nConstituents() < 2) return false;
394  if(iJet->chargedHadronEnergy()/iJet->energy() <= 0 && std::abs(iJet->eta()) < 2.4 ) return false;
395  if(iJet->chargedEmEnergy()/iJet->energy() > 0.99 && std::abs(iJet->eta()) < 2.4 ) return false;
396  if(iJet->chargedMultiplicity() < 1 && std::abs(iJet->eta()) < 2.4 ) return false;
397  return true;
398 }
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:142
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:155
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:150
virtual double energy() const
energy
virtual float eta() const
momentum pseudorapidity
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int nConstituents() const
of constituents
Definition: Jet.h:65
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:102
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:98
void PFMETProducerMVA::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 102 of file PFMETProducerMVA.cc.

References funct::abs(), chargedFrac(), mvaMEtUtilities::leptonInfo::chargedFrac_, computeJetInfo(), computePFCandidateInfo(), computeVertexInfo(), mvaPFMET_cff::corrector, correctorLabel_, reco::deltaR2(), dPtMatch, dR2Max, PFMETAlgorithmMVA::evaluateMVA(), edm::EventID::event(), edm::Event::getByToken(), JetCorrector::getJetCorrector(), PFMETAlgorithmMVA::getMEt(), PFMETAlgorithmMVA::getMEtCov(), globalThreshold_, edm::EventBase::id(), PFMETAlgorithmMVA::initialize(), istau(), EgammaValidation_Wenu_cff::leptons, LogDebug, edm::EventBase::luminosityBlock(), CommonMETData::met, metAlgo_, CommonMETData::mex, CommonMETData::mey, minNumLeptons_, mvaMEtAlgo_, mvaMEtAlgo_isInitialized_, p4, reco::LeafCandidate::p4(), mvaMEtUtilities::leptonInfo::p4_, reco::tau::pfCandidates(), 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_, srcLeptons_, srcPFCandidates_, srcPFCandidatesView_, srcUncorrJets_, srcVertices_, CommonMETData::sumet, and useType1_.

103 {
104  // CV: check if the event is to be skipped
105  if ( minNumLeptons_ > 0 ) {
106  int numLeptons = 0;
107  for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = srcLeptons_.begin();
108  srcLeptons_i != srcLeptons_.end(); ++srcLeptons_i ) {
110  evt.getByToken(*srcLeptons_i, leptons);
111  numLeptons += leptons->size();
112  }
113  if ( !(numLeptons >= minNumLeptons_) ) {
114  LogDebug( "produce" )
115  << "<PFMETProducerMVA::produce>:" << std::endl
116  << "Run: " << evt.id().run() << ", LS: " << evt.luminosityBlock() << ", Event: " << evt.id().event() << std::endl
117  << " numLeptons = " << numLeptons << ", minNumLeptons = " << minNumLeptons_ << " --> skipping !!" << std::endl;
118 
119  reco::PFMET pfMEt;
120  std::auto_ptr<reco::PFMETCollection> pfMEtCollection(new reco::PFMETCollection());
121  pfMEtCollection->push_back(pfMEt);
122  evt.put(pfMEtCollection);
123  return;
124  }
125  }
126 
127  // get jets (corrected and uncorrected)
129  evt.getByToken(srcCorrJets_, corrJets);
130 
132  evt.getByToken(srcUncorrJets_, uncorrJets);
133 
134  const JetCorrector* corrector = nullptr;
136 
137  // get PFCandidates
139  evt.getByToken(srcPFCandidates_, pfCandidates);
140 
141  edm::Handle<CandidateView> pfCandidates_view;
142  evt.getByToken(srcPFCandidatesView_, pfCandidates_view);
143 
144  // get vertices
146  evt.getByToken(srcVertices_, vertices);
147  // take vertex with highest sum(trackPt) as the vertex of the "hard scatter" interaction
148  // (= first entry in vertex collection)
149  const reco::Vertex* hardScatterVertex = ( vertices->size() >= 1 ) ?
150  &(vertices->front()) : 0;
151 
152  // get leptons
153  // (excluded from sum over PFCandidates when computing hadronic recoil)
154  int lId = 0;
155  bool lHasPhotons = false;
156  std::vector<mvaMEtUtilities::leptonInfo> leptonInfo;
157  for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = srcLeptons_.begin();
158  srcLeptons_i != srcLeptons_.end(); ++srcLeptons_i ) {
160  evt.getByToken(*srcLeptons_i, leptons);
161  for ( CandidateView::const_iterator lepton1 = leptons->begin();
162  lepton1 != leptons->end(); ++lepton1 ) {
163  bool pMatch = false;
164  for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_j = srcLeptons_.begin();
165  srcLeptons_j != srcLeptons_.end(); ++srcLeptons_j ) {
167  evt.getByToken(*srcLeptons_j, leptons2);
168  for ( CandidateView::const_iterator lepton2 = leptons2->begin();
169  lepton2 != leptons2->end(); ++lepton2 ) {
170  if(&(*lepton1) == &(*lepton2)) { continue; }
171  if(deltaR2(lepton1->p4(),lepton2->p4()) < dR2Max) { pMatch = true; }
172  if(pMatch && !istau(&(*lepton1)) && istau(&(*lepton2))) { pMatch = false; }
173  if(pMatch && ( (istau(&(*lepton1)) && istau(&(*lepton2))) || (!istau(&(*lepton1)) && !istau(&(*lepton2))))
174  && lepton1->pt() > lepton2->pt()) { pMatch = false; }
175  if(pMatch && lepton1->pt() == lepton2->pt()) {
176  pMatch = false;
177  for(unsigned int i0 = 0; i0 < leptonInfo.size(); i0++) {
178  if(std::abs(lepton1->pt() - leptonInfo[i0].p4_.pt()) < dPtMatch) { pMatch = true; break; }
179  }
180  }
181  if(pMatch) break;
182  }
183  if(pMatch) break;
184  }
185  if(pMatch) continue;
186  mvaMEtUtilities::leptonInfo pLeptonInfo;
187  pLeptonInfo.p4_ = lepton1->p4();
188  pLeptonInfo.chargedFrac_ = chargedFrac(&(*lepton1),*pfCandidates,hardScatterVertex);
189  leptonInfo.push_back(pLeptonInfo);
190  if(lepton1->isPhoton()) { lHasPhotons = true; }
191  }
192  lId++;
193  }
194  //if(lNMu == 2) std::cout << "=====> Di Muon Cand =======>" << leptonInfo[0].p4_.pt() << " -- " << leptonInfo[1].p4_.pt() << std::endl;
195 
196  // get average energy density in the event
197  //edm::Handle<double> rho;
198  //evt.getByToken(srcRho_, rho);
199 
200  // initialize MVA MET algorithm
201  // (this will load the BDTs, stored as GBRForrest objects;
202  // either in input ROOT files or in SQL-lite files/the Conditions Database)
203  if ( !mvaMEtAlgo_isInitialized_ ) {
206  }
207 
208  // reconstruct "standard" particle-flow missing Et
209  // MM cahnged needed in 72X, need to check resutls are consistent with 53X
210  //53X
211  //CommonMETData pfMEt_data = metAlgo_.run(pfCandidates_view, globalThreshold_);
212  //reco::PFMET pfMEt = pfMEtSpecificAlgo_.addInfo(pfCandidates_view, pfMEt_data);
213 
214  //72X
215  CommonMETData pfMEt_data = metAlgo_.run( (*pfCandidates_view), globalThreshold_);
216  SpecificPFMETData specificPfMET = pfMEtSpecificAlgo_.run( (*pfCandidates_view) );
217  const reco::Candidate::LorentzVector p4( pfMEt_data.mex, pfMEt_data.mey, 0.0, pfMEt_data.met);
218  const reco::Candidate::Point vtx(0.0, 0.0, 0.0 );
219  reco::PFMET pfMEt(specificPfMET,pfMEt_data.sumet, p4, vtx);
220  reco::Candidate::LorentzVector pfMEtP4_original = pfMEt.p4();
221 
222  // compute objects specific to MVA based MET reconstruction
223  std::vector<mvaMEtUtilities::pfCandInfo> pfCandidateInfo = computePFCandidateInfo(*pfCandidates, hardScatterVertex);
224  std::vector<mvaMEtUtilities::JetInfo> jetInfo = computeJetInfo(*uncorrJets, *corrJets, *vertices, hardScatterVertex, *corrector,evt,es,leptonInfo,pfCandidateInfo);
225  std::vector<reco::Vertex::Point> vertexInfo = computeVertexInfo(*vertices);
226 
227  // compute MVA based MET and estimate of its uncertainty
228  mvaMEtAlgo_.setInput(leptonInfo, jetInfo, pfCandidateInfo, vertexInfo);
229  mvaMEtAlgo_.setHasPhotons(lHasPhotons);
231  pfMEt.setP4(mvaMEtAlgo_.getMEt());
233 
234 
235  LogDebug("produce")
236  << "<PFMETProducerMVA::produce>:" << std::endl
237  << "Run: " << evt.id().run() << ", LS: " << evt.luminosityBlock() << ", Event: " << evt.id().event() << std::endl
238  << " PFMET: Pt = " << pfMEtP4_original.pt() << ", phi = " << pfMEtP4_original.phi() << " "
239  << "(Px = " << pfMEtP4_original.px() << ", Py = " << pfMEtP4_original.py() << ")" << std::endl
240  << " MVA MET: Pt = " << pfMEt.pt() << " phi = " << pfMEt.phi() << " (Px = " << pfMEt.px() << ", Py = " << pfMEt.py() << ")" << std::endl
241  << " Cov:" << std::endl
242  <<(mvaMEtAlgo_.getMEtCov())(0,0)<<" "<<(mvaMEtAlgo_.getMEtCov())(0,1)<<std::endl
243  <<(mvaMEtAlgo_.getMEtCov())(1,0)<<" "<<(mvaMEtAlgo_.getMEtCov())(1,1)<<std::endl << std::endl;
244  //mvaMEtAlgo_.print(std::cout);
245 
246  // add PFMET object to the event
247  std::auto_ptr<reco::PFMETCollection> pfMEtCollection(new reco::PFMETCollection());
248  pfMEtCollection->push_back(pfMEt);
249  evt.put(pfMEtCollection);
250 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
PFMETAlgorithmMVA mvaMEtAlgo_
EventNumber_t event() const
Definition: EventID.h:41
const double dR2Max
virtual float pt() const
transverse momentum
PFSpecificAlgo pfMEtSpecificAlgo_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual float phi() const
momentum azimuthal angle
std::vector< reco::Vertex::Point > computeVertexInfo(const reco::VertexCollection &)
void setSignificanceMatrix(const reco::METCovMatrix &matrix)
Definition: MET.cc:157
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
virtual void setP4(const LorentzVector &p4)
set 4-momentum
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
reco::Candidate::LorentzVector getMEt() const
const reco::METCovMatrix & getMEtCov() const
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
bool istau(const reco::Candidate *iCand)
edm::EDGetTokenT< edm::View< reco::Candidate > > srcPFCandidatesView_
std::vector< mvaMEtUtilities::pfCandInfo > computePFCandidateInfo(const reco::PFCandidateCollection &, const reco::Vertex *)
CommonMETData run(const edm::View< reco::Candidate > &candidates, double globalThreshold=0.0)
Definition: METAlgo.cc:16
reco::Candidate::LorentzVector p4_
tuple corrector
Definition: mvaPFMET_cff.py:50
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< reco::PFJetCollection > srcCorrJets_
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< reco::VertexCollection > srcVertices_
const double dPtMatch
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
void initialize(const edm::EventSetup &)
MET made from Particle Flow Candidates.
void setHasPhotons(bool hasPhotons)
SpecificPFMETData run(const edm::View< reco::Candidate > &pfCands)
double chargedFrac(const reco::Candidate *iCand, const reco::PFCandidateCollection &pfCandidates, const reco::Vertex *hardScatterVertex)
virtual double px() const
x coordinate of momentum vector
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
edm::EventID id() const
Definition: EventBase.h:56
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
void setInput(const std::vector< mvaMEtUtilities::leptonInfo > &, const std::vector< mvaMEtUtilities::JetInfo > &, const std::vector< mvaMEtUtilities::pfCandInfo > &, const std::vector< reco::Vertex::Point > &)
math::XYZPoint Point
point in the space
Definition: Candidate.h:45
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > srcLeptons_
edm::EDGetTokenT< reco::PFJetCollection > srcUncorrJets_
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
std::vector< mvaMEtUtilities::JetInfo > computeJetInfo(const reco::PFJetCollection &, const reco::PFJetCollection &, const reco::VertexCollection &, const reco::Vertex *, const JetCorrector &iCorr, edm::Event &iEvent, const edm::EventSetup &iSetup, std::vector< mvaMEtUtilities::leptonInfo > &iLeptons, std::vector< mvaMEtUtilities::pfCandInfo > &iCands)
virtual double py() const
y coordinate of momentum vector

Member Data Documentation

std::string reco::PFMETProducerMVA::correctorLabel_
private

Definition at line 74 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

double reco::PFMETProducerMVA::globalThreshold_
private

Definition at line 78 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

bool reco::PFMETProducerMVA::isOld42_
private

Definition at line 75 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA().

METAlgo reco::PFMETProducerMVA::metAlgo_
private

Definition at line 82 of file PFMETProducerMVA.h.

Referenced by produce().

double reco::PFMETProducerMVA::minCorrJetPt_
private

Definition at line 80 of file PFMETProducerMVA.h.

Referenced by computeJetInfo(), and PFMETProducerMVA().

int reco::PFMETProducerMVA::minNumLeptons_
private

Definition at line 71 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

PileupJetIdAlgo reco::PFMETProducerMVA::mvaJetIdAlgo_
private

Definition at line 86 of file PFMETProducerMVA.h.

Referenced by computeJetInfo().

PFMETAlgorithmMVA reco::PFMETProducerMVA::mvaMEtAlgo_
private

Definition at line 84 of file PFMETProducerMVA.h.

Referenced by produce().

bool reco::PFMETProducerMVA::mvaMEtAlgo_isInitialized_
private

Definition at line 85 of file PFMETProducerMVA.h.

Referenced by produce().

PFSpecificAlgo reco::PFMETProducerMVA::pfMEtSpecificAlgo_
private

Definition at line 83 of file PFMETProducerMVA.h.

Referenced by produce().

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

Definition at line 64 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > > reco::PFMETProducerMVA::srcLeptons_
private

Definition at line 70 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

edm::EDGetTokenT<reco::PFCandidateCollection> reco::PFMETProducerMVA::srcPFCandidates_
private

Definition at line 66 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

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

Definition at line 67 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

edm::EDGetTokenT<edm::Handle<double> > reco::PFMETProducerMVA::srcRho_
private

Definition at line 72 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA().

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

Definition at line 65 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

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

Definition at line 68 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA(), and produce().

bool reco::PFMETProducerMVA::useType1_
private

Definition at line 76 of file PFMETProducerMVA.h.

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

int reco::PFMETProducerMVA::verbosity_
private

Definition at line 88 of file PFMETProducerMVA.h.

Referenced by PFMETProducerMVA().