Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:26:46

0001 // @(#)root/hist:$Id$
0002 // Author: Rene Brun   27/10/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 // ---------------------------------- F3.h
0012 
0013 #ifndef ROOT_TF3
0014 #define ROOT_TF3
0015 
0016 
0017 
0018 //////////////////////////////////////////////////////////////////////////
0019 //                                                                      //
0020 // TF3                                                                  //
0021 //                                                                      //
0022 // The Parametric 3-D function                                          //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "TF2.h"
0027 
0028 class TF3 : public TF2 {
0029 
0030 protected:
0031    Double_t  fZmin;              ///<  Lower bound for the range in z
0032    Double_t  fZmax;              ///<  Upper bound for the range in z
0033    Int_t     fNpz;               ///<  Number of points along z used for the graphical representation
0034    Bool_t    fClipBoxOn{kFALSE}; ///<! Is clip box on
0035    Double_t  fClipBox[3];        ///<! Coordinates of clipbox
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); // same as above but using a string for option
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    // Constructor using a functor
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    /// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
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    /// Template constructors from any  C++ callable object,  defining  the operator() (double * , double *) and returning a double.
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(); // *MENU*
0096    virtual Bool_t   GetClippingBoxOn() const { return fClipBoxOn; }
0097    virtual void     SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0); // *MENU*
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; // *MENU*
0103 
0104    //Moments
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)  //The Parametric 3-D function
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