Logo ROOT  
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 #include "TNamed.h"
25 #include "TMethodCall.h"
26 #include "Foption.h"
27 
28 
29 class TVirtualFitter : public TNamed {
30 
31 protected:
32  Foption_t fOption; //struct with the fit options
33  Int_t fXfirst; //first bin on X axis
34  Int_t fXlast; //last bin on X axis
35  Int_t fYfirst; //first bin on Y axis
36  Int_t fYlast; //last bin on Y axis
37  Int_t fZfirst; //first bin on Z axis
38  Int_t fZlast; //last bin on Z axis
39  Int_t fNpoints; //Number of points to fit
40  Int_t fPointSize; //Number of words per point in the cache
41  Int_t fCacheSize; //Size of the fCache array
42  Double_t *fCache; //[fCacheSize] array of points data (fNpoints*fPointSize < fCacheSize words)
43  TObject *fObjectFit; //pointer to object being fitted
44  TObject *fUserFunc; //pointer to user theoretical function (a TF1*)
45  TMethodCall *fMethodCall; //Pointer to MethodCall in case of interpreted function
46  void (*fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
47 
48 // static TVirtualFitter *fgFitter; //Current fitter (default TFitter)
49 // static Int_t fgMaxpar; //Maximum number of fit parameters for current fitter
50 // static Int_t fgMaxiter; //Maximum number of iterations
51 // static Double_t fgErrorDef; //Error definition (default=1)
52 // static Double_t fgPrecision; //maximum precision
53 // static TString fgDefault; //name of the default fitter ("Minuit","Fumili",etc)
54 
55  TVirtualFitter(const TVirtualFitter& tvf);
57 
58 public:
60  virtual ~TVirtualFitter();
61  virtual Double_t Chisquare(Int_t npar, Double_t *params) const = 0;
62 
63  virtual void Clear(Option_t *option="") = 0;
64  virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs) = 0;
65  virtual void FixParameter(Int_t ipar) = 0;
66  virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95);
67  virtual void GetConfidenceIntervals(TObject *obj, Double_t cl=0.95);
68  virtual Double_t *GetCovarianceMatrix() const = 0;
70  virtual Int_t GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const = 0;
71  typedef void (* FCNFunc_t )(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
72  virtual FCNFunc_t GetFCN() { return fFCN; }
73  virtual Foption_t GetFitOption() const {return fOption;}
75  virtual Int_t GetNumberTotalParameters() const = 0;
76  virtual Int_t GetNumberFreeParameters() const = 0;
77  virtual TObject *GetObjectFit() const {return fObjectFit;}
78  virtual Double_t GetParError(Int_t ipar) const = 0;
79  virtual Double_t GetParameter(Int_t ipar) const = 0;
80  virtual Int_t GetParameter(Int_t ipar,char *name,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const = 0;
81  virtual const char *GetParName(Int_t ipar) const = 0;
82  virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const = 0;
83  virtual Double_t GetSumLog(Int_t i) = 0;
84  virtual TObject *GetUserFunc() const {return fUserFunc;}
85  virtual Int_t GetXfirst() const {return fXfirst;}
86  virtual Int_t GetXlast() const {return fXlast;}
87  virtual Int_t GetYfirst() const {return fYfirst;}
88  virtual Int_t GetYlast() const {return fYlast;}
89  virtual Int_t GetZfirst() const {return fZfirst;}
90  virtual Int_t GetZlast() const {return fZlast;}
91  virtual Bool_t IsFixed(Int_t ipar) const = 0;
92  virtual void PrintResults(Int_t level, Double_t amin) const = 0;
93  virtual void ReleaseParameter(Int_t ipar) = 0;
94  virtual Double_t *SetCache(Int_t npoints, Int_t psize);
95  virtual void SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t));
96  virtual void SetFitMethod(const char *name) = 0;
97  virtual void SetFitOption(Foption_t option) {fOption = option;}
98  virtual void SetObjectFit(TObject *obj) {fObjectFit = obj;}
99  virtual Int_t SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh) = 0;
100  virtual void SetUserFunc(TObject *userfunc) {fUserFunc = userfunc;}
101  virtual void SetXfirst(Int_t first) {fXfirst = first;}
102  virtual void SetXlast (Int_t last) {fXlast = last;}
103  virtual void SetYfirst(Int_t first) {fYfirst = first;}
104  virtual void SetYlast (Int_t last) {fYlast = last;}
105  virtual void SetZfirst(Int_t first) {fZfirst = first;}
106  virtual void SetZlast (Int_t last) {fZlast = last;}
107 
108  static TVirtualFitter *GetFitter();
109  static TVirtualFitter *Fitter(TObject *obj, Int_t maxpar = 25);
110  static const char *GetDefaultFitter();
111  static Int_t GetMaxIterations();
112  static Double_t GetErrorDef();
113  static Double_t GetPrecision();
114  static void SetDefaultFitter(const char* name = "");
115  static void SetFitter(TVirtualFitter *fitter, Int_t maxpar = 25);
116  static void SetMaxIterations(Int_t niter=5000);
117  static void SetErrorDef(Double_t errdef=1);
118  static void SetPrecision(Double_t prec=1e-6);
119 
120  ClassDef(TVirtualFitter,0) //Abstract interface for fitting
121 };
122 
123 #endif
TVirtualFitter::SetMaxIterations
static void SetMaxIterations(Int_t niter=5000)
static: Set the maximum number of function calls for the minimization algorithm For example for MIGRA...
Definition: TVirtualFitter.cxx:298
TVirtualFitter::fObjectFit
TObject * fObjectFit
Definition: TVirtualFitter.h:43
TVirtualFitter::fCacheSize
Int_t fCacheSize
Definition: TVirtualFitter.h:41
TVirtualFitter::fMethodCall
TMethodCall * fMethodCall
Definition: TVirtualFitter.h:45
n
const Int_t n
Definition: legend1.C:16
TVirtualFitter::ReleaseParameter
virtual void ReleaseParameter(Int_t ipar)=0
TVirtualFitter::PrintResults
virtual void PrintResults(Int_t level, Double_t amin) const =0
TGeant4Unit::eplus
static constexpr double eplus
Definition: TGeant4SystemOfUnits.h:170
first
Definition: first.py:1
e
#define e(i)
Definition: RSha256.hxx:103
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
TVirtualFitter::GetNumberFreeParameters
virtual Int_t GetNumberFreeParameters() const =0
Foption_t
Definition: Foption.h:24
TVirtualFitter::operator=
TVirtualFitter & operator=(const TVirtualFitter &tvf)
assignment operator
Definition: TVirtualFitter.cxx:116
TVirtualFitter::GetYlast
virtual Int_t GetYlast() const
Definition: TVirtualFitter.h:88
TVirtualFitter::SetParameter
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)=0
TVirtualFitter::fYfirst
Int_t fYfirst
Definition: TVirtualFitter.h:35
TVirtualFitter::ExecuteCommand
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)=0
TVirtualFitter::SetFitter
static void SetFitter(TVirtualFitter *fitter, Int_t maxpar=25)
Static function to set an alternative fitter.
Definition: TVirtualFitter.cxx:257
TNamed.h
TVirtualFitter::fPointSize
Int_t fPointSize
Definition: TVirtualFitter.h:40
TVirtualFitter::TVirtualFitter
TVirtualFitter()
Default constructor.
Definition: TVirtualFitter.cxx:72
Int_t
int Int_t
Definition: RtypesCore.h:45
TVirtualFitter::FixParameter
virtual void FixParameter(Int_t ipar)=0
TVirtualFitter::GetConfidenceIntervals
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
Definition: TVirtualFitter.cxx:185
x
Double_t x[n]
Definition: legend1.C:17
TVirtualFitter::Clear
virtual void Clear(Option_t *option="")=0
Set name and title to empty strings ("").
TVirtualFitter::Fitter
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
Definition: TVirtualFitter.cxx:159
TVirtualFitter::GetParError
virtual Double_t GetParError(Int_t ipar) const =0
TVirtualFitter::SetZlast
virtual void SetZlast(Int_t last)
Definition: TVirtualFitter.h:106
TVirtualFitter::SetObjectFit
virtual void SetObjectFit(TObject *obj)
Definition: TVirtualFitter.h:98
TVirtualFitter::~TVirtualFitter
virtual ~TVirtualFitter()
Cleanup virtual fitter.
Definition: TVirtualFitter.cxx:142
TVirtualFitter::GetZfirst
virtual Int_t GetZfirst() const
Definition: TVirtualFitter.h:89
Foption.h
TVirtualFitter
Abstract Base Class for Fitting.
Definition: TVirtualFitter.h:29
bool
TVirtualFitter::fNpoints
Int_t fNpoints
Definition: TVirtualFitter.h:39
TVirtualFitter::GetParName
virtual const char * GetParName(Int_t ipar) const =0
TVirtualFitter::SetYfirst
virtual void SetYfirst(Int_t first)
Definition: TVirtualFitter.h:103
TVirtualFitter::GetXfirst
virtual Int_t GetXfirst() const
Definition: TVirtualFitter.h:85
TVirtualFitter::SetZfirst
virtual void SetZfirst(Int_t first)
Definition: TVirtualFitter.h:105
TVirtualFitter::SetFCN
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
To set the address of the minimization objective function called by the native compiler (see function...
Definition: TVirtualFitter.cxx:267
TVirtualFitter::fCache
Double_t * fCache
Definition: TVirtualFitter.h:42
TVirtualFitter::fYlast
Int_t fYlast
Definition: TVirtualFitter.h:36
TVirtualFitter::SetYlast
virtual void SetYlast(Int_t last)
Definition: TVirtualFitter.h:104
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TVirtualFitter::GetXlast
virtual Int_t GetXlast() const
Definition: TVirtualFitter.h:86
TVirtualFitter::SetErrorDef
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...
Definition: TVirtualFitter.cxx:308
TVirtualFitter::SetPrecision
static void SetPrecision(Double_t prec=1e-6)
static: Set the tolerance used in the minimization algorithm For example for MIGRAD this is tolerance...
Definition: TVirtualFitter.cxx:323
TVirtualFitter::SetXfirst
virtual void SetXfirst(Int_t first)
Definition: TVirtualFitter.h:101
TVirtualFitter::GetNumberTotalParameters
virtual Int_t GetNumberTotalParameters() const =0
TVirtualFitter::GetDefaultFitter
static const char * GetDefaultFitter()
static: return the name of the default fitter
Definition: TVirtualFitter.cxx:200
void
typedef void((*Func_t)())
TVirtualFitter::fUserFunc
TObject * fUserFunc
Definition: TVirtualFitter.h:44
TVirtualFitter::GetMaxIterations
static Int_t GetMaxIterations()
static: Return the maximum number of iterations actually max number of function calls
Definition: TVirtualFitter.cxx:218
TVirtualFitter::GetErrorDef
static Double_t GetErrorDef()
static: Return the Error Definition
Definition: TVirtualFitter.cxx:227
TVirtualFitter::fXlast
Int_t fXlast
Definition: TVirtualFitter.h:34
TVirtualFitter::GetErrors
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const =0
TVirtualFitter::fFCN
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Definition: TVirtualFitter.h:46
TVirtualFitter::GetUserFunc
virtual TObject * GetUserFunc() const
Definition: TVirtualFitter.h:84
Double_t
double Double_t
Definition: RtypesCore.h:59
TVirtualFitter::GetPrecision
static Double_t GetPrecision()
static: Return the fit relative precision
Definition: TVirtualFitter.cxx:236
TVirtualFitter::GetCovarianceMatrix
virtual Double_t * GetCovarianceMatrix() const =0
TVirtualFitter::GetMethodCall
TMethodCall * GetMethodCall() const
Definition: TVirtualFitter.h:74
TVirtualFitter::GetObjectFit
virtual TObject * GetObjectFit() const
Definition: TVirtualFitter.h:77
TVirtualFitter::GetSumLog
virtual Double_t GetSumLog(Int_t i)=0
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TVirtualFitter::fXfirst
Int_t fXfirst
Definition: TVirtualFitter.h:33
name
char name[80]
Definition: TGX11.cxx:110
TVirtualFitter::GetParameter
virtual Double_t GetParameter(Int_t ipar) const =0
TVirtualFitter::GetParameter
virtual Int_t GetParameter(Int_t ipar, char *name, Double_t &value, Double_t &verr, Double_t &vlow, Double_t &vhigh) const =0
TVirtualFitter::GetFitOption
virtual Foption_t GetFitOption() const
Definition: TVirtualFitter.h:73
TVirtualFitter::FCNFunc_t
void(* FCNFunc_t)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Definition: TVirtualFitter.h:71
TVirtualFitter::GetZlast
virtual Int_t GetZlast() const
Definition: TVirtualFitter.h:90
TVirtualFitter::SetFitOption
virtual void SetFitOption(Foption_t option)
Definition: TVirtualFitter.h:97
TVirtualFitter::SetDefaultFitter
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
Definition: TVirtualFitter.cxx:245
TMethodCall
Method or function calling interface.
Definition: TMethodCall.h:37
TVirtualFitter::GetStats
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const =0
TVirtualFitter::SetFitMethod
virtual void SetFitMethod(const char *name)=0
TVirtualFitter::GetFitter
static TVirtualFitter * GetFitter()
static: return the current Fitter
Definition: TVirtualFitter.cxx:209
TVirtualFitter::SetXlast
virtual void SetXlast(Int_t last)
Definition: TVirtualFitter.h:102
TVirtualFitter::IsFixed
virtual Bool_t IsFixed(Int_t ipar) const =0
TVirtualFitter::SetCache
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...
Definition: TVirtualFitter.cxx:281
TVirtualFitter::fZfirst
Int_t fZfirst
Definition: TVirtualFitter.h:37
TVirtualFitter::fOption
Foption_t fOption
Definition: TVirtualFitter.h:32
TVirtualFitter::SetUserFunc
virtual void SetUserFunc(TObject *userfunc)
Definition: TVirtualFitter.h:100
TVirtualFitter::GetYfirst
virtual Int_t GetYfirst() const
Definition: TVirtualFitter.h:87
TVirtualFitter::GetFCN
virtual FCNFunc_t GetFCN()
Definition: TVirtualFitter.h:72
TVirtualFitter::GetCovarianceMatrixElement
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const =0
int
TVirtualFitter::Chisquare
virtual Double_t Chisquare(Int_t npar, Double_t *params) const =0
TVirtualFitter::fZlast
Int_t fZlast
Definition: TVirtualFitter.h:38
TMethodCall.h