AliPhysics  b76e98e (b76e98e)
ClusterExpectations.C
Go to the documentation of this file.
1 
11 #ifndef __CINT__
12 # include "AliTrackletAODUtils.C"
13 # include <vector>
14 # include <TFile.h>
15 # include <TError.h>
16 # include <TCollection.h>
17 # include <TString.h>
18 # include <TH1.h>
19 # include <TH2.h>
20 # include <THStack.h>
21 # include <TClass.h>
22 # include <TBrowser.h>
23 # include <TCanvas.h>
24 # include <TLegend.h>
25 # include <TLegendEntry.h>
26 # include <TStyle.h>
27 #else
28 class TFile;
29 class TClass;
30 class TH1;
31 class TH2;
32 class TDirectory;
33 class THStack;
34 class TCollection;
35 class TBrowser;
36 class TCanvas;
37 class TVirtualPad;
38 class TLegend;
39 class TAxis;
40 #endif
41 
47 {
48 #ifndef __CINT__
50 #endif
51  void FixLabels(TAxis* axis)
52  {
53  for (Int_t i = 1; i <= axis->GetNbins(); i++) {
54  TString lbl = axis->GetBinLabel(i);
55  Int_t pdg = lbl.Atoi();
56  Color_t d1; Style_t d2;
57  U::PdgAttr(pdg, lbl, d1, d2);
58  axis->SetBinLabel(i, lbl);
59  }
60  axis->LabelsOption("v");
61  axis->SetLabelSize(0.05);
62  }
63  void Run(const char* filename="PbPb_5023_LHC15k1a1_245064_gridAOD_stk/root_archive_245064/AnalysisResults.root")
64  {
65  TFile* file = U::OpenFile(filename);
66  U::Container* top = U::GetC(file, "trackletsSums");
67  TH1* seenP = U::GetH1(top, "seenTrackPdg");
68  TH1* usedP = U::GetH1(top, "usedTrackPdg");
69  TH2* seenC = U::GetH2(top, "seenClusterPdg");
70  TH2* usedC = U::GetH2(top, "usedClusterPdg");
71 
72  THStack* stackP = new THStack("stackP","");
73  stackP->Add(seenP);
74  stackP->Add(usedP);
75 
76  TH1* ratioP = static_cast<TH1*>(seenP->Clone("ratioP"));
77  ratioP->Divide(usedP);
78 
79  TH1* seenC1 = seenC->ProjectionX("seenC1",1,1);
80  TH1* usedC1 = usedC->ProjectionX("usedC1",1,1);
81  TH1* seenC2 = seenC->ProjectionX("seenC2",2,2);
82  TH1* usedC2 = usedC->ProjectionX("usedC2",2,2);
83  seenC1->SetMarkerStyle(20); seenC1->SetMarkerColor(kGreen+1);
84  usedC1->SetMarkerStyle(24); usedC1->SetMarkerColor(kBlue+1);
85  seenC2->SetMarkerStyle(21); seenC2->SetMarkerColor(kGreen+3);
86  usedC2->SetMarkerStyle(25); usedC2->SetMarkerColor(kBlue+3);
87  TH1* ratio1 = static_cast<TH1*>(seenC1->Clone("ratio1"));
88  TH1* ratio2 = static_cast<TH1*>(seenC2->Clone("ratio2"));
89  ratio1->Divide(usedC1);
90  ratio2->Divide(usedC2);
91  FixLabels(ratio1->GetXaxis());
92  FixLabels(ratio2->GetXaxis());
93 
94  THStack* stackC = new THStack("stackC","");
95  stackC->Add(seenC1);
96  stackC->Add(usedC1);
97  stackC->Add(seenC2);
98  stackC->Add(usedC2);
99 
100  THStack* ratioC = new THStack("ratioC","");
101  ratioC->Add(ratio1);
102  ratioC->Add(ratio2);
103 
104  Double_t smin = 0.2;
105  Double_t smax = 2e11;
106  Double_t rmin = 0;
107  Double_t rmax = 3.48;
108  Int_t mode = 1; // 0: square, 1: landscape, 2: portrait
109  Int_t cw = (mode == 1 ? 1600 : mode == 2 ? 800 : 1000);
110  Int_t ch = (mode == 1 ? cw/2 : mode == 2 ? 1.5*cw : cw);
111  TCanvas* c = new TCanvas("clusterExpectations","Cluster canvas",
112  cw,ch);
113  c->SetTopMargin(0.01);
114  c->SetRightMargin(0.01);
115  c->SetBottomMargin(0.13);
116  c->Divide(2,2,0,0);
117 
118  TVirtualPad* q = c->cd(1);
119  q->SetLogy();
120  q->SetTicks();
121  q->SetGridx();
122  q->SetGridy();
123  stackP->SetMaximum(smax);
124  stackP->SetMinimum(smin);
125  stackP->Draw("nostack");
126  stackP->GetHistogram()->SetYTitle("#it{N}_{tracks}");
127 
128  TLegend* l1 = new TLegend(q->GetLeftMargin()+.5,
129  1-q->GetTopMargin()-.2,
130  1-q->GetRightMargin(),
131  1-q->GetTopMargin(),
132  "Generated tracks");
133  l1->SetBorderSize(0);
134  l1->SetFillStyle(0);
135  TLegendEntry* e = l1->AddEntry("d1", "Before suppression", "p");
136  e->SetMarkerStyle(20);
137  e = l1->AddEntry("d1", "After suppression", "p");
138  e->SetMarkerStyle(24);
139  l1->Draw();
140 
141  q = c->cd(3);
142  q->SetTicks();
143  q->SetGridx();
144  q->SetGridy();
145  ratioP->SetMinimum(rmin);
146  ratioP->SetMaximum(rmax);
147  ratioP->SetStats(0);
148  ratioP->SetTitle("");
149  ratioP->Draw();
150  ratioP->SetYTitle("Before/After");
151  FixLabels(ratioP->GetXaxis());
152 
153 
154  q = c->cd(2);
155  q->SetLogy();
156  q->SetTicks();
157  q->SetGridx();
158  q->SetGridy();
159  q->SetRightMargin(0.01);
160  stackC->SetMinimum(smin);
161  stackC->SetMaximum(smax);
162  stackC->Draw("nostack");
163  stackC->GetHistogram()->SetYTitle("#it{N}_{cluster}");
164 
165  TLegend* l2 = new TLegend(q->GetLeftMargin()+.6,
166  1-q->GetTopMargin()-.2,
167  1-q->GetRightMargin(),
168  1-q->GetTopMargin(),
169  "Associated clusters");
170  l2->SetBorderSize(0);
171  l2->SetFillStyle(0);
172  // l2->SetNColumns(2);
173  e = l2->AddEntry("d1","Layer 1", "p");
174  e->SetMarkerStyle(20);
175  e = l2->AddEntry("d1","Layer 2", "p");
176  e->SetMarkerStyle(21);
177  l2->Draw();
178 
179 
180  q = c->cd(4);
181  q->SetTicks();
182  q->SetRightMargin(0.01);
183  q->SetGridx();
184  q->SetGridy();
185  ratioC->SetMinimum(rmin);
186  ratioC->SetMaximum(rmax);
187  ratioC->Draw("nostack");
188  ratioC->GetHistogram()->SetYTitle("Before/After");
189  ratioC->GetHistogram()->GetXaxis()->LabelsOption("v");
190  ratioC->GetHistogram()->GetXaxis()->SetLabelSize(ratioP->GetXaxis()
191  ->GetLabelSize());
192  // FixLabels(ratioC->GetHistogram()->GetXaxis());
193 
194  c->Modified();
195  c->Update();
196  c->cd();
197  c->SaveAs(Form("%s.png",c->GetName()));
198 
199  TH1* eff1 = static_cast<TH1*>(seenC1->Clone("eff1"));
200  TH1* eff2 = static_cast<TH1*>(seenC2->Clone("eff2"));
201  eff1->Divide(seenP);
202  eff2->Divide(seenP);
203  FixLabels(eff1->GetXaxis());
204  FixLabels(eff2->GetXaxis());
205  THStack* eff = new THStack("eff","");
206  eff->Add(eff1);
207  eff->Add(eff2);
208  TCanvas* cc = new TCanvas("clusterEfficiency","EffCanvas",cw,ch);
209  cc->SetTopMargin(0.01);
210  cc->SetRightMargin(0.01);
211  cc->SetTicks();
212  eff->Draw("nostack");
213  eff->GetHistogram()->SetYTitle("#it{N}_{cluster}/#it{N}_{tracks}");
214  eff->GetHistogram()->GetXaxis()->LabelsOption("v");
215  eff->GetHistogram()->GetXaxis()->SetLabelSize(ratioP->GetXaxis()
216  ->GetLabelSize());
217 
218 
219  cc->Modified();
220  cc->Update();
221  cc->cd();
222  cc->SaveAs(Form("%s.png",cc->GetName()));
223  }
224 };
225 
232 {
233  if (!gROOT->GetClass("AliTrackletAODUtils")) {
234  Printf("Loading utilities");
235  gROOT->LoadMacro("$ANA_SRC/dndeta/tracklets3/AliTrackletAODUtils.C+g");
236  }
237 #if 0
238  gSystem->AddIncludePath("-DSELF_COMPILE__");
239  if (!gROOT->GetClass("ClusterCalculations")) {
240  gInterpreter->ClearFileBusy();
241  // gInterpreter->UnloadFile("YieldExpectations.C");
242  Printf("Reload self compiled");
243  gROOT->LoadMacro("$ANA_SRC/dndeta/tracklets3/YieldExpectations.C+g");
244  }
245 #endif
247  c.Run();
248 }
249 
250 
Int_t pdg
const char * filename
Definition: TestFCM.C:1
static void PdgAttr(Int_t pdg, TString &nme, Color_t &c, Style_t &s)
const Color_t cc[]
Definition: DrawKs.C:1
double Double_t
Definition: External.C:58
static TFile * OpenFile(const char *filename)
TSystem * gSystem
static TH1 * GetH1(Container *parent, const char *name, Bool_t verb=true)
void Run(const char *filename="PbPb_5023_LHC15k1a1_245064_gridAOD_stk/root_archive_245064/AnalysisResults.root")
TCanvas * c
Definition: TestFitELoss.C:172
void FixLabels(TAxis *axis)
Utilities for midrapidity analysis.
int Int_t
Definition: External.C:63
void ClusterExpectations(Double_t c1=0, Double_t c2=0)
Int_t mode
Definition: anaM.C:41
static TH2 * GetH2(Container *parent, const char *name, Bool_t verb=true)
AliTrackletAODUtils U
Definition: External.C:220
TFile * file
TList with histograms for a given trigger.
static Container * GetC(Container *parent, const char *name, Bool_t verb=true)
Definition: External.C:196