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