1 #if !defined(__CINT__) || defined(__MAKECINT__)
6 #include <TPaveStats.h>
8 #include <TGraphErrors.h>
13 #include <TLegendEntry.h>
21 //-------------------------------------------------------
23 // Macro do plot the output histograms of the QA task for ITS standalone tracks
24 // General Plots: ratios between ITSsa, ITSpureSA and TPC+ITS tracks
25 // eta phi distributions of tracks
26 // number of clusters per track
27 // Pt resolution (matching ITSèureSA with TPC+ITS tracks)
28 // d0 resolution and bias
30 // Authors: Leonardo Milano, Francesco Prino
32 //-------------------------------------------------------
34 enum{kDoGeneral,kDoPt,kDoImpPar,kDoAll};
36 void PlotITSsa(TList* l);
37 void PlotPtResol(TList* l, Bool_t optFromMC);
38 void PlotImpPar(TList* l);
39 void SetDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TH1 *h1);
41 void PlotOutputQATaskITSsa(TString filename, Int_t analysisType=kDoAll, Bool_t isMC=kFALSE){
43 gROOT->SetStyle("Plain");
45 if(filename.Contains("alien")) TGrid::Connect("alien:");
46 TFile* fil=TFile::Open(filename.Data());
47 TDirectoryFile* df=(TDirectoryFile*)fil->Get("TracksITSsa");
48 if(!df) df=(TDirectoryFile*)fil->Get("ITSsaTracks");
49 TList* l=(TList*)df->Get("clistITSsaTracks");
50 if(analysisType==kDoAll || analysisType==kDoGeneral) PlotITSsa(l);
51 if(analysisType==kDoAll || analysisType==kDoPt) PlotPtResol(l,isMC);
52 if(analysisType==kDoAll || analysisType==kDoImpPar) PlotImpPar(l);
56 //-----------------------------------------------------
58 void PlotITSsa(TList* l){
60 TH1F* hPtTPCITS=(TH1F*)l->FindObject("hPtTPCITS");
61 TH1F* hPtITSsa=(TH1F*)l->FindObject("hPtITSsa");
62 TH1F* hPtITSpureSA=(TH1F*)l->FindObject("hPtITSpureSA");
64 TH2F* hEtaPhiTPCITS=(TH2F*)l->FindObject("hEtaPhiTPCITS");
65 TH2F* hEtaPhiITSsa=(TH2F*)l->FindObject("hEtaPhiITSsa");
66 TH2F* hEtaPhiITSpureSA=(TH2F*)l->FindObject("hEtaPhiITSpureSA");
68 TH1F* hChi2TPCITS=(TH1F*)l->FindObject("hChi2TPCITS");
69 TH1F* hChi2ITSsa=(TH1F*)l->FindObject("hChi2ITSsa");
70 TH1F* hChi2ITSpureSA=(TH1F*)l->FindObject("hChi2ITSpureSA");
72 TH1F* hNcluTPCITS=(TH1F*)l->FindObject("hNcluTPCITS");
73 TH1F* hNcluITSsa=(TH1F*)l->FindObject("hNcluITSsa");
74 TH1F* hNcluITSpureSA=(TH1F*)l->FindObject("hNcluITSpureSA");
77 TH1F* hRatio=(TH1F*)hPtTPCITS->Clone("hRatio");
78 hRatio->Add(hPtITSsa);
79 hRatio->Divide(hPtITSpureSA);
82 TCanvas* c1=new TCanvas("c1","Pt",800,1000);
86 hPtITSpureSA->GetXaxis()->SetTitle("Pt (GeV/c)");
88 TPaveStats *st1=(TPaveStats*)hPtITSpureSA->GetListOfFunctions()->FindObject("stats");
91 hPtTPCITS->SetLineColor(2);
92 hPtTPCITS->Draw("sames");
94 TPaveStats *st2=(TPaveStats*)hPtTPCITS->GetListOfFunctions()->FindObject("stats");
99 hPtITSsa->SetLineColor(4);
100 hPtITSsa->Draw("sames");
102 TPaveStats *st3=(TPaveStats*)hPtITSsa->GetListOfFunctions()->FindObject("stats");
105 st3->SetTextColor(4);
106 TLegend* leg=new TLegend(0.5,0.5,0.69,0.69);
107 leg->SetFillColor(0);
108 TLegendEntry* ent=leg->AddEntry(hPtITSpureSA,"ITS pureSA","L");
109 ent->SetTextColor(hPtITSpureSA->GetLineColor());
110 ent=leg->AddEntry(hPtTPCITS,"TPC+ITS","L");
111 ent->SetTextColor(hPtTPCITS->GetLineColor());
112 ent=leg->AddEntry(hPtITSsa,"ITSsa","L");
113 ent->SetTextColor(hPtITSsa->GetLineColor());
119 hRatio->GetXaxis()->SetTitle("Pt (GeV/c)");
120 hRatio->GetYaxis()->SetTitle("(TPCITS+ITSsa)/ITSpureSA");
122 hChi2ITSpureSA->Scale(1./hChi2ITSpureSA->GetEntries());
123 hChi2ITSsa->Scale(1./hChi2ITSsa->GetEntries());
124 hChi2TPCITS->Scale(1./hChi2TPCITS->GetEntries());
126 TCanvas* c2=new TCanvas("c2","Chi2");
127 hChi2ITSpureSA->Draw();
128 hChi2ITSpureSA->GetXaxis()->SetTitle("Chi2");
130 TPaveStats *stc1=(TPaveStats*)hChi2ITSpureSA->GetListOfFunctions()->FindObject("stats");
131 stc1->SetY1NDC(0.71);
133 hChi2TPCITS->SetLineColor(2);
134 hChi2TPCITS->Draw("sames");
136 TPaveStats *stc2=(TPaveStats*)hChi2TPCITS->GetListOfFunctions()->FindObject("stats");
137 stc2->SetY1NDC(0.51);
139 stc2->SetTextColor(2);
141 hChi2ITSsa->SetLineColor(4);
142 hChi2ITSsa->Draw("sames");
144 TPaveStats *stc3=(TPaveStats*)hChi2ITSsa->GetListOfFunctions()->FindObject("stats");
145 stc3->SetY1NDC(0.31);
147 stc3->SetTextColor(4);
150 hNcluITSpureSA->Scale(1./hNcluITSpureSA->GetEntries());
151 hNcluITSsa->Scale(1./hNcluITSsa->GetEntries());
152 hNcluTPCITS->Scale(1./hNcluTPCITS->GetEntries());
154 TCanvas* c3=new TCanvas("c3","Nclu");
155 c3->SetRightMargin(0.22);
156 hNcluITSpureSA->Draw();
157 hNcluITSpureSA->GetXaxis()->SetTitle("n. ITS clusters");
159 TPaveStats *stn1=(TPaveStats*)hNcluITSpureSA->GetListOfFunctions()->FindObject("stats");
160 stn1->SetY1NDC(0.71);
162 hNcluTPCITS->SetLineColor(2);
163 hNcluTPCITS->Draw("sames");
165 TPaveStats *stn2=(TPaveStats*)hNcluTPCITS->GetListOfFunctions()->FindObject("stats");
166 stn2->SetY1NDC(0.51);
168 stn2->SetTextColor(2);
170 hNcluITSsa->SetLineColor(4);
171 hNcluITSsa->Draw("sames");
173 TPaveStats *stn3=(TPaveStats*)hNcluITSsa->GetListOfFunctions()->FindObject("stats");
174 stn3->SetY1NDC(0.31);
176 stn3->SetTextColor(4);
179 gStyle->SetPalette(1);
180 hEtaPhiITSpureSA->SetStats(0);
181 hEtaPhiITSpureSA->SetTitle("ITS pureSA");
182 hEtaPhiITSsa->SetStats(0);
183 hEtaPhiITSsa->SetTitle("ITSsa");
184 hEtaPhiTPCITS->SetStats(0);
185 hEtaPhiTPCITS->SetTitle("TPC+ITS");
186 TCanvas* c4=new TCanvas("c4","EtaPhi",1000,700);
189 hEtaPhiITSpureSA->Draw("colz");
190 hEtaPhiITSpureSA->GetXaxis()->SetTitle("Eta");
191 hEtaPhiITSpureSA->GetYaxis()->SetTitle("Phi");
193 hEtaPhiITSsa->Draw("colz");
194 hEtaPhiITSsa->GetXaxis()->SetTitle("Eta");
195 hEtaPhiITSsa->GetYaxis()->SetTitle("Phi");
197 hEtaPhiTPCITS->Draw("colz");
198 hEtaPhiTPCITS->GetXaxis()->SetTitle("Eta");
199 hEtaPhiTPCITS->GetYaxis()->SetTitle("Phi");
202 //-----------------------------------------------------
204 void PlotPtResol(TList* l, Bool_t optFromMC){
205 TString hNameR,hNameA;
206 TString partName[3]={"Pion","Kaon","Proton"};
208 if(optFromMC) prefix="hMC";
218 TH1F* h1ptrelres[3][40];
219 TH1F* hptreco[3][40];
221 TGraphErrors* gbias[3];
222 TGraphErrors* grelresol[3];
224 gStyle->SetPalette(1);
226 for(Int_t iSpec=0; iSpec<3; iSpec++){
227 hNameA=Form("%sPtResid%s",prefix.Data(),partName[iSpec].Data());
228 hNameR=Form("%sInvPtRelResid%s",prefix.Data(),partName[iSpec].Data());
229 printf("%s %s\n",hNameA.Data(),hNameR.Data());
230 h2DA[iSpec]=(TH2F*)l->FindObject(hNameA.Data());
231 h2DR[iSpec]=(TH2F*)l->FindObject(hNameR.Data());
232 c2d[iSpec]=new TCanvas(Form("c2d%s",partName[iSpec].Data()),Form("c2d%s",partName[iSpec].Data()));
233 c2d[iSpec]->Divide(2,1);
235 h2DA[iSpec]->Draw("colz");
237 h2DR[iSpec]->Draw("colz");
239 Int_t nptbins=h2DR[iSpec]->GetNbinsX();
241 Int_t nybinsA=h2DA[iSpec]->GetNbinsY();
242 Float_t minyA=h2DA[iSpec]->GetYaxis()->GetBinLowEdge(1);
243 Float_t maxyA=h2DA[iSpec]->GetYaxis()->GetBinUpEdge(nybinsA);
245 Int_t nybinsR=h2DR[iSpec]->GetNbinsY();
246 Float_t minyR=h2DR[iSpec]->GetYaxis()->GetBinLowEdge(1);
247 Float_t maxyR=h2DR[iSpec]->GetYaxis()->GetBinUpEdge(nybinsR);
248 printf("%d %d %f %f %d %f %f\n",nptbins,nybinsA,minyA,maxyA,nybinsR,minyR,maxyR);
250 c1dA[iSpec]=new TCanvas(Form("c1dA%s",partName[iSpec].Data()),Form("c1dA%s",partName[iSpec].Data()));
251 c1dA[iSpec]->Divide(6,5);
252 c1dR[iSpec]=new TCanvas(Form("c1dR%s",partName[iSpec].Data()),Form("c1dR%s",partName[iSpec].Data()));
253 c1dR[iSpec]->Divide(6,5);
256 gbias[iSpec]=new TGraphErrors(0);
257 grelresol[iSpec]=new TGraphErrors(0);
258 gbias[iSpec]->SetTitle("");
259 grelresol[iSpec]->SetTitle("");
261 for(Int_t iptbin=0; iptbin<nptbins;iptbin++){
262 Float_t avept=h2DA[iSpec]->GetXaxis()->GetBinCenter(iptbin+1);
263 Float_t widpt=0.5*h2DA[iSpec]->GetXaxis()->GetBinWidth(iptbin+1);
264 Int_t minptbinmev=(Int_t)(h2DA[iSpec]->GetXaxis()->GetBinLowEdge(iptbin+1)*1000.+0.5);
266 hptres[iSpec][iptbin]=new TH1F(Form("hptres%s_%d",partName[iSpec].Data(),minptbinmev),
267 Form("hptres%s_%d",partName[iSpec].Data(),minptbinmev),
268 nybinsA,minyA,maxyA);
269 h1ptrelres[iSpec][iptbin]=new TH1F(Form("h1ptrelres%s_%d",partName[iSpec].Data(),minptbinmev),
270 Form("h1ptrelres%s_%d",partName[iSpec].Data(),minptbinmev),
271 nybinsR,minyR,maxyR);
272 hptreco[iSpec][iptbin]=new TH1F(Form("hptreco%s_%d",partName[iSpec].Data(),minptbinmev),
273 Form("hptreco%s_%d",partName[iSpec].Data(),minptbinmev),
275 for(Int_t iBin=1; iBin<=nybinsA; iBin++){
276 hptres[iSpec][iptbin]->SetBinContent(iBin,h2DA[iSpec]->GetBinContent(iptbin+1,iBin));
277 hptres[iSpec][iptbin]->SetBinError(iBin,h2DA[iSpec]->GetBinError(iptbin+1,iBin));
279 for(Int_t iBin=1; iBin<=nybinsR; iBin++){
280 h1ptrelres[iSpec][iptbin]->SetBinContent(iBin,h2DR[iSpec]->GetBinContent(iptbin+1,iBin));
281 h1ptrelres[iSpec][iptbin]->SetBinError(iBin,h2DR[iSpec]->GetBinError(iptbin+1,iBin));
284 c1dA[iSpec]->cd(iptbin+1);
285 hptres[iSpec][iptbin]->Draw();
286 if(hptres[iSpec][iptbin]->Integral()>50){
287 hptres[iSpec][iptbin]->Fit("gaus");
288 hptres[iSpec][iptbin]->GetXaxis()->SetTitle("Pt residuals (GeV/c)");
289 hptres[iSpec][iptbin]->GetXaxis()->CenterTitle();
290 TF1* fgaus= (TF1*)hptres[iSpec][iptbin]->GetListOfFunctions()->FindObject("gaus");
291 Int_t nPoint=gbias[iSpec]->GetN();
292 gbias[iSpec]->SetPoint(nPoint, avept, fgaus->GetParameter(1));//hptres[iSpec][iptbin]->GetMean());
293 gbias[iSpec]->SetPointError(nPoint, widpt, fgaus->GetParError(1)); //hptres[iSpec][iptbin]->GetMeanError());
295 c1dR[iSpec]->cd(iptbin+1);
296 h1ptrelres[iSpec][iptbin]->Draw();
297 if(h1ptrelres[iSpec][iptbin]->Integral()>50){
298 h1ptrelres[iSpec][iptbin]->Fit("gaus");//,"L");
299 h1ptrelres[iSpec][iptbin]->GetXaxis()->SetTitle("1/Pt relative residuals");
300 h1ptrelres[iSpec][iptbin]->GetXaxis()->CenterTitle();
301 TF1* fgaus= (TF1*)h1ptrelres[iSpec][iptbin]->GetListOfFunctions()->FindObject("gaus");
302 Int_t nPoint=grelresol[iSpec]->GetN();
303 grelresol[iSpec]->SetPoint(nPoint, avept, fgaus->GetParameter(2));
304 grelresol[iSpec]->SetPointError(nPoint, widpt, fgaus->GetParError(2));
311 TCanvas* cb=new TCanvas("cb","Bias");
312 gbias[2]->SetMarkerStyle(22);
313 gbias[2]->SetMarkerColor(4);
314 gbias[2]->SetLineColor(4);
315 gbias[2]->Draw("PA");
316 gbias[0]->SetMarkerStyle(20);
317 gbias[0]->SetMarkerColor(1);
318 gbias[0]->SetLineColor(1);
319 gbias[0]->Draw("PSAME");
320 gbias[1]->SetMarkerStyle(25);
321 gbias[1]->SetMarkerColor(2);
322 gbias[1]->SetLineColor(2);
323 gbias[1]->Draw("PSAME");
324 gbias[2]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
325 if(optFromMC) gbias[2]->GetYaxis()->SetTitle("<p_{T}(ITSsa)-p_{T}(MC)> (GeV/c)");
326 else gbias[2]->GetYaxis()->SetTitle("<p_{T}(ITSsa)-p_{T}(TPCITS)> (GeV/c)");
327 gbias[2]->GetYaxis()->SetTitleOffset(1.2);
330 TCanvas* cr=new TCanvas("cr","Resol");
331 grelresol[2]->SetMinimum(0.);
332 grelresol[2]->SetMaximum(0.2);
333 grelresol[2]->SetMarkerStyle(22);
334 grelresol[2]->SetMarkerColor(4);
335 grelresol[2]->SetLineColor(4);
336 grelresol[2]->Draw("PA");
337 grelresol[0]->SetMarkerStyle(20);
338 grelresol[0]->SetMarkerColor(1);
339 grelresol[0]->SetLineColor(1);
340 grelresol[0]->Draw("PSAME");
341 grelresol[1]->SetMarkerStyle(25);
342 grelresol[1]->SetMarkerColor(2);
343 grelresol[1]->SetLineColor(2);
344 grelresol[1]->Draw("PSAME");
345 grelresol[2]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
346 grelresol[2]->GetYaxis()->SetTitle("1/Pt relative resolution (%)");
347 grelresol[2]->GetYaxis()->SetTitleOffset(1.2);
352 //-----------------------------------------------------
354 void PlotImpPar(TList* l){
356 TString particle[3]={"Pion","Kaon","Proton"};
357 Int_t colors[3]={1,2,4};
358 TCanvas *cImpPar=new TCanvas("ImpParRes","ImpParRes",1000,800);
361 cImpPar->SetLeftMargin(0.14);
362 TCanvas *cImpParMean=new TCanvas("ImpParMean","ImpParMean",1000,800);
363 cImpParMean->SetGridx();
364 cImpParMean->SetLogx();
365 cImpParMean->SetLeftMargin(0.14);
367 TLegend* leg1=new TLegend(0.6,0.7,0.89,0.89);
368 leg1->SetFillColor(0);
371 TH2F *hd0rphiITSpureSA[3];
373 const Int_t nbins = 29;
374 Double_t xbins[nbins+1]={0.06,0.08,0.10,0.12,0.14,0.16,0.18,0.20,0.25,0.30,
375 0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,
376 0.85,0.90,0.95,1.00,1.20,1.40,1.60,1.80,1.90,2.00};
378 TH1F *fHistDCA[nbins];
380 for(Int_t iparticle=0;iparticle<3;iparticle++){
381 hd0rphiITSpureSA[iparticle]=(TH2F*)l->FindObject(Form("hd0rphiITSpureSA%s",particle[iparticle].Data()));
384 TH1F *fHistImpParRes = new TH1F(Form("fHistImpParRes%s",particle[iparticle].Data()),"",nbins,xbins);
385 fHistImpParRes->SetStats(0);
386 fHistImpParRes->GetXaxis()->SetTitle("Pt [GeV/c]");
387 fHistImpParRes->GetYaxis()->SetTitle("d0 r#phi resolution [#mum]");
388 fHistImpParRes->GetYaxis()->SetTitleOffset(1.4);
389 TH1F *fHistImpParMean = new TH1F(Form("fHistImpParMean%s",particle[iparticle].Data()),"",nbins,xbins);
390 fHistImpParMean->SetStats(0);
391 fHistImpParMean->GetXaxis()->SetTitle("Pt [GeV/c]");
392 fHistImpParMean->GetYaxis()->SetTitle("d0 r#phi mean [#mum]");
393 fHistImpParMean->GetYaxis()->SetTitleOffset(1.4);
394 TF1 *fPar = new TF1("fPar","gaus",-1,1);
395 for(Int_t m=0;m<nbins;m++){
397 fHistDCA[m]= (TH1F*)hd0rphiITSpureSA[iparticle]->ProjectionY(Form("%s%i",particle[iparticle].Data(),m),hd0rphiITSpureSA[iparticle]->GetXaxis()->FindBin(xbins[m]+0.000001),hd0rphiITSpureSA[iparticle]->GetXaxis()->FindBin(xbins[m+1]-0.000001));
398 fHistDCA[m]->Rebin();
401 TCanvas *cgaus=new TCanvas(Form("cgaus%s",particle[iparticle].Data()),Form("DCA dist %s ",particle[iparticle].Data()),1000,800);
402 cgaus->Divide(8,4,0.001,0.001);
403 for(Int_t i=0; i<nbins; i++){
405 fHistDCA[i]->SetLineColor(colors[iparticle]);
406 fHistDCA[i]->SetMarkerColor(colors[iparticle]);
407 fPar->SetLineColor(colors[iparticle]);
410 fHistDCA[i]->SetFillColor(16);
411 printf("\n\n\n\n\n\n first fit step\n\n\n\n\n");
412 fHistDCA[i]->Fit(fPar,"NM","",-1,1);
413 printf("\n\n\n\n\n\n second fit step\n\n\n\n\n");
415 Float_t sigma=fPar->GetParameter(2);
416 fHistDCA[i]->Fit(fPar,"NM","",fPar->GetParameter(1)-nsigmas*sigma,fPar->GetParameter(1)+nsigmas*sigma);
417 fHistDCA[i]->GetXaxis()->SetRangeUser(fPar->GetParameter(1)-nsigmas*sigma,fPar->GetParameter(1)+nsigmas*sigma);
418 fPar->DrawClone("same");
419 fHistImpParRes->Fill((xbins[i]+xbins[i+1])/2,10000*fPar->GetParameter(2));
420 fHistImpParRes->SetBinError(fHistImpParRes->FindBin((xbins[i]+xbins[i+1])/2),10000*fPar->GetParError(2));
421 fHistImpParMean->Fill((xbins[i]+xbins[i+1])/2,10000*fPar->GetParameter(1));
422 fHistImpParMean->SetBinError(fHistImpParMean->FindBin((xbins[i]+xbins[i+1])/2),10000*fPar->GetParError(1));
424 fHistImpParRes->SetMaximum(1000);
425 fHistImpParRes->SetMinimum(0);
426 fHistImpParMean->SetMaximum(80);
427 fHistImpParMean->SetMinimum(-80);
429 SetDrawAtt(iparticle+20,colors[iparticle],1,colors[iparticle],1,fHistImpParRes);
430 SetDrawAtt(iparticle+20,colors[iparticle],1,colors[iparticle],1,fHistImpParMean);
433 if(iparticle==0)fHistImpParRes->DrawCopy("p");
434 else fHistImpParRes->DrawCopy("psame");
437 if(iparticle==0)fHistImpParMean->DrawCopy("p");
438 else fHistImpParMean->DrawCopy("psame");
440 ent=leg1->AddEntry(fHistImpParMean,Form("%s",particle[iparticle].Data()),"PL");
441 ent->SetTextColor(fHistImpParMean->GetLineColor());
451 void SetDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TH1 *h1){
454 h1->SetMarkerStyle(markerstyle);
455 h1->SetMarkerColor(markercolor);
456 h1->SetMarkerSize(markersize);
457 h1->SetLineColor(linecolor);
458 h1->SetLineWidth(linewidth);