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 | Static Public Member Functions | Private Attributes
pat::MuonMvaIDEstimator Class Reference

#include <MuonMvaIDEstimator.h>

Public Member Functions

std::vector< float > computeMVAID (const pat::Muon &imuon) const
 
 MuonMvaIDEstimator (const edm::FileInPath &weightsfile)
 
 ~MuonMvaIDEstimator ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
static void globalEndJob (const cms::Ort::ONNXRuntime *)
 

Private Attributes

std::vector< std::string > flav_names_
 
std::vector< std::string > input_names_
 
std::unique_ptr< const
cms::Ort::ONNXRuntime
randomForest_
 

Detailed Description

Definition at line 21 of file MuonMvaIDEstimator.h.

Constructor & Destructor Documentation

MuonMvaIDEstimator::MuonMvaIDEstimator ( const edm::FileInPath weightsfile)

Definition at line 13 of file MuonMvaIDEstimator.cc.

References edm::FileInPath::fullPath(), and LogDebug.

13  {
14  randomForest_ = std::make_unique<ONNXRuntime>(weightsfile.fullPath());
15  LogDebug("MuonMvaIDEstimator") << randomForest_.get();
16 }
std::unique_ptr< const cms::Ort::ONNXRuntime > randomForest_
std::string fullPath() const
Definition: FileInPath.cc:161
#define LogDebug(id)
pat::MuonMvaIDEstimator::~MuonMvaIDEstimator ( )
default

Member Function Documentation

std::vector< float > MuonMvaIDEstimator::computeMVAID ( const pat::Muon imuon) const

Definition at line 32 of file MuonMvaIDEstimator.cc.

References arbitrationType, cms::cuda::assert(), reco::MuonQuality::chi2LocalPosition, reco::Muon::combinedQuality(), PVValHelper::eta, reco::LeafCandidate::eta(), pat::Muon::globalTrack(), pat::Muon::innerTrack(), reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), LogDebug, reco::Muon::numberOfMatchedStations(), DiDispStaMuonMonitor_cfi::pt, reco::LeafCandidate::pt(), pat::Muon::segmentCompatibility(), and reco::MuonQuality::trkKink.

32  {
33  const float local_chi2 = muon.combinedQuality().chi2LocalPosition;
34  const float kink = muon.combinedQuality().trkKink;
35  const float segment_comp = muon.segmentCompatibility(arbitrationType);
36  const float n_MatchedStations = muon.numberOfMatchedStations();
37  const float pt = muon.pt();
38  const float eta = muon.eta();
39  const float global_muon = muon.isGlobalMuon();
40  float Valid_pixel;
41  float tracker_layers;
42  float validFraction;
43  if (muon.innerTrack().isNonnull()) {
44  Valid_pixel = muon.innerTrack()->hitPattern().numberOfValidPixelHits();
45  tracker_layers = muon.innerTrack()->hitPattern().trackerLayersWithMeasurement();
46  validFraction = muon.innerTrack()->validFraction();
47  } else {
48  Valid_pixel = -99.;
49  tracker_layers = -99.0;
50  validFraction = -99.0;
51  }
52  float norm_chi2;
53  float n_Valid_hits;
54  if (muon.globalTrack().isNonnull()) {
55  norm_chi2 = muon.globalTrack()->normalizedChi2();
56  n_Valid_hits = muon.globalTrack()->hitPattern().numberOfValidMuonHits();
57  } else if (muon.innerTrack().isNonnull()) {
58  norm_chi2 = muon.innerTrack()->normalizedChi2();
59  n_Valid_hits = muon.innerTrack()->hitPattern().numberOfValidMuonHits();
60  } else {
61  norm_chi2 = -99;
62  n_Valid_hits = -99;
63  }
64  const std::vector<std::string> input_names_{"float_input"};
65  std::vector<float> vars = {global_muon,
66  validFraction,
67  norm_chi2,
68  local_chi2,
69  kink,
70  segment_comp,
71  n_Valid_hits,
72  n_MatchedStations,
73  Valid_pixel,
74  tracker_layers,
75  pt,
76  eta};
77  const std::vector<std::string> flav_names_{"probBAD", "probGOOD"};
78  cms::Ort::FloatArrays input_values_;
79  input_values_.emplace_back(vars);
80  std::vector<float> outputs;
81  LogDebug("MuonMvaIDEstimator") << randomForest_.get();
82  outputs = randomForest_->run(input_names_, input_values_, {}, {"probabilities"})[0];
83  assert(outputs.size() == flav_names_.size());
84  return outputs;
85 }
std::vector< std::string > input_names_
std::vector< std::string > flav_names_
std::unique_ptr< const cms::Ort::ONNXRuntime > randomForest_
std::vector< std::vector< float > > FloatArrays
Definition: ONNXRuntime.h:23
assert(be >=bs)
const reco::Muon::ArbitrationType arbitrationType
vars
Definition: DeepTauId.cc:164
#define LogDebug(id)
void MuonMvaIDEstimator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 18 of file MuonMvaIDEstimator.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), and submitPVResolutionJobs::desc.

18  {
20  desc.add<edm::FileInPath>("mvaIDTrainingFile", edm::FileInPath("RecoMuon/MuonIdentification/data/mvaID.onnx"));
21  desc.add<std::vector<std::string>>("flav_names",
22  std::vector<std::string>{
23  "probBAD",
24  "probGOOD",
25  });
26 
27  descriptions.addWithDefaultLabel(desc);
28 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void MuonMvaIDEstimator::globalEndJob ( const cms::Ort::ONNXRuntime cache)
static

Definition at line 30 of file MuonMvaIDEstimator.cc.

30 {}

Member Data Documentation

std::vector<std::string> pat::MuonMvaIDEstimator::flav_names_
private

Definition at line 31 of file MuonMvaIDEstimator.h.

std::vector<std::string> pat::MuonMvaIDEstimator::input_names_
private

Definition at line 32 of file MuonMvaIDEstimator.h.

std::unique_ptr<const cms::Ort::ONNXRuntime> pat::MuonMvaIDEstimator::randomForest_
private

Definition at line 33 of file MuonMvaIDEstimator.h.