BCHistogramFitter.h
1 #ifndef __BCMODELHISTOGRAMFITTER__H
2 #define __BCMODELHISTOGRAMFITTER__H
3 
15 /*
16  * Copyright (C) 2007-2018, the BAT core developer team
17  * All rights reserved.
18  *
19  * For the licensing terms see doc/COPYING.
20  * For documentation see http://mpp.mpg.de/bat
21  */
22 
23 // ---------------------------------------------------------
24 
25 #include "BCFitter.h"
26 
27 #include <string>
28 #include <vector>
29 
30 // ---------------------------------------------------------
31 
33 {
34 public:
35 
37  /* @{ */
46  BCHistogramFitter(const TH1& hist, const TF1& func, const std::string& name = "histogram_fitter_model");
47 
50  virtual ~BCHistogramFitter() {};
51 
52  /* @} */
53 
55  /* @{ */
56 
59  const TH1& GetHistogram()
60  { return fHistogram; };
61 
62  /* @} */
63 
65  /* @{ */
66 
70  virtual double LogLikelihood(const std::vector<double>& parameters);
71 
75  virtual void Fit();
76 
79  void DrawFit(const std::string& options = "HIST", bool flaglegend = false);
80 
87  double CalculatePValueFast(const std::vector<double>& par, unsigned nIterations = 100000);
88 
95  double CalculatePValueLikelihood(const std::vector<double>& par);
96 
106  double CalculatePValueLeastSquares(const std::vector<double>& par, bool weightExpect = true);
107  /* @} */
108 
109 protected:
110 
114 
115  virtual double GraphCorrection(unsigned ibin) const;
116 };
117 
118 // ---------------------------------------------------------
119 
120 #endif
double CalculatePValueLeastSquares(const std::vector< double > &par, bool weightExpect=true)
Calculate the p-value using approximate chi^2 distribution of squared difference for conventional wei...
virtual double LogLikelihood(const std::vector< double > &parameters)
The log of the conditional probability.
virtual ~BCHistogramFitter()
The default destructor.
void DrawFit(const std::string &options="HIST", bool flaglegend=false)
Draw the fit in the current pad.
BCHistogramFitter(const TH1 &hist, const TF1 &func, const std::string &name="histogram_fitter_model")
Constructor.
const TH1 & GetHistogram()
TH1D fHistogram
The histogram with observed number of counts.
double CalculatePValueLikelihood(const std::vector< double > &par)
Calculate the p-value using approximate chi^2 distribution of scaled likelihood.
virtual void Fit()
Performs the fit.
A class for fitting histograms with functions.
A base class for all fitting classes.
Definition: BCFitter.h:31
virtual double GraphCorrection(unsigned ibin) const
Take care of bin width when creating a graph from the fit function.
double CalculatePValueFast(const std::vector< double > &par, unsigned nIterations=100000)
Calculate the p-value using fast-MCMC and the likelihood as test statistic.