CMS 3D CMS Logo

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

#include <SoftMuonMvaEstimator.h>

Public Member Functions

void computeMva (const pat::Muon &imuon)
 
void initialize (std::string weightsfile)
 
float mva () const
 
 SoftMuonMvaEstimator ()
 

Private Attributes

float chi2LocalMomentum_
 
float chi2LocalPosition_
 
float dummy_
 
float eta_
 
float glbTrackProbability_
 
bool initialized_
 
float innerChi2_
 
float iValidFraction_
 
float layersWithMeasurement_
 
float log2PlusGlbKink_
 
float momID_
 
float mva_
 
float outerChi2_
 
float pID_
 
float pt_
 
float qProd_
 
float segmentCompatibility_
 
float timeAtIpInOutErr_
 
TMVA::Reader tmvaReader_
 
float trkKink_
 
float trkRelChi2_
 
float vMuonHitComb_
 

Detailed Description

Definition at line 8 of file SoftMuonMvaEstimator.h.

Constructor & Destructor Documentation

SoftMuonMvaEstimator::SoftMuonMvaEstimator ( )

Definition at line 7 of file SoftMuonMvaEstimator.cc.

7  :
8  tmvaReader_("!Color:!Silent:Error"),
9  initialized_(false),
10  mva_(0)
11 {}

Member Function Documentation

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

Definition at line 40 of file SoftMuonMvaEstimator.cc.

References reco::MuonQuality::chi2LocalMomentum, chi2LocalMomentum_, reco::MuonQuality::chi2LocalPosition, chi2LocalPosition_, reco::Muon::combinedQuality(), dummy_, reco::LeafCandidate::eta(), eta_, Exception, reco::HitPattern::getHitPattern(), reco::HitPattern::getMuonStation(), reco::MuonQuality::glbKink, reco::MuonQuality::glbTrackProbability, glbTrackProbability_, pat::Muon::globalTrack(), mps_fire::i, initialized_, innerChi2_, pat::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), iValidFraction_, layersWithMeasurement_, log2PlusGlbKink_, momID_, reco::HitPattern::muonCSCHitFilter(), reco::HitPattern::muonDTHitFilter(), reco::HitPattern::muonRPCHitFilter(), mva_, reco::HitPattern::numberOfAllHits(), outerChi2_, pat::Muon::outerTrack(), pID_, reco::LeafCandidate::pt(), pt_, qProd_, pat::Muon::segmentCompatibility(), segmentCompatibility_, relativeConstraints::station, reco::Muon::time(), reco::MuonTime::timeAtIpInOutErr, timeAtIpInOutErr_, tmvaReader_, reco::HitPattern::TRACK_HITS, reco::MuonQuality::trkKink, trkKink_, reco::MuonQuality::trkRelChi2, trkRelChi2_, reco::HitPattern::validHitFilter(), and vMuonHitComb_.

Referenced by pat::PATMuonProducer::produce().

41 {
42  if (not initialized_)
43  throw cms::Exception("FatalError") << "SoftMuonMVA is not initialized";
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
50  muon.outerTrack().isNonnull() and
51  muon.globalTrack().isNonnull()))
52  {
53  mva_ = -1;
54  return;
55  }
56 
57  //VARIABLE EXTRACTION
58  pt_ = muon.pt();
59  eta_ = muon.eta();
60  dummy_ = -1;
61  momID_ = dummy_;
62  pID_ = dummy_;
63 
64 
65  chi2LocalMomentum_ = muon.combinedQuality().chi2LocalMomentum;
66  chi2LocalPosition_ = muon.combinedQuality().chi2LocalPosition;
67  glbTrackProbability_ = muon.combinedQuality().glbTrackProbability;
68  trkRelChi2_ = muon.combinedQuality().trkRelChi2;
69 
70  trkKink_ = muon.combinedQuality().trkKink;
71  log2PlusGlbKink_ = TMath::Log(2+muon.combinedQuality().glbKink);
72  segmentCompatibility_ = muon.segmentCompatibility();
73 
74  timeAtIpInOutErr_ = muon.time().timeAtIpInOutErr;
75 
76  //TRACK RELATED VARIABLES
77 
78  iValidFraction_ = iTrack->validFraction();
79  innerChi2_ = iTrack->normalizedChi2();
80  layersWithMeasurement_ = iTrack->hitPattern().trackerLayersWithMeasurement();
81 
82  outerChi2_ = oTrack->normalizedChi2();
83 
84  qProd_ = iTrack->charge()*oTrack->charge();
85 
86  //vComb Calculation
87 
88  const reco::HitPattern &gMpattern = gTrack->hitPattern();
89 
90  std::vector<int> fvDThits = {0,0,0,0};
91  std::vector<int> fvRPChits = {0,0,0,0};
92  std::vector<int> fvCSChits = {0,0,0,0};
93 
94  vMuonHitComb_ = 0;
95 
96  for (int i=0;i<gMpattern.numberOfAllHits(reco::HitPattern::TRACK_HITS);i++){
97 
98  uint32_t hit = gMpattern.getHitPattern(reco::HitPattern::TRACK_HITS, i);
99  if ( !gMpattern.validHitFilter(hit) ) continue;
100 
101  int muStation0 = gMpattern.getMuonStation(hit) - 1;
102  if (muStation0 >=0 && muStation0 < 4){
103  if (gMpattern.muonDTHitFilter(hit)) fvDThits[muStation0]++;
104  if (gMpattern.muonRPCHitFilter(hit)) fvRPChits[muStation0]++;
105  if (gMpattern.muonCSCHitFilter(hit)) fvCSChits[muStation0]++;
106  }
107 
108  }
109 
110 
111  for (unsigned int station = 0; station < 4; ++station) {
112 
113  vMuonHitComb_ += (fvDThits[station])/2.;
114  vMuonHitComb_ += fvRPChits[station];
115 
116  if (fvCSChits[station] > 6){
117  vMuonHitComb_ += 6;
118  }else{
119  vMuonHitComb_ += fvCSChits[station];
120  }
121 
122  }
123 
124  if(chi2LocalMomentum_ < 5000 and chi2LocalPosition_ < 2000 and
125  glbTrackProbability_ < 5000 and trkKink_ < 900 and
126  log2PlusGlbKink_ < 50 and timeAtIpInOutErr_ < 4 and
127  outerChi2_ < 1000 and innerChi2_ < 10 and trkRelChi2_ < 3)
128  {
129  mva_ = tmvaReader_.EvaluateMVA("BDT");
130  }else{ mva_ = -1; }
131 
132 }
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:787
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:640
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:807
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:630
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:742
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:650
void SoftMuonMvaEstimator::initialize ( std::string  weightsfile)

