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, math::XYZPoint leadPV,
12 #ifdef EDM_ML_DEBUG
13  debug
14 #endif
15  ) {
16 
17  bool select = pTrack->quality(parameters.minQuality);
18  double dxy = pTrack->dxy(leadPV);
19  double dz = pTrack->dz(leadPV);
20  double dpbyp = 999;
21  if (std::abs(pTrack->qoverp()) > 0.0000001)
22  dpbyp = std::abs(pTrack->qoverpError()/pTrack->qoverp());
23 
24 #ifdef EDM_ML_DEBUG
25  if (debug) std::cout << "Track:: Pt " << pTrack->pt() << " dxy " << dxy << " dz " << dz << " Chi2 " << pTrack->normalizedChi2() << " dpbyp " << dpbyp << " Quality " << select << std::endl;
26 #endif
27  if (pTrack->pt() < parameters.minPt) select = false;
28  if (dxy > parameters.maxDxyPV || dz > parameters.maxDzPV) select = false;
29  if (pTrack->normalizedChi2() > parameters.maxChi2) select = false;
30  if (dpbyp > parameters.maxDpOverP) select = false;
31 
32  if (parameters.minLayerCrossed>0 || parameters.minOuterHit>0) {
33  const reco::HitPattern& hitp = pTrack->hitPattern();
34  if (parameters.minLayerCrossed>0 && hitp.trackerLayersWithMeasurement() < parameters.minLayerCrossed) select = false;
35  if (parameters.minOuterHit>0 && (hitp.stripTOBLayersWithMeasurement()+hitp.stripTECLayersWithMeasurement() ) < parameters.minOuterHit) select = false;
36 #ifdef EDM_ML_DEBUG
37  if (debug) {
38  std::cout << "Default Hit Pattern with " << hitp.numberOfHits(reco::HitPattern::TRACK_HITS) << " hits" << std::endl;
39  for (int i=0; i<hitp.numberOfHits(reco::HitPattern::TRACK_HITS); i++)
41  }
42 #endif
43  }
44  if (parameters.maxInMiss >= 0) {
45  const reco::HitPattern& hitp = pTrack->hitPattern();
47 #ifdef EDM_ML_DEBUG
48  if (debug) {
49  std::cout << "Inner Hit Pattern with " << hitp.numberOfHits(reco::HitPattern::MISSING_INNER_HITS) << " hits" << std::endl;
52  }
53 #endif
54  }
55  if (parameters.maxOutMiss >= 0) {
56  const reco::HitPattern& hitp = pTrack->hitPattern();
58 #ifdef EDM_ML_DEBUG
59  if (debug) {
60  std::cout << "Outer Hit Pattern with " << hitp.numberOfHits(reco::HitPattern::MISSING_OUTER_HITS) << " hits" << std::endl;
63  }
64 #endif
65  }
66 #ifdef EDM_ML_DEBUG
67  if (debug) std::cout << "Final Selection Result " << select << std::endl;
68 #endif
69  return select;
70  }
71 }
double qoverp() const
q / p
Definition: TrackBase.h:568
int stripTOBLayersWithMeasurement() const
Definition: HitPattern.cc:598
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:556
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:512
void printHitPattern(HitCategory category, int position, std::ostream &stream) const
Definition: HitPattern.cc:826
#define EDM_ML_DEBUG
Definition: MPUnpacker.cc:1
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
double pt() const
track transverse momentum
Definition: TrackBase.h:616
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:752
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:604
#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:445
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:505
int trackerLayersWithoutMeasurement(HitCategory category) const
Definition: HitPattern.cc:529
reco::TrackBase::TrackQuality minQuality
int stripTECLayersWithMeasurement() const
Definition: HitPattern.cc:609
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:586
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:807