CbmRoot
Loading...
Searching...
No Matches
CbmDrawHist.h
Go to the documentation of this file.
1/* Copyright (C) 2008-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
11#ifndef CBMDRAWHIST_H_
12#define CBMDRAWHIST_H_
13
14#include <Rtypes.h> // for kBlue, kGreen, kOrange, kRed, kYellow, kBlack
15#include <RtypesCore.h> // for Int_t, Double_t, Bool_t
16#include <TAttMarker.h> // for kFullCircle, kFullSquare, kFullTriangleUp
17
18#include <string> // for string
19#include <vector> // for vector
20
21class TGraph2D;
22class TGraph;
23class TH1;
24class TH2;
25class TH2D;
26class TH3;
27
35public:
36 static Int_t Color(Int_t colorIndex)
37 {
38 static const Int_t nofColors = 15;
39 static Int_t colors[nofColors] = {kRed, kBlue + 1, kGreen + 3, kMagenta + 4, kYellow + 2,
40 kViolet, kOrange - 5, kOrange + 3, kRed - 8, kPink + 9,
41 kBlue - 6, kCyan + 1, kGreen - 6, kYellow - 1, kGray + 1};
42 return (colorIndex < nofColors) ? colors[colorIndex] : colorIndex;
43 }
44
45 static Int_t LineWidth() { return 2; }
46
47 static Int_t LineStyle(Int_t lineStyleIndex) { return lineStyleIndex + 1; }
48
49 static Int_t MarkerSize() { return 1; }
50
51 static Int_t MarkerStyle(Int_t markerIndex)
52 {
53 static const Int_t nofMarkers = 8;
54 static Int_t markers[nofMarkers] = {kOpenCircle, kOpenSquare, kOpenTriangleUp, kOpenDiamond,
55 kFullCircle, kFullSquare, kFullTriangleUp};
56 return (markerIndex < nofMarkers) ? markers[markerIndex] : markerIndex;
57 }
58
59 static Double_t TextSize() { return 0.06; }
60};
61
67{
68 kLog = 0,
69 kLinear = 1
70};
71
72
78
92void DrawH1(TH1* hist, HistScale logx = kLinear, HistScale logy = kLinear, const std::string& drawOpt = "",
93 Int_t color = CbmDrawingOptions::Color(0), Int_t lineWidth = CbmDrawingOptions::LineWidth(),
94 Int_t lineStyle = CbmDrawingOptions::LineStyle(0), Int_t markerSize = CbmDrawingOptions::MarkerSize(),
95 Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
96
97
106void DrawH2(TH2* hist, HistScale logx = kLinear, HistScale logy = kLinear, HistScale logz = kLinear,
107 const std::string& drawOpt = "COLZ");
108
109
124void DrawH1(const std::vector<TH1*>& histos, const std::vector<std::string>& histLabels, HistScale logx = kLinear,
125 HistScale logy = kLinear, Bool_t drawLegend = true, Double_t x1 = 0.25, Double_t y1 = 0.99,
126 Double_t x2 = 0.55, Double_t y2 = 0.75, const std::string& drawOpt = "");
127
141void DrawGraph(TGraph* graph, HistScale logx = kLinear, HistScale logy = kLinear, const std::string& drawOpt = "AC",
142 Int_t color = CbmDrawingOptions::Color(0), Int_t lineWidth = CbmDrawingOptions::LineWidth(),
143 Int_t lineStyle = CbmDrawingOptions::LineStyle(0), Int_t markerSize = CbmDrawingOptions::MarkerSize(),
144 Int_t markerStyle = CbmDrawingOptions::MarkerStyle(0));
145
159void DrawGraph(const std::vector<TGraph*>& graphs, const std::vector<std::string>& graphLabels,
160 HistScale logx = kLinear, HistScale logy = kLinear, Bool_t drawLegend = true, Double_t x1 = 0.50,
161 Double_t y1 = 0.78, Double_t x2 = 0.99, Double_t y2 = 0.99);
162
172void DrawGraph2D(TGraph2D* graph, HistScale logx = kLinear, HistScale logy = kLinear, HistScale logz = kLinear,
173 const std::string& drawOpt = "colz");
174
184void DrawTextOnPad(const std::string& text, Double_t x1, Double_t y1, Double_t x2, Double_t y2);
185
186
196void DrawH1andFitGauss(TH1* hist, Bool_t drawResults = true, Bool_t doScale = true, Double_t userRangeMin = 0.,
197 Double_t userRangeMax = 0.);
198
209void DrawH2WithProfile(TH2* hist, Bool_t doGaussFit = false, Bool_t drawOnlyMean = false,
210 const std::string& drawOpt = "COLZ", Int_t profileColor = kBlack, Int_t profileLineWidth = 4);
211
221TH2D* DrawH3Profile(TH3* h, Bool_t drawMean = true, Bool_t doGaussFit = false, Double_t zUserRangeMin = 0.,
222 Double_t zUserRangeMax = 0.);
223
224#endif
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))
void DrawH2(TH2 *hist, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="COLZ")
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))
void SetDefaultDrawStyle()
void DrawGraph2D(TGraph2D *graph, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const std::string &drawOpt="colz")
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)
void DrawTextOnPad(const std::string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
HistScale
Define linear or logarithmic scale for drawing.
Definition CbmDrawHist.h:67
@ kLinear
Definition CbmDrawHist.h:69
@ kLog
Definition CbmDrawHist.h:68
TH2D * DrawH3Profile(TH3 *h, Bool_t drawMean=true, Bool_t doGaussFit=false, Double_t zUserRangeMin=0., Double_t zUserRangeMax=0.)
void DrawH1andFitGauss(TH1 *hist, Bool_t drawResults=true, Bool_t doScale=true, Double_t userRangeMin=0., Double_t userRangeMax=0.)
Default options for drawing.
Definition CbmDrawHist.h:34
static Int_t MarkerSize()
Definition CbmDrawHist.h:49
static Int_t LineWidth()
Definition CbmDrawHist.h:45
static Double_t TextSize()
Definition CbmDrawHist.h:59
static Int_t LineStyle(Int_t lineStyleIndex)
Definition CbmDrawHist.h:47
static Int_t Color(Int_t colorIndex)
Definition CbmDrawHist.h:36
static Int_t MarkerStyle(Int_t markerIndex)
Definition CbmDrawHist.h:51
Data class with information on a STS local track.