File indexing completed on 2026-09-16 09:26:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TF3
0014 #define ROOT_TF3
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "TF2.h"
0027
0028 class TF3 : public TF2 {
0029
0030 protected:
0031 Double_t fZmin;
0032 Double_t fZmax;
0033 Int_t fNpz;
0034 Bool_t fClipBoxOn{kFALSE};
0035 Double_t fClipBox[3];
0036 public:
0037 TF3();
0038 TF3(const char *name, const char *formula, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0,
0039 Double_t ymax = 1, Double_t zmin = 0, Double_t zmax = 1, EAddToList addToGlobList = EAddToList::kDefault,
0040 bool vectorize = false);
0041 TF3(const char *name, const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin,
0042 Double_t zmax, Option_t *opt);
0043 TF3(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
0044 Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3, EAddToList addToGlobList = EAddToList::kDefault);
0045 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,
0046 Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3, EAddToList addToGlobList = EAddToList::kDefault);
0047
0048
0049 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, EAddToList addToGlobList = EAddToList::kDefault);
0050
0051
0052 template <class PtrObj, typename MemFn>
0053 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,
0054 Int_t ndim = 3, EAddToList addToGlobList = EAddToList::kDefault) :
0055 TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,ndim,addToGlobList),
0056 fZmin(zmin), fZmax(zmax), fNpz(30)
0057 { }
0058
0059
0060 template <typename Func>
0061 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,
0062 Int_t ndim = 3, EAddToList addToGlobList = EAddToList::kDefault) :
0063 TF2(name,f,xmin,xmax,ymin,ymax,npar,ndim,addToGlobList),
0064 fZmin(zmin), fZmax(zmax), fNpz(30)
0065 { }
0066
0067 TF3(const TF3 &f3);
0068 TF3& operator=(const TF3 &rhs);
0069 ~TF3() override;
0070 void Copy(TObject &f3) const override;
0071 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
0072 void Draw(Option_t *option="") override;
0073 TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
0074 TObject *DrawIntegral(Option_t * ="al") override {return nullptr;}
0075 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0076 virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z);
0077 virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z);
0078 Int_t GetNpz() const {return fNpz;}
0079 virtual void GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom * rng = nullptr);
0080 using TF1::GetRange;
0081 void GetRange(Double_t &xmin, Double_t &xmax) const override;
0082 void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override ;
0083 void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
0084 Double_t GetSave(const Double_t *x) override;
0085 virtual Double_t GetZmin() const {return fZmin;}
0086 virtual Double_t GetZmax() const {return fZmax;}
0087 static void InitStandardFunctions();
0088 using TF2::Integral;
0089 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);
0090 Bool_t IsInside(const Double_t *x) const override;
0091 TH1 *CreateHistogram() override;
0092 void Paint(Option_t *option="") override;
0093 void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override;
0094 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0095 virtual void SetClippingBoxOff();
0096 virtual Bool_t GetClippingBoxOn() const { return fClipBoxOn; }
0097 virtual void SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0);
0098 virtual const Double_t *GetClippingBox() const { return fClipBoxOn ? fClipBox : nullptr; }
0099 virtual void SetNpz(Int_t npz=30);
0100 void SetRange(Double_t xmin, Double_t xmax) override;
0101 void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0102 void SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax) override;
0103
0104
0105 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);
0106 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);
0107
0108 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);}
0109 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);}
0110 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);}
0111
0112 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);}
0113 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);}
0114 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);}
0115
0116 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);}
0117 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);}
0118 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);}
0119
0120 protected:
0121
0122 Double_t FindMinMax(Double_t* x, bool findmax) const override;
0123
0124 ClassDefOverride(TF3,3)
0125 };
0126
0127 inline void TF3::GetRange(Double_t &xmin, Double_t &xmax) const
0128 { TF2::GetRange(xmin, xmax); }
0129 inline void TF3::GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
0130 { TF2::GetRange(xmin, ymin, xmax, ymax); }
0131 inline void TF3::SetRange(Double_t xmin, Double_t xmax)
0132 { TF2::SetRange(xmin, xmax); }
0133 inline void TF3::SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
0134 { TF2::SetRange(xmin, ymin, xmax, ymax); }
0135
0136 #endif