CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ( const edm::FileInPath weightsfile,
float  dRmax 
)

Definition at line 16 of file MuonMvaEstimator.cc.

References createGBRForest(), and gbrForest_.

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

Definition at line 20 of file MuonMvaEstimator.cc.

20 {}

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

Definition at line 53 of file MuonMvaEstimator.cc.

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

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 };
static std::vector< std::string > checklist log
const reco::Track * bestTrack() const override
Definition: PFCandidate.h:150
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:46
example_track example_trackconst char *const kPt
Definition: TSelector.cc:33
const Point & position() const
position
Definition: Vertex.h:127
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
double pt() const
track transverse momentum
Definition: TrackBase.h:637
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
std::unique_ptr< const GBRForest > gbrForest_
int charge() const final
electric charge

Member Data Documentation

float pat::MuonMvaEstimator::dRmax_
private

Definition at line 42 of file MuonMvaEstimator.h.

Referenced by computeMva().

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

Definition at line 41 of file MuonMvaEstimator.h.

Referenced by computeMva(), and MuonMvaEstimator().