ATLAS Offline Software
HistToolKit.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ##########################################
6 // Author: Dengfeng Zhang
7 // dengfeng.zhang@cern.ch
8 // ##########################################
9 // std include
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <algorithm>
15 // local include
16 #include "SetAttributes.h"
17 // if want to call following functions, do following
18 // from ROOT import *; gROOT.ProcessLine("#include \"HistToolKit.h\"")
19 
20 // define some functions in head
21 int DrawLabels(float xstart, float ystart, string label, bool isbold=true) ;
22 int DrawATLASLabels(float xstart, float ystart, int labelstyle) ;
23 int DrawCMEAndLumi(float xstart, float ystart, string lumiInFb, string CME) ;
25 bool sort_by_vechistmax(std::pair<TH1F*, bool> p1, std::pair<TH1F*, bool> p2) ;
26 
27 TH1F* bookTH1F( const std::string& name, const std::string& title,
28  const std::string& xlabel,const std::string& ylabel,
29  int xbins, double xlow, double xhigh,
30  bool sumw2 = true, bool overflow=true)
31 {
32  TH1F* tmp = new TH1F( name.c_str(), title.c_str(), xbins, xlow, xhigh);
33  tmp->GetXaxis()->SetTitle(xlabel.c_str()) ;
34  tmp->GetYaxis()->SetTitle(ylabel.c_str()) ;
35  if(sumw2) tmp->Sumw2() ;
36  if(overflow) tmp->StatOverflows() ;
37  return tmp ;
38 }
39 TH1F* bookTH1F(string name, string title,
40  string xlabel,string ylabel,
41  int nbins, float *bininterval,
42  bool sumw2 = true)
43 {
44  TH1F* tmp = new TH1F( name.c_str(), title.c_str(), nbins, bininterval);
45  tmp->GetXaxis()->SetTitle(xlabel.c_str()) ;
46  tmp->GetYaxis()->SetTitle(ylabel.c_str()) ;
47  if(sumw2) tmp->Sumw2() ;
48  tmp->StatOverflows() ;
49  return tmp ;
50 }
51 
52 TH1F* bookTH1F(const string& name, const string& title,
53  const string& xlabel,const string& ylabel,
54  TH1F* hist,
55  bool sumw2 = true)
56 {
57  TH1F* tmp = new TH1F( name.c_str(), title.c_str(), hist->GetNbinsX(), hist->GetXaxis()->GetXbins()->GetArray());
58  tmp->GetXaxis()->SetTitle(xlabel.c_str()) ;
59  tmp->GetYaxis()->SetTitle(ylabel.c_str()) ;
60  if(sumw2) tmp->Sumw2() ;
61  tmp->StatOverflows() ;
62  return tmp ;
63 }
64 
65 TH1I* bookTH1I(const std::string& name, const std::string& title,
66  const std::string& xlabel,const std::string& ylabel,
67  int xbins, double xlow, double xhigh,
68  bool sumw2 = true)
69 {
70  TH1I* tmp = new TH1I( name.c_str(), title.c_str(), xbins, xlow, xhigh);
71  tmp->GetXaxis()->SetTitle(xlabel.c_str()) ;
72  tmp->GetYaxis()->SetTitle(ylabel.c_str()) ;
73  if(sumw2) tmp->Sumw2() ;
74  tmp->StatOverflows() ;
75  return tmp ;
76 }
77 
78 // Get Effective Histogram
80 {
81  std::cout<<"Get Effective Entries."<<std::endl ;
82  TH1F *hee = new TH1F(name.c_str(), name.c_str(), hist->GetXaxis()->GetNbins(),
83  hist->GetXaxis()->GetXbins()->GetArray()) ;
84  hee->SetDirectory(0) ;
85  for(int bin=1 ; bin<hist->GetNbinsX()+1 ; bin++)
86  {
87  float nee ;
88  if (hist->GetBinError(bin) != 0.)
89  nee = pow(hist->GetBinContent(bin),2)/pow(hist->GetBinError(bin),2) ;
90  else
91  nee = 0. ;
92  hee->SetBinContent(bin, nee);
93  hee->SetBinError(bin, sqrt(nee)) ;
94  }
95  return hee ;
96 }
97 // Get DataLike Histogram
98 TH1F* getDataLikeHist(TH1F* eff, TH1F* scaled, string name, int jobSeed = 10 )
99 {
100  std::cout<<"Get DataLike Entries."<<std::endl ;
101  TH1F *dataLike = new TH1F(name.c_str(), name.c_str(), eff->GetXaxis()->GetNbins(),
102  eff->GetXaxis()->GetXbins()->GetArray()) ;
103  dataLike->SetDirectory(0) ;
104  //random number generator
105  TRandom3 rand3(1986) ; //1986 #ORIGINAL
106 
107  //loop over bins
108  for( int bin=1 ; bin<eff->GetNbinsX()+1 ; bin++)
109  {
110  //enough effective entries?
111  float nee = eff->GetBinContent(bin) ;
112  if(nee>=scaled->GetBinContent(bin))
113  {
114  //set seed
115  //NOTE the seed for each bin must be always the same
116  int binSeed = int(eff->GetBinCenter(bin) + jobSeed*1e5 );
117  rand3.SetSeed(binSeed);
118  //get data-like bin content by drawing entries
119  //NOTE weights are poissonian by construction
120  for( int jj=1 ; jj<=int(nee) ; jj++)
121  if(rand3.Uniform()<(float)scaled->GetBinContent(bin)/nee)
122  dataLike->Fill(dataLike->GetBinCenter(bin)) ;
123  }
124  }
125  return dataLike ;
126 }
127 
128 
129 // Get map from binary file
130 int GetNumberOfEvents(const std::string& filename, std::map<string, int> *channelvsbumber)
131 {
132  ifstream fileIn(filename.c_str());
133  std::string line;
134  std::string subStr;
135  std::string channel ;
136  int number ;
137  while (getline(fileIn, line))
138  {
139  istringstream iss(line);
140  iss >> channel ;
141  if( channel.find_first_of('#')==0 )
142  continue ;
143  iss >> subStr;
144  iss >> subStr;
145  iss >> subStr;
146  sscanf(subStr.c_str(), "%i", &number);
147  (*channelvsbumber)[channel]=number ;
148  cout << "channelvsbumber[" << channel << "]: " << (*channelvsbumber)[channel] << endl;
149  }
150  return 0 ;
151 }
152 
153 int DrawSingleHistOnCanvas(string canvasname, TH1F* hist, string drawoption="PE", bool logx=false, bool logy=true, bool isrectangle=false, string label="")
154 {
155  gStyle->SetOptTitle(0);
156  float height=600,width=600 ;
157  if(isrectangle)
158  width=800 ;
159  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
160  // Define pads
161  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
162  outpad->SetFillStyle(4000) ;
163  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
164  SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
165 
166  interpad->Draw() ;
167  outpad->Draw() ;
168 
169  outpad->cd() ;
170  //DrawLabels(0.5, 0.8, label) ;
171  // Draw ATLAS Label
172  DrawATLASLabels(0.2, 0.8, 2) ;
173  // draw center of mass energy and integrated luminosity
174  //DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
175  interpad->cd() ;
176  // Set histogram attributes
177  SetHistAttributes(hist, 1, 2, 1, 1001, 0, 20, 1, 1) ;
178  // draw histogram
179  hist->Draw(drawoption.c_str()) ;
180  c->Print((canvasname+".eps").c_str()) ;
181  c->Print((canvasname+".pdf").c_str()) ;
182  return 0 ;
183 }
184 int SetHistDrawOption(TH1F* hist, TLegend *leg, bool DrawHistorNot=false)
185 {
186  if(DrawHistorNot)
187  {
188  hist->Draw("HISTSAME") ;
189  leg->AddEntry(hist, hist->GetTitle(), "L") ;
190  }
191  else
192  {
193  hist->Draw("PESAME") ;
194  leg->AddEntry(hist, hist->GetTitle(), "LPE") ;
195  }
196  leg->Draw("same") ;
197  return 0 ;
198 }
199 int SetHistDrawOption(std::vector< std::pair< TH1F*, bool > > histvec, TLegend *leg)
200 {
201  for(std::vector< std::pair< TH1F*, bool > >::iterator itr=histvec.begin() ; itr!=histvec.end() ; ++itr)
202  {
203  if(itr->second)
204  {
205  itr->first->Draw("HISTSAME") ;
206  leg->AddEntry(itr->first, itr->first->GetTitle(), "L") ;
207  }
208  else
209  {
210  itr->first->Draw("PESAME") ;
211  leg->AddEntry(itr->first, itr->first->GetTitle(), "LPE") ;
212  }
213  }
214  leg->Draw("same") ;
215  return 0 ;
216 }
217 int DrawTwoHistsOnCanvas(string canvasname, TH1F* hist1, TH1F* hist2, string drawoption1="HIST", string drawoption2="HISTSame", bool logx=false, bool logy=true, bool isrectangle=true)
218 {
219  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
220  // define Canvas
221  float height=600 ;
222  float width ;
223  if(isrectangle)
224  width=800 ;
225  else
226  width=600 ;
227  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
228 
229  // Define pads
230  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
231  outpad->SetFillStyle(4000) ;//transparent
232  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
233  SetPadAttributes(interpad, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
234 
235  interpad->Draw() ;
236  outpad->Draw() ;
237 
238  outpad->cd() ;
239  // Draw ATLAS Label
240  DrawATLASLabels(0.2, 0.8, 2) ;
241  // draw center of mass energy and integrated luminosity
242  //DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
243 
244  interpad->cd() ;
245  // Set histogram attributes
246  SetHistAttributes(hist1, 1, 2, 1, 0, 1, 20, 1) ;
247  SetHistAttributes(hist2, 1, 2, 2, 0, 1, 22, 2) ;
248  hist1->Draw(drawoption1.c_str()) ;
249  hist2->Draw(drawoption2.c_str()) ;
250  // define legend
251  TLegend *leg=new TLegend(0.5,0.7,0.89,0.89) ;
252  leg->SetFillStyle(0) ;
253  leg->SetTextSize(0.04) ;
254  leg->SetBorderSize(0) ;
255  if(drawoption1.find("HIST")!=string::npos)
256  leg->AddEntry(hist1, hist1->GetTitle(), "L") ;
257  else
258  leg->AddEntry(hist1, hist1->GetTitle(), "LPE") ;
259  if(drawoption2.find("HIST")!=string::npos)
260  leg->AddEntry(hist2, hist2->GetTitle(), "L") ;
261  else
262  leg->AddEntry(hist2, hist2->GetTitle(), "LPE") ;
263  leg->Draw("same") ;
264  c->Print((canvasname+".eps").c_str()) ;
265  return 0 ;
266 }
267 
268 int DrawThreeHistsOnCanvas(string canvasname, TH1F* hist1, TH1F* hist2, TH1F* hist3, string drawopt1="PE",string drawopt2="PESame", string drawopt3="PESame", bool logx=false, bool logy=true, bool isrectangle=true, string header="", string label="")
269 {
270  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
271  // define Canvas
272  float height=600 ;
273  float width ;
274  if(isrectangle)
275  width=800 ;
276  else
277  width=600 ;
278  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
279 
280  // Define pads
281  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
282  outpad->SetFillStyle(4000) ;//transparent
283  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
284  SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
285 
286  interpad->Draw() ;
287  outpad->Draw() ;
288 
289  outpad->cd() ;
290  if(canvasname.find("LongitudinalProfile")!=std::string::npos&&canvasname.find("Ratio")==std::string::npos)
291  DrawLabels(0.2, 0.4, label, true) ;
292  else
293  DrawLabels(0.2, 0.85, label, true) ;
294  // Draw ATLAS Label
295  DrawATLASLabels(0.2, 0.25, 2) ;
296  // draw center of mass energy and integrated luminosity
297 // DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
298 
299  interpad->cd() ;
300  // Set histogram attributes
301  SetHistAttributes(hist1, 1, 2, 3, 3004, 1, 22, 3, 1) ;
302  SetHistAttributes(hist2, 1, 2, 4, 3005, 1, 23, 4, 1) ;
303  SetHistAttributes(hist3, 1, 2, 6, 3006, 1, 24, 6, 1) ;
304  // Draw Histograms
305  hist1->Draw(drawopt1.c_str()) ;
306  hist2->Draw(drawopt2.c_str()) ;
307  hist3->Draw(drawopt3.c_str()) ;
308  // define legend
309  TLegend *leg=new TLegend(0.57,0.65,0.92,0.9) ;
310  string PhysicsLists[4] = {"FTFP_BERT", "FTFP_BERT_ATL", "QGSP_BERT", "QGSP_BIC"} ;
311  for(int i=0 ; i<4 ; i++)
312  {
313  if(canvasname.find(PhysicsLists[i])!=std::string::npos)
314  {
315  leg->SetX1(0.65) ;
316  leg->SetX2(0.9) ;
317  leg->SetY1(0.65) ;
318  leg->SetY2(0.9) ;
319  }
320  }
321  leg->SetTextFont(42) ;
322  leg->SetTextAlign(22);
323  leg->SetFillStyle(0) ;
324  leg->SetTextSize(0.04) ;
325  leg->SetBorderSize(0) ;
326  leg->SetHeader(header.c_str()) ;
327  TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
328  theader->SetTextFont(22) ;
329  leg->AddEntry(hist1, hist1->GetTitle(), "P") ;
330  leg->AddEntry(hist2, hist2->GetTitle(), "P") ;
331  leg->AddEntry(hist3, hist3->GetTitle(), "P") ;
332  leg->Draw("same") ;
333  c->Print((canvasname+".eps").c_str()) ;
334  c->Print((canvasname+".pdf").c_str()) ;
335  c->Print((canvasname+".png").c_str()) ;
336  return 0 ;
337 }
338 
339 int DrawFourHistsOnCanvas(string canvasname, TH1F* hist1, TH1F* hist2, TH1F* hist3, TH1F* hist4, string drawopt1="PE",string drawopt2="PESame", string drawopt3="PESame",string drawopt4="PESame",bool logx=false, bool logy=true, bool isrectangle=false, string header="", string label="")
340 {
341  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
342  // define Canvas
343  float height=600 ;
344  float width ;
345  if(isrectangle)
346  width=800 ;
347  else
348  width=600 ;
349  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
350 
351  // Define pads
352  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
353  outpad->SetFillStyle(4000) ;//transparent
354  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
355  SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
356 
357  interpad->Draw() ;
358  outpad->Draw() ;
359 
360  outpad->cd() ;
361  if(canvasname.find("LongitudinalProfile")!=std::string::npos&&canvasname.find("Ratio")==std::string::npos)
362  DrawLabels(0.2, 0.4, label, true) ;
363  else
364  DrawLabels(0.2, 0.85, label, true) ;
365  //Draw ATLAS Label
366  DrawATLASLabels(0.2, 0.25, 2) ;
367  //draw center of mass energy and integrated luminosity
368  //DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
369 
370  interpad->cd() ;
371  // Set histogram attributes
372  SetHistAttributes(hist1, 1, 2, 2, 0, 1, 21, 2, 1) ;
373  SetHistAttributes(hist2, 1, 2, 3, 0, 1, 22, 3, 1) ;
374  SetHistAttributes(hist3, 1, 2, 4, 0, 1, 23, 4, 1) ;
375  SetHistAttributes(hist4, 1, 2, 6, 0, 1, 24, 6, 1) ;
376  // Draw Histograms
377  hist1->Draw(drawopt1.c_str()) ;
378  hist2->Draw(drawopt2.c_str()) ;
379  hist3->Draw(drawopt3.c_str()) ;
380  hist4->Draw(drawopt4.c_str()) ;
381  // define legend
382  TLegend *leg=new TLegend(0.57,0.6,0.92,0.9) ;
383  string PhysicsLists[4] = {"FTFP_BERT", "FTFP_BERT_ATL", "QGSP_BERT", "QGSP_BIC"} ;
384  for(int i=0 ; i<4 ; i++)
385  {
386  if(canvasname.find(PhysicsLists[i])!=std::string::npos)
387  {
388  leg->SetX1(0.65) ;
389  leg->SetX2(0.9) ;
390  leg->SetY1(0.6) ;
391  leg->SetY2(0.9) ;
392  }
393  }
394  leg->SetTextFont(42) ;
395  leg->SetTextAlign(22);
396  leg->SetBorderSize(0) ;
397  leg->SetFillStyle(0) ;
398  leg->SetTextSize(0.04) ;
399  leg->SetHeader(header.c_str()) ;
400  TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
401  theader->SetTextFont(22) ;
402  leg->AddEntry(hist1, hist1->GetTitle(), "P") ;
403  leg->AddEntry(hist2, hist2->GetTitle(), "P") ;
404  leg->AddEntry(hist3, hist3->GetTitle(), "P") ;
405  leg->AddEntry(hist4, hist4->GetTitle(), "P") ;
406  leg->Draw("Same") ;
407  c->Print((canvasname+".eps").c_str()) ;
408  c->Print((canvasname+".pdf").c_str()) ;
409  c->Print((canvasname+".png").c_str()) ;
410 
411  return 0 ;
412 }
413 
414 int DrawFiveHistsOnCanvas(string canvasname, TH1F* hist1, TH1F* hist2, TH1F* hist3, TH1F* hist4, TH1F* hist5,
415 string drawopt1="PE",string drawopt2="PESame",string drawopt3="PESame",string drawopt4="PESame", string drawopt5="PESame",bool logx=false, bool logy=true, bool isrectangle=true, string header="", string label="")
416 {
417  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
418  // define Canvas
419  float height=600 ;
420  float width ;
421  if(isrectangle)
422  width=800 ;
423  else
424  width=600 ;
425  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
426 
427  // Define pads
428  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
429  outpad->SetFillStyle(4000) ;//transparent
430  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
431  SetPadAttributes(interpad, 0, 0, 0.16, 0.04, 0.15, 0.05, 0, logx, logy) ;
432 
433  interpad->Draw() ;
434  outpad->Draw() ;
435 
436  outpad->cd() ;
437  if(canvasname.find("LongitudinalProfile")!=std::string::npos&&canvasname.find("Ratio")==std::string::npos)
438  DrawLabels(0.2, 0.4, label, true) ;
439  else
440  DrawLabels(0.2, 0.85, label, true) ;
441  // Draw ATLAS Label
442  DrawATLASLabels(0.2, 0.25, 2) ;
443  // draw center of mass energy and integrated luminosity
444 // DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
445 
446  interpad->cd() ;
447  // Set histogram attributes
448  SetHistAttributes(hist1, 1, 2, 1, 0, 1, 20, 1, 1) ;
449  SetHistAttributes(hist2, 1, 2, 2, 0, 1, 21, 2, 1) ;
450  SetHistAttributes(hist3, 1, 2, 3, 0, 1, 22, 3, 1) ;
451  SetHistAttributes(hist4, 1, 2, 4, 0, 1, 23, 4, 1) ;
452  SetHistAttributes(hist5, 1, 2, 6, 0, 1, 24, 6, 1) ;
453  // Draw Histograms
454  hist1->Draw(drawopt1.c_str()) ;
455  hist2->Draw(drawopt2.c_str()) ;
456  hist3->Draw(drawopt3.c_str()) ;
457  hist4->Draw(drawopt4.c_str()) ;
458  hist5->Draw(drawopt5.c_str()) ;
459  // define legend
460  TLegend *leg=new TLegend(0.57,0.55,0.92,0.9) ;
461  string PhysicsLists[4] = {"FTFP_BERT", "FTFP_BERT_ATL", "QGSP_BERT", "QGSP_BIC"} ;
462  for(int i=0 ; i<4 ; i++)
463  {
464  if(canvasname.find(PhysicsLists[i])!=std::string::npos)
465  {
466  leg->SetX1(0.65) ;
467  leg->SetX2(0.9) ;
468  leg->SetY1(0.55) ;
469  leg->SetY2(0.9) ;
470  }
471  }
472  leg->SetTextFont(42);
473  leg->SetTextAlign(22);
474  leg->SetBorderSize(0) ;
475  leg->SetFillStyle(0) ;
476  leg->SetTextSize(0.04) ;
477  leg->SetHeader(header.c_str()) ;
478  TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
479  theader->SetTextFont(22) ;
480  leg->AddEntry(hist1, hist1->GetTitle(), "P") ;
481  leg->AddEntry(hist2, hist2->GetTitle(), "P") ;
482  leg->AddEntry(hist3, hist3->GetTitle(), "P") ;
483  leg->AddEntry(hist4, hist4->GetTitle(), "P") ;
484  leg->AddEntry(hist5, hist5->GetTitle(), "P") ;
485  leg->Draw("Same") ;
486  c->Print((canvasname+".eps").c_str()) ;
487  c->Print((canvasname+".pdf").c_str()) ;
488  c->Print((canvasname+".png").c_str()) ;
489  return 0 ;
490 }
491 
492 int DrawTopFiveHistsAndBottomFourHistsOnCanvas(string canvasname, TH1F *top1, TH1F* top2, TH1F* top3, TH1F* top4, TH1F* top5, TH1F* bottom1, TH1F* bottom2, TH1F* bottom3, TH1F* bottom4, string topdrawopt1 = "PE",string topdrawopt2 = "PESAME", string topdrawopt3 = "PE",string topdrawopt4 = "PESAME", string topdrawopt5 = "PESAME", string bottomdrawopt1="PE", string bottomdrawopt2="PESame", string bottomdrawopt3="PESame", string bottomdrawopt4="PESame",bool logx=false, bool toplogy=true, bool bottomlogy=false, bool isrectangle=false, string header="", string label="")
493 {
494  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
495  // define Canvas
496  float height=600 ;
497  float width ;
498  if(isrectangle)
499  width=800 ;
500  else
501  width=600 ;
502  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
503 
504  // Define pads
505  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
506  outpad->SetFillStyle(4000) ;//transparent
507  TPad *interpad1 = new TPad("intpad1","pad1",0,0.33,1,1) ;// For main histo
508  TPad *interpad2 = new TPad("intpad2","pad2",0,0,1,0.33) ;// For residuals histo
509  //outpad->SetFillStyle(4000) ;//transparent
510  SetPadAttributes(interpad1, 0, 0, 0.15, 0.05, 0.00001, 0.05, 0, logx, toplogy) ;
511  SetPadAttributes(interpad2, 0, 0, 0.15, 0.05, 0.3, 0.00001, 0, logx, bottomlogy) ;
512 
513  interpad1->Draw() ;
514  interpad2->Draw() ;
515  outpad->Draw() ;
516 
517  outpad->cd() ;
518  DrawLabels(0.65, 0.65, label, true) ;
519  // Draw ATLAS Label
520  DrawATLASLabels(0.2, 0.45, 1) ;
521  DrawLabels(0.2, 0.4, "Tile Calorimeter", false) ;
522 
523  interpad1->cd() ;
524  // Set histogram attributes
525  SetHistAttributes(top1, 1, 2, 1, 0, 1, 20, 1, 1, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
526  SetHistAttributes(top2, 1, 2, 2, 0, 1, 21, 2, 1, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
527  SetHistAttributes(top3, 1, 2, 3, 0, 1, 22, 3, 1, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
528  SetHistAttributes(top4, 1, 2, 4, 0, 1, 23, 4, 1, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
529  SetHistAttributes(top5, 1, 2, 6, 0, 1, 24, 6, 1, 0.06, 1.2, 0.06, 0.06, 1.2, 0.06) ;
530  // Draw Histograms
531  top1->Draw(topdrawopt1.c_str()) ;
532  top2->Draw(topdrawopt2.c_str()) ;
533  top3->Draw(topdrawopt3.c_str()) ;
534  top4->Draw(topdrawopt4.c_str()) ;
535  top5->Draw(topdrawopt5.c_str()) ;
536  // define legend
537  TLegend *leg=new TLegend(0.55,0.54,0.9,0.94) ;
538  string PhysicsLists[4] = {"FTFP_BERT", "FTFP_BERT_ATL", "QGSP_BERT", "QGSP_BIC"} ;
539  for(int i=0 ; i<4 ; i++)
540  {
541  if(canvasname.find(PhysicsLists[i])!=std::string::npos)
542  {
543  leg->SetX1(0.6) ;
544  leg->SetX2(0.9) ;
545  leg->SetY1(0.45) ;
546  leg->SetY2(0.9) ;
547  }
548  }
549  leg->SetTextFont(42);
550  leg->SetTextAlign(22);
551  leg->SetBorderSize(0) ;
552  leg->SetFillStyle(0) ;
553  leg->SetTextSize(0.05) ;
554  leg->SetHeader(header.c_str()) ;
555  TLegendEntry *theader = (TLegendEntry*)leg->GetListOfPrimitives()->First();
556  theader->SetTextFont(22) ;
557  leg->AddEntry(top1, top1->GetTitle(), "P") ;
558  leg->AddEntry(top2, top2->GetTitle(), "P") ;
559  leg->AddEntry(top3, top3->GetTitle(), "P") ;
560  leg->AddEntry(top4, top4->GetTitle(), "P") ;
561  leg->AddEntry(top5, top5->GetTitle(), "P") ;
562  leg->Draw("Same") ;
563 
564  interpad2->cd() ;
565  // set bottom histograms attributes
566  SetHistAttributes(bottom1, 1, 2, 2, 0, 1, 21, 2, 1, 0.12, 1.4, 0.1, 0.12, 0.7, 0.1) ;
567  SetHistAttributes(bottom2, 1, 2, 3, 0, 1, 22, 3, 1, 0.12, 1.4, 0.1, 0.12, 0.7, 0.1) ;
568  SetHistAttributes(bottom3, 1, 2, 4, 0, 1, 23, 4, 1, 0.12, 1.4, 0.1, 0.12, 0.7, 0.1) ;
569  SetHistAttributes(bottom4, 1, 2, 6, 0, 1, 24, 6, 1, 0.12, 1.4, 0.1, 0.12, 0.7, 0.1) ;
570  // Draw bottom histograms
571  bottom1->Draw(bottomdrawopt1.c_str()) ;
572  bottom2->Draw(bottomdrawopt2.c_str()) ;
573  bottom3->Draw(bottomdrawopt3.c_str()) ;
574  bottom4->Draw(bottomdrawopt4.c_str()) ;
575  c->Update() ;
576  c->Print((canvasname+".eps").c_str()) ;
577  c->Print((canvasname+".pdf").c_str()) ;
578  c->Print((canvasname+".png").c_str()) ;
579  return 0;
580 }
581 
582 int DrawTwelveHistsOnCanvas(string canvasname, TH1F* hist1, TH1F* hist2, TH1F* hist3, TH1F* hist4, TH1F* hist5,TH1F* hist6, TH1F* hist7, TH1F* hist8, TH1F* hist9, TH1F* hist10,TH1F* hist11, TH1F* hist12, string drawopt1="PE",string drawopt2="PESame",string drawopt3="PESame",string drawopt4="PESame", string drawopt5="PESame",string drawopt6="PESame",string drawopt7="PESame",string drawopt8="PESame",string drawopt9="PESame", string drawopt10="PESame",string drawopt11="PESame",string drawopt12="PESame",bool logx=false, bool logy=true, bool isrectangle=true)
583 {
584  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
585  // define Canvas
586  float height=600 ;
587  float width ;
588  if(isrectangle)
589  width=800 ;
590  else
591  width=600 ;
592  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
593 
594  // Define pads
595  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
596  outpad->SetFillStyle(4000) ;//transparent
597  TPad *interpad = new TPad("interpad","interpad",0,0,1,1) ;// For main histo
598  SetPadAttributes(interpad, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
599 
600  interpad->Draw() ;
601  outpad->Draw() ;
602 
603  outpad->cd() ;
604  // Draw ATLAS Label
605  DrawATLASLabels(0.6, 0.85, 2) ;
606  // draw center of mass energy and integrated luminosity
607 // DrawCMEAndLumi(0.5, 0.7, "XX", "13 TeV") ;
608 
609  interpad->cd() ;
610  // Set histogram attributes
611  SetHistAttributes(hist1, 1, 2, 1, 0, 1, 20, 1, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
612  SetHistAttributes(hist2, 1, 2, 2, 0, 1, 21, 2, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
613  SetHistAttributes(hist3, 1, 2, 3, 0, 1, 22, 3, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
614  SetHistAttributes(hist4, 1, 2, 4, 0, 1, 23, 4, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
615  SetHistAttributes(hist5, 1, 2, 5, 0, 1, 24, 5, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
616  SetHistAttributes(hist6, 1, 2, 6, 0, 1, 25, 6, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
617  SetHistAttributes(hist7, 1, 2, 7, 0, 1, 26, 7, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
618  SetHistAttributes(hist8, 1, 2, 8, 0, 1, 27, 8, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
619  SetHistAttributes(hist9, 1, 2, 9, 0, 1, 28, 9, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
620  SetHistAttributes(hist10, 1, 2, 15, 0, 1, 29, 15, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
621  SetHistAttributes(hist11, 1, 2, 11, 0, 1, 30, 11, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
622  SetHistAttributes(hist12, 1, 2, 12, 0, 1, 31, 12, 1, 0.04, 1., 0.04, 0.04, 1.2, 0.04, false) ;
623  // Draw Histograms
624  hist1->Draw(drawopt1.c_str()) ;
625  hist2->Draw(drawopt2.c_str()) ;
626  hist3->Draw(drawopt3.c_str()) ;
627  hist4->Draw(drawopt4.c_str()) ;
628  hist5->Draw(drawopt5.c_str()) ;
629  hist6->Draw(drawopt6.c_str()) ;
630  hist7->Draw(drawopt7.c_str()) ;
631  hist8->Draw(drawopt8.c_str()) ;
632  hist9->Draw(drawopt9.c_str()) ;
633  hist10->Draw(drawopt10.c_str()) ;
634  hist11->Draw(drawopt11.c_str()) ;
635  hist12->Draw(drawopt12.c_str()) ;
636  // define legend
637  TLegend *leg=new TLegend(0.6,0.4,0.89,0.8) ;
638  leg->SetBorderSize(0) ;
639  leg->SetFillStyle(0) ;
640  leg->SetTextSize(0.03) ;
641  leg->AddEntry(hist1, hist1->GetTitle(), "f") ;
642  leg->AddEntry(hist2, hist2->GetTitle(), "f") ;
643  leg->AddEntry(hist3, hist3->GetTitle(), "f") ;
644  leg->AddEntry(hist4, hist4->GetTitle(), "f") ;
645  leg->AddEntry(hist5, hist5->GetTitle(), "f") ;
646  leg->AddEntry(hist6, hist6->GetTitle(), "f") ;
647  leg->AddEntry(hist7, hist7->GetTitle(), "f") ;
648  leg->AddEntry(hist8, hist8->GetTitle(), "f") ;
649  leg->AddEntry(hist9, hist9->GetTitle(), "f") ;
650  leg->AddEntry(hist10, hist10->GetTitle(), "f") ;
651  leg->AddEntry(hist11, hist11->GetTitle(), "f") ;
652  leg->AddEntry(hist12, hist12->GetTitle(), "f") ;
653  leg->Draw("Same") ;
654  c->Print((canvasname+".eps").c_str()) ;
655  c->Print((canvasname+".pdf").c_str()) ;
656  return 0 ;
657 }
658 
659 int DrawTopTwoHistsAndBottomOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *bottom1, string topdrawopt1 = "HIST",string topdrawopt2 = "PESAME", string bottomdrawopt="PE",bool logx=false, bool toplogy=true, bool bottomlogy=false)
660 {
661  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
662  // define Canvas
663  TCanvas *c = new TCanvas(canvasname.c_str(), "", 800, 800) ;
664  // Define pads
665  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
666  TPad *pad1 = new TPad("pad1","pad1",0,0.33,1,1) ;// For main histo
667  TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.33) ;// For residuals histo
668 
669  outpad->SetFillStyle(4000) ;//transparent
670  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.00001, 0.1, 0, logx, toplogy) ;
671  SetPadAttributes(pad2, 0, 0, 0.1, 0.1, 0.3, 0.00001, 0, logx, bottomlogy) ;
672  pad1->Draw() ;
673  pad2->Draw() ;
674  outpad->Draw() ;
675 
676  outpad->cd() ;
677  // Draw ATLAS Label
678  DrawATLASLabels(0.6, 0.75, 2) ;
679  // draw center of mass energy and integrated luminosity
680  //DrawCMEAndLumi(0.6, 0.7, "XX", "13 TeV") ;
681 
682  pad1->cd() ;
683  pad1->SetTickx() ;
684  pad1->SetTicky() ;
685 
686  // set histogram attributes
687  SetHistAttributes(top1, 1, 2, 1, 0, 1, 20, 1, 1, 0.05, 1., 0.05, 0.05, 1., 0.05, false) ;
688  SetHistAttributes(top2, 1, 2, 2, 0, 1, 21, 2, 1, 0.05, 1., 0.05, 0.05, 1., 0.05, false) ;
689  SetHistAttributes(bottom1, 1, 2, 1, 0, 1, 20, 1, 1, 0.1, 1.0, 0.1, 0.1, 0.5, 0.1, false) ;
690  if(logx)
691  {
692  top1->GetXaxis()->SetMoreLogLabels() ;
693  top2->GetXaxis()->SetMoreLogLabels() ;
694  bottom1->GetXaxis()->SetMoreLogLabels() ;
695  }
696  top1->Draw(topdrawopt1.c_str()) ;
697  top2->Draw(topdrawopt2.c_str()) ;
698  // draw legend
699  TLegend *leg=new TLegend(0.5,0.7,0.89,0.89) ;
700  leg->SetFillStyle(0) ;
701  leg->SetTextSize(0.03) ;
702  leg->SetBorderSize(0) ;
703  if(topdrawopt1.find("HIST")!=string::npos)
704  leg->AddEntry(top1, top1->GetTitle(), "L") ;
705  else
706  leg->AddEntry(top1, top1->GetTitle(), "LPE") ;
707  if(topdrawopt2.find("HIST")!=string::npos)
708  leg->AddEntry(top2, top2->GetTitle(), "L") ;
709  else
710  leg->AddEntry(top2, top2->GetTitle(), "LPE") ;
711  leg->Draw("same") ;
712 
713  pad2->cd() ;
714  pad2->SetTicky() ;
715  // Draw bottom histograms
716  bottom1->Draw(bottomdrawopt.c_str()) ;
717  c->Update() ;
718  c->Print((canvasname+".eps").c_str()) ;
719 
720  return 0;
721 }
722 
723 int DrawTopTwoHistsAndBottomTwoHistsOnCanvas(string canvasname, TH1F *top1, TH1F* top2,
724  TH1F* bottom1, TH1F* bottom2,
725  bool TFirstDrawHistorNot=true, bool TSecondDrawHistorNot=false,
726  bool DFirstDrawHistorNot=true, bool BSecondDrawHistorNot=false,
727  bool logx=false, bool toplogy=true, bool bottomlogy=false)
728 {
729  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
730  // define Canvas
731  TCanvas *c = new TCanvas(canvasname.c_str(), "", 800, 800) ;
732 
733  // Define pads
734  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
735  TPad *pad1 = new TPad("pad1","pad1",0,0.33,1,1) ;// For main histo
736  TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.33) ;// For residuals histo
737 
738  //outpad->SetFillStyle(4000) ;//transparent
739  SetPadAttributes(pad1, 4000, 0, 0.1, 0.1, 0.00001, 0.1, 0, logx, toplogy) ;
740  SetPadAttributes(pad2, 0, 0, 0.1, 0.1, 0.3, 0.00001, 0, logx, bottomlogy) ;
741  pad1->Draw() ;
742  pad2->Draw() ;
743  outpad->Draw() ;
744 
745  outpad->cd() ;
746  // Draw ATLAS Label
747  DrawATLASLabels(0.5, 0.85, 4) ;
748  // draw center of mass energy and integrated luminosity
749  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
750 
751  pad1->cd() ;
752  pad1->SetTickx() ;
753  pad1->SetTicky() ;
754  // set top histograms attributes
755  SetHistAttributes(top1, 1, 2, 1, 0, 1, 20, 1, 1, 0.04, 1., 0.04, 0.04, 1., 0.04, false) ;
756  SetHistAttributes(top2, 1, 2, 2, 0, 1, 21, 2, 1, 0.04, 1., 0.04, 0.04, 1., 0.04, false) ;
757  // draw legend
758  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
759  leg->SetBorderSize(0) ;
760  // sort the top hists by its maximum
761  std::vector< std::pair< TH1F*, bool > > histvec ;
762  histvec.push_back(std::make_pair(top1, TFirstDrawHistorNot)) ;
763  histvec.push_back(std::make_pair(top2, TSecondDrawHistorNot)) ;
764  std::sort(histvec.begin(), histvec.end(),sort_by_vechistmax) ;
765  // draw histograms using option "HIST" or not
766  SetHistDrawOption(histvec, leg) ;
767 
768  pad2->cd() ;
769  pad2->SetTicky() ;
770  // set bottom histograms attributes
771  SetHistAttributes(bottom1, 1, 2, 1, 3004, 1, 20, 1, 1, 0.1, 0.5, 0.1, 0.1, 0.5, 0.1, false) ;
772  SetHistAttributes(bottom2, 1, 2, 2, 3005, 1, 21, 2, 1, 0.1, 0.5, 0.1, 0.1, 0.5, 0.1, false) ;
773  // Draw bottom histograms
774  bottom1->Draw("EP0") ;
775  bottom2->Draw("EP0same") ;
776 
777  c->Update() ;
778  c->Print((canvasname+".eps").c_str()) ;
779  return 0;
780 }
781 
782 int DrawTwoHistsinHStackOnCanvas(string canvasname, TH1F *top1, TH1F *top2,
783  bool logx=false, bool logy=false,
784  bool drawlabel=true, string label="",
785  bool drawcmeandlumi=false, bool isrectangle=true)
786 {
787  gStyle->SetOptTitle(0); //this will disable the title for all coming histograms
788  // define Canvas
789  float height=600 ;
790  float width ;
791  if(isrectangle)
792  width=800 ;
793  else
794  width=600 ;
795  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
796 
797  // set attributs of histograms
798  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
799  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
800 
801  // define stack
802  THStack *stack=new THStack("stack","") ;
803  stack->Add(top1) ;
804  stack->Add(top2) ;
805  // Define pads
806  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
807  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
808 
809  outpad->SetFillStyle(4000) ;//transparent
810  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
811  pad1->Draw() ;
812  outpad->Draw() ;
813 
814  outpad->cd() ;
815  // Draw ATLAS Label
816  if(drawlabel)
817  DrawLabels(0.65, 0.7, label.c_str(), true) ;
818  // draw center of mass energy and integrated luminosity
819  if(drawcmeandlumi)
820  DrawCMEAndLumi(0.65, 0.65, "XX", "13 TeV") ;
821 
822  pad1->cd() ;
823  pad1->SetTickx() ;
824  pad1->SetTicky() ;
825  // draw stack
826  stack->Draw("HIST") ;
827  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
828  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
830  gPad->Modified() ;
831  // draw legend
832  TLegend *leg=new TLegend(0.65,0.75,0.89,0.89) ;
833  leg->SetBorderSize(0) ;
834  leg->AddEntry(top1, top1->GetTitle(), "F") ;
835  leg->AddEntry(top2, top2->GetTitle(), "F") ;
836  // draw legend
837  leg->Draw("same") ;
838 
839  c->Update() ;
840  c->Print((canvasname+".eps").c_str()) ;
841  return 0;
842 }
843 
844 int DrawThreeHistsinHStackOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F* top3,
845  bool logx=false, bool logy=false,
846  bool isrectangle=true, bool drawlabel=true, string label="",
847  bool drawcmeandlumi=false)
848 {
849  // define Canvas
850  float height=600 ;
851  float width ;
852  if(isrectangle)
853  width=800 ;
854  else
855  width=600 ;
856  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
857 
858  // set attributs of histograms
859  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
860  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
861  SetHistAttributes(top3, 1, 2, 4, 1001, 4) ;
862 
863  // define stack
864  THStack *stack=new THStack("stack","") ;
865  stack->Add(top1) ;
866  stack->Add(top2) ;
867  stack->Add(top3) ;
868  // Define pads
869  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
870  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
871 
872  outpad->SetFillStyle(4000) ;//transparent
873  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
874  pad1->Draw() ;
875  outpad->Draw() ;
876 
877  outpad->cd() ;
878  // Draw ATLAS Label
879  if(drawlabel)
880  DrawLabels(0.65, 0.7, label.c_str(), true) ;
881  // draw center of mass energy and integrated luminosity
882  if(drawcmeandlumi)
883  DrawCMEAndLumi(0.65, 0.65, "XX", "13 TeV") ;
884 
885  pad1->cd() ;
886  // draw stack
887  stack->Draw("HIST") ;
888  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
889  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
891  gPad->Modified() ;
892 
893  // draw legend
894  TLegend *leg=new TLegend(0.65,0.75,0.89,0.89) ;
895  leg->SetBorderSize(0) ;
896  leg->AddEntry(top1, top1->GetTitle(), "F") ;
897  leg->AddEntry(top2, top2->GetTitle(), "F") ;
898  leg->AddEntry(top3, top2->GetTitle(), "F") ;
899  // draw legend
900  leg->Draw("same") ;
901 
902  c->Update() ;
903  c->Print((canvasname+".eps").c_str()) ;
904 
905  return 0;
906 }
907 
908 int DrawFourHistsinHStackOnCanvas(string canvasname,
909  TH1F *top1, TH1F *top2, TH1F* top3, TH1F* top4,
910  bool logx=false, bool logy=false,
911  bool isrectangle=true, bool drawlabel=true, string label="",
912  bool drawcmeandlumi=false)
913 {
914  // define Canvas
915  float height=600 ;
916  float width ;
917  if(isrectangle)
918  width=800 ;
919  else
920  width=600 ;
921  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
922 
923  // set attributs of histograms
924  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
925  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
926  SetHistAttributes(top3, 1, 2, 4, 1001, 4) ;
927  SetHistAttributes(top4, 1, 2, 5, 1001, 5) ;
928 
929  // define stack
930  THStack *stack=new THStack("stack","") ;
931  stack->Add(top1) ;
932  stack->Add(top2) ;
933  stack->Add(top3) ;
934  stack->Add(top4) ;
935  // Define pads
936  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
937  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
938 
939  outpad->SetFillStyle(4000) ;//transparent
940  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
941  pad1->Draw() ;
942  outpad->Draw() ;
943 
944  outpad->cd() ;
945  // Draw ATLAS Label
946  if(drawlabel)
947  DrawLabels(0.65, 0.65, label.c_str(), true) ;
948  // draw center of mass energy and integrated luminosity
949  if(drawcmeandlumi)
950  DrawCMEAndLumi(0.65, 0.6, "XX", "13 TeV") ;
951 
952  pad1->cd() ;
953  // draw stack
954  stack->Draw("HIST") ;
955  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
956  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
958  gPad->Modified() ;
959 
960  // draw legend
961  TLegend *leg=new TLegend(0.65,0.7,0.89,0.89) ;
962  leg->SetBorderSize(0) ;
963  leg->AddEntry(top1, top1->GetTitle(), "F") ;
964  leg->AddEntry(top2, top2->GetTitle(), "F") ;
965  leg->AddEntry(top3, top3->GetTitle(), "F") ;
966  leg->AddEntry(top4, top4->GetTitle(), "F") ;
967  // draw legend
968  leg->Draw("same") ;
969 
970  c->Update() ;
971  c->Print((canvasname+".eps").c_str()) ;
972 
973  return 0;
974 }
975 
976 int DrawTwoHistsinStackAndOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *hist,
977  bool logx=false, bool logy=false,
978  bool isrectangle=true, bool drawlabel=true, string label="",
979  bool drawcmeandlumi=false)
980 {
981  // define Canvas
982  float height=600 ;
983  float width ;
984  if(isrectangle)
985  width=800 ;
986  else
987  width=600 ;
988  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
989 
990  // set attributs of histograms
991  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
992  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
993  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1, 1) ;
994 
995  // define stack
996  THStack *stack=new THStack("stack","") ;
997  stack->Add(top1) ;
998  stack->Add(top2) ;
999  // Define pads
1000  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1001  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
1002 
1003  outpad->SetFillStyle(4000) ;//transparent
1004  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
1005  pad1->Draw() ;
1006  outpad->Draw() ;
1007 
1008  outpad->cd() ;
1009  // Draw ATLAS Label
1010  if(drawlabel)
1011  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1012  // draw center of mass energy and integrated luminosity
1013  if(drawcmeandlumi)
1014  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1015 
1016  pad1->cd() ;
1017  // draw stack
1018  stack->Draw("HIST") ;
1019  hist->Draw("PESAME") ;
1020 
1021  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1022  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1024  // draw legend
1025  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1026  //leg->SetTextSize(0.06) ;
1027  leg->SetBorderSize(0) ;
1028  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1029  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1030  leg->AddEntry(hist, hist->GetTitle(), "APL") ;
1031  // draw legend
1032  leg->Draw("same") ;
1033 
1034  c->Update() ;
1035  c->Print((canvasname+".eps").c_str()) ;
1036 
1037  return 0;
1038 }
1039 
1040 int DrawThreeHistsinHStackAndOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F* top3, TH1F *hist,
1041  bool logx=false, bool logy=false,
1042  bool isrectangle=true, bool drawlabel=true, string label="",
1043  bool drawcmeandlumi=false)
1044 {
1045  // define Canvas
1046  float height=600 ;
1047  float width ;
1048  if(isrectangle)
1049  width=800 ;
1050  else
1051  width=600 ;
1052  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
1053 
1054  // set attributs of histograms
1055  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
1056  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
1057  SetHistAttributes(top3, 1, 2, 4, 1001, 4) ;
1058  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1, 1) ;
1059 
1060  // define stack
1061  THStack *stack=new THStack("stack","") ;
1062  stack->Add(top1) ;
1063  stack->Add(top2) ;
1064  stack->Add(top3) ;
1065  // Define pads
1066  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1067  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
1068 
1069  outpad->SetFillStyle(4000) ;//transparent
1070  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, logx, logy) ;
1071  pad1->Draw() ;
1072  outpad->Draw() ;
1073 
1074  outpad->cd() ;
1075  // Draw ATLAS Label
1076  if(drawlabel)
1077  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1078  // draw center of mass energy and integrated luminosity
1079  if(drawcmeandlumi)
1080  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1081 
1082  pad1->cd() ;
1083  // draw stack
1084  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1085  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1087  stack->Draw("HIST") ;
1088  hist->Draw("PESAME") ;
1089 
1090  // draw legend
1091  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1092  leg->SetBorderSize(0) ;
1093  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1094  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1095  leg->AddEntry(top3, top3->GetTitle(), "F") ;
1096  leg->AddEntry(hist, hist->GetTitle(), "APL") ;
1097  // draw legend
1098  leg->Draw("same") ;
1099 
1100  c->Update() ;
1101  c->Print((canvasname+".eps").c_str()) ;
1102 
1103  return 0;
1104 }
1105 
1107  TH1F *top1, TH1F *top2, TH1F* top3, TH1F *top4, TH1F *hist,
1108  bool logx=false, bool logy=false,
1109  bool isrectangle=true, bool drawlabel=true, string label="",
1110  bool drawcmeandlumi=false)
1111 {
1112  // define Canvas
1113  float height=600 ;
1114  float width ;
1115  if(isrectangle)
1116  width=800 ;
1117  else
1118  width=600 ;
1119  TCanvas *c = new TCanvas(canvasname.c_str(), "", width, height) ;
1120 
1121  // set attributs of histograms
1122  SetHistAttributes(top1, 1, 2, 2, 1001, 2) ;
1123  SetHistAttributes(top2, 1, 2, 3, 1001, 3) ;
1124  SetHistAttributes(top3, 1, 2, 4, 1001, 4) ;
1125  SetHistAttributes(top4, 1, 2, 5, 1001, 5) ;
1126  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1, 1) ;
1127 
1128  // define stack
1129  THStack *stack=new THStack("stack","") ;
1130  stack->Add(top1) ;
1131  stack->Add(top2) ;
1132  stack->Add(top3) ;
1133  stack->Add(top4) ;
1134  // Define pads
1135  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1136  TPad *pad1 = new TPad("pad1","pad1",0,0,1,1) ;// For main histo
1137 
1138  outpad->SetFillStyle(4000) ;//transparent
1139  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.1, 0.1, logx, logy) ;
1140  pad1->Draw() ;
1141  outpad->Draw() ;
1142 
1143  outpad->cd() ;
1144  // Draw ATLAS Label
1145  if(drawlabel)
1146  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1147  // draw center of mass energy and integrated luminosity
1148  if(drawcmeandlumi)
1149  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1150 
1151  pad1->cd() ;
1152  // draw stack
1153  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1154  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1156  stack->Draw("HIST") ;
1157  hist->Draw("PESAME") ;
1158 
1159  // draw legend
1160  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1161  leg->SetBorderSize(0) ;
1162  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1163  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1164  leg->AddEntry(top3, top3->GetTitle(), "F") ;
1165  leg->AddEntry(top4, top4->GetTitle(), "F") ;
1166  leg->AddEntry(hist, hist->GetTitle(), "F") ;
1167  // draw legend
1168  leg->Draw("same") ;
1169 
1170  c->Update() ;
1171  c->Print((canvasname+".eps").c_str()) ;
1172 
1173  return 0;
1174 }
1175 
1177  TH1F *top1, TH1F *top2, TH1F *hist, TH1F*bottom,
1178  bool logx=false, bool toplogy=false, bool bottomlogy=false,
1179  bool drawlabel=true, string label="",
1180  bool drawcmeandlumi=false)
1181 {
1182  // define Canvas
1183  TCanvas *c = new TCanvas(canvasname.c_str(), "", 800, 800) ;
1184 
1185  // set attributs of histograms
1186  SetHistAttributes(top1, 1, 2, 2, 1001, 2, 21, 2) ;
1187  SetHistAttributes(top2, 1, 2, 3, 1001, 3, 21, 3) ;
1188  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1) ;
1189  SetHistAttributes(bottom, 1, 2, 1, 1001, 1, 20, 1, 1, 0.1, 0.5, 0.1, 0.1, 0.5, 0.1) ;
1190 
1191  // define stack
1192  THStack *stack=new THStack("stack","") ;
1193  stack->Add(top1) ;
1194  stack->Add(top2) ;
1195  // Define pads
1196  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1197  TPad *pad1 = new TPad("pad1","pad1",0,0.33,1,1) ;// For main histo
1198  TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.33) ;// For main histo
1199 
1200  outpad->SetFillStyle(4000) ;//transparent
1201  SetPadAttributes(pad1, 0, 0, 0.1, 0.1, 0.00001, 0.1, 0, logx, toplogy) ;
1202  SetPadAttributes(pad2, 0, 0, 0.1, 0.1, 0.3, 0.00001, 0, logx, bottomlogy) ;
1203  pad1->Draw() ;
1204  pad2->Draw() ;
1205  outpad->Draw() ;
1206 
1207  outpad->cd() ;
1208  // Draw ATLAS Label
1209  if(drawlabel)
1210  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1211  // draw center of mass energy and integrated luminosity
1212  if(drawcmeandlumi)
1213  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1214 
1215  pad1->cd() ;
1216  // draw stack
1217  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1218  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1220  stack->Draw("HIST") ;
1221  hist->Draw("PESAME") ;
1222 
1223  // draw legend
1224  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1225  leg->SetBorderSize(0) ;
1226  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1227  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1228  // draw legend
1229  leg->Draw("same") ;
1230  // draw bottom pad
1231  pad2->cd() ;
1232  bottom->Draw("PE") ;
1233 
1234  c->Update() ;
1235  c->Print((canvasname+".eps").c_str()) ;
1236 
1237  return 0;
1238 }
1239 
1241  TH1F *top1, TH1F *top2, TH1F* top3, TH1F *hist, TH1F *bottom,
1242  bool logx=false, bool toplogy=false, bool bottomlogy=false,
1243  bool drawlabel=true, string label="",
1244  bool drawcmeandlumi=false)
1245 {
1246  // define Canvas
1247  TCanvas *c = new TCanvas(canvasname.c_str(), "", 800, 800) ;
1248 
1249  // set attributs of histograms
1250  SetHistAttributes(top1, 1, 2, 2, 1001, 2, 21, 2) ;
1251  SetHistAttributes(top2, 1, 2, 3, 1001, 3, 21, 3) ;
1252  SetHistAttributes(top3, 1, 2, 4, 1001, 4, 21, 4) ;
1253  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1) ;
1254  SetHistAttributes(bottom, 1, 2, 1, 1001, 1, 20, 1, 1, 0.1, 0.5, 0.1, 0.1, 0.5, 0.1) ;
1255 
1256  // define stack
1257  THStack *stack=new THStack("stack","") ;
1258  stack->Add(top1) ;
1259  stack->Add(top2) ;
1260  stack->Add(top3) ;
1261  // Define pads
1262  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1263  TPad *pad1 = new TPad("pad1","pad1",0,0.33,1,1) ;// For main histo
1264  TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.33) ;// For main histo
1265 
1266  outpad->SetFillStyle(4000) ;//transparent
1267  SetPadAttributes(pad1, 0,0, 0.1, 0.1, 0.00001, 0.1, 0, logx, toplogy) ;
1268  SetPadAttributes(pad2, 0,0, 0.1, 0.1, 0.3, 0.00001, 0, logx, bottomlogy) ;
1269  pad1->Draw() ;
1270  pad2->Draw() ;
1271  outpad->Draw() ;
1272 
1273  outpad->cd() ;
1274  // Draw ATLAS Label
1275  if(drawlabel)
1276  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1277  // draw center of mass energy and integrated luminosity
1278  if(drawcmeandlumi)
1279  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1280 
1281  pad1->cd() ;
1282  // draw stack
1283  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1284  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1286  stack->Draw("HIST") ;
1287  hist->Draw("PESAME") ;
1288 
1289  // draw legend
1290  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1291  leg->SetBorderSize(0) ;
1292  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1293  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1294  // draw legend
1295  leg->Draw("same") ;
1296  // draw bottom pad
1297  pad2->cd() ;
1298  bottom->Draw("PE") ;
1299 
1300  c->Update() ;
1301  c->Print((canvasname+".eps").c_str()) ;
1302 
1303  return 0;
1304 }
1305 
1307  TH1F *top1, TH1F *top2, TH1F* top3, TH1F* top4, TH1F *hist,TH1F* bottom,
1308  bool logx=false, bool toplogy=false, bool bottomlogy=false,
1309  bool drawlabel=true, string label="",
1310  bool drawcmeandlumi=false)
1311 {
1312  // define Canvas
1313  TCanvas *c = new TCanvas(canvasname.c_str(), "", 800, 800) ;
1314 
1315  // set attributs of histograms
1316  SetHistAttributes(top1, 1, 2, 2, 1001, 2, 21, 2) ;
1317  SetHistAttributes(top2, 1, 2, 3, 1001, 3, 21, 3) ;
1318  SetHistAttributes(top3, 1, 2, 4, 1001, 4, 21, 4) ;
1319  SetHistAttributes(top4, 1, 2, 5, 1001, 5, 21, 5) ;
1320  SetHistAttributes(hist, 1, 2, 1, 1001, 1, 20, 1) ;
1321  SetHistAttributes(bottom, 1, 2, 1, 1001, 1, 20, 1, 1, 0.1, 0.5, 0.1, 0.1, 0.5, 0.1) ;
1322 
1323  // define stack
1324  THStack *stack=new THStack("stack","") ;
1325  stack->Add(top1) ;
1326  stack->Add(top2) ;
1327  stack->Add(top3) ;
1328  stack->Add(top4) ;
1329  // Define pads
1330  TPad *outpad = new TPad("extpad","extpad",0,0,1,1) ;// For marking outermost dimensions
1331  TPad *pad1 = new TPad("pad1","pad1",0,0.33,1,1) ;// For main histo
1332  TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.33) ;// For main histo
1333 
1334  outpad->SetFillStyle(4000) ;//transparent
1335  SetPadAttributes(pad1, 0,0, 0.1, 0.1, 0.00001, 0.1, 0, logx, toplogy) ;
1336  SetPadAttributes(pad2, 0,0, 0.1, 0.1, 0.3, 0.00001, 0, logx, bottomlogy) ;
1337  pad1->Draw() ;
1338  pad2->Draw() ;
1339  outpad->Draw() ;
1340 
1341  outpad->cd() ;
1342  // Draw ATLAS Label
1343  if(drawlabel)
1344  DrawLabels(0.5, 0.85, label.c_str(), true) ;
1345  // draw center of mass energy and integrated luminosity
1346  if(drawcmeandlumi)
1347  DrawCMEAndLumi(0.5, 0.8, "XX", "13 TeV") ;
1348 
1349  pad1->cd() ;
1350  // draw stack
1351  stack->GetXaxis()->SetTitle(top1->GetXaxis()->GetTitle()) ;
1352  stack->GetYaxis()->SetTitle(top1->GetYaxis()->GetTitle()) ;
1353  stack->Draw("HIST") ;
1354  hist->Draw("PESAME") ;
1355 
1356  // draw legend
1357  TLegend *leg=new TLegend(0.5,0.55,0.89,0.65) ;
1358  leg->SetBorderSize(0) ;
1359  leg->AddEntry(top1, top1->GetTitle(), "F") ;
1360  leg->AddEntry(top2, top2->GetTitle(), "F") ;
1361  // draw legend
1362  leg->Draw("same") ;
1363  // draw bottom pad
1364  pad2->cd() ;
1365  bottom->Draw("PE") ;
1366 
1367  c->Update() ;
1368  c->Print((canvasname+".eps").c_str()) ;
1369 
1370  return 0;
1371 }
1372 
1373 //-----------------------------------------------------
1374 int DrawLabels(float xstart, float ystart, string label="", bool isbold=true)
1375 {
1376  TLatex m_latex;
1377  m_latex.SetTextSize(0.04) ;
1378  m_latex.SetTextColor(kBlack) ;
1379  m_latex.SetTextFont(42) ;
1380  if(isbold) m_latex.SetTextFont(22) ;
1381  m_latex.DrawLatex(xstart, ystart, label.c_str()) ;
1382  return 0 ;
1383 }
1384 #ifndef DrawATLASLabels_Func
1385 #define DrawATLASLabels_Func
1387 int DrawATLASLabels(float xstart, float ystart, int labeltype)
1388 {
1389  // (xstart, ystart) the starting coordinate of the latex
1390  // define tlatex
1391  TLatex m_latex;
1392  //m_latex.SetFillStyle(0) ;
1393  m_latex.SetTextSize(0.04) ;
1394  m_latex.SetTextColor(kBlack) ;
1395  m_latex.SetTextFont(72) ;
1396  // Draw ATLAS lebel
1397  m_latex.DrawLatex(xstart, ystart, "ATLAS") ;
1398 
1399  m_latex.SetTextFont(42) ;
1400  float spacing = 0.13 ;
1401  switch(labeltype)
1402  {
1403  case 0:
1404  break ;
1405  case 1:
1406  m_latex.DrawLatex(xstart+spacing, ystart, "Preliminary") ;
1407  break ;
1408  case 2:
1409  m_latex.DrawLatex(xstart+spacing, ystart, "Internal") ;
1410  break ;
1411  case 3:
1412  m_latex.DrawLatex(xstart+spacing, ystart, "Simulation Preliminary") ;
1413  break ;
1414  case 4:
1415  m_latex.DrawLatex(xstart+spacing, ystart, "Work in Progress") ;
1416  break ;
1417  default: break ;
1418  }
1419  return 0;
1420 }
1421 #endif
1422 int DrawCMEAndLumi(float xstart, float ystart, string lumiInFb, string CME)
1423 {
1424  // (xstart, ystart): coornidate of the leftbottom of the pavetext
1425  TPaveText *pavetext =new TPaveText() ;
1426  pavetext->SetOption("brNDC") ;
1427  pavetext->SetFillColor(0) ;
1428  pavetext->SetFillStyle(0) ;
1429  pavetext->SetBorderSize(0) ;
1430  pavetext->SetTextAlign(11) ;
1431  pavetext->SetTextFont(42) ;
1432  pavetext->SetTextSize(0.03) ;
1433  pavetext->SetTextColor(kBlack) ;
1434  pavetext->SetX1NDC(xstart-0.01) ;
1435  pavetext->SetY1NDC(ystart-0.01) ;
1436  pavetext->SetX2NDC(xstart+0.25) ;
1437  pavetext->SetY2NDC(ystart+0.05) ;
1438 
1439  pavetext->AddText(0.04, 1./8., ("#sqrt{s}="+CME+", #intLdt="+lumiInFb+"fb^{-1}").c_str()) ;
1440  pavetext->Draw() ;
1441 
1442  return 0;
1443 }
1444 
1445 // get the ratio histogram of two histrograms
1446 TH1F *GetRatioHistOfTwoHists(string name, string title, string xaxistitle, string yaxistitle, TH1F* numeratorhist, TH1F* denominatorhist)
1447 {
1448  //TH1F *ratiohist = new TH1F(name.c_str(), title.c_str(), numeratorhist->GetNbinsX(), numeratorhist->GetXaxis()->GetXbins()->GetArray()) ;
1449  TH1F *ratiohist = (TH1F*) numeratorhist->Clone() ;
1450  ratiohist->Sumw2() ;
1451  ratiohist->SetName(name.c_str()) ;
1452  ratiohist->SetTitle(title.c_str()) ;
1453  ratiohist->GetXaxis()->SetTitle(xaxistitle.c_str()) ;
1454  ratiohist->GetYaxis()->SetTitle(yaxistitle.c_str()) ;
1455  //ratiohist->Divide(numeratorhist, denominatorhist, 1., 1., "B") ;
1456  ratiohist->Divide(denominatorhist) ;
1457  return ratiohist ;
1458 }
1459 
1460 // get the ratio histogram of errorbar of two histrograms
1461 TH1F *GetErrorBarRatioHistOfTwoHists(string name, string title, string xaxistitle, string yaxistitle, TH1F* numeratorhist, TH1F* denominatorhist)
1462 {
1463  //TH1F *ratiohist = (TH1F*)denominatorhist->Clone() ;
1464  TH1F *ratiohist = new TH1F(name.c_str(), title.c_str(), numeratorhist->GetNbinsX(), numeratorhist->GetXaxis()->GetXbins()->GetArray()) ;
1465  ratiohist->GetYaxis()->SetTitle(yaxistitle.c_str()) ;
1466  ratiohist->GetXaxis()->SetTitle(xaxistitle.c_str()) ;
1467  //ratiohist->Divide(denominatorhist) ;
1468  for(int n=1 ; n<=ratiohist->GetNbinsX() ; n++)
1469  {
1470  if(denominatorhist->GetBinError(n)==0)
1471  ratiohist->SetBinContent(n, 0.) ;
1472  else
1473  {
1474  float over = numeratorhist->GetBinError(n)/denominatorhist->GetBinError(n) ;
1475  ratiohist->SetBinContent(n, over) ;
1476  }
1477  }
1478  return ratiohist ;
1479 }
1480 
1482 {
1483  return hist1->GetMaximum()>hist2->GetMaximum() ;
1484 }
1485 bool sort_by_vechistmax(std::pair<TH1F*, bool> p1, std::pair<TH1F*, bool> p2)
1486 {
1487  return p1.first->GetMaximum()>p2.first->GetMaximum() ; ;
1488 }
DrawThreeHistsinHStackAndOneHistOnCanvas
int DrawThreeHistsinHStackAndOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *hist, bool logx=false, bool logy=false, bool isrectangle=true, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:1040
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
04Plot.stack
list stack
Definition: 04Plot.py:10
checkFileSG.line
line
Definition: checkFileSG.py:75
DrawTwelveHistsOnCanvas
int DrawTwelveHistsOnCanvas(string canvasname, TH1F *hist1, TH1F *hist2, TH1F *hist3, TH1F *hist4, TH1F *hist5, TH1F *hist6, TH1F *hist7, TH1F *hist8, TH1F *hist9, TH1F *hist10, TH1F *hist11, TH1F *hist12, string drawopt1="PE", string drawopt2="PESame", string drawopt3="PESame", string drawopt4="PESame", string drawopt5="PESame", string drawopt6="PESame", string drawopt7="PESame", string drawopt8="PESame", string drawopt9="PESame", string drawopt10="PESame", string drawopt11="PESame", string drawopt12="PESame", bool logx=false, bool logy=true, bool isrectangle=true)
Definition: HistToolKit.h:582
TH1F::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:326
header
Definition: hcg.cxx:526
DrawTopFiveHistsAndBottomFourHistsOnCanvas
int DrawTopFiveHistsAndBottomFourHistsOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *top4, TH1F *top5, TH1F *bottom1, TH1F *bottom2, TH1F *bottom3, TH1F *bottom4, string topdrawopt1="PE", string topdrawopt2="PESAME", string topdrawopt3="PE", string topdrawopt4="PESAME", string topdrawopt5="PESAME", string bottomdrawopt1="PE", string bottomdrawopt2="PESame", string bottomdrawopt3="PESame", string bottomdrawopt4="PESame", bool logx=false, bool toplogy=true, bool bottomlogy=false, bool isrectangle=false, string header="", string label="")
Definition: HistToolKit.h:492
sort_by_histmax
bool sort_by_histmax(TH1F *hist1, TH1F *hist2)
Definition: HistToolKit.h:1481
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TH1I
Definition: rootspy.cxx:332
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
plotmaker.hist
hist
Definition: plotmaker.py:148
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
bookTH1I
TH1I * bookTH1I(const std::string &name, const std::string &title, const std::string &xlabel, const std::string &ylabel, int xbins, double xlow, double xhigh, bool sumw2=true)
Definition: HistToolKit.h:65
DrawLabels
int DrawLabels(float xstart, float ystart, string label, bool isbold=true)
Definition: HistToolKit.h:1374
bin
Definition: BinsDiffFromStripMedian.h:43
DrawTwoHistsinHStackOnCanvas
int DrawTwoHistsinHStackOnCanvas(string canvasname, TH1F *top1, TH1F *top2, bool logx=false, bool logy=false, bool drawlabel=true, string label="", bool drawcmeandlumi=false, bool isrectangle=true)
Definition: HistToolKit.h:782
DrawThreeHistsOnCanvas
int DrawThreeHistsOnCanvas(string canvasname, TH1F *hist1, TH1F *hist2, TH1F *hist3, string drawopt1="PE", string drawopt2="PESame", string drawopt3="PESame", bool logx=false, bool logy=true, bool isrectangle=true, string header="", string label="")
Definition: HistToolKit.h:268
DrawFourHistsinHStackOnCanvas
int DrawFourHistsinHStackOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *top4, bool logx=false, bool logy=false, bool isrectangle=true, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:908
DrawTopTwoHistsAndBottomOneHistOnCanvas
int DrawTopTwoHistsAndBottomOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *bottom1, string topdrawopt1="HIST", string topdrawopt2="PESAME", string bottomdrawopt="PE", bool logx=false, bool toplogy=true, bool bottomlogy=false)
Definition: HistToolKit.h:659
DrawTwoHistsOnCanvas
int DrawTwoHistsOnCanvas(string canvasname, TH1F *hist1, TH1F *hist2, string drawoption1="HIST", string drawoption2="HISTSame", bool logx=false, bool logy=true, bool isrectangle=true)
Definition: HistToolKit.h:217
GetRatioHistOfTwoHists
TH1F * GetRatioHistOfTwoHists(string name, string title, string xaxistitle, string yaxistitle, TH1F *numeratorhist, TH1F *denominatorhist)
Definition: HistToolKit.h:1446
logy
bool logy
Definition: listroot.cxx:45
GetErrorBarRatioHistOfTwoHists
TH1F * GetErrorBarRatioHistOfTwoHists(string name, string title, string xaxistitle, string yaxistitle, TH1F *numeratorhist, TH1F *denominatorhist)
Definition: HistToolKit.h:1461
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
DrawATLASLabels
int DrawATLASLabels(float xstart, float ystart, int labelstyle)
Definition: HistToolKit.h:1387
lumiFormat.i
int i
Definition: lumiFormat.py:92
DrawCMEAndLumi
int DrawCMEAndLumi(float xstart, float ystart, string lumiInFb, string CME)
Definition: HistToolKit.h:1422
beamspotman.n
n
Definition: beamspotman.py:731
covarianceTool.title
title
Definition: covarianceTool.py:542
DrawFiveHistsOnCanvas
int DrawFiveHistsOnCanvas(string canvasname, TH1F *hist1, TH1F *hist2, TH1F *hist3, TH1F *hist4, TH1F *hist5, string drawopt1="PE", string drawopt2="PESame", string drawopt3="PESame", string drawopt4="PESame", string drawopt5="PESame", bool logx=false, bool logy=true, bool isrectangle=true, string header="", string label="")
Definition: HistToolKit.h:414
SetPadAttributes
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)
Definition: SetAttributes.h:143
bookTH1F
TH1F * bookTH1F(const std::string &name, const std::string &title, const std::string &xlabel, const std::string &ylabel, int xbins, double xlow, double xhigh, bool sumw2=true, bool overflow=true)
Definition: HistToolKit.h:27
compute_lumi.leg
leg
Definition: compute_lumi.py:95
TH1F::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:327
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
DrawFourHistsOnCanvas
int DrawFourHistsOnCanvas(string canvasname, TH1F *hist1, TH1F *hist2, TH1F *hist3, TH1F *hist4, string drawopt1="PE", string drawopt2="PESame", string drawopt3="PESame", string drawopt4="PESame", bool logx=false, bool logy=true, bool isrectangle=false, string header="", string label="")
Definition: HistToolKit.h:339
CompareRootFiles.hist1
hist1
Definition: CompareRootFiles.py:36
DrawTopTwoHistsAndBottomTwoHistsOnCanvas
int DrawTopTwoHistsAndBottomTwoHistsOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *bottom1, TH1F *bottom2, bool TFirstDrawHistorNot=true, bool TSecondDrawHistorNot=false, bool DFirstDrawHistorNot=true, bool BSecondDrawHistorNot=false, bool logx=false, bool toplogy=true, bool bottomlogy=false)
Definition: HistToolKit.h:723
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
getDataLikeHist
TH1F * getDataLikeHist(TH1F *eff, TH1F *scaled, string name, int jobSeed=10)
Definition: HistToolKit.h:98
DrawTopFourHistsinHStacksAndOneHistBottomOneHistOnCanvas
int DrawTopFourHistsinHStacksAndOneHistBottomOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *top4, TH1F *hist, TH1F *bottom, bool logx=false, bool toplogy=false, bool bottomlogy=false, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:1306
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
DrawTopTwoHistsinHStackAndOneHistBottomOneHistOnCanvas
int DrawTopTwoHistsinHStackAndOneHistBottomOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *hist, TH1F *bottom, bool logx=false, bool toplogy=false, bool bottomlogy=false, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:1176
SetHistDrawOption
int SetHistDrawOption(TH1F *hist, TLegend *leg, bool DrawHistorNot=false)
Definition: HistToolKit.h:184
getEffectiveEntriesHistogram
TH1F * getEffectiveEntriesHistogram(TH1F *hist, string name="hee")
Definition: HistToolKit.h:79
DrawTopThreeHistsinHStackAndOneHistBottomOneHistOnCanvas
int DrawTopThreeHistsinHStackAndOneHistBottomOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *hist, TH1F *bottom, bool logx=false, bool toplogy=false, bool bottomlogy=false, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:1240
TH1F
Definition: rootspy.cxx:320
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
makePlot.PhysicsLists
PhysicsLists
Definition: makePlot.py:26
SetHStackAttributes
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)
Definition: SetAttributes.h:336
sort_by_vechistmax
bool sort_by_vechistmax(std::pair< TH1F *, bool > p1, std::pair< TH1F *, bool > p2)
Definition: HistToolKit.h:1485
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
GetNumberOfEvents
int GetNumberOfEvents(const std::string &filename, std::map< string, int > *channelvsbumber)
Definition: HistToolKit.h:130
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
SetHistAttributes
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)
Definition: SetAttributes.h:120
DrawSingleHistOnCanvas
int DrawSingleHistOnCanvas(string canvasname, TH1F *hist, string drawoption="PE", bool logx=false, bool logy=true, bool isrectangle=false, string label="")
Definition: HistToolKit.h:153
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
SetAttributes.h
python.compressB64.c
def c
Definition: compressB64.py:93
readCCLHist.float
float
Definition: readCCLHist.py:83
DrawThreeHistsinHStackOnCanvas
int DrawThreeHistsinHStackOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, bool logx=false, bool logy=false, bool isrectangle=true, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:844
DrawFourHistsinHStackAndOneHistOnCanvas
int DrawFourHistsinHStackAndOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *top3, TH1F *top4, TH1F *hist, bool logx=false, bool logy=false, bool isrectangle=true, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:1106
CompareRootFiles.hist2
hist2
Definition: CompareRootFiles.py:37
DrawTwoHistsinStackAndOneHistOnCanvas
int DrawTwoHistsinStackAndOneHistOnCanvas(string canvasname, TH1F *top1, TH1F *top2, TH1F *hist, bool logx=false, bool logy=false, bool isrectangle=true, bool drawlabel=true, string label="", bool drawcmeandlumi=false)
Definition: HistToolKit.h:976