Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:04

0001 // @(#)root/hist:$Id: TGraph2D.h,v 1.00
0002 // Author: Olivier Couet
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 
0012 #ifndef ROOT_TGraph2D
0013 #define ROOT_TGraph2D
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TGraph2D                                                             //
0019 //                                                                      //
0020 // Graph 2D graphics class.                                             //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TNamed.h"
0025 #include "TAttLine.h"
0026 #include "TAttFill.h"
0027 #include "TAttMarker.h"
0028 
0029 class TAxis;
0030 class TList;
0031 class TF2;
0032 class TH1;
0033 class TH2;
0034 class TH2D;
0035 class TView;
0036 class TDirectory;
0037 class TVirtualHistPainter;
0038 
0039 #include "TFitResultPtr.h"
0040 
0041 class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
0042 
0043 protected:
0044 
0045    Int_t       fNpoints;          ///< Number of points in the data set
0046    Int_t       fNpx;              ///< Number of bins along X in fHistogram
0047    Int_t       fNpy;              ///< Number of bins along Y in fHistogram
0048    Int_t       fMaxIter;          ///< Maximum number of iterations to find Delaunay triangles
0049    Int_t       fSize;             ///<!Real size of fX, fY and fZ
0050    Double_t   *fX;                ///<[fNpoints]
0051    Double_t   *fY;                ///<[fNpoints] Data set to be plotted
0052    Double_t   *fZ;                ///<[fNpoints]
0053    Double_t    fMinimum;          ///< Minimum value for plotting along z
0054    Double_t    fMaximum;          ///< Maximum value for plotting along z
0055    Double_t    fMargin;           ///< Extra space (in %) around interpolated area for fHistogram
0056    Double_t    fZout;             ///< fHistogram bin height for points lying outside the interpolated area
0057    TList      *fFunctions;        ///< Pointer to list of functions (fits and user)
0058    TH2D       *fHistogram;        ///<!2D histogram of z values linearly interpolated on the triangles
0059    TObject    *fDelaunay;         ///<! Pointer to Delaunay interpolator object
0060    TDirectory *fDirectory;        ///<!Pointer to directory holding this 2D graph
0061    TVirtualHistPainter *fPainter; ///<!Pointer to histogram painter
0062 
0063    void     Build(Int_t n);
0064 
0065 private:
0066 
0067    Bool_t      fUserHisto;   // True when SetHistogram has been called
0068 
0069    enum EStatusBits {
0070       kOldInterpolation =  BIT(15)
0071    };
0072 
0073    void CreateInterpolator(Bool_t oldInterp);
0074 
0075 protected:
0076 
0077 public:
0078 
0079    TGraph2D();
0080    TGraph2D(Int_t n);
0081    TGraph2D(Int_t n, Int_t *x, Int_t *y, Int_t *z);
0082    TGraph2D(Int_t n, Float_t *x, Float_t *y, Float_t *z);
0083    TGraph2D(Int_t n, Double_t *x, Double_t *y, Double_t *z);
0084    TGraph2D(TH2 *h2);
0085    TGraph2D(const char *name, const char *title, Int_t n, Double_t *x, Double_t *y, Double_t *z);
0086    TGraph2D(const char *filename, const char *format="%lg %lg %lg", Option_t *option="");
0087    TGraph2D(const TGraph2D &);
0088 
0089    ~TGraph2D() override;
0090 
0091    TGraph2D& operator=(const TGraph2D &);
0092 
0093    virtual void          AddPoint(Double_t x, Double_t y, Double_t z) { SetPoint(fNpoints, x, y, z); } ///< Append a new point to the graph.
0094    void          Browse(TBrowser *) override;
0095    void          Clear(Option_t *option="") override;
0096    virtual void          DirectoryAutoAdd(TDirectory *);
0097    Int_t                 DistancetoPrimitive(Int_t px, Int_t py) override;
0098    void          Draw(Option_t *option="P0") override;
0099    void                  ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0100    TObject      *FindObject(const char *name) const override;
0101    TObject      *FindObject(const TObject *obj) const override;
0102    virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption=""); // *MENU*
0103    virtual TFitResultPtr Fit(TF2 *f2 ,Option_t *option="" ,Option_t *goption=""); // *MENU*
0104    virtual void          FitPanel(); // *MENU*
0105    TList                *GetContourList(Double_t contour);
0106    TDirectory           *GetDirectory() const {return fDirectory;}
0107    Int_t                 GetNpx() const {return fNpx;}
0108    Int_t                 GetNpy() const {return fNpy;}
0109    TH2D                 *GetHistogram(Option_t *option="");
0110    TList                *GetListOfFunctions() const { return fFunctions; }
0111    virtual Double_t      GetErrorX(Int_t bin) const;
0112    virtual Double_t      GetErrorY(Int_t bin) const;
0113    virtual Double_t      GetErrorZ(Int_t bin) const;
0114    Double_t              GetMargin() const {return fMargin;}
0115    Double_t              GetMaximum() const {return fMaximum;};
0116    Double_t              GetMinimum() const {return fMinimum;};
0117    TAxis                *GetXaxis() const ;
0118    TAxis                *GetYaxis() const ;
0119    TAxis                *GetZaxis() const ;
0120    Int_t                 GetN() const {return fNpoints;}
0121    Double_t             *GetX() const {return fX;}
0122    Double_t             *GetY() const {return fY;}
0123    Double_t             *GetZ() const {return fZ;}
0124    virtual Double_t     *GetEX() const {return nullptr;}
0125    virtual Double_t     *GetEY() const {return nullptr;}
0126    virtual Double_t     *GetEZ() const {return nullptr;}
0127    virtual Double_t     *GetEXlow() const {return nullptr;}
0128    virtual Double_t     *GetEXhigh() const {return nullptr;}
0129    virtual Double_t     *GetEYlow() const {return nullptr;}
0130    virtual Double_t     *GetEYhigh() const {return nullptr;}
0131    virtual Double_t     *GetEZlow() const {return nullptr;}
0132    virtual Double_t     *GetEZhigh() const {return nullptr;}
0133    Double_t              GetXmax() const;
0134    Double_t              GetXmin() const;
0135    Double_t              GetYmax() const;
0136    Double_t              GetYmin() const;
0137    Double_t              GetZmax() const;
0138    Double_t              GetZmin() const;
0139    virtual Double_t      GetXmaxE() const {return GetXmax();}
0140    virtual Double_t      GetXminE() const {return GetXmin();}
0141    virtual Double_t      GetYmaxE() const {return GetYmax();}
0142    virtual Double_t      GetYminE() const {return GetYmin();}
0143    virtual Double_t      GetZmaxE() const {return GetZmax();}
0144    virtual Double_t      GetZminE() const {return GetZmin();}
0145    virtual Int_t         GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const;
0146    Double_t              Interpolate(Double_t x, Double_t y);
0147    void                  Paint(Option_t *option="") override;
0148    void          Print(Option_t *chopt="") const override;
0149    TH1                  *Project(Option_t *option="x") const; // *MENU*
0150    Int_t                 RemovePoint(Int_t ipoint); // *MENU*
0151    void          SavePrimitive(std::ostream &out, Option_t *option = "") override;
0152    virtual void          Scale(Double_t c1=1., Option_t *option="z"); // *MENU*
0153    virtual void          Set(Int_t n);
0154    virtual void          SetDirectory(TDirectory *dir);
0155    virtual void          SetHistogram(TH2 *h, Option_t *option="");
0156    void                  SetMargin(Double_t m=0.1); // *MENU*
0157    void                  SetMarginBinsContent(Double_t z=0.); // *MENU*
0158    void                  SetMaximum(Double_t maximum=-1111); // *MENU*
0159    void                  SetMinimum(Double_t minimum=-1111); // *MENU*
0160    void                  SetMaxIter(Int_t n=100000) {fMaxIter = n;} // *MENU*
0161    void          SetName(const char *name) override; // *MENU*
0162    void          SetNameTitle(const char *name, const char *title) override;
0163    void                  SetNpx(Int_t npx=40); // *MENU*
0164    void                  SetNpy(Int_t npx=40); // *MENU*
0165    virtual void          SetPoint(Int_t point, Double_t x, Double_t y, Double_t z); // *MENU*
0166    void          SetTitle(const char *title="") override; // *MENU*
0167 
0168 
0169    ClassDefOverride(TGraph2D,1)  //Set of n x[n],y[n],z[n] points with 3-d graphics including Delaunay triangulation
0170 };
0171 
0172 #endif