PandaRoot
FitParams.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 // ******************************************************
14 // DecayTreeFitter Package
15 // We thank the original author Wouter Hulsbergen
16 // (BaBar, LHCb) for providing the sources.
17 // http://arxiv.org/abs/physics/0503191v1 (2005)
18 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
19 // ******************************************************
20 #ifndef FITPARAMS_H
21 #define FITPARAMS_H 1
22 
23 #include <iostream>
24 #include <vector>
25 #include <cmath>
26 #include <map>
27 #include "TVectorD.h"
28 #include "TMatrixDSym.h"
29 #include "ChiSquare.h"
30 #include "Rtypes.h"
31 
32 namespace DecayTreeFitter {
33 class ParticleBase;
34 
35 class FitParams {
36  public:
37  // Class that contains the parameters and covariance for the
38  // vertex fit.
39  FitParams(int dim);
40 
41  FitParams(const FitParams &par);
42  virtual ~FitParams();
43 
44  TMatrixDSym &cov() { return m_cov; }
45  TVectorD &par() { return m_par; }
46  double &par(int row) { return m_par(row); }
47 
48  TMatrixDSym cov(const std::vector<int> &indexVec) const;
49  TVectorD par(const std::vector<int> &indexVec) const;
50 
51  const TMatrixDSym &cov() const { return m_cov; }
52  const TVectorD &par() const { return m_par; }
53  const double &par(int row) const { return m_par(row); }
54 
55  // TMatrixDSym& scale() { return m_scale ; }
56 
57  int &nConstraintsVec(int row) { return m_nConstraintsVec[row /*-1*/]; }
58 
59  // int dim() const { return m_par.num_row() ; }
60  int dim() const { return m_dim; }
61  double chiSquare() const { return m_chiSquare; }
62 
63  int nConstraints() const { return m_nConstraints; }
64  int nDof() const { return nConstraints() - dim(); }
65  double err(int row) const { return sqrt(m_cov(row, row)); }
66 
67  void resize(int newdim);
68  void reset(int newdim);
69  void resetPar();
70  void resetCov(double scale = 100);
71  void print() const;
72  bool testCov() const;
73  void addChiSquare(double chi2, int nconstraints, const ParticleBase *p);
74  ChiSquare chiSquare(const ParticleBase &p) const;
75 
76  protected:
77  FitParams(){};
78 
79  private:
80  int m_dim;
81  TVectorD m_par;
82  TMatrixDSym m_cov;
83  // TMatrixDSym m_scale ;
84  double m_chiSquare;
85  int m_nConstraints;
86  std::vector<int> m_nConstraintsVec; // vector with number of constraints per parameter
87  std::map<const ParticleBase *, ChiSquare> m_chiSquareMap;
88  ClassDef(FitParams, 1)
89 };
90 } // namespace DecayTreeFitter
91 
92 #endif
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:40
void addChiSquare(double chi2, int nconstraints, const ParticleBase *p)
int nConstraints() const
Definition: FitParams.h:63
double err(int row) const
Definition: FitParams.h:65
const double & par(int row) const
Definition: FitParams.h:53
void resize(int newdim)
const TMatrixDSym & cov() const
Definition: FitParams.h:51
double chiSquare() const
Definition: FitParams.h:61
void resetCov(double scale=100)
int & nConstraintsVec(int row)
Definition: FitParams.h:57
double & par(int row)
Definition: FitParams.h:46
void reset(int newdim)
TMatrixDSym & cov()
Definition: FitParams.h:44
const TVectorD & par() const
Definition: FitParams.h:52