Belle II Software  release-05-01-25
KalmanCalculator.h
1 /**************************************************************************
2 
3  * BASF2 (Belle Analysis Framework 2) *
4  * Copyright(C) 2013 - Belle II Collaboration *
5  * *
6  * Author: The Belle II Collaboration *
7  * Contributor: Wouter Hulsbergen, Francesco Tenchini, Jo-Frederik Krohn *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 #pragma once
12 
13 #include <analysis/VertexFitting/TreeFitter/EigenStackConfig.h>
14 
15 #include <analysis/VertexFitting/TreeFitter/FitParams.h>
16 #include <analysis/VertexFitting/TreeFitter/ErrCode.h>
17 
18 // inverse() needs this, in the other classes we get away with just Eigen/Core
19 #include <Eigen/Dense>
20 
21 
22 namespace TreeFitter {
23 
25  class KalmanCalculator {
26  public:
27 
30  int sizeRes,
31  int sizeState
32  );
33 
35  void updateState(FitParams& fitparams);
36 
38  void updateState(FitParams& fitparams, FitParams& oldState);
39 
41  void updateCovariance(FitParams& fitparams);
42 
44  double getChiSquare() { return m_chisq;}
45 
47  ErrCode calculateGainMatrix(
48  const Eigen::Matrix < double, -1, 1, 0, 5, 1 > & residuals,
49  const Eigen::Matrix < double, -1, -1, 0, 5, MAX_MATRIX_SIZE > & G,
50  const FitParams& fitparams,
51  const Eigen::Matrix < double, -1, -1, 0, 5, 5 > * V = 0,
52  double weight = 1);
53 
55  double chisq() const { return m_chisq ; }
56 
58  double getConstraintDim() { return m_constrDim; }
59 
60  private:
63 
65  double m_chisq;
66 
79  Eigen::Matrix < double, -1, 1, 0, 5, 1 > m_res;
80 
82  Eigen::Matrix < double, -1, -1, 0, 5, MAX_MATRIX_SIZE > m_G;
83 
85  Eigen::Matrix < double, -1, -1, 0, 5, 5 > m_R;
86 
88  Eigen::Matrix < double, -1, -1, 0, 5, 5 > m_Rinverse;
89 
91  Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, 5 > m_K;
92 
94  Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, 5 > m_CGt;
95 
96  };
97 }
TreeFitter::KalmanCalculator::m_chisq
double m_chisq
chi2
Definition: KalmanCalculator.h:83
TreeFitter::KalmanCalculator::chisq
double chisq() const
get chi2
Definition: KalmanCalculator.h:73
TreeFitter::KalmanCalculator::m_G
Eigen::Matrix< double, -1, -1, 0, 5, MAX_MATRIX_SIZE > m_G
G former H, transforms covraince of {residuals}<->{x,p,E}.
Definition: KalmanCalculator.h:100
TreeFitter::KalmanCalculator::KalmanCalculator
KalmanCalculator(int sizeRes, int sizeState)
constructor
Definition: KalmanCalculator.cc:23
TreeFitter::KalmanCalculator::m_constrDim
int m_constrDim
dimension of the constraint
Definition: KalmanCalculator.h:80
TreeFitter::KalmanCalculator::m_res
Eigen::Matrix< double, -1, 1, 0, 5, 1 > m_res
we know the max sizes of the matrices we assume the tree is smaller than MAX_MATRIX_SIZE parameters a...
Definition: KalmanCalculator.h:97
TreeFitter::KalmanCalculator::getConstraintDim
double getConstraintDim()
get dimension of the constraint
Definition: KalmanCalculator.h:76
TreeFitter::KalmanCalculator::m_CGt
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, 5 > m_CGt
C times G^t
Definition: KalmanCalculator.h:112
TreeFitter::KalmanCalculator::m_R
Eigen::Matrix< double, -1, -1, 0, 5, 5 > m_R
R residual covariance.
Definition: KalmanCalculator.h:103
TreeFitter::KalmanCalculator::m_Rinverse
Eigen::Matrix< double, -1, -1, 0, 5, 5 > m_Rinverse
R inverse.
Definition: KalmanCalculator.h:106
TreeFitter::KalmanCalculator::getChiSquare
double getChiSquare()
get chi2 of this iteration
Definition: KalmanCalculator.h:62
TreeFitter::KalmanCalculator::updateState
void updateState(FitParams &fitparams)
update statevector
Definition: KalmanCalculator.cc:74
TreeFitter::KalmanCalculator::updateCovariance
void updateCovariance(FitParams &fitparams)
update the statevectors covariance
Definition: KalmanCalculator.cc:90
TreeFitter::KalmanCalculator::m_K
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, 5 > m_K
K kalman gain matrix.
Definition: KalmanCalculator.h:109
TreeFitter::KalmanCalculator::calculateGainMatrix
ErrCode calculateGainMatrix(const Eigen::Matrix< double, -1, 1, 0, 5, 1 > &residuals, const Eigen::Matrix< double, -1, -1, 0, 5, MAX_MATRIX_SIZE > &G, const FitParams &fitparams, const Eigen::Matrix< double, -1, -1, 0, 5, 5 > *V=0, double weight=1)
init the kalman machienery
Definition: KalmanCalculator.cc:40