FairRoot/PandaRoot
ChiSquare.h
Go to the documentation of this file.
1 // ******************************************************
2 // DecayTreeFitter Package
3 // We thank the original author Wouter Hulsbergen
4 // (BaBar, LHCb) for providing the sources.
5 // http://arxiv.org/abs/physics/0503191v1 (2005)
6 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
7 // ******************************************************
8 #ifndef DECAYTREEFITTER_ChiSquare_H
9 #define DECAYTREEFITTER_ChiSquare_H 1
10 #include "Rtypes.h"
11 #include "TMath.h"
12 
13 namespace DecayTreeFitter
14 {
15 
16  class ChiSquare
17  {
18  public:
19 
21  ChiSquare(const double achi2, int andof) : m_chi2(achi2),m_nDoF(andof) {}
22 
24  ChiSquare() : m_chi2(0.0),
25  m_nDoF(0) {}
26 
28  virtual ~ChiSquare() {}
29 
31  double chi2PerDoF() const { return m_nDoF>0 ? m_chi2/m_nDoF : 0 ; }
32 
34  ChiSquare& operator+=(const ChiSquare& rhs);
35 
37  ChiSquare& operator-=(const ChiSquare& rhs);
38 
40  ChiSquare operator+(const ChiSquare& rhs);
41 
43  ChiSquare operator-(const ChiSquare& rhs);
44 
46  double chi2() const { return m_chi2 ; }
47 
49  int nDoF() const { return m_nDoF ; }
50 
52  double prob() const { return TMath::Prob(m_chi2,m_nDoF) ; }
53 
54 
55  protected:
56 
57  private:
58 
59  double m_chi2;
60  int m_nDoF;
61  ClassDef ( ChiSquare,1 )
62 
63  }; // class ChiSquare
64 
65 
67  {
68  m_chi2 += rhs.m_chi2 ;
69  m_nDoF += rhs.m_nDoF ;
70  return *this ;
71  }
72 
74  {
75  m_chi2 -= rhs.m_chi2 ;
76  m_nDoF -= rhs.m_nDoF ;
77  return *this ;
78  }
79 
81  {
82  ChiSquare rc = *this ;
83  rc += rhs ;
84  return rc ;
85  }
86 
88  {
89  ChiSquare rc = *this ;
90  rc -= rhs ;
91  return rc ;
92  }
93 }
94 
95 #endif
int nDoF() const
Retrieve const number of degrees of freedom.
Definition: ChiSquare.h:49
ChiSquare operator-(const ChiSquare &rhs)
subtraction operator
Definition: ChiSquare.h:87
ChiSquare & operator+=(const ChiSquare &rhs)
addition operator
Definition: ChiSquare.h:66
ChiSquare & operator-=(const ChiSquare &rhs)
subtraction operator
Definition: ChiSquare.h:73
int m_nDoF
number of degrees of freedom
Definition: ChiSquare.h:60
ChiSquare operator+(const ChiSquare &rhs)
addition operator
Definition: ChiSquare.h:80
double chi2() const
Retrieve const chi square.
Definition: ChiSquare.h:46
double m_chi2
chi square
Definition: ChiSquare.h:59
double prob() const
Get Cofidence level.
Definition: ChiSquare.h:52
ChiSquare()
Default Constructor.
Definition: ChiSquare.h:24
virtual ~ChiSquare()
Default Destructor.
Definition: ChiSquare.h:28
double chi2PerDoF() const
return chi2/ndof if ndof>0. returns zero otherwise.
Definition: ChiSquare.h:31
ChiSquare(const double achi2, int andof)
Constructor.
Definition: ChiSquare.h:21