lsst.jointcal  master-gc935ebf72c+13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Chi2.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_CHI2_H
3 #define LSST_JOINTCAL_CHI2_H
4 
5 #include <string>
6 #include <iostream>
7 #include <sstream>
8 
9 namespace lsst {
10 namespace jointcal {
11 
13 struct Chi2 {
14  double chi2;
15  unsigned ndof;
16 
17  Chi2() : chi2(0), ndof(0){};
18 
19  friend std::ostream& operator<<(std::ostream& s, const Chi2& chi2) {
20  s << "chi2/ndof : " << chi2.chi2 << '/' << chi2.ndof << '=' << chi2.chi2 / chi2.ndof;
21  return s;
22  }
23 
25  std::string __str__() {
26  std::stringstream s;
27  s << "Chi2/ndof : " << chi2 << '/' << ndof << '=' << chi2 / ndof;
28  return s.str();
29  }
30 
31  // Addentry has a third argument in order to make it compatible with an
32  // other stat accumulator.
33  template <typename T>
34  void addEntry(double inc, unsigned dof, T) {
35  chi2 += inc;
36  ndof += dof;
37  }
38 
39  void operator+=(const Chi2& right) {
40  chi2 += right.chi2;
41  ndof += right.ndof;
42  }
43 
44 }; // end of struct Chi2
45 } // namespace jointcal
46 } // namespace lsst
47 #endif // LSST_JOINTCAL_CHI2_H
friend std::ostream & operator<<(std::ostream &s, const Chi2 &chi2)
Definition: Chi2.h:19
void operator+=(const Chi2 &right)
Definition: Chi2.h:39
unsigned ndof
Definition: Chi2.h:15
Simple structure to accumulate Chi2 and Ndof.
Definition: Chi2.h:13
void addEntry(double inc, unsigned dof, T)
Definition: Chi2.h:34
std::string __str__()
this routine is the one called by the python print.
Definition: Chi2.h:25