11#include <gtest/gtest.h>
13#include "analysis/VertexFitting/TreeFitter/FitParams.h"
14#include "analysis/VertexFitting/TreeFitter/KalmanCalculator.h"
19 class TreeFitterKalmanCalculatorTest :
public ::testing::Test {
24 TEST_F(TreeFitterKalmanCalculatorTest, Functions)
29 fitParDim6.getStateVector() << Eigen::Matrix<double, 6, 1>::Zero(6, 1);
31 fitParDim6.getCovariance() = 2 * Eigen::Matrix<double, 6, 6>::Identity(6, 6);
33 Eigen::Matrix<double, 3, 6> G;
36 G << 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1;
38 const Eigen::Matrix<double, 3, 6>& c_G = G;
48 Eigen::Matrix<double, 3, 1> residuals;
50 residuals << .1, .2, .3;
51 const Eigen::Matrix<double, 3, 1>& c_r = residuals;
53 kalman.calculateGainMatrix(c_r, c_G, fitParDim6,
nullptr, 0);
55 kalman.updateState(fitParDim6);
57 Eigen::Matrix<double, 6, 1> expectedUpdatedFitpars;
59 expectedUpdatedFitpars << -0.05, -0.1, -0.15, -0.05, -0.1, -0.15;
61 EXPECT_TRUE(expectedUpdatedFitpars.isApprox(fitParDim6.getStateVector().segment(0, 6))) <<
"fitpar update failed.";
63 Eigen::Matrix<double, 6, 6> expectedUpdatedCov = Eigen::Matrix<double, 6, 6>::Identity(6, 6);
65 expectedUpdatedCov.diagonal < -3 > () << -1, -1, -1;
67 expectedUpdatedCov.diagonal<3>() << -1, -1, -1;
69 kalman.updateCovariance(fitParDim6);
70 Eigen::Matrix<double, 6, 6> updatedCov = fitParDim6.getCovariance().selfadjointView<Eigen::Lower>();
73 EXPECT_TRUE(updatedCov.isApprox(expectedUpdatedCov)) <<
"covariance update failed.";
Class to store and manage fitparams (statevector)
does the calculation of the gain matrix, updates the cov and fitpars