]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/ITS/AliITSQAchecks.C
MFT track shit tool added
[u/mrichter/AliRoot.git] / PWGPP / ITS / AliITSQAchecks.C
CommitLineData
c6f340ff 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TCanvas.h>
3#include <TGrid.h>
4#include <TFile.h>
5#include <TList.h>
6#include <TGridResult.h>
7#include <TPaveStats.h>
8#include <TGraph.h>
9#include <TMath.h>
10#include <TGraphErrors.h>
11#include <TH1.h>
12#include <TF1.h>
13#include <TH2.h>
14#include <TLegend.h>
15#include <TLegendEntry.h>
16#include <TLatex.h>
e7815454 17#include <TString.h>
c6f340ff 18#include <TStyle.h>
e7815454 19#include <TSystem.h>
c6f340ff 20#include <TROOT.h>
21#endif
22
23void PlotGeneral(TFile* fildat, TCanvas**& clist, Int_t& cnum);
24void PlotITSsa(TFile* fildat, TCanvas**& clist, Int_t& cnum);
25void PlotSDD(TFile* fildat, TCanvas**& clist, Int_t& cnum);
26void GetGainModuleLevelSSD(TFile* fildat, TCanvas**& clist, Int_t& cnum);
27void VertexQAMacro(TFile *fildat, TCanvas **&clist, Int_t &cnum);
28void PlotSPD(TFile* fildat, TFile* filMC, TCanvas**& clist, Int_t& cnum);
29Bool_t PlotITSTPCMatchingEff(TFile *f, TCanvas**& clist,Int_t& cnum);
30void SetDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TH1 *h1);
31Double_t LangausFun(Double_t *x, Double_t *par);
32void SaveC(TFile &fout, TCanvas**& clist, Int_t cnum);
1f7d40d1 33TString GetRunNumber();
34
35// the run number is available to all the functions. Its value is set by AliITSQAchecks
36 Int_t gRunNumber = 0;
bd9e89b9 37 Int_t gRunNumberMC = 0;
e7815454 38 TString pdfFileNames="";
1f7d40d1 39
c6f340ff 40
41//_______________________________________________________________________
42void AliITSQAchecks(TString option="grid",
1a76a60f 43 Int_t nRun=170389,
44 TString period="LHC11h_2",
45 TString qaTrain="",
46 TString filenamedata="QAresults.root", TString filenameMC="alien:///alice/data/2011/LHC11h_2/000170546/ESDs/pass2/QAresults.root",Int_t nRunMC=0){
bd9e89b9 47 // THIS MACRO SHOULD BE COMPILED. IT DOES NOT WORK WITH THE INTERPRETER
c6f340ff 48 // option: "local" if filenamedata is the name of a local file
49 // "grid" if on alien
7eb2b2df 50 // nRun: run number
51 // period: LHC period (e.g. LHC11h)
bd9e89b9 52 // qaTrain: QA train specifier
53 // Empty string if QAresults.root is in the ESDs/pass1_HLT directory
7eb2b2df 54 // filenamedata: QAresults.root is by default the file name with the results
55 // filenameMC: file name for MC comparison. If the names begins with alien:
56 // the file is accessed through alien, otherwise is taken as local
bd9e89b9 57 // nRunMC: run number for comparison. If filenamMC begings with "alien:"
58 // the run number is taken from the path. Otherwise, in case of a
59 // local filenameMC, the run number must be specified here
c6f340ff 60 // Select here what you want to display
61 // the complete selection string is
62 // "general ITSSA SPD SDD SSD vertex ITSTPC"
63 // Contact: Stefania Beole': beole@to.infn.it
64
7eb2b2df 65/* $Id$ */
c6f340ff 66
1f7d40d1 67 gRunNumber = nRun;
bd9e89b9 68 TString aux(filenameMC);
69 if(aux.BeginsWith("alien:")){
2b0a46f8 70 Int_t pl=aux.Index("/000",4)+4;
71 aux=aux.Remove(0,pl);
72 aux=aux.Remove(6,aux.Length()-6);
bd9e89b9 73 gRunNumberMC = atoi(aux.Data());
74 }
75 else {
76 gRunNumber = nRunMC;
77 }
1f7d40d1 78
c6f340ff 79 TString selection("general ITSSA SPD SDD SSD vertex ITSTPC");
1a76a60f 80
81 // TString selection("SPD");
c6f340ff 82 gROOT->SetStyle("Plain");
83 gStyle->SetOptStat(1111);
84 TFile *fildat;
85 TString path;
86 Int_t year=2011;
87 if(period.Contains("LHC10")) year=2010;
88 else if(period.Contains("LHC09")) year=2009;
89
90 if(option.Contains("local")){
91 fildat=new TFile(filenamedata.Data());
92 printf("Opened file %s\n",fildat->GetName());
93 }else{
94 TGrid::Connect("alien:");
95 if(qaTrain.Contains("QA")){
1a76a60f 96 path=Form("/alice/data/%d/%s/%09d/ESDs/pass2/%s/",year,period.Data(),nRun,qaTrain.Data());
c6f340ff 97 } else {
1a76a60f 98 path=Form("/alice/data/%d/%s/%09d/ESDs/pass2/",year,period.Data(),nRun);
c6f340ff 99 }
697ff557 100 filenamedata = "alien://"+path+"QAresults.root";
c6f340ff 101 fildat=TFile::Open(filenamedata.Data());
102 }
103 if(option.Contains("local") && filenameMC.Contains("alien"))TGrid::Connect("alien:");
104 TFile* filMC=TFile::Open(filenameMC.Data());
105 TCanvas** clist;
106 Int_t cnum;
e7815454 107 char rn[10];
108 sprintf(rn,"%d",gRunNumber);
109 TString strRN(rn);
110 TString founame="Outfil"+strRN+".root";
111 TFile fout(founame,"recreate");
c6f340ff 112 if(selection.Contains("general")){
113 PlotGeneral(fildat,clist,cnum);
114 printf("GENERAL - cnum = %d\n",cnum);
115 SaveC(fout,clist,cnum);
e7815454 116
c6f340ff 117 }
118 if(selection.Contains("ITSSA")){
119 PlotITSsa(fildat,clist,cnum);
120 printf("ITSSA - cnum = %d\n",cnum);
121 SaveC(fout,clist,cnum);
122 }
123 if(selection.Contains("SDD")){
124 PlotSDD(fildat,clist,cnum);
125 printf("SDD - cnum = %d\n",cnum);
126 SaveC(fout,clist,cnum);
127 }
128 if(selection.Contains("SSD")){
129 GetGainModuleLevelSSD(fildat,clist,cnum);
130 printf("SSD - cnum = %d\n",cnum);
131 SaveC(fout,clist,cnum);
132 }
133 if(selection.Contains("vertex")){
134 VertexQAMacro(fildat,clist,cnum);
135 printf("VERTEX - cnum = %d\n",cnum);
136 SaveC(fout,clist,cnum);
137 }
138 if(selection.Contains("SPD")){
139 PlotSPD(fildat,filMC,clist,cnum);
140 printf("SPD - cnum = %d\n",cnum);
141 SaveC(fout,clist,cnum);
142 }
143 if(selection.Contains("ITSTPC")){
144 PlotITSTPCMatchingEff(fildat,clist,cnum);
145 printf("ITSTPC - cnum = %d\n",cnum);
146 SaveC(fout,clist,cnum);
147 }
148
149 fout.Close();
e7815454 150
151 // merge the pdf files
152 TString command("gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged");
153 command=command+strRN+".pdf "+pdfFileNames;
154 gSystem->Exec(command.Data());
155 printf(" Merging the pdf file: %s \n",command.Data());
c6f340ff 156
157}
158
159//_______________________________________________________________________
160void PlotGeneral(TFile* fildat, TCanvas**& clist, Int_t& cnum){
161 TDirectoryFile* df=(TDirectoryFile*)fildat->Get("SDD_Performance");
bd9e89b9 162 if(!df){
163 printf("SDD_Performance MISSING -> Exit\n");
164 return;
165 }
166 TList* l=(TList*)df->Get("coutputRP");
167 if(!df){
168 printf("coutputRP TList MISSING -> Exit\n");
169 return;
170 }
171 cnum=1; // number of canvases
172 clist= new TCanvas* [1];//array of pointers to TCanvases
173 gROOT->SetStyle("Plain");
c6f340ff 174 gStyle->SetOptStat(1111);
175 TH1F* hcllay=(TH1F*)l->FindObject("hCluInLay");
bd9e89b9 176 TH1F* hev=(TH1F*)l->FindObject("hNEvents");
c6f340ff 177 Int_t nTotEvents=hev->GetBinContent(2);
178 Int_t nTrigEvents=hev->GetBinContent(3);
179 Int_t nEvents=nTotEvents;
180 printf("---- Statistics ----\n");
181 printf("Number of Events = %d\n",nTotEvents);
182 if(nTrigEvents>0){
183 printf("Number of Triggered Events = %d\n",nTrigEvents);
184 nEvents=nTrigEvents;
185 }else{
186 printf("No request on the trigger done when running the task\n");
187 }
188 if(hcllay){
189 Double_t norm=hcllay->GetBinContent(1);
190 if(norm>0.){
191 hcllay->Scale(1./norm);
192 hcllay->SetTitle("");
193 hcllay->GetXaxis()->SetRange(2,7);
194 hcllay->SetMinimum(0.);
195 hcllay->SetMaximum(1.1);
196 hcllay->SetMarkerStyle(23);
1f7d40d1 197 TString ctitle=GetRunNumber()+"General checks: PointPerLayer";
198 TCanvas* ceffL=new TCanvas("ceffL",ctitle,1000,800);
c6f340ff 199 clist[0]=ceffL;
200 // ceffL->Divide(1,2);
201 // ceffL->cd(1);
202 ceffL->SetGridy();
203 hcllay->Draw();
204 TLatex* tg=new TLatex(0.15,0.2,"Fraction of tracks with point in ITS layer");
205 tg->SetTextSize(0.04);
206 tg->SetNDC();
207 tg->SetTextColor(1);
208 tg->Draw();
1f7d40d1 209 TString testo="Run "+GetRunNumber();
210 TLatex* tg2 = new TLatex(0.15,0.85,testo.Data());
211 tg2->SetTextSize(0.04);
212 tg2->SetNDC();
213 tg2->SetTextColor(2);
214 tg2->Draw();
c6f340ff 215 hcllay->GetXaxis()->SetTitle("Layer");
216 hcllay->GetYaxis()->SetTitle("Fraction of tracks with point in layer");
217 ceffL->Update();
218 ceffL->SaveAs("track_points_per_layer.pdf");
e7815454 219 pdfFileNames+=" track_points_per_layer.pdf";
c6f340ff 220 }
221 }
222}
223
224
225//_______________________________________________________________________
226//////////////////////////////////////////////////////////////////////
227/// ITSsa ////////////////////////////////////////////////////////////
228//////////////////////////////////////////////////////////////////////
229 void PlotITSsa(TFile* fildat, TCanvas**& clist, Int_t& cnum){
230 TDirectoryFile* df=(TDirectoryFile*)fildat->Get("TracksITSsa");
231 if(!df) df=(TDirectoryFile*)fildat->Get("ITSsaTracks");
232 if(!df){
233 printf("ITSsa_Performance MISSING -> Exit\n");
234 return;
235 }
236
237 TList* l=(TList*)df->Get("clistITSsaTracks");
238 if(!df){
239 printf("clistITSsaTracks TList MISSING -> Exit\n");
240 return;
241 }
242 cnum=2; // number of canvases
243 clist= new TCanvas* [2];//array of pointers to TCanvases
244 gROOT->SetStyle("Plain");
245 gStyle->SetOptStat(1111);
246
247
248 TH1F* hPtTPCITS=(TH1F*)l->FindObject("hPtTPCITS");
249 TH1F* hPtITSsa=(TH1F*)l->FindObject("hPtITSsa");
250 TH1F* hPtITSpureSA=(TH1F*)l->FindObject("hPtITSpureSA");
251
252 TH2F* hEtaPhiTPCITS=(TH2F*)l->FindObject("hEtaPhiTPCITS");
253 TH2F* hEtaPhiITSsa=(TH2F*)l->FindObject("hEtaPhiITSsa");
254 TH2F* hEtaPhiITSpureSA=(TH2F*)l->FindObject("hEtaPhiITSpureSA");
bd9e89b9 255 TH1F* hChi2TPCITS=(TH1F*)l->FindObject("hChi2TPCITS");
256 TH1F* hChi2ITSsa=(TH1F*)l->FindObject("hChi2ITSsa");
c6f340ff 257
258 TH1F* hRatio=(TH1F*)hPtTPCITS->Clone("hRatio");
259 TH1F* hRatio1=(TH1F*)hPtTPCITS->Clone("hRatio1");
260 hRatio->Add(hPtITSsa);
261 hRatio->Divide(hPtITSpureSA);
262 hRatio->SetStats(0);
263 hRatio1->Divide(hPtITSsa);
264 hRatio1->SetStats(0);
265
1f7d40d1 266 TString ctitle=GetRunNumber()+"ITS standalone: performance vs Pt";
267 TCanvas* cITSsa1=new TCanvas("cITSsa1",ctitle,1200,1200);
c6f340ff 268 clist[0]=cITSsa1;
bd9e89b9 269 cITSsa1->Divide(1,3);
c6f340ff 270 cITSsa1->cd(1);
271 // hPtITSpureSA->Draw();
272 // hPtITSpureSA->GetXaxis()->SetTitle("Pt (GeV/c)");
273 // gPad->Update();
274 // TPaveStats *st1=(TPaveStats*)hPtITSpureSA->GetListOfFunctions()->FindObject("stats");
275 // st1->SetY1NDC(0.71);
276 // st1->SetY2NDC(0.9);
277 hPtTPCITS->SetLineColor(2);
278 hPtTPCITS->GetXaxis()->SetTitle("Pt (GeV/c)");
279 // hPtTPCITS->Draw("sames");
280 hPtTPCITS->Draw();
281 gPad->Update();
282 TPaveStats *st2=(TPaveStats*)hPtTPCITS->GetListOfFunctions()->FindObject("stats");
283 st2->SetY1NDC(0.71);
284 st2->SetY2NDC(0.9);
285 st2->SetTextColor(2);
286
287 hPtITSsa->SetLineColor(4);
288 hPtITSsa->Draw("sames");
289 gPad->Update();
290 TPaveStats *st3=(TPaveStats*)hPtITSsa->GetListOfFunctions()->FindObject("stats");
291 st3->SetY1NDC(0.51);
292 st3->SetY2NDC(0.7);
293 st3->SetTextColor(4);
294 TLegend* leg=new TLegend(0.5,0.5,0.69,0.79);
295 leg->SetFillColor(0);
296 TLegendEntry* ent=leg->AddEntry(hPtTPCITS,"TPC+ITS","L");
297 ent->SetTextColor(hPtTPCITS->GetLineColor());
298 ent=leg->AddEntry(hPtITSsa,"ITSsa","L");
299 ent->SetTextColor(hPtITSsa->GetLineColor());
300 // to be used only with pp data (ITS pure SA)
301 // ent=leg->AddEntry(hPtITSpureSA,"ITS pureSA","L");
302 //ent->SetTextColor(hPtITSpureSA->GetLineColor());
303 leg->Draw();
304 cITSsa1->cd(2);
305 gPad->SetGridx();
306 gPad->SetGridy();
307 hRatio1->GetXaxis()->SetTitle("Pt (GeV/c)");
308 hRatio1->GetYaxis()->SetTitle("TPCITS/ITSsa");
309 // hRatio->GetYaxis()->SetTitle("(TPCITS+ITSsa)/ITSpureSA");
310 hRatio1->DrawCopy();
311 TLatex* tratio=new TLatex(0.2,0.75,"TPC+ITS/ITSsa vs Pt");
312 tratio->SetNDC();
313 tratio->SetTextColor(1);
314 tratio->Draw();
bd9e89b9 315 cITSsa1->cd(3);
316 hChi2ITSsa->Scale(1./hChi2ITSsa->GetEntries());
317 hChi2TPCITS->Scale(1./hChi2TPCITS->GetEntries());
318 hChi2TPCITS->SetLineColor(2);
319 hChi2TPCITS->Draw("");
320 TLatex* tchi=new TLatex(0.25,0.85,"chi2 vs Pt");
321 tchi->SetNDC();
322 tchi->SetTextColor(1);
323 tchi->Draw();
324 gPad->Update();
325 TPaveStats *stc2=(TPaveStats*)hChi2TPCITS->GetListOfFunctions()->FindObject("stats");
326 stc2->SetY1NDC(0.71);
327 stc2->SetY2NDC(0.9);
328 stc2->SetTextColor(2);
329 // c2->Update();
330 hChi2ITSsa->SetLineColor(4);
331 hChi2ITSsa->Draw("sames");
332 gPad->Update();
333 TPaveStats *stc3=(TPaveStats*)hChi2ITSsa->GetListOfFunctions()->FindObject("stats");
334 stc3->SetY1NDC(0.51);
335 stc3->SetY2NDC(0.7);
336 stc3->SetTextColor(4);
337 leg->Draw();
338
c6f340ff 339 cITSsa1->Update();
340 cITSsa1->SaveAs("ITSsa1.pdf");
e7815454 341 pdfFileNames+=" ITSsa1.pdf";
c6f340ff 342 gStyle->SetPalette(1);
343 hEtaPhiITSpureSA->SetStats(0);
344 hEtaPhiITSpureSA->SetTitle("ITS pureSA");
345 hEtaPhiITSsa->SetStats(0);
346 hEtaPhiITSsa->SetTitle("ITSsa tracks");
347 hEtaPhiTPCITS->SetStats(0);
348 hEtaPhiTPCITS->SetTitle("TPC+ITS tracks");
1f7d40d1 349 ctitle=GetRunNumber()+"Eta-phi distribution for ITSsa and TPC+ITS tracks";
350 TCanvas* cITSsa2=new TCanvas("cITSsa2",ctitle,1200,800);
c6f340ff 351 clist[1]=cITSsa2;
352 // cITSsa2->Divide(3,1); for ITSpuresa
353 cITSsa2->Divide(2,1);
354 cITSsa2->cd(1);
355 // TPad* p1=new TPad("p1","Tracking: tracks distribution in EtaPhi",0,0.5,1.,1.);
356 // p1->Divide(3,1);
357 // p1->cd (1);
358 // hEtaPhiITSpureSA->Draw("colz");
359 // hEtaPhiITSpureSA->GetXaxis()->SetTitle("Eta");
360 // hEtaPhiITSpureSA->GetYaxis()->SetTitle("Phi");
361 // cITSsa2->cd(2);
362 // p1->cd(2);
363 hEtaPhiITSsa->Draw("colz");
364 hEtaPhiITSsa->GetXaxis()->SetTitle("Eta");
365 hEtaPhiITSsa->GetYaxis()->SetTitle("Phi");
366 cITSsa2->cd(2);
367 // p1->cd(3);
368 hEtaPhiTPCITS->Draw("colz");
369 hEtaPhiTPCITS->GetXaxis()->SetTitle("Eta");
370 hEtaPhiTPCITS->GetYaxis()->SetTitle("Phi");
371 // c4->cd(4);
372 cITSsa2->SaveAs("ITSsa2.pdf");
e7815454 373 pdfFileNames+=" ITSsa2.pdf";
c6f340ff 374}
375
376//-----------------------------------------------------
377// /////////// Plot SDD ////////////
378//_______________________________________________________________________
379void SetDrawAtt(Int_t markerstyle,Int_t markercolor,Int_t markersize,Int_t linecolor,Int_t linewidth,TH1 *h1){
380
381
382 h1->SetMarkerStyle(markerstyle);
383 h1->SetMarkerColor(markercolor);
384 h1->SetMarkerSize(markersize);
385 h1->SetLineColor(linecolor);
386 h1->SetLineWidth(linewidth);
387}
388
389//_______________________________________________________________________
390Double_t LangausFun(Double_t *x, Double_t *par) {
391
392 //Fit parameters:
393 //par[0]=Width (scale) parameter of Landau density
394 //par[1]=Most Probable (MP, location) parameter of Landau density
395 //par[2]=Total area (integral -inf to inf, normalization constant)
396 //par[3]=Width (sigma) of convoluted Gaussian function
397 //
398 //In the Landau distribution (represented by the CERNLIB approximation),
399 //the maximum is located at x=-0.22278298 with the location parameter=0.
400 //This shift is corrected within this function, so that the actual
401 //maximum is identical to the MP parameter.
402
403 // Numeric constants
404 Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
405 Double_t mpshift = -0.22278298; // Landau maximum location
406
407 // Control constants
408 Double_t np = 100.0; // number of convolution steps
409 Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
410
411 // Variables
412 Double_t xx;
413 Double_t mpc;
414 Double_t fland;
415 Double_t sum = 0.0;
416 Double_t xlow,xupp;
417 Double_t step;
418 Double_t i;
419
420
421 // MP shift correction
422 mpc = par[1] - mpshift * par[0];
423
424 // Range of convolution integral
425 xlow = x[0] - sc * par[3];
426 xupp = x[0] + sc * par[3];
427
428 step = (xupp-xlow) / np;
429
430 // Convolution integral of Landau and Gaussian by sum
431 for(i=1.0; i<=np/2; i++) {
432 xx = xlow + (i-.5) * step;
433 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
434 sum += fland * TMath::Gaus(x[0],xx,par[3]);
435
436 xx = xupp - (i-.5) * step;
437 fland = TMath::Landau(xx,mpc,par[0]) / par[0];
438 sum += fland * TMath::Gaus(x[0],xx,par[3]);
439 }
440
441 return (par[2] * step * sum * invsq2pi / par[3]);
442
443}
444//_________________________________________________________________________
445void PlotSDD(TFile* fildat, TCanvas**& clist, Int_t& cnum){
446 TDirectoryFile* df=(TDirectoryFile*)fildat->Get("SDD_Performance");
447 if(!df){
448 printf("SDD_Performance MISSING -> Exit\n");
449 return;
450 }
451 TList* l=(TList*)df->Get("coutputRP");
452 if(!df){
453 printf("coutputRP TList MISSING -> Exit\n");
454 return;
455 }
456 cnum=1; // number of canvases
457 clist= new TCanvas* [cnum];//array of pointers to TCanvases
458 gROOT->SetStyle("Plain");
459 gStyle->SetOptStat(1111);
460 TH1F* htimT=(TH1F*)l->FindObject("hDrTimTPAll");
461 TH1F* htimTe=(TH1F*)l->FindObject("hDrTimTPExtra");
462 TH1F* htimTne=(TH1F*)l->FindObject("hDrTimTPNoExtra");
463 htimT->Rebin(4);
464 htimTe->Rebin(4);
465 htimTne->Rebin(4);
466 htimT->SetLineWidth(2);
467 htimTe->SetLineWidth(2);
468 htimTne->SetLineWidth(2);
469 // TH1F* hev=(TH1F*)l->FindObject("hNEvents");
470 // Int_t nTotEvents=hev->GetBinContent(2);
471 // Int_t nTrigEvents=hev->GetBinContent(3);
472 // Int_t nEvents=nTotEvents;
473 // printf("---- Statistics ----\n");
474 // printf("Number of Events = %d\n",nTotEvents);
475 // if(nTrigEvents>0){
476 // printf("Number of Triggered Events = %d\n",nTrigEvents);
477 // nEvents=nTrigEvents;
478 // }else{
479 // printf("No request on the trigger done when running the task\n");
480 // }
481 // if(hcllay){
482 // Double_t norm=hcllay->GetBinContent(1);
483 // if(norm>0.){
484 // hcllay->Scale(1./norm);
485 // hcllay->SetTitle("");
486 // hcllay->GetXaxis()->SetRange(2,7);
487 // hcllay->SetMinimum(0.);
488 // hcllay->SetMaximum(1.1);
489 // hcllay->SetMarkerStyle(23);
490 // TCanvas* ceffL=new TCanvas("ceffL","General: PointPerLayer",800,1000);
491 // clist[0]=ceffL;
492 // ceffL->Divide(1,2);
493 // ceffL->cd(1);
494 // ceffL->SetGridy();
495 // hcllay->Draw();
496 // hcllay->GetXaxis()->SetTitle("Layer");
497 // hcllay->GetYaxis()->SetTitle("Fraction of tracks with point in layer");
498 // ceffL->Update();
499 // }
500 // }
501 TH1F* hSigTim[8];
502 TGraphErrors* gmpv=new TGraphErrors(0);
503 TGraphErrors* gsigg=new TGraphErrors(0);
504 TGraphErrors* gsigl=new TGraphErrors(0);
505 gmpv->SetTitle("");
506 gsigg->SetTitle("");
507 gsigl->SetTitle("");
508 Int_t iPoint=0;
509 TF1 *lfun = new TF1("LangausFun",LangausFun,50.,300.,4);
510 for(Int_t it=0; it<8; it++){
511 hSigTim[it]=(TH1F*)l->FindObject(Form("hSigTimeInt%d",it));
512 if(hSigTim[it]->GetEntries()>200){
513 lfun->SetLineWidth(2);
514 lfun->SetParameter(0,5.);
515 lfun->SetParameter(1,80.);
516 lfun->SetParameter(2,hSigTim[it]->GetEntries()/10.);
517 lfun->SetParameter(3,10.);
518 lfun->SetParLimits(3,0.,20);
519
520 // hSigTim[it]->Fit("LangausFun","QLR");
521 hSigTim[it]->Fit("LangausFun","ON");
522 hSigTim[it]->GetXaxis()->SetTitle(Form("dE/dx, time interval %d",it+1));
523 hSigTim[it]->GetYaxis()->SetTitle("Events");
524 Float_t mpv=lfun->GetParameter(1);
525 Float_t empv=lfun->GetParError(1);
526 Float_t sig=lfun->GetParameter(3);
527 Float_t esig=lfun->GetParError(3);
528 Float_t sigl=lfun->GetParameter(0);
529 Float_t esigl=lfun->GetParError(0);
530 gmpv->SetPoint(iPoint,(Float_t)it,mpv);
531 gmpv->SetPointError(iPoint,0.,empv);
532 gsigg->SetPoint(iPoint,(Float_t)it,sig);
533 gsigg->SetPointError(iPoint,0.,esig);
534 gsigl->SetPoint(iPoint,(Float_t)it,sigl);
535 gsigl->SetPointError(iPoint,0.,esigl);
536 ++iPoint;
537 printf("Bin %d - MPV=%.3f \t SigmaLandau=%.3f \t SigmaGaus=%.3f\n",it,mpv,sigl,sig);
538 }
539 }
1f7d40d1 540 TString ctitle=GetRunNumber()+"SDD: DriftTime - dE/dx";
541 TCanvas* ctim=new TCanvas("ctim",ctitle,800,1000);
c6f340ff 542 clist[0]=ctim;
543 ctim->Divide(1,2);
544 ctim->cd(1);
545 // htimT->Draw();
546 // htimTe->SetLineColor(2);
547 // htimTe->Draw("same");
548 htimTne->SetLineColor(4);
549 htimTne->Draw("");
550 htimTne->GetXaxis()->SetTitle("Drift Time (ns)");
551 htimTne->GetYaxis()->SetTitle("TrackPoints");
552 htimTne->GetYaxis()->SetTitleOffset(1.2);
553 // TLatex* ta=new TLatex(0.5,0.85,"All Clusters");
554 // ta->SetNDC();
555 // ta->SetTextColor(1);
556 // ta->Draw();
557 // TLatex* te=new TLatex(0.5,0.8,"Extra Clusters");
558 // te->SetNDC();
559 // te->SetTextColor(2);
560 // te->Draw();
561 // TLatex* tn=new TLatex(0.3,0.3,"Non-Extra Clusters");
562 TLatex* tn=new TLatex(0.3,0.3,"Clusters on SDD modules");
563 tn->SetNDC();
564 tn->SetTextColor(4);
565 tn->Draw();
566 TLine* tlin3=new TLine(450.,0.,450.,htimTne->GetMaximum());
567 tlin3->SetLineColor(2);
568 tlin3->SetLineWidth(2);
569 tlin3->SetLineStyle(7);
570 tlin3->Draw("same");
571 TLine* tlin4=new TLine(620.,0.,620.,htimTne->GetMaximum());
572 tlin4->SetLineColor(2);
573 tlin4->SetLineWidth(2);
574 tlin4->SetLineStyle(7);
575 tlin4->Draw("same");
576 TLatex* tlimit1=new TLatex(0.2,0.5,"Range for t0");
577 tlimit1->SetNDC();
578 tlimit1->SetTextColor(2);
579 tlimit1->Draw();
580 TLine* tlin5=new TLine(6200.,0.,6200.,htimTne->GetMaximum());
581 tlin5->SetLineColor(2);
582 tlin5->SetLineStyle(7);
583 tlin5->SetLineWidth(2);
584 tlin5->Draw("same");
585 TLine* tlin6=new TLine(5150.,0.,5150.,htimTne->GetMaximum());
586 tlin6->SetLineColor(2);
587 tlin6->SetLineWidth(2);
588 tlin6->SetLineStyle(7);
589 tlin6->Draw("same");
590 TLatex* tlimit2=new TLatex(0.6,0.5,"Range for falling edge");
591 tlimit2->SetNDC();
592 tlimit2->SetTextColor(2);
593 tlimit2->Draw();
594
595 // ctim->Update();
596 // TCanvas* cpars=new TCanvas("cpars","Params",800,600);
597 ctim->cd(2);
598 gPad->SetLeftMargin(0.14);
599 gPad->SetFrameLineWidth(2);
600 gPad->SetTickx();
601 gPad->SetTicky();
602 gmpv->SetMarkerStyle(20);
603 gmpv->SetMinimum(75);
604 gmpv->SetMaximum(90);
605 gmpv->GetXaxis()->SetLimits(-0.2,6.8);
606 gmpv->Draw("AP");
607 gmpv->GetXaxis()->SetTitle("Drift Time interval number");
608 gmpv->GetYaxis()->SetTitle("Landau MPV (keV)");
609 gmpv->GetXaxis()->SetTitleSize(0.05);
610 gmpv->GetYaxis()->SetTitleSize(0.05);
611 gmpv->GetYaxis()->SetTitleOffset(1.2);
612 TLatex* tex=new TLatex(0.2,0.75,"dE/dx MPV vs Drift time interval");
613 tex->SetNDC();
614 tex->SetTextColor(1);
615 tex->Draw();
616 // cpars->Update();
617 ctim->Update();
618 ctim->SaveAs("SDD.pdf");
e7815454 619 pdfFileNames+=" SDD.pdf";
c6f340ff 620}
621
622//_______________________________________________________________________
623//////////////// SSD ///////////////////////
624//_______________________________________________________________________
625void GetGainModuleLevelSSD(TFile* fildat, TCanvas**& clist, Int_t& cnum)
626{
627 gROOT->SetStyle("Plain");
628 gStyle->SetOptStat(1111);
629 gStyle->SetPalette(1,0);
630 cnum=1;
631 clist=new TCanvas*[1];
632
2bfe5463 633 TDirectoryFile* df=(TDirectoryFile*)fildat->Get("PWGPPdEdxSSDQA");
c6f340ff 634 TList* listin=(TList*)df->Get("SSDdEdxQA");
635 if(!listin) return;
636 TH2F* fHistQ=0x0;
637 fHistQ=(TH2F*)listin ->FindObject("QACharge");
638 fHistQ->SetStats(111);
639 fHistQ->SetTitle("SSD Charge vs module number");
640if(!fHistQ) return;
641 TH2F* fHistCR=(TH2F*)listin ->FindObject("QAChargeRatio");
642 fHistCR->SetStats(0);
643 fHistCR->SetTitle("SSD Charge Ratio vs module number");
644
645 if(!fHistCR) return;
646
647 TH1F* fHistMPVs=new TH1F("SSD HistMPVS","HistMPVs;MPV;N",75,70,95);
648
649 TH1F* fHistCRmean=new TH1F("SSD HistCRmean","HistCRmean;CRmean;N",200,-1,1);
650
651 TH1F *fMPVGraph = new TH1F("SSD MPV","MPVgraph;Module number;MPV",1698,-0.5,1697.5);
652 fMPVGraph->SetMarkerColor(kRed);
653 fMPVGraph->SetMarkerSize(0.5);
654 fMPVGraph->SetMarkerStyle(22);
655 fMPVGraph->SetStats(111111);
656
657 TH1F *fCRmeanGraph = new TH1F("SSD CRmeangraph","CRmeangraph;Module number;MPV",1698,-0.5,1697.5);
658 fCRmeanGraph->SetMarkerColor(kBlue);
659 fCRmeanGraph->SetMarkerSize(0.5);
660 fCRmeanGraph->SetMarkerStyle(23);
661 fCRmeanGraph->SetStats(111111);
662
663 Float_t mpv[1698];
664 Int_t ntofit=200;
665
666 // ofstream outfiletxtbad;
667 //outfiletxtbad.open("QALHC11eCPass1_bis/badModules.txt");
668 for (int i =0;i<1698;i++)
669 {
670 // cout<<i<<endl;
671 TString tmpQ("Q");
672 tmpQ+=i;
673 TString tmpCR("CR");
674 tmpCR+=i;
675 TH1D* fHist1DCR= fHistCR->ProjectionY(tmpCR,i+1,i+1);
676 Double_t mean=fHist1DCR->GetMean();
677 if(!(TMath::Abs(mean)<1.0)||fHist1DCR->GetEntries()<10)
678 continue;
679 fHistCRmean->Fill(mean);
680 fCRmeanGraph->SetBinContent(i+1,mean);
681 fCRmeanGraph->SetBinError(i+1,fHist1DCR->GetRMS());
682 fCRmeanGraph->GetYaxis()->SetTitle("CR");
683 TH1D* fHist1DQ=fHistQ->ProjectionY(tmpQ,i+1,i+1);
684 //check bad modules
685 if(fHist1DQ->GetEntries()<ntofit)
686 {
687 //outfiletxtbad<<"Low statistic \t module= "<<i<<" netries="<<fHist1DQ->GetEntries()<<endl;
688 continue;
689 }
690 else
691 {
692 tmpQ+="fit";
693 Float_t range=fHist1DQ->GetBinCenter(fHist1DQ->GetMaximumBin());
694 TF1 *f1 = new TF1(tmpQ,LangausFun,range*0.45,range*3.0,4);
695 f1->SetParameters(7.0,range,1.0,5.5);
696 Float_t normalization=fHist1DQ->GetEntries()*fHist1DQ->GetXaxis()->GetBinWidth(2)/f1->Integral(range*0.45,range*3.0);
697 f1->SetParameters(7.0,range,normalization,5.5);
698 //f1->SetParameters(7.0,range,fHist1DQ->GetMaximum(),5.5);
699 f1->SetParNames("sigma Landau","MPV","N","sigma Gaus");
700 f1->SetParLimits(0,2.0,100.0);
701 f1->SetParLimits(3,0.0,100.0);
702 if(fHist1DQ->Fit(tmpQ,"BRQON")==0)
703 {
704 mpv[i]=f1->GetParameter(1);
705 fHistMPVs->Fill(mpv[i]);
706 fMPVGraph->SetBinContent(i+1,f1->GetParameter(1));
707 fMPVGraph->SetBinError(i+1,f1->GetParError(1));
708 if(mpv[i]<75.0)
709 {
710 //outfiletxtbad<<"MPV lower than 75 \t module="<<i<<endl;
711 }
712 if(mpv[i]>100.0)
713 {
714 // outfiletxtbad<<"MPV higher than 100 \t module="<<i<<endl;
715 }
716 if(f1->GetParError(1)>1.0)
717 {
718 //outfiletxtbad<<"MPV high error on MPV \t module="<<i<<endl;
719 }
720 }
721 else
722 {
723 mpv[i]=1;
724 //outfiletxtbad<<"BAD FIT \t module="<<i<<endl;
725 continue;
726 }
727 }
728 }
729
1f7d40d1 730 TString ctitle=GetRunNumber()+"SSD Calibration 1";
731 TCanvas *c1SSD = new TCanvas("c1SSD",ctitle,1000,1000);
c6f340ff 732 clist[0]=c1SSD;
733 c1SSD->Divide(2,3);
734 c1SSD->cd(1);
735 fHistQ->DrawCopy("colz");
736 c1SSD->cd(2);
737 fHistCR->DrawCopy("colz");
738
739 // TCanvas *c2SSD = new TCanvas("c2SSD","SSD Calibration 2",1000,1000);
740 //clist[1]=c2SSD;
741 //c2SSD->Divide(2,2);
742 c1SSD->cd(3);
743 fMPVGraph->DrawCopy();
744 TLine* tlin0=new TLine(0.,80.,1698.,80.);
745 tlin0->SetLineColor(2);
746 tlin0->SetLineWidth(2);
747 tlin0->Draw("same");
748 TLine* tlin01=new TLine(0.,90.,1698.,90.);
749 tlin01->SetLineColor(2);
750 tlin01->SetLineWidth(2);
751 tlin01->Draw("same");
752 c1SSD->cd(4);
753 fHistMPVs->DrawCopy();
754 c1SSD->cd(5);
755 fCRmeanGraph->DrawCopy();
756 TLine* tlin1=new TLine(0.,0.2,1698.,0.2);
757 tlin1->SetLineColor(2);
758 tlin1->SetLineWidth(2);
759 tlin1->Draw("same");
760 TLine* tlin2=new TLine(0.,-0.2,1698.,-0.2);
761 tlin2->SetLineColor(2);
762 tlin2->SetLineWidth(2);
763 tlin2->Draw("same");
764 TLatex* ta1=new TLatex(0.2,0.8,"SSD Calibration");
765 ta1->SetNDC();
766 ta1->SetTextSize(0.05);
767 ta1->SetTextColor(2);
768 ta1->Draw("same");
769 c1SSD->cd(6);
770 fHistCRmean->DrawCopy();
771 c1SSD->Update();
772 c1SSD->SaveAs("SSD.pdf");
e7815454 773 pdfFileNames+=" SSD.pdf";
c6f340ff 774}
775
776//_______________________________________________________________________
777void VertexQAMacro(TFile *fildat, TCanvas **&clist, Int_t &cnum){
778
779 TDirectoryFile *dir = (TDirectoryFile*)fildat->Get("Vertex_Performance");
780 if(!dir){
781 Printf("Vertex directory not found... check!");
782 }
783
784 TList *lt = (TList*)dir->Get("cOutputVtxESD");
785
786 cnum = 1;
787 clist = new TCanvas*[1];
788
789
790 TH1F *xVtxSPD = (TH1F*)lt->FindObject("fhSPDVertexX");
791 TH1F *yVtxSPD = (TH1F*)lt->FindObject("fhSPDVertexY");
792 TH1F *zVtxSPD = (TH1F*)lt->FindObject("fhSPDVertexZ");
793
794 TH1F *zVtxSPD_Zonly = (TH1F*)lt->FindObject("fhSPDVertexZonly");
795
796 if(!zVtxSPD_Zonly){
797 Printf("using SPD 3D histo, Zonly not available");
798 zVtxSPD_Zonly = (TH1F*)lt->FindObject("fhSPDVertexZ");
799 }
800
801 TH1F *xVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexX");
802 TH1F *yVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexY");
803 TH1F *zVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexZ");
804
805 TH2F *hntrksSPDvsSPDcls = (TH2F*)lt->FindObject("fhntrksSPDvsSPDcls");
806 TH2F *hntrksZvsSPDcls = (TH2F*)lt->FindObject("fhntrksZvsSPDcls");
807
808 Bool_t histoCorelation = kTRUE;
809
810 if(!hntrksZvsSPDcls){
811 Printf("skipping the second part, no 2D histos available");
812 histoCorelation=kFALSE;
813 }
1f7d40d1 814
815 TString ctitle=GetRunNumber()+"TRKandSPD3DxVtx";
816 TCanvas *TRK_SPD3D_Vtx = new TCanvas("TRKandSPD3DVtx",ctitle,1000,1000);
c6f340ff 817 TRK_SPD3D_Vtx->Divide(3,2);
818 clist[0]=TRK_SPD3D_Vtx;
819 gStyle->SetOptFit(111);
820
821 TRK_SPD3D_Vtx->cd(1);
822 xVtxSPD->SetMarkerStyle(20);
823 xVtxSPD->SetLineWidth(3);
824 xVtxSPD->SetMarkerColor(kBlue+2);
825 TF1 *fx = new TF1("gaus", "gaus", -1, 1);
826 xVtxTRK->SetMarkerStyle(20);
827 xVtxTRK->SetLineWidth(4);
828 xVtxTRK->SetLineColor(2);
829 xVtxTRK->Draw("PE");
830 xVtxTRK->Fit("gaus", "M");
831 xVtxSPD->Draw("PE SAME");
832 xVtxTRK->GetXaxis()->SetRangeUser(-0.05, 0.15);
833 xVtxSPD->GetXaxis()->SetRangeUser(-0.05, 0.15);
834
835 TLatex* tVTX1=new TLatex(0.15,0.85,"VertexSPD");
836 tVTX1->SetNDC();
837 tVTX1->SetTextColor(kBlue+2);
838 tVTX1->Draw();
839 TLatex* tVTX2=new TLatex(0.15,0.8,"VertexTRK");
840 tVTX2->SetNDC();
841 tVTX2->SetTextColor(2);
842 tVTX2->Draw();
843
844 TRK_SPD3D_Vtx->cd(2);
845 yVtxSPD->SetMarkerStyle(20);
846 yVtxSPD->SetLineWidth(3);
847 yVtxSPD->SetMarkerColor(kBlue+2);
848 TF1 *fy = new TF1("gaus", "gaus", -1, 1);
849 yVtxTRK->SetMarkerStyle(20);
850 yVtxTRK->SetLineWidth(3);
851 yVtxTRK->SetLineColor(2);
852 yVtxTRK->Draw("PE");
853 yVtxTRK->Fit("gaus", "M");
854 yVtxSPD->Draw("PE SAME");
855 yVtxTRK->GetXaxis()->SetRangeUser(0.15, 0.4);
856 yVtxSPD->GetXaxis()->SetRangeUser(0.15, 0.4);
857
858 TLatex* tVTX3=new TLatex(0.15,0.85,"VertexSPD");
859 tVTX3->SetNDC();
860 tVTX3->SetTextColor(kBlue+2);
861 tVTX3->Draw();
862 TLatex* tVTX4=new TLatex(0.15,0.8,"VertexTRK");
863 tVTX4->SetNDC();
864 tVTX4->SetTextColor(2);
865 tVTX4->Draw();
866
867
868
869 TRK_SPD3D_Vtx->cd(3);
870
871 TF1 *fz = new TF1("gaus", "gaus", -20, 20);
872 zVtxTRK->SetMarkerStyle(20);
873 zVtxTRK->SetLineWidth(3);
874 zVtxTRK->SetMarkerColor(2);
875 zVtxTRK->SetLineColor(2);
876 zVtxTRK->Draw("PE");
877 zVtxTRK->Fit("gaus", "M");
878 zVtxSPD->SetMarkerStyle(20);
879 zVtxSPD->SetLineWidth(1);
880 zVtxSPD->SetLineColor(kBlue+2);
881 zVtxSPD->SetMarkerColor(kBlue+2);
882 zVtxSPD->SetMarkerSize(0.8);
883 zVtxSPD->Draw("PE SAME");
884 TLatex* tVTX5=new TLatex(0.15,0.85,"VertexSPD");
885 tVTX5->SetNDC();
886 tVTX5->SetTextColor(kBlue+2);
887 tVTX5->Draw();
888 TLatex* tVTX6=new TLatex(0.15,0.8,"VertexTRK");
889 tVTX6->SetNDC();
890 tVTX6->SetTextColor(2);
891 tVTX6->Draw();
892
893
894
895 // TCanvas *corrContrSPDClusters = new TCanvas("corrContrSPDClusters", "corrContrSPDClusters");
896 // corrContrSPDClusters->Divide(3,1);
897 //clist[1]=corrContrSPDClusters;
898 TRK_SPD3D_Vtx->cd(4);
899 // corrContrSPDClusters->cd(1);
900 zVtxSPD_Zonly->SetLineWidth(3);
901 zVtxSPD_Zonly->SetLineColor(kBlue+2);
902 zVtxSPD_Zonly->Draw();
903 TLatex* tVTX7=new TLatex(0.15,0.8,"Vertex Z only");
904 tVTX7->SetNDC();
905 tVTX7->SetTextColor(2);
906 tVTX7->Draw();
907
908 if(histoCorelation){
909 TRK_SPD3D_Vtx->cd(5);
910 //corrContrSPDClusters->cd(2);
911 hntrksSPDvsSPDcls->SetMarkerStyle(20);
912 hntrksSPDvsSPDcls->Draw();
913
914 TRK_SPD3D_Vtx->cd(6);
915 // corrContrSPDClusters->cd(3);
916 hntrksZvsSPDcls->SetMarkerStyle(20);
917 hntrksZvsSPDcls->Draw();
918 }
919 TRK_SPD3D_Vtx->SaveAs("vertex.pdf");
e7815454 920 pdfFileNames+=" vertex.pdf";
c6f340ff 921 delete fx;
922 delete fy;
923 delete fz;
924}
925
926//_______________________________________________________________________
927void PlotSPD(TFile *fildat, TFile *filMC, TCanvas **&clist, Int_t &cnum){
928
929 gROOT->SetStyle("Plain");
930 gStyle->SetPalette(1);
931 gStyle->SetOptStat(0);
932 gStyle->SetOptFit(111);
933 cnum=2; // number of canvases
934 clist= new TCanvas* [2];//array of pointers to TCanvases
935
936 TDirectoryFile *spddata = (TDirectoryFile*)fildat->Get("SPD_Performance");
937 spddata->cd();
938 TList *fListData = (TList*)spddata->Get("coutput1");
939
940 TString fTitleData = "Data";
941 TString fTitleMc = "MC";
942
943
944 Double_t nevtsData = ((TH1I*)(fListData->FindObject("hEventsProcessed")))->GetEntries();
945 printf(" #events in %s : %f \n",fTitleData.Data(),nevtsData);
946
947 TDirectoryFile *spdmc = (TDirectoryFile*)filMC->Get("SPD_Performance");
948 spdmc->cd();
949 TList *fListMc = (TList*)spdmc->Get("coutput1");
950 Double_t nevtsMc = ((TH1I*)(fListMc->FindObject("hEventsProcessed")))->GetEntries();
951 printf(" #events in %s : %f \n",fTitleMc.Data(),nevtsMc);
bd9e89b9 952
c6f340ff 953 TH2F *trackData = (TH2F*)fListData->FindObject("hSPDphivsSPDeta");
954 trackData->SetTitle(Form("%s %s",trackData->GetTitle(),fTitleData.Data()));
955 TH1D *trackDataPhi = trackData->ProjectionY();
956 if(!trackDataPhi) printf("NO 1 \n");
bd9e89b9 957
c6f340ff 958 trackDataPhi->SetTitle("Tracklets vs Phi");
c6f340ff 959 TH1D *trackDataEta = trackData->ProjectionX();
960 if(!trackDataEta) printf("NO 2 \n");
961 trackDataEta->SetTitle("Tracklets vs eta");
c6f340ff 962
963 TH1F etaData, phiData;
964 trackDataEta->Copy(etaData);
965 trackDataPhi->Copy(phiData);
bd9e89b9 966
c6f340ff 967 TH1F etaFrac, phiFrac, mcEta, mcPhi;
968 trackDataEta->Copy(etaFrac);
969 trackDataPhi->Copy(phiFrac);
970
971 TH2F *trackMc = (TH2F*)fListMc->FindObject("hSPDphivsSPDeta");
972 trackMc->SetTitle(Form("%s %s",trackMc->GetTitle(),fTitleMc.Data()));
973
1f7d40d1 974 TString ctitle = GetRunNumber()+"tracklets";
975 TCanvas *tracklets = new TCanvas("tracklets",ctitle,1200,600);
c6f340ff 976 clist[0]=tracklets;
977 tracklets->Divide(2,1);
978 tracklets->cd(1);
979 tracklets->cd(1)->SetRightMargin(0.15);
bd9e89b9 980 trackData->SetTitle(Form("Run %d",gRunNumber));
c6f340ff 981 trackData->DrawCopy("colz");
982 tracklets->cd(2);
983 tracklets->cd(2)->SetRightMargin(0.15);
bd9e89b9 984 trackMc->SetTitle(Form("Run %d",gRunNumberMC));
c6f340ff 985 TH1D *h = (TH1D*)trackMc->DrawCopy("colz");
c6f340ff 986 tracklets->SaveAs("SPDtracklets.pdf");
e7815454 987 pdfFileNames+=" SPDtracklets.pdf";
c6f340ff 988
989 TH1D *trackMcPhi = trackMc->ProjectionY();
990 trackMcPhi->SetTitle(Form("%s",h->GetTitle()));
c6f340ff 991 TH1D *trackMcEta = trackMc->ProjectionX();
992 trackMcEta->SetTitle(Form("%s",h->GetTitle()));
c6f340ff 993
994 TH1F etaMc, phiMc;
995 trackMcEta->Copy(etaMc);
996 trackMcPhi->Copy(phiMc);
997
998 trackMcEta->Copy(mcEta);
999 trackMcPhi->Copy(mcPhi);
1000
1001 etaFrac.Scale(1./etaFrac.GetEntries());
1002 mcEta.Scale(1./mcEta.GetEntries());
1003 etaFrac.Add(&mcEta,-1);
1004 etaFrac.Divide(&mcEta);
1005
1006 phiFrac.Scale(1./phiFrac.GetEntries());
1007 mcPhi.Scale(1./mcPhi.GetEntries());
1008 phiFrac.Add(&mcPhi,-1);
1009 phiFrac.Divide(&mcPhi);
1010
1f7d40d1 1011 ctitle = GetRunNumber()+"tracklets and ratios vs eta and phi";
1012 TCanvas *track = new TCanvas("track",ctitle,1200,1200);
c6f340ff 1013 clist[1]=track;
1014 track->Divide(2,2);
1015 track->cd(1);
1016 phiData.SetLineColor(kRed);
1017 phiData.SetLineWidth(2);
1018 phiData.Scale(1./phiData.GetEntries());
1019 phiData.DrawCopy();
1020 phiMc.Scale(1./phiMc.GetEntries());
bd9e89b9 1021 TLatex* tphi=new TLatex(0.5,0.85,Form("Red = %d; Blue = %d",gRunNumber,gRunNumberMC));
c6f340ff 1022 tphi->SetNDC();
1023 tphi->SetTextSize(0.04);
1024 tphi->SetTextColor(1);
1025 tphi->Draw();
1026 phiMc.DrawCopy("same");
1027 track->cd(2);
1028 etaData.SetLineColor(kRed);
1029 etaData.SetLineWidth(2);
1030 etaData.Scale(1./etaData.GetEntries());
1031 etaData.DrawCopy();
1032 etaMc.Scale(1./etaMc.GetEntries());
1033 tphi->Draw();
1034 etaMc.DrawCopy("same");
eb74d031 1035 track->cd(3);
c6f340ff 1036 phiFrac.SetLineColor(1);
bd9e89b9 1037 TLatex* tratio=new TLatex(0.2,0.85,Form("Run %d / Run %d",gRunNumber,gRunNumberMC));
c6f340ff 1038 tratio->SetNDC();
c6f340ff 1039 tratio->SetTextColor(1);
1040 phiFrac.DrawCopy();
1041 tratio->Draw();
1042 track->cd(4);
c6f340ff 1043 etaFrac.SetLineColor(1);
1044 etaFrac.DrawCopy();
c6f340ff 1045 tratio->Draw();
1046 track->SaveAs("SPD_eta_phi.pdf");
e7815454 1047 pdfFileNames+=" SPD_eta_phi.pdf";
c6f340ff 1048}
1049
1050//_______________________________________________________________________
1051Bool_t PlotITSTPCMatchingEff(TFile *f, TCanvas**& clist,Int_t& cnum) {
1052
1053 cnum=1;
1054 clist = new TCanvas*[1];
1055
1056 // clist = new TCanvas* [1];
1f7d40d1 1057 TString ctitle = GetRunNumber()+"ITS-TPC match";
1058 TCanvas* cITSTPCmatch = new TCanvas("cITSTPCmatch",ctitle,10,10,1200,600);
c6f340ff 1059 clist[0]=cITSTPCmatch;
1060 cITSTPCmatch->Divide(2,1);
1061 cITSTPCmatch->cd(1);
1062 gPad->SetGridy();
1063 gPad->SetLogx();
1064 cITSTPCmatch->cd(2);
1065 gPad->SetGridy();
1066 gPad->SetLogx();
1067
1068 // clist = cITSTPCmatch;
1069
1070 if(!f) return kFALSE;
1071
1072 TList *list=0;
1073 TList *listSPD=0;
1074 TDirectoryFile *dir=0;
1075
1076 // count active SPD HSs
1077 dir=(TDirectoryFile*)f->GetDirectory("SPD_Performance");
1078 if(dir) listSPD = (TList*)dir->Get("coutput1");
1079 if(!dir) return kFALSE;
1080
1081 Float_t spdFrac[2]={0.,0.};
1082 TH1F *hnHSsSPD=new TH1F("hnHSsSPD","Active HSs in SPD layers 1 and 2; layer; HSs",2,0.5,2.5);
1083 if(listSPD) {
1084 //listSPD->Print();
1085 TH1F *hFiredChip = (TH1F*)listSPD->FindObject("hFiredChip");
1086 Int_t nHSsInner=0,nHSsOuter=0;
1087 for(Int_t i=0;i<400;i++) if(hFiredChip->GetBinContent(i)>0) nHSsInner++;
1088 for(Int_t i=400;i<1200;i++) if(hFiredChip->GetBinContent(i)>0) nHSsOuter++;
1089 nHSsInner = (Int_t)(nHSsInner/10);
1090 nHSsOuter = (Int_t)(nHSsOuter/10);
1091 hnHSsSPD->SetBinContent(1,nHSsInner);
1092 hnHSsSPD->SetBinContent(2,nHSsOuter);
1093 spdFrac[0]=(Float_t)nHSsInner/40.;
1094 spdFrac[1]=(Float_t)nHSsOuter/80.;
1095 }
1096 TGraph *spdFrac0=new TGraph(1);
1097 spdFrac0->SetPoint(0,0.08,spdFrac[0]);
1098 spdFrac0->SetMarkerColor(1); spdFrac0->SetMarkerStyle(20);
1099 TGraph *spdFrac1=new TGraph(1);
1100 spdFrac1->SetPoint(0,0.08,spdFrac[1]);
1101 spdFrac1->SetMarkerColor(1); spdFrac1->SetMarkerStyle(24);
1102 TLegend *l2=new TLegend(0.1,0.62,0.5,0.93);
1103 l2->SetBorderSize(1);
1104 l2->AddEntry(spdFrac0,"Frac. active SPD0","p");
1105 l2->AddEntry(spdFrac1,"Frac. active SPD1","p");
1106
1107 //
1108 // Efficiencies for CENTRAL
1109 //
1110 dir=(TDirectoryFile*)f->GetDirectory("ITS_Performance");
1111 if(dir) list = (TList*)dir->Get("cOutputITS_3500_10000");
1112 if(!list) return kFALSE;
1113
1114 TH1F *fHistPtTPCInAcc = (TH1F*)list->FindObject("fHistPtTPCInAcc");
1115 TH1F *fHistPtITSMI6InAcc = (TH1F*)list->FindObject("fHistPtITSMI6InAcc");
1116 TH1F *fHistPtITSMI5InAcc = (TH1F*)list->FindObject("fHistPtITSMI5InAcc");
1117 TH1F *fHistPtITSMI4InAcc = (TH1F*)list->FindObject("fHistPtITSMI4InAcc");
1118 TH1F *fHistPtITSMI3InAcc = (TH1F*)list->FindObject("fHistPtITSMI3InAcc");
1119 TH1F *fHistPtITSMI2InAcc = (TH1F*)list->FindObject("fHistPtITSMI2InAcc");
1120 TH1F *fHistPtITSMISPDInAcc = (TH1F*)list->FindObject("fHistPtITSMISPDInAcc");
1121 TH1F *fHistPtITSMIoneSPDInAcc = (TH1F*)list->FindObject("fHistPtITSMIoneSPDInAcc");
1122 TH1F *fHistPtITSTPCsel = (TH1F*)list->FindObject("fHistPtITSTPCsel");
1123 TH1F *fHistPtITSMIge2InAcc = (TH1F*)fHistPtITSMI6InAcc->Clone("fHistPtITSMIge2InAcc");
1124 fHistPtITSMIge2InAcc->Add(fHistPtITSMI5InAcc);
1125 fHistPtITSMIge2InAcc->Add(fHistPtITSMI4InAcc);
1126 fHistPtITSMIge2InAcc->Add(fHistPtITSMI3InAcc);
1127 fHistPtITSMIge2InAcc->Add(fHistPtITSMI2InAcc);
1128
1129
1130 TLegend *l3=new TLegend(0.5,0.62,0.95,0.93);
1131 l3->SetBorderSize(1);
1132 cITSTPCmatch->cd(1);
1133 fHistPtITSMIge2InAcc->SetTitle("Fraction of prolonged tracks with N ITS points: central");
1134 fHistPtITSMIge2InAcc->SetYTitle("ITS+TPC / TPC");
1135 fHistPtITSMIge2InAcc->Divide(fHistPtITSMIge2InAcc,fHistPtTPCInAcc,1,1,"B");
1136 fHistPtITSMIge2InAcc->SetMaximum(1.6);
1137 fHistPtITSMIge2InAcc->SetMinimum(0);
1138 fHistPtITSMIge2InAcc->GetXaxis()->SetRangeUser(0.1,30);
1139 fHistPtITSMIge2InAcc->Draw();
1140 l3->AddEntry(fHistPtITSMIge2InAcc,">=2 cls","l");
1141 fHistPtITSMI6InAcc->Divide(fHistPtITSMI6InAcc,fHistPtTPCInAcc,1,1,"B");
1142 fHistPtITSMI6InAcc->SetLineColor(2);
1143 l3->AddEntry(fHistPtITSMI6InAcc,"6 cls","l");
1144 fHistPtITSMI6InAcc->Draw("same");
1145 fHistPtITSMI5InAcc->Divide(fHistPtITSMI5InAcc,fHistPtTPCInAcc,1,1,"B");
1146 fHistPtITSMI5InAcc->SetLineColor(3);
1147 l3->AddEntry(fHistPtITSMI5InAcc,"5 cls","l");
1148 fHistPtITSMI5InAcc->Draw("same");
1149 fHistPtITSMI4InAcc->Divide(fHistPtITSMI4InAcc,fHistPtTPCInAcc,1,1,"B");
1150 fHistPtITSMI4InAcc->SetLineColor(4);
1151 l3->AddEntry(fHistPtITSMI4InAcc,"4 cls","l");
1152 fHistPtITSMI4InAcc->Draw("same");
1153 fHistPtITSMI3InAcc->Divide(fHistPtITSMI3InAcc,fHistPtTPCInAcc,1,1,"B");
1154 fHistPtITSMI3InAcc->SetLineColor(6);
1155 l3->AddEntry(fHistPtITSMI3InAcc,"3 cls","l");
1156 fHistPtITSMI3InAcc->Draw("same");
1157 fHistPtITSMI2InAcc->Divide(fHistPtITSMI2InAcc,fHistPtTPCInAcc,1,1,"B");
1158 fHistPtITSMI2InAcc->SetLineColor(7);
1159 l3->AddEntry(fHistPtITSMI2InAcc,"2 cls","l");
1160 fHistPtITSMI2InAcc->Draw("same");
1161 fHistPtITSMISPDInAcc->Divide(fHistPtITSMISPDInAcc,fHistPtTPCInAcc,1,1,"B");
1162 fHistPtITSMISPDInAcc->SetLineColor(9);
1163 l3->AddEntry(fHistPtITSMISPDInAcc,"2SPD + any","l");
1164 fHistPtITSMISPDInAcc->Draw("same");
1165 fHistPtITSMIoneSPDInAcc->Divide(fHistPtITSMIoneSPDInAcc,fHistPtTPCInAcc,1,1,"B");
1166 fHistPtITSMIoneSPDInAcc->SetLineColor(15);
1167 l3->AddEntry(fHistPtITSMIoneSPDInAcc,">=1SPD + any","l");
1168 fHistPtITSMIoneSPDInAcc->Draw("same");
1169 fHistPtITSTPCsel->Divide(fHistPtITSTPCsel,fHistPtTPCInAcc,1,1,"B");
1170 fHistPtITSTPCsel->SetLineColor(kAzure+1);
1171 l3->AddEntry(fHistPtITSTPCsel,">=1SPD + any + d_{0} cut","l");
1172 fHistPtITSTPCsel->Draw("same");
1173 fHistPtITSMIge2InAcc->Draw("same");
1174 l3->Draw();
1175 l2->Draw();
1176 spdFrac0->Draw("p");
1177 spdFrac1->Draw("p");
1178
1179 //
1180 // Efficiencies for PERIPHERAL
1181 //
1182 dir=(TDirectoryFile*)f->GetDirectory("ITS_Performance");
1183 if(dir) list = (TList*)dir->Get("cOutputITS_70_310");
1184 if(!list) return kFALSE;
1185
1186 fHistPtTPCInAcc = (TH1F*)list->FindObject("fHistPtTPCInAcc");
1187 fHistPtITSMI6InAcc = (TH1F*)list->FindObject("fHistPtITSMI6InAcc");
1188 fHistPtITSMI5InAcc = (TH1F*)list->FindObject("fHistPtITSMI5InAcc");
1189 fHistPtITSMI4InAcc = (TH1F*)list->FindObject("fHistPtITSMI4InAcc");
1190 fHistPtITSMI3InAcc = (TH1F*)list->FindObject("fHistPtITSMI3InAcc");
1191 fHistPtITSMI2InAcc = (TH1F*)list->FindObject("fHistPtITSMI2InAcc");
1192 fHistPtITSMISPDInAcc = (TH1F*)list->FindObject("fHistPtITSMISPDInAcc");
1193 fHistPtITSMIoneSPDInAcc = (TH1F*)list->FindObject("fHistPtITSMIoneSPDInAcc");
1194 fHistPtITSTPCsel = (TH1F*)list->FindObject("fHistPtITSTPCsel");
1195 fHistPtITSMIge2InAcc = (TH1F*)fHistPtITSMI6InAcc->Clone("fHistPtITSMIge2InAcc");
1196 fHistPtITSMIge2InAcc->Add(fHistPtITSMI5InAcc);
1197 fHistPtITSMIge2InAcc->Add(fHistPtITSMI4InAcc);
1198 fHistPtITSMIge2InAcc->Add(fHistPtITSMI3InAcc);
1199 fHistPtITSMIge2InAcc->Add(fHistPtITSMI2InAcc);
1200
1201
1202 cITSTPCmatch->cd(2);
1203 fHistPtITSMIge2InAcc->SetTitle("Fraction of prolonged tracks with N ITS points: peripheral");
1204 fHistPtITSMIge2InAcc->SetYTitle("ITS+TPC / TPC");
1205 fHistPtITSMIge2InAcc->Divide(fHistPtITSMIge2InAcc,fHistPtTPCInAcc,1,1,"B");
1206 fHistPtITSMIge2InAcc->SetMaximum(1.6);
1207 fHistPtITSMIge2InAcc->SetMinimum(0);
1208 fHistPtITSMIge2InAcc->GetXaxis()->SetRangeUser(0.1,30);
1209 fHistPtITSMIge2InAcc->Draw();
1210 fHistPtITSMI6InAcc->Divide(fHistPtITSMI6InAcc,fHistPtTPCInAcc,1,1,"B");
1211 fHistPtITSMI6InAcc->SetLineColor(2);
1212 fHistPtITSMI6InAcc->Draw("same");
1213 fHistPtITSMI5InAcc->Divide(fHistPtITSMI5InAcc,fHistPtTPCInAcc,1,1,"B");
1214 fHistPtITSMI5InAcc->SetLineColor(3);
1215 fHistPtITSMI5InAcc->Draw("same");
1216 fHistPtITSMI4InAcc->Divide(fHistPtITSMI4InAcc,fHistPtTPCInAcc,1,1,"B");
1217 fHistPtITSMI4InAcc->SetLineColor(4);
1218 fHistPtITSMI4InAcc->Draw("same");
1219 fHistPtITSMI3InAcc->Divide(fHistPtITSMI3InAcc,fHistPtTPCInAcc,1,1,"B");
1220 fHistPtITSMI3InAcc->SetLineColor(6);
1221 fHistPtITSMI3InAcc->Draw("same");
1222 fHistPtITSMI2InAcc->Divide(fHistPtITSMI2InAcc,fHistPtTPCInAcc,1,1,"B");
1223 fHistPtITSMI2InAcc->SetLineColor(7);
1224 fHistPtITSMI2InAcc->Draw("same");
1225 fHistPtITSMISPDInAcc->Divide(fHistPtITSMISPDInAcc,fHistPtTPCInAcc,1,1,"B");
1226 fHistPtITSMISPDInAcc->SetLineColor(9);
1227 fHistPtITSMISPDInAcc->Draw("same");
1228 fHistPtITSMIoneSPDInAcc->Divide(fHistPtITSMIoneSPDInAcc,fHistPtTPCInAcc,1,1,"B");
1229 fHistPtITSMIoneSPDInAcc->SetLineColor(15);
1230 fHistPtITSMIoneSPDInAcc->Draw("same");
1231 fHistPtITSTPCsel->Divide(fHistPtITSTPCsel,fHistPtTPCInAcc,1,1,"B");
1232 fHistPtITSTPCsel->SetLineColor(kAzure+1);
1233 fHistPtITSTPCsel->Draw("same");
1234 fHistPtITSMIge2InAcc->Draw("same");
1235 l3->Draw();
1236 l2->Draw();
1237 spdFrac0->Draw("p");
1238 spdFrac1->Draw("p");
1239 cITSTPCmatch->SaveAs("TPCITSmatching.pdf");
e7815454 1240 pdfFileNames+=" TPCITSmatching.pdf";
c6f340ff 1241 return kTRUE;
1242}
1243
1244//_______________________________________________________________________
1245void SaveC(TFile &fout, TCanvas**& clist, Int_t cnum){
1246 TDirectory *current = gDirectory;
1247 fout.cd();
1248 for(Int_t i=0;i<cnum;i++)clist[i]->Write();
1249 delete[] clist;
1250 current->cd();
1251}
1f7d40d1 1252
1253//_______________________________________________________________________
1254TString GetRunNumber(){
1255 // returns a string with the run number
1256 char rn[10];
1257 sprintf(rn,"%d ",gRunNumber);
1258 TString str(rn);
1259 return str;
1260}