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'("HLT-OFFLINE-GLOBAL-comparison.root")'
8 * or aliroot drawGlobalESDHistograms.C++ in compiled mode
10 * It saves the canvas with the output histograms in a png and a ROOT file.
13 * @author Camilla.Stokkevag@student.uib.no, Kalliopi.Kanaki@ift.uib.no
16 #if !defined(__CINT__) || defined(__MAKECINT__)
24 #include "TPaveStats.h"
35 // --------------------- forward declerations --------------//
37 void printStats(TH1F *h1, TH1F *h2);
38 void plot(TH1F *h1, TH1F *h2);
40 //==========================================================//
42 void drawGlobalESDHistograms(const char* filename="HLT-OFFLINE-GLOBAL-comparison.root"){
44 gROOT->SetStyle("Plain");
45 gStyle->SetPalette(1);
46 gStyle->SetOptStat("emr");
47 gStyle->SetTitleX(gStyle->GetPadLeftMargin());
49 TFile *file = TFile::Open(filename);
50 if(!file || file->IsZombie()) {
51 printf("file %s does not exist or there is an error opening it\n", filename);
55 TList *list = (TList*)file->Get("global_histograms");
57 printf("No list %s contained in your input file\n", list->GetName());
61 TText *hText = (TText*)list->FindObject("text");
62 if(!hText) printf("No hText\n");
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
70 TCanvas *c1 = new TCanvas("c1","HLT vs. offline",1200,700);
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; }
77 h1->SetTitle("TPC cluster distribution");
78 h1->GetXaxis()->SetTitle("TPC clusters per track");
80 TLegend *leg1 = new TLegend(0.7,0.6,0.88,0.77);
81 leg1->SetFillColor(10);
82 leg1->SetLineColor(10);
83 leg1->AddEntry(h1,"HLT", "l");
84 leg1->AddEntry(h2,"OFF", "l");
90 //-------------------------------------------------
92 h1 = (TH1F*)list->FindObject("fDCA_hlt"); if(!h1) { printf("Empty histogram fDCA_hlt\n"); return; }
93 h2 = (TH1F*)list->FindObject("fDCA_off"); if(!h2) { printf("Empty histogram fDCA_off\n"); return; }
94 h1->SetTitle("DCA between track and vertex on XY plane");
95 h1->SetXTitle("DCAr (cm)");
100 //-------------------------------------------------
102 h1 = (TH1F*)list->FindObject("fMult_hlt"); if(!h1) { printf("Empty histogram fMult_hlt\n"); return; }
103 h2 = (TH1F*)list->FindObject("fMult_off"); if(!h2) { printf("Empty histogram fMult_off\n"); return; }
104 h1->SetTitle("track multiplicity");
109 //-------------------------------------------------
111 h1 = (TH1F*)list->FindObject("fCharge_hlt"); if(!h1) { printf("Empty histogram fCharge_hlt\n"); return; }
112 h2 = (TH1F*)list->FindObject("fCharge_off"); if(!h2) { printf("Empty histogram fCharge_off\n"); return; }
113 h1->SetXTitle("polarity");
114 h1->SetTitle("charge distribution");
119 //-------------------------------------------------
121 h1 = (TH1F*)list->FindObject("fMomentum_hlt"); if(!h1) { printf("Empty histogram fMomentum_hlt\n"); return; }
122 h2 = (TH1F*)list->FindObject("fMomentum_off"); if(!h2) { printf("Empty histogram fMomentum_off\n"); return; }
123 h1->SetXTitle("p_{t} (GeV/c)");
124 h1->SetTitle("transverse momentum");
129 //-------------------------------------------------
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; }
133 h1->SetTitle("pseudorapidity");
134 h1->SetXTitle("#eta");
139 //-------------------------------------------------
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; }
143 h1->SetXTitle("x (cm)");
144 h1->SetTitle("x of primary vertex");
149 //-------------------------------------------------
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; }
153 h1->SetXTitle("y (cm)");
154 h1->SetTitle("y of primary vertex");
159 //-------------------------------------------------
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; }
163 h1->SetXTitle("z (cm)");
164 h1->SetTitle("z of primary vertex");
169 //-------------------------------------------------
171 c1->SaveAs(folder+"/HLT-offline.png");
172 c1->SaveAs(folder+"/HLT-offline.root");
176 void printStats(TH1F* h1, TH1F* h2){
179 TPaveStats *st1 = (TPaveStats*)h1->FindObject("stats"); if(!st1) { printf("TPaveStats st1 is 0x0\n"); return; }
180 st1->SetLineColor(0);
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());
188 st2->SetFillStyle(0);
193 void plot(TH1F *h1, TH1F *h2){
195 if(h1->GetMaximum() > h2->GetMaximum()) h2->SetMaximum(1.1*h1->GetMaximum());
196 else h1->SetMaximum(1.1*h2->GetMaximum());
204 if(h1->GetBinLowEdge(1) > h2->GetBinLowEdge(1)) xmin = h1->GetBinLowEdge(1);
205 else xmin = h2->GetBinLowEdge(1);
206 if(h1->GetBinLowEdge(h1->GetNbinsX()+1) > h2->GetBinLowEdge(h1->GetNbinsX()+1)) xmax = h1->GetBinLowEdge(h1->GetNbinsX()+1);
207 else xmax = h2->GetBinLowEdge(h2->GetNbinsX()+1);
209 h2->SetAxisRange(xmin, xmax, "X");