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 std::string &weightsfile)
 
 ~SoftMuonMvaEstimator ()
 

Private Attributes

float chi2LocalMomentum_ = 0.0
 
float chi2LocalPosition_ = 0.0
 
float eta_ = 0.0
 
std::unique_ptr< const GBRForestgbrForest_
 
float glbTrackProbability_ = 0.0
 
float innerChi2_ = 0.0
 
float iValidFraction_ = 0.0
 
float layersWithMeasurement_ = 0.0
 
float log2PlusGlbKink_ = 0.0
 
float momID_ = 0.0
 
float outerChi2_ = 0.0
 
float pID_ = 0.0
 
float pt_ = 0.0
 
float qProd_ = 0.0
 
float segmentCompatibility_ = 0.0
 
float timeAtIpInOutErr_ = 0.0
 
float trkKink_ = 0.0
 
float trkRelChi2_ = 0.0
 
float vMuonHitComb_ = 0.0
 

Detailed Description

Definition at line 14 of file SoftMuonMvaEstimator.h.

Constructor & Destructor Documentation

SoftMuonMvaEstimator::SoftMuonMvaEstimator ( const std::string &  weightsfile)

Definition at line 18 of file SoftMuonMvaEstimator.cc.

References chi2LocalMomentum_, chi2LocalPosition_, eta_, gbrForest_, glbTrackProbability_, innerChi2_, iValidFraction_, layersWithMeasurement_, log2PlusGlbKink_, momID_, outerChi2_, pID_, pt_, qProd_, segmentCompatibility_, groupFilesInBlocks::temp, timeAtIpInOutErr_, trkKink_, trkRelChi2_, and vMuonHitComb_.

19 {
20  TMVA::Reader tmvaReader("!Color:!Silent:Error");
21  tmvaReader.AddVariable("segComp", &segmentCompatibility_);
22  tmvaReader.AddVariable("chi2LocMom", &chi2LocalMomentum_);
23  tmvaReader.AddVariable("chi2LocPos", &chi2LocalPosition_);
24  tmvaReader.AddVariable("glbTrackTailProb", &glbTrackProbability_);
25  tmvaReader.AddVariable("iValFrac", &iValidFraction_);
26  tmvaReader.AddVariable("LWH", &layersWithMeasurement_);
27  tmvaReader.AddVariable("kinkFinder", &trkKink_);
28  tmvaReader.AddVariable("TMath::Log(2+glbKinkFinder)", &log2PlusGlbKink_);
29  tmvaReader.AddVariable("timeAtIpInOutErr", &timeAtIpInOutErr_);
30  tmvaReader.AddVariable("outerChi2", &outerChi2_);
31  tmvaReader.AddVariable("innerChi2", &innerChi2_);
32  tmvaReader.AddVariable("trkRelChi2", &trkRelChi2_);
33  tmvaReader.AddVariable("vMuonHitComb", &vMuonHitComb_);
34  tmvaReader.AddVariable("Qprod", &qProd_);
35 
36  tmvaReader.AddSpectator("pID", &pID_);
37  tmvaReader.AddSpectator("pt", &pt_);
38  tmvaReader.AddSpectator("eta", &eta_);
39  tmvaReader.AddSpectator("MomID", &momID_);
40 
41  auto temp{ tmvaReader.BookMVA(softmuon_mva_name, weightsfile.c_str()) };
42  gbrForest_ = std::make_unique<GBRForest>( dynamic_cast<TMVA::MethodBDT*>( temp ) );
43 }
std::unique_ptr< const GBRForest > gbrForest_
SoftMuonMvaEstimator::~SoftMuonMvaEstimator ( )

Definition at line 45 of file SoftMuonMvaEstimator.cc.

45 { }

Member Function Documentation

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

Definition at line 71 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.

