AliPhysics  8b695ca (8b695ca)
DrawDeltas2.C
Go to the documentation of this file.
1 
9 TCanvas* DrawDeltas2(const char* filename, Double_t c1=0, Double_t c2=5)
10 {
11  TFile* file = TFile::Open(filename, "READ");
12  if (!file) {
13  Warning("DrawDeltas2", "File %s couldn't be opened", filename);
14  return 0;
15  }
16 
17  TString dname; dname.Form("cent%06.2f_%06.2f", c1, c2);
18  dname.ReplaceAll(".", "d");
19  TDirectory* d = file->GetDirectory(dname);
20  if (!d) {
21  Warning("DrawDeltas2", "Directory %s not found in %s",
22  dname.Data(), file->GetName());
23  return 0;
24  }
25 
26  TDirectory* det = d->GetDirectory("details");
27  if (!det) {
28  Warning("DrawDeltas2", "Directory details not found in %s",
29  d->GetName());
30  d->ls();
31  return 0;
32  }
33 
34  TObject* o = det->Get("deltas");
35  if (!o) {
36  Warning("DrawDeltas2", "Object deltas not found in %s",
37  det->GetName());
38  return 0;
39  }
40 
41  if (!o->IsA()->InheritsFrom(THStack::Class())) {
42  Warning("DrawDeltas2", "Object %s is not a THStack, but a %s",
43  o->GetName(), o->ClassName());
44  return 0;
45  }
46  THStack* s = static_cast<THStack*>(o);
47 
48  TString t(filename);
49  t.ReplaceAll("results/", "");
50  t.ReplaceAll("combine_","");
51  t.ReplaceAll("_0x3.root", "");
52  TString nm(filename);
53  nm.ReplaceAll(".root", "_");
54  nm.ReplaceAll("results/", "plots/");
55  nm.ReplaceAll("combine", "deltas");
56  if (t.Contains("none"))
57  t.ReplaceAll("none", "No weights,");
58  else
59  t.Append(" weights,");
60  if (det->Get("scalar")) {
61  t.Append(" #it{k}(#eta),"); nm.Append("keta_");
62  }
63  else {
64  t.Append(" #it{k}#equiv1,"); nm.Append("kunit_");
65  }
66  t.Append(Form(" %5.2f - %5.2f%%", c1, c2));
67  nm.Append(dname);
68 
69  Int_t cW = 1200;
70  Int_t cH = 800;
71  TCanvas* c = new TCanvas(nm,t,cW, cH);
72  c->SetTopMargin(0.10);
73  c->SetRightMargin(0.01);
74  c->Divide(1,2,0,0);
75 
76  TLatex* tit = new TLatex(0.55, 0.99, t);
77  tit->SetTextFont(42);
78  tit->SetTextAlign(23);
79  tit->SetTextSize(0.03);
80  tit->Draw();
81 
82  TVirtualPad* p = c->cd(1);
83  p->SetRightMargin(0.01);
84  p->SetLogx();
85  p->SetLogy();
86  p->SetGridx();
87  p->SetGridy();
88  p->SetTicks();
89  s->Draw("nostack");
90 
91  TH1* h = s->GetHistogram();
92  Double_t min = h->GetMinimum();
93  Double_t max = h->GetMaximum();
94  h->SetXTitle("#Delta");
95  h->SetYTitle("Tracklets/event");
96 
97  TLine* ll = new TLine(1.5, min, 1.5, max);
98  ll->SetLineColor(kGreen+2);
99  ll->SetLineWidth(3);
100  ll->Draw();
101 
102  TLine* lh = new TLine(5, min, 5, max);
103  lh->SetLineColor(kRed+2);
104  lh->SetLineWidth(3);
105  lh->Draw();
106 
107  // TLegend* l = p->BuildLegend(.6,.75,.99,.99);
108  TLegend* l = p->BuildLegend(.11,.0,.7,.35);
109  l->SetNColumns(2);
110  Int_t n = l->GetListOfPrimitives()->GetEntries();
111  ((TNamed*)(l->GetListOfPrimitives()->At(n-2)))->SetTitle("Signal cut");
112  ((TNamed*)(l->GetListOfPrimitives()->At(n-1)))->SetTitle("Background cut");
113  // l->SetBorderSize(0);
114  // l->SetFillStyle(0);
115  p->Modified();
116  // s->GetHists()->Print();
117 
118  TH1* realMeas = static_cast<TH1*>(s->GetHists()->At(0));
119  TH1* simMeas = static_cast<TH1*>(s->GetHists()->At(1));
120  TH1* realInj = static_cast<TH1*>(s->GetHists()->At(2));
121  TH1* simInj = static_cast<TH1*>(s->GetHists()->At(3));
122  TH1* simComb = static_cast<TH1*>(s->GetHists()->At(4));
123 
124  TH1* measRat = static_cast<TH1*>(simMeas->Clone("ratioMeas"));
125  measRat->Divide(realMeas);
126  measRat->SetTitle("Sim./Real Measured");
127 
128 
129  TH1* simInjRat = static_cast<TH1*>(simInj->Clone("ratioSimInj"));
130  simInjRat->Divide(simComb);
131  simInjRat->SetDirectory(0);
132  simInjRat->SetTitle("Sim. Inj./Combinatorics");
133 
134  TH1* realInjRat = static_cast<TH1*>(realInj->Clone("ratioRealInj"));
135  realInjRat->Divide(simComb);
136  realInjRat->SetDirectory(0);
137  realInjRat->SetTitle("Real Inj./Combinatorics");
138 
139  THStack* ratios = new THStack("ratios", "");
140  ratios->Add(measRat);
141  ratios->Add(realInjRat);
142  ratios->Add(simInjRat);
143 
144  p = c->cd(2);
145  p->SetRightMargin(0.01);
146  p->SetLogx();
147  // p->SetLogy();
148  p->SetGridx();
149  p->SetGridy();
150  p->SetTicks();
151  ratios->SetMinimum(0.5);
152  ratios->SetMaximum(1.5);
153  ratios->Draw("nostack");
154  h = ratios->GetHistogram();
155  h->SetXTitle(realMeas->GetXaxis()->GetTitle());
156  h->SetYTitle("Ratio");
157 
158  l = p->BuildLegend(.11,.11,.7,.35);
159  // l->SetNColumns(2);
160 
161  p->Modified();
162  c->Modified();
163  c->Update();
164  c->cd();
165 
166  return c;
167 }
168 
169 
170 void DrawDeltas2(UShort_t flags, const char* which)
171 {
172  TCanvas* c =
173  DrawDeltas2(Form("results/combine_%s_0x%x.root", which, flags), 0, 5);
174  c->SaveAs(Form("plots/deltas_%s_0x%x.png", which, flags));
175 }
176 
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
TCanvas * DrawDeltas2(const char *filename, Double_t c1=0, Double_t c2=5)
Definition: DrawDeltas2.C:9
TCanvas * c
Definition: TestFitELoss.C:172
Int_t cH
Definition: Combine.C:26
int Int_t
Definition: External.C:63
Int_t cW
Definition: Combine.C:25
TFile * file
TList with histograms for a given trigger.
unsigned short UShort_t
Definition: External.C:28
Definition: External.C:196