ATLAS Offline Software
Loading...
Searching...
No Matches
GraphToolKit.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// local includes
10#include "SetAttributes.h"
11// if want to call following functions, do following
12// from ROOT import *; gROOT.ProcessLine("#include \"HistToolKit.h\"")
13int DrawLabel(float xstart, float ystart, string label)
14{
15 // (xstart, ystart): coornidate of the leftbottom of the pavetext
16 TLatex m_latex;
17 m_latex.SetTextSize(0.04) ;
18 m_latex.SetTextColor(kBlack) ;
19 m_latex.SetTextFont(42) ;
20 m_latex.DrawLatex(xstart, ystart, label.c_str()) ;
21 return 0;
22}
23int DrawLabels(float xstart, float ystart, string label="")
24{
25 TLatex m_latex;
26 m_latex.SetTextSize(0.04) ;
27 m_latex.SetTextColor(kBlack) ;
28 m_latex.SetTextFont(22) ;
29 m_latex.DrawLatex(xstart, ystart, label.c_str()) ;
30 return 0;
31}
32#ifndef DrawATLASLabels_Func
33#define DrawATLASLabels_Func
34int DrawATLASLabels(float xstart, float ystart, int labeltype)
35{
36 TLatex m_latex;
37 m_latex.SetTextSize(0.04) ;
38 m_latex.SetTextColor(kBlack) ;
39 m_latex.SetTextFont(72) ;
40 m_latex.DrawLatex(xstart, ystart, "ATLAS") ;
41 m_latex.SetTextFont(42) ;
42 float spacing = 0.13 ;
43 switch(labeltype)
44 {
45 case 0:
46 break ;
47 case 1:
48 m_latex.DrawLatex(xstart+spacing, ystart, "Preliminary") ;
49 break ;
50 case 2:
51 m_latex.DrawLatex(xstart+spacing, ystart, "Internal") ;
52 break ;
53 case 3:
54 m_latex.DrawLatex(xstart+spacing, ystart, "Simulation Preliminary") ;
55 break ;
56 case 4:
57 m_latex.DrawLatex(xstart+spacing, ystart, "Work in Progress") ;
58 break ;
59 default: break ;
60 }
61 return 0;
62}
63#endif
64int SetGraphDrawOption(TGraph *gr, bool isdrawline=true, bool isdrawbar=false)
65{
66 if(!isdrawline&&!isdrawbar)
67 { gr->Draw("AP") ; return 0 ;}
68 if(isdrawline)
69 { gr->Draw("ALP") ; return 0 ;}
70 if(isdrawbar)
71 gr->Draw("AB") ;
72 return 0 ;
73}
74
75int DrawSingleGraphOnCanvas(string canvasname, TGraph *gr, string drawoption="APL" ,
76 bool logx=false, bool logy=false, bool isrectangle=true)
77{ // better not to set drawline or drawbar to be 1 at the same time
78 // define canvas
79 gStyle->SetOptTitle(0) ;
80 float height = 600, width = 600 ;
81 if(isrectangle)
82 width = 800 ;
83 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
84 c->SetTickx() ;
85 c->SetTicky() ;
86 if(logx) c->SetLogx() ;
87 if(logy) c->SetLogy() ;
88 // set attributes of graph
89 SetGraphAttributes(gr, 1, 2, 1, 1001, 1, 20, 1, 1) ;
90 // draw graph
91 gr->Draw(drawoption.c_str()) ;
92 c->Print((canvasname+".eps").c_str()) ;
93 return 0 ;
94}
95
96int DrawTwoGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2,
97 string drawoption1="APL", string drawoption2="PL",
98 bool logx=false, bool logy=false, bool isrectangle=true)
99{ // better not to set drawline or drawbar to be 1 at the same time
100 // define canvas
101 gStyle->SetOptTitle(0) ;
102 float height = 600, width = 600 ;
103 if(isrectangle)
104 width = 800 ;
105 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
106 c->SetTickx() ;
107 c->SetTicky() ;
108 if(logx) c->SetLogx() ;
109 if(logy) c->SetLogy() ;
110 // set attributes of graph
111 SetGraphAttributes(gr1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
112 SetGraphAttributes(gr2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
113
114 // draw graph
115 gr1->Draw(drawoption1.c_str()) ;
116 gr2->Draw(drawoption2.c_str()) ;
117 // draw TLegend
118 TLegend *leg=new TLegend(0.55,0.7,0.89,0.89) ;
119 leg->SetFillStyle(0) ;
120 leg->SetBorderSize(0) ;
121 leg->AddEntry(gr1, gr1->GetTitle(), "LP") ;
122 leg->AddEntry(gr2, gr2->GetTitle(), "LP") ;
123 leg->Draw("same") ;
124 c->Print((canvasname+".eps").c_str()) ;
125 return 0 ;
126}
127
128int DrawThreeGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3,
129 string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",
130 bool logx=false, bool logy=false, bool isrectangle=true)
131{ // better not to set drawline or drawbar to be 1 at the same time
132 // define canvas
133 gStyle->SetOptTitle(0) ;
134 float height = 600, width = 600 ;
135 if(isrectangle)
136 width = 800 ;
137 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
138 c->SetTickx() ;
139 c->SetTicky() ;
140 if(logx) c->SetLogx() ;
141 if(logy) c->SetLogy() ;
142 // set attributes of graph
143 SetGraphAttributes(gr1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
144 SetGraphAttributes(gr2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
145 SetGraphAttributes(gr3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
146
147 // draw graph
148 gr1->Draw(drawopt1.c_str()) ;
149 gr2->Draw(drawopt2.c_str()) ;
150 gr3->Draw(drawopt3.c_str()) ;
151 // draw TLegend
152 TLegend *leg=new TLegend(0.55,0.7,0.89,0.89) ;
153 leg->SetTextSize(0.03) ;
154 leg->SetFillStyle(0) ;
155 leg->SetBorderSize(0) ;
156 leg->AddEntry(gr1, gr1->GetTitle(), "LP") ;
157 leg->AddEntry(gr2, gr2->GetTitle(), "LP") ;
158 leg->AddEntry(gr3, gr3->GetTitle(), "LP") ;
159 leg->Draw("same") ;
160 c->Print((canvasname+".eps").c_str()) ;
161 return 0 ;
162}
163
164int DrawFourGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3,TGraph *gr4,
165 string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",string drawopt4="PL",
166 bool logx=false, bool logy=false, bool isrectangle=true)
167{ // better not to set drawline or drawbar to be 1 at the same time
168 // define canvas
169 gStyle->SetOptTitle(0) ;
170 float height = 600, width = 600 ;
171 if(isrectangle)
172 width = 800 ;
173 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
174 c->SetTickx() ;
175 c->SetTicky() ;
176 if(logx) c->SetLogx() ;
177 if(logy) c->SetLogy() ;
178 // set attributes of graph
179 SetGraphAttributes(gr1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
180 SetGraphAttributes(gr2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
181 SetGraphAttributes(gr3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
182 SetGraphAttributes(gr4, 1, 2, 4, 1001, 4, 23, 4, 1) ;
183 // draw graph
184 gr1->Draw(drawopt1.c_str()) ;
185 gr2->Draw(drawopt2.c_str()) ;
186 gr3->Draw(drawopt3.c_str()) ;
187 gr4->Draw(drawopt4.c_str()) ;
188 // draw TLegend
189 TLegend *leg=new TLegend(0.55,0.5,0.89,0.89) ;
190 leg->SetTextSize(0.03) ;
191 leg->SetFillStyle(0) ;
192 leg->SetBorderSize(0) ;
193 leg->AddEntry(gr1, gr1->GetTitle(), "LP") ;
194 leg->AddEntry(gr2, gr2->GetTitle(), "LP") ;
195 leg->AddEntry(gr3, gr3->GetTitle(), "LP") ;
196 leg->AddEntry(gr4, gr4->GetTitle(), "LP") ;
197 leg->Draw("same") ;
198 c->Print((canvasname+".eps").c_str()) ;
199 return 0 ;
200}
201int DrawFiveGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3,TGraph *gr4,TGraph *gr5,
202string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",string drawopt4="PL",string drawopt5="PL",
203bool logx=false, bool logy=false, bool isrectangle=true)
204{ // better not to set drawline or drawbar to be 1 at the same time
205 // define canvas
206 gStyle->SetOptTitle(0) ;
207 float height = 600, width = 600 ;
208 if(isrectangle)
209 width = 800 ;
210 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
211 c->SetTickx() ;
212 c->SetTicky() ;
213 if(logx) c->SetLogx() ;
214 if(logy) c->SetLogy() ;
215 // set attributes of graph
216 SetGraphAttributes(gr1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
217 SetGraphAttributes(gr2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
218 SetGraphAttributes(gr3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
219 SetGraphAttributes(gr4, 1, 2, 4, 1001, 4, 23, 4, 1) ;
220 SetGraphAttributes(gr5, 1, 2, 5, 1001, 5, 24, 5, 1) ;
221 // draw graph
222 gr1->Draw(drawopt1.c_str()) ;
223 gr2->Draw(drawopt2.c_str()) ;
224 gr3->Draw(drawopt3.c_str()) ;
225 gr4->Draw(drawopt4.c_str()) ;
226 gr5->Draw(drawopt5.c_str()) ;
227 // draw TLegend
228 TLegend *leg=new TLegend(0.55,0.5,0.89,0.89) ;
229 leg->SetTextSize(0.03) ;
230 leg->SetFillStyle(0) ;
231 leg->SetBorderSize(0) ;
232 leg->AddEntry(gr1, gr1->GetTitle(), "LP") ;
233 leg->AddEntry(gr2, gr2->GetTitle(), "LP") ;
234 leg->AddEntry(gr3, gr3->GetTitle(), "LP") ;
235 leg->AddEntry(gr4, gr4->GetTitle(), "LP") ;
236 leg->AddEntry(gr5, gr5->GetTitle(), "LP") ;
237 leg->Draw("same") ;
238 c->Print((canvasname+".eps").c_str()) ;
239 return 0 ;
240}
241
242int SetGraphErrorsDrawOption(TGraphErrors *gre, bool isdrawline=true, bool isdrawerrorrectangle=false, bool isdrawerrorband=false)
243{
244 if(!isdrawline&&!isdrawerrorrectangle&&!isdrawerrorband)
245 { gre->Draw("AP") ; return 0 ;}
246 if(isdrawline)
247 { gre->Draw("APL") ; return 0 ;}
248 if(isdrawerrorrectangle)
249 {
250 gre->Draw("A2") ;
251 gre->Draw("P") ;
252 return 0 ;
253 }
254 if(isdrawerrorband)
255 {
256 gre->Draw("A3") ;
257 gre->Draw("LX") ;
258 }
259 return 0 ;
260}
261
262int DrawSingleGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre, string drawoption="AP", bool logx=false, bool logy=false, bool isrectangle=true, string label="")
263{
264 //gStyle->SetOptTitle(0) ;
265 // define canvas
266 float height = 600, width = 600 ;
267 if(isrectangle)
268 width = 800 ;
269 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
270 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
271 outpad->SetFillStyle(4000) ;
272 TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
273 SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
274 interpad->Draw() ;
275 outpad->Draw() ;
276
277 outpad->cd() ;
278 DrawLabels(0.5,0.8,label.c_str()) ;
279
280 interpad->cd() ;
281 // set options of grapherrors
282 SetGraphErrorsAttributes(gre, 1, 2, 1, 1001, 1, 20, 1, 1) ;
283 gre->Draw(drawoption.c_str()) ;
284 //DrawLabel(0.15,0.15,"#font[22]{ATLAS} #font[12]{Internal}") ;
285 // draw legend
286 TLegend *leg=new TLegend(0.6,0.7,0.8,0.8) ;
287 leg->SetTextSize(0.04) ;
288 leg->SetFillStyle(0) ;
289 leg->SetBorderSize(0) ;
290 leg->AddEntry(gre, gre->GetTitle(), "LP") ;
291 //leg->Draw("same") ;
292 c->Print((canvasname+".eps").c_str()) ;
293 c->Print((canvasname+".pdf").c_str()) ;
294 return 0 ;
295}
296
297int DrawTwoGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2,
298 string drawoption1="APL", string drawoption2="PL",
299 bool logx=false, bool logy=false, bool isrectangle=true)
300{
301 gStyle->SetOptTitle(0) ;
302 // define canvas
303 float height = 600, width = 600 ;
304 if(isrectangle)
305 width = 800 ;
306 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
307 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
308 outpad->SetFillStyle(4000) ;
309 TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
310 SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
311 interpad->Draw() ;
312 outpad->Draw() ;
313
314 outpad->cd() ;
315 //DrawLabels(0.5,0.8,label.c_str()) ;
316
317 interpad->cd() ;
318
319 // set options of grapherrors
320 SetGraphErrorsAttributes(gre1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
321 SetGraphErrorsAttributes(gre2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
322 TMultiGraph *mg = new TMultiGraph();
323 mg->Add(gre1, drawoption1.c_str()) ;
324 mg->Add(gre2, drawoption2.c_str()) ;
325 mg->Draw("A") ;
326 gPad->Modified();
327 float max=0, min=100000 ;
328 for (int i=0 ; i<gre1->GetN() ; i++)
329 {
330 if(gre1->GetY()[i]>=max) max=gre1->GetY()[i] ;
331 if(gre1->GetY()[i]<=min) min=gre1->GetY()[i] ;
332 }
333 //mg->SetMinimum(min*0.9) ;
334 //mg->SetMaximum(max*1.1) ;
336 mg->GetXaxis()->SetTitle(gre1->GetXaxis()->GetTitle()) ;
337 mg->GetYaxis()->SetTitle(gre1->GetYaxis()->GetTitle()) ;
338 // draw legend
339 TLegend *leg=new TLegend(0.6,0.7,0.9,0.9) ;
340 if(gre1->GetY()[0]<gre1->GetY()[1])
341 {
342 leg->SetX1(0.5) ;
343 leg->SetX2(0.9) ;
344 leg->SetY1(0.3) ;
345 leg->SetY2(0.5) ;
346 }
347 leg->SetTextSize(0.03) ;
348 leg->SetFillStyle(0) ;
349 leg->SetBorderSize(0) ;
350 leg->AddEntry(gre1, gre1->GetTitle(), "P") ;
351 leg->AddEntry(gre2, gre2->GetTitle(), "P") ;
352 leg->Draw("same") ;
353 c->Print((canvasname+".eps").c_str()) ;
354 c->Print((canvasname+".pdf").c_str()) ;
355 return 0 ;
356}
357
358int DrawThreeGraphErrorsOnCanvas(string canvasname,
359 TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3,
360 string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",
361 bool logx=false, bool logy=false, bool isrectangle=true, string header="", string label="")
362{
363 gStyle->SetOptTitle(0) ;
364 // define canvas
365 float height = 600, width = 600 ;
366 if(isrectangle)
367 width = 800 ;
368 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
369 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
370 outpad->SetFillStyle(4000) ;
371 TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
372 SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
373 interpad->Draw() ;
374 outpad->Draw() ;
375
376 outpad->cd() ;
377 //DrawLabels(0.4,0.8,label.c_str()) ;
378 DrawATLASLabels(0.25,0.85,2) ;
379
380 interpad->cd() ;
381
382 // set options of grapherrors
383 SetGraphErrorsAttributes(gre1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
384 SetGraphErrorsAttributes(gre2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
385 SetGraphErrorsAttributes(gre3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
386 TMultiGraph *mg = new TMultiGraph();
387 mg->Add(gre1, drawopt1.c_str()) ;
388 mg->Add(gre2, drawopt2.c_str()) ;
389 mg->Add(gre3, drawopt3.c_str()) ;
390 mg->Draw("A") ;
391 gPad->Modified();
392 float max=0, min=100000 ;
393 for (int i=0 ; i<gre1->GetN() ; i++)
394 {
395 if(gre1->GetY()[i]>=max) max=gre1->GetY()[i] ;
396 if(gre1->GetY()[i]<=min) min=gre1->GetY()[i] ;
397 }
398 mg->SetMinimum(min*0.9) ;
399 mg->SetMaximum(max*1.1) ;
401 mg->GetXaxis()->SetTitle(gre1->GetXaxis()->GetTitle()) ;
402 mg->GetYaxis()->SetTitle(gre1->GetYaxis()->GetTitle()) ;
403 // draw legend
404 TLegend *leg=new TLegend(0.55,0.65,0.9,0.9) ;
405 leg->SetTextFont(42);
406 leg->SetTextAlign(22);
407 leg->SetTextSize(0.05);
408 leg->SetFillStyle(0) ;
409 leg->SetBorderSize(0) ;
410 leg->SetHeader(header.c_str()) ;
411 TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
412 theader->SetTextFont(22);
413 leg->AddEntry(gre1, gre1->GetTitle(), "P") ;
414 leg->AddEntry(gre2, gre2->GetTitle(), "P") ;
415 leg->AddEntry(gre3, gre3->GetTitle(), "P") ;
416 leg->Draw("same") ;
417 c->Print((canvasname+".eps").c_str()) ;
418 c->Print((canvasname+".pdf").c_str()) ;
419 c->Print((canvasname+".png").c_str()) ;
420 return 0 ;
421}
422
423int DrawFourGraphErrorsOnCanvas(string canvasname,
424 TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4,
425 string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",string drawopt4="PL",
426 bool logx=false, bool logy=false, bool isrectangle=false, string header="", string label="")
427{
428 gStyle->SetOptTitle(0) ;
429 // define canvas
430 float height = 600, width = 600 ;
431 if(isrectangle)
432 width = 800 ;
433 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
434 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
435 outpad->SetFillStyle(4000) ;
436 TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
437 SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
438 interpad->Draw() ;
439 outpad->Draw() ;
440
441 outpad->cd() ;
442 //DrawLabels(0.3,0.85,label.c_str()) ;
443 DrawATLASLabels(0.25,0.85,2) ;
444
445 interpad->cd() ;
446
447 // set options of grapherrors
448 SetGraphErrorsAttributes(gre1, 1, 2, 2, 1001, 1, 21, 2, 1) ;
449 SetGraphErrorsAttributes(gre2, 1, 2, 3, 1001, 2, 22, 3, 1) ;
450 SetGraphErrorsAttributes(gre3, 1, 2, 4, 1001, 3, 23, 4, 1) ;
451 SetGraphErrorsAttributes(gre4, 1, 2, 6, 1001, 4, 24, 6, 1) ;
452 TMultiGraph *mg = new TMultiGraph();
453 mg->Add(gre1, drawopt1.c_str()) ;
454 mg->Add(gre2, drawopt2.c_str()) ;
455 mg->Add(gre3, drawopt3.c_str()) ;
456 mg->Add(gre4, drawopt4.c_str()) ;
457 mg->Draw("A") ;
458 gPad->Modified();
459 gPad->Update();
461 mg->GetXaxis()->SetTitle(gre1->GetXaxis()->GetTitle()) ;
462 mg->GetYaxis()->SetTitle(gre1->GetYaxis()->GetTitle()) ;
463 if(canvasname.find("pi")!=std::string::npos)
464 {
465 if(canvasname.find("Ratio")!=std::string::npos)
466 {
467 if(canvasname.find("LateralSpread")!=std::string::npos)
468 {
469 mg->GetYaxis()->SetRangeUser(0.76, 1.26) ;
470 mg->GetYaxis()->SetNdivisions(510) ;
471 }
472 if(canvasname.find("Resolution")!=std::string::npos)
473 {
474 mg->GetYaxis()->SetRangeUser(0.91, 1.41) ;
475 mg->GetYaxis()->SetNdivisions(510) ;
476 }
477 if(canvasname.find("Response")!=std::string::npos)
478 {
479 mg->GetYaxis()->SetRangeUser(0.96, 1.11) ;
480 mg->GetYaxis()->SetNdivisions(503) ;
481 }
482 }
483 else
484 {
485 if(canvasname.find("LateralSpread")!=std::string::npos)
486 {
487 mg->GetYaxis()->SetRangeUser(0.025, 0.055) ;
488 mg->GetYaxis()->SetNdivisions(503) ;
489 }
490 }
491 }
492 else
493 {
494 if(canvasname.find("Ratio")!=std::string::npos)
495 {
496 if(canvasname.find("LateralSpread")!=std::string::npos)
497 {
498 mg->GetYaxis()->SetRangeUser(0.94, 1.39) ;
499 mg->GetYaxis()->SetNdivisions(509) ;
500 }
501 if(canvasname.find("Resolution")!=std::string::npos)
502 {
503 mg->GetYaxis()->SetRangeUser(0.81, 1.36) ;
504 mg->GetYaxis()->SetNdivisions(511) ;
505 }
506 if(canvasname.find("Response")!=std::string::npos)
507 {
508 mg->GetYaxis()->SetRangeUser(0.91, 1.16) ;
509 mg->GetYaxis()->SetNdivisions(505) ;
510 }
511 }
512 else
513 {
514 if(canvasname.find("LateralSpread")!=std::string::npos)
515 {
516 mg->GetYaxis()->SetRangeUser(0.025, 0.065) ;
517 mg->GetYaxis()->SetNdivisions(504) ;
518 }
519 }
520 }
521 // draw legend
522 TLegend *leg=new TLegend(0.55,0.6,0.9,0.9) ;
523 leg->SetTextFont(42);
524 leg->SetTextAlign(22);
525 leg->SetTextSize(0.04);
526 leg->SetFillStyle(0) ;
527 leg->SetBorderSize(0) ;
528 leg->SetHeader(header.c_str()) ;
529 TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
530 theader->SetTextFont(22);
531 if(canvasname.find("Response")!=std::string::npos&&canvasname.find("Ratio")==std::string::npos)
532 {
533 leg->SetX1(0.55) ;
534 leg->SetX2(0.9) ;
535 leg->SetY1(0.25) ;
536 leg->SetY2(0.5) ;
537 }
538 leg->AddEntry(gre1, gre1->GetTitle(), "P") ;
539 leg->AddEntry(gre2, gre2->GetTitle(), "P") ;
540 leg->AddEntry(gre3, gre3->GetTitle(), "P") ;
541 leg->AddEntry(gre4, gre4->GetTitle(), "P") ;
542 leg->Draw("same") ;
543 c->Print((canvasname+".eps").c_str()) ;
544 c->Print((canvasname+".pdf").c_str()) ;
545 c->Print((canvasname+".png").c_str()) ;
546 return 0 ;
547}
548
549int DrawFiveGraphErrorsOnCanvas(string canvasname,
550TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4, TGraphErrors *gre5, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",string drawopt4="PL",string drawopt5="PL",
551bool logx=false, bool logy=false, bool isrectangle=false, string header="", string label="")
552{
553 gStyle->SetOptTitle(0) ;
554 // define canvas
555 float height = 600, width = 600 ;
556 if(isrectangle)
557 width = 800 ;
558 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
559 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
560 outpad->SetFillStyle(4000) ;
561 TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
562 SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
563 interpad->Draw() ;
564 outpad->Draw() ;
565
566 outpad->cd() ;
567 //DrawLabels(0.3,0.85,label.c_str()) ;
568 DrawATLASLabels(0.25,0.85,2) ;
569
570 interpad->cd() ;
571
572 // set options of grapherrors
573 SetGraphErrorsAttributes(gre1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
574 SetGraphErrorsAttributes(gre2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
575 SetGraphErrorsAttributes(gre3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
576 SetGraphErrorsAttributes(gre4, 1, 2, 4, 1001, 4, 23, 4, 1) ;
577 SetGraphErrorsAttributes(gre5, 1, 2, 6, 1001, 5, 24, 6, 1) ;
578 TMultiGraph *mg = new TMultiGraph();
579 mg->Add(gre1, drawopt1.c_str()) ;
580 mg->Add(gre2, drawopt2.c_str()) ;
581 mg->Add(gre3, drawopt3.c_str()) ;
582 mg->Add(gre4, drawopt4.c_str()) ;
583 mg->Add(gre5, drawopt5.c_str()) ;
584 mg->Draw("A") ;
586 mg->GetXaxis()->SetTitle(gre1->GetXaxis()->GetTitle()) ;
587 mg->GetYaxis()->SetTitle(gre1->GetYaxis()->GetTitle()) ;
588 if(canvasname.find("pi")!=std::string::npos)
589 {
590 if(canvasname.find("Ratio")!=std::string::npos)
591 {
592 if(canvasname.find("LateralSpread")!=std::string::npos)
593 {
594 mg->GetYaxis()->SetRangeUser(0.76, 1.16) ;
595 mg->GetYaxis()->SetNdivisions(508) ;
596 }
597 if(canvasname.find("Resolution")!=std::string::npos)
598 {
599 mg->GetYaxis()->SetRangeUser(0.91, 1.21) ;
600 mg->GetYaxis()->SetNdivisions(506) ;
601 }
602 if(canvasname.find("Response")!=std::string::npos)
603 {
604 mg->GetYaxis()->SetRangeUser(0.96, 1.16) ;
605 mg->GetYaxis()->SetNdivisions(504) ;
606 }
607 }
608 else
609 {
610 if(canvasname.find("LateralSpread")!=std::string::npos)
611 {
612 mg->GetYaxis()->SetRangeUser(0.025, 0.055) ;
613 mg->GetYaxis()->SetNdivisions(503) ;
614 }
615 }
616 }
617 else
618 {
619 if(canvasname.find("Ratio")!=std::string::npos)
620 {
621 if(canvasname.find("LateralSpread")!=std::string::npos)
622 {
623 mg->GetYaxis()->SetRangeUser(0.94, 1.39) ;
624 mg->GetYaxis()->SetNdivisions(509) ;
625 }
626 if(canvasname.find("Resolution")!=std::string::npos)
627 {
628 mg->GetYaxis()->SetRangeUser(0.81, 1.21) ;
629 mg->GetYaxis()->SetNdivisions(508) ;
630 }
631 if(canvasname.find("Response")!=std::string::npos)
632 {
633 mg->GetYaxis()->SetRangeUser(0.91, 1.26) ;
634 mg->GetYaxis()->SetNdivisions(507) ;
635 }
636 }
637 else
638 {
639 if(canvasname.find("LateralSpread")!=std::string::npos)
640 {
641 mg->GetYaxis()->SetRangeUser(0.025, 0.065) ;
642 mg->GetYaxis()->SetNdivisions(504) ;
643 }
644 }
645 }
646 gPad->Modified();
647 // draw legend
648 TLegend *leg=new TLegend(0.55,0.55,0.9,0.9) ;
649 leg->SetTextFont(42);
650 leg->SetTextAlign(22);
651 leg->SetTextSize(0.04);
652 leg->SetFillStyle(0) ;
653 leg->SetBorderSize(0) ;
654 leg->SetHeader(header.c_str()) ;
655 TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
656 theader->SetTextFont(22) ;
657 if(canvasname.find("Response")!=std::string::npos&&canvasname.find("Ratio")==std::string::npos)
658 {
659 leg->SetX1(0.55) ;
660 leg->SetX2(0.9) ;
661 leg->SetY1(0.2) ;
662 leg->SetY2(0.5) ;
663 }
664 leg->AddEntry(gre1, gre1->GetTitle(), "P") ;
665 leg->AddEntry(gre2, gre2->GetTitle(), "P") ;
666 leg->AddEntry(gre3, gre3->GetTitle(), "P") ;
667 leg->AddEntry(gre4, gre4->GetTitle(), "P") ;
668 leg->AddEntry(gre5, gre5->GetTitle(), "P") ;
669 leg->Draw("same") ;
670 c->Print((canvasname+".eps").c_str()) ;
671 c->Print((canvasname+".pdf").c_str()) ;
672 c->Print((canvasname+".png").c_str()) ;
673 return 0 ;
674}
675
677TGraphErrors *topgre1, TGraphErrors *topgre2, TGraphErrors *topgre3, TGraphErrors *topgre4, TGraphErrors *topgre5, TGraphErrors *bottomgre1, TGraphErrors *bottomgre2, TGraphErrors *bottomgre3, TGraphErrors *bottomgre4,string topdrawopt1="APL", string topdrawopt2="PL", string topdrawopt3="PL",string topdrawopt4="PL",string topdrawopt5="PL", string bottomdrawopt1="APL", string bottomdrawopt2="PL", string bottomdrawopt3="PL",string bottomdrawopt4="PL",
678bool logx=false, bool toplogy=false, bool bottomlogy=false, bool isrectangle=false, string header="")
679{
680 gStyle->SetOptTitle(0) ;
681 // define canvas
682 float height = 600, width = 600 ;
683 if(isrectangle)
684 width = 800 ;
685 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
686 TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;
687 outpad->SetFillStyle(4000) ;
688 TPad *interpad1 = new TPad("intpad1","pad1",0,0.33,1,1) ;// For main histo
689 TPad *interpad2 = new TPad("intpad2","pad2",0,0,1,0.33) ;// For residuals histo
690 SetPadAttributes(interpad1, 0, 0, 0.15, 0.05, 0.00001, 0.05, 0, logx, toplogy) ;
691 SetPadAttributes(interpad2, 0, 0, 0.15, 0.05, 0.3, 0.00001, 0, logx, bottomlogy) ;
692
693 interpad1->Draw() ;
694 interpad2->Draw() ;
695 outpad->Draw() ;
696
697 outpad->cd() ;
698 DrawATLASLabels(0.23,0.9,1) ;
699 DrawLabel(0.23,0.85,"Tile Calorimeter") ;
700
701 interpad1->cd() ;
702
703 // set options of grapherrors
704 SetGraphErrorsAttributes(topgre1, 1, 2, 1, 1001, 1, 20, 1, 1, 0.05, 1.4, 0.05, 0.05, 1.4, 0.05) ;
705 SetGraphErrorsAttributes(topgre2, 1, 2, 2, 1001, 2, 21, 2, 1, 0.05, 1.4, 0.05, 0.05, 1.4, 0.05) ;
706 SetGraphErrorsAttributes(topgre3, 1, 2, 3, 1001, 3, 22, 3, 1, 0.05, 1.4, 0.05, 0.05, 1.4, 0.05) ;
707 SetGraphErrorsAttributes(topgre4, 1, 2, 4, 1001, 4, 23, 4, 1, 0.05, 1.4, 0.05, 0.05, 1.4, 0.05) ;
708 SetGraphErrorsAttributes(topgre5, 1, 2, 6, 1001, 6, 24, 6, 1, 0.05, 1.4, 0.05, 0.05, 1.4, 0.05) ;
709 TMultiGraph *topmg = new TMultiGraph();
710 topmg->Add(topgre1, topdrawopt1.c_str()) ;
711 topmg->Add(topgre2, topdrawopt2.c_str()) ;
712 topmg->Add(topgre3, topdrawopt3.c_str()) ;
713 topmg->Add(topgre4, topdrawopt4.c_str()) ;
714 topmg->Add(topgre5, topdrawopt5.c_str()) ;
715 // Draw
716 topmg->Draw("A") ;
717 SetMGraphAttributes(topmg, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
718 topmg->GetXaxis()->SetTitle(topgre2->GetXaxis()->GetTitle()) ;
719 topmg->GetYaxis()->SetTitle(topgre2->GetYaxis()->GetTitle()) ;
720 if(canvasname.find("pi")!=std::string::npos)
721 {
722 if(canvasname.find("LateralSpread")!=std::string::npos)
723 {
724 topmg->GetYaxis()->SetRangeUser(0.025, 0.055) ;
725 topmg->GetYaxis()->SetNdivisions(503) ;
726 }
727 }
728 else
729 {
730 if(canvasname.find("LateralSpread")!=std::string::npos)
731 {
732 topmg->GetYaxis()->SetRangeUser(0.03, 0.055) ;
733 topmg->GetYaxis()->SetNdivisions(503) ;
734 }
735 }
736 gPad->Modified();
737 // draw legend
738 TLegend *leg=new TLegend(0.55,0.45,0.9,0.9) ;
739 leg->SetTextFont(42);
740 leg->SetTextAlign(22);
741 leg->SetTextSize(0.05);
742 leg->SetFillStyle(0) ;
743 leg->SetBorderSize(0) ;
744 leg->SetHeader(header.c_str()) ;
745 TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
746 theader->SetTextFont(22) ;
747 if(canvasname.find("Response")!=std::string::npos)
748 {
749 leg->SetX1(0.55) ;
750 leg->SetX2(0.9) ;
751 leg->SetY1(0.05) ;
752 leg->SetY2(0.5) ;
753 }
754 leg->AddEntry(topgre1, topgre1->GetTitle(), "P") ;
755 leg->AddEntry(topgre2, topgre2->GetTitle(), "P") ;
756 leg->AddEntry(topgre3, topgre3->GetTitle(), "P") ;
757 leg->AddEntry(topgre4, topgre4->GetTitle(), "P") ;
758 leg->AddEntry(topgre5, topgre5->GetTitle(), "P") ;
759 leg->Draw("same") ;
760
761 interpad2->cd() ;
762
763 // set options of bottom grapherrors
764 SetGraphErrorsAttributes(bottomgre1, 1, 2, 2, 1001, 2, 21, 2, 1, 0.12, 1.2, 0.1, 0.12, 0.7, 0.1) ;
765 SetGraphErrorsAttributes(bottomgre2, 1, 2, 3, 1001, 3, 22, 3, 1, 0.12, 1.2, 0.1, 0.12, 0.7, 0.1) ;
766 SetGraphErrorsAttributes(bottomgre3, 1, 2, 4, 1001, 4, 23, 4, 1, 0.12, 1.2, 0.1, 0.12, 0.7, 0.1) ;
767 SetGraphErrorsAttributes(bottomgre4, 1, 2, 6, 1001, 6, 24, 6, 1, 0.12, 1.2, 0.1, 0.12, 0.7, 0.1) ;
768 TMultiGraph *bottommg = new TMultiGraph();
769 bottommg->Add(bottomgre1, bottomdrawopt1.c_str()) ;
770 bottommg->Add(bottomgre2, bottomdrawopt2.c_str()) ;
771 bottommg->Add(bottomgre3, bottomdrawopt3.c_str()) ;
772 bottommg->Add(bottomgre4, bottomdrawopt4.c_str()) ;
773 bottommg->Draw("A") ;
774 SetMGraphAttributes(bottommg, 0.12, 1.4, 0.1, 0.12, 0.7, 0.1) ;
775 bottommg->GetXaxis()->SetTitle(bottomgre1->GetXaxis()->GetTitle()) ;
776 bottommg->GetYaxis()->SetTitle(bottomgre1->GetYaxis()->GetTitle()) ;
777
778 c->Update() ;
779 c->Print((canvasname+".eps").c_str()) ;
780 c->Print((canvasname+".pdf").c_str()) ;
781 c->Print((canvasname+".png").c_str()) ;
782 return 0 ;
783
784}
785
786int DrawSixGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4,TGraphErrors *gre5, TGraphErrors *gre6, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",string drawopt4="PL",string drawopt5="PL",string drawopt6="PL", bool logx=false, bool logy=false, bool isrectangle=true)
787{
788 gStyle->SetOptTitle(0) ;
789 // define canvas
790 float height = 600, width = 600 ;
791 if(isrectangle)
792 width = 800 ;
793 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
794 c->SetTickx() ;
795 c->SetTicky() ;
796 if(logx) c->SetLogx() ;
797 if(logy) c->SetLogy() ;
798
799 // set options of grapherrors
800 SetGraphErrorsAttributes(gre1, 1, 2, 1, 1001, 1, 20, 1, 1) ;
801 SetGraphErrorsAttributes(gre2, 1, 2, 2, 1001, 2, 21, 2, 1) ;
802 SetGraphErrorsAttributes(gre3, 1, 2, 3, 1001, 3, 22, 3, 1) ;
803 SetGraphErrorsAttributes(gre4, 1, 2, 4, 1001, 4, 23, 4, 1) ;
804 SetGraphErrorsAttributes(gre5, 1, 2, 5, 1001, 5, 24, 5, 1) ;
805 SetGraphErrorsAttributes(gre6, 1, 2, 6, 1001, 6, 25, 6, 1) ;
806 TMultiGraph *mg = new TMultiGraph();
807 mg->Add(gre1, drawopt1.c_str()) ;
808 mg->Add(gre2, drawopt2.c_str()) ;
809 mg->Add(gre3, drawopt3.c_str()) ;
810 mg->Add(gre4, drawopt4.c_str()) ;
811 mg->Add(gre5, drawopt5.c_str()) ;
812 mg->Add(gre6, drawopt6.c_str()) ;
813 mg->Draw("A") ;
814 gPad->Modified();
815 float max=0, min=100000 ;
816 for (int i=0 ; i<gre1->GetN() ; i++)
817 {
818 if(gre1->GetY()[i]>=max) max=gre1->GetY()[i] ;
819 if(gre1->GetY()[i]<=min) min=gre1->GetY()[i] ;
820 }
821 mg->SetMinimum(min*0.8) ;
822 mg->SetMaximum(max*1.2) ;
824 mg->GetXaxis()->SetTitle(gre1->GetXaxis()->GetTitle()) ;
825 mg->GetYaxis()->SetTitle(gre1->GetYaxis()->GetTitle()) ;
826 // draw legend
827 TLegend *leg=new TLegend(0.5,0.5,0.89,0.89) ;
828 leg->SetTextSize(0.03) ;
829 leg->SetFillStyle(0) ;
830 leg->SetBorderSize(0) ;
831 leg->AddEntry(gre1, gre1->GetTitle(), "P") ;
832 leg->AddEntry(gre2, gre2->GetTitle(), "P") ;
833 leg->AddEntry(gre3, gre3->GetTitle(), "P") ;
834 leg->AddEntry(gre4, gre4->GetTitle(), "P") ;
835 leg->AddEntry(gre5, gre5->GetTitle(), "P") ;
836 leg->AddEntry(gre6, gre6->GetTitle(), "P") ;
837 leg->Draw("same") ;
838 c->Print((canvasname+".eps").c_str()) ;
839 c->Print((canvasname+".pdf").c_str()) ;
840 return 0 ;
841}
842
843int SetGraphAsymmErrorsDrawOption(TGraphAsymmErrors *grae, bool isdrawline=true, bool isdrawerrorrectangle=false, bool isdrawerrorband=false)
844{
845 if(!isdrawline&&!isdrawerrorrectangle&&!isdrawerrorband)
846 { grae->Draw("AP") ; return 0 ;}
847 if(isdrawline)
848 { grae->Draw("APL") ; return 0 ;}
849 if(isdrawerrorrectangle)
850 {
851 grae->Draw("A2") ;
852 grae->Draw("P") ;
853 return 0 ;
854 }
855 if(isdrawerrorband)
856 {
857 grae->Draw("A3") ;
858 grae->Draw("LX") ;
859 }
860 return 0 ;
861}
862
863int DrawSigleAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre,
864 string drawoption="APL" , bool logx=false, bool logy=false, bool isrectangle=true)
865{
866 gStyle->SetOptTitle(0) ;
867 // define canvas
868 float height = 600, width = 600 ;
869 if(isrectangle)
870 width = 800 ;
871 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
872 c->SetTickx() ;
873 c->SetTicky() ;
874 if(logx) c->SetLogx() ;
875 if(logy) c->SetLogy() ;
876 // set options of grapherror
877 SetGraphAsymmErrorsAttributes(agre, 1, 2, 1, 1001, 1, 1, 20, 1) ;
878 agre->Draw(drawoption.c_str()) ;
879 c->Print((canvasname+".eps").c_str()) ;
880 return 0 ;
881}
882
883int DrawTwoAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2,
884 string drawopt1="APL", string drawopt2="PL",
885 bool logx=false, bool logy=false,
886 bool isrectangle=true)
887{
888 gStyle->SetOptTitle(0) ;
889 // define canvas
890 float height = 600, width = 600 ;
891 if(isrectangle)
892 width = 800 ;
893 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
894 c->SetTickx() ;
895 c->SetTicky() ;
896 if(logx) c->SetLogx();
897 if(logy) c->SetLogy();
898 // set options of grapherror
899 SetGraphAsymmErrorsAttributes(agre1, 1, 2, 1, 1001, 1, 20, 1) ;
900 SetGraphAsymmErrorsAttributes(agre2, 1, 2, 2, 1001, 2, 21, 2) ;
901 agre1->Draw(drawopt1.c_str()) ;
902 agre2->Draw(drawopt2.c_str()) ;
903 // draw legend
904 TLegend *leg=new TLegend(0.55,0.7,0.89,0.89) ;
905 leg->SetTextSize(0.03) ;
906 leg->SetFillStyle(0) ;
907 leg->SetBorderSize(0) ;
908 leg->AddEntry(agre1, agre1->GetTitle(), "LEP") ;
909 leg->AddEntry(agre2, agre2->GetTitle(), "LEP") ;
910 leg->Draw("same") ;
911 c->Print((canvasname+".eps").c_str()) ;
912 return 0 ;
913}
914
915int DrawThreeAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL",
916 bool logx=false, bool logy=false,
917 bool isrectangle=true)
918{
919 gStyle->SetOptTitle(0) ;
920 // define canvas
921 float height = 600, width = 600 ;
922 if(isrectangle)
923 width = 800 ;
924 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
925 c->SetTickx() ;
926 c->SetTicky() ;
927 if(logx) c->SetLogx() ;
928 if(logy) c->SetLogy() ;
929 // set options of grapherror
930 SetGraphAsymmErrorsAttributes(agre1, 1, 2, 1, 1001, 1, 20, 1) ;
931 SetGraphAsymmErrorsAttributes(agre2, 1, 2, 2, 1001, 2, 21, 2) ;
932 SetGraphAsymmErrorsAttributes(agre3, 1, 2, 3, 1001, 3, 22, 3) ;
933 agre1->Draw(drawopt1.c_str()) ;
934 agre2->Draw(drawopt2.c_str()) ;
935 agre3->Draw(drawopt3.c_str()) ;
936 // draw legend
937 TLegend *leg=new TLegend(0.55,0.6,0.89,0.89) ;
938 leg->SetTextSize(0.03) ;
939 leg->SetFillStyle(0) ;
940 leg->SetBorderSize(0) ;
941 leg->AddEntry(agre1, agre1->GetTitle(), "LEP") ;
942 leg->AddEntry(agre2, agre2->GetTitle(), "LEP") ;
943 leg->AddEntry(agre3, agre3->GetTitle(), "LEP") ;
944 leg->Draw("same") ;
945 c->Print((canvasname+".eps").c_str()) ;
946 return 0 ;
947}
948
949int DrawFourAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, TGraphAsymmErrors *agre4,string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", bool logx=false, bool logy=false, bool isrectangle=true)
950{
951 gStyle->SetOptTitle(0) ;
952 // define canvas
953 float height = 600, width = 600 ;
954 if(isrectangle)
955 width = 800 ;
956 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
957 c->SetTickx() ;
958 c->SetTicky() ;
959 if(logx) c->SetLogx() ;
960 if(logy) c->SetLogy() ;
961 // set options of grapherror
962 SetGraphAsymmErrorsAttributes(agre1, 1, 2, 1, 1001, 1, 20, 1) ;
963 SetGraphAsymmErrorsAttributes(agre2, 1, 2, 2, 1001, 2, 21, 2) ;
964 SetGraphAsymmErrorsAttributes(agre3, 1, 2, 3, 1001, 3, 22, 3) ;
965 SetGraphAsymmErrorsAttributes(agre4, 1, 2, 4, 1001, 4, 23, 4) ;
966 agre1->Draw(drawopt1.c_str()) ;
967 agre2->Draw(drawopt2.c_str()) ;
968 agre3->Draw(drawopt3.c_str()) ;
969 agre4->Draw(drawopt4.c_str()) ;
970 // draw legend
971 TLegend *leg=new TLegend(0.55,0.5,0.89,0.89) ;
972 leg->SetTextSize(0.03) ;
973 leg->SetFillStyle(0) ;
974 leg->SetBorderSize(0) ;
975 leg->AddEntry(agre1, agre1->GetTitle(), "LEP") ;
976 leg->AddEntry(agre2, agre2->GetTitle(), "LEP") ;
977 leg->AddEntry(agre3, agre3->GetTitle(), "LEP") ;
978 leg->AddEntry(agre4, agre4->GetTitle(), "LEP") ;
979 leg->Draw("same") ;
980 c->Print((canvasname+".eps").c_str()) ;
981 return 0 ;
982}
983
984int DrawFiveAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, TGraphAsymmErrors *agre4,TGraphAsymmErrors *agre5,string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", string drawopt5="PL",bool logx=false, bool logy=false, bool isrectangle=true)
985{
986 gStyle->SetOptTitle(0) ;
987 // define canvas
988 float height = 600, width = 600 ;
989 if(isrectangle)
990 width = 800 ;
991 TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
992 c->SetTickx() ;
993 c->SetTicky() ;
994 if(logx) c->SetLogx() ;
995 if(logy) c->SetLogy() ;
996 // set options of grapherror
997 SetGraphAsymmErrorsAttributes(agre1, 1, 2, 1, 1001, 1, 20, 1) ;
998 SetGraphAsymmErrorsAttributes(agre2, 1, 2, 2, 1001, 2, 21, 2) ;
999 SetGraphAsymmErrorsAttributes(agre3, 1, 2, 3, 1001, 3, 22, 3) ;
1000 SetGraphAsymmErrorsAttributes(agre4, 1, 2, 4, 1001, 4, 23, 4) ;
1001 SetGraphAsymmErrorsAttributes(agre5, 1, 2, 5, 1001, 5, 23, 5) ;
1002 agre1->Draw(drawopt1.c_str()) ;
1003 agre2->Draw(drawopt2.c_str()) ;
1004 agre3->Draw(drawopt3.c_str()) ;
1005 agre4->Draw(drawopt4.c_str()) ;
1006 agre5->Draw(drawopt5.c_str()) ;
1007 // draw legend
1008 TLegend *leg=new TLegend(0.55,0.5,0.89,0.89) ;
1009 leg->SetTextSize(0.03) ;
1010 leg->SetFillStyle(0) ;
1011 leg->SetBorderSize(0) ;
1012 leg->AddEntry(agre1, agre1->GetTitle(), "LEP") ;
1013 leg->AddEntry(agre2, agre2->GetTitle(), "LEP") ;
1014 leg->AddEntry(agre3, agre3->GetTitle(), "LEP") ;
1015 leg->AddEntry(agre4, agre4->GetTitle(), "LEP") ;
1016 leg->AddEntry(agre5, agre5->GetTitle(), "LEP") ;
1017 leg->Draw("same") ;
1018 c->Print((canvasname+".eps").c_str()) ;
1019 return 0 ;
1020}
#define gr
int DrawFiveGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4, TGraphErrors *gre5, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", string drawopt5="PL", bool logx=false, bool logy=false, bool isrectangle=false, string header="", string label="")
int DrawSigleAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre, string drawoption="APL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawSingleGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre, string drawoption="AP", bool logx=false, bool logy=false, bool isrectangle=true, string label="")
int DrawThreeGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int SetGraphErrorsDrawOption(TGraphErrors *gre, bool isdrawline=true, bool isdrawerrorrectangle=false, bool isdrawerrorband=false)
int DrawFiveGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3, TGraph *gr4, TGraph *gr5, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", string drawopt5="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int SetGraphDrawOption(TGraph *gr, bool isdrawline=true, bool isdrawbar=false)
int DrawThreeGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", bool logx=false, bool logy=false, bool isrectangle=true, string header="", string label="")
int DrawTwoGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, string drawoption1="APL", string drawoption2="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawSingleGraphOnCanvas(string canvasname, TGraph *gr, string drawoption="APL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawLabel(float xstart, float ystart, string label)
int DrawATLASLabels(float xstart, float ystart, int labeltype)
int DrawFourAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, TGraphAsymmErrors *agre4, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawThreeAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawLabels(float xstart, float ystart, string label="")
int SetGraphAsymmErrorsDrawOption(TGraphAsymmErrors *grae, bool isdrawline=true, bool isdrawerrorrectangle=false, bool isdrawerrorband=false)
int DrawFourGraphsOnCanvas(string canvasname, TGraph *gr1, TGraph *gr2, TGraph *gr3, TGraph *gr4, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawSixGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4, TGraphErrors *gre5, TGraphErrors *gre6, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", string drawopt5="PL", string drawopt6="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawTwoGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, string drawoption1="APL", string drawoption2="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawTwoAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, string drawopt1="APL", string drawopt2="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawFourGraphErrorsOnCanvas(string canvasname, TGraphErrors *gre1, TGraphErrors *gre2, TGraphErrors *gre3, TGraphErrors *gre4, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", bool logx=false, bool logy=false, bool isrectangle=false, string header="", string label="")
int DrawFiveAsymmGraphErrorsOnCanvas(string canvasname, TGraphAsymmErrors *agre1, TGraphAsymmErrors *agre2, TGraphAsymmErrors *agre3, TGraphAsymmErrors *agre4, TGraphAsymmErrors *agre5, string drawopt1="APL", string drawopt2="PL", string drawopt3="PL", string drawopt4="PL", string drawopt5="PL", bool logx=false, bool logy=false, bool isrectangle=true)
int DrawTopFiveGraphErrorsAndBottomFourGraphErrorsOnCanvas(string canvasname, TGraphErrors *topgre1, TGraphErrors *topgre2, TGraphErrors *topgre3, TGraphErrors *topgre4, TGraphErrors *topgre5, TGraphErrors *bottomgre1, TGraphErrors *bottomgre2, TGraphErrors *bottomgre3, TGraphErrors *bottomgre4, string topdrawopt1="APL", string topdrawopt2="PL", string topdrawopt3="PL", string topdrawopt4="PL", string topdrawopt5="PL", string bottomdrawopt1="APL", string bottomdrawopt2="PL", string bottomdrawopt3="PL", string bottomdrawopt4="PL", bool logx=false, bool toplogy=false, bool bottomlogy=false, bool isrectangle=false, string header="")
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 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 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 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)
const double width
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
std::string label(const std::string &format, int i)
Definition label.h:19
bool logy
Definition listroot.cxx:45