]>
Commit | Line | Data |
---|---|---|
0740807a | 1 | // $Id$ |
2 | /* | |
3 | * Plotting macro for comparing offline- and HLT- ESD trees from | |
4 | * HLT-OFFLINE-GLOBAL-comparison.root produced using $ALICE_ROOT/HLT/QA/tasks/AliAnalysisTaskHLT.* | |
5 | * | |
6 | * Usage: aliroot drawGlobalESDHistograms.C'("HLT-OFFLINE-GLOBAL-comparison.root")' | |
7 | * | |
25ccfa3d | 8 | * or aliroot drawGlobalESDHistograms.C++ in compiled mode |
9 | * | |
3b149e33 | 10 | * It saves the canvas with the output histograms in a png and a ROOT file. |
0740807a | 11 | * |
12 | * @ingroup alihlt_qa | |
13 | * @author Camilla.Stokkevag@student.uib.no, Kalliopi.Kanaki@ift.uib.no | |
14 | */ | |
15 | ||
25ccfa3d | 16 | #if !defined(__CINT__) || defined(__MAKECINT__) |
17 | #include "TSystem.h" | |
18 | #include "TROOT.h" | |
19 | #include "TFile.h" | |
20 | #include "TString.h" | |
21 | #include "TList.h" | |
22 | #include "TCanvas.h" | |
23 | #include "TText.h" | |
25ccfa3d | 24 | #include "TPaveStats.h" |
25 | #include "TH1D.h" | |
26 | #include "TH2D.h" | |
27 | #include "TLegend.h" | |
28 | #include "TStyle.h" | |
29 | #include "TPad.h" | |
30 | #include <iostream> | |
31 | #include <cstdlib> | |
32 | using std::endl; | |
33 | #endif | |
34 | ||
35 | // --------------------- forward declerations --------------// | |
36 | ||
25ccfa3d | 37 | void plot(TH1F *h1, TH1F *h2); |
1281a832 | 38 | void printStats(TH1F *h1); |
39 | void printStats(TH1F *h1, TH1F *h2); | |
25ccfa3d | 40 | |
41 | //==========================================================// | |
42 | ||
0740807a | 43 | void drawGlobalESDHistograms(const char* filename="HLT-OFFLINE-GLOBAL-comparison.root"){ |
44 | ||
45 | gROOT->SetStyle("Plain"); | |
46 | gStyle->SetPalette(1); | |
25ccfa3d | 47 | gStyle->SetOptStat("emr"); |
69c78ecd | 48 | gStyle->SetTitleX(gStyle->GetPadLeftMargin()); |
0740807a | 49 | |
be66aae0 | 50 | TFile *file = TFile::Open(filename); |
51 | if(!file || file->IsZombie()) { | |
fa315f9c | 52 | printf("file %s does not exist or there is an error opening it\n", filename); |
53 | return; | |
54 | } | |
55 | ||
be66aae0 | 56 | TList *list = (TList*)file->Get("global_histograms"); |
57 | if(!list){ | |
58 | printf("No list %s contained in your input file\n", list->GetName()); | |
fa315f9c | 59 | return; |
60 | } | |
0740807a | 61 | |
be66aae0 | 62 | TText *hText = (TText*)list->FindObject("text"); |
63 | if(!hText) printf("No hText\n"); | |
64 | ||
65 | TString folder = "GlobalTask_"; | |
66 | folder += hText->GetTitle(); | |
67 | folder.ReplaceAll(" ",""); | |
68 | folder.ReplaceAll(",","_"); | |
69 | gSystem->Exec("mkdir "+folder); // create a folder whose name contains run number and date of run | |
70 | ||
c0fbe8ec | 71 | TCanvas *c1 = new TCanvas("c1","track properties HLT vs. OFF",1200,700); |
1281a832 | 72 | c1->Divide(4,2); |
73 | ||
25ccfa3d | 74 | TH1F *h1 = NULL; |
75 | TH1F *h2 = NULL; | |
0740807a | 76 | |
1281a832 | 77 | |
78 | h1 = (TH1F*)list->FindObject("fMomentum_hlt"); if(!h1) { printf("Empty histogram fMomentum_hlt\n"); return; } | |
79 | h2 = (TH1F*)list->FindObject("fMomentum_off"); if(!h2) { printf("Empty histogram fMomentum_off\n"); return; } | |
80 | h1->SetXTitle("p_{t} (GeV/c)"); | |
1281a832 | 81 | |
82 | c1->cd(1); | |
83 | plot(h1,h2); | |
0740807a | 84 | |
fa6dbeb8 | 85 | TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5); |
0740807a | 86 | leg1->SetFillColor(10); |
87 | leg1->SetLineColor(10); | |
88 | leg1->AddEntry(h1,"HLT", "l"); | |
89 | leg1->AddEntry(h2,"OFF", "l"); | |
1281a832 | 90 | leg1->Draw("same"); |
0740807a | 91 | |
1281a832 | 92 | //------------------------------------------------- |
93 | ||
94 | h1 = (TH1F*)list->FindObject("fNcluster_hlt"); if(!h1) { printf("Empty histogram fNcluster_hlt\n"); return; } | |
95 | h2 = (TH1F*)list->FindObject("fNcluster_off"); if(!h2) { printf("Empty histogram fNcluster_off\n"); return; } | |
c0fbe8ec | 96 | h1->SetXTitle("TPC clusters per track"); |
1281a832 | 97 | |
98 | c1->cd(2); | |
99 | plot(h1,h2); | |
100 | ||
101 | //------------------------------------------------- | |
102 | ||
103 | h1 = (TH1F*)list->FindObject("fEta_hlt"); if(!h1) { printf("Empty histogram fEta_hlt\n"); return; } | |
104 | h2 = (TH1F*)list->FindObject("fEta_off"); if(!h2) { printf("Empty histogram fEta_off\n"); return; } | |
1281a832 | 105 | h1->SetXTitle("#eta"); |
106 | ||
107 | c1->cd(3); | |
108 | plot(h1,h2); | |
109 | ||
110 | //------------------------------------------------- | |
111 | ||
112 | h1 = (TH1F*)list->FindObject("fPhi_hlt"); if(!h1) { printf("Empty histogram fPhi_hlt\n"); return; } | |
113 | h2 = (TH1F*)list->FindObject("fPhi_off"); if(!h2) { printf("Empty histogram fPhi_off\n"); return; } | |
1281a832 | 114 | h1->SetXTitle("#phi (deg)"); |
115 | ||
116 | c1->cd(4); | |
25ccfa3d | 117 | plot(h1,h2); |
0740807a | 118 | |
25ccfa3d | 119 | //------------------------------------------------- |
0740807a | 120 | |
1281a832 | 121 | h1 = (TH1F*)list->FindObject("fDCAr_hlt"); if(!h1) { printf("Empty histogram fDCAr_hlt\n"); return; } |
122 | h2 = (TH1F*)list->FindObject("fDCAr_off"); if(!h2) { printf("Empty histogram fDCAr_off\n"); return; } | |
25ccfa3d | 123 | h1->SetXTitle("DCAr (cm)"); |
124 | ||
1281a832 | 125 | c1->cd(5); |
25ccfa3d | 126 | plot(h1,h2); |
0740807a | 127 | |
25ccfa3d | 128 | //------------------------------------------------- |
0740807a | 129 | |
1281a832 | 130 | h1 = (TH1F*)list->FindObject("fDCAz_hlt"); if(!h1) { printf("Empty histogram fDCAz_hlt\n"); return; } |
131 | h2 = (TH1F*)list->FindObject("fDCAz_off"); if(!h2) { printf("Empty histogram fDCAz_off\n"); return; } | |
1281a832 | 132 | h1->SetXTitle("DCAz (cm)"); |
133 | ||
134 | c1->cd(6); | |
25ccfa3d | 135 | plot(h1,h2); |
0740807a | 136 | |
25ccfa3d | 137 | //------------------------------------------------- |
0740807a | 138 | |
be66aae0 | 139 | h1 = (TH1F*)list->FindObject("fCharge_hlt"); if(!h1) { printf("Empty histogram fCharge_hlt\n"); return; } |
140 | h2 = (TH1F*)list->FindObject("fCharge_off"); if(!h2) { printf("Empty histogram fCharge_off\n"); return; } | |
0740807a | 141 | |
1281a832 | 142 | c1->cd(7); |
25ccfa3d | 143 | plot(h1,h2); |
144 | ||
145 | //------------------------------------------------- | |
1281a832 | 146 | |
147 | h1 = (TH1F*)list->FindObject("fNITScluster_hlt"); if(!h1) { printf("Empty histogram fNITScluster_hlt\n"); return; } | |
148 | h2 = (TH1F*)list->FindObject("fNITScluster_off"); if(!h2) { printf("Empty histogram fNITScluster_off\n"); return; } | |
c0fbe8ec | 149 | h1->SetXTitle("ITS clusters per track"); |
25ccfa3d | 150 | |
1281a832 | 151 | c1->cd(8); |
25ccfa3d | 152 | plot(h1,h2); |
153 | ||
c0fbe8ec | 154 | //============= TRACK PROPERTIES WITH CUTS ===============// |
155 | ||
e302ba9e | 156 | TCanvas *c4 = new TCanvas("c4","HLT track properties with and w/o cuts",1200,700); |
157 | c4->Divide(3,2); | |
c0fbe8ec | 158 | |
159 | h1 = (TH1F*)list->FindObject("fMomentum_hlt"); if(!h1) { printf("Empty histogram fMomentum_hlt\n"); return; } | |
160 | h2 = (TH1F*)list->FindObject("fMomentum_hltcut"); if(!h2) { printf("Empty histogram fMomentum_hltcut\n"); return; } | |
161 | h1->SetXTitle("p_{t} (GeV/c)"); | |
162 | ||
163 | c4->cd(1); | |
164 | plot(h1,h2); | |
165 | ||
166 | TLegend *leg2 = new TLegend(0.6,0.2,0.8,0.5); | |
167 | leg2->SetFillColor(10); | |
168 | leg2->SetLineColor(10); | |
169 | leg2->AddEntry(h1,"HLT", "l"); | |
170 | leg2->AddEntry(h2,"HLT with cuts", "l"); | |
171 | leg2->Draw("same"); | |
172 | ||
173 | //------------------------------------------------- | |
174 | ||
175 | h1 = (TH1F*)list->FindObject("fNcluster_hlt"); if(!h1) { printf("Empty histogram fNcluster_hlt\n"); return; } | |
176 | h2 = (TH1F*)list->FindObject("fNcluster_hltcut"); if(!h2) { printf("Empty histogram fNcluster_hltcut\n"); return; } | |
177 | h1->SetXTitle("TPC clusters per track"); | |
178 | ||
179 | c4->cd(2); | |
180 | plot(h1,h2); | |
181 | ||
182 | //------------------------------------------------- | |
183 | ||
184 | h1 = (TH1F*)list->FindObject("fEta_hlt"); if(!h1) { printf("Empty histogram fEta_hlt\n"); return; } | |
185 | h2 = (TH1F*)list->FindObject("fEta_hltcut"); if(!h2) { printf("Empty histogram fEta_hltcut\n"); return; } | |
186 | h1->SetXTitle("#eta"); | |
187 | ||
188 | c4->cd(3); | |
189 | plot(h1,h2); | |
190 | ||
191 | //------------------------------------------------- | |
192 | ||
193 | h1 = (TH1F*)list->FindObject("fPhi_hlt"); if(!h1) { printf("Empty histogram fPhi_hlt\n"); return; } | |
194 | h2 = (TH1F*)list->FindObject("fPhi_hltcut"); if(!h2) { printf("Empty histogram fPhi_hltcut\n"); return; } | |
195 | h1->SetXTitle("#phi (deg)"); | |
196 | ||
197 | c4->cd(4); | |
198 | plot(h1,h2); | |
199 | ||
200 | //------------------------------------------------- | |
201 | ||
c0fbe8ec | 202 | h1 = (TH1F*)list->FindObject("fCharge_hlt"); if(!h1) { printf("Empty histogram fCharge_hlt\n"); return; } |
203 | h2 = (TH1F*)list->FindObject("fCharge_hltcut"); if(!h2) { printf("Empty histogram fCharge_hltcut\n"); return; } | |
204 | h1->SetXTitle("polarity"); | |
205 | ||
e302ba9e | 206 | c4->cd(5); |
c0fbe8ec | 207 | plot(h1,h2); |
208 | ||
209 | //------------------------------------------------- | |
210 | ||
211 | h1 = (TH1F*)list->FindObject("fNITScluster_hlt"); if(!h1) { printf("Empty histogram fNITScluster_hlt\n"); return; } | |
212 | h2 = (TH1F*)list->FindObject("fNITScluster_hltcut"); if(!h2) { printf("Empty histogram fNITScluster_hltcut\n"); return; } | |
213 | h1->SetXTitle("ITS clusters per track"); | |
214 | ||
e302ba9e | 215 | c4->cd(6); |
c0fbe8ec | 216 | plot(h1,h2); |
25ccfa3d | 217 | |
1281a832 | 218 | //============= EVENT PROPERTIES ===============// |
25ccfa3d | 219 | |
1281a832 | 220 | TCanvas *c2 = new TCanvas("c2","vertex event properties",1200,700); |
221 | c2->Divide(3,2); | |
25ccfa3d | 222 | |
be66aae0 | 223 | h1 = (TH1F*)list->FindObject("fXvertex_hlt"); if(!h1) { printf("Empty histogram fXvertex_hlt\n"); return; } |
224 | h2 = (TH1F*)list->FindObject("fXvertex_off"); if(!h2) { printf("Empty histogram fXvertex_off\n"); return; } | |
25ccfa3d | 225 | h1->SetXTitle("x (cm)"); |
0740807a | 226 | |
1281a832 | 227 | c2->cd(1); |
25ccfa3d | 228 | plot(h1,h2); |
1281a832 | 229 | leg1->Draw("same"); |
0740807a | 230 | |
25ccfa3d | 231 | //------------------------------------------------- |
0740807a | 232 | |
be66aae0 | 233 | h1 = (TH1F*)list->FindObject("fYvertex_hlt"); if(!h1) { printf("Empty histogram fYvertex_hlt\n"); return; } |
234 | h2 = (TH1F*)list->FindObject("fYvertex_off"); if(!h2) { printf("Empty histogram fYvertex_off\n"); return; } | |
25ccfa3d | 235 | h1->SetXTitle("y (cm)"); |
0740807a | 236 | |
1281a832 | 237 | c2->cd(2); |
25ccfa3d | 238 | plot(h1,h2); |
0740807a | 239 | |
25ccfa3d | 240 | //------------------------------------------------- |
0740807a | 241 | |
be66aae0 | 242 | h1 = (TH1F*)list->FindObject("fZvertex_hlt"); if(!h1) { printf("Empty histogram fZvertex_hlt\n"); return; } |
243 | h2 = (TH1F*)list->FindObject("fZvertex_off"); if(!h2) { printf("Empty histogram fZvertex_off\n"); return; } | |
25ccfa3d | 244 | h1->SetXTitle("z (cm)"); |
0740807a | 245 | |
1281a832 | 246 | c2->cd(3); |
247 | plot(h1,h2); | |
248 | ||
249 | //------------------------------------------------- | |
250 | ||
251 | h1 = (TH1F*)list->FindObject("fSPDXvertex_hlt"); if(!h1) { printf("Empty histogram fSPDXvertex_hlt\n"); return; } | |
252 | h2 = (TH1F*)list->FindObject("fSPDXvertex_off"); if(!h2) { printf("Empty histogram fSPDXvertex_off\n"); return; } | |
253 | h1->SetXTitle("x (cm)"); | |
1281a832 | 254 | |
255 | c2->cd(4); | |
25ccfa3d | 256 | plot(h1,h2); |
0740807a | 257 | |
25ccfa3d | 258 | //------------------------------------------------- |
0740807a | 259 | |
1281a832 | 260 | h1 = (TH1F*)list->FindObject("fSPDYvertex_hlt"); if(!h1) { printf("Empty histogram fSPDYvertex_hlt\n"); return; } |
261 | h2 = (TH1F*)list->FindObject("fSPDYvertex_off"); if(!h2) { printf("Empty histogram fSPDYvertex_off\n"); return; } | |
262 | h1->SetXTitle("y (cm)"); | |
1281a832 | 263 | |
264 | c2->cd(5); | |
265 | plot(h1,h2); | |
266 | ||
267 | //------------------------------------------------- | |
268 | ||
269 | h1 = (TH1F*)list->FindObject("fSPDZvertex_hlt"); if(!h1) { printf("Empty histogram fSPDZvertex_hlt\n"); return; } | |
270 | h2 = (TH1F*)list->FindObject("fSPDZvertex_off"); if(!h2) { printf("Empty histogram fSPDZvertex_off\n"); return; } | |
271 | h1->SetXTitle("z (cm)"); | |
1281a832 | 272 | |
273 | c2->cd(6); | |
274 | plot(h1,h2); | |
275 | ||
276 | //------------------------------------------------- | |
277 | ||
278 | TCanvas *c3 = new TCanvas("c3","general event properties",1200,500); | |
279 | c3->Divide(3,1); | |
280 | ||
281 | h1 = (TH1F*)list->FindObject("fMult_hlt"); if(!h1) { printf("Empty histogram fMult_hlt\n"); return; } | |
282 | h2 = (TH1F*)list->FindObject("fMult_off"); if(!h2) { printf("Empty histogram fMult_off\n"); return; } | |
1281a832 | 283 | |
284 | c3->cd(1); | |
285 | plot(h1,h2); | |
286 | leg1->Draw("same"); | |
287 | ||
288 | //------------------------------------------------- | |
289 | ||
290 | h1 = (TH1F*)list->FindObject("fNcont_hlt"); if(!h1) { printf("Empty histogram fNcont_hlt\n"); return; } | |
291 | h2 = (TH1F*)list->FindObject("fNcont_off"); if(!h2) { printf("Empty histogram fNcont_off\n"); return; } | |
1281a832 | 292 | |
293 | c3->cd(2); | |
294 | plot(h1,h2); | |
295 | ||
296 | //------------------------------------------------- | |
297 | ||
298 | h1 = (TH1F*)list->FindObject("fV0cent"); if(!h1) { printf("Empty histogram fV0cent\n"); return; } | |
299 | c3->cd(3); | |
300 | h1->Draw(); | |
301 | printStats(h1); | |
302 | ||
303 | //------------------------------------------------- | |
304 | ||
305 | c1->SaveAs(folder+"/track_properties.png"); | |
306 | c1->SaveAs(folder+"/track_properties.root"); | |
307 | c2->SaveAs(folder+"/vertex_event_properties.png"); | |
308 | c2->SaveAs(folder+"/vertex_event_properties.root"); | |
309 | c3->SaveAs(folder+"/general_event_properties.png"); | |
310 | c3->SaveAs(folder+"/general_event_properties.root"); | |
cb098126 | 311 | c4->SaveAs(folder+"/HLT_track_properties_cuts.png"); |
312 | c4->SaveAs(folder+"/HLT_track_properties_cuts.root"); | |
25ccfa3d | 313 | return; |
314 | } | |
315 | ||
316 | void printStats(TH1F* h1, TH1F* h2){ | |
317 | ||
318 | gPad->Update(); | |
319 | TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; } | |
320 | st1->SetLineColor(0); | |
321 | ||
322 | gPad->Update(); | |
323 | TPaveStats *st2 = (TPaveStats*)h2->FindObject("stats"); if(!st2) { printf("TPaveStats st2 is 0x0\n"); return; } | |
324 | st2->SetY2NDC(st1->GetY1NDC()-0.05); | |
325 | st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC())); | |
326 | st2->SetLineColor(0); | |
327 | st2->SetTextColor(h2->GetLineColor()); | |
25ccfa3d | 328 | st2->Draw(); |
329 | return; | |
330 | } | |
331 | ||
1281a832 | 332 | void printStats(TH1F* h1){ |
333 | gPad->Update(); | |
334 | TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; } | |
335 | st1->SetLineColor(0); | |
336 | return; | |
337 | } | |
338 | ||
25ccfa3d | 339 | void plot(TH1F *h1, TH1F *h2){ |
340 | //Y axis | |
341 | if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum()); | |
342 | else h1->SetMaximum(1.1*h2->GetMaximum()); | |
343 | ||
344 | h1->SetMinimum(0); | |
345 | h2->SetMinimum(0); | |
346 | h2->SetLineColor(2); | |
347 | ||
348 | // X axis | |
349 | double xmin, xmax; | |
350 | if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1); | |
351 | else xmin = h2->GetBinLowEdge(1); | |
352 | if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1); | |
353 | else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1); | |
354 | ||
355 | h2->SetAxisRange(xmin, xmax, "X"); | |
25ccfa3d | 356 | |
357 | h1->Draw(); | |
358 | h2->Draw("sames"); | |
fa6dbeb8 | 359 | printStats(h1,h2); |
25ccfa3d | 360 | return; |
0740807a | 361 | } |