Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:45

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, Option_t * opt = nullptr);
0040    TF3(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0,
0041        Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3);
0042    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,
0043        Double_t ymax=1, Double_t zmin=0, Double_t zmax=1, Int_t npar=0, Int_t ndim = 3);
0044 
0045    // Constructor using a functor
0046    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);
0047 
0048    /// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
0049    template <class PtrObj, typename MemFn>
0050    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,
0051        Int_t ndim = 3) :
0052       TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,ndim),
0053       fZmin(zmin), fZmax(zmax), fNpz(30)
0054    {   }
0055 
0056    /// Backward compatible ctor
0057    template <class PtrObj, typename MemFn>
0058    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,
0059        const char * , const char *  ) :
0060       TF2(name,p,memFn,xmin,xmax,ymin,ymax,npar,3),
0061       fZmin(zmin), fZmax(zmax), fNpz(30)
0062    {   }
0063 
0064    /// Template constructors from any  C++ callable object,  defining  the operator() (double * , double *) and returning a double.
0065    template <typename Func>
0066    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,
0067        Int_t ndim = 3 ) :
0068       TF2(name,f,xmin,xmax,ymin,ymax,npar,ndim),
0069       fZmin(zmin), fZmax(zmax), fNpz(30)
0070    { }
0071 
0072    /// Backward compatible ctor
0073    template <typename Func>
0074    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,
0075        const char *  ) :
0076       TF2(name,f,xmin,xmax,ymin,ymax,npar,3),
0077       fZmin(zmin), fZmax(zmax), fNpz(30)
0078    { }
0079 
0080    TF3(const TF3 &f3);
0081    TF3& operator=(const TF3 &rhs);
0082      ~TF3() override;
0083    void     Copy(TObject &f3) const override;
0084    Int_t    DistancetoPrimitive(Int_t px, Int_t py) override;
0085    void     Draw(Option_t *option="") override;
0086    TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
0087    TObject *DrawIntegral(Option_t * ="al") override   {return nullptr;}
0088    void     ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0089    virtual Double_t GetMinimumXYZ(Double_t &x, Double_t &y, Double_t &z);
0090    virtual Double_t GetMaximumXYZ(Double_t &x, Double_t &y, Double_t &z);
0091           Int_t     GetNpz() const {return fNpz;}
0092    virtual void     GetRandom3(Double_t &xrandom, Double_t &yrandom, Double_t &zrandom, TRandom * rng = nullptr);
0093    using TF1::GetRange;
0094    void     GetRange(Double_t &xmin, Double_t &xmax) const override;
0095    void     GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override ;
0096    void     GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
0097    Double_t GetSave(const Double_t *x) override;
0098    virtual Double_t GetZmin() const {return fZmin;}
0099    virtual Double_t GetZmax() const {return fZmax;}
0100    using TF2::Integral;
0101    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);
0102    Bool_t   IsInside(const Double_t *x) const override;
0103    TH1     *CreateHistogram() override;
0104    void     Paint(Option_t *option="") override;
0105    void     Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override;
0106    void     SavePrimitive(std::ostream &out, Option_t *option = "") override;
0107    virtual void     SetClippingBoxOff(); // *MENU*
0108    virtual Bool_t   GetClippingBoxOn() const { return fClipBoxOn; }
0109    virtual void     SetClippingBoxOn(Double_t xclip=0, Double_t yclip=0, Double_t zclip=0); // *MENU*
0110    virtual const Double_t *GetClippingBox() const { return fClipBoxOn ? fClipBox : nullptr; }
0111    virtual void     SetNpz(Int_t npz=30);
0112    void     SetRange(Double_t xmin, Double_t xmax) override;
0113    void     SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override;
0114    void     SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax) override; // *MENU*
0115 
0116    //Moments
0117    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);
0118    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);
0119 
0120    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);}
0121    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);}
0122    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);}
0123 
0124    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);}
0125    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);}
0126    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);}
0127 
0128    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);}
0129    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);}
0130    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);}
0131 
0132 protected:
0133 
0134    Double_t FindMinMax(Double_t* x, bool findmax) const override;
0135 
0136    ClassDefOverride(TF3,3)  //The Parametric 3-D function
0137 };
0138 
0139 inline void TF3::GetRange(Double_t &xmin, Double_t &xmax) const
0140    { TF2::GetRange(xmin, xmax); }
0141 inline void TF3::GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
0142    { TF2::GetRange(xmin, ymin, xmax, ymax); }
0143 inline void TF3::SetRange(Double_t xmin, Double_t xmax)
0144    { TF2::SetRange(xmin, xmax); }
0145 inline void TF3::SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
0146    { TF2::SetRange(xmin, ymin, xmax, ymax); }
0147 
0148 #endif