ATLAS Offline Software
FitProcedure.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // class FitProcedure
7 // Basic iterative least square fit procedure producing a fitted Track
8 //
9 // execute and constructTrack methods allow use from standard ITrackFitter
10 // and iPatRec specific Algtools.
11 // This class is kept transient rather than a tool as there are many state
12 // variables.
13 //
14 // for clarity (i.e. to avoid an overly long class) the inner loop over
15 // measurements is performed by MeasurementProcessor
16 //
18 
19 #ifndef TRKIPATFITTERUTILS_FITPROCEDURE_H
20 #define TRKIPATFITTERUTILS_FITPROCEDURE_H
21 
22 #include <vector>
23 
26 #include "GaudiKernel/ToolHandle.h"
31 
32 class MsgStream;
33 
34 namespace Trk {
35 class FitMeasurement;
36 class FitParameters;
37 class IIntersector;
38 class IPropagator;
39 class Track;
40 class TrackInfo;
41 class TrackStateOnSurface;
42 class Volume;
43 
44 class FitProcedure {
45  public:
46  // Cache to be passed by the caller
47  struct Cache {
49  : chRatio1(0.),
50  chRatio2(0.),
51  chiSq(0.),
52  chiSqCut(20.),
53  chiSqMin(0.),
54  chiSqOld(0.),
55  chiSqWorst(0.),
56  convergence(false),
57  cutStep(false),
58  cutTaken(0),
59  debug(false),
60  driftSum(0.),
61  driftSumLast(0.),
64  fitProbability(0.),
65  fitQuality(nullptr),
66  iteration(0),
67  log(nullptr),
68  nearConvergence(false),
69  nCuts(0),
70  numberDoF(0),
72  verbose(false),
73  worstMeasurement(0) {}
74  ~Cache() = default;
75  // delete the rest as should not be needed.
76  Cache(const Cache&) = delete;
77  Cache& operator=(const Cache&) = delete;
78  Cache(Cache&&) = delete;
79  Cache& operator=(Cache&&) = delete;
80 
81  double chRatio1 = 0;
82  double chRatio2 = 0;
83  double chiSq = 0;
84  double chiSqCut = 20;
85  double chiSqMin = 0;
86  double chiSqOld = 0;
87  double chiSqWorst = 0;
88  bool convergence = false;
89  bool cutStep = 0;
90  int cutTaken = false;
91  bool debug = false;
92  double driftSum = 0;
93  double driftSumLast = 0;
94  std::unique_ptr<FitMatrices> fitMatrices = nullptr;
95  double fitProbability = 0;
96  std::unique_ptr<FitProcedureQuality> fitQuality = nullptr;
97  int iteration = 0;
98  MsgStream* log = nullptr;
99  bool nearConvergence = false;
100  int nCuts = 0;
101  int numberDoF = 0;
103  bool verbose = false;
105  };
106 
107  FitProcedure(bool constrainedAlignmentEffects, bool extendedDebug,
108  bool lineFit, ToolHandle<IIntersector>& rungeKuttaIntersector,
109  ToolHandle<IIntersector>& solenoidalIntersector,
110  ToolHandle<IIntersector>& straightLineIntersector,
111  const ToolHandle<IPropagator>& stepPropagator,
112  const Volume* indetVolume = 0, int maxIterations = 25,
113  int useStepPropagator = 0);
114 
115  ~FitProcedure(void) = default; // destructor
116  // forbidden copy constructor
117  // forbidden assignment operator
118 
119  // clean up memory (after fit completion)
120  static void clear(FitProcedure::Cache& cache);
121 
122  // retrieve result
123  static Track* constructTrack(
124  FitProcedure::Cache& cache,
125  const std::vector<FitMeasurement*>& measurements,
127  const DataVector<const TrackStateOnSurface>* leadingTSOS = nullptr);
128 
129  // perform fit procedure
131  bool asymmetricCaloEnergy, MsgStream& log,
132  std::vector<FitMeasurement*>& measurements,
134  const FitQuality* perigeeQuality = 0,
135  bool for_iPatTrack = false) const;
136 
137  // for IGlobalTrackFit interface
138  static Amg::MatrixX* fullCovariance();
139 
140  // set minimum number of iterations to perform (IGlobalTrackFit friends)
141  void setMinIterations(int minIter);
142 
145  }
146 
147  private:
148  // copy, assignment: no semantics, no implementation
149  FitProcedure(const FitProcedure&) = delete;
153 
155  std::vector<FitMeasurement*>& measurements) const;
156 
157  const ToolHandle<IIntersector>& chooseIntersector(
158  std::vector<FitMeasurement*>& measurements,
159  const FitParameters& parameters) const;
160 
161  static void reportQuality(FitProcedure::Cache& cache,
162  const std::vector<FitMeasurement*>& measurements,
163  const FitParameters& parameters);
164 
170  bool m_lineFit;
173  double m_minPt;
174  ToolHandle<IIntersector>& m_rungeKuttaIntersector;
175  const ToolHandle<IIntersector>& m_solenoidalIntersector;
176  ToolHandle<IIntersector>& m_straightLineIntersector;
177  const ToolHandle<IPropagator>& m_stepPropagator;
179 };
180 } // namespace Trk
181 
182 #endif // TRKIPATFITTERUTILS_FITPROCEDURE_H
Trk::FitProcedure::Cache::~Cache
~Cache()=default
Trk::TrackInfo
Contains information about the 'fitter' of this track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:32
Trk::FitProcedure::Cache::Cache
Cache(const Cache &)=delete
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Trk::FitProcedure::m_largeRadius
double m_largeRadius
Definition: FitProcedure.h:169
Trk::FitProcedure::Cache::operator=
Cache & operator=(Cache &&)=delete
Trk::FitProcedure::Cache::log
MsgStream * log
Definition: FitProcedure.h:98
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
Trk::FitProcedure::m_straightLineIntersector
ToolHandle< IIntersector > & m_straightLineIntersector
Definition: FitProcedure.h:176
Trk::FitProcedure::m_stepPropagator
const ToolHandle< IPropagator > & m_stepPropagator
Definition: FitProcedure.h:177
Trk::FitProcedure::Cache::fitQuality
std::unique_ptr< FitProcedureQuality > fitQuality
Definition: FitProcedure.h:96
Trk::FitProcedure::Cache::fitProbability
double fitProbability
Definition: FitProcedure.h:95
Trk::FitProcedure::Cache::worstMeasurement
int worstMeasurement
Definition: FitProcedure.h:104
Trk::FitProcedure::Cache::chiSqMin
double chiSqMin
Definition: FitProcedure.h:85
Trk::FitProcedure::setMinIterations
void setMinIterations(int minIter)
Definition: FitProcedure.cxx:652
Trk::FitProcedure::execute
const FitProcedureQuality & execute(FitProcedure::Cache &cache, bool asymmetricCaloEnergy, MsgStream &log, std::vector< FitMeasurement * > &measurements, FitParameters *&parameters, const FitQuality *perigeeQuality=0, bool for_iPatTrack=false) const
Definition: FitProcedure.cxx:330
Trk::FitProcedure::m_minPt
double m_minPt
Definition: FitProcedure.h:173
Trk::FitProcedure::FitProcedure
FitProcedure(const FitProcedure &)=delete
Trk::FitProcedure::Cache::convergence
bool convergence
Definition: FitProcedure.h:88
Trk::FitProcedure::clear
static void clear(FitProcedure::Cache &cache)
Definition: FitProcedure.cxx:73
Trk::FitProcedure::Cache::cutTaken
int cutTaken
Definition: FitProcedure.h:90
Trk::FitProcedure::Cache
Definition: FitProcedure.h:47
Trk::FitProcedure::Cache::chiSqCut
double chiSqCut
Definition: FitProcedure.h:84
Trk::FitProcedureQuality
Definition: FitProcedureQuality.h:19
Trk::FitProcedure::Cache::nCuts
int nCuts
Definition: FitProcedure.h:100
Trk::FitProcedure
Definition: FitProcedure.h:44
Trk::FitProcedure::m_lineFit
bool m_lineFit
Definition: FitProcedure.h:170
Trk::FitProcedure::Cache::numberDoF
int numberDoF
Definition: FitProcedure.h:101
Trk::FitProcedure::Cache::cutStep
bool cutStep
Definition: FitProcedure.h:89
Trk::FitProcedure::m_extremeOneOverP
double m_extremeOneOverP
Definition: FitProcedure.h:167
Trk::FitProcedure::Cache::chRatio2
double chRatio2
Definition: FitProcedure.h:82
Trk::FitProcedure::m_indetVolume
const Trk::Volume * m_indetVolume
Definition: FitProcedure.h:168
Trk::FitProcedure::Cache::nearConvergence
bool nearConvergence
Definition: FitProcedure.h:99
Trk::FitProcedure::m_extendedDebug
bool m_extendedDebug
Definition: FitProcedure.h:166
Trk::FitProcedure::Cache::driftSum
double driftSum
Definition: FitProcedure.h:92
Trk::FitProcedure::m_useStepPropagator
int m_useStepPropagator
Definition: FitProcedure.h:178
Trk::FitProcedure::Cache::driftSumLast
double driftSumLast
Definition: FitProcedure.h:93
FitMatrices.h
Trk::FitMatrices
Definition: FitMatrices.h:41
Trk::FitProcedure::Cache::debug
bool debug
Definition: FitProcedure.h:91
Trk::FitProcedure::Cache::numberParameters
int numberParameters
Definition: FitProcedure.h:102
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
Trk::FitProcedure::Cache::chiSq
double chiSq
Definition: FitProcedure.h:83
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ParticleHypothesis.h
trackInfo
Definition: TrigInDetUtils.h:13
Trk::FitProcedure::reportQuality
static void reportQuality(FitProcedure::Cache &cache, const std::vector< FitMeasurement * > &measurements, const FitParameters &parameters)
Definition: FitProcedure.cxx:814
Trk::FitProcedure::FitProcedure
FitProcedure(FitProcedure &&)=delete
EventPrimitives.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::FitProcedure::Cache::chiSqOld
double chiSqOld
Definition: FitProcedure.h:86
Trk::FitProcedure::m_constrainedAlignmentEffects
bool m_constrainedAlignmentEffects
Definition: FitProcedure.h:165
Trk::FitProcedure::constructTrack
static Track * constructTrack(FitProcedure::Cache &cache, const std::vector< FitMeasurement * > &measurements, FitParameters &parameters, const TrackInfo &trackInfo, const DataVector< const TrackStateOnSurface > *leadingTSOS=nullptr)
Definition: FitProcedure.cxx:77
Trk::FitProcedure::Cache::chiSqWorst
double chiSqWorst
Definition: FitProcedure.h:87
Trk::FitProcedure::m_rungeKuttaIntersector
ToolHandle< IIntersector > & m_rungeKuttaIntersector
Definition: FitProcedure.h:174
Trk::FitProcedure::m_solenoidalIntersector
const ToolHandle< IIntersector > & m_solenoidalIntersector
Definition: FitProcedure.h:175
Trk::FitProcedure::m_maxIter
int m_maxIter
Definition: FitProcedure.h:171
Trk::FitProcedure::Cache::operator=
Cache & operator=(const Cache &)=delete
FitProcedureQuality.h
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
Trk::FitProcedure::FitProcedure
FitProcedure(bool constrainedAlignmentEffects, bool extendedDebug, bool lineFit, ToolHandle< IIntersector > &rungeKuttaIntersector, ToolHandle< IIntersector > &solenoidalIntersector, ToolHandle< IIntersector > &straightLineIntersector, const ToolHandle< IPropagator > &stepPropagator, const Volume *indetVolume=0, int maxIterations=25, int useStepPropagator=0)
Definition: FitProcedure.cxx:48
Trk::FitProcedure::chooseIntersector
const ToolHandle< IIntersector > & chooseIntersector(std::vector< FitMeasurement * > &measurements, const FitParameters &parameters) const
Definition: FitProcedure.cxx:789
Trk::FitProcedure::fullCovariance
static Amg::MatrixX * fullCovariance()
Definition: FitProcedure.cxx:646
Trk::FitProcedure::Cache::iteration
int iteration
Definition: FitProcedure.h:97
Trk::FitProcedure::operator=
FitProcedure & operator=(FitProcedure &&)=delete
Trk::FitProcedure::Cache::Cache
Cache(Cache &&)=delete
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::FitProcedure::m_minIter
int m_minIter
Definition: FitProcedure.h:172
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
Trk::FitProcedure::operator=
FitProcedure & operator=(const FitProcedure &)=delete
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
Trk::FitProcedure::Cache::fitMatrices
std::unique_ptr< FitMatrices > fitMatrices
Definition: FitProcedure.h:94
Trk::FitParameters
Definition: FitParameters.h:29
Trk::FitProcedure::~FitProcedure
~FitProcedure(void)=default
FitQuality.h
Trk::FitProcedure::calculateChiSq
void calculateChiSq(FitProcedure::Cache &cache, std::vector< FitMeasurement * > &measurements) const
Definition: FitProcedure.cxx:658
Trk::Volume
Definition: Volume.h:35
Trk::FitProcedure::Cache::chRatio1
double chRatio1
Definition: FitProcedure.h:81
Trk::FitProcedure::Cache::verbose
bool verbose
Definition: FitProcedure.h:103
Trk::FitProcedure::Cache::Cache
Cache(bool constrainedAlignmentEffects)
Definition: FitProcedure.h:48
Trk::FitProcedure::constrainedAlignmentEffects
bool constrainedAlignmentEffects() const
Definition: FitProcedure.h:143