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