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=nullptr, const reco::JetCorrector *correctorL1L2L3Res=nullptr) 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::MuonMvaEstimator ( const edm::FileInPath weightsfile,
float  dRmax 
)

Definition at line 16 of file MuonMvaEstimator.cc.

16  : dRmax_(dRmax) {
17  gbrForest_ = createGBRForest(weightsfile);
18 }

References createGBRForest(), and gbrForest_.

◆ ~MuonMvaEstimator()

MuonMvaEstimator::~MuonMvaEstimator ( )

Definition at line 20 of file MuonMvaEstimator.cc.

20 {}

Member Function Documentation

◆ computeMva()

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 = nullptr,
const reco::JetCorrector correctorL1L2L3Res = nullptr 
) const

Definition at line 53 of file MuonMvaEstimator.cc.

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

References TtFullHadKinFitProducer_cfi::bTags, reco::JetCorrector::correction(), PbPb_ZMuSkimMuonDPG_cff::deltaR, flavorHistoryFilter_cfi::dr, dRmax_, PVValHelper::dz, Exception, gbrForest_, reco::TrackBase::highPurity, metsig::jet, JetComb::kEta, kPt, dqm-mbProfile::log, SiStripPI::max, pfDeepBoostedJetPreprocessParams_cfi::pfcand, electrons_cff::ptRel, pat::Muon::PV2D, pat::Muon::PV3D, trigObjTnPSource_cfi::var, and bphysicsOniaDQM_cfi::vertex.

Member Data Documentation

◆ dRmax_

float pat::MuonMvaEstimator::dRmax_
private

Definition at line 42 of file MuonMvaEstimator.h.

Referenced by computeMva().

◆ gbrForest_

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

Definition at line 41 of file MuonMvaEstimator.h.

Referenced by computeMva(), and MuonMvaEstimator().

kPt
example_track example_trackconst char *const kPt
Definition: TSelector.cc:33
muon
Definition: MuonCocktails.h:17
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:244
reco::JetCorrector::correction
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:47
electrons_cff.ptRel
ptRel
Definition: electrons_cff.py:204
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
pat::Muon::PV3D
Definition: Muon.h:235
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
TtFullHadKinFitProducer_cfi.bTags
bTags
Definition: TtFullHadKinFitProducer_cfi.py:40
pat::MuonMvaEstimator::dRmax_
float dRmax_
Definition: MuonMvaEstimator.h:42
pat::Muon::PV2D
Definition: Muon.h:235
PVValHelper::dz
Definition: PVValidationHelpers.h:50
metsig::jet
Definition: SignAlgoResolutions.h:47
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
Exception
Definition: hltDiff.cc:246
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
pat::MuonMvaEstimator::gbrForest_
std::unique_ptr< const GBRForest > gbrForest_
Definition: MuonMvaEstimator.h:41
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
JetComb::kEta
Definition: TtSemiLepJetComb.h:17
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
reco::TrackBase::highPurity
Definition: TrackBase.h:154