CMS 3D CMS Logo

SoftMuonMvaEstimator.cc
Go to the documentation of this file.
2 
9 
10 using namespace pat;
11 
13 {
14  gbrForest_ = createGBRForest( weightsfile );
15 }
16 
18 
19 namespace {
20  enum inputIndexes {
21  kSegmentCompatibility,
22  kChi2LocalMomentum,
23  kChi2LocalPosition,
24  kGlbTrackProbability,
25  kIValidFraction,
26  kLayersWithMeasurement,
27  kTrkKink,
28  kLog2PlusGlbKink,
29  kTimeAtIpInOutErr,
30  kOuterChi2,
31  kInnerChi2,
32  kTrkRelChi2,
33  kVMuonHitComb,
34  kQProd,
35  kPID,
36  kPt,
37  kEta,
38  kMomID,
39  kLast
40  };
41 }
42 
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 }
float chi2LocalPosition
chi2 value for the STA-TK matching of local position
Definition: MuonQuality.h:19
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double eta() const final
momentum pseudorapidity
float chi2LocalMomentum
chi2 value for the STA-TK matching of local momentum
Definition: MuonQuality.h:21
example_track example_track const char *const kPt
Definition: TSelector.cc:34
float glbKink
value of the kink algorithm applied to the global track
Definition: MuonQuality.h:13
float glbTrackProbability
the tail probability (-ln(P)) of the global fit
Definition: MuonQuality.h:29
double pt() const final
transverse momentum
float trkKink
value of the kink algorithm applied to the inner track stub
Definition: MuonQuality.h:11
float trkRelChi2
chi2 value for the inner track stub with respect to the global track
Definition: MuonQuality.h:15
MuonTime time() const
get DT/CSC combined timing information
Definition: Muon.h:131
Definition: HeavyIon.h:7
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:855
inputIndexes
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
reco::TrackRef outerTrack() const override
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.h:76
static bool muonCSCHitFilter(uint16_t pattern)
Definition: HitPattern.h:678
float timeAtIpInOutErr
Definition: MuonTime.h:15
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:875
MuonQuality combinedQuality() const
get energy deposition information
Definition: Muon.h:121
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:80
SoftMuonMvaEstimator(const edm::FileInPath &weightsfile)
static bool muonDTHitFilter(uint16_t pattern)
Definition: HitPattern.h:668
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:801
float computeMva(const pat::Muon &imuon) const
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:553
static bool muonRPCHitFilter(uint16_t pattern)
Definition: HitPattern.h:688
Analysis-level muon class.
Definition: Muon.h:51
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)