ATLAS Offline Software
SortSegmentsByNumberOfHits.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 SORTSEGMENTSBYNUMBEROFHITS_H
6 #define SORTSEGMENTSBYNUMBEROFHITS_H
7 
10 
11 namespace Muon {
12 
14  public:
15  bool operator()(const std::unique_ptr<MuonSegment>& seg1, const std::unique_ptr<MuonSegment>& seg2) {
16  unsigned int nhits1 = seg1->containedMeasurements().size();
17  unsigned int nhits2 = seg2->containedMeasurements().size();
18  if (nhits1 > nhits2) return true;
19  if (nhits1 < nhits2) return false;
20 
21  // prefer segments with fit quality (always expected)
22  const Trk::FitQuality* fq1 = seg1->fitQuality();
23  const Trk::FitQuality* fq2 = seg2->fitQuality();
24  if (!fq1 && fq2) return false;
25  if (fq1 && !fq2) return true;
26  if (!fq1 && !fq2) { return true; }
27 
28  if (fq1->numberDoF() > fq2->numberDoF()) return true;
29  if (fq1->numberDoF() < fq2->numberDoF()) return false;
30 
31  // select candidate with smallest chi2
32  double chi2Ndof1 = fq1->chiSquared() / fq1->numberDoF();
33  double chi2Ndof2 = fq2->chiSquared() / fq2->numberDoF();
34  return chi2Ndof1 < chi2Ndof2;
35  }
36  };
37 
38 } // namespace Muon
39 
40 #endif
Muon::SortSegmentsByNumberOfHits::operator()
bool operator()(const std::unique_ptr< MuonSegment > &seg1, const std::unique_ptr< MuonSegment > &seg2)
Definition: SortSegmentsByNumberOfHits.h:15
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
MuonSegment.h
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
Muon::SortSegmentsByNumberOfHits
Definition: SortSegmentsByNumberOfHits.h:13
FitQuality.h