CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::MuonMvaEstimator Class Reference

#include <MuonMvaEstimator.h>

Public Member Functions

float computeMva (const pat::Muon &imuon, const reco::Vertex &vertex, const reco::JetTagCollection &bTags, float &jetPtRatio, float &jetPtRel, float &miniIsoValue, const reco::JetCorrector *correctorL1=0, const reco::JetCorrector *correctorL1L2L3Res=0) const
 
 MuonMvaEstimator (const edm::FileInPath &weightsfile, float dRmax)
 
 ~MuonMvaEstimator ()
 

Private Attributes

float dRmax_
 
std::unique_ptr< const GBRForestgbrForest_
 

Detailed Description

Definition at line 25 of file MuonMvaEstimator.h.

Constructor & Destructor Documentation

MuonMvaEstimator::MuonMvaEstimator ( const edm::FileInPath weightsfile,
float  dRmax 
)

Definition at line 16 of file MuonMvaEstimator.cc.

References createGBRForest(), and gbrForest_.

16  :
17  dRmax_(dRmax)
18 {
19  gbrForest_ = createGBRForest( weightsfile );
20 }
std::unique_ptr< const GBRForest > gbrForest_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
MuonMvaEstimator::~MuonMvaEstimator ( )

Definition at line 22 of file MuonMvaEstimator.cc.

22 { }

Member Function Documentation

float MuonMvaEstimator::computeMva ( const pat::Muon imuon,
const reco::Vertex vertex,
const reco::JetTagCollection bTags,
float &  jetPtRatio,
float &  jetPtRel,
float &  miniIsoValue,
const reco::JetCorrector correctorL1 = 0,
const reco::JetCorrector correctorL1L2L3Res = 0 
) const

Definition at line 54 of file MuonMvaEstimator.cc.

References reco::PFCandidate::bestTrack(), reco::LeafCandidate::charge(), pat::PFIsolation::chargedHadronIso(), reco::JetCorrector::correction(), pat::Muon::dB(), boostedElectronIsolation_cff::deltaR, runTauDisplay::dr, dRmax_, PVValHelper::dz, pat::Muon::edB(), reco::LeafCandidate::eta(), Exception, gbrForest_, reco::TrackBase::highPurity, metsig::jet, JetComb::kEta, kPt, cmsBatch::log, SiStripPI::max, pat::Lepton< LeptonType >::miniPFIsolation(), pat::Muon::muonBestTrack(), reco::LeafCandidate::p4(), pfDeepBoostedJetPreprocessParams_cfi::pfcand, reco::Muon::pfIsolationR04(), reco::Vertex::position(), reco::LeafCandidate::pt(), reco::TrackBase::pt(), electrons_cff::ptRel, pat::Muon::PV2D, pat::Muon::PV3D, pat::Muon::segmentCompatibility(), reco::MuonPFIsolation::sumChargedHadronPt, reco::MuonPFIsolation::sumNeutralHadronEt, reco::MuonPFIsolation::sumPhotonEt, reco::MuonPFIsolation::sumPUPt, and JetChargeProducer_cfi::var.

