Logo ROOT   6.08/07
Reference Guide
TGraphErrors.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 15/09/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGraphErrors
13 #define ROOT_TGraphErrors
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGraphErrors //
19 // //
20 // a Graph with error bars //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TGraph
25 #include "TGraph.h"
26 #endif
27 
28 class TGraphErrors : public TGraph {
29 
30 protected:
31  Double_t *fEX; //[fNpoints] array of X errors
32  Double_t *fEY; //[fNpoints] array of Y errors
33 
34  virtual void SwapPoints(Int_t pos1, Int_t pos2);
35 
36  virtual Double_t** Allocate(Int_t size);
37  virtual void CopyAndRelease(Double_t **newarrays,
38  Int_t ibegin, Int_t iend, Int_t obegin);
39  virtual Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend,
40  Int_t obegin);
42  virtual void FillZero(Int_t begin, Int_t end,
43  Bool_t from_ctor = kTRUE);
44  virtual Bool_t DoMerge(const TGraph * g);
45 
46 
47 public:
48  TGraphErrors();
50  TGraphErrors(Int_t n, const Float_t *x, const Float_t *y, const Float_t *ex=0, const Float_t *ey=0);
51  TGraphErrors(Int_t n, const Double_t *x, const Double_t *y, const Double_t *ex=0, const Double_t *ey=0);
52  TGraphErrors(const TVectorF &vx, const TVectorF &vy, const TVectorF &vex, const TVectorF &vey);
53  TGraphErrors(const TVectorD &vx, const TVectorD &vy, const TVectorD &vex, const TVectorD &vey);
56  TGraphErrors(const TH1 *h);
57  TGraphErrors(const char *filename, const char *format="%lg %lg %lg %lg", Option_t *option="");
58  virtual ~TGraphErrors();
59  virtual void Apply(TF1 *f);
60  static Int_t CalculateScanfFields(const char *fmt);
61  virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const;
62  Double_t GetErrorX(Int_t bin) const;
63  Double_t GetErrorY(Int_t bin) const;
64  Double_t GetErrorXhigh(Int_t bin) const;
65  Double_t GetErrorXlow(Int_t bin) const;
66  Double_t GetErrorYhigh(Int_t bin) const;
67  Double_t GetErrorYlow(Int_t bin) const;
68  Double_t *GetEX() const {return fEX;}
69  Double_t *GetEY() const {return fEY;}
70  virtual Int_t Merge(TCollection* list);
71  virtual void Print(Option_t *chopt="") const;
72  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
73  virtual void SetPointError(Double_t ex, Double_t ey); // *MENU
74  virtual void SetPointError(Int_t i, Double_t ex, Double_t ey);
75 
76  ClassDef(TGraphErrors,3) //A graph with error bars
77 };
78 
80  return AllocateArrays(4, size);
81 }
82 
83 #endif
float xmin
Definition: THbookFile.cxx:93
Double_t * GetEX() const
Definition: TGraphErrors.h:68
Double_t GetErrorYlow(Int_t bin) const
This function is called by GraphFitChisquare.
float Float_t
Definition: RtypesCore.h:53
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph with errors
const char Option_t
Definition: RtypesCore.h:62
virtual ~TGraphErrors()
TGraphErrors default destructor.
float ymin
Definition: THbookFile.cxx:93
Double_t GetErrorYhigh(Int_t bin) const
This function is called by GraphFitChisquare.
TH1 * h
Definition: legend2.C:5
TVectorT.
Definition: TMatrixTBase.h:89
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static std::string format(double x, double y, int digits, int width)
TGraphErrors()
TGraphErrors default constructor.
virtual Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy errors from fEX and fEY to arrays[0] and arrays[1] or to fX and fY.
virtual Int_t Merge(TCollection *list)
Adds all graphs with errors from the collection to this graph.
Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Double_t GetErrorX(Int_t bin) const
This function is called by GraphFitChisquare.
float ymax
Definition: THbookFile.cxx:93
virtual Double_t ** Allocate(Int_t size)
Definition: TGraphErrors.h:79
TGraphErrors & operator=(const TGraphErrors &gr)
TGraphErrors assignment operator.
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute range.
Collection abstract base class.
Definition: TCollection.h:48
Double_t * GetEY() const
Definition: TGraphErrors.h:69
float xmax
Definition: THbookFile.cxx:93
virtual void Apply(TF1 *f)
apply function to all the data points y = f(x,y)
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy and release.
TGraphErrors * gr
Definition: legend1.C:25
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
Set zero values for point arrays in the range [begin, end].
Double_t * fEX
Definition: TGraphErrors.h:31
Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
double f(double x)
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
Double_t ey[n]
Definition: legend1.C:17
The TH1 histogram class.
Definition: TH1.h:80
Bool_t CtorAllocate()
Constructor allocate.
1-Dim function class
Definition: TF1.h:149
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
A TGraphErrors is a TGraph with error bars.
Definition: TGraphErrors.h:28
static Int_t CalculateScanfFields(const char *fmt)
Calculate scan fields.
Double_t * fEY
Definition: TGraphErrors.h:32
virtual void Print(Option_t *chopt="") const
Print graph and errors values.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
Double_t GetErrorXhigh(Int_t bin) const
This function is called by GraphFitChisquare.
const Bool_t kTRUE
Definition: Rtypes.h:91
Double_t ** AllocateArrays(Int_t Narrays, Int_t arraySize)
Allocate arrays.
Definition: TGraph.cxx:529
Double_t ex[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16