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 class ChiSquare {
16  public:
18  ChiSquare(const double achi2, int andof) : m_chi2(achi2), m_nDoF(andof) {}
19 
21  ChiSquare() : m_chi2(0.0), m_nDoF(0) {}
22 
24  virtual ~ChiSquare() {}
25 
27  double chi2PerDoF() const { return m_nDoF > 0 ? m_chi2 / m_nDoF : 0; }
28 
30  ChiSquare &operator+=(const ChiSquare &rhs);
31 
33  ChiSquare &operator-=(const ChiSquare &rhs);
34 
36  ChiSquare operator+(const ChiSquare &rhs);
37 
39  ChiSquare operator-(const ChiSquare &rhs);
40 
42  double chi2() const { return m_chi2; }
43 
45  int nDoF() const { return m_nDoF; }
46 
48  double prob() const { return TMath::Prob(m_chi2, m_nDoF); }
49 
50  protected:
51  private:
52  double m_chi2;
53  int m_nDoF;
54  ClassDef(ChiSquare, 1)
55 
56 }; // class ChiSquare
57 
59 {
60  m_chi2 += rhs.m_chi2;
61  m_nDoF += rhs.m_nDoF;
62  return *this;
63 }
64 
66 {
67  m_chi2 -= rhs.m_chi2;
68  m_nDoF -= rhs.m_nDoF;
69  return *this;
70 }
71 
73 {
74  ChiSquare rc = *this;
75  rc += rhs;
76  return rc;
77 }
78 
80 {
81  ChiSquare rc = *this;
82  rc -= rhs;
83  return rc;
84 }
85 } // namespace DecayTreeFitter
86 
87 #endif
ChiSquare operator-(const ChiSquare &rhs)
subtraction operator
Definition: ChiSquare.h:79
ChiSquare & operator+=(const ChiSquare &rhs)
addition operator
Definition: ChiSquare.h:58
ChiSquare & operator-=(const ChiSquare &rhs)
subtraction operator
Definition: ChiSquare.h:65
ChiSquare operator+(const ChiSquare &rhs)
addition operator
Definition: ChiSquare.h:72
double chi2PerDoF() const
return chi2/ndof if ndof>0. returns zero otherwise.
Definition: ChiSquare.h:27
double prob() const
Get Cofidence level.
Definition: ChiSquare.h:48
double chi2() const
Retrieve const chi square.
Definition: ChiSquare.h:42
ChiSquare()
Default Constructor.
Definition: ChiSquare.h:21
virtual ~ChiSquare()
Default Destructor.
Definition: ChiSquare.h:24
ChiSquare(const double achi2, int andof)
Constructor.
Definition: ChiSquare.h:18
int nDoF() const
Retrieve const number of degrees of freedom.
Definition: ChiSquare.h:45