]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQA.C
cleanup
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_PbPb / macros / QA / DrawQA.C
1 #include "TCanvas.h" // needed for some reason.
2
3 TFile* file;
4 const char* prefixToName = "imgs/";
5 const int kNCents = 1;
6
7 void Draw(const char* name, const char* options = "", double yFrom=0., double yTo=-1.)
8 {
9   TH1* hist = ((TH1*)file->Get(name))->Clone();
10   //hist->SetAxisRange(0, 30 );
11   hist->GetXaxis()->SetLabelSize(0.011);
12   //hist->GetXaxis()->SetTitle("Run");
13   //hist->GetXaxis()->SetRange(1, );
14   if( yFrom < yTo ) {
15     if(yFrom > hist->GetMinimum())
16       Printf("in hist %s, yFrom (%f), is larger then hist min (%f)", name, yFrom, hist->GetMinimum());
17     if(yTo < hist->GetMaximum())
18       Printf("in hist %s, yTo (%f), is smaller then hist max (%f)", name, yTo, hist->GetMaximum());
19
20     hist->GetYaxis()->SetRangeUser(yFrom, yTo);
21   }
22
23   //if( ! TString(options).Contains("same") )
24   TCanvas* canv = new TCanvas;
25   //canv->SetGrid();
26   //hist->GetYaxis()->SetNdivisions(16);
27
28   canv->Divide(1,2);
29
30   hist->GetXaxis()->SetLabelSize(0.051);
31
32   if( TString(options).Contains("LINFIT") )
33     hist->Fit("pol0", "Q");
34   
35   canv->cd(1);
36   if( TString(name).Contains("grChi2RP") )
37     gPad->SetLogy();
38   hist->GetXaxis()->SetRange(1, hist->GetNbinsX()/2);
39   hist->DrawCopy(options);
40
41   canv->cd(2);
42   if( TString(name).Contains("grChi2RP") )
43     gPad->SetLogy();
44   hist->GetXaxis()->SetRange(hist->GetNbinsX()/2+1,200);
45   hist->DrawCopy(options);
46
47
48   canv->SaveAs(Form("%s%s.pdf", prefixToName, hist->GetName()));
49   canv->SaveAs(Form("%s%s.png", prefixToName, hist->GetName()));
50   delete hist;
51 }
52
53 void DrawPID()
54 {
55   for(int cent=0; cent<kNCents; ++cent) {
56     TString key = Form("nPhotPID_cen%i", cent);
57     
58     TH1* grNPhotAllcore = (TH1*)file->Get(Form("grNPhotAllcore_cen%d", cent))->Clone();
59     TH1* grNPhotCPVcore = (TH1*)file->Get(Form("grNPhotCPVcore_cen%d", cent))->Clone();
60     TH1* grNPhotDisp2core = (TH1*)file->Get(Form("grNPhotDisp2core_cen%d", cent))->Clone();
61     TH1* grNPhotBoth2core = (TH1*)file->Get(Form("grNPhotBoth2core_cen%d", cent))->Clone();
62
63     grNPhotAllcore->GetXaxis()->SetLabelSize(0.045);
64     grNPhotAllcore->GetYaxis()->SetRangeUser(0, grNPhotAllcore->GetMaximum()*1.2);
65
66     grNPhotAllcore  ->SetMarkerColor(kBlack);
67     grNPhotCPVcore ->SetMarkerColor(kCyan+1);
68     grNPhotDisp2core->SetMarkerColor(kBlue);
69     grNPhotBoth2core  ->SetMarkerColor(kOrange+1);
70
71     TCanvas* canv = new TCanvas(key.Data(), key.Data(), 1024, 768);
72     canv->Divide(1,2);
73
74     canv->cd(1);
75     grNPhotAllcore->SetTitle("#LTN_{clusters}^{PID}#GT");
76     gPad->SetGridy();
77     grNPhotAllcore->GetXaxis()->SetRange(0, 85);
78     grNPhotAllcore->DrawCopy();
79     grNPhotCPVcore->DrawCopy("same");
80     grNPhotDisp2core->DrawCopy("same");
81     grNPhotBoth2core->DrawCopy("same");
82
83     canv->cd(2);
84     gPad->SetGridy();
85     grNPhotAllcore->SetTitle("");
86     grNPhotAllcore->GetXaxis()->SetRange(85, 200);
87     grNPhotAllcore->DrawCopy();
88     grNPhotCPVcore->DrawCopy("same");
89     grNPhotDisp2core->DrawCopy("same");
90     grNPhotBoth2core->DrawCopy("same");
91
92     canv->cd(1);
93     leg = new TLegend(0.9,0.7,0.99,0.99);
94     leg->SetFillColor(kWhite);
95     leg->SetBorderSize(1);
96     leg->AddEntry(Form("grNPhotAllcore_cen%d",cent),"All","lP");
97     leg->AddEntry(Form("grNPhotCPVcore_cen%d",cent),"CPVcore","lP");
98     leg->AddEntry(Form("grNPhotDisp2core_cen%d",cent),"Disp2core","lP");
99     leg->AddEntry(Form("grNPhotBoth2core_cen%d",cent),"Both2core","lP");
100     
101     leg->Draw();
102   
103     canv->SaveAs(Form("%s%s_squeezed.pdf", prefixToName, key.Data()));
104     canv->SaveAs(Form("%s%s_squeezed.png", prefixToName, key.Data()));
105   }
106 }
107
108 void DrawCPVRatio()
109 {
110   for(int cent=0; cent<kNCents; ++cent) {
111     TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen0", cent))->Clone();
112     TH1* grNPhotCPV = (TH1*)file->Get(Form("grNPhotCPV_cen0", cent))->Clone();
113     TH1* grNPhotCPV2 = (TH1*)file->Get(Form("grNPhotCPV2_cen0", cent))->Clone();
114
115     grNPhotCPV->Divide(grNPhotAll);
116     grNPhotCPV->SetTitle(Form("%s / %s", grNPhotCPV->GetTitle(), grNPhotAll->GetTitle()));
117     grNPhotCPV->GetYaxis()->SetRangeUser(0.7,0.85);
118
119     grNPhotCPV2->Divide(grNPhotAll);
120
121     TCanvas* canv = new TCanvas;
122     canv->Divide(1,2);
123     canv->cd(1);
124     grNPhotCPV->GetXaxis()->SetRange(0, 85);
125     grNPhotCPV->DrawCopy();
126
127     canv->cd(2);
128     grNPhotCPV->SetTitle("");
129     grNPhotCPV->GetXaxis()->SetRange(85, 200);
130     grNPhotCPV->DrawCopy();
131   
132     canv->SaveAs(Form("%sCPVtoAllRatio_cen%d.pdf", prefixToName, cent));
133     canv->SaveAs(Form("%sCPVtoAllRatio_cen%d.png", prefixToName, cent));
134   }
135 }
136
137 void DrawNPhotAllAndHigh()
138 {
139   for(int cent=0; cent<kNCents; ++cent) {
140     TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen%d", cent))->Clone();
141     TH1* grNPhotAllHigh = (TH1*)file->Get(Form("grNPhotAllHigh_cen%d", cent))->Clone();
142     TH1* grNPhotAllcoreHigh = (TH1*)file->Get(Form("grNPhotAllcoreHigh_cen%d", cent))->Clone();
143
144     double sizeAll = grNPhotAll->Integral();
145     double sizeAllHigh = grNPhotAllHigh->Integral();
146     int scale = TMath::Nint(sizeAll / sizeAllHigh);
147     grNPhotAllHigh->Scale(scale);
148     grNPhotAllcoreHigh->Scale(scale);
149   
150     grNPhotAllHigh->SetMarkerColor(kRed);
151     grNPhotAllHigh->SetLineColor(kRed);
152     grNPhotAllcoreHigh->SetMarkerColor(kGreen+1);
153     grNPhotAllcoreHigh->SetLineColor(kGreen+1);
154
155     TCanvas* canv = new TCanvas;
156     canv->Divide(1,2);
157   
158     canv->cd(1);
159     grNPhotAll->SetTitle("#LTN_{clusters}#GT");
160     grNPhotAll->GetXaxis()->SetRange(0, 85);
161     grNPhotAll->GetYaxis()->SetRange(15, 40);
162     //grNPhotAll->GetYaxis()->SetRangeUser(15, 45);
163     grNPhotAll->DrawCopy();
164     grNPhotAllHigh->DrawCopy("same");
165     grNPhotAllcoreHigh->DrawCopy("same");
166
167     canv->cd(2);
168     grNPhotAll->GetXaxis()->SetRange(85, 200);
169     grNPhotAll->DrawCopy();
170     grNPhotAllHigh->DrawCopy("same");
171     grNPhotAllcoreHigh->DrawCopy("same");
172
173     canv->cd(1);
174     leg = new TLegend(0.8, 0.15, 0.99, 0.4);
175     leg->SetFillColor(kWhite);
176     leg->SetBorderSize(1);
177     leg->AddEntry(grNPhotAll, Form("All"),"lP");
178     leg->AddEntry(grNPhotAllHigh, Form("AllHigh * %d", scale),"lP");
179     leg->AddEntry(grNPhotAllcoreHigh, Form("AllcoreHigh * %d", scale),"lP");
180     leg->Draw();
181
182     canv->SaveAs( Form("%s%s.pdf", prefixToName, Form("nPhotAllAndHigh_cen%d", cent)));
183     canv->SaveAs( Form("%s%s.png", prefixToName, Form("nPhotAllAndHigh_cen%d", cent)));
184   }
185 }
186
187 void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* high)
188 {
189   int kNColors = 8;
190   const Int_t colors[8] = {kBlack, kRed-1, kRed+1, kBlue, kCyan, kGreen+3, kYellow+1, kMagenta};
191   int currentColorID = 99999;
192   Int_t color;
193   
194   for(int cent=0; cent<kNCents; ++cent) {
195     TH1* hAll = (TH1*)file->Get( Form("grNPhot%s%s_cen%d", pidNames[0], high, cent) )->Clone();
196
197     leg = new TLegend(0.91,0.6,0.99,0.99);
198     leg->SetFillColor(kWhite);
199     leg->SetBorderSize(1);
200
201     TCanvas* canv = new TCanvas;
202     canv->Divide(1,2);
203     char* same = "";
204     for(int ipid = 1; ipid < nPids; ++ipid) {
205       TString name(Form("grNPhot%s%s_cen%d", pidNames[ipid], high, cent));
206       TH1* hPID = (TH1*)file->Get( name.Data() )->Clone();
207       hPID->Divide(hAll);
208
209       if( ++currentColorID < kNColors )
210         color = colors[currentColorID] ;
211       else
212         color = colors[ currentColorID = 0 ]; 
213
214       hPID->SetMarkerColor(color);
215       hPID->SetLineColor(color);
216       hPID->GetYaxis()->SetRangeUser(0, 1.);
217
218       leg->AddEntry( hPID , pidNames[ipid], "lP");
219
220       canv->cd(1);
221       hPID->SetTitle( Form("#LTN_{clusters}^{PID}#GT / #LTN_{clusters}^{%s}#GT, cent=%d, %s", pidNames[0], cent, high) );
222       hPID->GetXaxis()->SetRange(0, 85);
223       hPID->DrawCopy(same);
224
225       canv->cd(2);
226       hPID->SetTitle("");
227       hPID->GetXaxis()->SetRange(85, 200);
228       hPID->DrawCopy(same);      
229
230       same = "same";
231     }
232     canv->cd(1);
233     leg->Draw();
234     TString fn(Form("CPVtoAllRatio%s_cen%d", high, cent));
235
236     canv->SaveAs(Form("%s%s.pdf", prefixToName, fn.Data()));
237     canv->SaveAs(Form("%s%s.png", prefixToName, fn.Data()));
238   }
239 }
240
241 void DrawPIDRatios()
242 {
243   const int nn = 8;
244   const int nc = 4;
245   const char* kPIDNames[nn] = {"All", "Allwou", "CPV", "CPV2", "Disp", "Disp2", "Dispwou", "Both"};
246   const char* kPIDNamesCore[nc] = {"Allcore", "CPVcore", "Dispcore", "Bothcore"};
247   const char* fillHigh[2] = {"", "High"};
248   for(int ihigh = 0; ihigh < 2; ++ihigh) {
249     DrawPIDRatiosHighCore(kPIDNames, nn, fillHigh[ihigh]);
250     DrawPIDRatiosHighCore(kPIDNamesCore, nc, fillHigh[ihigh]);
251   }
252 }
253
254 void DrawQA()
255 {
256   gStyle->SetOptStat(0);
257   gStyle->SetOptFit(1);
258
259   file = TFile::Open("outputQA.root", "read");
260
261   Draw("grVtxZ10Cent", "", 0.7, 1.);
262   Draw("grNCellsM1", "E");
263   Draw("grNCellsM2");
264   Draw("grNCellsM3");
265   Draw("grECluster", "", 0.5, 0.7);
266   Draw("grNCluster", "", 0, 40);
267   Draw("grNTracks0", "", 0 , 12000);
268   Draw("grNPhotAll_cen0", "", 0, 40);
269   Draw("grNPhotAllcore_cen0", "", 0, 40);
270   Draw("grNPhotAllwou_cen0", "", 0, 40);
271   Draw("grNPhotDisp_cen0", "", 0, 40);
272   Draw("grNPhotDisp2_cen0", "", 0, 40);
273   Draw("grNPhotDispwou_cen0", "", 0, 40);
274   Draw("grNPhotCPV_cen0", "", 0, 40);
275   Draw("grNPhotCPV2_cen0", "", 0, 40);
276   Draw("grNPhotBoth_cen0", "", 0, 40);
277   Draw("grEnAll_cen0", "", 0.4, 0.7);
278   Draw("grEnAllcore_cen0", "", 0.4, 0.7);
279   Draw("grEnAllwou_cen0", "", 0.4, 0.7);
280   Draw("grEnDisp_cen0", "", 0.4, 0.7);
281   Draw("grEnDisp2_cen0", "", 0.4, 0.7);
282   Draw("grEnDispcore_cen0", "", 0.4, 0.7);
283   Draw("grEnDispwou_cen0", "", 0.4, 0.7);
284   Draw("grEnCPV_cen0", "", 0.4, 0.7);
285   Draw("grEnCPVcore_cen0", "", 0.4, 0.7);
286   Draw("grEnCPV2_cen0", "", 0.4, 0.7);
287   Draw("grEnBoth_cen0", "", 0.4, 0.7);
288   Draw("grEnBothcore_cen0", "", 0.4, 0.7);
289
290
291   DrawPID();
292   DrawCPVRatio();
293   DrawNPhotAllAndHigh();
294   DrawPIDRatios();
295
296   Draw("grMPi0", "LINFIT", 0.13, 0.15 );
297   Draw("grWPi0", "LINFIT");
298   Draw("grNPi0", "LINFIT");
299
300   Draw("grSERPV0Aflat", "", 0, 0.4);
301   Draw("grSERPV0Cflat", "", 0, 0.4);
302   Draw("grSERPTPCflat", "", 0, 0.4);
303
304   Draw("grChi2RPV0A", "", 0.1, 500);
305   Draw("grChi2RPV0C", "", 0.1, 500);
306   Draw("grChi2RPTPC", "", 0.1, 500);
307   Draw("grChi2RPV0Aflat", "", 0.1, 500);
308   Draw("grChi2RPV0Cflat", "", 0.1, 500);
309   Draw("grChi2RPTPCflat", "", 0.1, 500);
310
311   Draw("grSinRPV0A1", "", 0, 0.7);
312   Draw("grSinRPV0A2", "", 0, 10);
313   Draw("grSinRPV0A3", "", -TMath::Pi(), TMath::Pi());
314   Draw("grSinRPV0C1", "", 0, 0.7);
315   Draw("grSinRPV0C2", "", 0, 10);
316   Draw("grSinRPV0C3", "", -TMath::Pi(), TMath::Pi());
317   Draw("grSinRPTPC1", "", 0, 0.7);
318   Draw("grSinRPTPC2", "", 0, 10);
319   Draw("grSinRPTPC3", "", -TMath::Pi(), TMath::Pi());
320  
321   file->Close();
322 }