00001 #ifndef __BCMODELHISTOGRAMFITTER__H 00002 #define __BCMODELHISTOGRAMFITTER__H 00003 00015 /* 00016 * Copyright (C) 2008, Daniel Kollar and Kevin Kroeninger. 00017 * All rights reserved. 00018 * 00019 * For the licensing terms see doc/COPYING. 00020 */ 00021 00022 // --------------------------------------------------------- 00023 00024 #include <vector> 00025 00026 #include "BAT/BCModel.h" 00027 00028 // ROOT classes 00029 class TH1D; 00030 class TF1; 00031 00032 // --------------------------------------------------------- 00033 00034 class BCHistogramFitter : public BCModel 00035 { 00036 public: 00037 00039 /* @{ */ 00040 00043 BCHistogramFitter(); 00044 00049 BCHistogramFitter(TH1D * hist, TF1 * func); 00050 00053 ~BCHistogramFitter(); 00054 00055 /* @} */ 00056 00058 /* @{ */ 00059 00062 TH1D * GetHistogram() 00063 { return fHistogram; }; 00064 00067 TF1 * GetFitFunction() 00068 { return fFitFunction; }; 00069 00072 TGraph * GetErrorBand() 00073 { return fErrorBand; }; 00074 00077 TGraph * GetGraphFitFunction() 00078 { return fGraphFitFunction; }; 00079 00080 /* @} */ 00081 00083 /* @{ */ 00084 00089 int SetHistogram(TH1D * hist); 00090 00095 int SetFitFunction(TF1 * func); 00096 00101 void SetFlagIntegration(bool flag) 00102 { fFlagIntegration = flag; }; 00103 00104 /* @} */ 00106 /* @{ */ 00107 00111 virtual double LogAPrioriProbability(std::vector <double> parameters); 00112 00116 virtual double LogLikelihood(std::vector <double> parameters); 00117 00126 // void PrintHistogram(const char * options = "", const char * filename = ""); 00127 00133 double FitFunction(std::vector <double> x, std::vector <double> parameters); 00134 00138 int Fit() 00139 { return this -> Fit(fHistogram, fFitFunction); }; 00140 00146 int Fit(TH1D * hist, TF1 * func); 00147 00150 void DrawFit(const char * options = "", bool flaglegend = false); 00151 00157 int CalculatePValueFast(std::vector<double> par, double &pvalue); 00158 00159 /* @} */ 00160 00161 private: 00162 00166 TH1D * fHistogram; 00167 00170 TF1 * fFitFunction; 00171 00175 bool fFlagIntegration; 00176 00179 TGraph * fErrorBand; 00180 00183 TGraph * fGraphFitFunction; 00184 }; 00185 00186 // --------------------------------------------------------- 00187 00188 #endif