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