ATLAS Offline Software
Loading...
Searching...
No Matches
KalmanUpdatorSMatrix.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// KalmanUpdatorSMatrix.h
7// Header file for Kalman Fitter Updator
9// (c) ATLAS Detector software
11// Markus.Elsing@cern.ch, Wolfgang.Liebig@cern.ch
13
14#ifndef TRK_KALMANUPDATORSMATRIX_H
15#define TRK_KALMANUPDATORSMATRIX_H
16
17
22// Eigen/Amg
24// ROOT SMatrix lin alg: for internal calculations
25#include "Math/SMatrix.h"
26#include "Math/SVector.h"
27#include <cmath>
28#include <string_view>
29
30typedef ROOT::Math::SMatrix<double, 1, 1, ROOT::Math::MatRepSym<double, 1>>
32typedef ROOT::Math::SMatrix<double, 2, 2, ROOT::Math::MatRepSym<double, 2>>
34typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3>>
36typedef ROOT::Math::SMatrix<double, 4, 4, ROOT::Math::MatRepSym<double, 4>>
38typedef ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepSym<double, 5>>
40typedef ROOT::Math::SMatrix<double, 2, 2, ROOT::Math::MatRepStd<double, 2, 2>>
42typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepStd<double, 3, 3>>
44typedef ROOT::Math::SMatrix<double, 4, 4, ROOT::Math::MatRepStd<double, 4, 4>>
46typedef ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepStd<double, 5, 5>>
48typedef ROOT::Math::SVector<double, 2> SParVector2;
49typedef ROOT::Math::SVector<double, 3> SParVector3;
50typedef ROOT::Math::SVector<double, 4> SParVector4;
51typedef ROOT::Math::SVector<double, 5> SParVector5;
52
53namespace Trk {
54
60
75 : virtual public IUpdator
76 , public AthAlgTool
77{
78public:
80 KalmanUpdatorSMatrix(const std::string&,
81 const std::string&,
82 const IInterface*);
84
86 virtual StatusCode initialize() override;
88 virtual StatusCode finalize() override;
89
92 // fails: @copydoc Trk::IUpdator::addToState(const TrackParameters&, const
93 // Amg::Vector2D&, const Amg::MatrixX&)
94 virtual std::unique_ptr<TrackParameters> addToState(
95 const TrackParameters&,
96 const Amg::Vector2D&,
97 const Amg::MatrixX&) const override final;
100 virtual std::unique_ptr<TrackParameters> addToState(
101 const TrackParameters&,
102 const LocalParameters&,
103 const Amg::MatrixX&) const override final;
106 virtual std::unique_ptr<TrackParameters> addToState(
107 const TrackParameters&,
108 const Amg::Vector2D&,
109 const Amg::MatrixX&,
110 FitQualityOnSurface*&) const override final;
113 virtual std::unique_ptr<TrackParameters> addToState(
114 const TrackParameters&,
115 const LocalParameters&,
116 const Amg::MatrixX&,
117 FitQualityOnSurface*&) const override final;
118
121 virtual std::unique_ptr<TrackParameters> removeFromState(
122 const TrackParameters&,
123 const Amg::Vector2D&,
124 const Amg::MatrixX&) const override final;
127 virtual std::unique_ptr<TrackParameters> removeFromState(
128 const TrackParameters&,
129 const LocalParameters&,
130 const Amg::MatrixX&) const override final;
133 virtual std::unique_ptr<TrackParameters> removeFromState(
134 const TrackParameters&,
135 const Amg::Vector2D&,
136 const Amg::MatrixX&,
137 FitQualityOnSurface*&) const override final;
140 virtual std::unique_ptr<TrackParameters> removeFromState(
141 const TrackParameters&,
142 const LocalParameters&,
143 const Amg::MatrixX&,
144 FitQualityOnSurface*&) const override final;
145
152
153 virtual std::unique_ptr<TrackParameters> combineStates(
154 const TrackParameters&,
155 const TrackParameters&) const override final;
162 virtual std::unique_ptr<TrackParameters> combineStates(
163 const TrackParameters&,
164 const TrackParameters&,
165 FitQualityOnSurface*&) const override final;
166
170 const TrackParameters&,
171 const Amg::Vector2D&,
172 const Amg::MatrixX&) const override final;
176 const TrackParameters&,
177 const LocalParameters&,
178 const Amg::MatrixX&) const override final;
182 const TrackParameters&,
183 const Amg::Vector2D&,
184 const Amg::MatrixX&) const override final;
188 const TrackParameters&,
189 const LocalParameters&,
190 const Amg::MatrixX&) const override final;
195 const TrackParameters&,
196 const TrackParameters&) const override final;
199 const AmgVector(5) &,
200 const AmgSymMatrix(5) &,
201 const Amg::VectorX&,
202 const Amg::MatrixX&,
203 int,
205 bool) const override final
206 {
207 return nullptr;
208 }
209
211 virtual std::vector<double> initialErrors() const override final;
212
213private:
218 const Amg::MatrixX&,
219 const int,
221 bool) const;
228 double,
229 int,
230 const Amg::MatrixX&,
231 const int,
233 bool) const;
241 int,
242 const Amg::MatrixX&,
243 const int,
245 bool) const;
253 const Amg::MatrixX&,
254 const int,
256 bool) const;
264 const Amg::MatrixX&,
265 const int,
267 bool) const;
271
278 const Amg::MatrixX&,
279 const int,
281 bool) const;
282
290 int,
291 bool,
292 std::string_view) const;
303 double,
304 double,
305 int,
306 int) const;
311 int,
312 int) const;
317 int) const;
320 const Amg::MatrixX&,
321 const Amg::MatrixX&,
322 int) const;
323
329 static SCovMatrix2 projection_2D(const Amg::MatrixX&, int) ;
336
337 // === note: any of the following log... method is only called if
338 // the msgstream level has been set appropriately.
340 void logStart(const std::string&, const TrackParameters&) const;
343 const Amg::VectorX&,
344 const Amg::MatrixX&) const;
346 void logGainForm(int,
351 void logResult(const std::string&,
352 const AmgVector(5) &,
354
357
359
367
370
373
378
384
387};
388inline bool
390 const RangeCheckDef rcd) const
391{
392 static const SParVector2 thetaMin(0.0, -M_PI);
393 return ((std::abs(V(Trk::phi)) <= M_PI) &&
394 (V(Trk::theta) >= thetaMin((int)rcd)) && (V(Trk::theta) <= M_PI));
395}
396
397inline bool
399{
400 return (V(Trk::theta) >= 0.0 && (V(Trk::theta) <= M_PI));
401}
402
403} // end of namespace
404
405#endif // TRK_KALMANUPDATOR_H
#define M_PI
#define AmgSymMatrix(dim)
#define AmgVector(rows)
ROOT::Math::SVector< double, 3 > SParVector3
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > SCovMatrix2
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepStd< double, 4, 4 > > SGenMatrix4
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > SCovMatrix5
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > SGenMatrix5
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > SCovMatrix3
ROOT::Math::SMatrix< double, 1, 1, ROOT::Math::MatRepSym< double, 1 > > SCovMatrix1
ROOT::Math::SVector< double, 2 > SParVector2
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > SGenMatrix3
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > SCovMatrix4
ROOT::Math::SVector< double, 5 > SParVector5
ROOT::Math::SVector< double, 4 > SParVector4
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > SGenMatrix2
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Set of interfaces for methods operating on track states, mainly for Kalman filtering.
Definition IUpdator.h:64
std::unique_ptr< TrackParameters > calculateFilterStep_4D(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, const LocalParameters &, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common maths calculation code for all addToState and removeFromState versions which happen to be call...
virtual FitQualityOnSurface fullStateFitQuality(const TrackParameters &, const Amg::Vector2D &, const Amg::MatrixX &) const override final
estimator for FitQuality on Surface from a full track state, that is a state which contains the curre...
bool thetaPhiWithinRange_5D(const SParVector5 &V, const RangeCheckDef rcd) const
Test if angles are inside boundaries.
std::unique_ptr< TrackParameters > calculateFilterStep_1D(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, double, int, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common maths calculation code for all addToState and removeFromState versions which happen to be call...
static const ParamDefsAccessor s_enumAccessor
std::unique_ptr< TrackParameters > calculateFilterStep_5D(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, const SParVector5 &, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common maths calculation code for all addToState and removeFromState versions which happen to be call...
void logGainForm(int, const SParVector5 &, const SCovMatrix5 &, const SGenMatrix5 &) const
internal structuring: common logfile output during calculation
virtual FitQualityOnSurface predictedStateFitQuality(const TrackParameters &, const Amg::Vector2D &, const Amg::MatrixX &) const override final
estimator for FitQuality on Surface from a predicted track state, that is a state which contains the ...
SCovMatrix5 m_unitMatrix
avoid mem allocation at every call
bool getStartCov(SCovMatrix5 &, const TrackParameters &, const int) const
Helper method to transform Eigen cov matrix to SMatrix.
FitQualityOnSurface makeChi2_2D(const SParVector5 &, const AmgSymMatrix(5)&, const SParVector2 &, const SCovMatrix2 &, int, int) const
virtual StatusCode initialize() override
AlgTool initialisation.
FitQualityOnSurface makeChi2Object(const Amg::VectorX &, const AmgSymMatrix(5)&, const Amg::MatrixX &, const Amg::MatrixX &, int) const
std::unique_ptr< TrackParameters > convertToClonedTrackPars(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, int, bool, std::string_view) const
Helper method to convert internal results from SMatrix to Eigen. *‍/.
virtual std::vector< double > initialErrors() const override final
give back how updator is configured for inital covariances
std::unique_ptr< TrackParameters > calculateFilterStep_2D(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, const SParVector2 &, int, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common maths calculation code for all addToState and removeFromState versions which happen to be call...
virtual std::unique_ptr< TrackParameters > addToState(const TrackParameters &, const Amg::Vector2D &, const Amg::MatrixX &) const override final
measurement updator for the KalmanFitter getting the meas't coord' from Amg::Vector2D (use eg with PR...
static SCovMatrix3 projection_3D(const SCovMatrix5 &, int)
Avoid multiplications with sparse H matrices by cutting 3D rows&columns out of the full cov matrix.
virtual StatusCode finalize() override
AlgTool termination.
bool thetaWithinRange_5D(const SParVector5 &V) const
Test if theta angle is inside boundaries. No differential-check option.
virtual std::unique_ptr< TrackParameters > removeFromState(const TrackParameters &, const Amg::Vector2D &, const Amg::MatrixX &) const override final
reverse update eg for track property analysis (unbiased residuals) getting the measurement coordinate...
bool correctThetaPhiRange_5D(SParVector5 &, SCovMatrix5 &, const RangeCheckDef) const
method correcting the calculated angles back to their defined ranges phi (-pi, pi) and theta (0,...
virtual std::unique_ptr< TrackParameters > combineStates(const TrackParameters &, const TrackParameters &) const override final
trajectory state updator which combines two parts of a trajectory on a common surface.
std::unique_ptr< TrackParameters > prepareFilterStep(const TrackParameters &, const LocalParameters &, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common code analysing the measurement's rank and calling the appropriate implementation for this rank...
KalmanUpdatorSMatrix(const std::string &, const std::string &, const IInterface *)
AlgTool standard constuctor.
SParVector5 m_cov0
initial cov values in SMatrix object
void logResult(const std::string &, const AmgVector(5) &, const AmgSymMatrix(5) &) const
internal structuring: common logfile output after calculation
static SCovMatrix2 projection_2D(const SCovMatrix5 &, int)
Avoid multiplications with sparse H matrices by cutting 2D rows&columns out of the full cov matrix.
bool m_useFruehwirth8a
job options controlling update formula for covariance matrix
void logInputCov(const SCovMatrix5 &, const Amg::VectorX &, const Amg::MatrixX &) const
internal structuring: common logfile output of the inputs
virtual std::pair< AmgVector(5), AmgSymMatrix(5)> * updateParameterDifference(const AmgVector(5) &, const AmgSymMatrix(5) &, const Amg::VectorX &, const Amg::MatrixX &, int, Trk::FitQualityOnSurface *&, bool) const override final
interface for reference-track KF, not implemented
std::unique_ptr< TrackParameters > calculateFilterStep_3D(const TrackParameters &, const SParVector5 &, const SCovMatrix5 &, const LocalParameters &, const Amg::MatrixX &, const int, FitQualityOnSurface *&, bool) const
common maths calculation code for all addToState and removeFromState versions which happen to be call...
std::vector< double > m_cov_stdvec
job options for initial cov values
static SCovMatrix4 projection_4D(const SCovMatrix5 &, int)
Avoid multiplications with sparse H matrices by cutting 4D rows&columns out of the full cov matrix.
FitQualityOnSurface makeChi2_5D(const SParVector5 &, const AmgSymMatrix(5)&, const SParVector5 &, const AmgSymMatrix(5)&, int) const
FitQualityOnSurface makeChi2_1D(const SParVector5 &, const AmgSymMatrix(5)&, double, double, int, int) const
also the chi2 calculation and FitQuality object creation is combined in an extra method.
bool consistentParamDimensions(const LocalParameters &, int) const
method testing correct use of LocalParameters
void logStart(const std::string &, const TrackParameters &) const
internal structuring: debugging output for start of method.
STL class.
Definition of ATLAS Math & Geometry primitives (Amg)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.
@ theta
Definition ParamDefs.h:66
@ phi
Definition ParamDefs.h:75
ParametersBase< TrackParametersDim, Charged > TrackParameters
AmgSymMatrix(5) &GXFTrackState
STL namespace.
Simple struct to access the ParamDefs enum with ints.
Definition ParamDefs.h:92
#define private