HFitInterface.h

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: HFitInterface.h 31491 2009-12-01 18:11:55Z moneta $
00002 // Author: L. Moneta Thu Aug 31 10:40:20 2006
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
00007  *                                                                    *
00008  *                                                                    *
00009  **********************************************************************/
00010 
00011 // Header file for class HFitInterface
00012 // set of free functions used to couple the ROOT data object with the fitting classes
00013 
00014 // avoid including this file when running CINT since free functions cannot be re-defined
00015 #if !defined(__CINT__) || defined(__MAKECINT__)
00016 
00017 #ifndef ROOT_HFitInterface
00018 #define ROOT_HFitInterface
00019 
00020 
00021 class TH1; 
00022 class THnSparse;
00023 class TF1;
00024 class TF2;
00025 class TGraph; 
00026 class TGraphErrors; 
00027 class TGraph2D;  
00028 class TMultiGraph; 
00029 struct Foption_t; 
00030 
00031 #include "TFitResultPtr.h"
00032 
00033 namespace ROOT { 
00034 
00035    namespace Math { 
00036       class MinimizerOptions; 
00037    }
00038 
00039    namespace Fit { 
00040 
00041       //class BinData; 
00042       class FitResult;
00043       class DataRange; 
00044       class BinData;
00045       class UnBinData; 
00046       class SparseData;
00047 
00048 #ifndef __CINT__  // does not link on Windows (why ??)
00049 
00050       /**
00051          Decode list of options into fitOption
00052        */
00053       void FitOptionsMake(const char *option, Foption_t &fitOption);
00054 
00055       /**
00056          fitting function for a TH1 (called from TH1::Fit)
00057        */
00058       TFitResultPtr FitObject(TH1 * h1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range); 
00059 
00060       /**
00061          fitting function for a TGraph (called from TGraph::Fit)
00062        */
00063       TFitResultPtr FitObject(TGraph * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);  
00064 
00065       /**
00066          fitting function for a MultiGraph (called from TMultiGraph::Fit)
00067        */
00068       TFitResultPtr FitObject(TMultiGraph * mg, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);  
00069 
00070       /**
00071          fitting function for a TGraph2D (called from TGraph2D::Fit)
00072        */
00073       TFitResultPtr FitObject(TGraph2D * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range); 
00074 
00075       /**
00076          fitting function for a THnSparse (called from THnSparse::Fit)
00077        */
00078       TFitResultPtr FitObject(THnSparse * s1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range); 
00079 #endif
00080 
00081       /** 
00082           fit an unbin data set (from tree or from histogram buffer) 
00083           using a TF1 pointer and fit options.
00084           N.B. ownership of fit data is passed to the UnBinFit function which will be responsible of 
00085           deleting the data after the fit. User calling this function MUST NOT delete UnBinData after 
00086           calling it.
00087       */
00088       TFitResultPtr UnBinFit(ROOT::Fit::UnBinData * data, TF1 * f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption); 
00089 
00090       /** 
00091           fill the data vector from a TH1. Pass also the TF1 function which is 
00092           needed in case of integral option and to reject points rejected by the function
00093       */ 
00094       void FillData ( BinData  & dv, const TH1 * hist, TF1 * func = 0); 
00095 
00096       /** 
00097           fill the data vector from a TH1 with sparse data. Pass also the TF1 function which is 
00098           needed in case of integral option and to reject points rejected by the function
00099       */ 
00100       void FillData ( SparseData  & dv, const TH1 * hist, TF1 * func = 0); 
00101 
00102       /** 
00103           fill the data vector from a THnSparse. Pass also the TF1 function which is 
00104           needed in case of integral option and to reject points rejected by the function
00105       */ 
00106       void FillData ( SparseData  & dv, const THnSparse * hist, TF1 * func = 0); 
00107 
00108       /** 
00109           fill the data vector from a THnSparse. Pass also the TF1 function which is 
00110           needed in case of integral option and to reject points rejected by the function
00111       */ 
00112       void FillData ( BinData  & dv, const THnSparse * hist, TF1 * func = 0); 
00113 
00114       /** 
00115           fill the data vector from a TGraph2D. Pass also the TF1 function which is 
00116           needed in case of integral option and to reject points rejected by the function
00117       */ 
00118       void FillData ( BinData  & dv, const TGraph2D * gr, TF1 * func = 0); 
00119 
00120 
00121       /** 
00122           fill the data vector from a TGraph. Pass also the TF1 function which is 
00123           needed in case to exclude points rejected by the function
00124       */ 
00125       void FillData ( BinData  & dv, const TGraph * gr, TF1 * func = 0 ); 
00126       /** 
00127           fill the data vector from a TMultiGraph. Pass also the TF1 function which is 
00128           needed in case to exclude points rejected by the function
00129       */ 
00130       void FillData ( BinData  & dv, const TMultiGraph * gr,  TF1 * func = 0); 
00131 
00132 
00133       /** 
00134           compute initial parameter for an exponential function given the fit data
00135           Set the constant and slope assuming a simple exponential going through xmin and xmax 
00136           of the data set
00137        */ 
00138       void InitExpo(const ROOT::Fit::BinData & data, TF1 * f1 ); 
00139       
00140 
00141       /** 
00142           compute initial parameter for gaussian function given the fit data
00143           Set the sigma limits for zero top 10* initial rms values 
00144           Set the initial parameter values in the TF1
00145        */ 
00146       void InitGaus(const ROOT::Fit::BinData & data, TF1 * f1 ); 
00147 
00148       /** 
00149           compute initial parameter for 2D gaussian function given the fit data
00150           Set the sigma limits for zero top 10* initial rms values 
00151           Set the initial parameter values in the TF1
00152        */ 
00153       void Init2DGaus(const ROOT::Fit::BinData & data, TF1 * f1 ); 
00154 
00155       /**
00156          compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
00157       */
00158       bool GetConfidenceIntervals(const TH1 * h1, const ROOT::Fit::FitResult & r, TGraphErrors * gr, double cl = 0.95); 
00159       
00160 
00161    } // end namespace Fit
00162 
00163 } // end namespace ROOT
00164 
00165 
00166 #endif /* ROOT_Fit_TH1Interface */
00167 
00168 
00169 #endif  /* not CINT OR MAKE_CINT */

Generated on Tue Jul 5 14:22:46 2011 for ROOT_528-00b_version by  doxygen 1.5.1