]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQA.C
Update to QA macros
[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,84);
15   if( yFrom < yTo )
16     hist->GetYaxis()->SetRangeUser(yFrom, yTo);
17
18
19   //if( ! TString(options).Contains("same") )
20   TCanvas* canv = new TCanvas;
21   canv->SetGrid();
22   hist->GetYaxis()->SetNdivisions(16);
23
24   canv->Divide(1,2);
25
26   hist->GetXaxis()->SetLabelSize(0.051);
27
28   canv->cd(1);
29   hist->GetXaxis()->SetRange(1,84);
30   hist->DrawCopy(options);
31
32   canv->cd(2);
33   hist->GetXaxis()->SetRange(85,200);
34   hist->DrawCopy(options);
35
36
37   canv->SaveAs(Form("%s%s%s", prefixToName, hist->GetName(), appendToName ));
38   delete hist;
39 }
40
41 void DrawPID()
42 {
43   for(int cent=0; cent<kNCents; ++cent) {
44     TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen%d", cent))->Clone();
45     TH1* grNPhotDisp = (TH1*)file->Get(Form("grNPhotDisp_cen%d", cent))->Clone();
46     TH1* grNPhotDisp2 = (TH1*)file->Get(Form("grNPhotDisp2_cen%d", cent))->Clone();
47     TH1* grNPhotCPV = (TH1*)file->Get(Form("grNPhotCPV_cen%d", cent))->Clone();
48     TH1* grNPhotCPV2 = (TH1*)file->Get(Form("grNPhotCPV2_cen%d", cent))->Clone();
49
50     grNPhotAll->GetXaxis()->SetLabelSize(0.045);
51     grNPhotAll->GetYaxis()->SetRangeUser(0, 40);
52
53     grNPhotAll  ->SetMarkerColor(kBlack);
54     grNPhotDisp ->SetMarkerColor(kCyan+1);
55     grNPhotDisp2->SetMarkerColor(kBlue);
56     grNPhotCPV  ->SetMarkerColor(kOrange+1);
57     grNPhotCPV2 ->SetMarkerColor(kRed);
58
59     TCanvas* canv = new TCanvas;
60     canv->Divide(1,2);
61
62     canv->cd(1);
63     grNPhotAll->SetTitle("#LTN_{clusters}^{PID}#GT");
64     grNPhotAll->GetXaxis()->SetRange(0, 84);
65     grNPhotAll->DrawCopy();
66     grNPhotDisp->DrawCopy("same");
67     grNPhotDisp2->DrawCopy("same");
68     grNPhotCPV->DrawCopy("same");
69     grNPhotCPV2->DrawCopy("same");
70
71     canv->cd(2);
72     grNPhotAll->SetTitle("");
73     grNPhotAll->GetXaxis()->SetRange(85, 200);
74     grNPhotAll->DrawCopy();
75     grNPhotDisp->DrawCopy("same");
76     grNPhotDisp2->DrawCopy("same");
77     grNPhotCPV->DrawCopy("same");
78     grNPhotCPV2->DrawCopy("same");
79
80     canv->cd(1);
81     leg = new TLegend(0.9,0.7,0.99,0.99);
82     leg->SetFillColor(kWhite);
83     leg->SetBorderSize(1);
84     leg->AddEntry(Form("grNPhotAll_cen%d",cent),"All","lP");
85     leg->AddEntry(Form("grNPhotCPV_cen%d",cent),"CPV","lP");
86     leg->AddEntry(Form("grNPhotCPV2_cen%d",cent),"CPV2","lP");
87     leg->AddEntry(Form("grNPhotDisp_cen%d",cent),"Disp","lP");
88     leg->AddEntry(Form("grNPhotDisp2_cen%d",cent),"Disp2","lP");
89     leg->Draw();
90   
91     canv->SaveAs(Form("%s%s%s", prefixToName, Form("nPhotPID_cen%d", cent), appendToName ));
92   }
93 }
94
95 void DrawCPVRatio()
96 {
97   for(int cent=0; cent<kNCents; ++cent) {
98     TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen0", cent))->Clone();
99     TH1* grNPhotCPV = (TH1*)file->Get(Form("grNPhotCPV_cen0", cent))->Clone();
100     TH1* grNPhotCPV2 = (TH1*)file->Get(Form("grNPhotCPV2_cen0", cent))->Clone();
101
102     grNPhotCPV->Divide(grNPhotAll);
103     grNPhotCPV->SetTitle(Form("%s / %s", grNPhotCPV->GetTitle(), grNPhotAll->GetTitle()));
104     grNPhotCPV->GetYaxis()->SetRangeUser(0.7,0.85);
105
106     grNPhotCPV2->Divide(grNPhotAll);
107
108     TCanvas* canv = new TCanvas;
109     canv->Divide(1,2);
110     canv->cd(1);
111     grNPhotCPV->GetXaxis()->SetRange(0, 84);
112     grNPhotCPV->DrawCopy();
113
114     canv->cd(2);
115     grNPhotCPV->SetTitle("");
116     grNPhotCPV->GetXaxis()->SetRange(85, 200);
117     grNPhotCPV->DrawCopy();
118   
119     canv->SaveAs(Form("%s%s%s", prefixToName, Form("CPVtoAllRatio_cen%d", cent), appendToName ));
120   }
121 }
122
123 void DrawNPhotAllAndHigh()
124 {
125   for(int cent=0; cent<kNCents; ++cent) {
126     TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen0", cent))->Clone();
127     TH1* grNPhotAllHigh = (TH1*)file->Get(Form("grNPhotAllHigh_cen0", cent))->Clone();
128
129     double sizeAll = grNPhotAll->Integral();
130     double sizeAllHigh = grNPhotAllHigh->Integral();
131     double scale = (sizeAll / sizeAllHigh);
132     grNPhotAllHigh->Scale(scale);
133   
134     grNPhotAllHigh->SetMarkerColor(kRed);
135     grNPhotAllHigh->SetLineColor(kRed);
136
137     TCanvas* canv = new TCanvas;
138     canv->Divide(1,2);
139   
140     canv->cd(1);
141     grNPhotAll->SetTitle("#LTN_{clusters}#GT");
142     grNPhotAll->GetXaxis()->SetRange(0, 84);
143     int min = grNPhotAll->GetMinimum(1.);
144     int max = grNPhotAll->GetMaximum() +1;
145     //grNPhotAll->GetYaxis()->SetRangeUser( min, max);
146     grNPhotAll->DrawCopy();
147     grNPhotAllHigh->DrawCopy("same");
148
149     canv->cd(2);
150     grNPhotAll->GetXaxis()->SetRange(85, 200);
151     grNPhotAll->DrawCopy();
152     grNPhotAllHigh->DrawCopy("same");
153
154     canv->cd(1);
155     leg = new TLegend(0.8,0.8,0.99,0.99);
156     leg->SetFillColor(kWhite);
157     leg->SetBorderSize(1);
158     leg->AddEntry(grNPhotAll, Form("All"),"lP");
159     leg->AddEntry(grNPhotAllHigh, Form("High * %f", scale),"lP");
160     leg->Draw();
161
162     canv->SaveAs( Form("%s%s%s", prefixToName, Form("nPhotAllAndHigh_cen%d", cent), appendToName ));
163   }
164 }
165
166 void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append)
167 {
168   int kNColors = 8;
169   const Int_t colors[8] = {kBlack, kRed-1, kRed+1, kBlue, kCyan, kGreen+3, kYellow+1, kMagenta};
170   int currentColorID = 99999;
171   Int_t color;
172   
173   for(int cent=0; cent<kNCents; ++cent) {
174     TH1* hAll = (TH1*)file->Get( Form("grNPhot%s%s_cen%d", pidNames[0], append, cent) )->Clone();
175
176     leg = new TLegend(0.91,0.6,0.99,0.99);
177     leg->SetFillColor(kWhite);
178     leg->SetBorderSize(1);
179
180     TCanvas* canv = new TCanvas;
181     canv->Divide(1,2);
182     char* same = "";
183     for(int ipid = 1; ipid < nPids; ++ipid) {
184       TString name(Form("grNPhot%s%s_cen%d", pidNames[ipid], append, cent));
185       TH1* hPID = (TH1*)file->Get( name.Data() )->Clone();
186       hPID->Divide(hAll);
187
188       if( ++currentColorID < kNColors )
189         color = colors[currentColorID] ;
190       else
191         color = colors[ currentColorID = 0 ]; 
192
193       hPID->SetMarkerColor(color);
194       hPID->SetLineColor(color);
195       hPID->GetYaxis()->SetRangeUser(0, 1.);
196
197       leg->AddEntry( hPID , pidNames[ipid], "lP");
198
199       canv->cd(1);
200       hPID->SetTitle( Form("#LTN_{clusters}^{PID}#GT, cent=%d, %s", cent, append) );
201       hPID->GetXaxis()->SetRange(0, 84);
202       hPID->DrawCopy(same);
203
204       canv->cd(2);
205       hPID->SetTitle("");
206       hPID->GetXaxis()->SetRange(85, 200);
207       hPID->DrawCopy(same);      
208
209       same = "same";
210     }
211     canv->cd(1);
212     leg->Draw();
213     canv->SaveAs(Form("%s%s%s", prefixToName, Form("CPVtoAllRatio_cen%d", cent), appendToName ));
214   }
215 }
216
217 void DrawPIDRatios()
218 {
219   const int nn = 8;
220   const int nc = 4;
221   const char* kPIDNames[nn] = {"All", "Allwou", "CPV", "CPV2", "Disp", "Disp2", "Dispwou", "Both"};
222   const char* kPIDNamesCore[nc] = {"Allcore", "CPVcore", "Dispcore", "Bothcore"};
223   const char* fillHigh[2] = {"", "High"};
224   for(int ihigh = 0; ihigh < 1; ++ihigh) {
225     DrawPIDRatiosHighCore(kPIDNames, nn, fillHigh[ihigh]);
226     //DrawPIDRatiosHighCore(kPIDNamesCore, nc, fillHigh[ihigh]);
227   }
228 }
229
230 void DrawQA()
231 {
232   gStyle->SetOptStat(0);
233
234   file = TFile::Open("runQA.root", "read");
235
236   // Draw("grVtxZ10Cent", "", 0.7, 1.);
237   // Draw("grNCellsM1", "E");
238   // Draw("grNCellsM2");
239   // Draw("grNCellsM3");
240   // Draw("grECluster", "", 0.5, 0.7);
241   // Draw("grNCluster", "", 0, 40);
242   // Draw("grNTracks0", "", 0 , 12000);
243   // Draw("grNPhotAll_cen0", "", 0, 40);
244   // Draw("grNPhotAllcore_cen0", "", 0, 40);
245   // Draw("grNPhotAllwou_cen0", "", 0, 40);
246   // Draw("grNPhotDisp_cen0", "", 0, 40);
247   // Draw("grNPhotDisp2_cen0", "", 0, 40);
248   // Draw("grNPhotDispwou_cen0", "", 0, 40);
249   // Draw("grNPhotCPV_cen0", "", 0, 40);
250   // Draw("grNPhotCPV2_cen0", "", 0, 40);
251   // Draw("grNPhotBoth_cen0", "", 0, 40);
252   // Draw("grEnAll_cen0", "", 0.4, 0.7);
253   // Draw("grEnAllcore_cen0", "", 0.4, 0.7);
254   // Draw("grEnAllwou_cen0", "", 0.4, 0.7);
255   // Draw("grEnDisp_cen0", "", 0.4, 0.7);
256   // Draw("grEnDisp2_cen0", "", 0.4, 0.7);
257   // Draw("grEnDispcore_cen0", "", 0.4, 0.7);
258   // Draw("grEnDispwou_cen0", "", 0.4, 0.7);
259   // Draw("grEnCPV_cen0", "", 0.4, 0.7);
260   // Draw("grEnCPVcore_cen0", "", 0.4, 0.7);
261   // Draw("grEnCPV2_cen0", "", 0.4, 0.7);
262   // Draw("grEnBoth_cen0", "", 0.4, 0.7);
263   // Draw("grEnBothcore_cen0", "", 0.4, 0.7);
264
265
266   // DrawPID();
267   // DrawCPVRatio();
268   DrawNPhotAllAndHigh();
269   DrawPIDRatios();
270
271   file->Close();
272 }