AliPhysics  56f1704 (56f1704)
DrawEmpirical.C
Go to the documentation of this file.
1 THStack* DrawOne(TVirtualPad* p,
2  Double_t yr,
3  Bool_t top,
4  TDirectory* dir,
5  const char* name)
6 {
7  p->cd();
8  p->SetFillColor(0);
9  p->SetFillStyle(0);
10  p->SetLineColor(0);
11  p->SetRightMargin(0.01);
12  p->SetLeftMargin(0.12);
13  p->SetGridx();
14  if (top) p->SetBottomMargin(0.001);
15  else p->SetBottomMargin(0.2);
16  if (top) p->SetTopMargin(0.02);
17  else p->SetTopMargin(0.0001);
18 
19 
20  THStack* s = static_cast<THStack*>(dir->Get(name));
21  s->Draw("nostack");
22  Double_t sc = (top ? 1-yr : yr);
23  TAxis* ya = s->GetHistogram()->GetYaxis();
24  ya->SetLabelSize(1/sc*ya->GetLabelSize());
25  ya->SetTitleSize(1/sc*ya->GetTitleSize());
26  ya->SetTitleOffset(sc*(ya->GetTitleOffset()+.5));
27  ya->SetTitleFont(42);
28  ya->SetLabelFont(42);
29  TAxis* xa = s->GetHistogram()->GetXaxis();
30  xa->SetLabelSize(!top ? 1/yr*xa->GetLabelSize() : 0);
31  xa->SetTitleSize(!top ? 1/yr*xa->GetTitleSize() : 0);
32  xa->SetTitleOffset(yr*(xa->GetTitleOffset()+2));
33  xa->SetTitleFont(42);
34  xa->SetLabelFont(42);
35 
36  p->Modified();
37  p->Update();
38  p->cd();
39 
40  return s;
41 }
42 
43 void DrawEmpirical(const char* filename="Empirical.root",
44  Bool_t fmd=true)
45 {
46  gStyle->SetOptTitle(0);
47 
48  TFile* file = TFile::Open(filename, "READ");
49  if (!file) return;
50 
51  Double_t yr = 0.3;
52  TCanvas* c = new TCanvas("c","c", 1000,1000);
53  TPad* p1 = new TPad("p1","p1",0,0,1,yr);
54  TPad* p2 = new TPad("p2","p2",0,yr,1,1);
55  c->cd(); p1->Draw();
56  c->cd(); p2->Draw();
57 
58  gDirectory->cd("Forward");
59  THStack* r = DrawOne(p1, yr, false, gDirectory, "ratios");
60  THStack* e = DrawOne(p2, yr, true, gDirectory, "empirical");
61 
62  r->SetMinimum(0.945);
63  r->SetMaximum(1.055);
64  r->GetXaxis()->SetTitle("#it{#eta}");
65  r->GetYaxis()->SetTitle("Ratio to mean");
66  e->SetMinimum(0.005);
67  e->GetYaxis()->SetTitle("#it{E_{c}}(#it{#eta})");
68  TIter nextE(e->GetHists());
69  TIter nextR(r->GetHists());
70  TH1* hist = 0;
71  Color_t cols[] = { kRed+2, kGreen+2, kBlue+2, kMagenta+2, 0 };
72  Color_t *ptr = cols;
73  Style_t stys[] = { 20, 21, 22, 23 };
74  Style_t* sty = stys;
75  while (*ptr) {
76  hist = static_cast<TH1*>(nextE());
77  hist->SetMarkerColor(*ptr);
78  hist->SetMarkerSize(2);
79  hist->SetMarkerStyle(*sty);
80  hist = static_cast<TH1*>(nextR());
81  hist->SetMarkerColor(*ptr);
82  hist->SetMarkerSize(2);
83  hist->SetMarkerStyle(*sty);
84  ptr++;
85  sty++;
86  }
87 
88 
89  TLegend* l = p2->BuildLegend(0.35, .2, .65, .8);
90  l->SetFillColor(0);
91  l->SetFillStyle(0);
92  l->SetBorderSize(0);
93 
94  c->Modified();
95  c->Update();
96  c->cd();
97  c->Print("empirical.png");
98 
99 }
100 
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
void DrawEmpirical(const char *filename="Empirical.root", Bool_t fmd=true)
Definition: DrawEmpirical.C:43
THStack * DrawOne(TVirtualPad *p, Double_t yr, Bool_t top, TDirectory *dir, const char *name)
Definition: DrawEmpirical.C:1
TCanvas * c
Definition: TestFitELoss.C:172
TFile * file
TList with histograms for a given trigger.
bool Bool_t
Definition: External.C:53
Definition: External.C:196
TDirectoryFile * dir