ATLAS Offline Software
SortTracksByHitNumber.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef SORTTRACKSBYHITNUMBER_H
6 #define SORTTRACKSBYHITNUMBER_H
7 
8 #include <functional>
9 
11 #include "TrkTrack/Track.h"
12 
13 namespace Muon {
14 
16  public:
17  bool operator()(const Trk::Track* tr1, const Trk::Track* tr2) { return this->operator()(*tr1, *tr2); }
18 
19  bool operator()(const Trk::Track& tr1, const Trk::Track& tr2) {
20  // prefer tracks with fit quality (always expected)
21  const Trk::FitQuality* fq1 = tr1.fitQuality();
22  const Trk::FitQuality* fq2 = tr2.fitQuality();
23  if (!fq1 && fq2) return false;
24  if (fq1 && !fq2) return true;
25  if (!fq1 && !fq2) return false;
26 
27  if (fq1->numberDoF() > fq2->numberDoF()) return true;
28  if (fq1->numberDoF() < fq2->numberDoF()) return false;
29 
30  // select candidate with smallest chi2
31  double chi2Ndof1 = fq1->chiSquared() / fq1->numberDoF();
32  double chi2Ndof2 = fq2->chiSquared() / fq2->numberDoF();
33  return chi2Ndof1 < chi2Ndof2;
34  }
35  };
36 
38  public:
39  bool operator()(const Trk::Track* tr1, const Trk::Track* tr2) { return this->operator()(*tr1, *tr2); }
40 
41  bool operator()(const Trk::Track& tr1, const Trk::Track& tr2) {
42  // prefer tracks with fit quality (always expected)
43  const Trk::FitQuality* fq1 = tr1.fitQuality();
44  const Trk::FitQuality* fq2 = tr2.fitQuality();
45  if (!fq1 && fq2) return false;
46  if (fq1 && !fq2) return true;
47  if (!fq1 && !fq2) return false;
48 
49  // select candidate with smallest chi2
50  double chi2Ndof1 = fq1->chiSquared() / fq1->numberDoF();
51  double chi2Ndof2 = fq2->chiSquared() / fq2->numberDoF();
52  return chi2Ndof1 < chi2Ndof2;
53  }
54  };
55 } // namespace Muon
56 
57 #endif
Muon::SortTracksByChi2Ndof::operator()
bool operator()(const Trk::Track &tr1, const Trk::Track &tr2)
Definition: SortTracksByHitNumber.h:41
Trk::Track::fitQuality
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
MeasurementBase.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Muon::SortTracksByHitNumber::operator()
bool operator()(const Trk::Track &tr1, const Trk::Track &tr2)
Definition: SortTracksByHitNumber.h:19
Muon::SortTracksByHitNumber::operator()
bool operator()(const Trk::Track *tr1, const Trk::Track *tr2)
Definition: SortTracksByHitNumber.h:17
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Track.h
Muon::SortTracksByHitNumber
Definition: SortTracksByHitNumber.h:15
Muon::SortTracksByChi2Ndof::operator()
bool operator()(const Trk::Track *tr1, const Trk::Track *tr2)
Definition: SortTracksByHitNumber.h:39
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
Muon::SortTracksByChi2Ndof
Definition: SortTracksByHitNumber.h:37
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60