Belle II Software development
FitParams.cc
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
10#include <analysis/VertexFitting/TreeFitter/FitParams.h>
11#include <analysis/VertexFitting/TreeFitter/FitParameterDimensionException.h>
12#include <string>
13
14namespace TreeFitter {
15
16
17 FitParams::FitParams(const int dim)
18 :
19 m_dim(dim),
20 m_chiSquare(1e10),
21 m_nConstraints(0),
22 m_dimensionReduction(0),
23 m_nConstraintsVec(dim, 0),
24 m_globalState(dim),
25 m_globalCovariance(dim, dim)
26 {
29 }
30
32 {
33 m_globalState = Eigen::Matrix<double, Eigen::Dynamic, 1>::Zero(m_dim);
34 }
35
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 }
45
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 }
55
56 int FitParams::nDof() const
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 }
67
68} //TreeFitter namespace
exception template, runtime_error implements what()
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
FitParams()
constructor
Definition: FitParams.h:111
std::vector< int > m_nConstraintsVec
vector with the number of constraints per parameter
Definition: FitParams.h:128
bool testCovariance() const
test if the covariance makes sense
Definition: FitParams.cc:46
int nDof() const
get number of degrees of freedom
Definition: FitParams.cc:56
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