Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TF2.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/hist:$Id$
0002 // Author: Rene Brun   23/08/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 // ---------------------------------- F2.h
0012 
0013 #ifndef ROOT_TF2
0014 #define ROOT_TF2
0015 
0016 
0017 
0018 //////////////////////////////////////////////////////////////////////////
0019 //                                                                      //
0020 // TF2                                                                  //
0021 //                                                                      //
0022 // The Parametric 2-D function                                          //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "TF1.h"
0027 #include "TArrayD.h"
0028 
0029 class TF2 : public TF1 {
0030 
0031 protected:
0032    Double_t  fYmin;        ///< Lower bound for the range in y
0033    Double_t  fYmax;        ///< Upper bound for the range in y
0034    Int_t     fNpy;         ///< Number of points along y used for the graphical representation
0035    TArrayD   fContour;     ///< Array to display contour levels
0036 
0037 public:
0038    TF2();
0039    TF2(const char *name, const char *formula, Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Option_t * opt = nullptr);
0040    TF2(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0,Int_t ndim = 2);
0041    TF2(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim = 2);
0042 
0043    // Constructor using a functor
0044    TF2(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0, Double_t ymax = 1, Int_t npar = 0, Int_t ndim = 2);
0045 
0046    /// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
0047    template <class PtrObj, typename MemFn>
0048    TF2(const char *name, const  PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim = 2) :
0049       TF1(name,p,memFn,xmin,xmax,npar,ndim),
0050    fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
0051    {
0052       fNpx = 30;
0053    }
0054 
0055    /// Backward compatible ctor
0056    template <class PtrObj, typename MemFn>
0057    TF2(const char *name, const  PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, const char * , const char *) :
0058       TF1(name,p,memFn,xmin,xmax,npar,2),
0059    fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
0060    {
0061       fNpx = 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    TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar,Int_t ndim = 2) :
0067       TF1(name,f,xmin,xmax,npar,ndim),
0068    fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
0069    {
0070       fNpx = 30;
0071    }
0072 
0073    /// Backward compatible ctor
0074    template <typename Func>
0075    TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar,const char *) :
0076       TF1(name,f,xmin,xmax,npar,2),
0077    fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
0078    {
0079       fNpx = 30;
0080    }
0081 
0082 
0083    TF2(const TF2 &f2);
0084    TF2 &operator=(const TF2& rhs);
0085      ~TF2() override;
0086    void     Copy(TObject &f2) const override;
0087    Int_t    DistancetoPrimitive(Int_t px, Int_t py) override;
0088    void     Draw(Option_t *option="") override;
0089    TF1     *DrawCopy(Option_t *option="") const override;
0090    TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
0091    TObject *DrawIntegral(Option_t * ="al") override   {return nullptr;}
0092    //virtual void     DrawF2(const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Option_t *option="");
0093    void     ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0094    virtual Int_t    GetContour(Double_t *levels=nullptr);
0095    virtual Double_t GetContourLevel(Int_t level) const;
0096           Int_t     GetNpy() const {return fNpy;}
0097    char    *GetObjectInfo(Int_t px, Int_t py) const override;
0098    Double_t GetRandom(TRandom * rng = nullptr, Option_t * opt = nullptr) override;
0099    Double_t GetRandom(Double_t xmin, Double_t xmax, TRandom * rng = nullptr, Option_t * opt = nullptr) override;
0100    virtual void     GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom * rng = nullptr);
0101    using TF1::GetRange;
0102    void     GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override;
0103    void     GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
0104    Double_t GetSave(const Double_t *x) override;
0105    virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const;
0106    virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const;
0107    using TF1::GetMinimum;
0108    using TF1::GetMaximum;
0109    virtual Double_t GetMinimum(Double_t *x ) const;
0110    virtual Double_t GetMaximum(Double_t *x ) const;
0111    virtual Double_t GetYmin() const {return fYmin;}
0112    virtual Double_t GetYmax() const {return fYmax;}
0113    using TF1::Integral;
0114    virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6);
0115    Bool_t   IsInside(const Double_t *x) const override;
0116    TH1     *CreateHistogram() override;
0117    void     Paint(Option_t *option="") override;
0118    void     Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override;
0119    void     SavePrimitive(std::ostream &out, Option_t *option = "") override;
0120    virtual void     SetNpy(Int_t npy=100); // *MENU*
0121    virtual void     SetContour(Int_t nlevels=20, const Double_t *levels=nullptr);
0122    virtual void     SetContourLevel(Int_t level, Double_t value);
0123    void     SetRange(Double_t xmin, Double_t xmax) override;
0124    void     SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override; // *MENU*
0125    void     SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax) override;
0126 
0127    //Moments
0128    virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
0129    virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
0130 
0131    virtual Double_t Mean2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(1,ax,bx,0,ay,by,epsilon);}
0132    virtual Double_t Mean2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(0,ax,bx,1,ay,by,epsilon);}
0133 
0134    virtual Double_t Variance2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(2,ax,bx,0,ay,by,epsilon);}
0135    virtual Double_t Variance2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(0,ax,bx,2,ay,by,epsilon);}
0136 
0137    virtual Double_t Covariance2XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(1,ax,bx,1,ay,by,epsilon);}
0138 
0139 protected:
0140 
0141    virtual Double_t FindMinMax(Double_t* x, bool findmax) const;
0142 
0143    ClassDefOverride(TF2,4)  //The Parametric 2-D function
0144 };
0145 
0146 inline void TF2::SetRange(Double_t xmin, Double_t xmax)
0147    { TF1::SetRange(xmin, xmax); }
0148 inline void TF2::SetRange(Double_t xmin, Double_t ymin, Double_t, Double_t xmax, Double_t ymax, Double_t)
0149    { SetRange(xmin, ymin, xmax, ymax); }
0150 
0151 #endif