Go to the documentation of this file.00001 #ifndef __BCMODELHISTOGRAMFITTER__H
00002 #define __BCMODELHISTOGRAMFITTER__H
00003
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <vector>
00025
00026 #include "BCModel.h"
00027
00028 class BCHistogramFitterToyDataInterface;
00029
00030
00031 class TH1D;
00032 class TF1;
00033
00034
00035
00036 class BCHistogramFitter : public BCModel
00037 {
00038 public:
00039
00041
00042
00045 BCHistogramFitter();
00046
00051 BCHistogramFitter(TH1D * hist, TF1 * func);
00052
00055 ~BCHistogramFitter();
00056
00057
00058
00060
00061
00064 TH1D * GetHistogram()
00065 { return fHistogram; };
00066
00069 TH1D * GetHistogramExpected()
00070 { return fHistogramExpected; };
00071
00072
00075 TF1 * GetFitFunction()
00076 { return fFitFunction; };
00077
00080 TGraph * GetErrorBand()
00081 { return fErrorBand; };
00082
00085 TGraph * GetGraphFitFunction()
00086 { return fGraphFitFunction; };
00087
00088
00089
00091
00092
00097 int SetHistogram(TH1D * hist);
00098
00103 int SetHistogramExpected(const std::vector <double>& parameters);
00104
00109 int SetFitFunction(TF1 * func);
00110
00115 void SetFlagIntegration(bool flag)
00116 { fFlagIntegration = flag; };
00117
00118
00120
00121
00125
00126
00130 virtual double LogLikelihood(std::vector <double> parameters);
00131
00140
00141
00147 double FitFunction(std::vector <double> x, std::vector <double> parameters);
00148
00152 int Fit();
00153
00159 int Fit(TH1D * hist, TF1 * func);
00160
00163 void DrawFit(const char * options = "HIST", bool flaglegend = false);
00164
00172 int CalculatePValueFast(std::vector<double> par, double &pvalue, int nIterations = 100000);
00173
00184 int CalculatePValueFast(std::vector<double> par, BCHistogramFitterToyDataInterface* callback,
00185 double &pvalue, int nIterations = 100000);
00186
00194 int CalculatePValueLikelihood(std::vector<double> par, double &pvalue);
00195
00206 int CalculatePValueLeastSquares(std::vector<double> par, double &pvalue, bool weightExpect=true);
00207
00215 int CalculatePValueKolmogorov(std::vector<double> par, double &pvalue);
00216
00217
00218 double CDF(const std::vector<double>& parameters, int index, bool lower=false);
00219
00220
00221
00222 private:
00223
00227 TH1D * fHistogram;
00228
00231 TF1 * fFitFunction;
00232
00236 bool fFlagIntegration;
00237
00240 TGraph * fErrorBand;
00241
00244 TGraph * fGraphFitFunction;
00245
00249 TH1D * fHistogramExpected;
00250
00251 };
00252
00253
00254
00260 class BCHistogramFitterToyDataInterface
00261 {
00262 public:
00269 virtual void operator()(const std::vector<double>& expectation, const std::vector<int>& toyData)=0;
00270
00272 virtual ~BCHistogramFitterToyDataInterface(){}
00273 };
00274
00275 #endif