EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmDrawHist.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmDrawHist.h
1 
7 #ifndef CBMDRAWHIST_H_
8 #define CBMDRAWHIST_H_
9 
10 #include "TH1.h"
11 #include "TH1D.h"
12 #include "TH2.h"
13 #include "TPad.h"
14 #include "TLegend.h"
15 #include "TGraph.h"
16 #include "TGraph2D.h"
17 
18 #include <string>
19 #include <vector>
20 using std::string;
21 using std::vector;
22 
30 {
31 public:
32 
33  static Int_t Color(Int_t colorIndex) {
34  static const Int_t nofColors = 6;
35  static Int_t colors[nofColors] = {kRed, kBlue + 1, kGreen + 3, kMagenta + 4, kYellow + 2, kViolet};
36  return (colorIndex < nofColors) ? colors[colorIndex] : colorIndex;
37  }
38 
39  static Int_t LineWidth() {
40  return 2;
41  }
42 
43  static Int_t LineStyle(Int_t lineStyleIndex) {
44  return lineStyleIndex + 1;
45  }
46 
47  static Int_t MarkerSize() {
48  return 1;
49  }
50 
51  static Int_t MarkerStyle(Int_t markerIndex) {
52  static const Int_t nofMarkers = 8;
53  static Int_t markers[nofMarkers] = {kOpenCircle, kOpenSquare, kOpenTriangleUp, kOpenDiamond,
54  kFullCircle, kFullSquare, kFullTriangleUp};
55  return (markerIndex < nofMarkers) ? markers[markerIndex] : markerIndex;
56  }
57 
58  static Double_t TextSize() {
59  return 0.06;
60  }
61 };
62 
67 enum HistScale {
68  kLog = 0,
69  kLinear = 1
70 };
71 
72 
77 void SetDefaultDrawStyle();
78 
92 void DrawH1(
93  TH1* hist,
94  HistScale logx = kLinear,
95  HistScale logy = kLinear,
96  const string& drawOpt = "",
98  Int_t lineWidth = CbmDrawingOptions::LineWidth(),
99  Int_t lineStyle = CbmDrawingOptions::LineStyle(0),
100  Int_t markerSize = CbmDrawingOptions::MarkerSize(),
101  Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
102 
103 
112 void DrawH2(
113  TH2* hist,
114  HistScale logx = kLinear,
115  HistScale logy = kLinear,
116  HistScale logz = kLinear,
117  const string& drawOpt = "COLZ");
118 
119 
134 void DrawH1(
135  const vector<TH1*>& histos,
136  const vector<string>& histLabels,
137  HistScale logx = kLinear,
138  HistScale logy = kLinear,
139  Bool_t drawLegend = true,
140  Double_t x1 = 0.25,
141  Double_t y1 = 0.99,
142  Double_t x2 = 0.55,
143  Double_t y2 = 0.75,
144  const string& drawOpt = "");
145 
159 void DrawGraph(
160  TGraph* graph,
161  HistScale logx = kLinear,
162  HistScale logy = kLinear,
163  const string& drawOpt = "AC",
164  Int_t color = CbmDrawingOptions::Color(0),
165  Int_t lineWidth = CbmDrawingOptions::LineWidth(),
166  Int_t lineStyle = CbmDrawingOptions::LineStyle(0),
167  Int_t markerSize = CbmDrawingOptions::MarkerSize(),
168  Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
169 
183 void DrawGraph(
184  const vector<TGraph*>& graphs,
185  const vector<string>& graphLabels,
186  HistScale logx = kLinear,
187  HistScale logy = kLinear,
188  Bool_t drawLegend = true,
189  Double_t x1 = 0.25,
190  Double_t y1 = 0.99,
191  Double_t x2 = 0.55,
192  Double_t y2 = 0.75);
193 
203 void DrawGraph2D(
204  TGraph2D* graph,
205  HistScale logx = kLinear,
206  HistScale logy = kLinear,
207  HistScale logz = kLinear,
208  const string& drawOpt = "colz");
209 
210 #endif