CMS 3D CMS Logo

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

#include <SoftMuonMvaEstimator.h>

Public Member Functions

float computeMva (const pat::Muon &imuon) const
 
 SoftMuonMvaEstimator (const edm::FileInPath &weightsfile)
 
 ~SoftMuonMvaEstimator ()
 

Private Attributes

std::unique_ptr< const GBRForestgbrForest_
 

Detailed Description

Definition at line 18 of file SoftMuonMvaEstimator.h.

Constructor & Destructor Documentation

SoftMuonMvaEstimator::SoftMuonMvaEstimator ( const edm::FileInPath weightsfile)

Definition at line 12 of file SoftMuonMvaEstimator.cc.

References createGBRForest(), and gbrForest_.

12  {
13  gbrForest_ = createGBRForest(weightsfile);
14 }
std::unique_ptr< const GBRForest > gbrForest_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
SoftMuonMvaEstimator::~SoftMuonMvaEstimator ( )

Definition at line 16 of file SoftMuonMvaEstimator.cc.

16 {}

Member Function Documentation

float SoftMuonMvaEstimator::computeMva ( const pat::Muon imuon) const

Definition at line 42 of file SoftMuonMvaEstimator.cc.

References reco::MuonQuality::chi2LocalMomentum, reco::MuonQuality::chi2LocalPosition, reco::Muon::combinedQuality(), reco::LeafCandidate::eta(), gbrForest_, reco::HitPattern::getHitPattern(), reco::HitPattern::getMuonStation(), reco::MuonQuality::glbKink, reco::MuonQuality::glbTrackProbability, pat::Muon::globalTrack(), mps_fire::i, pat::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), JetComb::kEta, kPt, reco::HitPattern::muonCSCHitFilter(), reco::HitPattern::muonDTHitFilter(), reco::HitPattern::muonRPCHitFilter(), reco::HitPattern::numberOfAllHits(), pat::Muon::outerTrack(), reco::LeafCandidate::pt(), pat::Muon::segmentCompatibility(), relativeConstraints::station, reco::Muon::time(), reco::MuonTime::timeAtIpInOutErr, reco::HitPattern::TRACK_HITS, reco::MuonQuality::trkKink, reco::MuonQuality::trkRelChi2, reco::HitPattern::validHitFilter(), and trigObjTnPSource_cfi::var.

42  {
43  float var[kLast]{};
44 
45  reco::TrackRef gTrack = muon.globalTrack();
46  reco::TrackRef iTrack = muon.innerTrack();
47  reco::TrackRef oTrack = muon.outerTrack();
48 
49  if (!(muon.innerTrack().isNonnull() and muon.outerTrack().isNonnull() and muon.globalTrack().isNonnull())) {
50  return -1;
51  }
52 
53  //VARIABLE EXTRACTION
54  var[kPt] = muon.pt();
55  var[kEta] = muon.eta();
56  var[kMomID] = -1;
57  var[kPID] = -1;
58 
59  var[kChi2LocalMomentum] = muon.combinedQuality().chi2LocalMomentum;
60  var[kChi2LocalPosition] = muon.combinedQuality().chi2LocalPosition;
61  var[kGlbTrackProbability] = muon.combinedQuality().glbTrackProbability;
62  var[kTrkRelChi2] = muon.combinedQuality().trkRelChi2;
63 
64  var[kTrkKink] = muon.combinedQuality().trkKink;
65  var[kLog2PlusGlbKink] = TMath::Log(2 + muon.combinedQuality().glbKink);
66  var[kSegmentCompatibility] = muon.segmentCompatibility();
67 
68  var[kTimeAtIpInOutErr] = muon.time().timeAtIpInOutErr;
69 
70  //TRACK RELATED VARIABLES
71 
72  var[kIValidFraction] = iTrack->validFraction();
73  var[kInnerChi2] = iTrack->normalizedChi2();
74  var[kLayersWithMeasurement] = iTrack->hitPattern().trackerLayersWithMeasurement();
75 
76  var[kOuterChi2] = oTrack->normalizedChi2();
77 
78  var[kQProd] = iTrack->charge() * oTrack->charge();
79 
80  //vComb Calculation
81 
82  const reco::HitPattern& gMpattern = gTrack->hitPattern();
83 
84  std::vector<int> fvDThits{0, 0, 0, 0};
85  std::vector<int> fvRPChits{0, 0, 0, 0};
86  std::vector<int> fvCSChits{0, 0, 0, 0};
87 
88  var[kVMuonHitComb] = 0;
89 
90  for (int i = 0; i < gMpattern.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++) {
91  uint32_t hit = gMpattern.getHitPattern(reco::HitPattern::TRACK_HITS, i);
92  if (!gMpattern.validHitFilter(hit))
93  continue;
94 
95  int muStation0 = gMpattern.getMuonStation(hit) - 1;
96  if (muStation0 >= 0 && muStation0 < 4) {
97  if (gMpattern.muonDTHitFilter(hit))
98  fvDThits[muStation0]++;
99  if (gMpattern.muonRPCHitFilter(hit))
100  fvRPChits[muStation0]++;
101  if (gMpattern.muonCSCHitFilter(hit))
102  fvCSChits[muStation0]++;
103  }
104  }
105 
106  for (unsigned int station = 0; station < 4; ++station) {
107  var[kVMuonHitComb] += (fvDThits[station]) / 2.;
108  var[kVMuonHitComb] += fvRPChits[station];
109 
110  if (fvCSChits[station] > 6) {
111  var[kVMuonHitComb] += 6;
112  } else {
113  var[kVMuonHitComb] += fvCSChits[station];
114  }
115  }
116 
117  if (var[kChi2LocalMomentum] < 5000 and var[kChi2LocalPosition] < 2000 and var[kGlbTrackProbability] < 5000 and
118  var[kTrkKink] < 900 and var[kLog2PlusGlbKink] < 50 and var[kTimeAtIpInOutErr] < 4 and var[kOuterChi2] < 1000 and
119  var[kInnerChi2] < 10 and var[kTrkRelChi2] < 3) {
120  return gbrForest_->GetAdaBoostClassifier(var);
121  } else {
122  return -1;
123  }
124 }
example_track example_track const char *const kPt
Definition: TSelector.cc:34
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:766
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:633
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:774
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:625
std::unique_ptr< const GBRForest > gbrForest_
static uint16_t getMuonStation(uint16_t pattern)
Muon station (1-4). Only valid for muon patterns, of course. only for patterns from muon...
Definition: HitPattern.h:733
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:531
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:641

Member Data Documentation

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

Definition at line 27 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and SoftMuonMvaEstimator().