Belle II Software light-2406-ragdoll
FitParams.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * External Contributor: Wouter Hulsbergen *
5 * *
6 * See git log for contributors and copyright holders. *
7 * This file is licensed under LGPL-3.0, see LICENSE.md. *
8 **************************************************************************/
9#pragma once
10
11#include <analysis/VertexFitting/TreeFitter/EigenStackConfig.h>
12#include <Eigen/Core>
13#include <vector>
14
15namespace TreeFitter {
16
17 class ParticleBase;
18
20 class FitParams {
21
22 public:
23
25 explicit FitParams(const int dim);
26
29
31 FitParams(const FitParams& toCopy)
32 : m_dim(toCopy.m_dim),
36 m_globalState(Eigen::Matrix < double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > (toCopy.m_globalState)),
37 m_globalCovariance(Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > (toCopy.m_globalCovariance))
38 { }
39
42 {
43 m_dim = other.m_dim;
49 return *this;
50 }
51
53 Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance()
54 {
55 return m_globalCovariance;
56 }
57
59 const Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance() const
60 {
61 return m_globalCovariance;
62 }
63
65 Eigen::Matrix < double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector() {return m_globalState;}
66
68 const Eigen::Matrix < double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector() const
69 {
70 return m_globalState;
71 }
72
74 void resetStateVector();
75
77 void resetCovariance();
78
80 int getDimensionOfState() const {return m_dim;};
81
83 bool testCovariance() const;
84
86 double chiSquare() const {return m_chiSquare;};
87
89 int nDof() const;
90
92 void addChiSquare(double chisq, int nconstraints)
93 {
94 m_chiSquare += chisq;
95 m_nConstraints += nconstraints;
96 }
97
100 {
101 m_chiSquare = 0;
102 m_nConstraints = 0;
103 }
104
106 typedef std::vector< std::pair<const ParticleBase*, int> > indexmap;
107
108 protected:
109
112
113 private:
114
116 int m_dim;
117
120
123
126
128 std::vector<int> m_nConstraintsVec;
129
131 Eigen::Matrix < double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState;
132
134 Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance;
135
136 };
137}
Class to store and manage fitparams (statevector)
Definition: FitParams.h:20
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState
vector holding all parameters of this fit
Definition: FitParams.h:131
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
Definition: FitParams.h:65
~FitParams()
Destructor.
Definition: FitParams.h:28
void addChiSquare(double chisq, int nconstraints)
increment global chi2
Definition: FitParams.h:92
int m_dim
dimension of statevector
Definition: FitParams.h:116
FitParams()
constructor
Definition: FitParams.h:111
std::vector< int > m_nConstraintsVec
vector with the number of constraints per parameter
Definition: FitParams.h:128
FitParams & operator=(const FitParams &other)
Assignment operator.
Definition: FitParams.h:41
bool testCovariance() const
test if the covariance makes sense
Definition: FitParams.cc:46
double chiSquare() const
get chi2 of statevector
Definition: FitParams.h:86
int nDof() const
get number of degrees of freedom
Definition: FitParams.cc:56
const Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance() const
const getter for the states covariance
Definition: FitParams.h:59
int getDimensionOfState() const
get the states dimension
Definition: FitParams.h:80
int m_dimensionReduction
reduce the ndf used in the chi2 by this count
Definition: FitParams.h:125
double m_chiSquare
chi2
Definition: FitParams.h:119
std::vector< std::pair< const ParticleBase *, int > > indexmap
index map
Definition: FitParams.h:106
void resetStateVector()
reset the statevector
Definition: FitParams.cc:31
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance()
getter for the states covariance
Definition: FitParams.h:53
void resetChiSquare()
reset chi2
Definition: FitParams.h:99
int m_nConstraints
number of constraints
Definition: FitParams.h:122
const Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector() const
const getter for the fit parameters/statevector
Definition: FitParams.h:68
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance
covariance of the global state
Definition: FitParams.h:134
void resetCovariance()
reset the statevector
Definition: FitParams.cc:36
FitParams(const FitParams &toCopy)
copy constructor
Definition: FitParams.h:31