Belle II Software  light-2212-foldex
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 
15 namespace TreeFitter {
16 
17  class ParticleBase;
18 
20  class FitParams {
21 
22  public:
23 
25  explicit FitParams(const int dim);
26 
28  ~FitParams() {};
29 
31  FitParams(const FitParams& toCopy)
32  : m_dim(toCopy.m_dim),
33  m_chiSquare(toCopy.m_chiSquare),
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;
44  m_chiSquare = other.m_chiSquare;
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  double& getRefToElementOfStateVec(int row) { return m_globalState(row, 0); }
75 
77  const double& getRefToElementOfStateVec(int row) const { return m_globalState(row, 0); }
78 
80  double getCovDiaElement(int counter) { return m_globalCovariance(counter, counter); }
81 
83  void resetStateVector();
84 
86  void resetCovariance();
87 
89  int getDimensionOfState() const {return m_dim;};
90 
92  bool testCovariance() const;
93 
95  int& incrementNConstraintsVec(int row) { return m_nConstraintsVec[row];}
96 
98  int& nConstraintsVec(int row) { return m_nConstraintsVec[row - 1]; }
99 
101  double chiSquare() const {return m_chiSquare;};
102 
104  int nDof() const;
105 
107  void addNConstraint(int value) { m_nConstraints += value; }
108 
110  void addChiSquare(double chisq, int nconstraints)
111  {
112  m_chiSquare += chisq;
113  m_nConstraints += nconstraints;
114  }
115 
118  {
119  m_chiSquare = 0;
120  m_nConstraints = 0;
121  }
122 
124  typedef std::vector< std::pair<const ParticleBase*, int> > indexmap;
125 
126  protected:
127 
130 
131  private:
132 
134  int m_dim;
135 
137  double m_chiSquare;
138 
141 
144 
146  std::vector<int> m_nConstraintsVec;
147 
149  Eigen::Matrix < double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > m_globalState;
150 
152  Eigen::Matrix < double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance;
153 
154  };
155 }
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:149
~FitParams()
Destructor.
Definition: FitParams.h:28
double getCovDiaElement(int counter)
get an covaraince diagonal element
Definition: FitParams.h:80
const double & getRefToElementOfStateVec(int row) const
get a const reference to an element of the state vector todo replace by setter?
Definition: FitParams.h:77
void addChiSquare(double chisq, int nconstraints)
increment global chi2
Definition: FitParams.h:110
int m_dim
dimension of statevector
Definition: FitParams.h:134
int & incrementNConstraintsVec(int row)
increment nconstraints vec
Definition: FitParams.h:95
FitParams()
constructor
Definition: FitParams.h:129
double & getRefToElementOfStateVec(int row)
get a reference to an element of the state vector todo replace by setter?
Definition: FitParams.h:74
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > & getCovariance()
getter for the states covariance
Definition: FitParams.h:53
int & nConstraintsVec(int row)
returns a reference(!) to the number of constraints for rows parameter.
Definition: FitParams.h:98
std::vector< int > m_nConstraintsVec
vector with the number of constraints per parameter
Definition: FitParams.h:146
bool testCovariance() const
test if the covariance makes sense
Definition: FitParams.cc:46
Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector()
getter for the fit parameters/statevector
Definition: FitParams.h:65
double chiSquare() const
get chi2 of statevector
Definition: FitParams.h:101
void addNConstraint(int value)
some constraints are special the geometric for example
Definition: FitParams.h:107
FitParams & operator=(const FitParams &other)
Assignment operator.
Definition: FitParams.h:41
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 nDof() const
get numer of degrees of freedom
Definition: FitParams.cc:56
int getDimensionOfState() const
get the states dimension
Definition: FitParams.h:89
const Eigen::Matrix< double, -1, 1, 0, MAX_MATRIX_SIZE, 1 > & getStateVector() const
const getter for the fit parameters/statevector
Definition: FitParams.h:68
int m_dimensionReduction
reduce the ndf used in the chi2 by this count
Definition: FitParams.h:143
double m_chiSquare
chi2
Definition: FitParams.h:137
std::vector< std::pair< const ParticleBase *, int > > indexmap
index map
Definition: FitParams.h:124
void resetStateVector()
reset the staevector
Definition: FitParams.cc:31
void resetChiSquare()
reset chi2
Definition: FitParams.h:117
int m_nConstraints
number of conatraints
Definition: FitParams.h:140
Eigen::Matrix< double, -1, -1, 0, MAX_MATRIX_SIZE, MAX_MATRIX_SIZE > m_globalCovariance
covariance of the global state
Definition: FitParams.h:152
void resetCovariance()
reset the staevector
Definition: FitParams.cc:36
FitParams(const FitParams &toCopy)
copy constructor
Definition: FitParams.h:31