]>
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" |
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> | |
33 | using std::endl; | |
34 | #endif | |
35 | ||
36 | // --------------------- forward declerations --------------// | |
37 | ||
25ccfa3d | 38 | void plot(TH1F *h1, TH1F *h2); |
1281a832 | 39 | void printStats(TH1F *h1); |
40 | void printStats(TH1F *h1, TH1F *h2); | |
25ccfa3d | 41 | |
42 | //==========================================================// | |
43 | ||
0740807a | 44 | void 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 | ||
2f281fd6 | 75 | const static int sizeTrack=8; |
76 | const char *trackHLT[sizeTrack]={"fMomentum_hlt","fNcluster_hlt","fEta_hlt","fPhi_hlt","fDCAr_hlt","fDCAz_hlt","fCharge_hlt","fNITScluster_hlt"}; | |
77 | const char *trackOFF[sizeTrack]={"fMomentum_off","fNcluster_off","fEta_off","fPhi_off","fDCAr_off","fDCAz_off","fCharge_off","fNITScluster_off"}; | |
78 | const char *trackHLTcut[sizeTrack]={"fMomentum_hltcut","fNcluster_hltcut","fEta_hltcut","fPhi_hltcut","fDCAr_hltcut","fDCAz_hltcut","fCharge_hltcut","fNITScluster_hltcut"}; | |
79 | ||
80 | const static int sizeEvent=9; | |
81 | const char *eventHLT[sizeEvent]={"fXvertex_hlt","fYvertex_hlt","fZvertex_hlt","fSPDXvertex_hlt","fSPDYvertex_hlt","fSPDZvertex_hlt","fMult_hlt","fNcont_hlt","fV0cent"}; | |
82 | const char *eventOFF[sizeEvent]={"fXvertex_off","fYvertex_off","fZvertex_off","fSPDXvertex_off","fSPDYvertex_off","fSPDZvertex_off","fMult_off","fNcont_off","fV0cent"}; | |
83 | ||
84 | TCanvas *c1 = new TCanvas("c1","track properties HLT vs. OFF",1250,700); | |
1281a832 | 85 | c1->Divide(4,2); |
86 | ||
25ccfa3d | 87 | TH1F *h1 = NULL; |
88 | TH1F *h2 = NULL; | |
1281a832 | 89 | |
2f281fd6 | 90 | for(int i=0;i<sizeTrack;i++){ |
91 | c1->cd(i+1); | |
92 | h1 = (TH1F*)list->FindObject(trackHLT[i]); if(!h1) { return; } | |
93 | h2 = (TH1F*)list->FindObject(trackOFF[i]); if(!h2) { return; } | |
94 | plot(h1,h2); | |
95 | if(i==0){ | |
96 | TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5); | |
97 | leg1->SetFillColor(10); | |
98 | leg1->SetLineColor(10); | |
99 | leg1->AddEntry(h1,"HLT", "l"); | |
100 | leg1->AddEntry(h2,"OFF", "l"); | |
101 | leg1->Draw("same"); | |
102 | } | |
103 | } | |
c0fbe8ec | 104 | |
17ab437a | 105 | TCanvas *c4 = new TCanvas("c4","HLT track properties with and w/o cuts",1250,700); |
106 | c4->Divide(4,2); | |
c0fbe8ec | 107 | |
2f281fd6 | 108 | for(int i=0;i<sizeTrack;i++){ |
109 | c4->cd(i+1); | |
110 | h1 = (TH1F*)list->FindObject(trackHLT[i]); if(!h1) { return; } | |
111 | h2 = (TH1F*)list->FindObject(trackHLTcut[i]); if(!h2) { return; } | |
112 | plot(h1,h2); | |
113 | if(i==0){ | |
114 | TPaveText *pave = new TPaveText(2.1,24000,8.3,31600); | |
115 | pave->SetFillColor(kWhite); | |
116 | pave->SetLineColor(kWhite); | |
117 | pave->SetShadowColor(kWhite); | |
118 | TString tmp=cuts->GetTitle(); | |
119 | pave->SetTextColor(2); | |
120 | pave->AddText(tmp); | |
121 | pave->SetTextFont(42); | |
122 | pave->SetTextSize(0.04); | |
123 | pave->Draw(); | |
124 | c4->Update(); | |
125 | } | |
126 | } | |
25ccfa3d | 127 | |
1281a832 | 128 | TCanvas *c2 = new TCanvas("c2","vertex event properties",1200,700); |
129 | c2->Divide(3,2); | |
1281a832 | 130 | |
2f281fd6 | 131 | for(int i=0;i<6;i++){ |
132 | c2->cd(i+1); | |
133 | h1 = (TH1F*)list->FindObject(eventHLT[i]); if(!h1) { return; } | |
134 | h2 = (TH1F*)list->FindObject(eventOFF[i]); if(!h2) { return; } | |
135 | plot(h1,h2); | |
136 | if(i==0){ | |
137 | TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5); | |
138 | leg1->SetFillColor(10); | |
139 | leg1->SetLineColor(10); | |
140 | leg1->AddEntry(h1,"HLT", "l"); | |
141 | leg1->AddEntry(h2,"OFF", "l"); | |
142 | leg1->Draw("same"); | |
143 | } | |
144 | } | |
1281a832 | 145 | |
146 | TCanvas *c3 = new TCanvas("c3","general event properties",1200,500); | |
147 | c3->Divide(3,1); | |
148 | ||
2f281fd6 | 149 | for(int i=6;i<9;i++){ |
150 | c3->cd(i-5); | |
151 | h2 = (TH1F*)list->FindObject(eventOFF[i]); if(!h2) { return; } | |
152 | h1 = (TH1F*)list->FindObject(eventHLT[i]); if(!h1) { return; } | |
153 | plot(h1,h2); | |
154 | if(i==6){ | |
155 | TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5); | |
156 | leg1->SetFillColor(10); | |
157 | leg1->SetLineColor(10); | |
158 | leg1->AddEntry(h1,"HLT", "l"); | |
159 | leg1->AddEntry(h2,"OFF", "l"); | |
160 | leg1->Draw("same"); | |
161 | } | |
162 | } | |
163 | ||
1281a832 | 164 | c1->SaveAs(folder+"/track_properties.png"); |
165 | c1->SaveAs(folder+"/track_properties.root"); | |
166 | c2->SaveAs(folder+"/vertex_event_properties.png"); | |
167 | c2->SaveAs(folder+"/vertex_event_properties.root"); | |
168 | c3->SaveAs(folder+"/general_event_properties.png"); | |
169 | c3->SaveAs(folder+"/general_event_properties.root"); | |
cb098126 | 170 | c4->SaveAs(folder+"/HLT_track_properties_cuts.png"); |
171 | c4->SaveAs(folder+"/HLT_track_properties_cuts.root"); | |
25ccfa3d | 172 | return; |
2f281fd6 | 173 | } |
25ccfa3d | 174 | |
2f281fd6 | 175 | void printStats(TH1F* h1, TH1F* h2){ |
25ccfa3d | 176 | gPad->Update(); |
177 | TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; } | |
178 | st1->SetLineColor(0); | |
179 | ||
180 | gPad->Update(); | |
181 | TPaveStats *st2 = (TPaveStats*)h2->FindObject("stats"); if(!st2) { printf("TPaveStats st2 is 0x0\n"); return; } | |
182 | st2->SetY2NDC(st1->GetY1NDC()-0.05); | |
183 | st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC())); | |
184 | st2->SetLineColor(0); | |
185 | st2->SetTextColor(h2->GetLineColor()); | |
25ccfa3d | 186 | st2->Draw(); |
187 | return; | |
188 | } | |
189 | ||
1281a832 | 190 | void printStats(TH1F* h1){ |
191 | gPad->Update(); | |
192 | TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; } | |
193 | st1->SetLineColor(0); | |
194 | return; | |
195 | } | |
196 | ||
25ccfa3d | 197 | void plot(TH1F *h1, TH1F *h2){ |
198 | //Y axis | |
199 | if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum()); | |
200 | else h1->SetMaximum(1.1*h2->GetMaximum()); | |
201 | ||
202 | h1->SetMinimum(0); | |
203 | h2->SetMinimum(0); | |
204 | h2->SetLineColor(2); | |
205 | ||
206 | // X axis | |
207 | double xmin, xmax; | |
208 | if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1); | |
209 | else xmin = h2->GetBinLowEdge(1); | |
210 | if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1); | |
211 | else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1); | |
212 | ||
213 | h2->SetAxisRange(xmin, xmax, "X"); | |
25ccfa3d | 214 | |
215 | h1->Draw(); | |
216 | h2->Draw("sames"); | |
fa6dbeb8 | 217 | printStats(h1,h2); |
25ccfa3d | 218 | return; |
0740807a | 219 | } |