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_.

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

Definition at line 17 of file SoftMuonMvaEstimator.cc.

17 { }

Member Function Documentation

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

Definition at line 43 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 JetChargeProducer_cfi::var.

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

Member Data Documentation

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

Definition at line 29 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and SoftMuonMvaEstimator().