SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ScatterGraph.hh
1 #ifndef SCATTERGRAPH_HH
2 #define SCATTERGRAPH_HH
3 
4 // C++ includes
5 #include <iostream>
6 #include <vector>
7 #include <algorithm>
8 
9 // ROOT includes
10 #include "TStyle.h"
11 #include "TGraph2D.h"
12 #include "TAxis.h"
13 #include "TGaxis.h"
14 #include "TCanvas.h"
15 #include "TH2F.h"
16 
23 enum Order {ascending, descending};
24 
31 class ScatterGraph {
32  public:
33 
35  ScatterGraph();
36 
38  ScatterGraph(const ScatterGraph& scat);
39 
41  ScatterGraph& operator=(const ScatterGraph& scat);
42 
44  ScatterGraph(size_t n);
45 
47  ScatterGraph(size_t n, double* x, double* y, double* z);
48 
50  ScatterGraph(const char *name, const char *title, size_t n, double* x, double* y, double* z);
51 
53  ScatterGraph(const TGraph2D& graph);
54 
56  virtual ~ScatterGraph();
57 
59  void AddPoint(double x, double y, double w=1);
60 
62  void SetPoint(size_t i, double x, double y, double w=1) { _graph->SetPoint(i, x, y, w); }
63 
65  void SetPoints(size_t n, double* x, double* y, double* w);
66 
68  void SetOrder(const Order& order);
69 
71  void SetMaxSize(const size_t& size);
72 
74  void Draw();
75 
77  void Save();
78 
80  void SetName(const char* name) { _graph->SetName(name); }
81 
83  virtual const char* GetName() const { return _graph->GetName(); }
84 
86  void SetTitle(const char* title) { _graph->SetTitle(title); }
87 
89  virtual const char* GetTitle() const { return _graph->GetTitle(); }
90 
92  size_t GetN() const { return _graph->GetN(); }
93 
95  TGraph2D* GetGraph2D() { return _graph; }
96 
98  TGaxis* GetXaxis() { return _xaxis; }
99 
101  TGaxis* GetYaxis() { return _yaxis; }
102 
104  TAxis* GetZaxis() { return _graph->GetZaxis(); }
105 
107  void SetMinimum(const double min) { _graph->SetMinimum(min); }
108 
110  void SetMaximum(const double max) { _graph->SetMaximum(max); }
111 
113  void SetRange(double minx, double miny, double maxx, double maxy);
114 
116  void SetMarkerStyle(int style) { _graph->SetMarkerStyle(style); }
117 
119  void SetMarkerSize(double size) { _graph->SetMarkerSize(size); }
120 
122  void SetXaxisTitle(const char *title="") { _xaxis->SetTitle(title); }
123 
125  void SetYaxisTitle(const char *title="") { _yaxis->SetTitle(title); }
126 
128  void Write() { _graph->Write(); }
129 
130  private:
131 
132  TGraph2D* _graph;
133  TGaxis* _xaxis;
134  TGaxis* _yaxis;
135 };
136 
137 #endif
TGraph2D * _graph
Underlying TGraph2D object.
Definition: ScatterGraph.hh:132
void Draw()
Draws the scatter plot.
Definition: ScatterGraph.cc:125
void SetMaximum(const double max)
Sets the minimum of the underlying TGraph2D.
Definition: ScatterGraph.hh:110
void SetMinimum(const double min)
Sets the minimum of the underlying TGraph2D.
Definition: ScatterGraph.hh:107
virtual ~ScatterGraph()
Destructor - any member pointers are deleted.
Definition: ScatterGraph.cc:61
void SetTitle(const char *title)
Sets the name of the underlying TGraph2D.
Definition: ScatterGraph.hh:86
TGaxis * _xaxis
Underlying TGaxis object defined for the x axis.
Definition: ScatterGraph.hh:133
void Write()
Save the histogram to the root file.
Definition: ScatterGraph.hh:128
virtual const char * GetName() const
Returns the name of the underlying TGraph2D.
Definition: ScatterGraph.hh:83
void SetYaxisTitle(const char *title="")
Sets the title of the y axis.
Definition: ScatterGraph.hh:125
void SetPoints(size_t n, double *x, double *y, double *w)
Sets one of the points to a certain value.
Definition: ScatterGraph.cc:77
void AddPoint(double x, double y, double w=1)
Sets one of the points to a certain value.
Definition: ScatterGraph.cc:71
ScatterGraph()
Default constructor - initialises to 0/NULL.
Definition: ScatterGraph.cc:3
void SetPoint(size_t i, double x, double y, double w=1)
Sets one of the points to a certain value.
Definition: ScatterGraph.hh:62
void SetMarkerStyle(int style)
Sets the marker style of the underlying TGraph2D.
Definition: ScatterGraph.hh:116
void SetName(const char *name)
Sets the name of the underlying TGraph2D.
Definition: ScatterGraph.hh:80
size_t GetN() const
Returns the number of entries in the underlying TGraph2D.
Definition: ScatterGraph.hh:92
virtual const char * GetTitle() const
Returns the title of the underlying TGraph2D.
Definition: ScatterGraph.hh:89
void SetMarkerSize(double size)
Sets the marker size of the underlying TGraph2D.
Definition: ScatterGraph.hh:119
TGaxis * _yaxis
Underlying TGaxis object defined for the y axis.
Definition: ScatterGraph.hh:134
void SetRange(double minx, double miny, double maxx, double maxy)
Sets the limits of the x and y axes.
Definition: ScatterGraph.cc:85
void Save()
Saves the scatter plot.
Definition: ScatterGraph.cc:164
void SetOrder(const Order &order)
Sets the order in which the points are drawn.
Definition: ScatterGraph.cc:91
Defines functions that allow to plot a ROOT scatter graph with a color scale.
Definition: ScatterGraph.hh:31
void SetMaxSize(const size_t &size)
Sets the maximum amount of points to be drawn.
Definition: ScatterGraph.cc:118
ScatterGraph & operator=(const ScatterGraph &scat)
Equality operator - any pointers are deep copied.
Definition: ScatterGraph.cc:44
TAxis * GetZaxis()
Returns a pointer to the y axis, in order to set its attributes.
Definition: ScatterGraph.hh:104
TGaxis * GetYaxis()
Returns a pointer to the y axis, in order to set its attributes.
Definition: ScatterGraph.hh:101
void SetXaxisTitle(const char *title="")
Sets the title of the x axis.
Definition: ScatterGraph.hh:122
TGaxis * GetXaxis()
Returns a pointer to the x axis, in order to set its attributes.
Definition: ScatterGraph.hh:98
TGraph2D * GetGraph2D()
Returns the the underlying TGraph2D.
Definition: ScatterGraph.hh:95