72 {
73  float var[kLast]{};
74 
75  reco::TrackRef gTrack = muon.globalTrack();
76  reco::TrackRef iTrack = muon.innerTrack();
77  reco::TrackRef oTrack = muon.outerTrack();
78 
79  if(!(muon.innerTrack().isNonnull() and
80  muon.outerTrack().isNonnull() and
81  muon.globalTrack().isNonnull()))
82  {
83  return -1;
84  }
85 
86  //VARIABLE EXTRACTION
87  var[kPt] = muon.pt();
88  var[kEta] = muon.eta();
89  var[kMomID] = -1;
90  var[kPID] = -1;
91 
92  var[kChi2LocalMomentum] = muon.combinedQuality().chi2LocalMomentum;
93  var[kChi2LocalPosition] = muon.combinedQuality().chi2LocalPosition;
94  var[kGlbTrackProbability] = muon.combinedQuality().glbTrackProbability;
95  var[kTrkRelChi2] = muon.combinedQuality().trkRelChi2;
96 
97  var[kTrkKink] = muon.combinedQuality().trkKink;
98  var[kLog2PlusGlbKink] = TMath::Log(2+muon.combinedQuality().glbKink);
99  var[kSegmentCompatibility] = muon.segmentCompatibility();
100 
101  var[kTimeAtIpInOutErr] = muon.time().timeAtIpInOutErr;
102 
103  //TRACK RELATED VARIABLES
104 
105  var[kIValidFraction] = iTrack->validFraction();
106  var[kInnerChi2] = iTrack->normalizedChi2();
107  var[kLayersWithMeasurement] = iTrack->hitPattern().trackerLayersWithMeasurement();
108 
109  var[kOuterChi2] = oTrack->normalizedChi2();
110 
111  var[kQProd] = iTrack->charge()*oTrack->charge();
112 
113  //vComb Calculation
114 
115  const reco::HitPattern &gMpattern = gTrack->hitPattern();
116 
117  std::vector<int> fvDThits = {0,0,0,0};
118  std::vector<int> fvRPChits = {0,0,0,0};
119  std::vector<int> fvCSChits = {0,0,0,0};
120 
121  var[kVMuonHitComb] = 0;
122 
123  for (int i=0;i<gMpattern.numberOfAllHits(reco::HitPattern::TRACK_HITS);i++){
124 
125  uint32_t hit = gMpattern.getHitPattern(reco::HitPattern::TRACK_HITS, i);
126  if ( !gMpattern.validHitFilter(hit) ) continue;
127 
128  int muStation0 = gMpattern.getMuonStation(hit) - 1;
129  if (muStation0 >=0 && muStation0 < 4){
130  if (gMpattern.muonDTHitFilter(hit)) fvDThits[muStation0]++;
131  if (gMpattern.muonRPCHitFilter(hit)) fvRPChits[muStation0]++;
132  if (gMpattern.muonCSCHitFilter(hit)) fvCSChits[muStation0]++;
133  }
134 
135  }
136 
137 
138  for (unsigned int station = 0; station < 4; ++station) {
139 
140  var[kVMuonHitComb] += (fvDThits[station])/2.;
141  var[kVMuonHitComb] += fvRPChits[station];
142 
143  if (fvCSChits[station] > 6){
144  var[kVMuonHitComb] += 6;
145  }else{
146  var[kVMuonHitComb] += fvCSChits[station];
147  }
148 
149  }
150 
151  if(var[kChi2LocalMomentum] < 5000 and var[kChi2LocalPosition] < 2000 and
152  var[kGlbTrackProbability] < 5000 and var[kTrkKink] < 900 and
153  var[kLog2PlusGlbKink] < 50 and var[kTimeAtIpInOutErr] < 4 and
154  var[kOuterChi2] < 1000 and var[kInnerChi2] < 10 and var[kTrkRelChi2] < 3)
155  {
156  return gbrForest_->GetAdaBoostClassifier(var);
157  } else {
158  return -1;
159  }
160 }
example_track example_track const char *const kPt
Definition: TSelector.cc:34
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:788
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:641
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:808
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:631
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:743
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:516
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:651

Member Data Documentation

float pat::SoftMuonMvaEstimator::chi2LocalMomentum_ = 0.0
private

Definition at line 29 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::chi2LocalPosition_ = 0.0
private

Definition at line 30 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::eta_ = 0.0
private

Definition at line 46 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

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

Definition at line 25 of file SoftMuonMvaEstimator.h.

Referenced by computeMva(), and SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::glbTrackProbability_ = 0.0
private

Definition at line 31 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::innerChi2_ = 0.0
private

Definition at line 38 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::iValidFraction_ = 0.0
private

Definition at line 32 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::layersWithMeasurement_ = 0.0
private

Definition at line 33 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::log2PlusGlbKink_ = 0.0
private

Definition at line 35 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::momID_ = 0.0
private

Definition at line 47 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::outerChi2_ = 0.0
private

Definition at line 37 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::pID_ = 0.0
private

Definition at line 44 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::pt_ = 0.0
private

Definition at line 45 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::qProd_ = 0.0
private

Definition at line 41 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::segmentCompatibility_ = 0.0
private

Definition at line 28 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::timeAtIpInOutErr_ = 0.0
private

Definition at line 36 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::trkKink_ = 0.0
private

Definition at line 34 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::trkRelChi2_ = 0.0
private

Definition at line 39 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().

float pat::SoftMuonMvaEstimator::vMuonHitComb_ = 0.0
private

Definition at line 40 of file SoftMuonMvaEstimator.h.

Referenced by SoftMuonMvaEstimator().