]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/macros/PlotITSTrackingRes.C
adapt for ITS upgrade
[u/mrichter/AliRoot.git] / PWGPP / macros / PlotITSTrackingRes.C
1 Bool_t gboxbin=kFALSE;
2 Int_t  gMarkerColor=2;
3
4 void PlotITSTrackingRes(TString filename="ITS.Performance.root",
5                         Int_t pdgcode=211,
6                         Bool_t useAbsPdg=kTRUE,
7                         Bool_t box=kTRUE,
8                         Int_t minITSpoints=7,
9                         Bool_t nofakes=kTRUE,
10                         Bool_t askITSrefit=kTRUE,
11                         Int_t minTPCcls=70) 
12 {
13   //
14   // Plot ITS tracking resolutions from ITS.Performance.root
15   // A. Dainese
16   // 
17
18
19   //Open File
20   if(gSystem->AccessPathName(filename.Data())) {
21     printf("file not found!\n");  
22     return;
23   }
24   TFile *file= TFile::Open(filename.Data());
25   cout<<"Opening file "<<filename.Data()<<endl;   
26     
27   TList *list = (TList*)file->Get("cOutputITS");
28   TDirectoryFile *dir=0;
29   if(!list) {
30     dir=(TDirectoryFile*)file->GetDirectory("ITS_Performance");
31     if(dir) list = (TList*)dir->Get("cOutputITS");
32   }
33
34
35   TNtuple *ntTracks = (TNtuple*)list->FindObject("fNtupleESDTracks");
36
37       
38   //Getting and Addressing  NTuples
39     
40   Float_t pt,ptmes,eta,phi,pdg,d0True,d0TV,d0zTV,sigmad0zTV,d0All,d0Oth,sigmad0Oth,ITSflag,sigmad0TV,sigmad0All;
41   
42   ntTracks->SetBranchAddress("pt",&ptmes);
43   ntTracks->SetBranchAddress("ptMC",&pt);
44   ntTracks->SetBranchAddress("eta",&eta);
45   ntTracks->SetBranchAddress("phi",&phi);
46   ntTracks->SetBranchAddress("pdgMC",&pdg);
47   ntTracks->SetBranchAddress("d0MC",&d0True);
48   ntTracks->SetBranchAddress("d0MCv",&d0TV);
49   ntTracks->SetBranchAddress("z0MCv",&d0zTV);
50   ntTracks->SetBranchAddress("sigmad0MCv",&sigmad0TV);
51   ntTracks->SetBranchAddress("sigmaz0MCv",&sigmad0zTV);
52   ntTracks->SetBranchAddress("d0",&d0All);
53   ntTracks->SetBranchAddress("sigmad0",&sigmad0All);
54   ntTracks->SetBranchAddress("ITSflag",&ITSflag);
55
56     
57   //make STANDARD Pt BINNING
58   gboxbin=box;
59   const Int_t nPtBins=10;
60   Double_t ptbinning[2*nPtBins];
61   const Int_t numint=10;
62   Double_t ptmin[numint],lenghtbin[numint],stepbin[numint],interval[numint],steplenght;
63   Int_t nbinning[numint];
64   Int_t runningbin=0;
65
66   for(Int_t i=0;i<nPtBins;i++) nbinning[i]=1;
67   
68   ptbinning[0]=0.2;
69   ptbinning[1]=0.35;
70   ptbinning[2]=0.4;
71   ptbinning[3]=0.6;
72   ptbinning[4]=0.7;
73   ptbinning[5]=0.85;
74   ptbinning[6]=0.85;
75   ptbinning[7]=1.2;
76   ptbinning[8]=1.7;
77   ptbinning[9]=2.3;
78   ptbinning[10]=3.6;
79   ptbinning[11]=4.4;
80   ptbinning[12]=6.5;
81   ptbinning[13]=7.5;
82   ptbinning[14]=9.5;
83   ptbinning[15]=10.5;
84   ptbinning[16]=19.5;
85   ptbinning[17]=20.5;
86   ptbinning[18]=29.5;
87   ptbinning[19]=30.5;
88  
89   interval[0]=600;
90   interval[1]=300;
91   interval[2]=200;
92   interval[3]=150;
93   interval[4]=100;
94   interval[5]=100;
95   interval[6]=100;
96   interval[7]=70;
97   interval[8]=50;
98   interval[9]=50;
99
100   
101   const Int_t dipnbin=10;
102   const Double_t lenghtbindip=0.1;//0.03;
103   const Double_t stepbindip=0.0;
104   const Double_t dipinterval=200;
105   
106   
107   //  Double_t radice=TMath::Sqrt(2.)/2.; // |eta|<0.9
108   Double_t radice=0.; // all eta
109  
110   Int_t ntracks,entries,ntotaltracks=0,nfaketr=0;
111   Double_t bin,sinteta,rms;
112   Double_t ptbin[nPtBins],dipbin[dipnbin],multptbin[nPtBins],multdipbin[dipnbin],ex[nPtBins],exdip[dipnbin];
113   Double_t sigmaResolutionTV[dipnbin][nPtBins],sigmaResolutionPtTV[nPtBins],errsigmResPtTV[nPtBins],meanResolutionPtTV[nPtBins],errmeanResPtTV[nPtBins],sigmaResolutionDipTV[dipnbin],errsigmResDipTV[dipnbin];
114   Double_t binpt,bindip,sigmaResolutionOV[dipnbin][nPtBins],sigmaResolutionPtOV[nPtBins],errsigmResPtOV[nPtBins],sigmaResolutionDipOV[dipnbin],errsigmResDipOV[dipnbin];
115   Double_t sigmaResolutionRV[dipnbin][nPtBins],sigmaResolutionPtRV[nPtBins],errsigmResPtRV[nPtBins],sigmaResolutionDipRV[dipnbin],errsigmResDipRV[dipnbin];
116   Double_t mediumsigmad0rphiPtTV[nPtBins],errmediumsigmad0rphiPtTV[nPtBins],mediumsigmad0rphiPtRV[nPtBins],errmediumsigmad0rphiPtRV[nPtBins],mediumsigmad0rphiPtOV[nPtBins],errmediumsigmad0rphiPtOV[nPtBins];
117   Double_t sigmaPullPtTV[nPtBins],errsigmPullPtTV[nPtBins],sigmaPullPtRV[nPtBins],errsigmPullPtRV[nPtBins],sigmaPullPtOV[nPtBins],errsigmPullPtOV[nPtBins];
118   Double_t sigmad0zResPtTV[nPtBins],errsigmd0zResPtTV[nPtBins];
119   // Double_t sigmad0zResPtRV[nPtBins],errsigmd0zResPtRV[nPtBins],sigmad0zResPtOV[nPtBins],errsigmd0zResPtOV[nPtBins];
120   Double_t sigmad0zPullPtTV[nPtBins],errsigmd0zPullPtTV[nPtBins];
121   Double_t sigmaPtResTV[nPtBins],errsigmPtResTV[nPtBins],meanPtResTV[nPtBins],errmeanPtResTV[nPtBins],sigmaCurvResTV[nPtBins],errsigmCurvResTV[nPtBins];
122   // Double_t sigmad0zPullPtRV[nPtBins],errsigmd0zPullPtRV[nPtBins],sigmad0zPullPtOV[nPtBins],errsigmd0zPullPtOV[nPtBins];
123   
124   Int_t ITSnpoints;
125   
126   Float_t hptbin[nPtBins+1],hdipbin[dipnbin+1];
127   
128   TF1 *gauss = new TF1("gauss","gaus",-10,10); 
129
130   TGraphErrors *gr0TV;
131   TGraphErrors *gr0OV;
132   TGraphErrors *gr0RV; 
133   TGraphErrors *gr1TV;
134   TGraphErrors *gr1OV;
135   TGraphErrors *gr1RV;
136
137   TGraphErrors *grPullTV;
138   TGraphErrors *grPullOV;
139   TGraphErrors *grPullRV; 
140
141   TGraphErrors *grsigmad0rphiTV;
142   TGraphErrors *grsigmad0rphiRV;
143   TGraphErrors *grsigmad0rphiOV;
144
145   TGraphErrors *grd0zResTV;
146   //TGraphErrors *grd0zRes0OV;
147   //TGraphErrors *grd0zRes0RV; 
148   
149   TGraphErrors *grd0zPullTV;
150   //TGraphErrors *grd0zPull0OV;
151   //TGraphErrors *grd0zPull0RV; 
152   TGraphErrors *grPtResTV;
153   TGraphErrors *grPtResMeanTV;
154   TGraphErrors *grCurvResTV;
155
156   TString numerobin,numerobin2,numerobinSigma,numerobinSigma2,numerobinPull,numerobinPull2,numerobind0zRes,numerobind0zPull,numerobind0zRes2,numerobind0zPull2,numerobinCurvRes,numerobinCurvRes2,numerobinPtRes,numerobinPtRes2,numerobin3,titlegraph1,titlegraph2,str=" ";
157   
158
159   
160   //DECLARING AND CONSTRUCTING HISTOGRAMS
161    
162   TH1F **hFitResolutionTV=new TH1F*[dipnbin*nPtBins];
163   TH1F **hFitResolutionOV=new TH1F*[dipnbin*nPtBins];
164   TH1F **hFitResolutionRV=new TH1F*[dipnbin*nPtBins];
165
166   TH1F **hFitResolutionPtTV=new TH1F*[nPtBins];
167   TH1F **hFitResolutionPtRV=new TH1F*[nPtBins];
168   TH1F **hFitResolutionPtOV=new TH1F*[nPtBins];
169
170   TH1F **hFitsigmad0rphiPtTV=new TH1F*[nPtBins];
171   TH1F **hFitsigmad0rphiPtRV=new TH1F*[nPtBins];
172   TH1F **hFitsigmad0rphiPtOV=new TH1F*[nPtBins];
173
174   TH1F **hFitPullPtTV=new TH1F*[nPtBins];
175   TH1F **hFitPullPtRV=new TH1F*[nPtBins];
176   TH1F **hFitPullPtOV=new TH1F*[nPtBins];
177
178   TH1F **hFitd0zResPtTV=new TH1F*[nPtBins];
179   //  TH1F **hFitd0zResPtRV=new TH1F*[nPtBins];
180   //TH1F **hFitd0zResPtOV=new TH1F*[nPtBins];
181
182   TH1F **hFitd0zPullPtTV=new TH1F*[nPtBins];
183   //TH1F **hFitd0zPullPtRV=new TH1F*[nPtBins];
184   //TH1F **hFitd0zPullPtOV=new TH1F*[nPtBins];
185
186   TH1F **hFitResolutionDipTV=new TH1F*[dipnbin];
187   TH1F **hFitResolutionDipRV=new TH1F*[dipnbin];
188   TH1F **hFitResolutionDipOV=new TH1F*[dipnbin];
189   
190   TH1F **hFitPtResTV=new TH1F*[nPtBins];
191   TH1F **hFitCurvResTV=new TH1F*[nPtBins];
192  
193   TH2F *hFitResPtDipTV;
194   TH2F *hFitResPtDipRV;
195   TH2F *hFitResPtDipOV;
196
197   
198   Int_t incycle=0;
199   
200   for(Int_t v=0;v<dipnbin;v++) {
201     incycle=0;
202     for (Int_t nint=0;nint<numint;nint++) {
203       for (Int_t k=0;k<nbinning[nint];k++) { 
204         numerobin ="TranvDipResolution";
205         numerobin+=v;
206         numerobin.Append("_");
207         numerobin+=(k+incycle); 
208         numerobin.Append("bin");
209         
210         numerobin2=numerobin;
211         numerobin.Append("TV");
212         hFitResolutionTV[v*nPtBins+k+incycle]=new TH1F(numerobin,numerobin,3*100,-2*interval[nint],2*interval[nint]);
213         //      numerobin.Replace(24,25,"RV");
214         //      cout<<numerobin<<endl;
215         
216         numerobin=numerobin2;
217         numerobin2.Append("RV");
218         hFitResolutionRV[v*nPtBins+k+incycle]=new TH1F(numerobin2,numerobin2,3*100,-2*interval[nint],2*interval[nint]);
219         //      cout<<numerobin2<<endl;
220         
221         numerobin.Append("OV");
222         hFitResolutionOV[v*nPtBins+k+incycle]=new TH1F(numerobin,numerobin,3*100,-2*interval[nint],2*interval[nint]);
223         //      cout<<numerobin<<endl;
224         
225         //      cout<<(v*nPtBins+k+incycle)<<endl;
226       }
227       incycle+=nbinning[nint];
228     }
229   }
230
231   for(Int_t v=0;v<dipnbin;v++) {
232     numerobin="DipResolution";
233     numerobin+=v;
234     numerobin.Append("bin");
235     
236     numerobin2=numerobin;
237     numerobin.Append("TV");
238     hFitResolutionDipTV[v]=new TH1F(numerobin,numerobin,3*100,-3*dipinterval,3*dipinterval);
239
240     numerobin=numerobin2;
241     numerobin2.Append("RV");
242     hFitResolutionDipRV[v]=new TH1F(numerobin2,numerobin2,3*100,-3*dipinterval,3*dipinterval);
243
244     numerobin.Append("OV");
245     hFitResolutionDipOV[v]=new TH1F(numerobin,numerobin,3*100,-3*dipinterval,3*dipinterval);
246
247     dipbin[v]=0;
248     multdipbin[v]=0;    
249   }
250  
251   incycle=0;
252   
253   for (Int_t nint=0;nint<numint;nint++) {   
254     for(Int_t k=0;k<nbinning[nint];k++) { 
255       numerobin = "d0PtResolution";
256       numerobinSigma="d0rphiPtsigma";
257       numerobinPull="d0PtPull";
258       numerobind0zRes="d0zPtResolution";
259       numerobind0zPull="d0zPtPull";
260       numerobinPtRes="PtResolution";
261       numerobinCurvRes="CurvRes";
262
263
264       numerobin+=k+incycle;
265       numerobinSigma+=k+incycle;
266       numerobinPull+=k+incycle;
267       numerobind0zRes+=k+incycle;
268       numerobind0zPull+=k+incycle;
269       numerobinPtRes+=k+incycle;
270       numerobinCurvRes+=k+incycle;
271
272       numerobin.Append("bin");
273       numerobinSigma.Append("bin");
274       numerobinPull.Append("bin");
275       numerobind0zRes.Append("bin");
276       numerobind0zPull.Append("bin");
277       numerobinPtRes.Append("bin");
278       numerobinCurvRes.Append("bin");
279
280         
281       numerobin2=numerobin;
282       numerobinSigma2=numerobinSigma;
283       numerobinPull2=numerobinPull;
284       numerobind0zRes2=numerobind0zRes;
285       numerobind0zPull2=numerobind0zPull;
286       numerobinPtRes2=numerobinPtRes;
287       numerobinCurvRes2=numerobinCurvRes;
288
289       numerobin.Append("TV");
290       hFitResolutionPtTV[k+incycle]=new TH1F(numerobin,numerobin,100,-2*interval[nint],2*interval[nint]);
291       hFitsigmad0rphiPtTV[k+incycle]=new TH1F(numerobinSigma,numerobinSigma,3*100,0.,4*interval[nint]);
292       numerobinPull.Append("TV");
293       hFitPullPtTV[k+incycle]=new TH1F(numerobinPull,numerobinPull,100,-4.,4.);
294       numerobind0zRes.Append("TV");
295       hFitd0zResPtTV[k+incycle]=new TH1F(numerobind0zRes,numerobind0zRes,3*100,-3*interval[nint],3*interval[nint]);
296       numerobind0zPull.Append("TV");
297       hFitd0zPullPtTV[k+incycle]=new TH1F(numerobind0zPull,numerobind0zPull,100,-4.,4.);
298       numerobinPtRes.Append("TV");
299       hFitPtResTV[k+incycle]=new TH1F(numerobinPtRes,numerobinPtRes,300,-1.,1.);
300       numerobinCurvRes.Append("TV");
301       hFitCurvResTV[k+incycle]=new TH1F(numerobinCurvRes,numerobinCurvRes,300,-1.,1.);
302
303       numerobin=numerobin2;
304       numerobinSigma=numerobinSigma2;
305       numerobin.Append("RV");
306       numerobinSigma.Append("RV");
307       hFitResolutionPtRV[k+incycle]=new TH1F(numerobin,numerobin,3*100,-2*interval[nint],2*interval[nint]);
308       hFitsigmad0rphiPtRV[k+incycle]=new TH1F(numerobinSigma,numerobinSigma,3*100,0.,4*interval[nint]);
309       numerobinPull=numerobinPull2;
310       numerobinPull.Append("RV");
311       hFitPullPtRV[k+incycle]=new TH1F(numerobinPull,numerobinPull,100,-4,4);
312
313       /*      numerobind0zRes=numerobind0zRes2;
314       numerobind0zRes.Append("RV");
315       hFitd0zResPtRV[k+incycle]=new TH1F(numerobind0zRes,numerobind0zRes,3*100,-3*interval[nint],3*interval[nint]);
316       numerobind0zPull=numerobind0zPull2;
317       numerobind0zPull.Append("RV");
318       hFitd0zPullPtRV[k+incycle]=new TH1F(numerobind0zPull,numerobind0zPull,100,-4,4);
319       */
320
321       numerobin=numerobin2;
322       numerobin.Append("OV");
323       hFitResolutionPtOV[k+incycle]=new TH1F(numerobin,numerobin,3*100,-2*interval[nint],2*interval[nint]);
324
325       numerobinSigma=numerobinSigma2;
326       numerobinSigma.Append("OV");
327       hFitsigmad0rphiPtOV[k+incycle]=new TH1F(numerobinSigma,numerobinSigma,3*100,0.,4.*interval[nint]);
328       numerobinPull=numerobinPull2;
329       numerobinPull.Append("OV");
330       hFitPullPtOV[k+incycle]=new TH1F(numerobinPull,numerobinPull,100,-4,4);
331
332       /* numerobind0zRes=numerobind0zRes2;
333       numerobind0zRes.Append("OV");
334       hFitd0zResPtOV[k+incycle]=new TH1F(numerobind0zRes,numerobind0zRes,3*100,-3*interval[nint],3*interval[nint]);
335       numerobind0zPull=numerobind0zPull2;
336       numerobind0zPull.Append("OV");
337       hFitd0zPullPtOV[k+incycle]=new TH1F(numerobind0zPull,numerobind0zPull,100,-4,4);
338       */
339       
340       ptbin[k+incycle]=0;
341       multptbin[k+incycle]=0;
342       hptbin[k+incycle]=0;
343       //      hptbin[(k+incycle)+1]=0;
344       //hptbin[(k+incycle)]=0;
345     }
346     incycle+=nbinning[nint];
347   }
348     
349   //  binpt=lenghtbin+stepbin;
350
351   bindip=lenghtbindip+stepbindip;
352   Int_t np=0;  
353   Int_t kbox=0;
354   if(gboxbin) kbox=1;
355
356
357
358   // ------------ Loop on Tracks ----------
359   ntracks=ntTracks->GetEntries();
360   cout<<"Number of Tracks: "<<ntracks<<endl;  
361   for (Int_t j=0;j<ntracks;j++) {
362     if(j%5000==0) printf("Reading track %d\n",j);
363     ntTracks->GetEvent(j);    
364     d0True*=1.e4;
365     d0TV*=1.e4;
366     d0zTV*=1.e4;
367     sigmad0zTV*=1.e4;
368     d0All*=1.e4;
369     d0Oth*1.e4;
370     sigmad0Oth*=1.e4;
371     sigmad0TV*=1.e4;
372     sigmad0All*=1.e4;
373
374     if(TMath::Abs(eta)>0.9) continue;
375     //if(TMath::Abs(eta)<0.9 || TMath::Abs(eta)>1.4) continue;
376     Float_t theta = 2.*TMath::ATan(TMath::Exp(-eta));
377     //if(TMath::Abs(TMath::Abs(phi)-0.5*TMath::Pi())>0.5 || TMath::Abs(theta-0.5*TMath::Pi())>0.5) continue;
378     Bool_t isFake=kFALSE;
379     if(ITSflag<0) isFake=kTRUE;
380     //printf("  %d\n",ITSflag);
381     ITSflag=TMath::Abs(ITSflag); 
382     //printf("%d\n",ITSflag);
383     Int_t ITSflagorig=ITSflag;
384     Int_t nTPCcls =       (Int_t)(ITSflag/100000);
385     ITSflag -= nTPCcls*100000;
386     Int_t nITSclspart =   (Int_t)(ITSflag/10000);
387     ITSflag -= nITSclspart*10000;
388     //printf("%d\n",ITSflag);
389     Int_t nITSclsassign = (Int_t)(ITSflag/1000);
390     ITSflag -= nITSclsassign*1000;
391     //printf("%d\n",ITSflag);
392     //printf("%d\n",ITSflag);
393     Int_t nITSsel=ITSnCluster(ITSflag);
394
395     //cout<<nITSsel<<"  "<<nITSclsassign<<endl;
396
397     if(nTPCcls<=minTPCcls) continue;
398
399     if(useAbsPdg) pdg=TMath::Abs(pdg);
400     if(pdg!=pdgcode) continue;
401
402
403     
404     if(TMath::Abs(nITSclsassign)<minITSpoints) continue;
405
406     if(askITSrefit && sigmad0TV<0.) continue;   
407
408     if(TMath::Abs(d0True)>0.5) continue;//skipping secondaries tracks if asked
409     //consider only "part" (if "all" is set to 1 all particles are considered)
410
411     if(isFake) nfaketr++;
412     if(nofakes && isFake) continue;        // reject fakes
413     np++;
414
415     //hPtResolutionOV->Fill(pt-ptmes);
416     //hPtResolutionRV->Fill(ptRV-ptmesRV);
417     //hPzResolutionOV->Fill(pz-pzmes);
418     //hPzResolutionRV->Fill(pzRV-pzmesRV);
419     
420     sinteta=TMath::Sin(2*TMath::ATan(TMath::Exp(-eta)));
421
422     for(Int_t v=0;v<dipnbin;v++) {
423       if (v*bindip+radice<sinteta&&sinteta<=v*bindip+radice+lenghtbindip) { //printf("Prova2 %d \n",v);
424         
425         for (Int_t k=0;k<nPtBins;k=k+1) {
426           
427           hFitResolutionDipTV[v]->Fill(d0TV-d0True);
428           
429           if(sigmad0All>0.) {
430             hFitResolutionDipRV[v]->Fill(d0All-d0True);
431           }
432           //if(sigmad0Oth>0.) {
433           //  hFitResolutionDipOV[v]->Fill(d0Oth-d0True);
434           //}
435           
436           //Transverse Momentum bin
437           if(ptbinning[(1+kbox)*k]<pt&&pt<=ptbinning[(1+kbox)*k+1]) { //printf("Prova3 %d \n",k/2)
438             if(ptmes!=0.&&pt!=0.) {
439               hFitPtResTV[k]->Fill(ptmes/pt-1.);
440               hFitCurvResTV[k]->Fill(1/ptmes-1/pt);
441             }
442             hFitResolutionTV[v*nPtBins+k]->Fill(d0TV-d0True);
443             hFitResolutionPtTV[k]->Fill(d0TV-d0True);
444             //to calculate resolution on d0z we should have d0zTrue but we haven't. So we ask for the track being primary and then d0zTV is equal to the residual
445             if(TMath::Abs(d0True)<0.1) {
446               hFitd0zResPtTV[k]->Fill(d0zTV);
447               if(sigmad0zTV>0)hFitd0zPullPtTV[k]->Fill(d0zTV/sigmad0zTV);
448             }
449             if(sigmad0TV>0) {
450               hFitPullPtTV[k]->Fill((d0TV-d0True)/sigmad0TV);
451               hFitsigmad0rphiPtTV[k]->Fill(sigmad0TV);
452             }
453             if(sigmad0All>=0.) {
454               hFitResolutionRV[v*nPtBins+k]->Fill(d0All-d0True);        
455               hFitResolutionPtRV[k]->Fill(d0All-d0True);
456               if(sigmad0All>0) {
457                 hFitPullPtRV[k]->Fill((d0All-d0True)/sigmad0All);
458                 hFitsigmad0rphiPtRV[k]->Fill(sigmad0All);
459               }
460             }
461             /*if(sigmad0Oth>=0.) {
462               hFitResolutionOV[v*nPtBins+k]->Fill(d0Oth-d0True);
463               hFitResolutionPtOV[k]->Fill(d0Oth-d0True);
464               if(sigmad0Oth>0) {
465               hFitPullPtOV[k]->Fill((d0Oth-d0True)/sigmad0Oth);
466               hFitsigmad0rphiPtOV[k]->Fill(sigmad0Oth);
467               }
468               }*/
469             
470             ptbin[k]+=pt;
471             multptbin[k]++;  
472             dipbin[v]+=sinteta;
473             multdipbin[v]++;
474           }
475         }
476       }
477     }
478   }
479
480   printf("Loop on ntuple finished \n");
481
482   /*
483     for (Int_t k=0;k<nPtBins;k++) {
484     for (Int_t j=0;j<dipnbin;j++) {
485     hFitResolutionPtTV[k]->Add(hFitResolutionTV[j*nPtBins+k],1.);
486     hFitResolutionPtRV[k]->Add(hFitResolutionRV[j*nPtBins+k],1.);
487     hFitResolutionPtOV[k]->Add(hFitResolutionOV[j*nPtBins+k],1.);
488     
489     hFitResolutionDipTV[j]->Add(hFitResolutionTV[j*nPtBins+k],1.);
490     hFitResolutionDipRV[j]->Add(hFitResolutionRV[j*nPtBins+k],1.);
491     hFitResolutionDipOV[j]->Add(hFitResolutionOV[j*nPtBins+k],1.);
492     }
493     }
494   */
495   //Loop and Fits
496   gauss->SetRange(-dipinterval,dipinterval);
497   
498   // pt and dip angle binning array for TGraphs: it reproduces the mean pt and angle of the intervals
499   for (Int_t v=0;v<dipnbin;v++) {
500     if (multdipbin[v]!=0) {
501       exdip[v]=0;
502       dipbin[v]=(dipbin[v]/multdipbin[v]);
503       
504       hFitResolutionDipTV[v]->Fit("gauss","N,R");
505       sigmaResolutionDipTV[v]=gauss->GetParameter(2);
506       errsigmResDipTV[v]=gauss->GetParError(2);
507       
508       hFitResolutionDipRV[v]->Fit("gauss","N,R");
509       sigmaResolutionDipRV[v]=gauss->GetParameter(2);
510       errsigmResDipRV[v]=gauss->GetParError(2);
511       
512       hFitResolutionDipOV[v]->Fit("gauss","N,R");
513       sigmaResolutionDipOV[v]=gauss->GetParameter(2);
514       errsigmResDipOV[v]=gauss->GetParError(2);
515       
516       hdipbin[v]=(Float_t)radice+v*bindip;
517     } else {
518       dipbin[v]=radice+v*bindip+lenghtbindip/2.;
519       
520       exdip[v]=0;
521       sigmaResolutionDipTV[v]=0;
522       errsigmResDipTV[v]=0;
523       sigmaResolutionDipRV[v]=0;
524       errsigmResDipRV[v]=0;
525       sigmaResolutionDipOV[v]=0;
526       errsigmResDipTV[v]=0;
527       
528       hdipbin[v]=(Float_t)radice+v*bindip;
529     }
530   }
531   
532   hdipbin[dipnbin]=(Float_t)hdipbin[dipnbin-1]+bindip;
533   
534   for (Int_t j=0;j<nPtBins;j++) {
535     if (multptbin[j]!=0) {
536       ptbin[j]=ptbin[j]/multptbin[j];
537     } else {
538       ptbin[j]=(ptbinning[j]+ptbinning[j+1])/2.;
539     }
540     hptbin[j]=(Float_t)ptbinning[j];
541   }
542   hptbin[nPtBins]=ptbinning[nPtBins];
543   
544   incycle=0; 
545   
546   for (Int_t nint=0;nint<numint;nint++) {       
547     gauss->SetRange(-interval[nint],interval[nint]);
548     for (Int_t k=0;k<nbinning[nint];k++) {
549       ex[k+incycle]=0;
550       rms=hFitPtResTV[k+incycle]->GetRMS();
551       gauss->SetRange(-3*rms,3*rms);
552       hFitPtResTV[k+incycle]->Fit("gauss","N,R");
553       sigmaPtResTV[k+incycle]=gauss->GetParameter(2);
554       errsigmPtResTV[k+incycle]=gauss->GetParError(2);
555       meanPtResTV[k+incycle]=gauss->GetParameter(1);
556       errmeanPtResTV[k+incycle]=gauss->GetParError(1);
557
558       rms=hFitCurvResTV[k+incycle]->GetRMS();
559       gauss->SetRange(-3*rms,3*rms);
560       hFitCurvResTV[k+incycle]->Fit("gauss","N,R");
561       sigmaCurvResTV[k+incycle]=gauss->GetParameter(2);
562       errsigmCurvResTV[k+incycle]=gauss->GetParError(2);
563
564       rms=hFitResolutionPtTV[k+incycle]->GetRMS();
565       gauss->SetRange(-3*rms,3*rms);
566       hFitResolutionPtTV[k+incycle]->Fit("gauss","N,R");
567       sigmaResolutionPtTV[k+incycle]=gauss->GetParameter(2);
568       errsigmResPtTV[k+incycle]=gauss->GetParError(2);
569       meanResolutionPtTV[k+incycle]=gauss->GetParameter(1);
570       errmeanResPtTV[k+incycle]=gauss->GetParError(1);
571       
572       rms=hFitResolutionPtRV[k+incycle]->GetRMS();
573       gauss->SetRange(-3*rms,3*rms);
574       hFitResolutionPtRV[k+incycle]->Fit("gauss","N,R");
575       sigmaResolutionPtRV[k+incycle]=gauss->GetParameter(2);
576       errsigmResPtRV[k+incycle]=gauss->GetParError(2);
577       
578       rms=hFitResolutionPtOV[k+incycle]->GetRMS();
579       gauss->SetRange(-3*rms,3*rms);
580       hFitResolutionPtOV[k+incycle]->Fit("gauss","N,R");
581       sigmaResolutionPtOV[k+incycle]=gauss->GetParameter(2); 
582       errsigmResPtOV[k+incycle]=gauss->GetParError(2);
583
584       /*
585       rms=hFitsigmad0rphiPtTV[k+incycle]->GetRMS();
586       gauss->SetRange(-3*rms,3*rms);
587       hFitsigmad0rphiPtTV[k+incycle]->Fit("gauss","N,R");
588       mediumsigmad0rphiPtTV[k+incycle]=gauss->GetParameter(2);
589       errmediumsigmad0rphiPtTV[k+incycle]=gauss->GetParError(2);*/
590       mediumsigmad0rphiPtTV[k+incycle]=hFitsigmad0rphiPtTV[k+incycle]->GetMean();
591       errmediumsigmad0rphiPtTV[k+incycle]=0;
592       
593       /*
594       rms=hFitsigmad0rphiPtRV[k+incycle]->GetRMS();
595       gauss->SetRange(-3*rms,3*rms);
596       hFitsigmad0rphiPtRV[k+incycle]->Fit("gauss","N,R");
597       mediumsigmad0rphiPtRV[k+incycle]=gauss->GetParameter(2);
598       errmediumsigmad0rphiPtRV[k+incycle]=gauss->GetParError(2);*/
599       mediumsigmad0rphiPtRV[k+incycle]=hFitsigmad0rphiPtRV[k+incycle]->GetMean();
600       errmediumsigmad0rphiPtRV[k+incycle]=0;
601       
602       /*  
603       rms=hFitsigmad0rphiPtOV[k+incycle]->GetRMS();
604       gauss->SetRange(-3*rms,3*rms);
605       hFitsigmad0rphiPtOV[k+incycle]->Fit("gauss","N,R");
606       mediumsigmad0rphiPtOV[k+incycle]=gauss->GetParameter(2); 
607       errmediumsigmad0rphiPtOV[k+incycle]=gauss->GetParError(2);*/
608       mediumsigmad0rphiPtOV[k+incycle]=hFitsigmad0rphiPtOV[k+incycle]->GetMean();
609       errmediumsigmad0rphiPtOV[k+incycle]=0;
610
611       rms=hFitPullPtTV[k+incycle]->GetRMS();
612       gauss->SetRange(-3*rms,3*rms);
613       hFitPullPtTV[k+incycle]->Fit("gauss","N,R");
614       sigmaPullPtTV[k+incycle]=gauss->GetParameter(2);
615       errsigmPullPtTV[k+incycle]=gauss->GetParError(2);
616       
617       rms=hFitPullPtRV[k+incycle]->GetRMS();
618       gauss->SetRange(-3*rms,3*rms);
619       hFitPullPtRV[k+incycle]->Fit("gauss","N,R");
620       sigmaPullPtRV[k+incycle]=gauss->GetParameter(2);
621       errsigmPullPtRV[k+incycle]=gauss->GetParError(2);
622       
623       rms=hFitPullPtOV[k+incycle]->GetRMS();
624       gauss->SetRange(-3*rms,3*rms);
625       hFitPullPtOV[k+incycle]->Fit("gauss","N,R");
626       sigmaPullPtOV[k+incycle]=gauss->GetParameter(2); 
627       errsigmPullPtOV[k+incycle]=gauss->GetParError(2);
628
629       rms=hFitd0zResPtTV[k+incycle]->GetRMS();
630       gauss->SetRange(-3*rms,3*rms);
631       hFitd0zResPtTV[k+incycle]->Fit("gauss","N,R");
632       sigmad0zResPtTV[k+incycle]=gauss->GetParameter(2);
633       errsigmd0zResPtTV[k+incycle]=gauss->GetParError(2);
634
635       rms=hFitd0zPullPtTV[k+incycle]->GetRMS();
636       gauss->SetRange(-3*rms,3*rms);
637       hFitd0zPullPtTV[k+incycle]->Fit("gauss","N,R");
638       sigmad0zPullPtTV[k+incycle]=gauss->GetParameter(2);
639       errsigmd0zPullPtTV[k+incycle]=gauss->GetParError(2);      
640     }
641     incycle+=nbinning[nint];
642   }
643   
644   // hptbin[nPtBins]=hptbin[nPtBins-1]+lenghtbin;
645   
646   
647   hFitResPtDipTV=new TH2F("hFitResPtDipTV","The 3D histogram for Resolution in Pt*sin#theta space",nPtBins,hptbin,dipnbin,hdipbin);
648   hFitResPtDipRV=new TH2F("hFitResPtDipRV","The 3D histogram for Resolution in Pt*sin#theta space",nPtBins,hptbin,dipnbin,hdipbin);
649   hFitResPtDipOV=new TH2F("hFitResPtDipOV","The 3D histogram for Resolution in Pt*sin#theta space",nPtBins,hptbin,dipnbin,hdipbin);
650   
651   
652   for (Int_t v=0;v<dipnbin;v++) { 
653     incycle=0;
654     for (Int_t nint=0;nint<numint;nint++) {     
655       gauss->SetRange(-interval[nint],interval[nint]);
656       for (Int_t k=0;k<nbinning[nint];k++) {
657         //gauss->SetRange(-interval,interval);
658         if(hFitResolutionOV[v*nPtBins+k+incycle]->GetEntries()>1.) {
659           // cout<<"v "<<v<<"ptbin"<<k+incycle<<endl;
660           cout<<hFitResolutionTV[v*nPtBins+k+incycle]->GetEntries()<<endl;
661           hFitResolutionTV[v*nPtBins+k+incycle]->Fit("gauss","N,R");
662           sigmaResolutionTV[v][k+incycle]=gauss->GetParameter(2);
663           hFitResPtDipTV->SetBinContent((k+incycle+1),v+1,sigmaResolutionTV[v][k+incycle]);
664           
665           hFitResolutionRV[v*nPtBins+k+incycle]->Fit("gauss","N,R");
666           sigmaResolutionRV[v][k+incycle]=gauss->GetParameter(2);
667           hFitResPtDipRV->SetBinContent((k+incycle+1),v+1,sigmaResolutionRV[v][k+incycle]);
668           
669           hFitResolutionOV[v*nPtBins+k+incycle]->Fit("gauss","N,R");
670           sigmaResolutionOV[v][k+incycle]=gauss->GetParameter(2);
671           hFitResPtDipOV->SetBinContent((k+incycle+1),v+1,sigmaResolutionOV[v][k+incycle]);
672         } else {
673           sigmaResolutionTV[v][k+incycle]=0;
674           sigmaResolutionRV[v][k+incycle]=0;
675           sigmaResolutionOV[v][k+incycle]=0;
676           hFitResPtDipTV->SetBinContent((k+incycle+1),v+1,sigmaResolutionTV[v][k+incycle]);
677           hFitResPtDipRV->SetBinContent((k+incycle+1),v+1,sigmaResolutionRV[v][k+incycle]);
678           hFitResPtDipOV->SetBinContent((k+incycle+1),v+1,sigmaResolutionOV[v][k+incycle]);
679         }
680       }
681       incycle+=nbinning[nint];
682     }
683   }  
684   
685   printf("###########  Number of good tracks: %d  ###########\n",np);
686   printf("###########  Number of fake tracks: %d  ###########\n",nfaketr);
687
688
689   //-------DRAWING  TGRAPH--------  
690   
691   const int cWidth = 1400;
692   const int cHeight = 800;
693   
694   TCanvas* c0 = new TCanvas("c0","c0",cWidth,cHeight);
695   c0->Divide(3,1);
696   c0->cd(1);
697   gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();    
698   gr0TV = new TGraphErrors(nPtBins,ptbin,sigmaResolutionPtTV,ex,errsigmResPtTV);
699   gr0TV->SetName("mygraphd0TV");
700   gr0TV->SetLineColor(1);
701   gr0TV->SetLineWidth(1);
702   gr0TV->SetMarkerColor(gMarkerColor);
703   gr0TV->SetMarkerStyle(21);
704   gr0TV->SetMarkerSize(1);
705   titlegraph1="d_{0}(r#phi) Resolution  (MC vertex)";
706   gr0TV->SetTitle(titlegraph1);
707   gr0TV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
708   gr0TV->GetYaxis()->SetTitle("#sigma [#mu m]");
709   gr0TV->GetXaxis()->SetTitleSize(0.05);
710   gr0TV->GetYaxis()->SetTitleSize(0.05);
711   gr0TV->GetXaxis()->SetLabelSize(0.05);
712   gr0TV->GetYaxis()->SetLabelSize(0.05);
713   gr0TV->Draw("AP");
714
715   c0->cd(3);
716   gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();    
717   TGraphErrors *gr0meanTV = new TGraphErrors(nPtBins,ptbin,meanResolutionPtTV,ex,errmeanResPtTV);
718   gr0meanTV->SetName("mygraphmeand0TV");
719   gr0meanTV->SetLineColor(1);
720   gr0meanTV->SetLineWidth(1);
721   gr0meanTV->SetMarkerColor(gMarkerColor);
722   gr0meanTV->SetMarkerStyle(21);
723   gr0meanTV->SetMarkerSize(1);
724   titlegraph1="Mean of d_{0}(r#phi) residuals  (MC vertex)";
725   gr0meanTV->SetTitle(titlegraph1);
726   gr0meanTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
727   gr0meanTV->GetYaxis()->SetTitle("mean of residuals [#mu m]");
728   gr0meanTV->GetXaxis()->SetTitleSize(0.05);
729   gr0meanTV->GetYaxis()->SetTitleSize(0.05);
730   gr0meanTV->GetXaxis()->SetLabelSize(0.05);
731   gr0meanTV->GetYaxis()->SetLabelSize(0.05);
732   gr0meanTV->Draw("AP");
733   
734   /*
735     TCanvas* c1 = new TCanvas("c1","Resolution analysis dip Angle",cWidth,cHeight);
736     c1->Divide(3,1);
737     c1->cd(1);
738     gr1TV = new TGraphErrors(dipnbin,dipbin,sigmaResolutionDipTV,exdip,errsigmResDipTV);
739     gr1TV->SetName("mygraph1TV");
740     gr1TV->SetLineColor(1);
741     gr1TV->SetLineWidth(1);
742     gr1TV->SetMarkerColor(gMarkerColor);
743     gr1TV->SetMarkerStyle(21);
744     gr1TV->SetMarkerSize(1);
745     titlegraph1="d_{0}(z) Resolution for ";
746     titlegraph1.Append(partforgraph);
747     titlegraph1.Append(" using True Vertex");
748     gr1TV->SetTitle(titlegraph1);
749     gr1TV->GetXaxis()->SetTitle("sin#theta ");
750     gr1TV->GetYaxis()->SetTitle("#sigma [#mu m]");
751     gr1TV->GetXaxis()->SetTitleSize(0.05);
752     gr1TV->GetYaxis()->SetTitleSize(0.05);
753     gr1TV->GetXaxis()->SetLabelSize(0.05);
754     gr1TV->GetYaxis()->SetLabelSize(0.05);
755     gr1TV->GetXaxis()->SetRangeUser(0.7,1);
756     gr1TV->GetYaxis()->SetRangeUser(0,100);
757     gr1TV->Draw("AP");
758     c1->Update();
759         
760     c1->cd(2);
761     // gPad->SetLogy();
762     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
763     gr1RV = new TGraphErrors(dipnbin,dipbin,sigmaResolutionDipRV,exdip,errsigmResDipRV);
764     gr1RV->SetName("mygraph1RV");
765     gr1RV->SetLineColor(1);
766     gr1RV->SetLineWidth(1);
767     gr1RV->SetMarkerColor(gMarkerColor);
768     gr1RV->SetMarkerStyle(21);
769     gr1RV->SetMarkerSize(1);
770     titlegraph1="d_{0}(z) Resolution for ";
771     titlegraph1.Append(partforgraph);
772     titlegraph1.Append(" using Reconstructed Vertex");
773     gr1RV->SetTitle(titlegraph1);
774     gr1RV->GetXaxis()->SetTitle("sin#theta ");
775     gr1RV->GetYaxis()->SetTitle("#sigma [#mu m]");
776     gr1RV->GetXaxis()->SetTitleSize(0.05);
777     gr1RV->GetYaxis()->SetTitleSize(0.05);
778     gr1RV->GetXaxis()->SetLabelSize(0.05);
779     gr1RV->GetYaxis()->SetLabelSize(0.05);
780     gr1RV->GetXaxis()->SetRangeUser(0.7,1);
781     gr1RV->GetYaxis()->SetRangeUser(0,100);
782     gr1RV->Draw("AP");
783     c1->Update();
784
785
786   
787     c1->cd(3);
788     // gPad->SetLogy();
789     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
790     gr1OV = new TGraphErrors(dipnbin,dipbin,sigmaResolutionDipOV,exdip,errsigmResDipOV);
791     gr1OV->SetName("mygraph1OV");
792     gr1OV->SetLineColor(1);
793     gr1OV->SetLineWidth(1);
794     gr1OV->SetMarkerColor(gMarkerColor);
795     gr1OV->SetMarkerStyle(21);
796     gr1OV->SetMarkerSize(1);
797     titlegraph1="d_{0}(z) Resolution for ";
798     titlegraph1.Append(partforgraph);
799     titlegraph1.Append(" using Vertex on the Fly");
800     gr1OV->SetTitle(titlegraph1);
801     gr1OV->GetXaxis()->SetTitle("sin#theta ");
802     gr1OV->GetYaxis()->SetTitle("#sigma [#mu m]");
803     gr1OV->GetXaxis()->SetTitleSize(0.05);
804     gr1OV->GetYaxis()->SetTitleSize(0.05);
805     gr1OV->GetXaxis()->SetLabelSize(0.05);
806     gr1OV->GetYaxis()->SetLabelSize(0.05);
807     gr1OV->GetXaxis()->SetRangeUser(0.7,1);
808     gr1OV->GetYaxis()->SetRangeUser(0,100);
809     gr1OV->Draw("AP");
810     c1->Update();
811     */    
812
813     TCanvas* c2 = new TCanvas("c2","c2",cWidth,cHeight);
814     c2->Divide(3,1);
815     c2->cd(1);
816     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();    
817     grPullTV = new TGraphErrors(nPtBins,ptbin,sigmaPullPtTV,ex,errsigmPullPtTV);
818     grPullTV->SetName("mygraphPullTV");
819     grPullTV->SetMinimum(0);
820     grPullTV->SetMaximum(1.5);
821     grPullTV->SetLineColor(1);
822     grPullTV->SetLineWidth(1);
823     grPullTV->SetMarkerColor(gMarkerColor);
824     grPullTV->SetMarkerStyle(21);
825     grPullTV->SetMarkerSize(1);
826     titlegraph1="d_{0}(r#phi) Pull  (MC vertex)";
827     grPullTV->SetTitle(titlegraph1);
828     grPullTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
829     grPullTV->GetYaxis()->SetTitle("");
830     grPullTV->GetXaxis()->SetTitleSize(0.05);
831     grPullTV->GetYaxis()->SetTitleSize(0.05);
832     grPullTV->GetXaxis()->SetLabelSize(0.05);
833     grPullTV->GetYaxis()->SetLabelSize(0.05);
834     grPullTV->Draw("AP");
835     c0->cd(2);
836     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
837     grPullTV->Draw("AP");
838
839     c2->cd(2);
840     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
841     grPullRV = new TGraphErrors(nPtBins,ptbin,sigmaPullPtRV,ex,errsigmPullPtRV);
842     grPullRV->SetName("mygraphPullRV");
843     grPullRV->SetMinimum(0);
844     grPullRV->SetMaximum(1.2);
845     grPullRV->SetLineColor(1);
846     grPullRV->SetLineWidth(1);
847     grPullRV->SetMarkerColor(gMarkerColor);
848     grPullRV->SetMarkerStyle(21);
849     grPullRV->SetMarkerSize(1);
850     titlegraph1="d_{0}(r#phi) Pull for using Reconstructed Vertex";
851     grPullRV->SetTitle(titlegraph1);
852     grPullRV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
853     grPullRV->GetYaxis()->SetTitle("");
854     grPullRV->GetXaxis()->SetTitleSize(0.05);
855     grPullRV->GetYaxis()->SetTitleSize(0.05);
856     grPullRV->GetXaxis()->SetLabelSize(0.05);
857     grPullRV->GetYaxis()->SetLabelSize(0.05);
858     grPullRV->Draw("AP");
859
860     c2->cd(3);
861     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
862     grPullOV = new TGraphErrors(nPtBins,ptbin,sigmaPullPtOV,ex,errsigmPullPtOV);
863     grPullOV->SetName("mygraphPullOV");
864     grPullOV->SetMinimum(0);
865     grPullOV->SetMaximum(1.2);
866     grPullOV->SetLineColor(1);
867     grPullOV->SetLineWidth(1);
868     grPullOV->SetMarkerColor(gMarkerColor);
869     grPullOV->SetMarkerStyle(21);
870     grPullOV->SetMarkerSize(1);
871     titlegraph1="d_{0}(r#phi) Pull using Vertex on the Fly";
872     grPullOV->SetTitle(titlegraph1);
873     grPullOV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
874     grPullOV->GetYaxis()->SetTitle("");
875     grPullOV->GetXaxis()->SetTitleSize(0.05);
876     grPullOV->GetYaxis()->SetTitleSize(0.05);
877     grPullOV->GetXaxis()->SetLabelSize(0.05);
878     grPullOV->GetYaxis()->SetLabelSize(0.05);
879     grPullOV->Draw("AP");
880
881
882     TCanvas* c3 = new TCanvas("c3","c3",cWidth,cHeight);
883     c3->Divide(2,1);   
884     c3->cd(1);
885     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
886     grd0zResTV = new TGraphErrors(nPtBins,ptbin,sigmad0zResPtTV,ex,errsigmd0zResPtTV);
887     grd0zResTV->SetName("mygraphd0zResTV");
888     grd0zResTV->SetLineColor(1);
889     grd0zResTV->SetLineWidth(1);
890     grd0zResTV->SetMarkerColor(gMarkerColor);
891     grd0zResTV->SetMarkerStyle(21);
892     grd0zResTV->SetMarkerSize(1);
893     titlegraph1="d_{0}(z) Resolution  (MC vertex)";
894     grd0zResTV->SetTitle(titlegraph1);
895     grd0zResTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
896     grd0zResTV->GetYaxis()->SetTitle("#sigma [#mu m]");
897     grd0zResTV->GetXaxis()->SetTitleSize(0.05);
898     grd0zResTV->GetYaxis()->SetTitleSize(0.05);
899     grd0zResTV->GetXaxis()->SetLabelSize(0.05);
900     grd0zResTV->GetYaxis()->SetLabelSize(0.05);
901     grd0zResTV->Draw("AP");
902     c3->cd(2);
903     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
904     grd0zPullTV = new TGraphErrors(nPtBins,ptbin,sigmad0zPullPtTV,ex,errsigmd0zPullPtTV);
905     grd0zPullTV->SetName("mygraphd0zPullTV");
906     grd0zPullTV->SetMinimum(0);
907     grd0zPullTV->SetMaximum(1.5);
908     grd0zPullTV->SetLineColor(1);
909     grd0zPullTV->SetLineWidth(1);
910     grd0zPullTV->SetMarkerColor(gMarkerColor);
911     grd0zPullTV->SetMarkerStyle(21);
912     grd0zPullTV->SetMarkerSize(1);
913     titlegraph1="d_{0}(z) Pull  (MC vertex)";
914     grd0zPullTV->SetTitle(titlegraph1);
915     grd0zPullTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
916     grd0zPullTV->GetYaxis()->SetTitle("");
917     grd0zPullTV->GetXaxis()->SetTitleSize(0.05);
918     grd0zPullTV->GetYaxis()->SetTitleSize(0.05);
919     grd0zPullTV->GetXaxis()->SetLabelSize(0.05);
920     grd0zPullTV->GetYaxis()->SetLabelSize(0.05);
921     grd0zPullTV->Draw("AP");
922
923     TCanvas* c4 = new TCanvas("c4","c4",cWidth,cHeight);
924     c4->Divide(3,1);
925     c4->cd(1);
926     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
927     grPtResTV = new TGraphErrors(nPtBins,ptbin,sigmaPtResTV,ex,errsigmPtResTV);
928     grPtResTV->SetName("mygraphPtResTV");
929     grPtResTV->SetLineColor(1);
930     grPtResTV->SetLineWidth(1);
931     grPtResTV->SetMarkerColor(gMarkerColor);
932     grPtResTV->SetMarkerStyle(21);
933     grPtResTV->SetMarkerSize(1);
934     titlegraph1="p_{t}mes/p_{t}true - 1 ";
935     grPtResTV->SetTitle(titlegraph1);
936     grPtResTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
937     grPtResTV->GetYaxis()->SetTitle("#sigma(p_{t}mes/p_{t}true- 1 ) ");
938     grPtResTV->GetXaxis()->SetTitleSize(0.05);
939     grPtResTV->GetYaxis()->SetTitleSize(0.05);
940     grPtResTV->GetXaxis()->SetLabelSize(0.05);
941     grPtResTV->GetYaxis()->SetLabelSize(0.05);
942     grPtResTV->GetYaxis()->SetRangeUser(0,0.025);
943     grPtResTV->Draw("AP");
944     c4->cd(2);
945     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
946     grPtResMeanTV = new TGraphErrors(nPtBins,ptbin,meanPtResTV,ex,errmeanPtResTV);
947     grPtResMeanTV->SetName("mygraphPtResMeanTV");
948     grPtResMeanTV->SetLineColor(1);
949     grPtResMeanTV->SetLineWidth(1);
950     grPtResMeanTV->SetMarkerColor(gMarkerColor);
951     grPtResMeanTV->SetMarkerStyle(21);
952     grPtResMeanTV->SetMarkerSize(1);
953     titlegraph1="p_{t}mes/p_{t}true - 1 ";
954     grPtResMeanTV->SetTitle(titlegraph1);
955     grPtResMeanTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
956     grPtResMeanTV->GetYaxis()->SetTitle("mean(p_{t}mes/p_{t}true - 1) ");
957     grPtResMeanTV->GetXaxis()->SetTitleSize(0.05);
958     grPtResMeanTV->GetYaxis()->SetTitleSize(0.05);
959     grPtResMeanTV->GetXaxis()->SetLabelSize(0.05);
960     grPtResMeanTV->GetYaxis()->SetLabelSize(0.05);
961     grPtResMeanTV->GetYaxis()->SetRangeUser(0,0.025);
962     grPtResMeanTV->Draw("AP");
963     c4->cd(3);
964     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
965     grCurvResTV = new TGraphErrors(nPtBins,ptbin,sigmaCurvResTV,ex,errsigmCurvResTV);
966     grCurvResTV->SetName("mygraphCurvResTV");
967     grCurvResTV->SetLineColor(1);
968     grCurvResTV->SetLineWidth(1);
969     grCurvResTV->SetMarkerColor(gMarkerColor);
970     grCurvResTV->SetMarkerStyle(21);
971     grCurvResTV->SetMarkerSize(1);
972     titlegraph1="1/p_{t} Resolution ";
973     grCurvResTV->SetTitle(titlegraph1);
974     grCurvResTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
975     grCurvResTV->GetYaxis()->SetTitle("#sigma(1/p_{t}) [1/(GeV/c)]");
976     grCurvResTV->GetXaxis()->SetTitleSize(0.05);
977     grCurvResTV->GetYaxis()->SetTitleSize(0.05);
978     grCurvResTV->GetXaxis()->SetLabelSize(0.05);
979     grCurvResTV->GetYaxis()->SetLabelSize(0.05);
980     grCurvResTV->Draw("AP");
981
982
983     /*
984     TCanvas* c5 = new TCanvas("c5","Resolution analysis 2",cWidth,cHeight);
985     c5->Divide(3,1);
986     c5->cd(1);
987     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();    
988     grsigmad0rphiTV = new TGraphErrors(nPtBins,ptbin,mediumsigmad0rphiPtTV,ex,errmediumsigmad0rphiPtTV);
989     grsigmad0rphiTV->SetName("mygraphsigmad0rphiTV");
990     grsigmad0rphiTV->SetLineColor(1);
991     grsigmad0rphiTV->SetLineWidth(1);
992     grsigmad0rphiTV->SetMarkerColor(gMarkerColor);
993     grsigmad0rphiTV->SetMarkerStyle(21);
994     grsigmad0rphiTV->SetMarkerSize(1);
995     titlegraph1="d_{0}(r#phi) Resolution Estimated from Cov. Matr (RelateToVtx) for ";
996     titlegraph1.Append(" using TV");
997     grsigmad0rphiTV->SetTitle(titlegraph1);
998     grsigmad0rphiTV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
999     grsigmad0rphiTV->GetYaxis()->SetTitle("#sigma [#mu m]");
1000     grsigmad0rphiTV->GetXaxis()->SetTitleSize(0.05);
1001     grsigmad0rphiTV->GetYaxis()->SetTitleSize(0.05);
1002     grsigmad0rphiTV->GetXaxis()->SetLabelSize(0.05);
1003     grsigmad0rphiTV->GetYaxis()->SetLabelSize(0.05);
1004     grsigmad0rphiTV->Draw("AP");
1005     c5->cd(2);
1006     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
1007     grsigmad0rphiRV = new TGraphErrors(nPtBins,ptbin,mediumsigmad0rphiPtRV,ex,errmediumsigmad0rphiPtRV);
1008     grsigmad0rphiRV->SetName("mygraphsigmad0rphiRV");
1009     grsigmad0rphiRV->SetLineColor(1);
1010     grsigmad0rphiRV->SetLineWidth(1);
1011     grsigmad0rphiRV->SetMarkerColor(gMarkerColor);
1012     grsigmad0rphiRV->SetMarkerStyle(21);
1013     grsigmad0rphiRV->SetMarkerSize(1);
1014     titlegraph1="d_{0}(r#phi) Resolution Estimated from Cov. Matr (RelateToVtx) for ";
1015     titlegraph1.Append(" using RVtx");
1016     grsigmad0rphiRV->SetTitle(titlegraph1);
1017     grsigmad0rphiRV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
1018     grsigmad0rphiRV->GetYaxis()->SetTitle("#sigma [#mu m]");
1019     grsigmad0rphiRV->GetXaxis()->SetTitleSize(0.05);
1020     grsigmad0rphiRV->GetYaxis()->SetTitleSize(0.05);
1021     grsigmad0rphiRV->GetXaxis()->SetLabelSize(0.05);
1022     grsigmad0rphiRV->GetYaxis()->SetLabelSize(0.05);
1023     grsigmad0rphiRV->Draw("AP");
1024     c5->cd(3);
1025     gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
1026     grsigmad0rphiOV = new TGraphErrors(nPtBins,ptbin,mediumsigmad0rphiPtOV,ex,errmediumsigmad0rphiPtOV);
1027     grsigmad0rphiOV->SetName("mygraphsigmad0rphiOV");
1028     grsigmad0rphiOV->SetLineColor(1);
1029     grsigmad0rphiOV->SetLineWidth(1);
1030     grsigmad0rphiOV->SetMarkerColor(gMarkerColor);
1031     grsigmad0rphiOV->SetMarkerStyle(21);
1032     grsigmad0rphiOV->SetMarkerSize(1);
1033     titlegraph1="d_{0}(r#phi) Resolution Estimated from Cov. Matr (RelateToVtx) for ";
1034     titlegraph1.Append(" using VtxOth");
1035     grsigmad0rphiOV->SetTitle(titlegraph1);
1036     grsigmad0rphiOV->GetXaxis()->SetTitle("p_{t} [GeV/c] ");
1037     grsigmad0rphiOV->GetYaxis()->SetTitle("#sigma [#mu m]");
1038     grsigmad0rphiOV->GetXaxis()->SetTitleSize(0.05);
1039     grsigmad0rphiOV->GetYaxis()->SetTitleSize(0.05);
1040     grsigmad0rphiOV->GetXaxis()->SetLabelSize(0.05);
1041     grsigmad0rphiOV->GetYaxis()->SetLabelSize(0.05);
1042     grsigmad0rphiOV->Draw("AP");
1043     */
1044
1045
1046
1047     
1048     //---------CLOSE EVRYTHING AND SAVE------------
1049    TFile *outfile = new TFile("ResolutionsAnalysis.root","recreate");
1050     outfile->cd(); 
1051     for (Int_t i=0;i<nPtBins;i++) {
1052       hFitResolutionPtTV[i]->Write();
1053       hFitResolutionPtRV[i]->Write();
1054       hFitResolutionPtOV[i]->Write();
1055       delete hFitResolutionPtTV[i];//=0;
1056       delete    hFitResolutionPtRV[i];//=0;
1057       delete    hFitResolutionPtOV[i];
1058       hFitsigmad0rphiPtTV[i]->Write();
1059       hFitsigmad0rphiPtRV[i]->Write();
1060       hFitsigmad0rphiPtOV[i]->Write();
1061       delete hFitsigmad0rphiPtTV[i];//=0;
1062       delete    hFitsigmad0rphiPtRV[i];//=0;
1063       delete    hFitsigmad0rphiPtOV[i];
1064       hFitPullPtTV[i]->Write();
1065       hFitPullPtRV[i]->Write();
1066       hFitPullPtOV[i]->Write();
1067       delete hFitPullPtTV[i];//=0;
1068       delete    hFitPullPtRV[i];//=0;
1069       delete    hFitPullPtOV[i];
1070       hFitd0zResPtTV[i]->Write();
1071       hFitd0zPullPtTV[i]->Write();
1072       delete hFitd0zResPtTV[i];//=0;
1073       delete hFitd0zPullPtTV[i];//=0;
1074       hFitPtResTV[i]->Write();
1075       hFitCurvResTV[i]->Write();
1076       delete hFitPtResTV[i];//=0;
1077       delete hFitCurvResTV[i];//=0;
1078       for(Int_t j=0;j<dipnbin;j++) {
1079         hFitResolutionTV[j*nPtBins+i]->Write();
1080         hFitResolutionRV[j*nPtBins+i]->Write();
1081         hFitResolutionOV[j*nPtBins+i]->Write();
1082         delete  hFitResolutionTV[j*nPtBins+i];//=0;
1083         delete hFitResolutionRV[j*nPtBins+i];//=0;
1084         delete hFitResolutionOV[j*nPtBins+i];
1085       }
1086     }
1087     for (Int_t i=0;i<dipnbin;i++) {
1088       hFitResolutionDipTV[i]->Write();
1089       hFitResolutionDipRV[i]->Write();
1090       hFitResolutionDipOV[i]->Write();
1091       delete hFitResolutionDipTV[i];//=0;
1092       delete hFitResolutionDipRV[i];//=0;
1093       delete hFitResolutionDipOV[i];//=0;
1094     }
1095   
1096     //    delete hFitResolutionPtTV;
1097     hFitResPtDipTV->Write();
1098     hFitResPtDipRV->Write();
1099     hFitResPtDipOV->Write();
1100     delete hFitResPtDipOV;
1101     delete hFitResPtDipTV;
1102     delete hFitResPtDipRV;
1103
1104     gr0TV->Write();
1105     gr0meanTV->Write();
1106     //gr0RV->Write();
1107     //gr0OV->Write();
1108     //gr1TV->Write();
1109     //gr1RV->Write();
1110     //gr1OV->Write();
1111
1112     //grsigmad0rphiTV->Write();
1113     //grsigmad0rphiRV->Write();
1114     //grsigmad0rphiOV->Write();
1115   
1116     grd0zResTV->Write();
1117     grd0zPullTV->Write();
1118     grPtResTV->Write();
1119     grPtResMeanTV->Write();
1120     grCurvResTV->Write();
1121     
1122
1123     grPullTV->Write();
1124     grPullRV->Write();
1125     //grPullOV->Write();
1126     
1127     outfile->Close();
1128     
1129     return; 
1130 }
1131 //-----------------------------------------------------------------------------
1132 Int_t ITSnCluster(Int_t ITSf) {
1133
1134   Int_t nTPCclusters = (Int_t)(ITSf/1000);
1135   ITSf -= nTPCclusters*1000;
1136   Int_t sign,aITSf,n0,n3,aux,ITSsel;//be careful!:working with integer!
1137   n0=0;
1138   n3=0;
1139   aITSf=TMath::Abs(ITSf);
1140   if(aITSf==0)sign=0;
1141   else if (aITSf==ITSf)sign=1;
1142   else if(aITSf==-ITSf)sign=-1;
1143   
1144   if (aITSf/100<1)n0++;
1145   n3=aITSf/300;
1146   aux=(aITSf-(aITSf/100)*100);
1147   if(aux/10<1)n0++;
1148   n3+=aux/30;
1149   aux=(aux-(aux/10)*10);
1150   if (aux==0)n0++;
1151   n3+=aux/3;
1152   ITSsel=3+n3-n0;
1153   
1154   if(ITSsel>6) {
1155     printf("Wrong ITSflag assignment! \n");
1156     return 99;
1157   }
1158   return ITSsel*sign;
1159 }
1160 //-----------------------------------------------------------------------------
1161 Bool_t kITSrefit(Double_t sigmd0TV) {
1162   //return TRUE if track was kITSrefit, FALSE otherwise (see AliTrackProperties.C)
1163   Bool_t kITSref=kTRUE;
1164   if (sigmd0TV<0.)kITSref=kFALSE;
1165   return kITSref;
1166 }
1167 //-----------------------------------------------------------------------------
1168 void PlotResolutions() {
1169
1170   TCanvas *c1a = new TCanvas("c1a","d0 resolution",0,0,800,800);
1171   c1a->SetLogx();
1172   c1a->SetGridx();
1173   c1a->SetGridy();
1174   TCanvas *c1b = new TCanvas("c1b","d0 mean",0,0,800,800);
1175   c1b->SetLogx();
1176   c1b->SetGridx();
1177   c1b->SetGridy();
1178   TCanvas *c1c = new TCanvas("c1c","d0 pull",0,0,800,800);
1179   c1c->SetLogx();
1180   c1c->SetGridx();
1181   c1c->SetGridy();
1182
1183   TCanvas *c2a = new TCanvas("c2a","z0 resolution",0,0,800,800);
1184   c2a->SetLogx();
1185   c2a->SetGridx();
1186   c2a->SetGridy();
1187   TCanvas *c2c = new TCanvas("c2c","z0 pull",0,0,800,800);
1188   c2c->SetLogx();
1189   c2c->SetGridx();
1190   c2c->SetGridy();
1191
1192   TCanvas *c3a = new TCanvas("c3a","pt resolution",0,0,800,800);
1193   c3a->SetLogx();
1194   c3a->SetGridx();
1195   c3a->SetGridy();
1196   TCanvas *c3b = new TCanvas("c3b","pt mean",0,0,800,800);
1197   c3b->SetLogx();
1198   c3b->SetGridx();
1199   c3b->SetGridy();
1200
1201   TCanvas *c4 = new TCanvas("c4","d0 residuals",0,0,800,800);
1202   c4->Divide(3,3);
1203   c4_1->SetLogy();
1204   c4_2->SetLogy();
1205   c4_3->SetLogy();
1206   c4_4->SetLogy();
1207   c4_5->SetLogy();
1208   c4_6->SetLogy();
1209   c4_7->SetLogy();
1210   c4_8->SetLogy();
1211   c4_9->SetLogy();
1212
1213   TCanvas *c5 = new TCanvas("c5","pt residuals",0,0,800,800);
1214   c5->Divide(3,3);
1215   c5_1->SetLogy();
1216   c5_2->SetLogy();
1217   c5_3->SetLogy();
1218   c5_4->SetLogy();
1219   c5_5->SetLogy();
1220   c5_6->SetLogy();
1221   c5_7->SetLogy();
1222   c5_8->SetLogy();
1223   c5_9->SetLogy();
1224
1225
1226   TLegend *leg1=new TLegend(0.5,0.5,0.9,0.9);
1227   leg1->SetFillStyle(0);
1228   leg1->SetBorderSize(0);
1229   TLegend *leg2=new TLegend(0.5,0.5,0.9,0.9);
1230   leg2->SetFillStyle(0);
1231   leg2->SetBorderSize(0);
1232   TGraph *mark20=new TGraph();
1233   mark20->SetMarkerColor(4);
1234   mark20->SetLineColor(4);
1235   mark20->SetMarkerStyle(20);
1236   leg1->AddEntry(mark20,"pions","p");
1237   leg2->AddEntry(mark20,"pions","l");
1238   TGraph *mark21=new TGraph();
1239   mark21->SetMarkerColor(2);
1240   mark21->SetLineColor(2);
1241   mark21->SetMarkerStyle(21);
1242   leg1->AddEntry(mark21,"electrons","p");
1243   leg2->AddEntry(mark21,"electrons","l");
1244   TGraph *mark25=new TGraph();
1245   mark25->SetMarkerColor(1);
1246   mark25->SetLineColor(1);
1247   mark25->SetMarkerStyle(25);
1248   leg1->AddEntry(mark25,"electrons (no brem)","p");
1249   leg2->AddEntry(mark25,"electrons (no brem)","l");
1250   TGraph *mark22=new TGraph();
1251   mark22->SetMarkerColor(6);
1252   mark22->SetLineColor(6);
1253   mark22->SetMarkerStyle(22);
1254   leg1->AddEntry(mark22,"kaons","p");
1255   leg2->AddEntry(mark22,"kaons","l");
1256   TGraph *mark23=new TGraph();
1257   mark23->SetMarkerColor(8);
1258   mark23->SetLineColor(8);
1259   mark23->SetMarkerStyle(23);
1260   leg1->AddEntry(mark23,"protons","p");
1261   leg2->AddEntry(mark23,"protons","l");
1262
1263   // pions
1264   TFile *f1=new TFile("boxPiv416Release_zero/ResolutionsAnalysis_Pi.root");
1265   c1a->cd();
1266   mygraphd0TV->Draw("a,p");
1267   mygraphd0TV->SetMarkerColor(4);
1268   mygraphd0TV->SetMarkerStyle(20);
1269   leg1->Draw();
1270   c1b->cd();
1271   mygraphmeand0TV->Draw("a,p");
1272   mygraphmeand0TV->SetMarkerColor(4);
1273   mygraphmeand0TV->SetMarkerStyle(20);
1274   leg1->Draw();
1275   c1c->cd();
1276   mygraphPullTV->Draw("a,p");
1277   mygraphPullTV->SetMarkerColor(4);
1278   mygraphPullTV->SetMarkerStyle(20);
1279   leg1->Draw();
1280   c2a->cd();
1281   mygraphd0zResTV->Draw("a,p");
1282   mygraphd0zResTV->SetMarkerColor(4);
1283   mygraphd0zResTV->SetMarkerStyle(20);
1284   leg1->Draw();
1285   c2c->cd();
1286   mygraphd0zPullTV->Draw("a,p");
1287   mygraphd0zPullTV->SetMarkerColor(4);
1288   mygraphd0zPullTV->SetMarkerStyle(20);
1289   leg1->Draw();
1290   c3a->cd();
1291   mygraphPtResTV->Draw("a,p");
1292   mygraphPtResTV->SetMarkerColor(4);
1293   mygraphPtResTV->SetMarkerStyle(20);
1294   leg1->Draw();
1295   c3b->cd();
1296   mygraphPtResMeanTV->Draw("a,p");
1297   mygraphPtResMeanTV->SetMarkerColor(4);
1298   mygraphPtResMeanTV->SetMarkerStyle(20);
1299   leg1->Draw();
1300   c4->cd(1);
1301   d0PtResolution0binTV->Draw();
1302   d0PtResolution0binTV->SetLineColor(4);
1303   c4->cd(2);
1304   d0PtResolution1binTV->Draw();
1305   d0PtResolution1binTV->SetLineColor(4);
1306   c4->cd(3);
1307   d0PtResolution2binTV->Draw();
1308   d0PtResolution2binTV->SetLineColor(4);
1309   c4->cd(4);
1310   d0PtResolution3binTV->Draw();
1311   d0PtResolution3binTV->SetLineColor(4);
1312   c4->cd(5);
1313   d0PtResolution4binTV->Draw();
1314   d0PtResolution4binTV->SetLineColor(4);
1315   c4->cd(6);
1316   d0PtResolution5binTV->Draw();
1317   d0PtResolution5binTV->SetLineColor(4);
1318   c4->cd(7);
1319   d0PtResolution6binTV->Draw();
1320   d0PtResolution6binTV->SetLineColor(4);
1321   c4->cd(8);
1322   d0PtResolution7binTV->Draw();
1323   d0PtResolution7binTV->SetLineColor(4);
1324   c4->cd(9);
1325   d0PtResolution8binTV->Draw();
1326   d0PtResolution8binTV->SetLineColor(4);
1327   leg2->Draw();
1328   c5->cd(1);
1329   PtResolution0binTV->Draw();
1330   PtResolution0binTV->SetLineColor(4);
1331   c5->cd(2);
1332   PtResolution1binTV->Draw();
1333   PtResolution1binTV->SetLineColor(4);
1334   c5->cd(3);
1335   PtResolution2binTV->Draw();
1336   PtResolution2binTV->SetLineColor(4);
1337   c5->cd(4);
1338   PtResolution3binTV->Draw();
1339   PtResolution3binTV->SetLineColor(4);
1340   c5->cd(5);
1341   PtResolution4binTV->Draw();
1342   PtResolution4binTV->SetLineColor(4);
1343   c5->cd(6);
1344   PtResolution5binTV->Draw();
1345   PtResolution5binTV->SetLineColor(4);
1346   c5->cd(7);
1347   PtResolution6binTV->Draw();
1348   PtResolution6binTV->SetLineColor(4);
1349   c5->cd(8);
1350   PtResolution7binTV->Draw();
1351   PtResolution7binTV->SetLineColor(4);
1352   c5->cd(9);
1353   PtResolution8binTV->Draw();
1354   PtResolution8binTV->SetLineColor(4);
1355   leg2->Draw();
1356
1357
1358
1359   // kaons
1360   TFile *f3=new TFile("boxKav416Release_zero/ResolutionsAnalysis_Ka.root");
1361   c1a->cd();
1362   mygraphd0TV->Draw("p");
1363   mygraphd0TV->SetMarkerColor(6);
1364   mygraphd0TV->SetMarkerStyle(22);
1365   c1b->cd();
1366   mygraphmeand0TV->Draw("p");
1367   mygraphmeand0TV->SetMarkerColor(6);
1368   mygraphmeand0TV->SetMarkerStyle(22);
1369   c1c->cd();
1370   mygraphPullTV->Draw("p");
1371   mygraphPullTV->SetMarkerColor(6);
1372   mygraphPullTV->SetMarkerStyle(22);
1373   c2a->cd();
1374   mygraphd0zResTV->Draw("p");
1375   mygraphd0zResTV->SetMarkerColor(6);
1376   mygraphd0zResTV->SetMarkerStyle(22);
1377   c2c->cd();
1378   mygraphd0zPullTV->Draw("p");
1379   mygraphd0zPullTV->SetMarkerColor(6);
1380   mygraphd0zPullTV->SetMarkerStyle(22);
1381   c3a->cd();
1382   mygraphPtResTV->Draw("p");
1383   mygraphPtResTV->SetMarkerColor(6);
1384   mygraphPtResTV->SetMarkerStyle(22);
1385   c3b->cd();
1386   mygraphPtResMeanTV->Draw("p");
1387   mygraphPtResMeanTV->SetMarkerColor(6);
1388   mygraphPtResMeanTV->SetMarkerStyle(22);
1389   c4->cd(1);
1390   d0PtResolution0binTV->Draw("same");
1391   d0PtResolution0binTV->SetLineColor(6);
1392   c4->cd(2);
1393   d0PtResolution1binTV->Draw("same");
1394   d0PtResolution1binTV->SetLineColor(6);
1395   c4->cd(3);
1396   d0PtResolution2binTV->Draw("same");
1397   d0PtResolution2binTV->SetLineColor(6);
1398   c4->cd(4);
1399   d0PtResolution3binTV->Draw("same");
1400   d0PtResolution3binTV->SetLineColor(6);
1401   c4->cd(5);
1402   d0PtResolution4binTV->Draw("same");
1403   d0PtResolution4binTV->SetLineColor(6);
1404   c4->cd(6);
1405   d0PtResolution5binTV->Draw("same");
1406   d0PtResolution5binTV->SetLineColor(6);
1407   c4->cd(7);
1408   d0PtResolution6binTV->Draw("same");
1409   d0PtResolution6binTV->SetLineColor(6);
1410   c4->cd(8);
1411   d0PtResolution7binTV->Draw("same");
1412   d0PtResolution7binTV->SetLineColor(6);
1413   c4->cd(9);
1414   d0PtResolution8binTV->Draw("same");
1415   d0PtResolution8binTV->SetLineColor(6);
1416   c5->cd(1);
1417   PtResolution0binTV->Draw("same");
1418   PtResolution0binTV->SetLineColor(6);
1419   c5->cd(2);
1420   PtResolution1binTV->Draw("same");
1421   PtResolution1binTV->SetLineColor(6);
1422   c5->cd(3);
1423   PtResolution2binTV->Draw("same");
1424   PtResolution2binTV->SetLineColor(6);
1425   c5->cd(4);
1426   PtResolution3binTV->Draw("same");
1427   PtResolution3binTV->SetLineColor(6);
1428   c5->cd(5);
1429   PtResolution4binTV->Draw("same");
1430   PtResolution4binTV->SetLineColor(6);
1431   c5->cd(6);
1432   PtResolution5binTV->Draw("same");
1433   PtResolution5binTV->SetLineColor(6);
1434   c5->cd(7);
1435   PtResolution6binTV->Draw("same");
1436   PtResolution6binTV->SetLineColor(6);
1437   c5->cd(8);
1438   PtResolution7binTV->Draw("same");
1439   PtResolution7binTV->SetLineColor(6);
1440   c5->cd(9);
1441   PtResolution8binTV->Draw("same");
1442   PtResolution8binTV->SetLineColor(6);
1443
1444
1445   // protons
1446   TFile *f4=new TFile("boxPrv416Release_zero/ResolutionsAnalysis_Pr.root");
1447   c1a->cd();
1448   mygraphd0TV->Draw("p");
1449   mygraphd0TV->SetMarkerColor(8);
1450   mygraphd0TV->SetMarkerStyle(23);
1451   c1b->cd();
1452   mygraphmeand0TV->Draw("p");
1453   mygraphmeand0TV->SetMarkerColor(8);
1454   mygraphmeand0TV->SetMarkerStyle(23);
1455   c1c->cd();
1456   mygraphPullTV->Draw("p");
1457   mygraphPullTV->SetMarkerColor(8);
1458   mygraphPullTV->SetMarkerStyle(23);
1459   c2a->cd();
1460   mygraphd0zResTV->Draw("p");
1461   mygraphd0zResTV->SetMarkerColor(8);
1462   mygraphd0zResTV->SetMarkerStyle(23);
1463   c2c->cd();
1464   mygraphd0zPullTV->Draw("p");
1465   mygraphd0zPullTV->SetMarkerColor(8);
1466   mygraphd0zPullTV->SetMarkerStyle(23);
1467   c3a->cd();
1468   mygraphPtResTV->Draw("p");
1469   mygraphPtResTV->SetMarkerColor(8);
1470   mygraphPtResTV->SetMarkerStyle(23);
1471   c3b->cd();
1472   mygraphPtResMeanTV->Draw("p");
1473   mygraphPtResMeanTV->SetMarkerColor(8);
1474   mygraphPtResMeanTV->SetMarkerStyle(23);
1475   c4->cd(1);
1476   d0PtResolution0binTV->Draw("same");
1477   d0PtResolution0binTV->SetLineColor(8);
1478   c4->cd(2);
1479   d0PtResolution1binTV->Draw("same");
1480   d0PtResolution1binTV->SetLineColor(8);
1481   c4->cd(3);
1482   d0PtResolution2binTV->Draw("same");
1483   d0PtResolution2binTV->SetLineColor(8);
1484   c4->cd(4);
1485   d0PtResolution3binTV->Draw("same");
1486   d0PtResolution3binTV->SetLineColor(8);
1487   c4->cd(5);
1488   d0PtResolution4binTV->Draw("same");
1489   d0PtResolution4binTV->SetLineColor(8);
1490   c4->cd(6);
1491   d0PtResolution5binTV->Draw("same");
1492   d0PtResolution5binTV->SetLineColor(8);
1493   c4->cd(7);
1494   d0PtResolution6binTV->Draw("same");
1495   d0PtResolution6binTV->SetLineColor(8);
1496   c4->cd(8);
1497   d0PtResolution7binTV->Draw("same");
1498   d0PtResolution7binTV->SetLineColor(8);
1499   c4->cd(9);
1500   d0PtResolution8binTV->Draw("same");
1501   d0PtResolution8binTV->SetLineColor(8);
1502   c5->cd(1);
1503   PtResolution0binTV->Draw("same");
1504   PtResolution0binTV->SetLineColor(8);
1505   c5->cd(2);
1506   PtResolution1binTV->Draw("same");
1507   PtResolution1binTV->SetLineColor(8);
1508   c5->cd(3);
1509   PtResolution2binTV->Draw("same");
1510   PtResolution2binTV->SetLineColor(8);
1511   c5->cd(4);
1512   PtResolution3binTV->Draw("same");
1513   PtResolution3binTV->SetLineColor(8);
1514   c5->cd(5);
1515   PtResolution4binTV->Draw("same");
1516   PtResolution4binTV->SetLineColor(8);
1517   c5->cd(6);
1518   PtResolution5binTV->Draw("same");
1519   PtResolution5binTV->SetLineColor(8);
1520   c5->cd(7);
1521   PtResolution6binTV->Draw("same");
1522   PtResolution6binTV->SetLineColor(8);
1523   c5->cd(8);
1524   PtResolution7binTV->Draw("same");
1525   PtResolution7binTV->SetLineColor(8);
1526   c5->cd(9);
1527   PtResolution8binTV->Draw("same");
1528   PtResolution8binTV->SetLineColor(8);
1529
1530
1531   // electrons
1532   TFile *f2=new TFile("boxElv416Release_zero/ResolutionsAnalysis_El.root");
1533   c1a->cd();
1534   mygraphd0TV->Draw("p");
1535   mygraphd0TV->SetMarkerColor(2);
1536   mygraphd0TV->SetMarkerStyle(21);
1537   c1b->cd();
1538   mygraphmeand0TV->Draw("p");
1539   mygraphmeand0TV->SetMarkerColor(2);
1540   mygraphmeand0TV->SetMarkerStyle(21);
1541   c1c->cd();
1542   mygraphPullTV->Draw("p");
1543   mygraphPullTV->SetMarkerColor(2);
1544   mygraphPullTV->SetMarkerStyle(21);
1545   c2a->cd();
1546   mygraphd0zResTV->Draw("p");
1547   mygraphd0zResTV->SetMarkerColor(2);
1548   mygraphd0zResTV->SetMarkerStyle(21);
1549   c2c->cd();
1550   mygraphd0zPullTV->Draw("p");
1551   mygraphd0zPullTV->SetMarkerColor(2);
1552   mygraphd0zPullTV->SetMarkerStyle(21);
1553   c3a->cd();
1554   mygraphPtResTV->Draw("p");
1555   mygraphPtResTV->SetMarkerColor(2);
1556   mygraphPtResTV->SetMarkerStyle(21);
1557   c3b->cd();
1558   mygraphPtResMeanTV->Draw("p");
1559   mygraphPtResMeanTV->SetMarkerColor(2);
1560   mygraphPtResMeanTV->SetMarkerStyle(21);
1561   c4->cd(1);
1562   d0PtResolution0binTV->Draw("same");
1563   d0PtResolution0binTV->SetLineColor(2);
1564   c4->cd(2);
1565   d0PtResolution1binTV->Draw("same");
1566   d0PtResolution1binTV->SetLineColor(2);
1567   c4->cd(3);
1568   d0PtResolution2binTV->Draw("same");
1569   d0PtResolution2binTV->SetLineColor(2);
1570   c4->cd(4);
1571   d0PtResolution3binTV->Draw("same");
1572   d0PtResolution3binTV->SetLineColor(2);
1573   c4->cd(5);
1574   d0PtResolution4binTV->Draw("same");
1575   d0PtResolution4binTV->SetLineColor(2);
1576   c4->cd(6);
1577   d0PtResolution5binTV->Draw("same");
1578   d0PtResolution5binTV->SetLineColor(2);
1579   c4->cd(7);
1580   d0PtResolution6binTV->Draw("same");
1581   d0PtResolution6binTV->SetLineColor(2);
1582   c4->cd(8);
1583   d0PtResolution7binTV->Draw("same");
1584   d0PtResolution7binTV->SetLineColor(2);
1585   c4->cd(9);
1586   d0PtResolution8binTV->Draw("same");
1587   d0PtResolution8binTV->SetLineColor(2);
1588   c5->cd(1);
1589   PtResolution0binTV->Draw("same");
1590   PtResolution0binTV->SetLineColor(2);
1591   c5->cd(2);
1592   PtResolution1binTV->Draw("same");
1593   PtResolution1binTV->SetLineColor(2);
1594   c5->cd(3);
1595   PtResolution2binTV->Draw("same");
1596   PtResolution2binTV->SetLineColor(2);
1597   c5->cd(4);
1598   PtResolution3binTV->Draw("same");
1599   PtResolution3binTV->SetLineColor(2);
1600   c5->cd(5);
1601   PtResolution4binTV->Draw("same");
1602   PtResolution4binTV->SetLineColor(2);
1603   c5->cd(6);
1604   PtResolution5binTV->Draw("same");
1605   PtResolution5binTV->SetLineColor(2);
1606   c5->cd(7);
1607   PtResolution6binTV->Draw("same");
1608   PtResolution6binTV->SetLineColor(2);
1609   c5->cd(8);
1610   PtResolution7binTV->Draw("same");
1611   PtResolution7binTV->SetLineColor(2);
1612   c5->cd(9);
1613   PtResolution8binTV->Draw("same");
1614   PtResolution8binTV->SetLineColor(2);
1615
1616   // electrons, no bremsstrahlung
1617   TFile *f2=new TFile("boxElv416Release_zero/ResolutionsAnalysis_ElNoBrem.root");
1618   c1a->cd();
1619   mygraphd0TV->Draw("p");
1620   mygraphd0TV->SetMarkerColor(1);
1621   mygraphd0TV->SetMarkerStyle(25);
1622   c1b->cd();
1623   mygraphmeand0TV->Draw("p");
1624   mygraphmeand0TV->SetMarkerColor(1);
1625   mygraphmeand0TV->SetMarkerStyle(25);
1626   c1c->cd();
1627   mygraphPullTV->Draw("p");
1628   mygraphPullTV->SetMarkerColor(1);
1629   mygraphPullTV->SetMarkerStyle(25);
1630   c2a->cd();
1631   mygraphd0zResTV->Draw("p");
1632   mygraphd0zResTV->SetMarkerColor(1);
1633   mygraphd0zResTV->SetMarkerStyle(25);
1634   c2c->cd();
1635   mygraphd0zPullTV->Draw("p");
1636   mygraphd0zPullTV->SetMarkerColor(1);
1637   mygraphd0zPullTV->SetMarkerStyle(25);
1638   c3a->cd();
1639   mygraphPtResTV->Draw("p");
1640   mygraphPtResTV->SetMarkerColor(1);
1641   mygraphPtResTV->SetMarkerStyle(25);
1642   c3b->cd();
1643   mygraphPtResMeanTV->Draw("p");
1644   mygraphPtResMeanTV->SetMarkerColor(1);
1645   mygraphPtResMeanTV->SetMarkerStyle(25);
1646   c4->cd(1);
1647   d0PtResolution0binTV->Draw("same");
1648   d0PtResolution0binTV->SetLineColor(1);
1649   c4->cd(2);
1650   d0PtResolution1binTV->Draw("same");
1651   d0PtResolution1binTV->SetLineColor(1);
1652   c4->cd(3);
1653   d0PtResolution2binTV->Draw("same");
1654   d0PtResolution2binTV->SetLineColor(1);
1655   c4->cd(4);
1656   d0PtResolution3binTV->Draw("same");
1657   d0PtResolution3binTV->SetLineColor(1);
1658   c4->cd(5);
1659   d0PtResolution4binTV->Draw("same");
1660   d0PtResolution4binTV->SetLineColor(1);
1661   c4->cd(6);
1662   d0PtResolution5binTV->Draw("same");
1663   d0PtResolution5binTV->SetLineColor(1);
1664   c4->cd(7);
1665   d0PtResolution6binTV->Draw("same");
1666   d0PtResolution6binTV->SetLineColor(1);
1667   c4->cd(8);
1668   d0PtResolution7binTV->Draw("same");
1669   d0PtResolution7binTV->SetLineColor(1);
1670   c4->cd(9);
1671   d0PtResolution8binTV->Draw("same");
1672   d0PtResolution8binTV->SetLineColor(1);
1673   c5->cd(1);
1674   PtResolution0binTV->Draw("same");
1675   PtResolution0binTV->SetLineColor(1);
1676   c5->cd(2);
1677   PtResolution1binTV->Draw("same");
1678   PtResolution1binTV->SetLineColor(1);
1679   c5->cd(3);
1680   PtResolution2binTV->Draw("same");
1681   PtResolution2binTV->SetLineColor(1);
1682   c5->cd(4);
1683   PtResolution3binTV->Draw("same");
1684   PtResolution3binTV->SetLineColor(1);
1685   c5->cd(5);
1686   PtResolution4binTV->Draw("same");
1687   PtResolution4binTV->SetLineColor(1);
1688   c5->cd(6);
1689   PtResolution5binTV->Draw("same");
1690   PtResolution5binTV->SetLineColor(1);
1691   c5->cd(7);
1692   PtResolution6binTV->Draw("same");
1693   PtResolution6binTV->SetLineColor(1);
1694   c5->cd(8);
1695   PtResolution7binTV->Draw("same");
1696   PtResolution7binTV->SetLineColor(1);
1697   c5->cd(9);
1698   PtResolution8binTV->Draw("same");
1699   PtResolution8binTV->SetLineColor(1);
1700
1701
1702   return;
1703 }