]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/ITS/AliITSQAtrend.C
Added matching efficiency for tracks with TOFbc/2==0
[u/mrichter/AliRoot.git] / PWGPP / ITS / AliITSQAtrend.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TH1F.h>
3 #include <TH2F.h>
4 #include <TF1.h>
5 #include <TPad.h>
6 #include <TGraphErrors.h>
7 #include <TROOT.h>
8 #include <TFile.h>
9 #include <TTree.h>
10 #include <TGrid.h>
11 #include <TGridResult.h>
12 #include <TMath.h>
13 #include <TSystem.h>
14 #include <TNtuple.h>
15 #include <TCanvas.h>
16 #include <TStyle.h>
17 #include <TLatex.h>
18 #include <TLegend.h>
19 #include <TLegendEntry.h>
20 #include <Riostream.h>
21 #include "AliITSgeomTGeo.h"
22 #endif
23
24 TString pdfFileNames="";
25 void MakePlot(Int_t run1=-1,Int_t run2=99999999,TString ntupleFileName="TrendingITS.root");
26 void PlotITSSA(TFile *fil,Int_t *myIndex,Int_t kRunsToPlot);
27 void FillITSSAntuple(TFile* f,TNtuple* nt, Int_t nrun);
28 void AliITSQAtrend(TString runListFile="LHC11hNo.txt",TString ntupleFileName="TrendingITS.root");
29
30 ////////////////////////////////////////////////////////////////
31 //   Please, read this comment before using this macro 
32 //
33 //   INPUT FILE: a text file (by default LHC11hNo.txt) which contains
34 //   a list of the complete path+file name of the QAresults root files 
35 //   (without the alien:// prefix).
36 //   One file per line. The order is irrelevant.
37 //
38 //   USAGE:
39 //
40 //   Function AliITSQAtrend():  
41 //   it looks for a local root file named TrendingITS.root,
42 //   where the ntuples used to build the trending plots are
43 //   stored. This file is used to generate incrementally the ntuple contents:
44 //   when you add a new entry in the LHC11hNo.txt file and you have a
45 //   local copy of the  TrendingITS.root file, only the additional run will
46 //   be processed. The whole list is processed only the first time you use the
47 //   macro. Please, bear in mind that this macro is RAM-intensive: all the
48 //   ntuples are kept in memory. It is better to add few runs to the list at 
49 //   each time, according to the RAM of your computer. 
50 //   The function AliITSQAtrend does not produce any plot.
51 //
52 //   Function MakePlot(run1,run2):
53 //   it produces the plots. For each canvas a PDF file is created.
54 //   A PDF file with all the canvases merged is also produced
55 //   The first two argument define a range for the runs to be displayed
56 //   These two arguments are optional: by default, all the runs
57 //   found in the ntuples are displayed
58 ////////////////////////////////////////////////////////////////
59
60 /* $Id$ */
61
62 void MakePlot(Int_t run1,Int_t run2,TString ntupleFileName){
63   // Check run range
64   if(run1>=run2){
65     printf("******   ERROR: invalid run range %d - %d\n",run1,run2);
66     return;
67   }
68
69   TFile* fil=new TFile(ntupleFileName.Data(),"read");
70   if(!fil){
71     printf("File with ntuple does not exist\n");
72     return;
73   }
74   TNtuple* ntsdd=(TNtuple*)fil->Get("ntsdd");
75
76   Float_t nrun;
77   Float_t meanTrPts3,errmeanTrPts3,meanTrPts4,errmeanTrPts4;
78   Float_t minDrTime,errminDrTime,meanDrTime,errmeanDrTime;
79   Float_t fracTrackWithClu1,fracTrackWithClu2,errfracTrackWithClu1,errfracTrackWithClu2;
80   Float_t fracTrackWithClu3,fracTrackWithClu4,errfracTrackWithClu3,errfracTrackWithClu4;
81   Float_t fracTrackWithClu5,fracTrackWithClu6,errfracTrackWithClu5,errfracTrackWithClu6;
82   Float_t fracExtra,errfracExtra;
83   Float_t meandEdxLay3,errmeandEdxLay3,meandEdxLay4,errmeandEdxLay4;
84   Float_t meandEdxTB0,errmeandEdxTB0,meandEdxTB5,errmeandEdxTB5;
85   Float_t nMod95,nMod80,nMod60,nModEmpty;
86   
87   ntsdd->SetBranchAddress("nrun",&nrun);
88   ntsdd->SetBranchAddress("fracTrackWithClu1",&fracTrackWithClu1);
89   ntsdd->SetBranchAddress("errfracTrackWithClu1",&errfracTrackWithClu1);
90   ntsdd->SetBranchAddress("fracTrackWithClu2",&fracTrackWithClu2);
91   ntsdd->SetBranchAddress("errfracTrackWithClu2",&errfracTrackWithClu2);
92   ntsdd->SetBranchAddress("fracTrackWithClu3",&fracTrackWithClu3);
93   ntsdd->SetBranchAddress("errfracTrackWithClu3",&errfracTrackWithClu3);
94   ntsdd->SetBranchAddress("fracTrackWithClu4",&fracTrackWithClu4);
95   ntsdd->SetBranchAddress("errfracTrackWithClu4",&errfracTrackWithClu4);
96   ntsdd->SetBranchAddress("fracTrackWithClu5",&fracTrackWithClu5);
97   ntsdd->SetBranchAddress("errfracTrackWithClu5",&errfracTrackWithClu5);
98   ntsdd->SetBranchAddress("fracTrackWithClu6",&fracTrackWithClu6);
99   ntsdd->SetBranchAddress("errfracTrackWithClu6",&errfracTrackWithClu6);
100   ntsdd->SetBranchAddress("nMod95",&nMod95);
101   ntsdd->SetBranchAddress("nMod80",&nMod80);
102   ntsdd->SetBranchAddress("nMod60",&nMod60);
103   ntsdd->SetBranchAddress("nModEmpty",&nModEmpty);
104
105   ntsdd->SetBranchAddress("meanTrPts3",&meanTrPts3);
106   ntsdd->SetBranchAddress("errmeanTrPts3",&errmeanTrPts3);
107   ntsdd->SetBranchAddress("meanTrPts4",&meanTrPts4);
108   ntsdd->SetBranchAddress("errmeanTrPts4",&errmeanTrPts4);
109   ntsdd->SetBranchAddress("minDrTime",&minDrTime);
110   ntsdd->SetBranchAddress("errminDrTime",&errminDrTime);
111   ntsdd->SetBranchAddress("meanDrTime",&meanDrTime);
112   ntsdd->SetBranchAddress("errmeanDrTime",&errmeanDrTime);
113   ntsdd->SetBranchAddress("fracExtra",&fracExtra);
114   ntsdd->SetBranchAddress("errfracExtra",&errfracExtra);
115   ntsdd->SetBranchAddress("meandEdxTB0",&meandEdxTB0);
116   ntsdd->SetBranchAddress("errmeandEdxTB0",&errmeandEdxTB0);
117   ntsdd->SetBranchAddress("meandEdxTB5",&meandEdxTB5);
118   ntsdd->SetBranchAddress("errmeandEdxTB5",&errmeandEdxTB5);
119   ntsdd->SetBranchAddress("meandEdxLay3",&meandEdxLay3);
120   ntsdd->SetBranchAddress("errmeandEdxLay3",&errmeandEdxLay3);
121   ntsdd->SetBranchAddress("meandEdxLay4",&meandEdxLay4);
122   ntsdd->SetBranchAddress("errmeandEdxLay4",&errmeandEdxLay4);
123
124   // Sort entries according to run number in the chosen range
125   // Same order is assumed for all the subsequent ntuples
126   Int_t nr=ntsdd->GetEntries();
127   Int_t *myIndex = new Int_t [nr];
128   Int_t *noRuns = new Int_t [nr];
129   Int_t kRunsToPlot=0;
130   printf("Processing runs from %d up to %d\n",run1,run2);
131   for(Int_t i=0; i<nr;i++){
132     ntsdd->GetEvent(i);
133     Int_t intrun = static_cast<Int_t>(nrun+0.01);
134     if(intrun>=run1 && intrun<=run2){
135       printf("Accepting run number %d in position %d\n",intrun,kRunsToPlot);
136       noRuns[i]=intrun;
137       kRunsToPlot++;
138     }
139     else {
140       noRuns[i]=run2+10;  
141       printf("Rejecting run number %d - out of range\n",intrun);
142     }
143   }
144   TMath::Sort(nr,noRuns,myIndex,kFALSE);
145   printf("Total number of runs accepted fot display %d\n",kRunsToPlot);
146   if(kRunsToPlot==0)return;
147   for(Int_t i=0;i<kRunsToPlot;i++)printf("Position %d ) Run: %d\n",i,noRuns[myIndex[i]]);
148
149   TH1F* histotrp3=new TH1F("histotrp3","",kRunsToPlot,0.,kRunsToPlot);
150   TH1F* histotrp4=new TH1F("histotrp4","",kRunsToPlot,0.,kRunsToPlot);
151   TH1F* histominTime=new TH1F("histominTime","",kRunsToPlot,0.,kRunsToPlot);
152   TH1F* histomeanTime=new TH1F("histomeanTime","",kRunsToPlot,0.,kRunsToPlot);
153   TH1F* histofracExtra=new TH1F("histofracExtra","",kRunsToPlot,0.,kRunsToPlot);
154   TH1F* histodEdxTB0=new TH1F("histodEdxTB0","",kRunsToPlot,0.,kRunsToPlot);
155   TH1F* histodEdxTB5=new TH1F("histodEdxTB5","",kRunsToPlot,0.,kRunsToPlot);
156   TH1F* histodEdxLay3=new TH1F("histodEdxLay3","",kRunsToPlot,0.,kRunsToPlot);
157   TH1F* histodEdxLay4=new TH1F("histodEdxLay4","",kRunsToPlot,0.,kRunsToPlot);
158   TH1F* histoTrackClu1=new TH1F("histoTrackClu1","",kRunsToPlot,0.,kRunsToPlot);
159   TH1F* histoTrackClu2=new TH1F("histoTrackClu2","",kRunsToPlot,0.,kRunsToPlot);
160   TH1F* histoTrackClu3=new TH1F("histoTrackClu3","",kRunsToPlot,0.,kRunsToPlot);
161   TH1F* histoTrackClu4=new TH1F("histoTrackClu4","",kRunsToPlot,0.,kRunsToPlot);
162   TH1F* histoTrackClu5=new TH1F("histoTrackClu5","",kRunsToPlot,0.,kRunsToPlot);
163   TH1F* histoTrackClu6=new TH1F("histoTrackClu6","",kRunsToPlot,0.,kRunsToPlot);
164
165   TH1F* histoNmodEffBelow95=new TH1F("histoNmodEffBelow95","",kRunsToPlot,0.,kRunsToPlot);
166   TH1F* histoNmodEffBelow80=new TH1F("histoNmodEffBelow80","",kRunsToPlot,0.,kRunsToPlot);
167   TH1F* histoNmodEffBelow60=new TH1F("histoNmodEffBelow60","",kRunsToPlot,0.,kRunsToPlot);
168   TH1F* histoNmodEmpty=new TH1F("histoNmodEmpty","",kRunsToPlot,0.,kRunsToPlot);
169
170   for(Int_t i=0; i<kRunsToPlot;i++){
171     ntsdd->GetEvent(myIndex[i]);
172     histoTrackClu1->SetBinContent(i+1,fracTrackWithClu1);
173     histoTrackClu1->SetBinError(i+1,errfracTrackWithClu1);
174     histoTrackClu1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
175     histoTrackClu2->SetBinContent(i+1,fracTrackWithClu2);
176     histoTrackClu2->SetBinError(i+1,errfracTrackWithClu2);
177     histoTrackClu2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
178     histoTrackClu3->SetBinContent(i+1,fracTrackWithClu3);
179     histoTrackClu3->SetBinError(i+1,errfracTrackWithClu3);
180     histoTrackClu3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
181     histoTrackClu4->SetBinContent(i+1,fracTrackWithClu4);
182     histoTrackClu4->SetBinError(i+1,errfracTrackWithClu4);
183     histoTrackClu4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
184     histoTrackClu5->SetBinContent(i+1,fracTrackWithClu5);
185     histoTrackClu5->SetBinError(i+1,errfracTrackWithClu5);
186     histoTrackClu5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
187     histoTrackClu6->SetBinContent(i+1,fracTrackWithClu6);
188     histoTrackClu6->SetBinError(i+1,errfracTrackWithClu6);
189     histoTrackClu6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
190     histominTime->SetBinContent(i+1,minDrTime);
191     histominTime->SetBinError(i+1,errminDrTime);
192     histominTime->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
193     histomeanTime->SetBinContent(i+1,meanDrTime);
194     histomeanTime->SetBinError(i+1,errmeanDrTime);
195     histomeanTime->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
196     histotrp3->SetBinContent(i+1,meanTrPts3);
197     histotrp3->SetBinError(i+1,errmeanTrPts3);
198     histotrp3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
199     histotrp4->SetBinContent(i+1,meanTrPts4);
200     histotrp4->SetBinError(i+1,errmeanTrPts3);
201     histotrp4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
202     histofracExtra->SetBinContent(i+1,fracExtra);
203     histofracExtra->SetBinError(i+1,errfracExtra);
204     histofracExtra->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
205     histodEdxTB0->SetBinContent(i+1,meandEdxTB0);
206     histodEdxTB0->SetBinError(i+1,errmeandEdxTB0);
207     histodEdxTB0->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
208     histodEdxTB5->SetBinContent(i+1,meandEdxTB5);
209     histodEdxTB5->SetBinError(i+1,errmeandEdxTB5);
210     histodEdxTB5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
211     histodEdxLay3->SetBinContent(i+1,meandEdxLay3);
212     histodEdxLay3->SetBinError(i+1,errmeandEdxLay3);
213     histodEdxLay3->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
214     histodEdxLay4->SetBinContent(i+1,meandEdxLay4);
215     histodEdxLay4->SetBinError(i+1,errmeandEdxLay4);
216     histodEdxLay4->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
217
218     histoNmodEffBelow95->SetBinContent(i+1,nMod95);
219     histoNmodEffBelow95->SetBinError(i+1,0.0000001);
220     histoNmodEffBelow95->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
221     histoNmodEffBelow80->SetBinContent(i+1,nMod80);
222     histoNmodEffBelow80->SetBinError(i+1,0.0000001);
223     histoNmodEffBelow80->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
224     histoNmodEffBelow60->SetBinContent(i+1,nMod60);
225     histoNmodEffBelow60->SetBinError(i+1,0.0000001);
226     histoNmodEffBelow60->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
227     histoNmodEmpty->SetBinContent(i+1,nModEmpty);
228     histoNmodEmpty->SetBinError(i+1,0.000001);
229     histoNmodEmpty->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
230   }
231
232
233   //---SSD
234
235   TNtuple* ntssd=(TNtuple*)fil->Get("ntssd");
236
237   Float_t  nrunSSD, meandEdxLay5,errmeandEdxLay5,meandEdxLay6,errmeandEdxLay6;
238   Float_t ChargeRatioL5,errChargeratioL5,ChargeRatioL6, errChargeratioL6, moduleOff;
239
240   ntssd->SetBranchAddress("nrun",&nrunSSD);
241   ntssd->SetBranchAddress("meandEdxLay5",&meandEdxLay5);
242   ntssd->SetBranchAddress("errmeandEdxLay5",&errmeandEdxLay5);
243   ntssd->SetBranchAddress("meandEdxLay6",&meandEdxLay6);
244   ntssd->SetBranchAddress("errmeandEdxLay6",&errmeandEdxLay6);
245   ntssd->SetBranchAddress("ChargeRatioL5",&ChargeRatioL5);
246   ntssd->SetBranchAddress("errChargeratioL5",&errChargeratioL5);
247   ntssd->SetBranchAddress("ChargeRatioL6",&ChargeRatioL6);
248   ntssd->SetBranchAddress("errChargeratioL6",&errChargeratioL6);
249   ntssd->SetBranchAddress("moduleOff",&moduleOff);
250
251   TH1F* histodEdxLay5=new TH1F("histodEdxLay5","",kRunsToPlot,0.,kRunsToPlot);
252   TH1F* histodEdxLay6=new TH1F("histodEdxLay6","",kRunsToPlot,0.,kRunsToPlot);
253
254   TH1F* histoChargeRatioLay5=new TH1F("histoChargeRatioLay5","",kRunsToPlot,0.,kRunsToPlot);
255   TH1F* histoChargeRatioLay6=new TH1F("histoChargeRatioLay6","",kRunsToPlot,0.,kRunsToPlot);
256  
257   TH1F* histoEmpty=new TH1F("histoEmpty","",kRunsToPlot,0.,kRunsToPlot);
258   
259   for(Int_t i=0; i<kRunsToPlot;i++){
260
261     ntssd->GetEvent(myIndex[i]);
262
263     histodEdxLay5->SetBinContent(i+1,meandEdxLay5);
264     histodEdxLay5->SetBinError(i+1,errmeandEdxLay5);
265     histodEdxLay5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunSSD));
266
267     histodEdxLay6->SetBinContent(i+1,meandEdxLay6);
268     histodEdxLay6->SetBinError(i+1,errmeandEdxLay6);
269     histodEdxLay6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunSSD));
270
271     histoChargeRatioLay5->SetBinContent(i+1,ChargeRatioL5);
272     histoChargeRatioLay5->SetBinError(i+1,errChargeratioL5);
273     histoChargeRatioLay5->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunSSD));
274     
275     histoChargeRatioLay6->SetBinContent(i+1,ChargeRatioL6);
276     histoChargeRatioLay6->SetBinError(i+1,errChargeratioL6);
277     histoChargeRatioLay6->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunSSD));
278
279     histoEmpty->SetBinContent(i+1,moduleOff);
280     histoEmpty->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunSSD));
281
282   }
283
284   //Matching
285
286   TNtuple* ntmatching=(TNtuple*)fil->Get("ntmatching");
287
288   Float_t nrunMatch;
289   Float_t FracSPD1;
290   Float_t errFracSPD1;
291   Float_t FracSPD2;
292   Float_t errFracSPD2;
293   Float_t Eff6Pt02;
294   Float_t errEff6Pt02;
295   Float_t Eff6Pt1;
296   Float_t errEff6Pt1;
297   Float_t Eff6Pt10;
298   Float_t errEff6Pt10;
299   Float_t Eff5Pt02;
300   Float_t errEff5Pt02;
301   Float_t Eff5Pt1;
302   Float_t errEff5Pt1;
303   Float_t Eff5Pt10;
304   Float_t errEff5Pt10;
305   Float_t Eff4Pt02;
306   Float_t errEff4Pt02;
307   Float_t Eff4Pt1;
308   Float_t errEff4Pt1;
309   Float_t Eff4Pt10;
310   Float_t errEff4Pt10;
311   Float_t Eff3Pt02;
312   Float_t errEff3Pt02;
313   Float_t Eff3Pt1;
314   Float_t errEff3Pt1;
315   Float_t Eff3Pt10;
316   Float_t errEff3Pt10;
317   Float_t Eff2Pt02;
318   Float_t errEff2Pt02;
319   Float_t Eff2Pt1;
320   Float_t errEff2Pt1;
321   Float_t Eff2Pt10;
322   Float_t errEff2Pt10;
323   Float_t EffSPDPt02;
324   Float_t errEffSPDPt02;
325   Float_t EffSPDPt1;
326   Float_t errEffSPDPt1;
327   Float_t EffSPDPt10;
328   Float_t errEffSPDPt10;
329   Float_t EffoneSPDPt02;
330   Float_t errEffoneSPDPt02;
331   Float_t EffoneSPDPt1;
332   Float_t errEffoneSPDPt1;
333   Float_t EffoneSPDPt10;
334   Float_t errEffoneSPDPt10;
335   Float_t EffTOTPt02;
336   Float_t errEffTOTPt02;
337   Float_t EffTOTPt1;
338   Float_t errEffTOTPt1;
339   Float_t EffTOTPt10;
340   Float_t errEffTOTPt10;
341
342   ntmatching->SetBranchAddress("nrun",&nrunMatch);
343   //  ntmatching->SetBranchAddress("nrunMatch",&nrunMatch);
344   ntmatching->SetBranchAddress("FracSPD1",&FracSPD1);
345   ntmatching->SetBranchAddress("errFracSPD1",&errFracSPD1);
346   ntmatching->SetBranchAddress("FracSPD2",&FracSPD2);
347   ntmatching->SetBranchAddress("errFracSPD2",&errFracSPD2);
348   ntmatching->SetBranchAddress("Eff6Pt02",&Eff6Pt02);
349   ntmatching->SetBranchAddress("errEff6Pt02",&errEff6Pt02);
350   ntmatching->SetBranchAddress("Eff6Pt1",&Eff6Pt1);
351   ntmatching->SetBranchAddress("errEff6Pt1",&errEff6Pt1);
352   ntmatching->SetBranchAddress("Eff6Pt10",&Eff6Pt10);
353   ntmatching->SetBranchAddress("errEff6Pt10",&errEff6Pt10);
354   ntmatching->SetBranchAddress("Eff5Pt02",&Eff5Pt02);
355   ntmatching->SetBranchAddress("errEff5Pt02",&errEff5Pt02);
356   ntmatching->SetBranchAddress("Eff5Pt1",&Eff5Pt1);
357   ntmatching->SetBranchAddress("errEff5Pt1",&errEff5Pt1);
358   ntmatching->SetBranchAddress("Eff5Pt10",&Eff5Pt10);
359   ntmatching->SetBranchAddress("errEff5Pt10",&errEff5Pt10);
360   ntmatching->SetBranchAddress("Eff4Pt02",&Eff4Pt02);
361   ntmatching->SetBranchAddress("errEff4Pt02",&errEff4Pt02);
362   ntmatching->SetBranchAddress("Eff4Pt1",&Eff4Pt1);
363   ntmatching->SetBranchAddress("errEff4Pt1",&errEff4Pt1);
364   ntmatching->SetBranchAddress("Eff4Pt10",&Eff4Pt10);
365   ntmatching->SetBranchAddress("errEff4Pt10",&errEff4Pt10);
366   ntmatching->SetBranchAddress("Eff3Pt02",&Eff3Pt02);
367   ntmatching->SetBranchAddress("errEff3Pt02",&errEff3Pt02);
368   ntmatching->SetBranchAddress("Eff3Pt1",&Eff3Pt1);
369   ntmatching->SetBranchAddress("errEff3Pt1",&errEff3Pt1);
370   ntmatching->SetBranchAddress("Eff3Pt10",&Eff3Pt10);
371   ntmatching->SetBranchAddress("errEff3Pt10",&errEff3Pt10);
372   ntmatching->SetBranchAddress("Eff2Pt02",&Eff2Pt02);
373   ntmatching->SetBranchAddress("errEff2Pt02",&errEff2Pt02);
374   ntmatching->SetBranchAddress("Eff2Pt1",&Eff2Pt1);
375   ntmatching->SetBranchAddress("errEff2Pt1",&errEff2Pt1);
376   ntmatching->SetBranchAddress("Eff2Pt10",&Eff2Pt10);
377   ntmatching->SetBranchAddress("errEff2Pt10",&errEff2Pt10);
378   ntmatching->SetBranchAddress("EffSPDPt02",&EffSPDPt02);
379   ntmatching->SetBranchAddress("errEffSPDPt02",&errEffSPDPt02);  
380   ntmatching->SetBranchAddress("EffSPDPt1",&EffSPDPt1);
381   ntmatching->SetBranchAddress("errEffSPDPt1",&errEffSPDPt1);  
382   ntmatching->SetBranchAddress("EffSPDPt10",&EffSPDPt10);
383   ntmatching->SetBranchAddress("errEffSPDPt10",&errEffSPDPt10);  
384   ntmatching->SetBranchAddress("EffoneSPDPt02",&EffoneSPDPt02);
385   ntmatching->SetBranchAddress("errEffoneSPDPt02",&errEffoneSPDPt02);
386   ntmatching->SetBranchAddress("EffoneSPDPt1",&EffoneSPDPt1);
387   ntmatching->SetBranchAddress("errEffoneSPDPt1",&errEffoneSPDPt1);
388   ntmatching->SetBranchAddress("EffoneSPDPt10",&EffoneSPDPt10);
389   ntmatching->SetBranchAddress("errEffoneSPDPt10",&errEffoneSPDPt10);
390   ntmatching->SetBranchAddress("EffTOTPt02",&EffTOTPt02);
391   ntmatching->SetBranchAddress("errEffTOTPt02",&errEffTOTPt02);
392   ntmatching->SetBranchAddress("EffTOTPt1",&EffTOTPt1);
393   ntmatching->SetBranchAddress("errEffTOTPt1",&errEffTOTPt1);
394   ntmatching->SetBranchAddress("EffTOTPt10",&EffTOTPt10);
395   ntmatching->SetBranchAddress("errEffTOTPt10",&errEffTOTPt10);
396
397
398   TH1F *hFracSPD1 = new TH1F("hFracSPD1","SPD inner; run number; Fraction of HSs",kRunsToPlot,0.,kRunsToPlot);
399   hFracSPD1->SetLineColor(kGreen+2);
400   hFracSPD1->SetMarkerColor(kGreen+2);
401   hFracSPD1->SetMarkerStyle(20);
402
403   TH1F *hFracSPD2 = new TH1F("hFracSPD2","SPD outer; run number; Fraction of HSs",kRunsToPlot,0.,kRunsToPlot);
404   hFracSPD2->SetLineColor(kYellow+2);
405   hFracSPD2->SetMarkerColor(kYellow+2);
406   hFracSPD2->SetMarkerStyle(20);
407
408   TH1F *hEffSPDPt02 = new TH1F("hEffSPDPt02","Efficiency - P_{T} = 0.2; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
409   hEffSPDPt02->SetLineWidth(2);
410   hEffSPDPt02->SetLineColor(kAzure+1);
411   hEffSPDPt02->SetMarkerColor(kAzure+1);
412   hEffSPDPt02->SetMarkerStyle(20);
413
414   TH1F *hEffSPDPt1 = new TH1F("hEffSPDPt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
415   hEffSPDPt1->SetLineWidth(2);
416   hEffSPDPt1->SetLineColor(kAzure+1);
417   hEffSPDPt1->SetMarkerColor(kAzure+1);
418   hEffSPDPt1->SetMarkerStyle(20);
419
420   TH1F *hEffSPDPt10 = new TH1F("hEffSPDPt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
421   hEffSPDPt10->SetLineWidth(2);
422   hEffSPDPt10->SetLineColor(kAzure+1);
423   hEffSPDPt10->SetMarkerColor(kAzure+1);
424   hEffSPDPt10->SetMarkerStyle(20);
425
426   TH1F *hEffoneSPDPt02 = new TH1F("hEffoneSPDPt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
427   hEffoneSPDPt02->SetLineWidth(2);
428   hEffoneSPDPt02->SetLineColor(kGray);
429   hEffoneSPDPt02->SetMarkerColor(kGray);
430   hEffoneSPDPt02->SetMarkerStyle(20);
431   TH1F *hEffoneSPDPt1 = new TH1F("hEffoneSPDPt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
432   hEffoneSPDPt1->SetLineWidth(2);
433   hEffoneSPDPt1->SetLineColor(kGray);
434   hEffoneSPDPt1->SetMarkerColor(kGray);
435   hEffoneSPDPt1->SetMarkerStyle(20);
436   TH1F *hEffoneSPDPt10 = new TH1F("hEffoneSPDPt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
437   hEffoneSPDPt10->SetLineWidth(2);
438   hEffoneSPDPt10->SetLineColor(kGray);
439   hEffoneSPDPt10->SetMarkerColor(kGray);
440   hEffoneSPDPt10->SetMarkerStyle(20);
441
442   TH1F *hEff2Pt02 = new TH1F("hEff2Pt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
443   hEff2Pt02->SetLineWidth(2);
444   hEff2Pt02->SetLineColor(kViolet);
445   hEff2Pt02->SetMarkerColor(kViolet);
446   hEff2Pt02->SetMarkerStyle(20);
447   TH1F *hEff2Pt1 = new TH1F("hEff2Pt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
448   hEff2Pt1->SetLineWidth(2);
449   hEff2Pt1->SetLineColor(kViolet);
450   hEff2Pt1->SetMarkerColor(kViolet);
451   hEff2Pt1->SetMarkerStyle(20);
452   TH1F *hEff2Pt10 = new TH1F("hEff2Pt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
453   hEff2Pt10->SetLineWidth(2);
454   hEff2Pt10->SetLineColor(kViolet);
455   hEff2Pt10->SetMarkerColor(kViolet);
456   hEff2Pt10->SetMarkerStyle(20);
457
458   TH1F *hEff3Pt02 = new TH1F("hEff3Pt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
459   hEff3Pt02->SetLineWidth(2);
460   hEff3Pt02->SetLineColor(6);
461   hEff3Pt02->SetMarkerColor(6);
462   hEff3Pt02->SetMarkerStyle(20);
463   TH1F *hEff3Pt1 = new TH1F("hEff3Pt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
464   hEff3Pt1->SetLineWidth(2);
465   hEff3Pt1->SetLineColor(6);
466   hEff3Pt1->SetMarkerColor(6);
467   hEff3Pt1->SetMarkerStyle(20);
468   TH1F *hEff3Pt10 = new TH1F("hEff3Pt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
469   hEff3Pt10->SetLineWidth(2);
470   hEff3Pt10->SetLineColor(6);
471   hEff3Pt10->SetMarkerColor(6);
472   hEff3Pt10->SetMarkerStyle(20);
473
474   TH1F *hEff4Pt02 = new TH1F("hEff4Pt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
475   hEff4Pt02->SetLineWidth(2);
476   hEff4Pt02->SetLineColor(4);
477   hEff4Pt02->SetMarkerColor(4);
478   hEff4Pt02->SetMarkerStyle(20);
479   TH1F *hEff4Pt1 = new TH1F("hEff4Pt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
480   hEff4Pt1->SetLineWidth(2);
481   hEff4Pt1->SetLineColor(4);
482   hEff4Pt1->SetMarkerColor(4);
483   hEff4Pt1->SetMarkerStyle(20);
484   TH1F *hEff4Pt10 = new TH1F("hEff4Pt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
485   hEff4Pt10->SetLineWidth(2);
486   hEff4Pt10->SetLineColor(4);
487   hEff4Pt10->SetMarkerColor(4);
488   hEff4Pt10->SetMarkerStyle(20);
489
490   TH1F *hEff5Pt02 = new TH1F("hEff5Pt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
491   hEff5Pt02->SetLineWidth(2);
492   hEff5Pt02->SetLineColor(3);
493   hEff5Pt02->SetMarkerColor(3);
494   hEff5Pt02->SetMarkerStyle(20);
495   TH1F *hEff5Pt1 = new TH1F("hEff5Pt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
496   hEff5Pt1->SetLineWidth(2);
497   hEff5Pt1->SetLineColor(3);
498   hEff5Pt1->SetMarkerColor(3);
499   hEff5Pt1->SetMarkerStyle(20);
500   TH1F *hEff5Pt10 = new TH1F("hEff5Pt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
501   hEff5Pt10->SetLineWidth(3);
502   hEff5Pt10->SetLineColor(3);
503   hEff5Pt10->SetMarkerColor(3);
504   hEff5Pt10->SetMarkerStyle(20);
505
506   TH1F *hEff6Pt02 = new TH1F("hEff6Pt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
507   hEff6Pt02->SetLineWidth(2);
508   hEff6Pt02->SetLineColor(2);
509   hEff6Pt02->SetMarkerColor(2);
510   hEff6Pt02->SetMarkerStyle(20);
511   TH1F *hEff6Pt1 = new TH1F("hEff6Pt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
512   hEff6Pt1->SetLineWidth(2);
513   hEff6Pt1->SetLineColor(2);
514   hEff6Pt1->SetMarkerColor(2);
515   hEff6Pt1->SetMarkerStyle(20);
516   TH1F *hEff6Pt10 = new TH1F("hEff6Pt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
517   hEff6Pt10->SetLineWidth(2);
518   hEff6Pt10->SetLineColor(2);
519   hEff6Pt10->SetMarkerColor(2);
520   hEff6Pt10->SetMarkerStyle(20);
521
522
523   TH1F *hEffTOTPt02 = new TH1F("hEffTOTPt02","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
524   hEffTOTPt02->SetLineWidth(2);
525   hEffTOTPt02->SetLineColor(kBlue+2);
526   hEffTOTPt02->SetMarkerColor(kBlue+2);
527   hEffTOTPt02->SetMarkerStyle(20);
528   TH1F *hEffTOTPt1 = new TH1F("hEffTOTPt1","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
529   hEffTOTPt1->SetLineWidth(2);
530   hEffTOTPt1->SetLineColor(kBlue+2);
531   hEffTOTPt1->SetMarkerColor(kBlue+2);
532   hEffTOTPt1->SetMarkerStyle(20);
533   TH1F *hEffTOTPt10 = new TH1F("hEffTOTPt10","Efficiency; run number; TPC+ITS / TPC",kRunsToPlot,0.,kRunsToPlot);
534   hEffTOTPt10->SetLineWidth(2);
535   hEffTOTPt10->SetLineColor(kBlue+2);
536   hEffTOTPt10->SetMarkerColor(kBlue+2);
537   hEffTOTPt10->SetMarkerStyle(20);
538
539   //  Int_t nEntriesMatch=ntmatching->GetEntries();
540   
541   for(Int_t i=0;i<kRunsToPlot;i++){
542    
543     ntmatching->GetEvent(myIndex[i]);
544     //    Int_t bin=nrunMatch;
545
546     // fill histos
547     //    cout<<i<<") "<<"Index= "<<myIndex[i]<<" nrun= "<<nrunMatch<<", FracSPD1= "<<FracSPD1<<", FracSPD2"<<FracSPD2<<endl;        
548     hFracSPD1->SetBinContent(i+1,FracSPD1);
549     hFracSPD1->SetBinError(i+1,.01);
550     hFracSPD1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
551
552     //    cout<<FracSPD1<<endl;
553
554     hFracSPD2->SetBinContent(i+1,FracSPD2);
555     hFracSPD2->SetBinError(i+1,.01);
556     hFracSPD2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
557     
558     //    cout<<FracSPD2<<endl;
559
560     //-------------------------
561       
562     hEff6Pt02->SetBinContent(i+1,Eff6Pt02);
563     hEff6Pt02->SetBinError(i+1,errEff6Pt02);
564     hEff6Pt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
565       
566     hEff6Pt1->SetBinContent(i+1,Eff6Pt1);
567     hEff6Pt1->SetBinError(i+1,errEff6Pt1);
568     hEff6Pt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
569       
570     hEff6Pt10->SetBinContent(i+1,Eff6Pt10);
571     hEff6Pt10->SetBinError(i+1,errEff6Pt10);
572     hEff6Pt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
573
574     hEff5Pt02->SetBinContent(i+1,Eff5Pt02);
575     hEff5Pt02->SetBinError(i+1,errEff5Pt02);
576     hEff5Pt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
577             
578     hEff5Pt1->SetBinContent(i+1,Eff5Pt1);
579     hEff5Pt1->SetBinError(i+1,errEff5Pt1);
580     hEff5Pt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
581             
582     hEff5Pt10->SetBinContent(i+1,Eff5Pt10);
583     hEff5Pt10->SetBinError(i+1,errEff5Pt10);
584     hEff5Pt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
585       
586     hEff4Pt02->SetBinContent(i+1,Eff4Pt02);
587     hEff4Pt02->SetBinError(i+1,errEff4Pt1);
588     hEff4Pt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
589
590     hEff4Pt1->SetBinContent(i+1,Eff4Pt1);
591     hEff4Pt1->SetBinError(i+1,errEff4Pt1);
592     hEff4Pt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
593
594     hEff4Pt10->SetBinContent(i+1,Eff4Pt10);
595     hEff4Pt10->SetBinError(i+1,errEff4Pt10);
596     hEff4Pt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
597       
598     hEff3Pt02->SetBinContent(i+1,Eff3Pt02);
599     hEff3Pt02->SetBinError(i+1,errEff3Pt02);
600     hEff3Pt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
601             
602     hEff3Pt1->SetBinContent(i+1,Eff3Pt1);
603     hEff3Pt1->SetBinError(i+1,errEff3Pt1);
604     hEff3Pt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
605
606     hEff3Pt10->SetBinContent(i+1,Eff3Pt10);
607     hEff3Pt10->SetBinError(i+1,errEff3Pt10);
608     hEff3Pt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));      
609       
610     hEff2Pt02->SetBinContent(i+1,Eff2Pt02);
611     hEff2Pt02->SetBinError(i+1,errEff2Pt02);
612     hEff2Pt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));  
613
614     hEff2Pt1->SetBinContent(i+1,Eff2Pt1);
615     hEff2Pt1->SetBinError(i+1,errEff2Pt1);
616     hEff2Pt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));  
617
618     hEff2Pt10->SetBinContent(i+1,Eff2Pt10);
619     hEff2Pt10->SetBinError(i+1,errEff2Pt10);
620     hEff2Pt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));  
621
622
623     hEffSPDPt02->SetBinContent(i+1,EffSPDPt02);
624     hEffSPDPt02->SetBinError(i+1,errEffSPDPt02);
625     hEffSPDPt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));  
626       
627     hEffSPDPt1->SetBinContent(i+1,EffSPDPt1);
628     hEffSPDPt1->SetBinError(i+1,errEffSPDPt1);
629     hEffSPDPt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch)); 
630       
631     hEffSPDPt10->SetBinContent(i+1,EffSPDPt10);
632     hEffSPDPt10->SetBinError(i+1,errEffSPDPt10);
633     hEffSPDPt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch)); 
634       
635     hEffoneSPDPt02->SetBinContent(i+1,EffoneSPDPt02);
636     hEffoneSPDPt02->SetBinError(i+1,errEffoneSPDPt02);
637     hEffoneSPDPt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
638
639     hEffoneSPDPt1->SetBinContent(i+1,EffoneSPDPt1);
640     hEffoneSPDPt1->SetBinError(i+1,errEffoneSPDPt1);
641     hEffoneSPDPt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
642       
643     hEffoneSPDPt10->SetBinContent(i+1,EffoneSPDPt10);
644     hEffoneSPDPt10->SetBinError(i+1,errEffoneSPDPt10);
645     hEffoneSPDPt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
646
647     hEffTOTPt02->SetBinContent(i+1,EffTOTPt02);
648     hEffTOTPt02->SetBinError(i+1,errEffTOTPt02);
649     hEffTOTPt02->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
650       
651     hEffTOTPt1->SetBinContent(i+1,EffTOTPt1);
652     hEffTOTPt1->SetBinError(i+1,errEffTOTPt1);
653     hEffTOTPt1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));
654       
655     hEffTOTPt10->SetBinContent(i+1,EffTOTPt10);
656     hEffTOTPt10->SetBinError(i+1,errEffTOTPt10);
657     hEffTOTPt10->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunMatch));  
658
659   }
660   
661   //-----------------------------------
662
663   //---vertex
664
665   TNtuple* ntvertex=(TNtuple*)fil->Get("ntvertex");
666
667   Float_t nrunVertex,Vx,errVx,sigmaVx,errsigmaVx,Vy,errVy,sigmaVy,errsigmaVy,Vz,errVz,sigmaVz,errsigmaVz;
668
669   ntvertex->SetBranchAddress("nrun",&nrunVertex);
670   ntvertex->SetBranchAddress("Vx",&Vx);
671   ntvertex->SetBranchAddress("errVx",&errVx);
672   ntvertex->SetBranchAddress("sigmaVx",&sigmaVx);
673   ntvertex->SetBranchAddress("errsigmaVx",&errsigmaVx);
674   ntvertex->SetBranchAddress("Vy",&Vy);
675   ntvertex->SetBranchAddress("errVy",&errVy);
676   ntvertex->SetBranchAddress("sigmaVy",&sigmaVy);
677   ntvertex->SetBranchAddress("errsigmaVy",&errsigmaVy);
678   ntvertex->SetBranchAddress("Vz",&Vz);
679   ntvertex->SetBranchAddress("errVz",&errVz);
680   ntvertex->SetBranchAddress("sigmaVz",&sigmaVz);
681   ntvertex->SetBranchAddress("errsigmaVz",&errsigmaVz);
682
683
684   TH1F *hVx = new TH1F("hVx","Track Vertex Vx Distribution",kRunsToPlot,0.,kRunsToPlot);
685   hVx->SetLineWidth(2);
686   hVx->SetLineColor(kBlue+2);
687   hVx->SetMarkerColor(kBlue+2);
688   hVx->SetMarkerStyle(20);
689
690  TH1F *hVy = new TH1F("hVy","Track Vertex Vy Distribution",kRunsToPlot,0.,kRunsToPlot);
691   hVy->SetLineWidth(2);
692   hVy->SetLineColor(kBlue+2);
693   hVy->SetMarkerColor(kBlue+2);
694   hVy->SetMarkerStyle(20);
695
696  TH1F *hVz = new TH1F("hVz","Track Vertex Vz Distribution",kRunsToPlot,0.,kRunsToPlot);
697   hVz->SetLineWidth(2);
698   hVz->SetLineColor(kBlue+2);
699   hVz->SetMarkerColor(kBlue+2);
700   hVz->SetMarkerStyle(20);
701
702   TH1F *hSigmaVx = new TH1F("hSigmaVx","Track Vertex SigmaVx Distribution",kRunsToPlot,0.,kRunsToPlot);
703   hSigmaVx->SetLineWidth(2);
704   hSigmaVx->SetLineColor(kBlue+2);
705   hSigmaVx->SetMarkerColor(kBlue+2);
706   hSigmaVx->SetMarkerStyle(20);
707
708  TH1F *hSigmaVy = new TH1F("hSigmaVy","Track Vertex SigmaVy Distribution",kRunsToPlot,0.,kRunsToPlot);
709   hSigmaVy->SetLineWidth(2);
710   hSigmaVy->SetLineColor(kBlue+2);
711   hSigmaVy->SetMarkerColor(kBlue+2);
712   hSigmaVy->SetMarkerStyle(20);
713
714  TH1F *hSigmaVz = new TH1F("hSigmaVz","Track Vertex SigmaVz Distribution",kRunsToPlot,0.,kRunsToPlot);
715   hSigmaVz->SetLineWidth(2);
716   hSigmaVz->SetLineColor(kBlue+2);
717   hSigmaVz->SetMarkerColor(kBlue+2);
718   hSigmaVz->SetMarkerStyle(20);
719
720
721   //  Int_t nEntriesVertex=ntvertex->GetEntries();
722   
723   for(Int_t i=0;i<kRunsToPlot;i++){
724
725     ntvertex->GetEvent(myIndex[i]);
726     
727     //    cout<<Vx<<endl;
728
729     hVx->SetBinContent(i+1,Vx);
730     hVx->SetBinError(i+1,errVx);
731     hVx->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
732   
733     hVy->SetBinContent(i+1,Vy);
734     hVy->SetBinError(i+1,errVy);
735     hVy->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
736     
737     hVz->SetBinContent(i+1,Vz);
738     hVz->SetBinError(i+1,errVz);
739     hVz->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
740   
741     
742     hSigmaVx->SetBinContent(i+1,sigmaVx);
743     hSigmaVx->SetBinError(i+1,errsigmaVx);
744     hSigmaVx->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
745
746     hSigmaVy->SetBinContent(i+1,sigmaVy);
747     hSigmaVy->SetBinError(i+1,errsigmaVy);
748     hSigmaVy->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
749
750     hSigmaVz->SetBinContent(i+1,sigmaVz);
751     hSigmaVz->SetBinError(i+1,errsigmaVz);
752     hSigmaVz->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrunVertex));
753     
754   }
755  //--------  Draw Vertex histograms ---------
756   TCanvas *cVertexDisto=new TCanvas("cVertexDisto","cVertexDisto",1200,800);
757   cVertexDisto->Divide(3,2);
758   cVertexDisto->cd(1);
759   hVx->SetMinimum(0.03);
760   hVx->SetMaximum(0.08);
761   hVx->GetYaxis()->SetTitle("Vertex X coordinate");
762   hVx->Draw();
763   cVertexDisto->cd(2);
764   hVy->SetMinimum(0.25);
765   hVy->SetMaximum(0.30);
766   hVy->GetYaxis()->SetTitle("Vertex Y coordinate");
767   hVy->Draw();
768   cVertexDisto->cd(3);
769   hVz->SetMinimum(-1.);
770   hVz->SetMaximum(1.);
771   hVz->GetYaxis()->SetTitle("Vertex Z coordinate");
772   hVz->Draw();
773   cVertexDisto->cd(4);
774   hSigmaVx->SetMinimum(0.);
775   hSigmaVx->SetMaximum(0.01);
776   hSigmaVx->GetYaxis()->SetTitle("sigma on x coordinate");
777   hSigmaVx->Draw();
778   cVertexDisto->cd(5);
779   hSigmaVy->SetMinimum(0.);
780   hSigmaVy->SetMaximum(0.01);
781   hSigmaVy->GetYaxis()->SetTitle("sigma on y coordinate");
782   hSigmaVy->Draw();
783   cVertexDisto->cd(6);
784   hSigmaVz->SetMinimum(6.);
785   hSigmaVz->SetMaximum(10.);
786   hSigmaVz->GetYaxis()->SetTitle("sigma on z coordinate");
787   hSigmaVz->Draw();
788   cVertexDisto->SaveAs("Vertex_trend.pdf");
789     pdfFileNames+=" Vertex_trend.pdf";
790  //-----------------------------------
791
792   gStyle->SetOptStat(0);
793
794   TCanvas* c5=new TCanvas("c5","Track With points in ITS");
795   histoTrackClu3->Draw();
796   histoTrackClu3->SetLineColor(1);
797   histoTrackClu3->SetMarkerStyle(20);
798   histoTrackClu3->Draw();
799   histoTrackClu3->SetMinimum(0.);
800   histoTrackClu3->SetMaximum(1.05);
801   histoTrackClu4->SetLineColor(2);
802   histoTrackClu4->SetMarkerColor(2);
803   histoTrackClu4->SetMarkerStyle(22);
804   histoTrackClu4->Draw("same");
805   histoTrackClu1->SetLineColor(kGray+1);
806   histoTrackClu1->SetMarkerColor(kGray+1);
807   histoTrackClu1->SetMarkerStyle(24);
808   histoTrackClu1->Draw("same");
809   histoTrackClu2->SetLineColor(kGray+2);
810   histoTrackClu2->SetMarkerColor(kGray+2);
811   histoTrackClu2->SetMarkerStyle(26);
812   histoTrackClu2->Draw("same");
813   histoTrackClu5->SetLineColor(4);
814   histoTrackClu5->SetMarkerColor(4);
815   histoTrackClu5->SetMarkerStyle(29);
816   histoTrackClu5->Draw("same");
817   histoTrackClu6->SetLineColor(kBlue+1);
818   histoTrackClu6->SetMarkerColor(kBlue+1);
819   histoTrackClu6->SetMarkerStyle(30);
820   histoTrackClu6->SetTitle("Fraction of tracks with points in ITS");
821   histoTrackClu6->Draw("same");
822   histoTrackClu3->GetYaxis()->SetTitle("Fraction of Tracks with Points in ITS Layers");
823   TLegend* leg3=new TLegend(0.7,0.15,0.88,0.35);
824   TLegendEntry* ent;
825   ent=leg3->AddEntry(histoTrackClu1,"Layer1","PL");
826   ent->SetTextColor(histoTrackClu1->GetMarkerColor());
827   ent=leg3->AddEntry(histoTrackClu2,"Layer2","PL");
828   ent->SetTextColor(histoTrackClu2->GetMarkerColor());
829   ent=leg3->AddEntry(histoTrackClu3,"Layer3","PL");
830   ent->SetTextColor(histoTrackClu3->GetMarkerColor());
831   ent=leg3->AddEntry(histoTrackClu4,"Layer4","PL");
832   ent->SetTextColor(histoTrackClu4->GetMarkerColor());
833   ent=leg3->AddEntry(histoTrackClu5,"Layer5","PL");
834   ent->SetTextColor(histoTrackClu5->GetMarkerColor());
835   ent=leg3->AddEntry(histoTrackClu6,"Layer6","PL");
836   ent->SetTextColor(histoTrackClu6->GetMarkerColor());
837
838   leg3->SetFillStyle(0);
839   leg3->Draw();
840   c5->SaveAs("TrackPoints_trend.pdf");
841     pdfFileNames+=" TrackPoints_trend.pdf";
842   c5->Update();
843
844
845
846   TCanvas* c2=new TCanvas("c2","SDD DriftTime & Charge",1200,800);
847   c2->Divide(2,2);
848   c2->cd(1);
849   histominTime->Draw();
850   histominTime->SetMinimum(450);
851   histominTime->SetMaximum(550);
852   histominTime->GetYaxis()->SetTitle("Minimum Drift Time (ns)");
853   TLatex* td1=new TLatex(0.2,0.85,"SDD minimum drift time (ref=505ns)");
854   td1->SetNDC();
855   td1->SetTextColor(1);
856   td1->Draw();
857   c2->cd(2);
858   histomeanTime->Draw();
859   histomeanTime->SetMinimum(3200);
860   histomeanTime->SetMaximum(3300);
861   histomeanTime->GetYaxis()->SetTitle("Average Drift Time (ns)");
862   TLatex* td2=new TLatex(0.2,0.85,"SDD average drift time");
863   td2->SetNDC();
864   // td2>SetTextColor(1);
865   td2->Draw();
866
867   // TCanvas* c4=new TCanvas("c4","Charge");
868   c2->cd(3);
869   histodEdxTB0->SetLineColor(1);
870   histodEdxTB0->SetMarkerStyle(20);
871   histodEdxTB0->Draw();
872   histodEdxTB0->SetMinimum(90.);
873   histodEdxTB0->SetMaximum(120.);
874   histodEdxTB5->SetLineColor(4);
875   histodEdxTB5->SetMarkerColor(4);
876   histodEdxTB5->SetMarkerStyle(23);
877   // histodEdxTB5->SetMinimum(90);
878   // histodEdxTB5->SetMaximum(120);
879   histodEdxTB5->Draw("same");
880   histodEdxTB0->GetYaxis()->SetTitle("<dE/dx> (keV/300 #mum)");
881   TLegend* leg2=new TLegend(0.6,0.15,0.88,0.35);
882   ent=leg2->AddEntry(histodEdxTB0,"Small drift time","PL");
883   ent=leg2->AddEntry(histodEdxTB5,"Large drift time","PL");
884   ent->SetTextColor(histodEdxTB5->GetMarkerColor());
885   leg2->SetFillStyle(0);
886   leg2->Draw();
887   TLatex* tc1=new TLatex(0.2,0.85,"SDD charge in different drift regions");
888   tc1->SetNDC();
889   tc1->SetTextColor(1);
890   tc1->Draw();
891   // TCanvas* c4b=new TCanvas("c4b","Charge per Layer");
892   c2->cd(4);
893   histodEdxLay3->SetLineColor(1);
894   histodEdxLay3->SetMarkerStyle(20);
895   histodEdxLay3->Draw();
896   histodEdxLay3->SetMinimum(90.);
897   histodEdxLay3->SetMaximum(120.);
898   histodEdxLay4->SetLineColor(4);
899   histodEdxLay4->SetMarkerColor(4);
900   histodEdxLay4->SetMarkerStyle(23);
901   histodEdxLay4->Draw("same");
902   
903   histodEdxLay5->SetLineColor(6);
904   histodEdxLay5->SetMarkerColor(6);
905   histodEdxLay5->SetMarkerStyle(22);
906   histodEdxLay5->Draw("same");
907   histodEdxLay5->SetMinimum(0.);
908   histodEdxLay6->SetLineColor(7);
909   histodEdxLay6->SetMarkerColor(7);
910   histodEdxLay6->SetMarkerStyle(24);
911   histodEdxLay6->Draw("same");
912     
913   histodEdxLay3->GetYaxis()->SetTitle("<dE/dx> (keV/300 #mum)");
914   
915   TLegend* leg2b=new TLegend(0.6,0.15,0.88,0.35);
916   ent=leg2b->AddEntry(histodEdxLay3,"Layer 3","PL");
917   ent=leg2b->AddEntry(histodEdxLay4,"Layer 4","PL");
918   ent=leg2b->AddEntry(histodEdxLay5,"Layer 5","PL");
919   ent=leg2b->AddEntry(histodEdxLay6,"Layer 6","PL");
920   ent->SetTextColor(histodEdxLay4->GetMarkerColor());
921   leg2b->SetFillStyle(0);
922   leg2b->Draw();
923   // c4b->Update();
924   TLatex* tc2=new TLatex(0.2,0.85,"SDD and SSD charge in different layers");
925   tc2->SetNDC();
926   tc2->SetTextColor(1);
927   tc2->Draw();
928   c2->SaveAs("SDD_SSD_drift_charge_trend.pdf");  
929   pdfFileNames+=" SDD_SSD_drift_charge_trend.pdf";
930   c2->Update();
931
932   TCanvas *c7=new TCanvas("c7","Charge ratio");
933   c7->cd();
934   histoChargeRatioLay5->SetLineColor(6);
935   histoChargeRatioLay5->SetMarkerColor(6);
936   histoChargeRatioLay5->SetMarkerStyle(20);
937   histoChargeRatioLay5->SetMinimum(-0.01);
938   histoChargeRatioLay5->SetMaximum(+0.01);
939   histoChargeRatioLay5->Draw();
940   histoChargeRatioLay6->SetLineColor(7);
941   histoChargeRatioLay6->SetMarkerColor(7);
942   histoChargeRatioLay6->SetMarkerStyle(22);
943   histoChargeRatioLay6->GetYaxis()->SetTitle("SSD charge ratio");
944   histoChargeRatioLay6->Draw("same");
945   TLegend* legCR=new TLegend(0.7,0.75,0.88,0.85);
946   ent=legCR->AddEntry(histoChargeRatioLay5,"Layer5","PL");
947   ent->SetTextColor(histoChargeRatioLay5->GetMarkerColor());
948   ent=legCR->AddEntry(histoChargeRatioLay6,"Layer6","PL");
949   ent->SetTextColor(histoChargeRatioLay6->GetMarkerColor());
950   legCR->SetFillStyle(0);
951   legCR->Draw();
952   TLatex* tc3=new TLatex(0.2,0.85,"SSD charge ratio in different layers");
953   tc3->SetNDC();
954   tc3->SetTextColor(1);
955   tc3->Draw();
956   c7->SaveAs("SSD_chargeratio_trend.pdf");
957       pdfFileNames+=" SSD_chargeratio_trend.pdf";
958   // TCanvas *c8=new TCanvas("c8","Masked modules");
959   // c8->cd();
960   // histoEmpty->Draw();
961
962   TCanvas *cpt02=new TCanvas("cpt02","TPC-ITS matching efficiency",1200,1000);
963   cpt02->Divide(2,2);
964   cpt02->cd(1);
965   hEff6Pt02->SetMinimum(0);
966   hEff6Pt02->Draw();
967   hEff5Pt02->Draw("same");
968   hEff4Pt02->Draw("same");
969   hEff3Pt02->Draw("same");
970   hEff2Pt02->Draw("same");
971   hEffSPDPt02->Draw("same");
972   hEffoneSPDPt02->Draw("same");
973   hEffTOTPt02->Draw("same");
974   hEff6Pt02->GetYaxis()->SetRangeUser(0,1);
975   TLegend* lpt02=new TLegend(0.9,0.8,1,1);
976   lpt02->AddEntry(hEff6Pt02,"6 cls","l");
977   lpt02->AddEntry(hEff5Pt02,"5 cls","l");
978   lpt02->AddEntry(hEff4Pt02,"4 cls","l");
979   lpt02->AddEntry(hEff3Pt02,"3 cls","l");
980   lpt02->AddEntry(hEff2Pt02,"2 cls","l");
981   lpt02->AddEntry(hEffSPDPt02,"2SPD + any","l");
982   lpt02->AddEntry(hEffoneSPDPt02,">=1SPD + any","l");
983   lpt02->AddEntry(hEffTOTPt02,">=2","l");
984   lpt02->Draw("same");
985   TLatex* tpc1=new TLatex(0.2,0.85,"TPCITS match eff Pt=0.2");
986   tpc1->SetNDC();
987   tpc1->SetTextColor(1);
988   tpc1->Draw();
989
990   // TCanvas *cpt1=new TCanvas("cpt1","cpt1");
991   // cpt1->cd(1);
992   cpt02->cd(2);
993
994   hEff6Pt1->Draw();
995   hEff5Pt1->Draw("same");
996   hEff4Pt1->Draw("same");
997   hEff3Pt1->Draw("same");
998   hEff2Pt1->Draw("same");
999   hEffSPDPt1->Draw("same");
1000   hEffoneSPDPt1->Draw("same");
1001   hEffTOTPt1->Draw("same");
1002   hEff6Pt1->GetYaxis()->SetRangeUser(0,1);
1003
1004   TLegend* lpt1=new TLegend(0.9,0.8,1,1);
1005   lpt1->AddEntry(hEff6Pt1,"6 cls","l");
1006   lpt1->AddEntry(hEff5Pt1,"5 cls","l");
1007   lpt1->AddEntry(hEff4Pt1,"4 cls","l");
1008   lpt1->AddEntry(hEff3Pt1,"3 cls","l");
1009   lpt1->AddEntry(hEff2Pt1,"2 cls","l");
1010   lpt1->AddEntry(hEffSPDPt1,"2SPD + any","l");
1011   lpt1->AddEntry(hEffoneSPDPt1,">=1SPD + any","l");
1012   lpt1->AddEntry(hEffTOTPt02,">=2","l");
1013   lpt1->Draw("same");
1014   TLatex* tpc2=new TLatex(0.2,0.75,"TPCITS match eff Pt=1");
1015   tpc2->SetNDC();
1016   tpc2->SetTextColor(1);
1017   tpc2->Draw();
1018
1019
1020   // TCanvas *cpt10=new TCanvas("cpt10","cpt10");
1021   cpt02->cd(3);
1022
1023   hEff6Pt10->Draw();
1024   hEff5Pt10->Draw("same");
1025   hEff4Pt10->Draw("same");
1026   hEff3Pt10->Draw("same");
1027   hEff2Pt10->Draw("same");
1028   hEffSPDPt10->Draw("same");
1029   hEffoneSPDPt10->Draw("same");
1030   hEffTOTPt10->Draw("same");
1031   hEff6Pt10->GetYaxis()->SetRangeUser(0,1);
1032
1033   TLegend* lpt10=new TLegend(0.9,0.8,1,1);
1034   lpt10->AddEntry(hEff6Pt10,"6 cls","l");
1035   lpt10->AddEntry(hEff5Pt10,"5 cls","l");
1036   lpt10->AddEntry(hEff4Pt10,"4 cls","l");
1037   lpt10->AddEntry(hEff3Pt10,"3 cls","l");
1038   lpt10->AddEntry(hEff2Pt10,"2 cls","l");
1039   lpt10->AddEntry(hEffSPDPt10,"2SPD + any","l");
1040   lpt10->AddEntry(hEffoneSPDPt10,">=1SPD + any","l");
1041   lpt10->AddEntry(hEffTOTPt02,">=2","l");
1042   lpt10->Draw("same");
1043
1044   TLatex* tpc3=new TLatex(0.2,0.75,"TPCITS match eff Pt=10");
1045   tpc3->SetNDC();
1046   tpc3->SetTextColor(1);
1047   tpc3->Draw();
1048  
1049   cpt02->cd(4);
1050
1051
1052   //  TCanvas *cSPD = new TCanvas("cSPD","cSPD",0,0,1000,300);
1053   // cSPD->SetGridy();
1054   hFracSPD1->SetMaximum(1.2);
1055   hFracSPD1->SetMinimum(0);
1056   hFracSPD1->Draw("p");
1057   hFracSPD2->Draw("same,p");
1058
1059   TLegend* lSPD=new TLegend(0.9,0.8,1,1);
1060   lSPD->AddEntry(hFracSPD1,"Frac. SPD1 ON","l");
1061   lSPD->AddEntry(hFracSPD2,"Frac. SPD2 ON","l");
1062   lSPD->Draw();
1063   TLatex* tSPD=new TLatex(0.2,0.85,"Fraction of SPD half staves ON");
1064   tSPD->SetNDC();
1065   tSPD->SetTextColor(1);
1066   tSPD->Draw();
1067   cpt02->SaveAs("TPCITS_trend.pdf");
1068       pdfFileNames+=" TPCITS_trend.pdf";
1069   cpt02->Update();
1070
1071   //-----------  ITS SA -----------
1072   PlotITSSA(fil,myIndex,kRunsToPlot);
1073  // merge the pdf files
1074   TString command("gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged");
1075   command=command+"ITS_trend.pdf "+pdfFileNames;
1076   gSystem->Exec(command.Data());
1077   printf(" Merging the pdf file:  %s \n",command.Data());
1078   delete [] myIndex;
1079   delete [] noRuns;
1080 }
1081
1082 //____________________________________________________________________________
1083 void PlotITSSA(TFile *fil,Int_t *myIndex,Int_t kRunsToPlot){
1084   Double_t Lowbin[3]={0.1,0.5,0.9};
1085   Double_t Upbin[3]={0.2,0.6,1};
1086   gROOT->SetStyle("Plain");
1087   gStyle->SetOptTitle(0);
1088   gStyle->SetOptStat(0);
1089   gStyle->SetFillColor(0);
1090   gStyle->SetTextFont(32);
1091   
1092   TNtuple* nt = (TNtuple*)fil->Get("ntITSsa");
1093   Int_t nruns=nt->GetEntries();
1094   printf("Events = %d - Runs to be processed %d\n",nruns,kRunsToPlot);
1095   Float_t ITSA[3];
1096   Float_t TPIT[3];
1097   Float_t RAT[3];
1098   Float_t run;
1099   nt->SetBranchAddress("run",&run);
1100   nt->SetBranchAddress("NITSsaPtBin0",&ITSA[0]);
1101   nt->SetBranchAddress("NITSsaPtBin1",&ITSA[1]);
1102   nt->SetBranchAddress("NITSsaPtBin2",&ITSA[2]);
1103   nt->SetBranchAddress("NITSTPCPtBin0",&TPIT[0]);
1104   nt->SetBranchAddress("NITSTPCPtBin1",&TPIT[1]);
1105   nt->SetBranchAddress("NITSTPCPtBin2",&TPIT[2]);
1106   nt->SetBranchAddress("ratioPtBin0",&RAT[0]);
1107   nt->SetBranchAddress("ratioPtBin1",&RAT[1]);
1108   nt->SetBranchAddress("ratioPtBin2",&RAT[2]);
1109   TH1F *h0=new TH1F("h0","h0",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1110   TH1F *h1=new TH1F("h1","h1",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1111   TH1F *h2=new TH1F("h2","h2",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1112   TH1F *h3=new TH1F("h3","h4",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1113   TH1F *h4=new TH1F("h4","h5",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1114   TH1F *h5=new TH1F("h5","h5",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1115   TH1F *h6=new TH1F("h6","h6",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1116   TH1F *h7=new TH1F("h7","h7",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1117   TH1F *h8=new TH1F("h8","h8",kRunsToPlot,-0.5,kRunsToPlot-0.5);
1118   for(Int_t iev=0;iev<kRunsToPlot;iev++){
1119     nt->GetEvent(myIndex[iev]);
1120     //cout<<"Numeri TPCITS "<<TPIT[0]<<" "<<TPIT[1]<<" "<<TPIT[2]<<endl;
1121     h0->Fill(iev,ITSA[0]);
1122     h1->Fill(iev,ITSA[1]);
1123     h2->Fill(iev,ITSA[2]);
1124     h3->Fill(iev,TPIT[0]);
1125     h4->Fill(iev,TPIT[1]);
1126     h5->Fill(iev,TPIT[2]);
1127     h6->Fill(iev,RAT[0]);
1128     h7->Fill(iev,RAT[1]);
1129     h8->Fill(iev,RAT[2]);
1130     h0->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1131     h1->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1132     h2->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1133     h3->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1134     h4->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1135     h5->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1136     h6->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1137     h7->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1138     h8->GetXaxis()->SetBinLabel(iev+1,Form("%.0f",run));
1139     Printf("%f   %f   %f",ITSA[0],ITSA[1],ITSA[2]);
1140   }
1141   h0->Print("all");
1142   h0->GetYaxis()->SetTitle("ITSsa tracks");
1143   h0->GetXaxis()->SetTitle("run");
1144   h1->GetYaxis()->SetTitle("ITSsa tracks");
1145   h1->GetXaxis()->SetTitle("run");
1146   h2->GetYaxis()->SetTitle("ITSsa tracks");
1147   h2->GetXaxis()->SetTitle("run");
1148   h3->GetYaxis()->SetTitle("ITS+TPC tracks");
1149   h3->GetXaxis()->SetTitle("run");
1150   h4->GetYaxis()->SetTitle("ITS+TPC tracks");
1151   h4->GetXaxis()->SetTitle("run");
1152   h5->GetYaxis()->SetTitle("ITS+TPC tracks");
1153   h5->GetXaxis()->SetTitle("run");
1154   h6->GetYaxis()->SetTitle("(TPC+ITS)/ITS");
1155   h6->GetXaxis()->SetTitle("run");
1156   h7->GetYaxis()->SetTitle("(TPC+ITS)/ITS");
1157   h7->GetXaxis()->SetTitle("run");
1158   h8->GetYaxis()->SetTitle("(TPC+ITS)/ITS");
1159   h8->GetXaxis()->SetTitle("run");
1160   h0->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[0],Upbin[0]));
1161   h1->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[1],Upbin[1]));
1162   h2->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[2],Upbin[2]));
1163   h3->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[0],Upbin[0]));
1164   h4->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[1],Upbin[1]));
1165   h5->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[2],Upbin[2]));
1166   h6->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[0],Upbin[0]));
1167   h7->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[1],Upbin[1]));
1168   h8->SetTitle(Form("%.1f GeV/c < pt < %.1f GeV/c",Lowbin[2],Upbin[2]));
1169   h0->SetMinimum(100);
1170 //   h0->SetMaximum(2);
1171   h1->SetMinimum(100);
1172 //   h1->SetMaximum(2);
1173   h2->SetMinimum(100);
1174 //   h2->SetMaximum(2);
1175   h3->SetMinimum(100);
1176   h4->SetMinimum(100);
1177   h5->SetMinimum(100);
1178
1179   h8->SetMinimum(0.);
1180   h8->SetMaximum(20.);
1181
1182   h0->SetMarkerStyle(22);
1183   h1->SetMarkerStyle(23);
1184   h2->SetMarkerStyle(24);
1185   h0->SetMarkerColor(2);
1186   h1->SetMarkerColor(1);
1187   h2->SetMarkerColor(4);
1188   h0->SetLineColor(2);
1189   h1->SetLineColor(1);
1190   h2->SetLineColor(4);
1191
1192   h3->SetMarkerStyle(22);
1193   h4->SetMarkerStyle(23);
1194   h5->SetMarkerStyle(24);
1195   h3->SetMarkerColor(2);
1196   h4->SetMarkerColor(1);
1197   h5->SetMarkerColor(4);
1198   h3->SetLineColor(2);
1199   h4->SetLineColor(1);
1200   h5->SetLineColor(4);
1201
1202   h6->SetMarkerStyle(22);
1203   h7->SetMarkerStyle(23);
1204   h8->SetMarkerStyle(24);
1205   h6->SetMarkerColor(2);
1206   h7->SetMarkerColor(1);
1207   h8->SetMarkerColor(4);
1208   h6->SetLineColor(2);
1209   h7->SetLineColor(1);
1210   h8->SetLineColor(4);
1211
1212   TCanvas *c=new TCanvas();
1213   c->SetLogy();
1214   c->SetGridy();
1215   h0->Draw("p");
1216   h1->Draw("psame");
1217   h2->Draw("psame");
1218 c->BuildLegend(0.11,0.15,0.45,0.30);
1219   TLatex* ti1=new TLatex(0.11,0.40,"ITS standalone tracks (normalized to number of events)");
1220   ti1->SetNDC();
1221   ti1->SetTextColor(1);
1222   ti1->Draw();
1223   c->SaveAs("ITSsa_trend.pdf");
1224       pdfFileNames+=" ITSsa_trend.pdf";
1225   TCanvas *c2=new TCanvas();
1226   c2->SetLogy();
1227   c2->SetGridy();
1228   h3->Draw("p");
1229   h4->Draw("psame");
1230   h5->Draw("psame");
1231  c2->BuildLegend(0.11,0.15,0.45,0.30);
1232   TLatex* ti2=new TLatex(0.11,0.40,"ITS+TPC tracks (normalized to number of events)");
1233   ti2->SetNDC();
1234   ti2->SetTextColor(1);
1235   ti2->Draw();
1236    c2->SaveAs("ITSTPC_trend.pdf");
1237       pdfFileNames+=" ITSTPC_trend.pdf";
1238  
1239   TCanvas *c3=new TCanvas();
1240   c3->SetGridy();
1241   h8->Draw("p");
1242   h7->Draw("psame");
1243   h6->Draw("psame");
1244    c3->BuildLegend();
1245   TLatex* ti3=new TLatex(0.15,0.8,"ratio (ITS+TPC)/ITS ");
1246   ti3->SetNDC();
1247   ti3->Draw();
1248    c3->SaveAs("tracks_ratio_trend.pdf");
1249       pdfFileNames+=" tracks_ratio_trend.pdf";
1250
1251 }
1252
1253
1254
1255 //____________________________________________________________________________
1256 void AliITSQAtrend(TString runListFile,TString ntupleFileName){
1257
1258   TGrid::Connect("alien://");
1259   
1260
1261   
1262   //-----------SDD
1263   
1264   const Int_t nVariables=35;
1265   TNtuple* ntsdd=new TNtuple("ntsdd","SDD trending","nrun:fracTrackWithClu1:errfracTrackWithClu1:fracTrackWithClu2:errfracTrackWithClu2:fracTrackWithClu3:errfracTrackWithClu3:fracTrackWithClu4:errfracTrackWithClu4:fracTrackWithClu5:errfracTrackWithClu5:fracTrackWithClu6:errfracTrackWithClu6:meanTrPts3:errmeanTrPts3:meanTrPts4:errmeanTrPts4:minDrTime:errminDrTime:meanDrTime:errmeanDrTime:fracExtra:errfracExtra:meandEdxLay3:errmeandEdxLay3:meandEdxLay4:errmeandEdxLay4:meandEdxTB0:errmeandEdxTB0:meandEdxTB5:errmeandEdxTB5:nMod95:nMod80:nMod60:nModEmpty");
1266   Float_t xnt[nVariables];
1267   
1268   //--------------SSD
1269     
1270   const Int_t nVariablesSSD=10;
1271   TNtuple* ntssd=new TNtuple("ntssd","SSD trending","nrun:meandEdxLay5:errmeandEdxLay5:meandEdxLay6:errmeandEdxLay6:ChargeRatioL5:errChargeratioL5:ChargeRatioL6:errChargeratioL6:moduleOff");
1272   Float_t xntSSD[nVariablesSSD];
1273   
1274   //----Matching
1275
1276   const Int_t nVariablesMatching=60;
1277   TNtuple* ntmatching=new TNtuple("ntmatching","Matching Efficiency","nrun:FracSPD1:errFracSPD1:FracSPD2:errFracSPD2:Eff6Pt02:errEff6Pt02:Eff6Pt1:errEff6Pt1:Eff6Pt10:errEff6Pt10:Eff5Pt02:errEff5Pt02:Eff5Pt1:errEff5Pt1:Eff5Pt10:errEff5Pt10:Eff4Pt02:errEff4Pt02:Eff4Pt1:errEff4Pt1:Eff4Pt10:errEff4Pt10:Eff3Pt02:errEff3Pt02:Eff3Pt1:errEff3Pt1:Eff3Pt10:errEff3Pt10:Eff2Pt02:errEff2Pt02:Eff2Pt1:errEff2Pt1:Eff2Pt10:errEff2Pt10:EffSPDPt02:errEffSPDPt02:EffSPDPt1:errEffSPDPt1:EffSPDPt10:errEffSPDPt10:EffoneSPDPt02:errEffoneSPDPt02:EffoneSPDPt1:errEffoneSPDPt1:EffoneSPDPt10:errEffoneSPDPt10:EffTOTPt02:errEffTOTPt02:EffTOTPt1:errEffTOTPt1:EffTOTPt10:errEffTOTPt10");
1278
1279   Float_t xntMatching[nVariablesMatching];
1280   
1281   //--------------------------------
1282
1283   //----QA Vertex
1284
1285       const Int_t nVariablesVertex=15;
1286       TNtuple* ntvertex=new TNtuple("ntvertex","QA Vertex","nrun:Vx:errVx:sigmaVx:errsigmaVx:Vy:errVy:sigmaVy:errsigmaVy:Vz:errVz:sigmaVz:errsigmaVz");
1287       
1288       Float_t xntVertex[nVariablesVertex];
1289   
1290   //--------------------------------
1291
1292   //-----  Tracking ITS SA
1293   const Int_t nVariablesSA=13;
1294   Float_t xntSA[nVariablesSA];
1295   TNtuple *ntSA=new TNtuple("ntITSsa","ntITSsa","run:NITSTPCPtBin0:NITSTPCPtBin1:NITSTPCPtBin2:NITSsaPtBin0:NITSsaPtBin1:NITSsaPtBin2:NITSpureSAPtBin0:NITSpureSAPtBin1:NITSpureSAPtBin2:ratioPtBin0:ratioPtBin1:ratioPtBin2");
1296
1297   //---------------------------------
1298
1299
1300   
1301   TBits* readRun=new TBits(999999);
1302   readRun->ResetAllBits();
1303   //    if(!useExternalList){
1304   if(!gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",ntupleFileName.Data()))){
1305     TFile* oldfil=new TFile(ntupleFileName.Data());
1306     
1307     TNtuple* ntmp=(TNtuple*)oldfil->Get("ntsdd");
1308     
1309     TNtuple* ntmpSSD=(TNtuple*)oldfil->Get("ntssd");
1310
1311     TNtuple* ntmpMatching=(TNtuple*)oldfil->Get("ntmatching");
1312
1313     TNtuple* ntmpVertex=(TNtuple*)oldfil->Get("ntvertex");
1314
1315     TNtuple* ntmpSA=(TNtuple*)oldfil->Get("ntITSsa");
1316
1317     
1318     //-------SDD
1319     
1320     Bool_t isOK=kFALSE;
1321     if(ntmp){
1322       if(ntmp->GetNvar()==ntsdd->GetNvar()){
1323         isOK=kTRUE;
1324         TObjArray* arr1=(TObjArray*)ntsdd->GetListOfBranches();
1325         TObjArray* arr2=(TObjArray*)ntmp->GetListOfBranches();
1326           for(Int_t iV=0; iV<ntmp->GetNvar(); iV++){
1327             TString vnam1=arr1->At(iV)->GetName();
1328             TString vnam2=arr2->At(iV)->GetName();
1329             if(vnam1!=vnam2) isOK=kFALSE;
1330             ntmp->SetBranchAddress(vnam2.Data(),&xnt[iV]);
1331           }
1332           if(isOK){
1333             for(Int_t nE=0; nE<ntmp->GetEntries(); nE++){
1334               ntmp->GetEvent(nE);
1335               Int_t theRun=(Int_t)(xnt[0]+0.0001);
1336               readRun->SetBitNumber(theRun);
1337               ntsdd->Fill(xnt);
1338             }
1339           }
1340         }
1341       }
1342       if(!isOK){
1343         printf("Ntuple in local file not OK -> will be recreated\n");
1344       }
1345         
1346       //----------SSD----------
1347         
1348       Bool_t isOKSSD=kFALSE;
1349       if(ntmpSSD){
1350         if(ntmpSSD->GetNvar()==ntssd->GetNvar()){
1351           isOKSSD=kTRUE;
1352           TObjArray* arr1ssd=(TObjArray*)ntssd->GetListOfBranches();
1353           TObjArray* arr2ssd=(TObjArray*)ntmpSSD->GetListOfBranches();
1354           for(Int_t iV=0; iV<ntmpSSD->GetNvar(); iV++){
1355             TString vnam1=arr1ssd->At(iV)->GetName();
1356             TString vnam2=arr2ssd->At(iV)->GetName();
1357             if(vnam1!=vnam2) isOKSSD=kFALSE;
1358             ntmpSSD->SetBranchAddress(vnam2.Data(),&xntSSD[iV]);
1359           }
1360           if(isOKSSD){
1361             for(Int_t nE=0; nE<ntmpSSD->GetEntries(); nE++){
1362               ntmpSSD->GetEvent(nE);
1363               Int_t theRun=(Int_t)(xntSSD[0]+0.0001);
1364               readRun->SetBitNumber(theRun);
1365               ntssd->Fill(xntSSD);
1366             }
1367           }
1368         }
1369       }
1370       if(!isOKSSD){
1371         printf("\n\nNtuple SSD in local file not OK -> will be recreated\n\n");
1372       }
1373
1374       //---------Matching---------
1375         
1376       Bool_t isOKMatching=kFALSE;
1377       if(ntmpMatching){
1378         if(ntmpMatching->GetNvar()==ntmatching->GetNvar()){
1379           isOKMatching=kTRUE;
1380           TObjArray* arr1matching=(TObjArray*)ntmatching->GetListOfBranches();
1381           TObjArray* arr2matching=(TObjArray*)ntmpMatching->GetListOfBranches();
1382           for(Int_t iV=0; iV<ntmpMatching->GetNvar(); iV++){
1383             TString vnam1=arr1matching->At(iV)->GetName();
1384             TString vnam2=arr2matching->At(iV)->GetName();
1385             if(vnam1!=vnam2) isOKMatching=kFALSE;
1386             ntmpMatching->SetBranchAddress(vnam2.Data(),&xntMatching[iV]);
1387           }
1388           if(isOKMatching){
1389             for(Int_t nE=0; nE<ntmpMatching->GetEntries(); nE++){
1390               ntmpMatching->GetEvent(nE);
1391               Int_t theRun=(Int_t)(xntMatching[0]+0.0001);
1392               readRun->SetBitNumber(theRun);
1393               ntmatching->Fill(xntMatching);
1394             }
1395           }
1396         }
1397       }
1398       if(!isOKMatching){
1399         printf("\n\nNtuple Matching in local file not OK -> will be recreated\n\n");
1400       }
1401       //-----------------------
1402
1403       //---------Vertex QA---------
1404         
1405       Bool_t isOKVertex=kFALSE;
1406       if(ntmpVertex){
1407         if(ntmpVertex->GetNvar()==ntvertex->GetNvar()){
1408           isOKVertex=kTRUE;
1409           TObjArray* arr1vertex=(TObjArray*)ntvertex->GetListOfBranches();
1410           TObjArray* arr2vertex=(TObjArray*)ntmpVertex->GetListOfBranches();
1411           for(Int_t iV=0; iV<ntmpVertex->GetNvar(); iV++){
1412             TString vnam1=arr1vertex->At(iV)->GetName();
1413             TString vnam2=arr2vertex->At(iV)->GetName();
1414             if(vnam1!=vnam2) isOKVertex=kFALSE;
1415             ntmpVertex->SetBranchAddress(vnam2.Data(),&xntVertex[iV]);
1416           }
1417           if(isOKVertex){
1418             for(Int_t nE=0; nE<ntmpVertex->GetEntries(); nE++){
1419               ntmpVertex->GetEvent(nE);
1420               Int_t theRun=(Int_t)(xntVertex[0]+0.0001);
1421               readRun->SetBitNumber(theRun);
1422               ntvertex->Fill(xntVertex);
1423             }
1424           }
1425         }
1426       }
1427       if(!isOKVertex){
1428         printf("\n\nNtuple Vertex in local file not OK -> will be recreated\n\n");
1429       }
1430       //-----------------------
1431
1432       //-----------Tracking SA ----------------
1433       Bool_t isOKSA = kFALSE;
1434       if(ntmpSA){
1435         if(ntmpSA->GetNvar()==ntSA->GetNvar()){
1436           isOKSA = kTRUE;
1437           TObjArray* arr1SA=(TObjArray*)ntSA->GetListOfBranches();
1438           TObjArray* arr2SA=(TObjArray*)ntmpSA->GetListOfBranches();
1439           for(Int_t iV=0; iV<ntmpSA->GetNvar(); iV++){
1440             TString vnam1=arr1SA->At(iV)->GetName();
1441             TString vnam2=arr2SA->At(iV)->GetName();
1442             if(vnam1!=vnam2) isOKSA=kFALSE;
1443             ntmpSA->SetBranchAddress(vnam2.Data(),&xntSA[iV]);
1444           }
1445           if(isOKSA){
1446             for(Int_t nE=0; nE<ntmpSA->GetEntries(); nE++){
1447               ntmpSA->GetEvent(nE);
1448               Int_t theRun=(Int_t)(xntSA[0]+0.0001);
1449               readRun->SetBitNumber(theRun);
1450               ntSA->Fill(xntSA);
1451             }
1452           }
1453         }
1454       }
1455
1456       oldfil->Close();
1457       delete oldfil;
1458   }
1459
1460 #define MAX_LINES 200
1461 #define MAX_LINE_LEN 255
1462   
1463   char strings[MAX_LINES][MAX_LINE_LEN];
1464   ifstream in(runListFile.Data());
1465   int j = 0;
1466   Int_t nrun=0;
1467   Int_t runNumb[MAX_LINES];
1468   Bool_t goout = kFALSE;
1469   while ( in ) {
1470     in.getline(strings[j], MAX_LINE_LEN);
1471     TString aux(strings[j]);
1472     Int_t lentrail=0;
1473     if(aux.Contains("LHC11h/")){
1474       lentrail = 27;
1475     }
1476     else if(aux.Contains("LHC11h_2/")){
1477       lentrail = 29;
1478     }
1479     else {
1480       if(!aux.IsNull())printf("Unrecognised path name %s \n",aux.Data());
1481       goout = kTRUE;
1482     }
1483     if(goout)break;
1484     if(aux.Length()<lentrail)continue;
1485     aux=aux.Remove(0,lentrail);
1486     aux=aux.Remove(6,aux.Length());  
1487     runNumb[j]=atoi(aux.Data());
1488     printf("%d ) - path %s \n",runNumb[j],strings[j]);
1489     j++;
1490     nrun++;
1491   }
1492
1493   printf("\n *******************   Loop on runs *********** \n");
1494   for(Int_t jru=0;jru<nrun;jru++) {
1495     printf("jru=%d - run number= %d \n",jru,runNumb[jru]);
1496     Int_t iRun=runNumb[jru];
1497     if(readRun->TestBitNumber(iRun))printf("Run %d - already processed\n",iRun);
1498     if(readRun->TestBitNumber(iRun))continue;
1499     //cout << "Value from file is " <<t << endl;
1500     
1501     printf("%s\n",strings[jru]);
1502   
1503   
1504     if(!gGrid||!gGrid->IsConnected()) {
1505       printf("gGrid not found! exit macro\n");
1506       return;
1507     }
1508     
1509     TFile *f=TFile::Open(Form("alien://%s",strings[jru])); 
1510     
1511     TDirectoryFile* df=(TDirectoryFile*)f->Get("SDD_Performance");
1512     if(!df){
1513       printf("Run %d SDD_Performance MISSING -> Exit\n",iRun);
1514       continue;
1515     }
1516     
1517     TList* l=(TList*)df->Get("coutputRP");
1518     if(!df){
1519       printf("Run %d coutputRP TList MISSING -> Exit\n",iRun);
1520       continue;
1521     }  
1522     
1523     //-------------------
1524
1525     
1526     //------------SDD
1527
1528     TH1F* hcllay=(TH1F*)l->FindObject("hCluInLay");
1529       Float_t fracT[6]={0.,0.,0.,0.,0.,0.};
1530       Float_t efracT[6]={0.,0.,0.,0.,0.,0.};
1531       if(hcllay->GetBinContent(1)>0){
1532         for(Int_t iLay=0; iLay<6; iLay++){
1533           fracT[iLay]=hcllay->GetBinContent(iLay+2)/hcllay->GetBinContent(1);
1534           efracT[iLay]=TMath::Sqrt(fracT[iLay]*(1-fracT[iLay])/hcllay->GetBinContent(1));
1535         }
1536       }
1537       TH1F* hmodT=(TH1F*)l->FindObject("hTPMod");
1538       TH1F* hgamod=(TH1F*)l->FindObject("hGAMod");
1539       Int_t bestMod=0;
1540       for(Int_t iMod=0; iMod<260;iMod++){
1541         Int_t gda=(Int_t)hgamod->GetBinContent(iMod+1);
1542         if(gda>bestMod) bestMod=gda;
1543       }
1544       Int_t nChunks=1;
1545       if(bestMod>512){
1546         nChunks=(Int_t)(bestMod/512.+0.5);
1547       }
1548       hgamod->Scale(1./nChunks);
1549
1550       TH1F* hev=(TH1F*)l->FindObject("hNEvents");
1551       Int_t nTotEvents=hev->GetBinContent(2);
1552       Int_t nTrigEvents=hev->GetBinContent(3);
1553       Int_t nEvents=nTotEvents;
1554       printf("Run %d Number of Events = %d Triggered=%d\n",iRun,nTotEvents,nTrigEvents);
1555       if(nTrigEvents>0){ 
1556         nEvents=nTrigEvents;
1557       }
1558       if(nTotEvents==0) continue;
1559       Int_t nModGood3=0;
1560       Int_t nModGood4=0;
1561       Int_t nModBadAn=0;
1562       Float_t sumtp3=0;
1563       Float_t sumtp4=0;
1564       Float_t sumEtp3=0;
1565       Float_t sumEtp4=0;
1566       for(Int_t iMod=0; iMod<260; iMod++){
1567         Float_t tps=hmodT->GetBinContent(iMod+1);
1568         Float_t ga=hgamod->GetBinContent(iMod+1);
1569         if(ga<500) nModBadAn++;
1570         Float_t tpsN=0.;
1571         Float_t etpsN=0.;
1572         if(ga>0){
1573           tpsN=tps/ga/(Float_t)nEvents;
1574           etpsN=TMath::Sqrt(tps)/ga/(Float_t)nEvents;
1575           if(iMod<84){
1576             sumtp3+=tpsN;
1577             sumEtp3+=(etpsN*etpsN);
1578             nModGood3++;
1579           }
1580           else{
1581             sumtp4+=tpsN;
1582             sumEtp4+=(etpsN*etpsN);
1583             nModGood4++;
1584           }
1585         }
1586       }
1587
1588       TH1F* hapmod=(TH1F*)l->FindObject("hAllPmod");
1589       TH1F* hgpmod=(TH1F*)l->FindObject("hGoodPmod");
1590       //     TH1F* hmpmod=(TH1F*)l->FindObject("hMissPmod");
1591       TH1F* hbrmod=(TH1F*)l->FindObject("hBadRegmod");
1592       TH1F* hskmod=(TH1F*)l->FindObject("hSkippedmod");
1593       TH1F* hoamod=(TH1F*)l->FindObject("hOutAccmod");
1594       TH1F* hnrmod=(TH1F*)l->FindObject("hNoRefitmod");
1595       Int_t nBelow95=0;
1596       Int_t nBelow80=0;
1597       Int_t nBelow60=0;
1598       Int_t nZeroP=0;
1599       for(Int_t imod=0; imod<260;imod++){
1600         Float_t numer=hgpmod->GetBinContent(imod+1)+hbrmod->GetBinContent(imod+1)+hoamod->GetBinContent(imod+1)+hnrmod->GetBinContent(imod+1)+hskmod->GetBinContent(imod+1);
1601         Float_t denom=hapmod->GetBinContent(imod+1);
1602         if(denom>0){
1603           Float_t eff=numer/denom;
1604           if(eff<0.95) nBelow95++;
1605           if(eff<0.80) nBelow80++;
1606           if(eff<0.60) nBelow60++;
1607         }
1608         if(hmodT->GetBinContent(imod+1)<1.){
1609           nZeroP++;
1610         }       
1611       }
1612
1613       TH1F* htimT=(TH1F*)l->FindObject("hDrTimTPAll");
1614       TH1F* htimTe=(TH1F*)l->FindObject("hDrTimTPExtra");
1615       
1616       Double_t fracExtra=0.;
1617       Double_t errFracExtra=0.;
1618       if(htimT->GetEntries()>0){
1619         fracExtra=htimTe->GetEntries()/htimT->GetEntries();
1620         errFracExtra=TMath::Sqrt(htimTe->GetEntries())/htimT->GetEntries();
1621       }
1622       Double_t averPoints=0.;
1623       Double_t cntBins=0.;
1624       for(Int_t iBin=1; iBin<=htimT->GetNbinsX(); iBin++){
1625         Float_t tim=htimT->GetBinCenter(iBin);
1626         if(tim>2000. && tim<4000.){
1627           averPoints+=htimT->GetBinContent(iBin);
1628           cntBins+=1;
1629         }
1630       }
1631       Double_t minTime=-999.;
1632       Double_t errMinTime=0.;
1633       if(cntBins>0){ 
1634         averPoints/=cntBins;
1635         for(Int_t iBin=1; iBin<=htimT->GetNbinsX(); iBin++){
1636           if(htimT->GetBinContent(iBin)>0.5*averPoints){
1637             minTime=htimT->GetBinCenter(iBin);
1638             errMinTime=0.5*htimT->GetBinWidth(iBin);
1639             break;
1640           }
1641         }
1642       }
1643
1644       TH2F* hdedxmod=(TH2F*)l->FindObject("hdEdxVsMod");
1645       TH1D* hdedxLay3=hdedxmod->ProjectionY("hdedxLay3",1,84);
1646       TH1D* hdedxLay4=hdedxmod->ProjectionY("hdedxLay4",85,260);
1647       
1648       TH1F* hSigTim0=(TH1F*)l->FindObject("hSigTimeInt0");
1649       TH1F* hSigTim5=(TH1F*)l->FindObject("hSigTimeInt5");
1650
1651       Int_t index=0;
1652       xnt[index++]=iRun;
1653       xnt[index++]=fracT[0];
1654       xnt[index++]=efracT[0];
1655       xnt[index++]=fracT[1];
1656       xnt[index++]=efracT[1];
1657       xnt[index++]=fracT[2];
1658       xnt[index++]=efracT[2];
1659       xnt[index++]=fracT[3];
1660       xnt[index++]=efracT[3];
1661       xnt[index++]=fracT[4];
1662       xnt[index++]=efracT[4];
1663       xnt[index++]=fracT[5];
1664       xnt[index++]=efracT[5];
1665       xnt[index++]=sumtp3/nModGood3;
1666       xnt[index++]=TMath::Sqrt(sumEtp3)/nModGood3;
1667       xnt[index++]=sumtp4/nModGood4;
1668       xnt[index++]=TMath::Sqrt(sumEtp4)/nModGood4;
1669       xnt[index++]=minTime;
1670       xnt[index++]=errMinTime;
1671       xnt[index++]=htimT->GetMean();
1672       xnt[index++]=htimT->GetMeanError();
1673       xnt[index++]=fracExtra;
1674       xnt[index++]=errFracExtra;
1675       xnt[index++]=hdedxLay3->GetMean();
1676       xnt[index++]=hdedxLay3->GetMeanError();
1677       xnt[index++]=hdedxLay4->GetMean();
1678       xnt[index++]=hdedxLay4->GetMeanError();
1679       xnt[index++]=hSigTim0->GetMean();
1680       xnt[index++]=hSigTim0->GetMeanError();
1681       xnt[index++]=hSigTim5->GetMean();
1682       xnt[index++]=hSigTim5->GetMeanError();
1683       xnt[index++]=(Float_t)nBelow95;
1684       xnt[index++]=(Float_t)nBelow80;
1685       xnt[index++]=(Float_t)nBelow60;
1686       xnt[index++]=(Float_t)nZeroP;
1687       ntsdd->Fill(xnt);
1688
1689       cout<<"\n\nirun sDD"<<iRun<<endl<<endl;
1690
1691       //-------SSD
1692
1693       //TFile* fSSD=TFile::Open(fileNameLong.Data());  
1694     
1695       //TDirectoryFile* dfSSD=(TDirectoryFile*)fSSD->Get("PWGPPdEdxSSDQA");
1696       TDirectoryFile* dfSSD=(TDirectoryFile*)f->Get("PWGPPdEdxSSDQA");
1697       if(!dfSSD){
1698         printf("Run %d SDD_Performance MISSING -> Exit\n",iRun);
1699         continue;
1700       }
1701       
1702       TList* lSSD=(TList*)dfSSD->Get("SSDdEdxQA");
1703       if(!dfSSD){
1704         printf("Run %d coutputRP TList MISSING -> Exit\n",iRun);
1705         continue;
1706       }
1707       //
1708       
1709       TH2F* QAchargeRatio=(TH2F*)lSSD->FindObject("QAChargeRatio");
1710       TH2F* QAcharge=(TH2F*)lSSD->FindObject("QACharge");
1711     
1712       Int_t biny = QAcharge->GetXaxis()->FindBin(747);
1713       Int_t maxy = QAcharge->GetXaxis()->GetXmax();
1714       //     Int_t miny = QAcharge->GetXaxis()->GetXmin();
1715     
1716       Int_t  contEmpty=0;
1717       Int_t  contFull=0;
1718     
1719       TH1D *hChargeL5=QAcharge->ProjectionY("hChargeL5",0,biny);
1720       TH1D *hChargeL6=QAcharge->ProjectionY("hChargeL6",biny,maxy);
1721     
1722       cout<<  hChargeL5->GetMean()<< " " <<  hChargeL5->GetRMS()<<endl;
1723       cout<<  hChargeL6->GetMean()<< " " <<  hChargeL6->GetRMS()<<endl;
1724     
1725       TH1D *hChargeRatioL5=QAchargeRatio->ProjectionY("hChargeRatioL5",0,biny);
1726       TH1D *hChargeRatioL6=QAchargeRatio->ProjectionY("hChargeRatioL6",biny,maxy);
1727     
1728       cout<<  hChargeRatioL5->GetMean()<< " " <<  hChargeRatioL5->GetRMS()<<endl;
1729       cout<<  hChargeRatioL6->GetMean()<< " " <<  hChargeRatioL6->GetRMS()<<endl;
1730     
1731       if(QAcharge->GetEntries()< 45000)
1732         contEmpty=1;
1733       
1734       else{
1735         for(Int_t i =0;i<1698;i++){
1736           
1737           TString tmpQ("Q");
1738           tmpQ+=i;
1739           
1740           TH1D* fHist1DQ= QAcharge->ProjectionY(tmpQ,i+1,i+1);
1741           Double_t mean=fHist1DQ->GetMean();
1742
1743           if(TMath::Abs(mean)<1.0 ||fHist1DQ->GetEntries()<10)
1744             contEmpty++;
1745           
1746           else 
1747             contFull++;
1748           
1749         }
1750       }
1751
1752       cout<<"contFull: " <<contFull<<" contEmpty: "<<contEmpty<<endl;
1753       cout<<hChargeL5->GetMean()<<endl;
1754
1755       Int_t indexSSD=0;
1756       xntSSD[indexSSD++]=iRun;
1757       xntSSD[indexSSD++]=(Float_t)hChargeL5->GetMean();
1758       xntSSD[indexSSD++]=(Float_t)hChargeL5->GetMeanError();
1759       xntSSD[indexSSD++]=(Float_t)hChargeL6->GetMean();
1760       xntSSD[indexSSD++]=(Float_t)hChargeL6->GetMeanError();
1761       xntSSD[indexSSD++]=(Float_t)hChargeRatioL5->GetMean();
1762       xntSSD[indexSSD++]=(Float_t)hChargeRatioL5->GetMeanError();
1763       xntSSD[indexSSD++]=(Float_t)hChargeRatioL6->GetMean();
1764       xntSSD[indexSSD++]=(Float_t)hChargeRatioL6->GetMeanError();
1765       xntSSD[indexSSD++]=(Float_t)contEmpty;
1766       ntssd->Fill(xntSSD);                                              
1767
1768       cout<<xnt<<endl<<endl;
1769
1770       cout<<"\n\nirun ssd "<<iRun<<endl<<endl;
1771
1772       cout<< iRun<<" "<<hChargeL5->GetMean()<<" "<< hChargeL5->GetRMS()<<" "<<hChargeL6->GetMean()<<" "<<hChargeRatioL5->GetMean()<<" "<<" "<<hChargeRatioL5->GetRMS()<<" "<<hChargeRatioL6->GetMean()<<" "<<hChargeRatioL6->GetRMS()<<" "<<contEmpty<<endl;
1773
1774       cout<<xntSSD[0]<<" "<<xntSSD[1]<<" "<<xntSSD[2]<<" "<<xntSSD[3]<<endl;;
1775       
1776       //--------------matching
1777
1778       TDirectoryFile *dirMatch=(TDirectoryFile*)f->GetDirectory("ITS_Performance");
1779       TList *list=NULL;
1780       TList *listSPD=NULL;
1781       
1782       if(dirMatch) {
1783         list = (TList*)dirMatch->Get("cOutputITS_3500_10000"); //LHC11h
1784         if(!list)list = (TList*)dirMatch->Get("cOutputITS"); // LHC11e
1785       }
1786       dirMatch=(TDirectoryFile*)f->GetDirectory("SPD_Performance");
1787       if(dirMatch) listSPD = (TList*)dirMatch->Get("coutput1");
1788   
1789       // if(!list) return kFALSE;
1790       
1791       Float_t ioValues[30];
1792       Float_t ioErrors[30];
1793       for(Int_t jj=0;jj<30;jj++){
1794         ioValues[jj]=0.;
1795         ioErrors[jj]=0.;
1796       }
1797       
1798       Float_t ptbin=0;
1799       
1800       TH1F *hFiredChip = (TH1F*)listSPD->FindObject("hFiredChip");
1801       Int_t nHSsInner=0,nHSsOuter=0;
1802       for(Int_t i=0;i<400;i++) if(hFiredChip->GetBinContent(i)>0) nHSsInner++;
1803       for(Int_t i=400;i<1200;i++) if(hFiredChip->GetBinContent(i)>0) nHSsOuter++;
1804       nHSsInner = (Int_t)(nHSsInner/10);
1805       nHSsOuter = (Int_t)(nHSsOuter/10);
1806       // hnHSsSPD->SetBinContent(1,nHSsInner);
1807   // hnHSsSPD->SetBinContent(2,nHSsOuter);
1808       
1809       ioValues[0]=(Float_t)nHSsInner/40.;
1810       ioValues[1]=(Float_t)nHSsOuter/80.;
1811
1812       TH1F *fHistPtTPCInAcc = (TH1F*)list->FindObject("fHistPtTPCInAcc");
1813       
1814       TH1F *fHistPtITSMI6InAcc = (TH1F*)list->FindObject("fHistPtITSMI6InAcc");
1815       TH1F *fHistPtITSMI5InAcc = (TH1F*)list->FindObject("fHistPtITSMI5InAcc");
1816       TH1F *fHistPtITSMI4InAcc = (TH1F*)list->FindObject("fHistPtITSMI4InAcc");
1817       TH1F *fHistPtITSMI3InAcc = (TH1F*)list->FindObject("fHistPtITSMI3InAcc");
1818       TH1F *fHistPtITSMI2InAcc = (TH1F*)list->FindObject("fHistPtITSMI2InAcc");
1819       TH1F *fHistPtITSMISPDInAcc = (TH1F*)list->FindObject("fHistPtITSMISPDInAcc");
1820       TH1F *fHistPtITSMIoneSPDInAcc = (TH1F*)list->FindObject("fHistPtITSMIoneSPDInAcc");
1821       
1822
1823       TH1F *fHistPtITSMIge2InAcc = (TH1F*)fHistPtITSMI6InAcc->Clone("fHistPtITSMIge2InAcc");
1824       fHistPtITSMIge2InAcc->Add(fHistPtITSMI5InAcc);
1825       fHistPtITSMIge2InAcc->Add(fHistPtITSMI4InAcc);
1826       fHistPtITSMIge2InAcc->Add(fHistPtITSMI3InAcc);
1827       fHistPtITSMIge2InAcc->Add(fHistPtITSMI2InAcc);
1828
1829       
1830
1831       fHistPtITSMI6InAcc->Divide(fHistPtITSMI6InAcc,fHistPtTPCInAcc,1,1,"B");
1832       ptbin=fHistPtITSMI6InAcc->FindBin(0.201);
1833       ioValues[2]=fHistPtITSMI6InAcc->GetBinContent(ptbin);
1834       ioErrors[2]=fHistPtITSMI6InAcc->GetBinError(ptbin);
1835       ptbin=fHistPtITSMI6InAcc->FindBin(1.001);
1836       ioValues[3]=fHistPtITSMI6InAcc->GetBinContent(ptbin);
1837       ioErrors[3]=fHistPtITSMI6InAcc->GetBinError(ptbin);
1838       ptbin=fHistPtITSMI6InAcc->FindBin(10.001);
1839       ioValues[4]=fHistPtITSMI6InAcc->GetBinContent(ptbin);
1840       ioErrors[4]=fHistPtITSMI6InAcc->GetBinError(ptbin);
1841
1842       fHistPtITSMI5InAcc->Divide(fHistPtITSMI5InAcc,fHistPtTPCInAcc,1,1,"B");
1843       
1844       ptbin=fHistPtITSMI5InAcc->FindBin(0.201);
1845       ioValues[5]=fHistPtITSMI5InAcc->GetBinContent(ptbin);
1846       ioErrors[5]=fHistPtITSMI5InAcc->GetBinError(ptbin);
1847       ptbin=fHistPtITSMI5InAcc->FindBin(1.001);
1848       ioValues[6]=fHistPtITSMI5InAcc->GetBinContent(ptbin);
1849       ioErrors[6]=fHistPtITSMI5InAcc->GetBinError(ptbin);
1850       ptbin=fHistPtITSMI5InAcc->FindBin(10.001);
1851       ioValues[7]=fHistPtITSMI5InAcc->GetBinContent(ptbin);
1852       ioErrors[7]=fHistPtITSMI5InAcc->GetBinError(ptbin);
1853       
1854       fHistPtITSMI4InAcc->Divide(fHistPtITSMI4InAcc,fHistPtTPCInAcc,1,1,"B");
1855       
1856       ptbin=fHistPtITSMI4InAcc->FindBin(0.201);
1857       ioValues[9]=fHistPtITSMI4InAcc->GetBinContent(ptbin);
1858   ioErrors[9]=fHistPtITSMI4InAcc->GetBinError(ptbin);
1859   ptbin=fHistPtITSMI4InAcc->FindBin(1.001);
1860   ioValues[10]=fHistPtITSMI4InAcc->GetBinContent(ptbin);
1861   ioErrors[10]=fHistPtITSMI4InAcc->GetBinError(ptbin);
1862   ptbin=fHistPtITSMI4InAcc->FindBin(10.001);
1863   ioValues[11]=fHistPtITSMI4InAcc->GetBinContent(ptbin);
1864   ioErrors[11]=fHistPtITSMI4InAcc->GetBinError(ptbin);
1865
1866   fHistPtITSMI3InAcc->Divide(fHistPtITSMI3InAcc,fHistPtTPCInAcc,1,1,"B");
1867
1868   ptbin=fHistPtITSMI3InAcc->FindBin(0.201);
1869   ioValues[12]=fHistPtITSMI3InAcc->GetBinContent(ptbin);
1870   ioErrors[12]=fHistPtITSMI3InAcc->GetBinError(ptbin);
1871   ptbin=fHistPtITSMI3InAcc->FindBin(1.001);
1872   ioValues[13]=fHistPtITSMI3InAcc->GetBinContent(ptbin);
1873   ioErrors[13]=fHistPtITSMI3InAcc->GetBinError(ptbin);
1874   ptbin=fHistPtITSMI3InAcc->FindBin(10.001);
1875   ioValues[14]=fHistPtITSMI3InAcc->GetBinContent(ptbin);
1876   ioErrors[14]=fHistPtITSMI3InAcc->GetBinError(ptbin);
1877
1878   fHistPtITSMI2InAcc->Divide(fHistPtITSMI2InAcc,fHistPtTPCInAcc,1,1,"B");
1879
1880   ptbin=fHistPtITSMI2InAcc->FindBin(0.201);
1881   ioValues[15]=fHistPtITSMI2InAcc->GetBinContent(ptbin);
1882   ioErrors[15]=fHistPtITSMI2InAcc->GetBinError(ptbin);
1883   ptbin=fHistPtITSMI2InAcc->FindBin(1.001);
1884   ioValues[16]=fHistPtITSMI2InAcc->GetBinContent(ptbin);
1885   ioErrors[16]=fHistPtITSMI2InAcc->GetBinError(ptbin);
1886   ptbin=fHistPtITSMI2InAcc->FindBin(10.001);
1887   ioValues[17]=fHistPtITSMI2InAcc->GetBinContent(ptbin);
1888   ioErrors[17]=fHistPtITSMI2InAcc->GetBinError(ptbin);
1889
1890   fHistPtITSMISPDInAcc->Divide(fHistPtITSMISPDInAcc,fHistPtTPCInAcc,1,1,"B");
1891   ptbin=fHistPtITSMISPDInAcc->FindBin(0.201);
1892   ioValues[18]=fHistPtITSMISPDInAcc->GetBinContent(ptbin);
1893   ioErrors[18]=fHistPtITSMISPDInAcc->GetBinError(ptbin);
1894   ptbin=fHistPtITSMISPDInAcc->FindBin(1.001);
1895   ioValues[19]=fHistPtITSMISPDInAcc->GetBinContent(ptbin);
1896   ioErrors[19]=fHistPtITSMISPDInAcc->GetBinError(ptbin);
1897   ptbin=fHistPtITSMISPDInAcc->FindBin(10.001);
1898   ioValues[20]=fHistPtITSMISPDInAcc->GetBinContent(ptbin);
1899   ioErrors[20]=fHistPtITSMISPDInAcc->GetBinError(ptbin);
1900
1901   fHistPtITSMIoneSPDInAcc->Divide(fHistPtITSMIoneSPDInAcc,fHistPtTPCInAcc,1,1,"B");
1902
1903   ptbin=fHistPtITSMIoneSPDInAcc->FindBin(0.201);
1904   ioValues[21]=fHistPtITSMIoneSPDInAcc->GetBinContent(ptbin);
1905   ioErrors[21]=fHistPtITSMIoneSPDInAcc->GetBinError(ptbin);
1906   ptbin=fHistPtITSMIoneSPDInAcc->FindBin(1.001);
1907   ioValues[22]=fHistPtITSMIoneSPDInAcc->GetBinContent(ptbin);
1908   ioErrors[22]=fHistPtITSMIoneSPDInAcc->GetBinError(ptbin);
1909   ptbin=fHistPtITSMIoneSPDInAcc->FindBin(10.001);
1910   ioValues[23]=fHistPtITSMIoneSPDInAcc->GetBinContent(ptbin);
1911   ioErrors[23]=fHistPtITSMIoneSPDInAcc->GetBinError(ptbin);
1912
1913   
1914   fHistPtITSMIge2InAcc->Divide(fHistPtITSMIge2InAcc,fHistPtTPCInAcc,1,1,"B");
1915   ptbin=fHistPtITSMIge2InAcc->FindBin(0.201);
1916   ioValues[24]=fHistPtITSMIge2InAcc->GetBinContent(ptbin);
1917   ioErrors[24]=fHistPtITSMIge2InAcc->GetBinError(ptbin);
1918   ptbin=fHistPtITSMIge2InAcc->FindBin(1.001);
1919   ioValues[25]=fHistPtITSMIge2InAcc->GetBinContent(ptbin);
1920   ioErrors[25]=fHistPtITSMIge2InAcc->GetBinError(ptbin);
1921   ptbin=fHistPtITSMIge2InAcc->FindBin(10.001);
1922   ioValues[26]=fHistPtITSMIge2InAcc->GetBinContent(ptbin);
1923   ioErrors[26]=fHistPtITSMIge2InAcc->GetBinError(ptbin);
1924
1925   Int_t indexMatching=0;
1926   xntMatching[indexMatching++]=iRun;
1927   xntMatching[indexMatching++]=ioValues[0];
1928   xntMatching[indexMatching++]=ioErrors[0];
1929   xntMatching[indexMatching++]=ioValues[1];
1930   xntMatching[indexMatching++]=ioErrors[1];
1931   xntMatching[indexMatching++]=ioValues[2];
1932   xntMatching[indexMatching++]=ioErrors[2];
1933   xntMatching[indexMatching++]=ioValues[3];
1934   xntMatching[indexMatching++]=ioErrors[3];
1935   xntMatching[indexMatching++]=ioValues[4];
1936   xntMatching[indexMatching++]=ioErrors[4];
1937   xntMatching[indexMatching++]=ioValues[5];
1938   xntMatching[indexMatching++]=ioErrors[5];
1939   xntMatching[indexMatching++]=ioValues[6];
1940   xntMatching[indexMatching++]=ioErrors[6];
1941   xntMatching[indexMatching++]=ioValues[7];
1942   xntMatching[indexMatching++]=ioErrors[7];
1943   xntMatching[indexMatching++]=ioValues[8];
1944   xntMatching[indexMatching++]=ioErrors[8];
1945   xntMatching[indexMatching++]=ioValues[9];
1946   xntMatching[indexMatching++]=ioErrors[9];
1947   xntMatching[indexMatching++]=ioValues[10];
1948   xntMatching[indexMatching++]=ioErrors[10];
1949   xntMatching[indexMatching++]=ioValues[11];
1950   xntMatching[indexMatching++]=ioErrors[11];
1951   xntMatching[indexMatching++]=ioValues[12];
1952   xntMatching[indexMatching++]=ioErrors[12];
1953   xntMatching[indexMatching++]=ioValues[13];
1954   xntMatching[indexMatching++]=ioErrors[13];
1955   xntMatching[indexMatching++]=ioValues[14];
1956   xntMatching[indexMatching++]=ioErrors[14];
1957   xntMatching[indexMatching++]=ioValues[15];
1958   xntMatching[indexMatching++]=ioErrors[15];
1959   xntMatching[indexMatching++]=ioValues[16];
1960   xntMatching[indexMatching++]=ioErrors[16];
1961   xntMatching[indexMatching++]=ioValues[17];
1962   xntMatching[indexMatching++]=ioErrors[17];
1963   xntMatching[indexMatching++]=ioValues[18];
1964   xntMatching[indexMatching++]=ioErrors[18];
1965   xntMatching[indexMatching++]=ioValues[19];
1966   xntMatching[indexMatching++]=ioErrors[19];
1967   xntMatching[indexMatching++]=ioValues[20];
1968   xntMatching[indexMatching++]=ioErrors[20];
1969   xntMatching[indexMatching++]=ioValues[21];
1970   xntMatching[indexMatching++]=ioErrors[21];
1971   xntMatching[indexMatching++]=ioValues[22];
1972   xntMatching[indexMatching++]=ioErrors[22];
1973   xntMatching[indexMatching++]=ioValues[23];
1974   xntMatching[indexMatching++]=ioErrors[23];
1975   xntMatching[indexMatching++]=ioValues[24];
1976   xntMatching[indexMatching++]=ioErrors[24];
1977   xntMatching[indexMatching++]=ioValues[25];
1978   xntMatching[indexMatching++]=ioErrors[25];
1979   xntMatching[indexMatching++]=ioValues[26];
1980   xntMatching[indexMatching++]=ioErrors[26];
1981   
1982   ntmatching->Fill(xntMatching);                                                
1983
1984       //---------------------------
1985
1986   TDirectoryFile *dirVertex = (TDirectoryFile*)f->Get("Vertex_Performance");
1987   if(!dirVertex){
1988     Printf("Vertex directory not found... check!");
1989   }
1990   
1991   TList *lt = (TList*)dirVertex->Get("cOutputVtxESD");
1992         
1993   TH1F *xVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexX");
1994   TH1F *yVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexY");
1995   TH1F *zVtxTRK = (TH1F*)lt->FindObject("fhTRKVertexZ");
1996
1997   TF1 *fxTRK = new TF1("gausx", "gaus", -1, 1);
1998   xVtxTRK->Fit("gausx", "M");
1999
2000   TF1 *fyTRK = new TF1("gausy", "gaus", -1, 1);
2001   yVtxTRK->Fit("gausy","M");
2002   cout<<fyTRK->GetParameter(1)<<endl;
2003   cout<<fyTRK->GetParError(1)<<endl;
2004   cout<<fyTRK->GetParameter(2)<<endl;
2005   cout<<fyTRK->GetParError(2)<<endl;
2006
2007   TF1 *fzTRK = new TF1("gausz", "gaus", -1, 1);
2008   zVtxTRK->Fit("gausz","M");
2009   cout<<fzTRK->GetParameter(1)<<endl;
2010   cout<<fzTRK->GetParError(1)<<endl;
2011   cout<<fzTRK->GetParameter(2)<<endl;
2012   cout<<fzTRK->GetParError(2)<<endl;
2013
2014
2015   Int_t indexVertex=0;
2016   xntVertex[indexVertex++]=iRun;
2017   xntVertex[indexVertex++]=(Float_t)fxTRK->GetParameter(1);
2018   xntVertex[indexVertex++]=(Float_t)fxTRK->GetParError(1);
2019   xntVertex[indexVertex++]=(Float_t)fxTRK->GetParameter(2);
2020   xntVertex[indexVertex++]=(Float_t)fxTRK->GetParError(2);
2021   xntVertex[indexVertex++]=(Float_t)fyTRK->GetParameter(1);
2022   xntVertex[indexVertex++]=(Float_t)fyTRK->GetParError(1);
2023   xntVertex[indexVertex++]=(Float_t)fyTRK->GetParameter(2);
2024   xntVertex[indexVertex++]=(Float_t)fyTRK->GetParError(2);
2025   xntVertex[indexVertex++]=(Float_t)fzTRK->GetParameter(1);
2026   xntVertex[indexVertex++]=(Float_t)fzTRK->GetParError(1);
2027   xntVertex[indexVertex++]=(Float_t)fzTRK->GetParameter(2);
2028   xntVertex[indexVertex++]=(Float_t)fzTRK->GetParError(2);
2029   ntvertex->Fill(xntVertex);    
2030
2031                                         
2032   
2033   //---------------------------
2034
2035   //--------------   ITS SA ---------------
2036
2037   FillITSSAntuple(f,ntSA,iRun);
2038
2039   } // loop on runs
2040
2041   TFile* outfil=new TFile(ntupleFileName.Data(),"recreate");
2042   outfil->cd();
2043   ntsdd->Write();
2044   ntssd->Write();
2045   ntmatching->Write();
2046   ntvertex->Write();
2047   ntSA->Write();
2048   outfil->Close();
2049   delete outfil;
2050   delete ntsdd;
2051   delete ntssd;
2052   delete ntmatching;
2053   delete ntvertex;
2054   delete ntSA;
2055
2056 }
2057
2058 //____________________________________________________________________________
2059 void FillITSSAntuple(TFile* f,TNtuple* nt, Int_t nrun){
2060   static const Int_t nVariables=13;
2061   static Float_t xnt[nVariables];
2062   TH1F *hPtTPCITS=0x0;
2063   TH1F *hPtITSsa=0x0;
2064   TH1F *hPtITSpureSA=0x0;
2065   Double_t Lowbin[3]={0.1,0.5,0.9};
2066   Double_t Upbin[3]={0.2,0.6,1};
2067   Double_t NTPCITS[3];
2068   Double_t NITSsa[3];
2069   Double_t NITSpureSA[3];
2070   Double_t Ratio[3];
2071   TDirectory *dirFile=(TDirectory*)f->Get("ITSsaTracks");
2072   TList *cOutput = (TList*)dirFile->Get("clistITSsaTracks"); 
2073   // histogram with number of events: in the first cell there is the number of the events
2074   // in the second, the number of events with SPD vertex.
2075   // normalization will be done to the second number
2076   TH1F *hnev =(TH1F*)cOutput->FindObject("hNEvents");
2077   Double_t noEvents = hnev->GetBinContent(1);
2078   if(noEvents<1.)noEvents=1.;   // protection to avoid division by zero
2079   hPtTPCITS=(TH1F*)cOutput->FindObject("hPtTPCITS");
2080   hPtITSsa=(TH1F*)cOutput->FindObject("hPtITSsa");
2081   hPtITSpureSA=(TH1F*)cOutput->FindObject("hPtITSpureSA");
2082
2083   for(Int_t ibin=0;ibin<=2;ibin++){
2084     NTPCITS[ibin]=hPtTPCITS->Integral(hPtTPCITS->FindBin(Lowbin[ibin]),hPtTPCITS->FindBin(Upbin[ibin]))/noEvents;
2085     NITSsa[ibin]=hPtITSsa->Integral(hPtITSsa->FindBin(Lowbin[ibin]),hPtITSsa->FindBin(Upbin[ibin]))/noEvents;
2086     NITSpureSA[ibin]=hPtITSpureSA->Integral(hPtITSpureSA->FindBin(Lowbin[ibin]),hPtITSpureSA->FindBin(Upbin[ibin]))/noEvents;
2087     if(NTPCITS[ibin]!=0 && NITSsa[ibin]!=0)Ratio[ibin]=NTPCITS[ibin]/NITSsa[ibin];
2088     else Ratio[ibin]=0;
2089   }
2090  
2091   Int_t index=0;
2092   xnt[index++]=(Float_t)nrun;
2093   xnt[index++]=NTPCITS[0];
2094   xnt[index++]=NTPCITS[1];
2095   xnt[index++]=NTPCITS[2];
2096   xnt[index++]=NITSsa[0];
2097   xnt[index++]=NITSsa[1];
2098   xnt[index++]=NITSsa[2];
2099   xnt[index++]=NITSpureSA[0];
2100   xnt[index++]=NITSpureSA[1];
2101   xnt[index++]=NITSpureSA[2];
2102   xnt[index++]=Ratio[0];
2103   xnt[index++]=Ratio[1];
2104   xnt[index++]=Ratio[2];
2105   nt->Fill(xnt);
2106 }