TBackCompFitter.h

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: TBackCompFitter.h 35643 2010-09-23 12:48:32Z moneta $
00002 // Author: L. Moneta    08/2008  
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2008 ROOT Foundation,  CERN/PH-SFT                   *
00007  *                                                                    *
00008  **********************************************************************/
00009 
00010 #ifndef ROOT_TBackCompFitter_H_
00011 #define ROOT_TBackCompFitter_H_
00012 
00013 #ifndef ROOT_TVirtualFitter
00014 #include "TVirtualFitter.h"
00015 #endif
00016 
00017 #ifndef ROOT_Fit_Fitter
00018 #include "Fit/Fitter.h"
00019 #endif
00020 
00021 #ifndef ROOT_Fit_DataVector
00022 #include "Fit/DataVector.h"
00023 #endif
00024 
00025 #ifndef ROOT_Math_IFunctionfwd
00026 #include "Math/IFunctionfwd.h"
00027 #endif
00028 
00029 
00030 
00031 #include <vector>
00032 
00033 /**
00034     TVirtualFitter backward compatibility implementation using new ROOT::Fit::Fitter
00035 */
00036 
00037 class TGraph; 
00038 class TFitResult; 
00039 
00040 namespace ROOT { 
00041    namespace Fit { 
00042       class FitData; 
00043    }
00044    namespace Math { 
00045       class Minimizer; 
00046    }
00047 }
00048 
00049 
00050 class TBackCompFitter : public TVirtualFitter {
00051 
00052 public:
00053 
00054 
00055 
00056    TBackCompFitter();
00057 
00058    //TBackCompFitter(ROOT::Fit::Fitter & fitter, ROOT::Fit::FitData * ); 
00059    TBackCompFitter( std::auto_ptr<ROOT::Fit::Fitter>  fitter, std::auto_ptr<ROOT::Fit::FitData> data  ); 
00060 
00061    virtual ~TBackCompFitter();
00062 
00063 public:
00064 
00065    enum { 
00066       kCanDeleteLast = BIT(9)  // object can be deleted before creating a new one
00067    };
00068 
00069    // inherited interface
00070    virtual Double_t  Chisquare(Int_t npar, Double_t *params) const;
00071    virtual void      Clear(Option_t *option="");
00072    virtual Int_t     ExecuteCommand(const char *command, Double_t *args, Int_t nargs);
00073    virtual void      FixParameter(Int_t ipar);
00074 
00075    virtual void      GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95);
00076    virtual void      GetConfidenceIntervals(TObject *obj, Double_t cl=0.95);
00077 
00078    virtual Double_t *GetCovarianceMatrix() const;
00079    virtual Double_t  GetCovarianceMatrixElement(Int_t i, Int_t j) const;
00080    virtual Int_t     GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const;
00081    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
00082    virtual Int_t     GetNumberTotalParameters() const;
00083    virtual Int_t     GetNumberFreeParameters() const;
00084 
00085    virtual Double_t  GetParError(Int_t ipar) const;
00086    virtual Double_t  GetParameter(Int_t ipar) const;
00087    virtual Int_t     GetParameter(Int_t ipar,char *name,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const;
00088    virtual const char *GetParName(Int_t ipar) const;
00089    virtual Int_t     GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const;
00090    virtual Double_t  GetSumLog(Int_t i);
00091 
00092    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
00093    virtual Bool_t    IsFixed(Int_t ipar) const ;
00094 
00095    virtual void      PrintResults(Int_t level, Double_t amin) const;
00096    virtual void      ReleaseParameter(Int_t ipar);
00097    virtual void      SetFitMethod(const char *name);
00098    virtual Int_t     SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh);
00099 
00100    virtual void      SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t) );
00101    // this for CINT (interactive functions)
00102    virtual void      SetFCN(void * );
00103    // for using interpreted function passed by the user
00104    virtual void SetMethodCall(TMethodCall * m) { fMethodCall = m; }
00105 
00106    ///!!!! new method (of this interface) 
00107 
00108 
00109    // get reference to Fit configuration (NOTE: it will be invalid when class is deleted) 
00110    ROOT::Fit::FitConfig & GetFitConfig()  { return fFitter->Config(); }
00111 
00112    // get reference to Fit Result object (NOTE: it will be invalid when class is deleted) 
00113    const ROOT::Fit::FitResult & GetFitResult() const { return fFitter->Result(); }
00114 
00115    // get a copy of the Fit result returning directly a new  TFitResult 
00116    TFitResult * GetTFitResult() const; 
00117 
00118    // get reference to Fit Data object (NOTE: it will be invalid when class is deleted) 
00119    const ROOT::Fit::FitData & GetFitData() const { return *fFitData; }
00120 
00121    // return pointer to last used minimizer
00122    ROOT::Math::Minimizer * GetMinimizer() const; 
00123 
00124    // return pointer to last used objective function
00125    ROOT::Math::IMultiGenFunction * GetObjFunction() const; 
00126    
00127    // scan likelihood value of  parameter and fill the given graph. 
00128    bool  Scan(unsigned int ipar, TGraph * gr, double xmin = 0, double xmax = 0);
00129 
00130 //    // scan likelihood value for two  parameters and fill the given graph. 
00131 //    bool  Scan2D(unsigned int ipar, unsigned int jpar, TGraph2D * gr, 
00132 //                         double xmin = 0, double xmax = 0, double ymin = 0, double ymax = 0);
00133 
00134    // create contour of two parameters around the minimum
00135    // pass as option confidence level:  default is a value of 0.683 
00136    bool  Contour(unsigned int ipar, unsigned int jpar, TGraph * gr , double confLevel = 0.683); 
00137    
00138    // set FCN using new interface
00139    virtual void SetObjFunction(  ROOT::Math::IMultiGenFunction * f);
00140 
00141    // recreate minimizer and FCN for TMinuit fits and standard printout 
00142    void ReCreateMinimizer();
00143    
00144 
00145 protected: 
00146 
00147    // internal methods
00148 
00149    bool ValidParameterIndex(int ipar) const;
00150   
00151    void DoSetDimension(); 
00152    
00153    
00154 private:
00155 
00156 
00157    //ROOT::Fit::FitData * fFitData;          
00158    std::auto_ptr<ROOT::Fit::FitData>  fFitData;  //! data of the fit (managed by TBackCompFitter)
00159    std::auto_ptr<ROOT::Fit::Fitter>   fFitter;   //! pointer to fitter object (managed by TBackCompFitter)
00160    ROOT::Math::Minimizer * fMinimizer;
00161    ROOT::Math::IMultiGenFunction * fObjFunc; 
00162    ROOT::Math::IParamMultiFunction * fModelFunc; 
00163    mutable std::vector<double> fCovar; // cached covariance matrix (NxN)
00164 
00165 
00166 
00167    ClassDef(TBackCompFitter,1)  // Class providing backward compatibility for fitting by implementing the TVirtualFitter interface
00168 
00169 };
00170 
00171 
00172 
00173 #endif //ROOT_TBackCompFitter_H_

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