CMS 3D CMS Logo

CombinedChiSquaredLikelihood.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_CombinedChiSquaredLikelihood_h
2 #define PhysicsTools_Utilities_CombinedChiSquaredLikelihood_h
5 
6 namespace fit {
7  template <typename ChiSquared, typename Likelihood>
9  public:
12  // return chi-square value
13  double operator()() const { return -2 * like_() + chi2_(); }
14  ChiSquared& chi2() { return chi2_; }
15  const ChiSquared& chi2() const { return chi2_; }
16  Likelihood& like() { return like_; }
17  const Likelihood& like() const { return like_; }
18  size_t numberOfBins() const { return chi2_.numberOfBins(); }
19 
20  private:
23  };
24 
25  template <typename ChiSquared, typename Likelihood>
27  static void print(double amin,
28  unsigned int numberOfFreeParameters,
30  unsigned int ndof = f.numberOfBins() - numberOfFreeParameters;
31  std::cout << "-2 log(maximum-likelihood) = " << amin << ", n.d.o.f = " << ndof
32  << ", free parameters = " << numberOfFreeParameters << std::endl;
33  std::cout << "chi-2 contibution: " << f.chi2()() << "(n. bins: " << f.chi2().numberOfBins() << ")" << std::endl
34  << "likelihood contriution: " << -2. * f.like()() << std::endl;
35  }
36  };
37 
38 } // namespace fit
39 
40 #endif
static void print(double amin, unsigned int numberOfFreeParameters, const CombinedChiSquaredLikelihood< ChiSquared, Likelihood > &f)
CombinedChiSquaredLikelihood(const ChiSquared &chi2, const Likelihood &like)
double f[11][100]