Belle II Software development
KalmanStepper< Dimension > Class Template Reference

Class to bundle all algorithms needed for the kalman update procedure. More...

#include <KalmanStepper.h>

Public Member Functions

double kalmanStep (genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::MeasurementOnPlane &measurementOnPlane) const
 Kalman update of the mSoP using the measurement. Is just a wrapper around the other kalmanStepper working with bare matrices.
 
double calculateResidual (const genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::MeasurementOnPlane &measurementOnPlane) const
 Helper function to calculate a residual between the mSoP and the measurement.
 

Private Types

using MeasurementState = Eigen::Matrix< double, Dimension, 1 >
 Matrix class Dimension x 1.
 
using MeasurementCovariance = Eigen::Matrix< double, Dimension, Dimension >
 Matrix class Dimension x Dimension.
 
using HMatrix = Eigen::Matrix< double, Dimension, 5 >
 Matrix class Dimension x 5.
 
using TrackState = Eigen::Matrix< double, 5, 1 >
 Matrix class 5 x 1.
 
using TrackCovariance = Eigen::Matrix< double, 5, 5 >
 Matrix class 5 x 5.
 

Private Member Functions

double kalmanStep (TrackState &x_k, TrackCovariance &C_k, const MeasurementState &m_k, const MeasurementCovariance &V_k, const HMatrix &H_k) const
 This now is the real "update" step, where we update the X_k and the C_k.
 

Detailed Description

template<unsigned int Dimension>
class Belle2::KalmanStepper< Dimension >

Class to bundle all algorithms needed for the kalman update procedure.

Its main functionality is to update a measured state on plane with a measurement on plane from a hit using the Kalman procedure described in https://doi.org/10.1016/0168-9002(87)90887-4.

Template Parameters
DimensionThe dimension of the hit - e.g. how many Kalman state parameters are defined by the hits. This defines the size of the matrices.

Definition at line 34 of file KalmanStepper.h.

Member Typedef Documentation

◆ HMatrix

using HMatrix = Eigen::Matrix<double, Dimension, 5>
private

Matrix class Dimension x 5.

Definition at line 40 of file KalmanStepper.h.

◆ MeasurementCovariance

using MeasurementCovariance = Eigen::Matrix<double, Dimension, Dimension>
private

Matrix class Dimension x Dimension.

Definition at line 38 of file KalmanStepper.h.

◆ MeasurementState

using MeasurementState = Eigen::Matrix<double, Dimension, 1>
private

Matrix class Dimension x 1.

Definition at line 36 of file KalmanStepper.h.

◆ TrackCovariance

using TrackCovariance = Eigen::Matrix<double, 5, 5>
private

Matrix class 5 x 5.

Definition at line 44 of file KalmanStepper.h.

◆ TrackState

using TrackState = Eigen::Matrix<double, 5, 1>
private

Matrix class 5 x 1.

Definition at line 42 of file KalmanStepper.h.

Member Function Documentation

◆ calculateResidual()

double calculateResidual ( const genfit::MeasuredStateOnPlane &  measuredStateOnPlane,
const genfit::MeasurementOnPlane &  measurementOnPlane 
) const
inline

Helper function to calculate a residual between the mSoP and the measurement.

Definition at line 70 of file KalmanStepper.h.

72 {
73 // Extract matrices from the state
74 const TrackState& x_k = convertToEigen<5>(measuredStateOnPlane.getState());
75
76 // extract matrices from the measurement
77 const MeasurementState& m_k = convertToEigen<Dimension>(measurementOnPlane.getState());
78 const HMatrix& H_k = convertToEigen<Dimension, 5>(measurementOnPlane.getHMatrix()->getMatrix());
79
80 const MeasurementState& residual = m_k - H_k * x_k;
81 return residual.norm();
82 }
Eigen::Matrix< double, Dimension, 1 > MeasurementState
Matrix class Dimension x 1.
Definition: KalmanStepper.h:36
Eigen::Matrix< double, Dimension, 5 > HMatrix
Matrix class Dimension x 5.
Definition: KalmanStepper.h:40
Eigen::Matrix< double, 5, 1 > TrackState
Matrix class 5 x 1.
Definition: KalmanStepper.h:42

◆ kalmanStep() [1/2]

double kalmanStep ( genfit::MeasuredStateOnPlane &  measuredStateOnPlane,
const genfit::MeasurementOnPlane &  measurementOnPlane 
) const
inline

Kalman update of the mSoP using the measurement. Is just a wrapper around the other kalmanStepper working with bare matrices.

Definition at line 48 of file KalmanStepper.h.

50 {
51 // Extract matrices from the state
52 TrackState x_k = convertToEigen<5>(measuredStateOnPlane.getState());
53 TrackCovariance C_k = convertToEigen<5, 5>(measuredStateOnPlane.getCov());
54
55 // extract matrices from the measurement
56 const MeasurementState& m_k = convertToEigen<Dimension>(measurementOnPlane.getState());
57 const HMatrix& H_k = convertToEigen<Dimension, 5>(measurementOnPlane.getHMatrix()->getMatrix());
58 const MeasurementCovariance& V_k = convertToEigen<Dimension, Dimension>(measurementOnPlane.getCov());
59
60 const double chi2 = kalmanStep(x_k, C_k, m_k, V_k, H_k);
61
62 // set the state back
63 measuredStateOnPlane.setState(TVectorD(5, x_k.data()));
64 measuredStateOnPlane.setCov(TMatrixDSym(5, C_k.data()));
65
66 return chi2;
67 }
double kalmanStep(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::MeasurementOnPlane &measurementOnPlane) const
Kalman update of the mSoP using the measurement. Is just a wrapper around the other kalmanStepper wor...
Definition: KalmanStepper.h:48
Eigen::Matrix< double, Dimension, Dimension > MeasurementCovariance
Matrix class Dimension x Dimension.
Definition: KalmanStepper.h:38
Eigen::Matrix< double, 5, 5 > TrackCovariance
Matrix class 5 x 5.
Definition: KalmanStepper.h:44

◆ kalmanStep() [2/2]

double kalmanStep ( TrackState x_k,
TrackCovariance C_k,
const MeasurementState m_k,
const MeasurementCovariance V_k,
const HMatrix H_k 
) const
inlineprivate

This now is the real "update" step, where we update the X_k and the C_k.

Definition at line 86 of file KalmanStepper.h.

90 {
91 const Eigen::Matrix<double, 5, Dimension>& K_k = C_k * H_k.transpose() * (V_k + H_k * C_k * H_k.transpose()).inverse();
92 C_k -= K_k * H_k * C_k;
93 x_k += K_k * (m_k - H_k * x_k);
94
95 const MeasurementState& residual = m_k - H_k * x_k;
96 const double chi2 = (residual.transpose() * (V_k - H_k * C_k * H_k.transpose()).inverse() * residual).value();
97 return chi2;
98 }

The documentation for this class was generated from the following file: