Belle II Software light-2406-ragdoll
FitParams Class Reference

Class to store and manage fitparams (statevector) More...

#include <FitParams.h>

Collaboration diagram for FitParams:

Public Types

typedef std::vector< std::pair< const ParticleBase *, int > > indexmap
 index map
 

Public Member Functions

 FitParams (const int dim)
 Constructor.
 
 ~FitParams ()
 Destructor.
 
 FitParams (const FitParams &toCopy)
 copy constructor
 
FitParamsoperator= (const FitParams &other)
 Assignment operator.
 
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance ()
 getter for the states covariance
 
const Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance () const
 const getter for the states covariance
 
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector ()
 getter for the fit parameters/statevector
 
const Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector () const
 const getter for the fit parameters/statevector
 
void resetStateVector ()
 reset the statevector
 
void resetCovariance ()
 reset the statevector
 
int getDimensionOfState () const
 get the states dimension
 
bool testCovariance () const
 test if the covariance makes sense
 
double chiSquare () const
 get chi2 of statevector
 
int nDof () const
 get number of degrees of freedom
 
void addChiSquare (double chisq, int nconstraints)
 increment global chi2
 
void resetChiSquare ()
 reset chi2
 

Protected Member Functions

 FitParams ()
 constructor

 

Private Attributes

int m_dim
 dimension of statevector
 
double m_chiSquare
 chi2
 
int m_nConstraints
 number of constraints
 
int m_dimensionReduction
 reduce the ndf used in the chi2 by this count
 
std::vector< int > m_nConstraintsVec
 vector with the number of constraints per parameter
 
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState
 vector holding all parameters of this fit
 
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance
 covariance of the global state
 

Detailed Description

Class to store and manage fitparams (statevector)

Definition at line 20 of file FitParams.h.

Member Typedef Documentation

◆ indexmap

typedef std::vector< std::pair<const ParticleBase*, int> > indexmap

index map

Definition at line 106 of file FitParams.h.

Constructor & Destructor Documentation

◆ FitParams() [1/3]

FitParams ( const int  dim)
explicit

Constructor.

Definition at line 17 of file FitParams.cc.

18 :
19 m_dim(dim),
20 m_chiSquare(1e10),
23 m_nConstraintsVec(dim, 0),
24 m_globalState(dim),
25 m_globalCovariance(dim, dim)
26 {
29 }
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState
vector holding all parameters of this fit
Definition: FitParams.h:131
int m_dim
dimension of statevector
Definition: FitParams.h:116
std::vector< int > m_nConstraintsVec
vector with the number of constraints per parameter
Definition: FitParams.h:128
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
void resetStateVector()
reset the statevector
Definition: FitParams.cc:31
int m_nConstraints
number of constraints
Definition: FitParams.h:122
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()

~FitParams ( )
inline

Destructor.

Definition at line 28 of file FitParams.h.

28{};

◆ FitParams() [2/3]

FitParams ( const FitParams toCopy)
inline

copy constructor

Definition at line 31 of file FitParams.h.

32 : m_dim(toCopy.m_dim),
33 m_chiSquare(toCopy.m_chiSquare),
34 m_nConstraints(toCopy.m_nConstraints),
35 m_dimensionReduction(toCopy.m_dimensionReduction),
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 { }

◆ FitParams() [3/3]

FitParams ( )
inlineprotected

constructor

Definition at line 111 of file FitParams.h.

111{}

Member Function Documentation

◆ addChiSquare()

void addChiSquare ( double  chisq,
int  nconstraints 
)
inline

increment global chi2

Definition at line 92 of file FitParams.h.

93 {
94 m_chiSquare += chisq;
95 m_nConstraints += nconstraints;
96 }

◆ chiSquare()

double chiSquare ( ) const
inline

get chi2 of statevector

Definition at line 86 of file FitParams.h.

86{return m_chiSquare;};

◆ getCovariance() [1/2]

Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance ( )
inline

getter for the states covariance

Definition at line 53 of file FitParams.h.

54 {
55 return m_globalCovariance;
56 }

◆ getCovariance() [2/2]

const Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance ( ) const
inline

const getter for the states covariance

Definition at line 59 of file FitParams.h.

60 {
61 return m_globalCovariance;
62 }

◆ getDimensionOfState()

int getDimensionOfState ( ) const
inline

get the states dimension

Definition at line 80 of file FitParams.h.

80{return m_dim;};

◆ getStateVector() [1/2]

Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector ( )
inline

getter for the fit parameters/statevector

Definition at line 65 of file FitParams.h.

65{return m_globalState;}

◆ getStateVector() [2/2]

const Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector ( ) const
inline

const getter for the fit parameters/statevector

Definition at line 68 of file FitParams.h.

69 {
70 return m_globalState;
71 }

◆ nDof()

int nDof ( ) const

get number of degrees of freedom

Definition at line 56 of file FitParams.cc.

57 {
58 const int ndf = m_nConstraints - m_dim;
59 if (ndf < 1) {
60 const std::string error_string =
61 "Not enough constraints for this fit. Try adding a mass or beam constraint. constraints: " + std::to_string(
62 m_nConstraints) + " parameters to extract: " + std::to_string(m_dim) + " ndf: " + std::to_string(ndf);
63 throw FitParameterDimensionException(error_string);
64 }
65 return ndf;
66 }

◆ operator=()

FitParams & operator= ( const FitParams other)
inline

Assignment operator.

Definition at line 41 of file FitParams.h.

42 {
43 m_dim = other.m_dim;
44 m_chiSquare = other.m_chiSquare;
45 m_nConstraints = other.m_nConstraints;
46 m_dimensionReduction = other.m_dimensionReduction;
47 m_globalState = other.m_globalState;
48 m_globalCovariance = other.m_globalCovariance;
49 return *this;
50 }

◆ resetChiSquare()

void resetChiSquare ( )
inline

reset chi2

Definition at line 99 of file FitParams.h.

100 {
101 m_chiSquare = 0;
102 m_nConstraints = 0;
103 }

◆ resetCovariance()

void resetCovariance ( )

reset the statevector

Definition at line 36 of file FitParams.cc.

37 {
39 Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE >::Zero(m_dim, m_dim);
40
41 std::fill(m_nConstraintsVec.begin(), m_nConstraintsVec.end(), 0);
42 m_chiSquare = 0;
44 }

◆ resetStateVector()

void resetStateVector ( )

reset the statevector

Definition at line 31 of file FitParams.cc.

32 {
33 m_globalState = Eigen::Matrix<double, Eigen::Dynamic, 1>::Zero(m_dim);
34 }

◆ testCovariance()

bool testCovariance ( ) const

test if the covariance makes sense

Definition at line 46 of file FitParams.cc.

47 {
48 bool ok = true;
49 for (int row = 0; row < m_dim; ++row) {
50 ok = (m_globalCovariance(row, row) > 0);
51 if (!ok) break;
52 }
53 return ok;
54 }

Member Data Documentation

◆ m_chiSquare

double m_chiSquare
private

chi2

Definition at line 119 of file FitParams.h.

◆ m_dim

int m_dim
private

dimension of statevector

Definition at line 116 of file FitParams.h.

◆ m_dimensionReduction

int m_dimensionReduction
private

reduce the ndf used in the chi2 by this count

Definition at line 125 of file FitParams.h.

◆ m_globalCovariance

Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance
private

covariance of the global state

Definition at line 134 of file FitParams.h.

◆ m_globalState

Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState
private

vector holding all parameters of this fit

Definition at line 131 of file FitParams.h.

◆ m_nConstraints

int m_nConstraints
private

number of constraints

Definition at line 122 of file FitParams.h.

◆ m_nConstraintsVec

std::vector<int> m_nConstraintsVec
private

vector with the number of constraints per parameter

Definition at line 128 of file FitParams.h.


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