00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TF1
00014 #define ROOT_TF1
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_TFormula
00027 #include "TFormula.h"
00028 #endif
00029 #ifndef ROOT_TAttLine
00030 #include "TAttLine.h"
00031 #endif
00032 #ifndef ROOT_TAttFill
00033 #include "TAttFill.h"
00034 #endif
00035 #ifndef ROOT_TAttMarker
00036 #include "TAttMarker.h"
00037 #endif
00038
00039 #ifndef ROOT_Math_ParamFunctor
00040 #include "Math/ParamFunctor.h"
00041 #endif
00042
00043 class TF1;
00044 class TH1;
00045 class TAxis;
00046 class TMethodCall;
00047
00048 namespace ROOT {
00049 namespace Fit {
00050 class FitResult;
00051 }
00052 }
00053
00054 class TF1 : public TFormula, public TAttLine, public TAttFill, public TAttMarker {
00055
00056 protected:
00057 Double_t fXmin;
00058 Double_t fXmax;
00059 Int_t fNpx;
00060 Int_t fType;
00061 Int_t fNpfits;
00062 Int_t fNDF;
00063 Int_t fNsave;
00064 Double_t fChisquare;
00065 Double_t *fIntegral;
00066 Double_t *fParErrors;
00067 Double_t *fParMin;
00068 Double_t *fParMax;
00069 Double_t *fSave;
00070 Double_t *fAlpha;
00071 Double_t *fBeta;
00072 Double_t *fGamma;
00073 TObject *fParent;
00074 TH1 *fHistogram;
00075 Double_t fMaximum;
00076 Double_t fMinimum;
00077 TMethodCall *fMethodCall;
00078 void *fCintFunc;
00079 ROOT::Math::ParamFunctor fFunctor;
00080
00081 static Bool_t fgAbsValue;
00082 static Bool_t fgRejectPoint;
00083 static TF1 *fgCurrent;
00084
00085 void CreateFromFunctor(const char *name, Int_t npar);
00086 void CreateFromCintClass(const char *name, void * ptr, Double_t xmin, Double_t xmax, Int_t npar, const char * cname, const char * fname);
00087
00088 public:
00089
00090 enum {
00091 kNotDraw = BIT(9)
00092 };
00093
00094 TF1();
00095 TF1(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1);
00096 TF1(const char *name, Double_t xmin, Double_t xmax, Int_t npar);
00097 TF1(const char *name, void *fcn, Double_t xmin, Double_t xmax, Int_t npar);
00098 #ifndef __CINT__
00099 TF1(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0);
00100 TF1(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Int_t npar=0);
00101 #endif
00102
00103
00104 TF1(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0);
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 template <typename Func>
00115 TF1(const char *name, Func f, Double_t xmin, Double_t xmax, Int_t npar, const char * = 0 ) :
00116 TFormula(),
00117 TAttLine(),
00118 TAttFill(),
00119 TAttMarker(),
00120 fXmin ( xmin ),
00121 fXmax ( xmax ),
00122 fNpx ( 100 ),
00123 fType ( 1 ),
00124 fNpfits ( 0 ),
00125 fNDF ( 0 ),
00126 fNsave ( 0 ),
00127 fChisquare ( 0 ),
00128 fIntegral ( 0 ),
00129 fParErrors ( 0 ),
00130 fParMin ( 0 ),
00131 fParMax ( 0 ),
00132 fSave ( 0 ),
00133 fAlpha ( 0 ),
00134 fBeta ( 0 ),
00135 fGamma ( 0 ),
00136 fParent ( 0 ),
00137 fHistogram ( 0 ),
00138 fMaximum ( -1111 ),
00139 fMinimum ( -1111 ),
00140 fMethodCall ( 0),
00141 fCintFunc ( 0 ),
00142 fFunctor( ROOT::Math::ParamFunctor(f) )
00143 {
00144 CreateFromFunctor(name, npar);
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 template <class PtrObj, typename MemFn>
00156 TF1(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Int_t npar, const char * = 0, const char * = 0) :
00157 TFormula(),
00158 TAttLine(),
00159 TAttFill(),
00160 TAttMarker(),
00161 fXmin ( xmin ),
00162 fXmax ( xmax ),
00163 fNpx ( 100 ),
00164 fType ( 1 ),
00165 fNpfits ( 0 ),
00166 fNDF ( 0 ),
00167 fNsave ( 0 ),
00168 fChisquare ( 0 ),
00169 fIntegral ( 0 ),
00170 fParErrors ( 0 ),
00171 fParMin ( 0 ),
00172 fParMax ( 0 ),
00173 fSave ( 0 ),
00174 fAlpha ( 0 ),
00175 fBeta ( 0 ),
00176 fGamma ( 0 ),
00177 fParent ( 0 ),
00178 fHistogram ( 0 ),
00179 fMaximum ( -1111 ),
00180 fMinimum ( -1111 ),
00181 fMethodCall( 0 ),
00182 fCintFunc ( 0 ),
00183 fFunctor ( ROOT::Math::ParamFunctor(p,memFn) )
00184 {
00185 CreateFromFunctor(name, npar);
00186 }
00187
00188
00189 TF1(const char *name, void *ptr, Double_t xmin, Double_t xmax, Int_t npar, const char *className );
00190 TF1(const char *name, void *ptr, void *,Double_t xmin, Double_t xmax, Int_t npar, const char *className, const char *methodName = 0);
00191
00192 TF1(const TF1 &f1);
00193 TF1& operator=(const TF1 &rhs);
00194 virtual ~TF1();
00195 virtual void Browse(TBrowser *b);
00196 virtual void Copy(TObject &f1) const;
00197 virtual Double_t Derivative (Double_t x, Double_t *params=0, Double_t epsilon=0.001) const;
00198 virtual Double_t Derivative2(Double_t x, Double_t *params=0, Double_t epsilon=0.001) const;
00199 virtual Double_t Derivative3(Double_t x, Double_t *params=0, Double_t epsilon=0.001) const;
00200 static Double_t DerivativeError();
00201 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
00202 virtual void Draw(Option_t *option="");
00203 virtual TF1 *DrawCopy(Option_t *option="") const;
00204 virtual TObject *DrawDerivative(Option_t *option="al");
00205 virtual TObject *DrawIntegral(Option_t *option="al");
00206 virtual void DrawF1(const char *formula, Double_t xmin, Double_t xmax, Option_t *option="");
00207 virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const;
00208 virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0);
00209
00210 virtual Double_t operator()(Double_t x, Double_t y=0, Double_t z = 0, Double_t t = 0) const;
00211 virtual Double_t operator()(const Double_t *x, const Double_t *params=0);
00212 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00213 virtual void FixParameter(Int_t ipar, Double_t value);
00214 Double_t GetChisquare() const {return fChisquare;}
00215 TH1 *GetHistogram() const;
00216 virtual Double_t GetMaximum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon = 1.E-10, Int_t maxiter = 100, Bool_t logx = false) const;
00217 virtual Double_t GetMinimum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon = 1.E-10, Int_t maxiter = 100, Bool_t logx = false) const;
00218 virtual Double_t GetMaximumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon = 1.E-10, Int_t maxiter = 100, Bool_t logx = false) const;
00219 virtual Double_t GetMinimumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon = 1.E-10, Int_t maxiter = 100, Bool_t logx = false) const;
00220 virtual Int_t GetNDF() const;
00221 virtual Int_t GetNpx() const {return fNpx;}
00222 TMethodCall *GetMethodCall() const {return fMethodCall;}
00223 virtual Int_t GetNumberFreeParameters() const;
00224 virtual Int_t GetNumberFitPoints() const {return fNpfits;}
00225 virtual char *GetObjectInfo(Int_t px, Int_t py) const;
00226 TObject *GetParent() const {return fParent;}
00227 virtual Double_t GetParError(Int_t ipar) const;
00228 virtual Double_t *GetParErrors() const {return fParErrors;}
00229 virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const;
00230 virtual Double_t GetProb() const;
00231 virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum);
00232 virtual Double_t GetRandom();
00233 virtual Double_t GetRandom(Double_t xmin, Double_t xmax);
00234 virtual void GetRange(Double_t &xmin, Double_t &xmax) const;
00235 virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const;
00236 virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const;
00237 virtual Double_t GetSave(const Double_t *x);
00238 virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon = 1.E-10, Int_t maxiter = 100, Bool_t logx = false) const;
00239 virtual Double_t GetXmin() const {return fXmin;}
00240 virtual Double_t GetXmax() const {return fXmax;}
00241 TAxis *GetXaxis() const ;
00242 TAxis *GetYaxis() const ;
00243 TAxis *GetZaxis() const ;
00244 virtual Double_t GradientPar(Int_t ipar, const Double_t *x, Double_t eps=0.01);
00245 virtual void GradientPar(const Double_t *x, Double_t *grad, Double_t eps=0.01);
00246 virtual void InitArgs(const Double_t *x, const Double_t *params);
00247 static void InitStandardFunctions();
00248 virtual Double_t Integral(Double_t a, Double_t b, const Double_t *params=0, Double_t epsilon=1e-12);
00249 virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=1e-12);
00250 virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=1e-12);
00251 virtual Double_t IntegralError(Double_t a, Double_t b, const Double_t *params=0, const Double_t *covmat=0, Double_t epsilon=1e-12);
00252 virtual Double_t IntegralError(Int_t n, const Double_t * a, const Double_t * b, const Double_t *params=0, const Double_t *covmat=0, Double_t epsilon=1e-12);
00253
00254 virtual Double_t IntegralFast(Int_t num, Double_t *x, Double_t *w, Double_t a, Double_t b, Double_t *params=0, Double_t epsilon=1e-12);
00255 virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Int_t minpts, Int_t maxpts, Double_t epsilon, Double_t &relerr,Int_t &nfnevl, Int_t &ifail);
00256 virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Double_t epsilon, Double_t &relerr);
00257 virtual Bool_t IsInside(const Double_t *x) const;
00258 virtual void Paint(Option_t *option="");
00259 virtual void Print(Option_t *option="") const;
00260 virtual void ReleaseParameter(Int_t ipar);
00261 virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax);
00262 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00263 virtual void SetChisquare(Double_t chi2) {fChisquare = chi2;}
00264 virtual void SetFitResult(const ROOT::Fit::FitResult & result, const Int_t * indpar = 0);
00265 template <class PtrObj, typename MemFn>
00266 void SetFunction( PtrObj& p, MemFn memFn );
00267 template <typename Func>
00268 void SetFunction( Func f );
00269 virtual void SetMaximum(Double_t maximum=-1111);
00270 virtual void SetMinimum(Double_t minimum=-1111);
00271 virtual void SetNDF(Int_t ndf);
00272 virtual void SetNumberFitPoints(Int_t npfits) {fNpfits = npfits;}
00273 virtual void SetNpx(Int_t npx=100);
00274 virtual void SetParError(Int_t ipar, Double_t error);
00275 virtual void SetParErrors(const Double_t *errors);
00276 virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax);
00277 virtual void SetParent(TObject *p=0) {fParent = p;}
00278 virtual void SetRange(Double_t xmin, Double_t xmax);
00279 virtual void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax);
00280 virtual void SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax);
00281 virtual void SetSavedPoint(Int_t point, Double_t value);
00282 virtual void SetTitle(const char *title="");
00283 virtual void Update();
00284
00285 static TF1 *GetCurrent();
00286 static void AbsValue(Bool_t reject=kTRUE);
00287 static void RejectPoint(Bool_t reject=kTRUE);
00288 static Bool_t RejectedPoint();
00289 static void SetCurrent(TF1 *f1);
00290
00291
00292 virtual Double_t Moment(Double_t n, Double_t a, Double_t b, const Double_t *params=0, Double_t epsilon=0.000001);
00293 virtual Double_t CentralMoment(Double_t n, Double_t a, Double_t b, const Double_t *params=0, Double_t epsilon=0.000001);
00294 virtual Double_t Mean(Double_t a, Double_t b, const Double_t *params=0, Double_t epsilon=0.000001) {return Moment(1,a,b,params,epsilon);}
00295 virtual Double_t Variance(Double_t a, Double_t b, const Double_t *params=0, Double_t epsilon=0.000001) {return CentralMoment(2,a,b,params,epsilon);}
00296
00297
00298
00299
00300 static void CalcGaussLegendreSamplingPoints(Int_t num, Double_t *x, Double_t *w, Double_t eps=3.0e-11);
00301
00302 ClassDef(TF1,7)
00303 };
00304
00305 inline Double_t TF1::operator()(Double_t x, Double_t y, Double_t z, Double_t t) const
00306 { return Eval(x,y,z,t); }
00307 inline Double_t TF1::operator()(const Double_t *x, const Double_t *params)
00308 {
00309 if (fMethodCall) InitArgs(x,params);
00310 return EvalPar(x,params);
00311 }
00312
00313
00314 inline void TF1::SetRange(Double_t xmin, Double_t, Double_t xmax, Double_t)
00315 { TF1::SetRange(xmin, xmax); }
00316 inline void TF1::SetRange(Double_t xmin, Double_t, Double_t, Double_t xmax, Double_t, Double_t)
00317 { TF1::SetRange(xmin, xmax); }
00318
00319 template <typename Func>
00320 void TF1::SetFunction( Func f ) {
00321
00322 fType = 1;
00323 fFunctor = ROOT::Math::ParamFunctor(f);
00324 }
00325 template <class PtrObj, typename MemFn>
00326 void TF1::SetFunction( PtrObj& p, MemFn memFn ) {
00327
00328 fType = 1;
00329 fFunctor = ROOT::Math::ParamFunctor(p,memFn);
00330 }
00331
00332 #endif