Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
28 class TF3 : public TF2 {
29 
30 protected:
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 
35 public:
36  TF3();
37  TF3(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
38  Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Option_t * opt = nullptr);
39 #ifndef __CINT__
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 #endif
45 
46  // constructor using a functor
47 
48  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);
49 
50 
51  // Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type
52  // MemFn.
53  template <class PtrObj, typename MemFn>
54  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,
55  Int_t ndim = 3) :
56  TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,ndim),
57  fZmin(zmin), fZmax(zmax), fNpz(30)
58  { }
59  /// Backward compatible ctor
60  template <class PtrObj, typename MemFn>
61  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,
62  const char * , const char * ) :
63  TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,3),
64  fZmin(zmin), fZmax(zmax), fNpz(30)
65  { }
66  // Template constructors from any C++ callable object, defining the operator() (double * , double *)
67  // and returning a double.
68  template <typename Func>
69  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,
70  Int_t ndim = 3 ) :
71  TF2(name,f,xmin,xmax,ymin,ymax,npar,ndim),
72  fZmin(zmin), fZmax(zmax), fNpz(30)
73  { }
74  /// backward compatible ctor
75  template <typename Func>
76  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,
77  const char * ) :
78  TF2(name,f,xmin,xmax,ymin,ymax,npar,3),
79  fZmin(zmin), fZmax(zmax), fNpz(30)
80  { }
81 
82  TF3(const TF3 &f3);
83  TF3& operator=(const TF3 &rhs);
84  virtual ~TF3();
85  virtual void Copy(TObject &f3) const;
86  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
87  virtual void Draw(Option_t *option="");
88  virtual TObject *DrawDerivative(Option_t * ="al") {return 0;}
89  virtual TObject *DrawIntegral(Option_t * ="al") {return 0;}
90  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
91  virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z);
92  virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z);
93  Int_t GetNpz() const {return fNpz;}
94  virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom);
95  using TF1::GetRange;
96  virtual void GetRange(Double_t &xmin, Double_t &xmax) const;
97  virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const ;
98  virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const;
99  virtual Double_t GetSave(const Double_t *x);
100  virtual Double_t GetZmin() const {return fZmin;}
101  virtual Double_t GetZmax() const {return fZmax;}
102  using TF2::Integral;
103  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);
104  virtual Bool_t IsInside(const Double_t *x) const;
105  virtual TH1 *CreateHistogram();
106  virtual void Paint(Option_t *option="");
107  virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax);
108  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
109  virtual void SetClippingBoxOff(); // *MENU*
110  virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0); // *MENU*
111  virtual void SetNpz(Int_t npz=30);
112  virtual void SetRange(Double_t xmin, Double_t xmax);
113  virtual void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax);
114  virtual void SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax); // *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 
132 protected:
133 
134  virtual Double_t FindMinMax(Double_t* x, bool findmax) const;
135 
136  ClassDef(TF3,3) //The Parametric 3-D function
137 };
138 
139 inline void TF3::GetRange(Double_t &xmin, Double_t &xmax) const
140  { TF2::GetRange(xmin, xmax); }
141 inline void TF3::GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
142  { TF2::GetRange(xmin, ymin, xmax, ymax); }
143 inline void TF3::SetRange(Double_t xmin, Double_t xmax)
144  { TF2::SetRange(xmin, xmax); }
145 inline void TF3::SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
146  { TF2::SetRange(xmin, ymin, xmax, ymax); }
147 
148 #endif