10#include <tracking/ckf/general/utilities/EigenHelper.h>
12#include <genfit/MeasuredStateOnPlane.h>
13#include <genfit/MeasurementOnPlane.h>
33 template <
unsigned int Dimension>
40 using HMatrix = Eigen::Matrix<double, Dimension, 5>;
48 double kalmanStep(genfit::MeasuredStateOnPlane& measuredStateOnPlane,
49 const genfit::MeasurementOnPlane& measurementOnPlane)
const
52 TrackState x_k = convertToEigen<5>(measuredStateOnPlane.getState());
53 TrackCovariance C_k = convertToEigen<5, 5>(measuredStateOnPlane.getCov());
56 const MeasurementState& m_k = convertToEigen<Dimension>(measurementOnPlane.getState());
57 const HMatrix& H_k = convertToEigen<Dimension, 5>(measurementOnPlane.getHMatrix()->getMatrix());
60 const double chi2 =
kalmanStep(x_k, C_k, m_k, V_k, H_k);
63 measuredStateOnPlane.setState(TVectorD(5, x_k.data()));
64 measuredStateOnPlane.setCov(TMatrixDSym(5, C_k.data()));
71 const genfit::MeasurementOnPlane& measurementOnPlane)
const
74 const TrackState& x_k = convertToEigen<5>(measuredStateOnPlane.getState());
77 const MeasurementState& m_k = convertToEigen<Dimension>(measurementOnPlane.getState());
78 const HMatrix& H_k = convertToEigen<Dimension, 5>(measurementOnPlane.getHMatrix()->getMatrix());
81 return residual.norm();
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);
96 const double chi2 = (residual.transpose() * (V_k - H_k * C_k * H_k.transpose()).inverse() * residual).value();
Class to bundle all algorithms needed for the kalman update procedure.
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...
Eigen::Matrix< double, Dimension, Dimension > MeasurementCovariance
Matrix class Dimension x Dimension.
Eigen::Matrix< double, Dimension, 1 > MeasurementState
Matrix class Dimension x 1.
double calculateResidual(const genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::MeasurementOnPlane &measurementOnPlane) const
Helper function to calculate a residual between the mSoP and the measurement.
Eigen::Matrix< double, Dimension, 5 > HMatrix
Matrix class Dimension x 5.
Eigen::Matrix< double, 5, 1 > TrackState
Matrix class 5 x 1.
Eigen::Matrix< double, 5, 5 > TrackCovariance
Matrix class 5 x 5.
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.
Abstract base class for different kinds of events.