]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/QA/tasks/macros/drawGlobalESDHistograms.C
- include a series of HLT histograms with cuts for selecting primary tracks
[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"
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>
32using std::endl;
33#endif
34
35// --------------------- forward declerations --------------//
36
25ccfa3d 37void plot(TH1F *h1, TH1F *h2);
1281a832 38void printStats(TH1F *h1);
39void printStats(TH1F *h1, TH1F *h2);
25ccfa3d 40
41//==========================================================//
42
0740807a 43void 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
156 TCanvas *c4 = new TCanvas("c4","track properties HLT vs. OFF",1200,700);
157 c4->Divide(4,2);
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
202 h1 = (TH1F*)list->FindObject("fDCAr_hlt"); if(!h1) { printf("Empty histogram fDCAr_hlt\n"); return; }
203 h2 = (TH1F*)list->FindObject("fDCAr_hltcut"); if(!h2) { printf("Empty histogram fDCAr_hltcut\n"); return; }
204 h1->SetXTitle("DCAr (cm)");
205
206 c4->cd(5);
207 plot(h1,h2);
208
209//-------------------------------------------------
210
211 h1 = (TH1F*)list->FindObject("fDCAz_hlt"); if(!h1) { printf("Empty histogram fDCAz_hlt\n"); return; }
212 h2 = (TH1F*)list->FindObject("fDCAz_hltcut"); if(!h2) { printf("Empty histogram fDCAz_hltcut\n"); return; }
213 h1->SetXTitle("DCAz (cm)");
214
215 c4->cd(6);
216 plot(h1,h2);
217
218//-------------------------------------------------
219
220 h1 = (TH1F*)list->FindObject("fCharge_hlt"); if(!h1) { printf("Empty histogram fCharge_hlt\n"); return; }
221 h2 = (TH1F*)list->FindObject("fCharge_hltcut"); if(!h2) { printf("Empty histogram fCharge_hltcut\n"); return; }
222 h1->SetXTitle("polarity");
223
224 c4->cd(7);
225 plot(h1,h2);
226
227//-------------------------------------------------
228
229 h1 = (TH1F*)list->FindObject("fNITScluster_hlt"); if(!h1) { printf("Empty histogram fNITScluster_hlt\n"); return; }
230 h2 = (TH1F*)list->FindObject("fNITScluster_hltcut"); if(!h2) { printf("Empty histogram fNITScluster_hltcut\n"); return; }
231 h1->SetXTitle("ITS clusters per track");
232
233 c4->cd(8);
234 plot(h1,h2);
25ccfa3d 235
1281a832 236//============= EVENT PROPERTIES ===============//
25ccfa3d 237
1281a832 238 TCanvas *c2 = new TCanvas("c2","vertex event properties",1200,700);
239 c2->Divide(3,2);
25ccfa3d 240
be66aae0 241 h1 = (TH1F*)list->FindObject("fXvertex_hlt"); if(!h1) { printf("Empty histogram fXvertex_hlt\n"); return; }
242 h2 = (TH1F*)list->FindObject("fXvertex_off"); if(!h2) { printf("Empty histogram fXvertex_off\n"); return; }
25ccfa3d 243 h1->SetXTitle("x (cm)");
0740807a 244
1281a832 245 c2->cd(1);
25ccfa3d 246 plot(h1,h2);
1281a832 247 leg1->Draw("same");
0740807a 248
25ccfa3d 249//-------------------------------------------------
0740807a 250
be66aae0 251 h1 = (TH1F*)list->FindObject("fYvertex_hlt"); if(!h1) { printf("Empty histogram fYvertex_hlt\n"); return; }
252 h2 = (TH1F*)list->FindObject("fYvertex_off"); if(!h2) { printf("Empty histogram fYvertex_off\n"); return; }
25ccfa3d 253 h1->SetXTitle("y (cm)");
0740807a 254
1281a832 255 c2->cd(2);
25ccfa3d 256 plot(h1,h2);
0740807a 257
25ccfa3d 258//-------------------------------------------------
0740807a 259
be66aae0 260 h1 = (TH1F*)list->FindObject("fZvertex_hlt"); if(!h1) { printf("Empty histogram fZvertex_hlt\n"); return; }
261 h2 = (TH1F*)list->FindObject("fZvertex_off"); if(!h2) { printf("Empty histogram fZvertex_off\n"); return; }
25ccfa3d 262 h1->SetXTitle("z (cm)");
0740807a 263
1281a832 264 c2->cd(3);
265 plot(h1,h2);
266
267//-------------------------------------------------
268
269 h1 = (TH1F*)list->FindObject("fSPDXvertex_hlt"); if(!h1) { printf("Empty histogram fSPDXvertex_hlt\n"); return; }
270 h2 = (TH1F*)list->FindObject("fSPDXvertex_off"); if(!h2) { printf("Empty histogram fSPDXvertex_off\n"); return; }
271 h1->SetXTitle("x (cm)");
1281a832 272
273 c2->cd(4);
25ccfa3d 274 plot(h1,h2);
0740807a 275
25ccfa3d 276//-------------------------------------------------
0740807a 277
1281a832 278 h1 = (TH1F*)list->FindObject("fSPDYvertex_hlt"); if(!h1) { printf("Empty histogram fSPDYvertex_hlt\n"); return; }
279 h2 = (TH1F*)list->FindObject("fSPDYvertex_off"); if(!h2) { printf("Empty histogram fSPDYvertex_off\n"); return; }
280 h1->SetXTitle("y (cm)");
1281a832 281
282 c2->cd(5);
283 plot(h1,h2);
284
285//-------------------------------------------------
286
287 h1 = (TH1F*)list->FindObject("fSPDZvertex_hlt"); if(!h1) { printf("Empty histogram fSPDZvertex_hlt\n"); return; }
288 h2 = (TH1F*)list->FindObject("fSPDZvertex_off"); if(!h2) { printf("Empty histogram fSPDZvertex_off\n"); return; }
289 h1->SetXTitle("z (cm)");
1281a832 290
291 c2->cd(6);
292 plot(h1,h2);
293
294//-------------------------------------------------
295
296 TCanvas *c3 = new TCanvas("c3","general event properties",1200,500);
297 c3->Divide(3,1);
298
299 h1 = (TH1F*)list->FindObject("fMult_hlt"); if(!h1) { printf("Empty histogram fMult_hlt\n"); return; }
300 h2 = (TH1F*)list->FindObject("fMult_off"); if(!h2) { printf("Empty histogram fMult_off\n"); return; }
1281a832 301
302 c3->cd(1);
303 plot(h1,h2);
304 leg1->Draw("same");
305
306//-------------------------------------------------
307
308 h1 = (TH1F*)list->FindObject("fNcont_hlt"); if(!h1) { printf("Empty histogram fNcont_hlt\n"); return; }
309 h2 = (TH1F*)list->FindObject("fNcont_off"); if(!h2) { printf("Empty histogram fNcont_off\n"); return; }
1281a832 310
311 c3->cd(2);
312 plot(h1,h2);
313
314//-------------------------------------------------
315
316 h1 = (TH1F*)list->FindObject("fV0cent"); if(!h1) { printf("Empty histogram fV0cent\n"); return; }
317 c3->cd(3);
318 h1->Draw();
319 printStats(h1);
320
321//-------------------------------------------------
322
323 c1->SaveAs(folder+"/track_properties.png");
324 c1->SaveAs(folder+"/track_properties.root");
325 c2->SaveAs(folder+"/vertex_event_properties.png");
326 c2->SaveAs(folder+"/vertex_event_properties.root");
327 c3->SaveAs(folder+"/general_event_properties.png");
328 c3->SaveAs(folder+"/general_event_properties.root");
25ccfa3d 329 return;
330}
331
332void printStats(TH1F* h1, TH1F* h2){
333
334 gPad->Update();
335 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
336 st1->SetLineColor(0);
337
338 gPad->Update();
339 TPaveStats *st2 = (TPaveStats*)h2->FindObject("stats"); if(!st2) { printf("TPaveStats st2 is 0x0\n"); return; }
340 st2->SetY2NDC(st1->GetY1NDC()-0.05);
341 st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC()));
342 st2->SetLineColor(0);
343 st2->SetTextColor(h2->GetLineColor());
25ccfa3d 344 st2->Draw();
345 return;
346}
347
1281a832 348void printStats(TH1F* h1){
349 gPad->Update();
350 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
351 st1->SetLineColor(0);
352 return;
353}
354
25ccfa3d 355void plot(TH1F *h1, TH1F *h2){
356 //Y axis
357 if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum());
358 else h1->SetMaximum(1.1*h2->GetMaximum());
359
360 h1->SetMinimum(0);
361 h2->SetMinimum(0);
362 h2->SetLineColor(2);
363
364 // X axis
365 double xmin, xmax;
366 if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1);
367 else xmin = h2->GetBinLowEdge(1);
368 if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1);
369 else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1);
370
371 h2->SetAxisRange(xmin, xmax, "X");
25ccfa3d 372
373 h1->Draw();
374 h2->Draw("sames");
fa6dbeb8 375 printStats(h1,h2);
25ccfa3d 376 return;
0740807a 377}