Logo ROOT   6.07/09
Reference Guide
TVirtualFitter.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 31/08/99
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TVirtualFitter
13 #define ROOT_TVirtualFitter
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TVirtualFitter //
18 // //
19 // Abstract base class for fitting //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 
24 #ifndef ROOT_TNamed
25 #include "TNamed.h"
26 #endif
27 #ifndef ROOT_TMethodCall
28 #include "TMethodCall.h"
29 #endif
30 #include "Foption.h"
31 
32 
33 class TVirtualFitter : public TNamed {
34 
35 protected:
36  Foption_t fOption; //struct with the fit options
37  Int_t fXfirst; //first bin on X axis
38  Int_t fXlast; //last bin on X axis
39  Int_t fYfirst; //first bin on Y axis
40  Int_t fYlast; //last bin on Y axis
41  Int_t fZfirst; //first bin on Z axis
42  Int_t fZlast; //last bin on Z axis
43  Int_t fNpoints; //Number of points to fit
44  Int_t fPointSize; //Number of words per point in the cache
45  Int_t fCacheSize; //Size of the fCache array
46  Double_t *fCache; //[fCacheSize] array of points data (fNpoints*fPointSize < fCacheSize words)
47  TObject *fObjectFit; //pointer to object being fitted
48  TObject *fUserFunc; //pointer to user theoretical function (a TF1*)
49  TMethodCall *fMethodCall; //Pointer to MethodCall in case of interpreted function
50  void (*fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
51 
52 // static TVirtualFitter *fgFitter; //Current fitter (default TFitter)
53 // static Int_t fgMaxpar; //Maximum number of fit parameters for current fitter
54 // static Int_t fgMaxiter; //Maximum number of iterations
55 // static Double_t fgErrorDef; //Error definition (default=1)
56 // static Double_t fgPrecision; //maximum precision
57 // static TString fgDefault; //name of the default fitter ("Minuit","Fumili",etc)
58 
59  TVirtualFitter(const TVirtualFitter& tvf);
61 
62 public:
64  virtual ~TVirtualFitter();
65  virtual Double_t Chisquare(Int_t npar, Double_t *params) const = 0;
66 
67  virtual void Clear(Option_t *option="") = 0;
68  virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs) = 0;
69  virtual void FixParameter(Int_t ipar) = 0;
70  virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95);
71  virtual void GetConfidenceIntervals(TObject *obj, Double_t cl=0.95);
72  virtual Double_t *GetCovarianceMatrix() const = 0;
73  virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const = 0;
74  virtual Int_t GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const = 0;
75  typedef void (* FCNFunc_t )(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
76  virtual FCNFunc_t GetFCN() { return fFCN; }
77  virtual Foption_t GetFitOption() const {return fOption;}
79  virtual Int_t GetNumberTotalParameters() const = 0;
80  virtual Int_t GetNumberFreeParameters() const = 0;
81  virtual TObject *GetObjectFit() const {return fObjectFit;}
82  virtual Double_t GetParError(Int_t ipar) const = 0;
83  virtual Double_t GetParameter(Int_t ipar) const = 0;
84  virtual Int_t GetParameter(Int_t ipar,char *name,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const = 0;
85  virtual const char *GetParName(Int_t ipar) const = 0;
86  virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const = 0;
87  virtual Double_t GetSumLog(Int_t i) = 0;
88  virtual TObject *GetUserFunc() const {return fUserFunc;}
89  virtual Int_t GetXfirst() const {return fXfirst;}
90  virtual Int_t GetXlast() const {return fXlast;}
91  virtual Int_t GetYfirst() const {return fYfirst;}
92  virtual Int_t GetYlast() const {return fYlast;}
93  virtual Int_t GetZfirst() const {return fZfirst;}
94  virtual Int_t GetZlast() const {return fZlast;}
95  virtual Bool_t IsFixed(Int_t ipar) const = 0;
96  virtual void PrintResults(Int_t level, Double_t amin) const = 0;
97  virtual void ReleaseParameter(Int_t ipar) = 0;
98  virtual Double_t *SetCache(Int_t npoints, Int_t psize);
99  virtual void SetFCN(void *fcn)
100  R__DEPRECATED(6,10, "CINT remnant; not used anymore");
101  virtual void SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t));
102  virtual void SetFitMethod(const char *name) = 0;
103  virtual void SetFitOption(Foption_t option) {fOption = option;}
104  virtual void SetObjectFit(TObject *obj) {fObjectFit = obj;}
105  virtual Int_t SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh) = 0;
106  virtual void SetUserFunc(TObject *userfunc) {fUserFunc = userfunc;}
107  virtual void SetXfirst(Int_t first) {fXfirst = first;}
108  virtual void SetXlast (Int_t last) {fXlast = last;}
109  virtual void SetYfirst(Int_t first) {fYfirst = first;}
110  virtual void SetYlast (Int_t last) {fYlast = last;}
111  virtual void SetZfirst(Int_t first) {fZfirst = first;}
112  virtual void SetZlast (Int_t last) {fZlast = last;}
113 
114  static TVirtualFitter *GetFitter();
115  static TVirtualFitter *Fitter(TObject *obj, Int_t maxpar = 25);
116  static const char *GetDefaultFitter();
117  static Int_t GetMaxIterations();
118  static Double_t GetErrorDef();
119  static Double_t GetPrecision();
120  static void SetDefaultFitter(const char* name = "");
121  static void SetFitter(TVirtualFitter *fitter, Int_t maxpar = 25);
122  static void SetMaxIterations(Int_t niter=5000);
123  static void SetErrorDef(Double_t errdef=1);
124  static void SetPrecision(Double_t prec=1e-6);
125 
126  ClassDef(TVirtualFitter,0) //Abstract interface for fitting
127 };
128 
129 #endif
static Double_t GetErrorDef()
static: Return the Error Definition
static void SetErrorDef(Double_t errdef=1)
static: Set the Error Definition (default=1) For Minuit this is the value passed with the "SET ERR" c...
Double_t * fCache
#define R__DEPRECATED(MAJOR, MINOR, REASON)
Definition: RConfig.h:491
static Double_t GetPrecision()
static: Return the fit relative precision
TVirtualFitter()
Default constructor.
virtual void SetYlast(Int_t last)
virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95)
return confidence intervals in array x of dimension ndim implemented in TFitter and TLinearFitter ...
static Int_t GetMaxIterations()
static: Return the maximum number of iterations actually max number of function calls ...
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)=0
virtual void SetFitMethod(const char *name)=0
virtual Foption_t GetFitOption() const
virtual Int_t GetNumberFreeParameters() const =0
virtual void SetUserFunc(TObject *userfunc)
virtual Double_t Chisquare(Int_t npar, Double_t *params) const =0
virtual void SetXlast(Int_t last)
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
virtual TObject * GetUserFunc() const
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Double_t GetParameter(Int_t ipar) const =0
virtual Int_t GetZlast() const
virtual Double_t * SetCache(Int_t npoints, Int_t psize)
Initialize the cache array npoints is the number of points to be stored (or already stored) in the ca...
static const char * GetDefaultFitter()
static: return the name of the default fitter
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TVirtualFitter & operator=(const TVirtualFitter &tvf)
assignment operator
TObject * fObjectFit
static void SetMaxIterations(Int_t niter=5000)
static: Set the maximum number of function calls for the minimization algorithm For example for MIGRA...
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const =0
Foption_t fOption
virtual void SetFCN(void *fcn) R__DEPRECATED(6
To set the address of the minimization objective function.
virtual void Clear(Option_t *option="")=0
Set name and title to empty strings ("").
Method or function calling interface.
Definition: TMethodCall.h:41
virtual void ReleaseParameter(Int_t ipar)=0
virtual Int_t GetNumberTotalParameters() const =0
static void SetFitter(TVirtualFitter *fitter, Int_t maxpar=25)
Static function to set an alternative fitter.
virtual void SetZfirst(Int_t first)
TObject * fUserFunc
virtual Double_t GetParError(Int_t ipar) const =0
virtual const char * GetParName(Int_t ipar) const =0
virtual void SetObjectFit(TObject *obj)
virtual ~TVirtualFitter()
Cleanup virtual fitter.
virtual Int_t GetYlast() const
virtual void CINT remnant
virtual void FixParameter(Int_t ipar)=0
virtual Bool_t IsFixed(Int_t ipar) const =0
virtual void SetFitOption(Foption_t option)
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)=0
virtual FCNFunc_t GetFCN()
void(* FCNFunc_t)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual Int_t GetXlast() const
double f(double x)
double Double_t
Definition: RtypesCore.h:55
virtual void SetYfirst(Int_t first)
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const =0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
static void SetPrecision(Double_t prec=1e-6)
static: Set the tolerance used in the minimization algorithm For example for MIGRAD this is tolerance...
Abstract Base Class for Fitting.
virtual Int_t GetXfirst() const
Mother of all ROOT objects.
Definition: TObject.h:44
typedef void((*Func_t)())
virtual Double_t GetSumLog(Int_t i)=0
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const =0
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
TMethodCall * GetMethodCall() const
virtual TObject * GetObjectFit() const
virtual Double_t * GetCovarianceMatrix() const =0
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual Int_t GetYfirst() const
Definition: first.py:1
virtual void PrintResults(Int_t level, Double_t amin) const =0
virtual void SetXfirst(Int_t first)
virtual Int_t GetZfirst() const
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
virtual void SetZlast(Int_t last)
TMethodCall * fMethodCall