CMS 3D CMS Logo

TrackSelection.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 
6 //#define EDM_ML_DEBUG
7 
8 namespace spr {
9 
10  bool goodTrack(const reco::Track* pTrack,
11  math::XYZPoint leadPV,
13  bool
14 #ifdef EDM_ML_DEBUG
15  debug
16 #endif
17  ) {
18 
19  bool select = pTrack->quality(parameters.minQuality);
20  double dxy = pTrack->dxy(leadPV);
21  double dz = pTrack->dz(leadPV);
22  double dpbyp = 999;
23  if (std::abs(pTrack->qoverp()) > 0.0000001)
24  dpbyp = std::abs(pTrack->qoverpError() / pTrack->qoverp());
25 
26 #ifdef EDM_ML_DEBUG
27  if (debug)
28  std::cout << "Track:: Pt " << pTrack->pt() << " dxy " << dxy << " dz " << dz << " Chi2 "
29  << pTrack->normalizedChi2() << " dpbyp " << dpbyp << " Quality " << select << std::endl;
30 #endif
31  if (pTrack->pt() < parameters.minPt)
32  select = false;
33  if (dxy > parameters.maxDxyPV || dz > parameters.maxDzPV)
34  select = false;
35  if (pTrack->normalizedChi2() > parameters.maxChi2)
36  select = false;
37  if (dpbyp > parameters.maxDpOverP)
38  select = false;
39 
40  if (parameters.minLayerCrossed > 0 || parameters.minOuterHit > 0) {
41  const reco::HitPattern& hitp = pTrack->hitPattern();
42  if (parameters.minLayerCrossed > 0 && hitp.trackerLayersWithMeasurement() < parameters.minLayerCrossed)
43  select = false;
44  if (parameters.minOuterHit > 0 &&
46  select = false;
47 #ifdef EDM_ML_DEBUG
48  if (debug) {
49  std::cout << "Default Hit Pattern with " << hitp.numberOfAllHits(reco::HitPattern::TRACK_HITS) << " hits"
50  << std::endl;
51  for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++)
53  }
54 #endif
55  }
56  if (parameters.maxInMiss >= 0) {
57  const reco::HitPattern& hitp = pTrack->hitPattern();
59  select = false;
60 #ifdef EDM_ML_DEBUG
61  if (debug) {
62  std::cout << "Inner Hit Pattern with " << hitp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS) << " hits"
63  << std::endl;
64  for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i++)
66  }
67 #endif
68  }
69  if (parameters.maxOutMiss >= 0) {
70  const reco::HitPattern& hitp = pTrack->hitPattern();
72  select = false;
73 #ifdef EDM_ML_DEBUG
74  if (debug) {
75  std::cout << "Outer Hit Pattern with " << hitp.numberOfAllHits(reco::HitPattern::MISSING_OUTER_HITS) << " hits"
76  << std::endl;
77  for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::MISSING_OUTER_HITS); i++)
79  }
80 #endif
81  }
82 #ifdef EDM_ML_DEBUG
83  if (debug)
84  std::cout << "Final Selection Result " << select << std::endl;
85 #endif
86  return select;
87  }
88 } // namespace spr
double qoverp() const
q / p
Definition: TrackBase.h:578
int stripTOBLayersWithMeasurement() const
Definition: HitPattern.cc:597
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:572
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:513
void printHitPattern(HitCategory category, int position, std::ostream &stream) const
Definition: HitPattern.cc:803
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
double pt() const
track transverse momentum
Definition: TrackBase.h:602
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:774
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:693
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:596
#define debug
Definition: HDRShower.cc:19
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:483
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:531
select
when omitted electron plots will be filled w/o cut on electronId electronId = cms.PSet( src = cms.InputTag("mvaTrigV0"), cutValue = cms.double(0.5) ), when omitted electron plots will be filled w/o additional pre- selection of the electron candidates
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:532
reco::TrackBase::TrackQuality minQuality
#define EDM_ML_DEBUG
int stripTECLayersWithMeasurement() const
Definition: HitPattern.cc:607
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:587