CbmRoot
CbmDrawHist.h
Go to the documentation of this file.
1 
7 #ifndef CBMDRAWHIST_H_
8 #define CBMDRAWHIST_H_
9 
10 #include <Rtypes.h> // for kBlue, kGreen, kOrange, kRed, kYellow, kBlack
11 #include <RtypesCore.h> // for Int_t, Double_t, Bool_t
12 #include <TAttMarker.h> // for kFullCircle, kFullSquare, kFullTriangleUp
13 
14 #include <string> // for string
15 #include <vector> // for vector
16 
17 class TGraph2D;
18 class TGraph;
19 class TH1;
20 class TH2;
21 class TH2D;
22 class TH3;
23 
31 public:
32  static Int_t Color(Int_t colorIndex) {
33  static const Int_t nofColors = 15;
34  static Int_t colors[nofColors] = {kRed,
35  kBlue + 1,
36  kGreen + 3,
37  kMagenta + 4,
38  kYellow + 2,
39  kViolet,
40  kOrange - 5,
41  kOrange + 3,
42  kRed - 8,
43  kPink + 9,
44  kBlue - 6,
45  kCyan + 1,
46  kGreen - 6,
47  kYellow - 1,
48  kGray + 1};
49  return (colorIndex < nofColors) ? colors[colorIndex] : colorIndex;
50  }
51 
52  static Int_t LineWidth() { return 2; }
53 
54  static Int_t LineStyle(Int_t lineStyleIndex) { return lineStyleIndex + 1; }
55 
56  static Int_t MarkerSize() { return 1; }
57 
58  static Int_t MarkerStyle(Int_t markerIndex) {
59  static const Int_t nofMarkers = 8;
60  static Int_t markers[nofMarkers] = {kOpenCircle,
61  kOpenSquare,
62  kOpenTriangleUp,
63  kOpenDiamond,
64  kFullCircle,
65  kFullSquare,
66  kFullTriangleUp};
67  return (markerIndex < nofMarkers) ? markers[markerIndex] : markerIndex;
68  }
69 
70  static Double_t TextSize() { return 0.06; }
71 };
72 
77 enum HistScale {
78  kLog = 0,
79  kLinear = 1
80 };
81 
82 
87 void SetDefaultDrawStyle();
88 
102 void DrawH1(TH1* hist,
103  HistScale logx = kLinear,
104  HistScale logy = kLinear,
105  const std::string& drawOpt = "",
106  Int_t color = CbmDrawingOptions::Color(0),
107  Int_t lineWidth = CbmDrawingOptions::LineWidth(),
108  Int_t lineStyle = CbmDrawingOptions::LineStyle(0),
109  Int_t markerSize = CbmDrawingOptions::MarkerSize(),
110  Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
111 
112 
121 void DrawH2(TH2* hist,
122  HistScale logx = kLinear,
123  HistScale logy = kLinear,
124  HistScale logz = kLinear,
125  const std::string& drawOpt = "COLZ");
126 
127 
142 void DrawH1(const std::vector<TH1*>& histos,
143  const std::vector<std::string>& histLabels,
144  HistScale logx = kLinear,
145  HistScale logy = kLinear,
146  Bool_t drawLegend = true,
147  Double_t x1 = 0.25,
148  Double_t y1 = 0.99,
149  Double_t x2 = 0.55,
150  Double_t y2 = 0.75,
151  const std::string& drawOpt = "");
152 
166 void DrawGraph(TGraph* graph,
167  HistScale logx = kLinear,
168  HistScale logy = kLinear,
169  const std::string& drawOpt = "AC",
170  Int_t color = CbmDrawingOptions::Color(0),
171  Int_t lineWidth = CbmDrawingOptions::LineWidth(),
172  Int_t lineStyle = CbmDrawingOptions::LineStyle(0),
173  Int_t markerSize = CbmDrawingOptions::MarkerSize(),
174  Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
175 
189 void DrawGraph(const std::vector<TGraph*>& graphs,
190  const std::vector<std::string>& graphLabels,
191  HistScale logx = kLinear,
192  HistScale logy = kLinear,
193  Bool_t drawLegend = true,
194  Double_t x1 = 0.50,
195  Double_t y1 = 0.78,
196  Double_t x2 = 0.99,
197  Double_t y2 = 0.99);
198 
208 void DrawGraph2D(TGraph2D* graph,
209  HistScale logx = kLinear,
210  HistScale logy = kLinear,
211  HistScale logz = kLinear,
212  const std::string& drawOpt = "colz");
213 
223 void DrawTextOnPad(const std::string& text,
224  Double_t x1,
225  Double_t y1,
226  Double_t x2,
227  Double_t y2);
228 
229 
239 void DrawH1andFitGauss(TH1* hist,
240  Bool_t drawResults = true,
241  Bool_t doScale = true,
242  Double_t userRangeMin = 0.,
243  Double_t userRangeMax = 0.);
244 
255 void DrawH2WithProfile(TH2* hist,
256  Bool_t doGaussFit = false,
257  Bool_t drawOnlyMean = false,
258  const std::string& drawOpt = "COLZ",
259  Int_t profileColor = kBlack,
260  Int_t profileLineWidth = 4);
261 
271 TH2D* DrawH3Profile(TH3* h,
272  Bool_t drawMean = true,
273  Bool_t doGaussFit = false,
274  Double_t zUserRangeMin = 0.,
275  Double_t zUserRangeMax = 0.);
276 
277 #endif
SetDefaultDrawStyle
void SetDefaultDrawStyle()
Definition: CbmDrawHist.cxx:33
DrawH3Profile
TH2D * DrawH3Profile(TH3 *h, Bool_t drawMean=true, Bool_t doGaussFit=false, Double_t zUserRangeMin=0., Double_t zUserRangeMax=0.)
Definition: CbmDrawHist.cxx:369
HistScale
HistScale
Define linear or logarithmic scale for drawing.
Definition: CbmDrawHist.h:77
DrawTextOnPad
void DrawTextOnPad(const std::string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
DrawH1
void DrawH1(TH1 *hist, HistScale logx=kLinear, HistScale logy=kLinear, const std::string &drawOpt="", Int_t color=CbmDrawingOptions::Color(0), Int_t lineWidth=CbmDrawingOptions::LineWidth(), Int_t lineStyle=CbmDrawingOptions::LineStyle(0), Int_t markerSize=CbmDrawingOptions::MarkerSize(), Int_t markerStyle=CbmDrawingOptions::MarkerStyle(0))
CbmDrawingOptions::MarkerSize
static Int_t MarkerSize()
Definition: CbmDrawHist.h:56
CbmDrawingOptions::MarkerStyle
static Int_t MarkerStyle(Int_t markerIndex)
Definition: CbmDrawHist.h:58
h
Data class with information on a STS local track.
kLinear
@ kLinear
Definition: CbmDrawHist.h:79
CbmDrawingOptions
Default options for drawing.
Definition: CbmDrawHist.h:30
CbmDrawingOptions::LineWidth
static Int_t LineWidth()
Definition: CbmDrawHist.h:52
DrawH2WithProfile
void DrawH2WithProfile(TH2 *hist, Bool_t doGaussFit=false, Bool_t drawOnlyMean=false, const std::string &drawOpt="COLZ", Int_t profileColor=kBlack, Int_t profileLineWidth=4)
CbmDrawingOptions::LineStyle
static Int_t LineStyle(Int_t lineStyleIndex)
Definition: CbmDrawHist.h:54
DrawGraph
void DrawGraph(TGraph *graph, HistScale logx=kLinear, HistScale logy=kLinear, const std::string &drawOpt="AC", Int_t color=CbmDrawingOptions::Color(0), Int_t lineWidth=CbmDrawingOptions::LineWidth(), Int_t lineStyle=CbmDrawingOptions::LineStyle(0), Int_t markerSize=CbmDrawingOptions::MarkerSize(), Int_t markerStyle=CbmDrawingOptions::MarkerStyle(0))
DrawGraph2D
void DrawGraph2D(TGraph2D *graph, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="colz")
CbmDrawingOptions::TextSize
static Double_t TextSize()
Definition: CbmDrawHist.h:70
DrawH2
void DrawH2(TH2 *hist, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="COLZ")
kLog
@ kLog
Definition: CbmDrawHist.h:78
DrawH1andFitGauss
void DrawH1andFitGauss(TH1 *hist, Bool_t drawResults=true, Bool_t doScale=true, Double_t userRangeMin=0., Double_t userRangeMax=0.)
Definition: CbmDrawHist.cxx:266
CbmDrawingOptions::Color
static Int_t Color(Int_t colorIndex)
Definition: CbmDrawHist.h:32