Definition at line 13 of file SoftMuonMvaEstimator.cc.

References chi2LocalMomentum_, chi2LocalPosition_, eta_, glbTrackProbability_, initialized_, innerChi2_, iValidFraction_, layersWithMeasurement_, log2PlusGlbKink_, momID_, outerChi2_, pID_, pt_, qProd_, segmentCompatibility_, timeAtIpInOutErr_, tmvaReader_, trkKink_, trkRelChi2_, and vMuonHitComb_.

Referenced by pat::PATMuonProducer::PATMuonProducer().

14 {
15  if (initialized_) return;
16  tmvaReader_.AddVariable("segComp", &segmentCompatibility_);
17  tmvaReader_.AddVariable("chi2LocMom", &chi2LocalMomentum_);
18  tmvaReader_.AddVariable("chi2LocPos", &chi2LocalPosition_);
19  tmvaReader_.AddVariable("glbTrackTailProb", &glbTrackProbability_);
20  tmvaReader_.AddVariable("iValFrac", &iValidFraction_);
21  tmvaReader_.AddVariable("LWH", &layersWithMeasurement_);
22  tmvaReader_.AddVariable("kinkFinder", &trkKink_);
23  tmvaReader_.AddVariable("TMath::Log(2+glbKinkFinder)", &log2PlusGlbKink_);
24  tmvaReader_.AddVariable("timeAtIpInOutErr", &timeAtIpInOutErr_);
25  tmvaReader_.AddVariable("outerChi2", &outerChi2_);
26  tmvaReader_.AddVariable("innerChi2", &innerChi2_);
27  tmvaReader_.AddVariable("trkRelChi2", &trkRelChi2_);
28  tmvaReader_.AddVariable("vMuonHitComb", &vMuonHitComb_);
29  tmvaReader_.AddVariable("Qprod", &qProd_);
30 
31  tmvaReader_.AddSpectator("pID", &pID_);
32  tmvaReader_.AddSpectator("pt", &pt_);
33  tmvaReader_.AddSpectator("eta", &eta_);
34  tmvaReader_.AddSpectator("MomID", &momID_);
35 
36  tmvaReader_.BookMVA("BDT", weightsfile);
37  initialized_ = true;
38 }
float pat::SoftMuonMvaEstimator::mva ( ) const
inline

Definition at line 13 of file SoftMuonMvaEstimator.h.

References mva_.

Referenced by pat::PATMuonProducer::produce().

Member Data Documentation

float pat::SoftMuonMvaEstimator::chi2LocalMomentum_
private

Definition at line 28 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::chi2LocalPosition_
private

Definition at line 29 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::dummy_
private

Definition at line 24 of file SoftMuonMvaEstimator.h.

Referenced by computeMva().

float pat::SoftMuonMvaEstimator::eta_
private

Definition at line 22 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::glbTrackProbability_
private

Definition at line 30 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

bool pat::SoftMuonMvaEstimator::initialized_
private

Definition at line 16 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::innerChi2_
private

Definition at line 37 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::iValidFraction_
private

Definition at line 31 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::layersWithMeasurement_
private

Definition at line 32 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::log2PlusGlbKink_
private

Definition at line 34 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::momID_
private

Definition at line 23 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::mva_
private

Definition at line 17 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and mva().

float pat::SoftMuonMvaEstimator::outerChi2_
private

Definition at line 36 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::pID_
private

Definition at line 20 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::pt_
private

Definition at line 21 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::qProd_
private

Definition at line 40 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::segmentCompatibility_
private

Definition at line 27 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::timeAtIpInOutErr_
private

Definition at line 35 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

TMVA::Reader pat::SoftMuonMvaEstimator::tmvaReader_
private

Definition at line 15 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::trkKink_
private

Definition at line 33 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::trkRelChi2_
private

Definition at line 38 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().

float pat::SoftMuonMvaEstimator::vMuonHitComb_
private

Definition at line 39 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and initialize().