BCHistogramFitter.h

Go to the documentation of this file.
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 
00166       int CalculatePValueLikelihood(std::vector<double> par, double &pvalue);
00167 
00178       int CalculatePValueLeastSquares(std::vector<double> par, double &pvalue, bool weightExpect=true);
00179 
00180       double CDF(const std::vector<double>& parameters, int index, bool lower=false);
00181 
00182       /* @} */
00183 
00184    private:
00185 
00189       TH1D * fHistogram;
00190 
00193       TF1 * fFitFunction;
00194 
00198       bool fFlagIntegration;
00199 
00202       TGraph * fErrorBand;
00203 
00206       TGraph * fGraphFitFunction;
00207 
00211 //    TH1D * fHistogramExpected;
00212 };
00213 
00214 // ---------------------------------------------------------
00215 
00216 #endif

Generated on Thu Feb 11 11:29:30 2010 for BayesianAnalysisToolkit by  doxygen 1.5.1