ATLAS Offline Software
Loading...
Searching...
No Matches
SetAttributes.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// #########################################
6// Author: Dengfeng Zhang
7// dengfeng.zhang@cern.ch
8// #########################################
9
10// Set the attributes of pads, histograms, graphs, hstack ......
11// SetHistFillAttributes(): Set fillcolor and fillstyle of the histogram
12// SetHistLineAttributes(): Set Line attributes of hist
13// SetHistAxisAttributes(): Set Axis attributes of hist
14// SetHistMarkerAttributes(): Set Axis attributes of hist
15// SetHistAttributes(): Set attributes(fill, line axis marker) of hist
16// SetPadFillAttributes): Set fill attributes of apd
17// SetPadAttributes(): Set attributes(fill, line axis marker) of pad
18// SetGraphAttributes(): Set attributes(fill, line axis marker) of graph
19// SetGraphFillAttributes()
20// SetGraphLineAttributes()
21// SetGraphMarkerAttributes()
22// SetGraphAxisAttributes()
23// SetGraphErrorsAttributes(): Set attributes(fill, line axis marker) of grapherrors
24// SetGraphErrorsFillAttributes()
25// SetGraphErrorsLineAttributes()
26// SetGraphErrorsMarkerAttributes()
27// SetGraphErrorsAxisAttributes()
28// SetGraphAsymmErrorsAttributes(): Set attributes(fill, line axis marker) of graphasymmerrors
29// SetGraphAsymmErrorsFillAttributes()
30// SetGraphAsymmErrorsLineAttributes()
31// SetGraphAsymmErrorsMarkerAttributes()
32// SetGraphAsymmErrorsAxisAttributes()
33//
34// SetHStackAttributes()
35// std includes
36#include <sstream>
37#include <vector>
38#include <fstream>
39// include root
40#include "TH1F.h"
41#include "TCanvas.h"
42#include "TRandom.h"
43#include "THStack.h"
44#include "TGraph.h"
45#include "TGraphErrors.h"
46#include "TGraphAsymmErrors.h"
47#include "TStyle.h"
48#include "TLegend.h"
49#include "TPaveText.h"
50#include "TLatex.h"
51#include "TRandom3.h"
52#include "TMultiGraph.h"
53//
54/*
55int DrawATLASLabels(float xstart, float ystart, int labeltype)
56{
57 TLatex m_latex;
58 m_latex.SetTextSize(0.03) ;
59 m_latex.SetTextColor(kBlack) ;
60 m_latex.SetTextFont(72) ;
61 m_latex.DrawLatex(xstart, ystart, "ATLAS") ;
62 m_latex.SetTextFont(42) ;
63 float spacing = 0.15 ;
64 switch(labeltype)
65 {
66 case 0:
67 break ;
68 case 1:
69 m_latex.DrawLatex(xstart+spacing, ystart, "Preliminary") ;
70 break ;
71 case 2:
72 m_latex.DrawLatex(xstart+spacing, ystart, "Internal") ;
73 break ;
74 case 3:
75 m_latex.DrawLatex(xstart+spacing, ystart, "Simulation Preliminary") ;
76 break ;
77 case 4:
78 m_latex.DrawLatex(xstart+spacing, ystart, "Work in Progress") ;
79 break ;
80 default: break ;
81 }
82 return 0;
83}
84*/
85int SetHistFillAttributes(TH1F* hist, int fillstyle=1001, int fillcolor=0)
86{
87 hist->SetFillStyle(fillstyle) ;
88 hist->SetFillColor(fillcolor) ;
89 return 0 ;
90}
91
92int SetHistLineAttributes(TH1F* hist, int linestyle=1, int linewidth=2, int linecolor=1)
93{
94 hist->SetLineColor(linecolor) ;
95 hist->SetLineWidth(linewidth) ;
96 hist->SetLineStyle(linestyle) ;
97 return 0 ;
98}
99
100int SetHistAxisAttributes(TH1F* hist,
101 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
102 float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
103{
104 hist->GetXaxis()->SetTitleSize(xtitlesize) ;
105 hist->GetXaxis()->SetTitleOffset(xtitleoffset) ;
106 hist->GetXaxis()->SetLabelSize(xlabelsize) ;
107 hist->GetYaxis()->SetTitleSize(ytitlesize) ;
108 hist->GetYaxis()->SetTitleOffset(ytitleoffset) ;
109 hist->GetYaxis()->SetLabelSize(ylabelsize) ;
110 return 0 ;
111}
112
113int SetHistMarkerAttributes(TH1F* hist, int markerstyle=20, int markercolor=1, int markersize=1)
114{
115 hist->SetMarkerStyle(markerstyle) ;
116 hist->SetMarkerColor(markercolor) ;
117 hist->SetMarkerSize(markersize) ;
118 return 0 ;
119}
120int SetHistAttributes(TH1F* hist, int linestyle=1, int linewidth=2, int linecolor=1,
121 int fillstyle=1001, int fillcolor=0,
122 int markerstyle=20, int markercolor=1, int markersize=1,
123 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
124 float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05,
125 bool displaystats=false)
126{
127 SetHistFillAttributes(hist, fillstyle, fillcolor) ;
128 SetHistAxisAttributes(hist,xlabelsize, xtitleoffset, xtitlesize, ylabelsize, ytitleoffset, ytitlesize) ;
129 SetHistLineAttributes(hist, linestyle, linewidth, linecolor) ;
130 SetHistMarkerAttributes(hist, markerstyle, markercolor, markersize) ;
131 hist->SetStats(displaystats) ;
132
133 return 0 ;
134}
135
136int SetPadFillAttributes(TPad* pad, int fillstyle=0, float fillcolor=0)
137{
138 pad->SetFillStyle(fillstyle) ;
139 pad->SetFillColor(fillcolor) ;
140 return 0 ;
141}
142
143int SetPadAttributes(TPad* pad, int fillstyle=0, int fillcolor=0,
144 float leftmargin=0.15, float rightmargin=0.05, float bottommargin=0.15, float topmargin=0.05,
145int bordermode=0, bool logx=false, bool logy=true, bool settickx=true, bool setticky=true)
146{
147 SetPadFillAttributes(pad, fillstyle, fillcolor) ;
148 pad->SetMargin(leftmargin, rightmargin, bottommargin, topmargin) ;
149 pad->SetBorderMode(bordermode) ;
150
151 pad->SetLogx(logx) ;
152 pad->SetLogy(logy) ;
153
154 pad->SetTickx(settickx) ;
155 pad->SetTicky(setticky) ;
156 return 0 ;
157}
158/*
159int SetLatexAttributes(TLatex* latex)
160{
161 return 0 ;
162}
163
164int SetPaveTextAttributes(TPaveText* pavetext)
165{
166 return 0 ;
167}
168
169int SetLegendAttributes(TLegend* legend)
170{
171 return 0 ;
172}
173*/
174int SetGraphLineAttributes(TGraph* gr, int linestyle=1, int linewidth=2, int linecolor=1)
175{
176 gr->SetLineColor(linecolor) ;
177 gr->SetLineWidth(linewidth) ;
178 gr->SetLineStyle(linestyle) ;
179 return 0 ;
180}
181
182int SetGraphFillAttributes(TGraph* gr, int fillstyle=1001, int fillcolor=0)
183{
184 gr->SetFillStyle(fillstyle) ;
185 gr->SetFillColor(fillcolor) ;
186 return 0 ;
187}
188
189int SetGraphMarkerAttributes(TGraph* gr, int markerstyle=20, int markercolor=1, int markersize=1)
190{
191 gr->SetMarkerStyle(markerstyle) ;
192 gr->SetMarkerColor(markercolor) ;
193 gr->SetMarkerSize(markersize) ;
194 return 0 ;
195}
196
198 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
199 float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
200{
201 gr->GetXaxis()->SetTitleSize(xtitlesize) ;
202 gr->GetXaxis()->SetTitleOffset(xtitleoffset) ;
203 gr->GetXaxis()->SetLabelSize(xlabelsize) ;
204 gr->GetYaxis()->SetTitleSize(ytitlesize) ;
205 gr->GetYaxis()->SetTitleOffset(ytitleoffset) ;
206 gr->GetYaxis()->SetLabelSize(ylabelsize) ;
207 return 0 ;
208}
209
210int SetGraphAttributes(TGraph* gr, int linestyle=1, int linewidth=2, int linecolor=1,
211 int fillstyle=1001, int fillcolor=0,
212 int markerstyle=20, int markercolor=1, int markersize=1,
213 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
214 float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
215{
216 SetGraphLineAttributes(gr, linestyle, linewidth, linecolor) ;
217 SetGraphFillAttributes(gr, fillstyle, fillcolor) ;
218 SetGraphMarkerAttributes(gr, markerstyle, markercolor, markersize) ;
219 SetGraphAxisAttributes(gr, xlabelsize, xtitleoffset, xtitlesize, ylabelsize, ytitleoffset, ytitlesize) ;
220 return 0 ;
221}
222
223int SetGraphErrorsLineAttributes(TGraphErrors* gre, int linestyle=1, int linewidth=2, int linecolor=1)
224{
225 gre->SetLineColor(linecolor) ;
226 gre->SetLineWidth(linewidth) ;
227 gre->SetLineStyle(linestyle) ;
228 return 0 ;
229}
230
231int SetGraphErrorsFillAttributes(TGraph* gre, int fillstyle=1001, int fillcolor=0)
232{
233 gre->SetFillStyle(fillstyle) ;
234 gre->SetFillColor(fillcolor) ;
235 return 0 ;
236}
237
238int SetGraphErrorsMarkerAttributes(TGraph* gre, int markerstyle=20, int markercolor=1, int markersize=1)
239{
240 gre->SetMarkerStyle(markerstyle) ;
241 gre->SetMarkerColor(markercolor) ;
242 gre->SetMarkerSize(markersize) ;
243 return 0 ;
244}
245
247 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
248 float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
249{
250 gre->GetXaxis()->SetTitleSize(xtitlesize) ;
251 gre->GetXaxis()->SetTitleOffset(xtitleoffset) ;
252 gre->GetXaxis()->SetLabelSize(xlabelsize) ;
253 gre->GetYaxis()->SetTitleSize(ytitlesize) ;
254 gre->GetYaxis()->SetTitleOffset(ytitleoffset) ;
255 gre->GetYaxis()->SetLabelSize(ylabelsize) ;
256 return 0 ;
257}
258
259int SetGraphErrorsAttributes(TGraphErrors* gre,
260 int linestyle=1, int linewidth=2, int linecolor=1,
261 int fillstyle=1001, int fillcolor=0,
262 int markerstyle=20, int markercolor=1, int markersize=1,
263 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
264 float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
265{
266 SetGraphErrorsLineAttributes(gre, linestyle, linewidth, linecolor) ;
267 SetGraphErrorsFillAttributes(gre, fillstyle, fillcolor) ;
268 SetGraphErrorsMarkerAttributes(gre, markerstyle, markercolor, markersize) ;
269 SetGraphErrorsAxisAttributes(gre, xlabelsize, xtitleoffset, xtitlesize, ylabelsize, ytitleoffset, ytitlesize) ;
270 return 0 ;
271}
272
273int SetMGraphAttributes(TMultiGraph *mg,
274 float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05,
275 float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
276{
277 mg->GetXaxis()->SetTitleSize(xtitlesize) ;
278 mg->GetXaxis()->SetTitleOffset(xtitleoffset) ;
279 mg->GetXaxis()->SetLabelSize(xlabelsize) ;
280 mg->GetYaxis()->SetTitleSize(ytitlesize) ;
281 mg->GetYaxis()->SetTitleOffset(ytitleoffset) ;
282 mg->GetYaxis()->SetLabelSize(ylabelsize) ;
283 return 0 ;
284}
285
286int SetGraphAsymmErrorsLineAttributes(TGraphAsymmErrors* grae, int linestyle=1, int linewidth=2, int linecolor=1)
287{
288 grae->SetLineColor(linecolor) ;
289 grae->SetLineWidth(linewidth) ;
290 grae->SetLineStyle(linestyle) ;
291 return 0 ;
292}
293
294int SetGraphAsymmErrorsFillAttributes(TGraphAsymmErrors* grae, int fillstyle=1001, int fillcolor=0)
295{
296 grae->SetFillStyle(fillstyle) ;
297 grae->SetFillColor(fillcolor) ;
298 return 0 ;
299}
300
301int SetGraphAsymmErrorsMarkerAttributes(TGraphAsymmErrors* grae, int markerstyle=20, int markercolor=1, int markersize=1)
302{
303 grae->SetMarkerStyle(markerstyle) ;
304 grae->SetMarkerColor(markercolor) ;
305 grae->SetMarkerSize(markersize) ;
306 return 0 ;
307}
308
309int SetGraphAsymmErrorsAxisAttributes(TGraphAsymmErrors* grae,
310 float xlabelsize=0.03, float xtitleoffset=1., float xtitlesize=0.04,
311 float ylabelsize=0.03, float ytitleoffset=1., float ytitlesize=0.04)
312{
313 grae->GetXaxis()->SetTitleSize(xtitlesize) ;
314 grae->GetXaxis()->SetTitleOffset(xtitleoffset) ;
315 grae->GetXaxis()->SetLabelSize(xlabelsize) ;
316 grae->GetYaxis()->SetTitleSize(ytitlesize) ;
317 grae->GetYaxis()->SetTitleOffset(ytitleoffset) ;
318 grae->GetYaxis()->SetLabelSize(ylabelsize) ;
319 return 0 ;
320}
321
322int SetGraphAsymmErrorsAttributes(TGraphAsymmErrors* grae,
323 int linestyle=1, int linewidth=2, int linecolor=1,
324 int fillstyle=1001, int fillcolor=0,
325 int markerstyle=20, int markercolor=1, int markersize=1,
326 float xlabelsize=0.03, float xtitleoffset=1., float xtitlesize=0.04,
327 float ylabelsize=0.03, float ytitleoffset=1., float ytitlesize=0.04)
328{
329 SetGraphAsymmErrorsLineAttributes(grae, linestyle, linewidth, linecolor) ;
330 SetGraphAsymmErrorsFillAttributes(grae, fillstyle, fillcolor) ;
331 SetGraphAsymmErrorsMarkerAttributes(grae, markerstyle, markercolor, markersize) ;
332 SetGraphAsymmErrorsAxisAttributes(grae, xlabelsize, xtitleoffset, xtitlesize, ylabelsize, ytitleoffset, ytitlesize) ;
333 return 0 ;
334}
335
336int SetHStackAttributes(THStack* hstack,
337 float xlabelsize=0.04, float xtitleoffset=1., float xtitlesize=0.04,
338 float ylabelsize=0.04, float ytitleoffset=1., float ytitlesize=0.04)
339{
340 hstack->GetXaxis()->SetTitleSize(xtitlesize) ;
341 hstack->GetXaxis()->SetTitleOffset(xtitleoffset) ;
342 hstack->GetXaxis()->SetLabelSize(xlabelsize) ;
343 hstack->GetYaxis()->SetTitleSize(ytitlesize) ;
344 hstack->GetYaxis()->SetTitleOffset(ytitleoffset) ;
345 hstack->GetYaxis()->SetLabelSize(ylabelsize) ;
346 return 0 ;
347}
#define gr
int SetGraphAxisAttributes(TGraph *gr, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
int SetGraphErrorsFillAttributes(TGraph *gre, int fillstyle=1001, int fillcolor=0)
int SetMGraphAttributes(TMultiGraph *mg, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
int SetGraphAsymmErrorsAttributes(TGraphAsymmErrors *grae, int linestyle=1, int linewidth=2, int linecolor=1, int fillstyle=1001, int fillcolor=0, int markerstyle=20, int markercolor=1, int markersize=1, float xlabelsize=0.03, float xtitleoffset=1., float xtitlesize=0.04, float ylabelsize=0.03, float ytitleoffset=1., float ytitlesize=0.04)
int SetGraphErrorsAxisAttributes(TGraph *gre, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
int SetPadFillAttributes(TPad *pad, int fillstyle=0, float fillcolor=0)
int SetGraphLineAttributes(TGraph *gr, int linestyle=1, int linewidth=2, int linecolor=1)
int SetGraphErrorsAttributes(TGraphErrors *gre, int linestyle=1, int linewidth=2, int linecolor=1, int fillstyle=1001, int fillcolor=0, int markerstyle=20, int markercolor=1, int markersize=1, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.5, float ytitlesize=0.05)
int SetGraphAsymmErrorsLineAttributes(TGraphAsymmErrors *grae, int linestyle=1, int linewidth=2, int linecolor=1)
int SetGraphAttributes(TGraph *gr, int linestyle=1, int linewidth=2, int linecolor=1, int fillstyle=1001, int fillcolor=0, int markerstyle=20, int markercolor=1, int markersize=1, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
int SetGraphAsymmErrorsMarkerAttributes(TGraphAsymmErrors *grae, int markerstyle=20, int markercolor=1, int markersize=1)
int SetGraphErrorsMarkerAttributes(TGraph *gre, int markerstyle=20, int markercolor=1, int markersize=1)
int SetGraphFillAttributes(TGraph *gr, int fillstyle=1001, int fillcolor=0)
int SetHistFillAttributes(TH1F *hist, int fillstyle=1001, int fillcolor=0)
int SetHistMarkerAttributes(TH1F *hist, int markerstyle=20, int markercolor=1, int markersize=1)
int SetPadAttributes(TPad *pad, int fillstyle=0, int fillcolor=0, float leftmargin=0.15, float rightmargin=0.05, float bottommargin=0.15, float topmargin=0.05, int bordermode=0, bool logx=false, bool logy=true, bool settickx=true, bool setticky=true)
int SetHStackAttributes(THStack *hstack, float xlabelsize=0.04, float xtitleoffset=1., float xtitlesize=0.04, float ylabelsize=0.04, float ytitleoffset=1., float ytitlesize=0.04)
int SetGraphErrorsLineAttributes(TGraphErrors *gre, int linestyle=1, int linewidth=2, int linecolor=1)
int SetHistAxisAttributes(TH1F *hist, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05)
int SetGraphMarkerAttributes(TGraph *gr, int markerstyle=20, int markercolor=1, int markersize=1)
int SetGraphAsymmErrorsAxisAttributes(TGraphAsymmErrors *grae, float xlabelsize=0.03, float xtitleoffset=1., float xtitlesize=0.04, float ylabelsize=0.03, float ytitleoffset=1., float ytitlesize=0.04)
int SetGraphAsymmErrorsFillAttributes(TGraphAsymmErrors *grae, int fillstyle=1001, int fillcolor=0)
int SetHistLineAttributes(TH1F *hist, int linestyle=1, int linewidth=2, int linecolor=1)
int SetHistAttributes(TH1F *hist, int linestyle=1, int linewidth=2, int linecolor=1, int fillstyle=1001, int fillcolor=0, int markerstyle=20, int markercolor=1, int markersize=1, float xlabelsize=0.05, float xtitleoffset=1.4, float xtitlesize=0.05, float ylabelsize=0.05, float ytitleoffset=1.4, float ytitlesize=0.05, bool displaystats=false)
bool logy
Definition listroot.cxx:45