Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TF3.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 27/10/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// ---------------------------------- F3.h
12
13#ifndef ROOT_TF3
14#define ROOT_TF3
15
16
17
18//////////////////////////////////////////////////////////////////////////
19// //
20// TF3 //
21// //
22// The Parametric 3-D function //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "TF2.h"
27
28class TF3 : public TF2 {
29
30protected:
31 Double_t fZmin; ///< Lower bound for the range in z
32 Double_t fZmax; ///< Upper bound for the range in z
33 Int_t fNpz; ///< Number of points along z used for the graphical representation
34 Bool_t fClipBoxOn{kFALSE}; ///<! Is clip box on
35 Double_t fClipBox[3]; ///<! Coordinates of clipbox
36public:
37 TF3();
38 TF3(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
39 Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Option_t * opt = nullptr);
40 TF3(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
41 Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3);
42 TF3(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
43 Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3);
44
45 // Constructor using a functor
46 TF3(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0, Double_t ymax = 1, Double_t zmin=0, Double_t zmax=1, Int_t npar = 0, Int_t ndim = 3);
47
48 /// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
49 template <class PtrObj, typename MemFn>
50 TF3(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar,
51 Int_t ndim = 3) :
52 TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,ndim),
53 fZmin(zmin), fZmax(zmax), fNpz(30)
54 { }
55
56 /// Backward compatible ctor
57 template <class PtrObj, typename MemFn>
58 TF3(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar,
59 const char * , const char * ) :
60 TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,3),
61 fZmin(zmin), fZmax(zmax), fNpz(30)
62 { }
63
64 /// Template constructors from any C++ callable object, defining the operator() (double * , double *) and returning a double.
65 template <typename Func>
66 TF3(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar,
67 Int_t ndim = 3 ) :
68 TF2(name,f,xmin,xmax,ymin,ymax,npar,ndim),
69 fZmin(zmin), fZmax(zmax), fNpz(30)
70 { }
71
72 /// Backward compatible ctor
73 template <typename Func>
74 TF3(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar,
75 const char * ) :
76 TF2(name,f,xmin,xmax,ymin,ymax,npar,3),
77 fZmin(zmin), fZmax(zmax), fNpz(30)
78 { }
79
80 TF3(const TF3 &f3);
81 TF3& operator=(const TF3 &rhs);
82 ~TF3() override;
83 void Copy(TObject &f3) const override;
84 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
85 void Draw(Option_t *option="") override;
86 TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
87 TObject *DrawIntegral(Option_t * ="al") override {return nullptr;}
88 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
91 Int_t GetNpz() const {return fNpz;}
92 virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom * rng = nullptr);
93 using TF1::GetRange;
94 void GetRange(Double_t &xmin, Double_t &xmax) const override;
95 void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override ;
96 void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
97 Double_t GetSave(const Double_t *x) override;
98 virtual Double_t GetZmin() const {return fZmin;}
99 virtual Double_t GetZmax() const {return fZmax;}
100 using TF2::Integral;
101 virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsrel=1.e-6);
102 Bool_t IsInside(const Double_t *x) const override;
103 TH1 *CreateHistogram() override;
104 void Paint(Option_t *option="") override;
105 void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override;
106 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
107 virtual void SetClippingBoxOff(); // *MENU*
108 virtual Bool_t GetClippingBoxOn() const { return fClipBoxOn; }
109 virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0); // *MENU*
110 virtual const Double_t *GetClippingBox() const { return fClipBoxOn ? fClipBox : nullptr; }
111 virtual void SetNpz(Int_t npz=30);
112 void SetRange(Double_t xmin, Double_t xmax) override;
114 void SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax) override; // *MENU*
115
116 //Moments
117 virtual Double_t Moment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001);
118 virtual Double_t CentralMoment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001);
119
120 virtual Double_t Mean3X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return Moment3(1,ax,bx,0,ay,by,0,az,bz,epsilon);}
121 virtual Double_t Mean3Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return Moment3(0,ax,bx,1,ay,by,0,az,bz,epsilon);}
122 virtual Double_t Mean3Z(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return Moment3(0,ax,bx,0,ay,by,1,az,bz,epsilon);}
123
124 virtual Double_t Variance3X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(2,ax,bx,0,ay,by,0,az,bz,epsilon);}
125 virtual Double_t Variance3Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(0,ax,bx,2,ay,by,0,az,bz,epsilon);}
126 virtual Double_t Variance3Z(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(0,ax,bx,0,ay,by,2,az,bz,epsilon);}
127
128 virtual Double_t Covariance3XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(1,ax,bx,1,ay,by,0,az,bz,epsilon);}
129 virtual Double_t Covariance3XZ(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(1,ax,bx,0,ay,by,1,az,bz,epsilon);}
130 virtual Double_t Covariance3YZ(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001) {return CentralMoment3(0,ax,bx,1,ay,by,1,az,bz,epsilon);}
131
132protected:
133
134 Double_t FindMinMax(Double_t* x, bool findmax) const override;
135
136 ClassDefOverride(TF3,3) //The Parametric 3-D function
137};
138
140 { TF2::GetRange(xmin, xmax); }
144 { TF2::SetRange(xmin, xmax); }
147
148#endif
#define f(i)
Definition RSha256.hxx:104
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
Param Functor class for Multidimensional functions.
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
Definition TF1.cxx:2279
A 2-Dim function with parameters.
Definition TF2.h:29
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Return range of a 2-D function.
Definition TF2.cxx:598
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6)
Return Integral of a 2d function in range [ax,bx],[ay,by] with desired relative accuracy (defined by ...
Definition TF2.cxx:661
void SetRange(Double_t xmin, Double_t xmax) override
Initialize the upper and lower bounds to draw the function.
Definition TF2.h:146
A 3-Dim function with parameters.
Definition TF3.h:28
virtual Double_t GetZmin() const
Definition TF3.h:98
virtual Double_t Covariance3XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:128
void GetRange(Double_t &xmin, Double_t &xmax) const override
Return range of a 1-D function.
Definition TF3.h:139
TF3()
F3 default constructor.
Definition TF3.cxx:37
TObject * DrawIntegral(Option_t *="al") override
Draw integral of this function.
Definition TF3.h:87
void Paint(Option_t *option="") override
Paint this 3-D function with its current attributes.
Definition TF3.cxx:517
Int_t GetNpz() const
Definition TF3.h:91
virtual Double_t Mean3Z(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:122
virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom *rng=nullptr)
Return 3 random numbers following this function shape.
Definition TF3.cxx:342
Bool_t IsInside(const Double_t *x) const override
Return kTRUE is the point is inside the function range.
Definition TF3.cxx:494
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TF3.cxx:209
Double_t fZmin
Lower bound for the range in z.
Definition TF3.h:31
TF3 & operator=(const TF3 &rhs)
Operator =.
Definition TF3.cxx:145
virtual void SetNpz(Int_t npz=30)
Set the number of points used to draw the function.
Definition TF3.cxx:684
virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z)
Compute the X, Y and Z values corresponding to the maximum value of the function on its range.
Definition TF3.cxx:314
TF3(const char *name, const PtrObj &p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar, const char *, const char *)
Backward compatible ctor.
Definition TF3.h:58
virtual Double_t CentralMoment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Return x^nx * y^ny * z^nz central moment of a 3d function in range [ax,bx],[ay,by],...
Definition TF3.cxx:764
void Copy(TObject &f3) const override
Copy this F3 to a new F3.
Definition TF3.cxx:170
Double_t FindMinMax(Double_t *x, bool findmax) const override
Return minimum/maximum value of the function.
Definition TF3.cxx:230
~TF3() override
F3 default destructor.
Definition TF3.cxx:155
virtual Double_t Covariance3XZ(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:129
Bool_t fClipBoxOn
! Is clip box on
Definition TF3.h:34
virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z)
Compute the X, Y and Z values corresponding to the minimum value of the function on its range.
Definition TF3.cxx:298
virtual Double_t Variance3Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:125
virtual Double_t Moment3(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t nz, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Return x^nx * y^ny * z^nz moment of a 3d function in range [ax,bx],[ay,by],[az,bz].
Definition TF3.cxx:739
Int_t fNpz
Number of points along z used for the graphical representation.
Definition TF3.h:33
virtual Bool_t GetClippingBoxOn() const
Definition TF3.h:108
virtual Double_t Covariance3YZ(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:130
TF3(const char *name, const PtrObj &p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar, Int_t ndim=3)
Template constructors from a pointer to any C++ class of type PtrObj with a specific member function ...
Definition TF3.h:50
virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0)
Set the function clipping box (for drawing) "on" and define the clipping box.
Definition TF3.cxx:668
TF3(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar, Int_t ndim=3)
Template constructors from any C++ callable object, defining the operator() (double * ,...
Definition TF3.h:66
virtual void SetClippingBoxOff()
Set the function clipping box (for drawing) "off".
Definition TF3.cxx:542
TObject * DrawDerivative(Option_t *="al") override
Draw derivative of this function.
Definition TF3.h:86
virtual const Double_t * GetClippingBox() const
Definition TF3.h:110
Double_t fZmax
Upper bound for the range in z.
Definition TF3.h:32
virtual Double_t Variance3X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:124
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a function.
Definition TF3.cxx:185
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsrel=1.e-6)
Return Integral of a 3d function in range [ax,bx],[ay,by],[az,bz] with a desired relative accuracy.
Definition TF3.cxx:468
virtual Double_t Mean3X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:120
virtual Double_t GetZmax() const
Definition TF3.h:99
virtual Double_t Variance3Z(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:126
TF3(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax, Int_t npar, const char *)
Backward compatible ctor.
Definition TF3.h:74
TH1 * CreateHistogram() override
Create a histogram for axis range.
Definition TF3.cxx:505
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override
Save values of function in array fSave.
Definition TF3.cxx:551
virtual Double_t Mean3Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t az, Double_t bz, Double_t epsilon=0.000001)
Definition TF3.h:121
Double_t GetSave(const Double_t *x) override
Get value corresponding to X in array of fSave values.
Definition TF3.cxx:415
Double_t fClipBox[3]
! Coordinates of clipbox
Definition TF3.h:35
void SetRange(Double_t xmin, Double_t xmax) override
Initialize the upper and lower bounds to draw the function.
Definition TF3.h:143
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TF3.cxx:608
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
Mother of all ROOT objects.
Definition TObject.h:41
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
th1 Draw()