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