Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TF2.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 23/08/95
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// ---------------------------------- F2.h
12
13#ifndef ROOT_TF2
14#define ROOT_TF2
15
16
17
18//////////////////////////////////////////////////////////////////////////
19// //
20// TF2 //
21// //
22// The Parametric 2-D function //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "TF1.h"
27#include "TArrayD.h"
28
29class TF2 : public TF1 {
30
31protected:
32 Double_t fYmin; ///< Lower bound for the range in y
33 Double_t fYmax; ///< Upper bound for the range in y
34 Int_t fNpy; ///< Number of points along y used for the graphical representation
35 TArrayD fContour; ///< Array to display contour levels
36
37public:
38 TF2();
39 TF2(const char *name, const char *formula, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0,
40 Double_t ymax = 1, EAddToList addToGlobList = EAddToList::kDefault, bool vectorize = false);
41 TF2(const char *name, const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax,
42 Option_t *opt); // same as above but using a string for option
44 TF2(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0,Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
45 TF2(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
46
47 // Constructor using a functor
48 TF2(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0, Double_t ymax = 1, Int_t npar = 0, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
49
50 /// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
51 template <class PtrObj, typename MemFn>
52 TF2(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault) :
53 TF1(name,p,memFn,xmin,xmax,npar,ndim, addToGlobList),
54 fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
55 {
56 fNpx = 30;
57 }
58
59 /// Template constructors from any C++ callable object, defining the operator() (double * , double *) and returning a double.
60 template <typename Func>
61 TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar,Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault) :
62 TF1(name,f,xmin,xmax,npar,ndim, addToGlobList),
63 fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
64 {
65 fNpx = 30;
66 }
67
68 TF2(const TF2 &f2);
69 TF2 &operator=(const TF2& rhs);
70 ~TF2() override;
71 void Copy(TObject &f2) const override;
73 void Draw(Option_t *option="") override;
74 TF1 *DrawCopy(Option_t *option="") const override;
75 TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
76 TObject *DrawIntegral(Option_t * ="al") override {return nullptr;}
77 //virtual void DrawF2(const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Option_t *option="");
78 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
79 virtual Int_t GetContour(Double_t *levels=nullptr);
80 virtual Double_t GetContourLevel(Int_t level) const;
81 Int_t GetNpy() const {return fNpy;}
82 char *GetObjectInfo(Int_t px, Int_t py) const override;
83 Double_t GetRandom(TRandom * rng = nullptr, Option_t * opt = nullptr) override;
84 Double_t GetRandom(Double_t xmin, Double_t xmax, TRandom * rng = nullptr, Option_t * opt = nullptr) override;
85 virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom * rng = nullptr);
86 using TF1::GetRange;
88 void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
89 Double_t GetSave(const Double_t *x) override;
92 using TF1::GetMinimum;
93 using TF1::GetMaximum;
94 virtual Double_t GetMinimum(Double_t *x ) const;
95 virtual Double_t GetMaximum(Double_t *x ) const;
96 virtual Double_t GetYmin() const {return fYmin;}
97 virtual Double_t GetYmax() const {return fYmax;}
98 static void InitStandardFunctions();
99 using TF1::Integral;
100 virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6);
101 Bool_t IsInside(const Double_t *x) const override;
102 TH1 *CreateHistogram() override;
103 void Paint(Option_t *option="") override;
105 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
106 virtual void SetNpy(Int_t npy=100); // *MENU*
107 virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr);
108 virtual void SetContourLevel(Int_t level, Double_t value);
109 void SetRange(Double_t xmin, Double_t xmax) override;
112 void SetSavedPoint(Int_t point, Double_t value) override;
113
114 //Moments
115 virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
116 virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
117
118 virtual Double_t Mean2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(1,ax,bx,0,ay,by,epsilon);}
119 virtual Double_t Mean2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(0,ax,bx,1,ay,by,epsilon);}
120
121 virtual Double_t Variance2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(2,ax,bx,0,ay,by,epsilon);}
122 virtual Double_t Variance2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(0,ax,bx,2,ay,by,epsilon);}
123
124 virtual Double_t Covariance2XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(1,ax,bx,1,ay,by,epsilon);}
125
126protected:
127
128 virtual Double_t FindMinMax(Double_t* x, bool findmax) const;
129
130 ClassDefOverride(TF2,4) //The Parametric 2-D function
131};
132
137
138#endif
#define f(i)
Definition RSha256.hxx:104
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
char name[80]
Definition TGX11.cxx:148
float xmin
float ymin
float xmax
float ymax
Array of doubles (64 bits per element).
Definition TArrayD.h:27
EAddToList
Add to list behavior.
Definition TF1.h:189
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
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
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
virtual void SetRange(Double_t xmin, Double_t xmax)
TF1(EFType functionType, const char *name, Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim, EAddToList addToGlobList, TF1Parameters *params=nullptr, TF1FunctorPointer *functor=nullptr)
General constructor for TF1. Most of the other constructors delegate on it.
Definition TF1.h:242
Int_t fNpx
Number of points used for the graphical representation.
Definition TF1.h:216
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
void SetSavedPoint(Int_t point, Double_t value) override
~TF2() override
virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const
void Copy(TObject &f2) const override
Copy this to obj.
Double_t GetSave(const Double_t *x) override
virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const
TF2(const char *name, const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Option_t *opt)
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
virtual Double_t Mean2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Definition TF2.h:118
virtual Double_t Variance2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Definition TF2.h:121
Double_t GetRandom(Double_t xmin, Double_t xmax, TRandom *rng=nullptr, Option_t *opt=nullptr) override
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
TH1 * CreateHistogram() override
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
TF2(const char *name, const PtrObj &p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
Template constructors from a pointer to any C++ class of type PtrObj with a specific member function ...
Definition TF2.h:52
TF2(const char *name, Double_t(*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
Bool_t IsInside(const Double_t *x) const override
return kTRUE if the point is inside the function range
TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
Template constructors from any C++ callable object, defining the operator() (double * ,...
Definition TF2.h:61
virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
virtual Double_t Mean2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Definition TF2.h:119
void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override
TF1 * DrawCopy(Option_t *option="") const override
Int_t fNpy
Number of points along y used for the graphical representation.
Definition TF2.h:34
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom *rng=nullptr)
TArrayD fContour
Array to display contour levels.
Definition TF2.h:35
void Draw(Option_t *option="") override
Default Draw method for all objects.
TF2(const TF2 &f2)
virtual Double_t GetYmax() const
Definition TF2.h:97
virtual Double_t Covariance2XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Definition TF2.h:124
virtual Double_t GetYmin() const
Definition TF2.h:96
Double_t fYmax
Upper bound for the range in y.
Definition TF2.h:33
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
TF2 & operator=(const TF2 &rhs)
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override
TObject * DrawIntegral(Option_t *="al") override
Definition TF2.h:76
char * GetObjectInfo(Int_t px, Int_t py) const override
Returns string containing info about the object at position (px,py).
TObject * DrawDerivative(Option_t *="al") override
Definition TF2.h:75
TF2(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, EAddToList addToGlobList=EAddToList::kDefault, bool vectorize=false)
TF2(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
virtual Double_t Variance2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Definition TF2.h:122
Double_t fYmin
Lower bound for the range in y.
Definition TF2.h:32
Int_t GetNpy() const
Definition TF2.h:81
TF2(const char *name, Double_t(*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
virtual void SetNpy(Int_t npy=100)
static void InitStandardFunctions()
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
virtual Int_t GetContour(Double_t *levels=nullptr)
virtual void SetContourLevel(Int_t level, Double_t value)
TF2(const char *name, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim=2, EAddToList addToGlobList=EAddToList::kDefault)
virtual Double_t GetMaximum(Double_t *x) const
Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr) override
virtual Double_t GetContourLevel(Int_t level) const
void SetRange(Double_t xmin, Double_t xmax) override
Definition TF2.h:133
virtual Double_t GetMinimum(Double_t *x) const
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6)
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TObject()
TObject constructor.
Definition TObject.h:259
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
ParamFunctorTempl< double > ParamFunctor