]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/QA/tasks/macros/drawGlobalESDHistograms.C
- added the task name in front of the folder name with the run number and the date...
[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"
24#include "TPaveText.h"
25#include "TPaveStats.h"
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
38void printStats(TH1F *h1, TH1F *h2);
39void plot(TH1F *h1, TH1F *h2);
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
fa315f9c 50 TFile *f1 = TFile::Open(filename);
51 if(!f1 || f1->IsZombie()) {
52 printf("file %s does not exist or there is an error opening it\n", filename);
53 return;
54 }
55
0740807a 56 TList *l1 = (TList*)f1->Get("global_histograms");
fa315f9c 57 if(!l1){
58 printf("No list %s contained in your input file\n", l1->GetName());
59 return;
60 }
0740807a 61
25ccfa3d 62 TCanvas *c1 = new TCanvas("c1","HLT vs. offline",1200,700);
63 c1->Divide(3,3);
64 TH1F *h1 = NULL;
65 TH1F *h2 = NULL;
0740807a 66
25ccfa3d 67 h1 = (TH1F*)l1->FindObject("fNcluster_hlt"); if(!h1) { printf("Empty histogram fNcluster_hlt\n"); return; }
68 h2 = (TH1F*)l1->FindObject("fNcluster_off"); if(!h2) { printf("Empty histogram fNcluster_off\n"); return; }
69 h1->SetTitle("TPC cluster distribution");
69c78ecd 70 h1->GetXaxis()->SetTitle("TPC clusters per track");
0740807a 71
25ccfa3d 72 TLegend *leg1 = new TLegend(0.7,0.6,0.88,0.77);
0740807a 73 leg1->SetFillColor(10);
74 leg1->SetLineColor(10);
75 leg1->AddEntry(h1,"HLT", "l");
76 leg1->AddEntry(h2,"OFF", "l");
77
25ccfa3d 78 c1->cd(1);
79 plot(h1,h2);
80 leg1->Draw("same");
0740807a 81
25ccfa3d 82//-------------------------------------------------
0740807a 83
25ccfa3d 84 h1 = (TH1F*)l1->FindObject("fDCA_hlt"); if(!h1) { printf("Empty histogram fDCA_hlt\n"); return; }
85 h2 = (TH1F*)l1->FindObject("fDCA_off"); if(!h2) { printf("Empty histogram fDCA_off\n"); return; }
86 h1->SetTitle("DCA between track and vertex on XY plane");
87 h1->SetXTitle("DCAr (cm)");
88
89 c1->cd(2);
90 plot(h1,h2);
0740807a 91
25ccfa3d 92//-------------------------------------------------
0740807a 93
25ccfa3d 94 h1 = (TH1F*)l1->FindObject("fMult_hlt"); if(!h1) { printf("Empty histogram fMult_hlt\n"); return; }
95 h2 = (TH1F*)l1->FindObject("fMult_off"); if(!h2) { printf("Empty histogram fMult_off\n"); return; }
96 h1->SetTitle("track multiplicity");
0740807a 97
25ccfa3d 98 c1->cd(3);
99 plot(h1,h2);
0740807a 100
25ccfa3d 101//-------------------------------------------------
0740807a 102
25ccfa3d 103 h1 = (TH1F*)l1->FindObject("fCharge_hlt"); if(!h1) { printf("Empty histogram fCharge_hlt\n"); return; }
104 h2 = (TH1F*)l1->FindObject("fCharge_off"); if(!h2) { printf("Empty histogram fCharge_off\n"); return; }
105 h1->SetXTitle("polarity");
106 h1->SetTitle("charge distribution");
0740807a 107
108 c1->cd(4);
25ccfa3d 109 plot(h1,h2);
110
111//-------------------------------------------------
112
113 h1 = (TH1F*)l1->FindObject("fMomentum_hlt"); if(!h1) { printf("Empty histogram fMomentum_hlt\n"); return; }
114 h2 = (TH1F*)l1->FindObject("fMomentum_off"); if(!h2) { printf("Empty histogram fMomentum_off\n"); return; }
115 h1->SetXTitle("p_{t} (GeV/c)");
116 h1->SetTitle("transverse momentum");
117
118 c1->cd(5);
119 plot(h1,h2);
120
121//-------------------------------------------------
122
123 h1 = (TH1F*)l1->FindObject("fEta_hlt"); if(!h1) { printf("Empty histogram fEta_hlt\n"); return; }
124 h2 = (TH1F*)l1->FindObject("fEta_off"); if(!h2) { printf("Empty histogram fEta_off\n"); return; }
125 h1->SetTitle("pseudorapidity");
126 h1->SetXTitle("#eta");
127
0740807a 128 c1->cd(6);
25ccfa3d 129 plot(h1,h2);
0740807a 130
25ccfa3d 131//-------------------------------------------------
132
133 h1 = (TH1F*)l1->FindObject("fXvertex_hlt"); if(!h1) { printf("Empty histogram fXvertex_hlt\n"); return; }
134 h2 = (TH1F*)l1->FindObject("fXvertex_off"); if(!h2) { printf("Empty histogram fXvertex_off\n"); return; }
135 h1->SetXTitle("x (cm)");
136 h1->SetTitle("x of primary vertex");
0740807a 137
25ccfa3d 138 c1->cd(7);
139 plot(h1,h2);
0740807a 140
25ccfa3d 141//-------------------------------------------------
0740807a 142
25ccfa3d 143 h1 = (TH1F*)l1->FindObject("fYvertex_hlt"); if(!h1) { printf("Empty histogram fYvertex_hlt\n"); return; }
144 h2 = (TH1F*)l1->FindObject("fYvertex_off"); if(!h2) { printf("Empty histogram fYvertex_off\n"); return; }
145 h1->SetXTitle("y (cm)");
146 h1->SetTitle("y of primary vertex");
0740807a 147
25ccfa3d 148 c1->cd(8);
149 plot(h1,h2);
0740807a 150
25ccfa3d 151//-------------------------------------------------
0740807a 152
25ccfa3d 153 h1 = (TH1F*)l1->FindObject("fZvertex_hlt"); if(!h1) { printf("Empty histogram fZvertex_hlt\n"); return; }
154 h2 = (TH1F*)l1->FindObject("fZvertex_off"); if(!h2) { printf("Empty histogram fZvertex_off\n"); return; }
155 h1->SetXTitle("z (cm)");
156 h1->SetTitle("z of primary vertex");
0740807a 157
158 c1->cd(9);
25ccfa3d 159 plot(h1,h2);
0740807a 160
25ccfa3d 161//-------------------------------------------------
0740807a 162
163 c1->SaveAs("HLT-offline.png");
25ccfa3d 164 c1->SaveAs("HLT-offline.root");
165 return;
166}
167
168void printStats(TH1F* h1, TH1F* h2){
169
170 gPad->Update();
171 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
172 st1->SetLineColor(0);
173
174 gPad->Update();
175 TPaveStats *st2 = (TPaveStats*)h2->FindObject("stats"); if(!st2) { printf("TPaveStats st2 is 0x0\n"); return; }
176 st2->SetY2NDC(st1->GetY1NDC()-0.05);
177 st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC()));
178 st2->SetLineColor(0);
179 st2->SetTextColor(h2->GetLineColor());
180 st2->SetFillStyle(0);
181 st2->Draw();
182 return;
183}
184
185void plot(TH1F *h1, TH1F *h2){
186 //Y axis
187 if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum());
188 else h1->SetMaximum(1.1*h2->GetMaximum());
189
190 h1->SetMinimum(0);
191 h2->SetMinimum(0);
192 h2->SetLineColor(2);
193
194 // X axis
195 double xmin, xmax;
196 if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1);
197 else xmin = h2->GetBinLowEdge(1);
198 if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1);
199 else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1);
200
201 h2->SetAxisRange(xmin, xmax, "X");
202 printStats(h1,h2);
203
204 h1->Draw();
205 h2->Draw("sames");
206 return;
0740807a 207}