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.*
6 * Usage: aliroot drawGlobalESDHistograms.C++ in compiled mode
8 * It saves all canvases with the output histograms in a png and a ROOT file.
9 * The second argument of the macro will produce individual files for all pads,
10 * in case it is turned to kTRUE.
13 * @author Camilla.Stokkevag@student.uib.no, Kalliopi.Kanaki@ift.uib.no
16 #if !defined(__CINT__) || defined(__MAKECINT__)
24 #include "TPaveStats.h"
25 #include "TPaveText.h"
36 // --------------------- forward declerations --------------//
38 void plot(TH1F *h1, TH1F *h2);
39 void printStats(TH1F *h1);
40 void printStats(TH1F *h1, TH1F *h2);
42 //==========================================================//
44 void drawGlobalESDHistograms(const char* filename="HLT-OFFLINE-GLOBAL-comparison.root", bool option=kFALSE){
46 gROOT->SetStyle("Plain");
47 gStyle->SetPalette(1);
48 gStyle->SetOptStat("emr");
49 gStyle->SetTitleX(gStyle->GetPadLeftMargin());
51 TFile *file = TFile::Open(filename);
52 if(!file || file->IsZombie()) {
53 printf("file %s does not exist or there is an error opening it\n", filename);
57 TList *list = (TList*)file->Get("global_histograms");
59 printf("No list %s contained in your input file\n", list->GetName());
63 TText *runInfo = (TText*)list->FindObject("text");
64 if(!runInfo) printf("No runInfo string\n");
66 TText *cuts = (TText*)list->FindObject("cuts");
67 if(!cuts) printf("No cuts string\n");
69 TString folder = "GlobalTask_";
70 folder += runInfo->GetTitle();
71 folder.ReplaceAll(" ","");
72 folder.ReplaceAll(",","_");
73 gSystem->Exec("mkdir "+folder); // create a folder whose name contains run number and date of run
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"};
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"};
84 TCanvas *c1 = new TCanvas("c1","track properties HLT vs. OFF",1250,700);
90 for(int i=0;i<sizeTrack;i++){
92 h1 = (TH1F*)list->FindObject(trackHLT[i]);
93 h2 = (TH1F*)list->FindObject(trackOFF[i]);
97 TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5);
98 leg1->SetFillColor(10);
99 leg1->SetLineColor(10);
100 leg1->AddEntry(h1,"HLT", "l");
101 leg1->AddEntry(h2,"OFF", "l");
107 TCanvas *c4 = new TCanvas("c4","HLT track properties with and w/o cuts",1250,700);
110 for(int i=0;i<sizeTrack;i++){
112 h1 = (TH1F*)list->FindObject(trackHLT[i]);
113 h2 = (TH1F*)list->FindObject(trackHLTcut[i]);
117 TPaveText *pave = new TPaveText(2.1,24000,8.3,31600);
118 pave->SetFillColor(kWhite);
119 pave->SetLineColor(kWhite);
120 pave->SetShadowColor(kWhite);
121 TString tmp=cuts->GetTitle();
122 pave->SetTextColor(2);
124 pave->SetTextFont(42);
125 pave->SetTextSize(0.04);
132 TCanvas *c2 = new TCanvas("c2","vertex event properties",1200,700);
135 for(int i=0;i<6;i++){
137 h1 = (TH1F*)list->FindObject(eventHLT[i]);
138 h2 = (TH1F*)list->FindObject(eventOFF[i]);
142 TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5);
143 leg1->SetFillColor(10);
144 leg1->SetLineColor(10);
145 leg1->AddEntry(h1,"HLT", "l");
146 leg1->AddEntry(h2,"OFF", "l");
152 TCanvas *c3 = new TCanvas("c3","general event properties",1200,500);
155 for(int i=6;i<9;i++){
157 h2 = (TH1F*)list->FindObject(eventOFF[i]);
158 h1 = (TH1F*)list->FindObject(eventHLT[i]);
162 TLegend *leg1 = new TLegend(0.6,0.2,0.8,0.5);
163 leg1->SetFillColor(10);
164 leg1->SetLineColor(10);
165 leg1->AddEntry(h1,"HLT", "l");
166 leg1->AddEntry(h2,"OFF", "l");
172 c1->SaveAs(folder+"/track_properties.png");
173 c1->SaveAs(folder+"/track_properties.root");
174 c2->SaveAs(folder+"/vertex_event_properties.png");
175 c2->SaveAs(folder+"/vertex_event_properties.root");
176 c3->SaveAs(folder+"/general_event_properties.png");
177 c3->SaveAs(folder+"/general_event_properties.root");
178 c4->SaveAs(folder+"/HLT_track_properties_cuts.png");
179 c4->SaveAs(folder+"/HLT_track_properties_cuts.root");
183 for(int i=1; i<=sizeTrack; i++){
184 pad = (TPad*)c1->GetListOfPrimitives()->FindObject(Form("c1_%d",i));
186 printf("Empty pad %d in canvas %s.\n", i, c1->GetName());
189 pad->SaveAs(Form(folder+"/c1_%s_off.png",trackHLT[i-1]));
192 for(int i=1; i<=sizeTrack; i++){
193 pad = (TPad*)c4->GetListOfPrimitives()->FindObject(Form("c4_%d",i));
195 printf("Empty pad %d in canvas %s.\n", i, c4->GetName());
198 pad->SaveAs(Form(folder+"/c4_%s_cuts.png",trackHLT[i-1]));
201 for(int i=1; i<7; i++){
202 pad = (TPad*)c2->GetListOfPrimitives()->FindObject(Form("c2_%d",i));
204 printf("Empty pad %d in canvas %s.\n", i, c2->GetName());
207 pad->SaveAs(Form(folder+"/c2_%s_off.png",eventHLT[i-1]));
210 for(int i=6; i<9; i++){
211 pad = (TPad*)c3->GetListOfPrimitives()->FindObject(Form("c3_%d",i-5));
213 printf("Empty pad %d in canvas %s.\n", i-5, c3->GetName());
216 pad->SaveAs(Form(folder+"/c3_%s_off.png",eventHLT[i]));
223 void printStats(TH1F* h1, TH1F* h2){
225 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
226 st1->SetLineColor(0);
229 TPaveStats *st2 = (TPaveStats*)h2->FindObject("stats"); if(!st2) { printf("TPaveStats st2 is 0x0\n"); return; }
230 st2->SetY2NDC(st1->GetY1NDC()-0.05);
231 st2->SetY1NDC(st2->GetY2NDC()-TMath::Abs(st1->GetY1NDC()-st1->GetY2NDC()));
232 st2->SetLineColor(0);
233 st2->SetTextColor(h2->GetLineColor());
238 void printStats(TH1F* h1){
240 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
241 st1->SetLineColor(0);
245 void plot(TH1F *h1, TH1F *h2){
247 if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum());
248 else h1->SetMaximum(1.1*h2->GetMaximum());
256 if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1);
257 else xmin = h2->GetBinLowEdge(1);
258 if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1);
259 else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1);
261 h2->SetAxisRange(xmin, xmax, "X");