TGraph.h

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: TGraph.h 36493 2010-11-03 13:01:36Z couet $
00002 // Author: Rene Brun, Olivier Couet   12/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGraph
00013 #define ROOT_TGraph
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGraph                                                               //
00019 //                                                                      //
00020 // Graph graphics class.                                                //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TNamed
00025 #include "TNamed.h"
00026 #endif
00027 #ifndef ROOT_TAttLine
00028 #include "TAttLine.h"
00029 #endif
00030 #ifndef ROOT_TAttFill
00031 #include "TAttFill.h"
00032 #endif
00033 #ifndef ROOT_TAttMarker
00034 #include "TAttMarker.h"
00035 #endif
00036 #ifndef ROOT_TVectorFfwd
00037 #include "TVectorFfwd.h"
00038 #endif
00039 #ifndef ROOT_TVectorDfwd
00040 #include "TVectorDfwd.h"
00041 #endif
00042 
00043 class TBrowser;
00044 class TAxis;
00045 class TH1;
00046 class TH1F;
00047 class TCollection;
00048 class TF1;
00049 class TSpline;
00050 
00051 #include "TFitResultPtr.h"
00052 
00053 class TGraph : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
00054 
00055 protected:
00056 
00057    Int_t              fMaxSize;   //!Current dimension of arrays fX and fY
00058    Int_t              fNpoints;   //Number of points <= fMaxSize
00059    Double_t          *fX;         //[fNpoints] array of X points
00060    Double_t          *fY;         //[fNpoints] array of Y points
00061    TList             *fFunctions; //Pointer to list of functions (fits and user)
00062    TH1F              *fHistogram; //Pointer to histogram used for drawing axis
00063    Double_t           fMinimum;   //Minimum value for plotting along y
00064    Double_t           fMaximum;   //Maximum value for plotting along y
00065 
00066    static void        SwapValues(Double_t* arr, Int_t pos1, Int_t pos2);
00067    virtual void       SwapPoints(Int_t pos1, Int_t pos2);
00068 
00069    virtual Double_t **Allocate(Int_t newsize);
00070    Double_t         **AllocateArrays(Int_t Narrays, Int_t arraySize);
00071    virtual Bool_t     CopyPoints(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin);
00072    virtual void       CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin);
00073    Bool_t             CtorAllocate();
00074    Double_t         **ExpandAndCopy(Int_t size, Int_t iend);
00075    virtual void       FillZero(Int_t begin, Int_t end, Bool_t from_ctor = kTRUE);
00076    Double_t         **ShrinkAndCopy(Int_t size, Int_t iend);
00077 
00078 public:
00079    // TGraph status bits
00080    enum {
00081       kClipFrame     = BIT(10),  // clip to the frame boundary
00082       kNotEditable   = BIT(18)   // bit set if graph is non editable
00083    };
00084 
00085    TGraph();
00086    TGraph(Int_t n);
00087    TGraph(Int_t n, const Int_t *x, const Int_t *y);
00088    TGraph(Int_t n, const Float_t *x, const Float_t *y);
00089    TGraph(Int_t n, const Double_t *x, const Double_t *y);
00090    TGraph(const TGraph &gr);
00091    TGraph& operator=(const TGraph&);
00092    TGraph(const TVectorF &vx, const TVectorF &vy);
00093    TGraph(const TVectorD &vx, const TVectorD &vy);
00094    TGraph(const TH1 *h);
00095    TGraph(const TF1 *f, Option_t *option="");
00096    TGraph(const char *filename, const char *format="%lg %lg", Option_t *option="");
00097    virtual ~TGraph();
00098 
00099    virtual void          Apply(TF1 *f);
00100    virtual void          Browse(TBrowser *b);
00101    virtual Double_t      Chisquare(const TF1 *f1) const;
00102    static Bool_t         CompareArg(const TGraph* gr, Int_t left, Int_t right);
00103    static Bool_t         CompareX(const TGraph* gr, Int_t left, Int_t right);
00104    static Bool_t         CompareY(const TGraph* gr, Int_t left, Int_t right);
00105    static Bool_t         CompareRadius(const TGraph* gr, Int_t left, Int_t right);
00106    virtual void          ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const;
00107    virtual Int_t         DistancetoPrimitive(Int_t px, Int_t py);
00108    virtual void          Draw(Option_t *chopt="");
00109    virtual void          DrawGraph(Int_t n, const Int_t *x, const Int_t *y, Option_t *option="");
00110    virtual void          DrawGraph(Int_t n, const Float_t *x, const Float_t *y, Option_t *option="");
00111    virtual void          DrawGraph(Int_t n, const Double_t *x=0, const Double_t *y=0, Option_t *option="");
00112    virtual void          DrawPanel(); // *MENU*
00113    virtual Double_t      Eval(Double_t x, TSpline *spline=0, Option_t *option="") const;
00114    virtual void          ExecuteEvent(Int_t event, Int_t px, Int_t py);
00115    virtual void          Expand(Int_t newsize);
00116    virtual void          Expand(Int_t newsize, Int_t step);
00117    virtual TObject      *FindObject(const char *name) const;
00118    virtual TObject      *FindObject(const TObject *obj) const;
00119    virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0); // *MENU*
00120    virtual TFitResultPtr Fit(TF1 *f1 ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0);
00121    virtual void          FitPanel(); // *MENU*
00122    Bool_t                GetEditable() const;
00123    TF1                  *GetFunction(const char *name) const;
00124    TH1F                 *GetHistogram() const;
00125    TList                *GetListOfFunctions() const { return fFunctions; }
00126    virtual Double_t      GetCorrelationFactor() const;
00127    virtual Double_t      GetCovariance() const;
00128    virtual Double_t      GetMean(Int_t axis=1) const;
00129    virtual Double_t      GetRMS(Int_t axis=1) const;
00130    Int_t                 GetMaxSize() const {return fMaxSize;}
00131    Int_t                 GetN() const {return fNpoints;}
00132    virtual Double_t      GetErrorX(Int_t bin) const;
00133    virtual Double_t      GetErrorY(Int_t bin) const;
00134    virtual Double_t      GetErrorXhigh(Int_t bin) const;
00135    virtual Double_t      GetErrorXlow(Int_t bin)  const;
00136    virtual Double_t      GetErrorYhigh(Int_t bin) const;
00137    virtual Double_t      GetErrorYlow(Int_t bin)  const;
00138    Double_t             *GetX()  const {return fX;}
00139    Double_t             *GetY()  const {return fY;}
00140    virtual Double_t     *GetEX() const {return 0;}
00141    virtual Double_t     *GetEY() const {return 0;}
00142    virtual Double_t     *GetEXhigh() const {return 0;}
00143    virtual Double_t     *GetEXlow()  const {return 0;}
00144    virtual Double_t     *GetEYhigh() const {return 0;}
00145    virtual Double_t     *GetEYlow()  const {return 0;}
00146    virtual Double_t     *GetEXlowd()  const {return 0;}
00147    virtual Double_t     *GetEXhighd() const {return 0;}
00148    virtual Double_t     *GetEYlowd()  const {return 0;}
00149    virtual Double_t     *GetEYhighd() const {return 0;}
00150    Double_t              GetMaximum()  const {return fMaximum;}
00151    Double_t              GetMinimum()  const {return fMinimum;}
00152    TAxis                *GetXaxis() const ;
00153    TAxis                *GetYaxis() const ;
00154    virtual Int_t         GetPoint(Int_t i, Double_t &x, Double_t &y) const;
00155    
00156    virtual void          InitExpo(Double_t xmin=0, Double_t xmax=0);
00157    virtual void          InitGaus(Double_t xmin=0, Double_t xmax=0);
00158    virtual void          InitPolynom(Double_t xmin=0, Double_t xmax=0);
00159    virtual Int_t         InsertPoint(); // *MENU*
00160    virtual Double_t      Integral(Int_t first=0, Int_t last=-1) const;
00161    virtual Bool_t        IsEditable() const {return !TestBit(kNotEditable);}
00162    virtual Int_t         IsInside(Double_t x, Double_t y) const;
00163    virtual void          LeastSquareFit(Int_t m, Double_t *a, Double_t xmin=0, Double_t xmax=0);
00164    virtual void          LeastSquareLinearFit(Int_t n, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin=0, Double_t xmax=0);
00165    virtual Int_t         Merge(TCollection* list);
00166    virtual void          Paint(Option_t *chopt="");
00167    void                  PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt);
00168    void                  PaintGrapHist(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt); 
00169    virtual void          PaintStats(TF1 *fit);
00170    virtual void          Print(Option_t *chopt="") const;
00171    virtual void          RecursiveRemove(TObject *obj);
00172    virtual Int_t         RemovePoint(); // *MENU*
00173    virtual Int_t         RemovePoint(Int_t ipoint);
00174    virtual void          SavePrimitive(ostream &out, Option_t *option = "");
00175    virtual void          SetEditable(Bool_t editable=kTRUE); // *TOGGLE* *GETTER=GetEditable
00176    virtual void          SetHistogram(TH1 *h) {fHistogram = (TH1F*)h;}
00177    virtual void          SetMaximum(Double_t maximum=-1111); // *MENU*
00178    virtual void          SetMinimum(Double_t minimum=-1111); // *MENU*
00179    virtual void          Set(Int_t n);
00180    virtual void          SetPoint(Int_t i, Double_t x, Double_t y);
00181    virtual void          SetTitle(const char *title="");    // *MENU*
00182    virtual void          Sort(Bool_t (*greater)(const TGraph*, Int_t, Int_t)=&TGraph::CompareX,
00183                               Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111);
00184    virtual void          UseCurrentStyle();
00185    void                  Zero(Int_t &k,Double_t AZ,Double_t BZ,Double_t E2,Double_t &X,Double_t &Y,Int_t maxiterations);
00186 
00187    ClassDef(TGraph,4)  //Graph graphics class
00188 };
00189 
00190 inline Double_t **TGraph::Allocate(Int_t newsize) {
00191    return AllocateArrays(2, newsize);
00192 }
00193 
00194 #endif

Generated on Tue Jul 5 14:22:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1