63 {
64  float var[kLast]{};
65 
66  var[kPt] = muon.pt();
67  var[kEta] = muon.eta();
68  var[kSegmentCompatibility] = muon.segmentCompatibility();
69  var[kMiniRelIsoCharged] = muon.miniPFIsolation().chargedHadronIso() / muon.pt();
70  var[kMiniRelIsoNeutral] = miniIsoValue - var[kMiniRelIsoCharged];
71 
72  double dB2D = fabs(muon.dB(pat::Muon::PV2D));
73  double dB3D = muon.dB(pat::Muon::PV3D);
74  double edB3D = muon.edB(pat::Muon::PV3D);
75  double dz = fabs(muon.muonBestTrack()->dz(vertex.position()));
76  var[kSip] = edB3D>0?fabs(dB3D/edB3D):0.0;
77  var[kLog_abs_dxyBS] = dB2D>0?log(dB2D):0;
78  var[kLog_abs_dzPV] = dz>0?log(dz):0;
79 
80  //Initialise loop variables
81  double minDr = 9999;
82  double jecL1L2L3Res = 1.;
83  double jecL1 = 1.;
84 
85  // Compute corrected isolation variables
86  double chIso = muon.pfIsolationR04().sumChargedHadronPt;
87  double nIso = muon.pfIsolationR04().sumNeutralHadronEt;
88  double phoIso = muon.pfIsolationR04().sumPhotonEt;
89  double puIso = muon.pfIsolationR04().sumPUPt;
90  double dbCorrectedIsolation = chIso + std::max( nIso + phoIso - .5*puIso, 0. ) ;
91  double dbCorrectedRelIso = dbCorrectedIsolation/muon.pt();
92 
93  var[kJetPtRatio] = 1./(1+dbCorrectedRelIso);
94  var[kJetPtRel] = 0;
95  var[kJetBTagCSV] = -999;
96  var[kJetNDauCharged] = -1;
97 
98 
99  for (const auto& tagI: bTags){
100  // for each muon with the lepton
101  double dr = deltaR(*(tagI.first), muon);
102  if(dr > minDr) continue;
103  minDr = dr;
104 
105  const reco::Candidate::LorentzVector& muP4(muon.p4());
106  reco::Candidate::LorentzVector jetP4(tagI.first->p4());
107 
108  if (correctorL1 && correctorL1L2L3Res){
109  jecL1L2L3Res = correctorL1L2L3Res->correction(*(tagI.first));
110  jecL1 = correctorL1->correction(*(tagI.first));
111  }
112 
113  // Get b-jet info
114  var[kJetBTagCSV] = tagI.second;
115  var[kJetNDauCharged] = 0;
116  for (auto jet: tagI.first->getJetConstituentsQuick()){
117  const reco::PFCandidate *pfcand = dynamic_cast<const reco::PFCandidate*>(jet);
118  if (pfcand==nullptr) throw cms::Exception("ConfigurationError") << "Cannot get jet constituents";
119  if (pfcand->charge()==0) continue;
120  auto bestTrackPtr = pfcand->bestTrack();
121  if (!bestTrackPtr) continue;
122  if (!bestTrackPtr->quality(reco::Track::highPurity)) continue;
123  if (bestTrackPtr->pt()<1.) continue;
124  if (bestTrackPtr->hitPattern().numberOfValidHits()<8) continue;
125  if (bestTrackPtr->hitPattern().numberOfValidPixelHits()<2) continue;
126  if (bestTrackPtr->normalizedChi2()>=5) continue;
127 
128  if (std::fabs(bestTrackPtr->dxy(vertex.position())) > 0.2) continue;
129  if (std::fabs(bestTrackPtr->dz(vertex.position())) > 17) continue;
130  var[kJetNDauCharged]++;
131  }
132 
133  if(minDr < dRmax_){
134  if ((jetP4-muP4).Rho()<0.0001){
135  var[kJetPtRel] = 0;
136  var[kJetPtRatio] = 1;
137  } else {
138  jetP4 -= muP4/jecL1;
139  jetP4 *= jecL1L2L3Res;
140  jetP4 += muP4;
141 
142  var[kJetPtRatio] = muP4.pt()/jetP4.pt();
143  var[kJetPtRel] = ptRel(muP4,jetP4);
144  }
145  }
146  }
147 
148  if (var[kJetPtRatio] > 1.5) var[kJetPtRatio] = 1.5;
149  if (var[kJetBTagCSV] < 0) var[kJetBTagCSV] = 0;
150  jetPtRatio = var[kJetPtRatio];
151  jetPtRel = var[kJetPtRel];
152  return gbrForest_->GetClassifier(var);
153 };
example_track example_track const char *const kPt
Definition: TSelector.cc:34
int charge() const final
electric charge
Definition: LeafCandidate.h:91
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:49
const Point & position() const
position
Definition: Vertex.h:109
double pt() const
track transverse momentum
Definition: TrackBase.h:660
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
std::unique_ptr< const GBRForest > gbrForest_
const reco::Track * bestTrack() const override
Definition: PFCandidate.h:162

Member Data Documentation

float pat::MuonMvaEstimator::dRmax_
private

Definition at line 44 of file MuonMvaEstimator.h.

Referenced by computeMva().

std::unique_ptr<const GBRForest> pat::MuonMvaEstimator::gbrForest_
private

Definition at line 43 of file MuonMvaEstimator.h.

Referenced by computeMva(), and MuonMvaEstimator().