02febdaee7f28bad441b56f4e1bc702b686357cc
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / Photon_Resolution.C
1 /***********************************************************************************************
2 *** provided by Gamma Conversion Group, PWG4,                                                                   ******
3 ***         Friederike Bock, fbock@physi.uni-heidelberg.de ***                                                  ******
4 ************************************************************************************************
5 ************************************************************************************************
6 *** With this Macro Resolution Studies for the Conversion Method can be carried out             ******
7 *** For this a run with the flag "resolution" of the Gamma Conversion Software needs    ******
8 *** to be performed, this study can only be carried out on Montecarlo Productions               ******
9 ************************************************************************************************/
10
11 #include <Riostream.h>
12 #include <TMath.h>
13 #include "PlottingGammaConversionHistos.h"
14 #include "PlottingGammaConversionAdditional.h"
15 extern TRandom *gRandom;
16 extern TBenchmark *gBenchmark;
17 extern TSystem *gSystem;
18
19 void  Photon_Resolution(const char *MCfile = "", const char *cutsel = "",const char *path = "", const char *output = "Photon-Resolution", const char *Plots = "kTRUE", const char *suffix = "eps"){     
20         
21         gROOT->Reset(); 
22         gROOT->SetStyle("Plain");
23         
24         StyleSettings();        
25         set_plot_style();
26
27         Bool_t SinglePlots = kFALSE;
28         if(Plots == "kTRUE") SinglePlots = kTRUE;
29
30
31 //**********************************************************************************************************************
32 //******************************** Definition of some plotting variables ***********************************************
33 //**********************************************************************************************************************
34
35         //Array defintion for printing Logo 
36         Float_t right_up[4]={0.7,0.63,0.15, 0.02};
37         Float_t right_up2D[4]={0.65,0.63,0.11, 0.02};
38         Float_t right_down[4]={0.7,0.23,0.15, 0.02};
39         Float_t left_up[4]={0.17,0.73, 0.15, 0.02};
40
41         //Defintion of Rebin
42         Float_t rebin = 4;      
43
44 //**********************************************************************************************************************
45 //******************************** Defintion of arrays for rebinning ***************************************************
46 //**********************************************************************************************************************
47
48         //pt rebinning array
49         Float_t ptcalcbinning1[5] =  {0.5 ,1 ,2 ,5,10};
50         Float_t ptcalcbinning2[4] = {14,40,100,200};
51         Float_t ptcalcbinning3[6] = {1,5,13,21,24,31};
52         Double_t ptbinning[31];
53         ptbinning[0] = 0;
54         for ( int j = 0; j < 5 ; j ++ ){
55                 for ( int i = ptcalcbinning3[j]; i<ptcalcbinning3[j+1]; i++){ 
56                 ptbinning[i] = ptbinning[i-1] +  ptcalcbinning1[j];
57                 }
58         }
59         
60         //R rebinning array
61         Float_t Rcalcbinning1[18] =  {5, 0.5, 2, 0.5, 4,0.5,1,0.5,3.5,0.5,4,0.5,5,0.5,4,1,11,15};
62         Float_t Rcalcbinning3[19] = {1,2,16,17,27,28,38,39,41,43,65,68,71,74,79,80,81,82,89};
63         Double_t Rbinning[89];
64         Rbinning[0] = 0;
65         for ( int j = 0; j < 18 ; j ++ ){
66                 for ( int i = Rcalcbinning3[j]; i<Rcalcbinning3[j+1]; i++){ 
67                 Rbinning[i] = Rbinning[i-1] +    Rcalcbinning1[j];
68                 }
69         }
70 //**********************************************************************************************************************
71 //******************************************* Defintion of file name ***************************************************
72 //**********************************************************************************************************************
73
74         Char_t filename_MC[100] = (Form("%s%s",path,MCfile));
75
76         if(cutsel != ""){
77                 char *GammaDirectory = Form("PWG4_GammaConversion_%s",  cutsel);
78                 cout << GammaDirectory << endl;
79                 char *GammaList = Form("histogramsAliGammaConversion_%s", cutsel);
80                 cout << GammaList << endl;
81         }else{
82                 char *GammaDirectory = "PWG4_GammaConversion";
83                 cout << GammaDirectory << endl;
84                 char *GammaList = "histogramsAliGammaConversion";
85                 cout << GammaList << endl;
86         }
87
88 //**********************************************************************************************************************
89 //****************************************** Loading of Histograms *****************************************************
90 //**********************************************************************************************************************
91
92         TFile f(filename_MC);  
93         
94         //************************** Container Loading ********************************************************************
95         TDirectory *fPWG4GammaConversion_montecarlo = new TDirectory(); 
96         TList *fHistosGammaConversion_montecarlo = new TList(); 
97         TList *fResolutionContainer_montecarlo = new TList();  
98      TList *fESDContainer_montecarlo = new TList();
99         if(!(fPWG4GammaConversion_montecarlo = (TDirectory*)f.Get(GammaDirectory))) cout <<"PWG4GammConversion TList NOT loaded correctly"<<endl; 
100         if(!(fHistosGammaConversion_montecarlo = (TList*)fPWG4GammaConversion_montecarlo->Get(GammaList))) cout<<"histogramsAliGammaConversion NOT loaded correctly!"<<endl; 
101         if(fResolutionContainer_montecarlo = (TList*)fHistosGammaConversion_montecarlo->FindObject("Resolution histograms")) cout<<"list loaded correctly!"<<endl; 
102         if(!(fESDContainer_montecarlo = (TList*)fHistosGammaConversion_montecarlo->FindObject("ESD histograms"))) cout<<"ESD histograms NOT loaded correctly!"<<endl; 
103         TH1F * ESD_ConvGamma_Pt=fESDContainer_montecarlo->FindObject("ESD_ConvGamma_Pt");
104         TH1F * ESD_E_Pt=fESDContainer_montecarlo->FindObject("ESD_E_Pt");
105         TH1F * ESD_P_Pt=fESDContainer_montecarlo->FindObject("ESD_P_Pt");
106
107         //************************** Histo loading *************************************************************************
108
109         //****************************** Resolution dPt vs Pt **********************************************
110         TH1F * Resolution_MC_Pt = fResolutionContainer_montecarlo->FindObject("Resolution_MC_Pt" ); //
111         TH1F * Resolution_ESD_Pt = fResolutionContainer_montecarlo->FindObject("Resolution_ESD_Pt" ); //
112         TH2F * Resolution_Gamma_dPt_Pt = fResolutionContainer_montecarlo->FindObject("Resolution_Gamma_dPt_Pt" ); //
113         TH2F * Resolution_E_dPt_Pt_ITS0 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS0" ); //
114         TH2F * Resolution_E_dPt_Pt_ITS1 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS1" ); //
115         TH2F * Resolution_E_dPt_Pt_ITS2 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS2" ); //
116         TH2F * Resolution_E_dPt_Pt_ITS3 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS3" ); //
117         TH2F * Resolution_E_dPt_Pt_ITS4 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS4" ); //
118         TH2F * Resolution_E_dPt_Pt_ITS5 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS5" ); //
119         TH2F * Resolution_E_dPt_Pt_ITS6 = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt_ITS6" ); //
120         TH2F * Resolution_E_dPt_Pt = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Pt" ); //
121         TH2F * Resolution_P_dPt_Pt_ITS0 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS0" ); //
122         TH2F * Resolution_P_dPt_Pt_ITS1 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS1" ); //
123         TH2F * Resolution_P_dPt_Pt_ITS2 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS2" ); //
124         TH2F * Resolution_P_dPt_Pt_ITS3 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS3" ); //
125         TH2F * Resolution_P_dPt_Pt_ITS4 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS4" ); //
126         TH2F * Resolution_P_dPt_Pt_ITS5 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS5" ); //
127         TH2F * Resolution_P_dPt_Pt_ITS6 = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt_ITS6" ); //
128         TH2F * Resolution_P_dPt_Pt = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Pt" ); //
129
130         //****************************** TRD performance ***************************************************
131         TH2F * Resolution_E_nTRDtracklets_ESDPt = fResolutionContainer_montecarlo->FindObject("Resolution_E_nTRDtracklets_ESDPt" );
132 //      TH2F * Resolution_E_nTRDtracklets_MCPt = fResolutionContainer_montecarlo->FindObject("Resolution_E_nTRDtracklets_MCPt" );
133         TH2F * Resolution_E_nTRDclusters_ESDPt = fResolutionContainer_montecarlo->FindObject("Resolution_E_nTRDclusters_ESDPt" );
134 //      TH2F * Resolution_E_nTRDclusters_MCPt = fResolutionContainer_montecarlo->FindObject("Resolution_E_nTRDclusters_MCPt" );
135         TH2F * Resolution_P_nTRDtracklets_ESDPt = fResolutionContainer_montecarlo->FindObject("Resolution_P_nTRDtracklets_ESDPt" );
136 //      TH2F * Resolution_P_nTRDtracklets_MCPt = fResolutionContainer_montecarlo->FindObject("Resolution_P_nTRDtracklets_MCPt" );
137         TH2F * Resolution_P_nTRDclusters_ESDPt = fResolutionContainer_montecarlo->FindObject("Resolution_P_nTRDclusters_ESDPt" );
138 //      TH2F * Resolution_P_nTRDclusters_MCPt = fResolutionContainer_montecarlo->FindObject("Resolution_P_nTRDclusters_MCPt" );
139
140         //******************************** Resolution in Absolute ********************************************
141         TH2F * Resolution_dZAbs_VS_R = fResolutionContainer_montecarlo->FindObject("Resolution_dZAbs_VS_R" ); //
142         TH2F * Resolution_dPhiAbs_VS_R = fResolutionContainer_montecarlo->FindObject("Resolution_dPhiAbs_VS_R" ); //
143         TH2F * Resolution_dRAbs_VS_R = fResolutionContainer_montecarlo->FindObject("Resolution_dRAbs_VS_R" ); //
144
145         // ******************************* Resolution in R ***************************************************
146         TH1F * Resolution_MC_R = fResolutionContainer_montecarlo->FindObject("Resolution_MC_R" ); //
147         TH1F * Resolution_ESD_R = fResolutionContainer_montecarlo->FindObject("Resolution_ESD_R" ); //
148 //      TH2F * Resolution_dR = fResolutionContainer_montecarlo->FindObject("Resolution_dR" );   
149         TH2F * Resolution_R_dPt = fResolutionContainer_montecarlo->FindObject("Resolution_R_dPt" );
150
151         //******************************** Resolution in Z ***************************************************
152         TH1F * Resolution_MC_Z = fResolutionContainer_montecarlo->FindObject("Resolution_MC_Z" ); //
153         TH1F * Resolution_ESD_Z = fResolutionContainer_montecarlo->FindObject("Resolution_ESD_Z" ); //
154 //      TH2F * Resolution_dZ = fResolutionContainer_montecarlo->FindObject("Resolution_dZ" ); 
155
156
157         //******************************** Resolution dPt vs Phi *********************************************
158         TH2F * Resolution_Gamma_dPt_Phi = fResolutionContainer_montecarlo->FindObject("Resolution_Gamma_dPt_Phi" );
159         TH2F * Resolution_E_dPt_Phi = fResolutionContainer_montecarlo->FindObject("Resolution_E_dPt_Phi" );
160         TH2F * Resolution_P_dPt_Phi = fResolutionContainer_montecarlo->FindObject("Resolution_P_dPt_Phi" ); 
161
162 //**********************************************************************************************************************************************
163 //*********************************** Rebinning of 2D histograms and fitslices *****************************************************************
164 //**********************************************************************************************************************************************
165         
166                 //********************************* Rebinning Gamma dPt Pt *****************************************************************
167                 TH2F *Resolution_Gamma_dPt_Ptrebin = new TH2F("Resolution_Gamma_dPt_Ptrebin", "Photon Resolution dPt vs Pt ", 30, ptbinning , 100, -10., 10.) ; 
168                 Resolution_Gamma_dPt_Pt->Sumw2();
169                 Int_t maxYbin = Resolution_Gamma_dPt_Pt->GetNbinsY();
170                 for (Int_t i = 1; i <201; i++) {
171                                 TAxis *xaxis_old =      Resolution_Gamma_dPt_Pt->GetXaxis()     ;               
172                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
173                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
174                                         Double_t biny = Resolution_Gamma_dPt_Pt->GetYaxis()->GetBinCenter(j);                                                           
175                                         Double_t value =  Resolution_Gamma_dPt_Pt->GetBinContent(i, j);
176                                         Resolution_Gamma_dPt_Ptrebin->Fill(binoldpoint, biny, value);
177                                 }
178                 }
179
180                 //********************************* Rebinning of E dPt Pt all **************************************************************
181                 TH2F *Resolution_E_dPt_Ptrebin = new TH2F("Resolution_E_dPt_Ptrebin", "Electron Resolution dPt vs Pt ", 30, ptbinning , 100, -10., 10.) ;       
182                 Resolution_E_dPt_Pt->Sumw2();
183                 Int_t maxYbin = Resolution_E_dPt_Pt->GetNbinsY();
184                 for (Int_t i = 1; i <201; i++) {
185                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt->GetXaxis() ;               
186                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
187                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
188                                         Double_t biny = Resolution_E_dPt_Pt->GetYaxis()->GetBinCenter(j);                                                               
189                                         Double_t value =  Resolution_E_dPt_Pt->GetBinContent(i, j);
190                                         Resolution_E_dPt_Ptrebin->Fill(binoldpoint, biny, value);
191                                 }
192                 }
193                 
194                 //**********************************Rebinning of E dPt Pt for different Nr of ITS clusters *********************************
195                 TH2F *Resolution_E_dPt_Pt_ITS0rebin = new TH2F("Resolution_E_dPt_Pt_ITS0rebin", "Electron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
196                 Resolution_E_dPt_Pt_ITS0->Sumw2();
197                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS0->GetNbinsY();
198                 for (Int_t i = 1; i <201; i++) {
199                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS0->GetXaxis()    ;               
200                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
201                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
202                                         Double_t biny = Resolution_E_dPt_Pt_ITS0->GetYaxis()->GetBinCenter(j);                                                          
203                                         Double_t value =  Resolution_E_dPt_Pt_ITS0->GetBinContent(i, j);
204                                         Resolution_E_dPt_Pt_ITS0rebin->Fill(binoldpoint, biny, value);
205                                 }
206                 }
207
208                 TH2F *Resolution_E_dPt_Pt_ITS1rebin = new TH2F("Resolution_E_dPt_Pt_ITS1rebin", "Electron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
209                 Resolution_E_dPt_Pt_ITS1->Sumw2();
210                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS1->GetNbinsY();
211                 for (Int_t i = 1; i <201; i++) {
212                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS1->GetXaxis()    ;               
213                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
214                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
215                                         Double_t biny = Resolution_E_dPt_Pt_ITS1->GetYaxis()->GetBinCenter(j);                                                          
216                                         Double_t value =  Resolution_E_dPt_Pt_ITS1->GetBinContent(i, j);
217                                         Resolution_E_dPt_Pt_ITS1rebin->Fill(binoldpoint, biny, value);
218                                 }
219                 }
220
221                 TH2F *Resolution_E_dPt_Pt_ITS2rebin = new TH2F("Resolution_E_dPt_Pt_ITS2rebin", "Electron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
222                 Resolution_E_dPt_Pt_ITS2->Sumw2();
223                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS2->GetNbinsY();
224                 for (Int_t i = 1; i <201; i++) {
225                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS2->GetXaxis()    ;               
226                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
227                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
228                                         Double_t biny = Resolution_E_dPt_Pt_ITS2->GetYaxis()->GetBinCenter(j);                                                          
229                                         Double_t value =  Resolution_E_dPt_Pt_ITS2->GetBinContent(i, j);
230                                         Resolution_E_dPt_Pt_ITS2rebin->Fill(binoldpoint, biny, value);
231                                 }
232                 }
233
234                 TH2F *Resolution_E_dPt_Pt_ITS3rebin = new TH2F("Resolution_E_dPt_Pt_ITS3rebin", "Electron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
235                 Resolution_E_dPt_Pt_ITS3->Sumw2();
236                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS3->GetNbinsY();
237                 for (Int_t i = 1; i <201; i++) {
238                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS3->GetXaxis()    ;               
239                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
240                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
241                                         Double_t biny = Resolution_E_dPt_Pt_ITS3->GetYaxis()->GetBinCenter(j);                                                          
242                                         Double_t value =  Resolution_E_dPt_Pt_ITS3->GetBinContent(i, j);
243                                         Resolution_E_dPt_Pt_ITS3rebin->Fill(binoldpoint, biny, value);
244                                 }
245                 }
246
247                 TH2F *Resolution_E_dPt_Pt_ITS4rebin = new TH2F("Resolution_E_dPt_Pt_ITS4rebin", "Electron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
248                 Resolution_E_dPt_Pt_ITS4->Sumw2();
249                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS4->GetNbinsY();
250                 for (Int_t i = 1; i <201; i++) {
251                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS4->GetXaxis()    ;               
252                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
253                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
254                                         Double_t biny = Resolution_E_dPt_Pt_ITS4->GetYaxis()->GetBinCenter(j);                                                          
255                                         Double_t value =  Resolution_E_dPt_Pt_ITS4->GetBinContent(i, j);
256                                         Resolution_E_dPt_Pt_ITS4rebin->Fill(binoldpoint, biny, value);
257                                 }
258                 }
259
260                 TH2F *Resolution_E_dPt_Pt_ITS5rebin = new TH2F("Resolution_E_dPt_Pt_ITS5rebin", "Electron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
261                 Resolution_E_dPt_Pt_ITS5->Sumw2();
262                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS5->GetNbinsY();
263                 for (Int_t i = 1; i <201; i++) {
264                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS5->GetXaxis()    ;               
265                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
266                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
267                                         Double_t biny = Resolution_E_dPt_Pt_ITS5->GetYaxis()->GetBinCenter(j);                                                          
268                                         Double_t value =  Resolution_E_dPt_Pt_ITS5->GetBinContent(i, j);
269                                         Resolution_E_dPt_Pt_ITS5rebin->Fill(binoldpoint, biny, value);
270                                 }
271                 }
272
273                 TH2F *Resolution_E_dPt_Pt_ITS6rebin = new TH2F("Resolution_E_dPt_Pt_ITS6rebin", "Electron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
274                 Resolution_E_dPt_Pt_ITS6->Sumw2();
275                 Int_t maxYbin = Resolution_E_dPt_Pt_ITS6->GetNbinsY();
276                 for (Int_t i = 1; i <201; i++) {
277                                 TAxis *xaxis_old =      Resolution_E_dPt_Pt_ITS6->GetXaxis()    ;               
278                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
279                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
280                                         Double_t biny = Resolution_E_dPt_Pt_ITS6->GetYaxis()->GetBinCenter(j);                                                          
281                                         Double_t value =  Resolution_E_dPt_Pt_ITS6->GetBinContent(i, j);
282                                         Resolution_E_dPt_Pt_ITS6rebin->Fill(binoldpoint, biny, value);
283                                 }
284                 }
285
286                 TH2F *Resolution_P_dPt_Ptrebin = new TH2F("Resolution_P_dPt_Ptrebin", "Positron Resolution dPt vs Pt ", 30, ptbinning , 100, -10., 10.) ;       
287                 Resolution_P_dPt_Pt->Sumw2();
288                 Int_t maxYbin = Resolution_P_dPt_Pt->GetNbinsY();
289                 for (Int_t i = 1; i <201; i++) {
290                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt->GetXaxis() ;               
291                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
292                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
293                                         Double_t biny = Resolution_P_dPt_Pt->GetYaxis()->GetBinCenter(j);                                                               
294                                         Double_t value =  Resolution_P_dPt_Pt->GetBinContent(i, j);
295                                         Resolution_P_dPt_Ptrebin->Fill(binoldpoint, biny, value);
296                                 }
297                 }
298
299                 //**********************************Rebinning of P dPt Pt for different Nr of ITS clusters *********************************
300                 TH2F *Resolution_P_dPt_Pt_ITS0rebin = new TH2F("Resolution_P_dPt_Pt_ITS0rebin", "Positron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
301                 Resolution_P_dPt_Pt_ITS0->Sumw2();
302                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS0->GetNbinsY();
303                 for (Int_t i = 1; i <201; i++) {
304                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS0->GetXaxis()    ;               
305                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
306                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
307                                         Double_t biny = Resolution_P_dPt_Pt_ITS0->GetYaxis()->GetBinCenter(j);                                                          
308                                         Double_t value =  Resolution_P_dPt_Pt_ITS0->GetBinContent(i, j);
309                                         Resolution_P_dPt_Pt_ITS0rebin->Fill(binoldpoint, biny, value);
310                                 }
311                 }
312
313                 TH2F *Resolution_P_dPt_Pt_ITS1rebin = new TH2F("Resolution_P_dPt_Pt_ITS1rebin", "Positron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
314                 Resolution_P_dPt_Pt_ITS1->Sumw2();
315                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS1->GetNbinsY();
316                 for (Int_t i = 1; i <201; i++) {
317                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS1->GetXaxis()    ;               
318                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
319                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
320                                         Double_t biny = Resolution_P_dPt_Pt_ITS1->GetYaxis()->GetBinCenter(j);                                                          
321                                         Double_t value =  Resolution_P_dPt_Pt_ITS1->GetBinContent(i, j);
322                                         Resolution_P_dPt_Pt_ITS1rebin->Fill(binoldpoint, biny, value);
323                                 }
324                 }
325
326                 TH2F *Resolution_P_dPt_Pt_ITS2rebin = new TH2F("Resolution_P_dPt_Pt_ITS2rebin", "Positron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
327                 Resolution_P_dPt_Pt_ITS2->Sumw2();
328                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS2->GetNbinsY();
329                 for (Int_t i = 1; i <201; i++) {
330                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS2->GetXaxis()    ;               
331                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
332                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
333                                         Double_t biny = Resolution_P_dPt_Pt_ITS2->GetYaxis()->GetBinCenter(j);                                                          
334                                         Double_t value =  Resolution_P_dPt_Pt_ITS2->GetBinContent(i, j);
335                                         Resolution_P_dPt_Pt_ITS2rebin->Fill(binoldpoint, biny, value);
336                                 }
337                 }
338
339                 TH2F *Resolution_P_dPt_Pt_ITS3rebin = new TH2F("Resolution_P_dPt_Pt_ITS3rebin", "Positron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
340                 Resolution_P_dPt_Pt_ITS3->Sumw2();
341                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS3->GetNbinsY();
342                 for (Int_t i = 1; i <201; i++) {
343                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS3->GetXaxis()    ;               
344                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
345                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
346                                         Double_t biny = Resolution_P_dPt_Pt_ITS3->GetYaxis()->GetBinCenter(j);                                                          
347                                         Double_t value =  Resolution_P_dPt_Pt_ITS3->GetBinContent(i, j);
348                                         Resolution_P_dPt_Pt_ITS3rebin->Fill(binoldpoint, biny, value);
349                                 }
350                 }
351
352                 TH2F *Resolution_P_dPt_Pt_ITS4rebin = new TH2F("Resolution_P_dPt_Pt_ITS4rebin", "Positron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
353                 Resolution_P_dPt_Pt_ITS4->Sumw2();
354                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS4->GetNbinsY();
355                 for (Int_t i = 1; i <201; i++) {
356                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS4->GetXaxis()    ;               
357                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
358                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
359                                         Double_t biny = Resolution_P_dPt_Pt_ITS4->GetYaxis()->GetBinCenter(j);                                                          
360                                         Double_t value =  Resolution_P_dPt_Pt_ITS4->GetBinContent(i, j);
361                                         Resolution_P_dPt_Pt_ITS4rebin->Fill(binoldpoint, biny, value);
362                                 }
363                 }
364
365                 TH2F *Resolution_P_dPt_Pt_ITS5rebin = new TH2F("Resolution_P_dPt_Pt_ITS5rebin", "Positron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
366                 Resolution_P_dPt_Pt_ITS5->Sumw2();
367                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS5->GetNbinsY();
368                 for (Int_t i = 1; i <201; i++) {
369                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS5->GetXaxis()    ;               
370                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
371                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
372                                         Double_t biny = Resolution_P_dPt_Pt_ITS5->GetYaxis()->GetBinCenter(j);                                                          
373                                         Double_t value =  Resolution_P_dPt_Pt_ITS5->GetBinContent(i, j);
374                                         Resolution_P_dPt_Pt_ITS5rebin->Fill(binoldpoint, biny, value);
375                                 }
376                 }
377
378                 TH2F *Resolution_P_dPt_Pt_ITS6rebin = new TH2F("Resolution_P_dPt_Pt_ITS6rebin", "Positron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning , 100, -10., 10.) ;       
379                 Resolution_P_dPt_Pt_ITS6->Sumw2();
380                 Int_t maxYbin = Resolution_P_dPt_Pt_ITS6->GetNbinsY();
381                 for (Int_t i = 1; i <201; i++) {
382                                 TAxis *xaxis_old =      Resolution_P_dPt_Pt_ITS6->GetXaxis()    ;               
383                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
384                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
385                                         Double_t biny = Resolution_P_dPt_Pt_ITS6->GetYaxis()->GetBinCenter(j);                                                          
386                                         Double_t value =  Resolution_P_dPt_Pt_ITS6->GetBinContent(i, j);
387                                         Resolution_P_dPt_Pt_ITS6rebin->Fill(binoldpoint, biny, value);
388                                 }
389                 }
390
391                 //************************************** Rebinning of dZAbs R **********************************************
392                 TH2F *Resolution_dZAbs_VS_Rrebin = new TH2F("Resolution_dZAbs_VS_Rrebin", "Photon Resolution dZabs vs R ", 88, Rbinning , 50, -25., 25.) ;      
393                 Resolution_dZAbs_VS_R->Sumw2();
394                 Int_t maxXbin = Resolution_dZAbs_VS_R->GetNbinsX();             
395                 Int_t maxYbin = Resolution_dZAbs_VS_R->GetNbinsY();
396                 for (Int_t i = 1; i <(maxXbin+1); i++) {
397                                 TAxis *xaxis_old =      Resolution_dZAbs_VS_R->GetXaxis()       ;               
398                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
399                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
400                                         Double_t biny = Resolution_dZAbs_VS_R->GetYaxis()->GetBinCenter(j);                                                             
401                                         Double_t value =  Resolution_dZAbs_VS_R->GetBinContent(i, j);
402                                         Resolution_dZAbs_VS_Rrebin->Fill(binoldpoint, biny, value);
403                                 }
404                 }
405
406                 //************************************** Rebinning of dPhiAbs R **********************************************
407                 TH2F *Resolution_dPhiAbs_VS_Rrebin = new TH2F("Resolution_dPhiAbs_VS_Rrebin", "Photon Resolution dPhiabs vs R ", 88, Rbinning , 100, -TMath::Pi()/30, TMath::Pi()/30) ; 
408                 Resolution_dPhiAbs_VS_R->Sumw2();
409                 Int_t maxXbin = Resolution_dPhiAbs_VS_R->GetNbinsX();           
410                 Int_t maxYbin = Resolution_dPhiAbs_VS_R->GetNbinsY();
411                 for (Int_t i = 1; i <(maxXbin+1); i++) {
412                                 TAxis *xaxis_old =      Resolution_dPhiAbs_VS_R->GetXaxis()     ;               
413                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
414                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
415                                         Double_t biny = Resolution_dPhiAbs_VS_R->GetYaxis()->GetBinCenter(j);                                                           
416                                         Double_t value =  Resolution_dPhiAbs_VS_R->GetBinContent(i, j);
417                                         Resolution_dPhiAbs_VS_Rrebin->Fill(binoldpoint, biny, value);
418                                 }
419                 }
420
421                 //************************************** Rebinning of dRAbs R **********************************************
422                 TH2F *Resolution_dRAbs_VS_Rrebin = new TH2F("Resolution_dRAbs_VS_Rrebin", "Photon Resolution dRabs vs R ", 88, Rbinning , 50, -25,25) ; 
423                 Resolution_dRAbs_VS_R->Sumw2();
424                 Int_t maxXbin = Resolution_dRAbs_VS_R->GetNbinsX();             
425                 Int_t maxYbin = Resolution_dRAbs_VS_R->GetNbinsY();
426                 for (Int_t i = 1; i <(maxXbin+1); i++) {
427                                 TAxis *xaxis_old =      Resolution_dRAbs_VS_R->GetXaxis()       ;               
428                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
429                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
430                                         Double_t biny = Resolution_dRAbs_VS_R->GetYaxis()->GetBinCenter(j);                                                             
431                                         Double_t value =  Resolution_dRAbs_VS_R->GetBinContent(i, j);
432                                         Resolution_dRAbs_VS_Rrebin->Fill(binoldpoint, biny, value);
433                                 }
434                 }
435
436                 //************************************** Rebinning of dRAbs R **********************************************
437                 TH2F *Resolution_R_dPtrebin = new TH2F("Resolution_R_dPtrebin", "Photon Resolution dp_{t} vs R ", 88, Rbinning , 50, -10,10) ;  
438                 Resolution_R_dPt->Sumw2();
439                 Int_t maxXbin = Resolution_R_dPt->GetNbinsX();          
440                 Int_t maxYbin = Resolution_R_dPt->GetNbinsY();
441                 for (Int_t i = 1; i <(maxXbin+1); i++) {
442                                 TAxis *xaxis_old =      Resolution_R_dPt->GetXaxis()    ;               
443                                 Double_t binoldpoint = xaxis_old->GetBinCenter(i);                                                      
444                                 for (Int_t j = 1 ; j < (maxYbin+1) ; j++){              
445                                         Double_t biny = Resolution_R_dPt->GetYaxis()->GetBinCenter(j);                                                          
446                                         Double_t value =  Resolution_R_dPt->GetBinContent(i, j);
447                                         Resolution_R_dPtrebin->Fill(binoldpoint, biny, value);
448                                 }
449                 }
450
451
452
453
454         //**************************** Writing all rebined histos in a file ********************************************
455         Resolution = new TFile("ResolutionGamma.root","RECREATE");
456                 Resolution_Gamma_dPt_Ptrebin->Write();
457                 Resolution_E_dPt_Ptrebin->Write();
458                 Resolution_E_dPt_Pt_ITS0rebin->Write();
459                 Resolution_E_dPt_Pt_ITS1rebin->Write();
460                 Resolution_E_dPt_Pt_ITS2rebin->Write();
461                 Resolution_E_dPt_Pt_ITS3rebin->Write();
462                 Resolution_E_dPt_Pt_ITS4rebin->Write();
463                 Resolution_E_dPt_Pt_ITS5rebin->Write();
464                 Resolution_E_dPt_Pt_ITS6rebin->Write();
465                 Resolution_P_dPt_Ptrebin->Write();
466                 Resolution_P_dPt_Pt_ITS0rebin->Write();
467                 Resolution_P_dPt_Pt_ITS1rebin->Write();
468                 Resolution_P_dPt_Pt_ITS2rebin->Write();
469                 Resolution_P_dPt_Pt_ITS3rebin->Write();
470                 Resolution_P_dPt_Pt_ITS4rebin->Write();
471                 Resolution_P_dPt_Pt_ITS5rebin->Write();
472                 Resolution_P_dPt_Pt_ITS6rebin->Write();
473                 Resolution_dZAbs_VS_Rrebin->Write();
474                 Resolution_dRAbs_VS_Rrebin->Write();
475                 Resolution_dPhiAbs_VS_Rrebin->Write();
476                 Resolution_R_dPtrebin->Write();
477         Resolution->Write();
478         Resolution->Close();
479
480                 Double_t precision = 10E-5;
481
482 //*********************************** Fitting for dRabs vs R **********************************************
483                 TH1F *Resolution_dRAbs_VS_Rrebin_1 = new TH1F("Resolution_dRAbs_VS_Rrebin_1", "Mean Photon Resolution dRabs vs R ", 88, Rbinning ) ;    
484                 TH1F *Resolution_dRAbs_VS_Rrebin_2 = new TH1F("Resolution_dRAbs_VS_Rrebin_2", "Sigma Photon Resolution dRabs vs R ", 88, Rbinning ) ;
485                 for (Int_t i = 1; i < 88 + 1 ; i ++){
486                         TF1 *f0 = new TF1("f0", "gaus", -25,25);
487                         TH1D *hy = Resolution_dRAbs_VS_Rrebin->ProjectionY("hy", i, i);
488                         hy->Fit(f0,"0RME");
489                         Double_t rp = f0->GetParameter(2);
490                         Double_t mp = f0->GetParameter(1);
491                         Double_t ymin = mp -(rp * 2);
492                         Double_t ymax = mp + (rp * 2);
493                         Double_t deviation = 100;
494                         Int_t counter = 0;
495                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
496                         while(deviation > precision && counter < 100){
497                                 f1->SetRange(ymin,ymax);
498                                 hy->Fit(f1,"0RME");
499                                 Double_t rp2 = f1->GetParameter(2);
500                                 if (rp2>rp){ deviation = rp2-rp;} 
501                                         else {deviation = rp -rp2 ;}
502                                 rp = rp2 ;
503                                 mp = f1->GetParameter(1);
504                                 ymin = mp -(rp * 2);
505                                 ymax = mp + (rp * 2);
506                                 counter++;
507                         }
508                         Double_t mean = f1->GetParameter(1);
509                         Double_t meanE = f1->GetParError(1);
510                         Double_t sigma = f1->GetParameter(2);
511                         Double_t sigmaE = f1->GetParError(2);
512                         
513                         Resolution_dRAbs_VS_Rrebin_1->SetBinContent(i, mean);
514                         Resolution_dRAbs_VS_Rrebin_1->SetBinError(i, meanE);
515                         Resolution_dRAbs_VS_Rrebin_2->SetBinContent(i, sigma);
516                         Resolution_dRAbs_VS_Rrebin_2->SetBinError(i, sigmaE);
517                         delete f1;
518                         delete f0;
519                 } //end of fitting 
520
521 //********************************************* fitting for dZAbs vs R *************************************************************
522                 TH1F *Resolution_dZAbs_VS_Rrebin_1 = new TH1F("Resolution_dZAbs_VS_Rrebin_1", "Mean Photon Resolution dZabs vs R ", 88, Rbinning ) ;    
523                 TH1F *Resolution_dZAbs_VS_Rrebin_2 = new TH1F("Resolution_dZAbs_VS_Rrebin_2", "Sigma Photon Resolution dZabs vs R ", 88, Rbinning ) ;
524                 for (Int_t i = 1; i < 88 + 1 ; i ++){
525                         TF1 *f0 = new TF1("f0", "gaus", -25,25);
526                         TH1D *hx = Resolution_dZAbs_VS_Rrebin->ProjectionY("hx", i, i);
527                         hx->Fit(f0,"0RME");
528                         Double_t rp = f0->GetParameter(2);
529                         Double_t mp = f0->GetParameter(1);
530                         Double_t ymin = mp -(rp * 2);
531                         Double_t ymax = mp +(rp * 2);
532                         Double_t deviation = 100;
533                         Int_t counter = 0;
534                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
535                         while(deviation > precision && counter < 100){
536                                 f1->SetRange(ymin,ymax);
537                                 hx->Fit(f1,"0RME");
538                                 Double_t rp2 = f1->GetParameter(2);
539                                 if (rp2>rp){ deviation = rp2-rp;} 
540                                         else {deviation = rp -rp2 ;}
541                                 rp = rp2 ;
542                                 mp = f1->GetParameter(1);
543                                 ymin = mp -(rp * 2);
544                                 ymax = mp +(rp * 2);
545                                 counter++;
546                         }
547                         Double_t mean = f1->GetParameter(1);
548                         Double_t meanE = f1->GetParError(1);
549                         Double_t sigma = f1->GetParameter(2);
550                         Double_t sigmaE = f1->GetParError(2);
551                         
552                         Resolution_dZAbs_VS_Rrebin_1->SetBinContent(i, mean);
553                         Resolution_dZAbs_VS_Rrebin_1->SetBinError(i, meanE);
554                         Resolution_dZAbs_VS_Rrebin_2->SetBinContent(i, sigma);
555                         Resolution_dZAbs_VS_Rrebin_2->SetBinError(i, sigmaE);
556                         delete f1;
557                         delete f0;
558                 } //end of fitting 
559
560 //********************************************* fitting for dPt vs R *************************************************************
561                 TH1F *Resolution_R_dPtrebin_1 = new TH1F("Resolution_R_dPtrebin_1", "Mean Photon Resolution dPt vs R ", 88, Rbinning ) ;        
562                 TH1F *Resolution_R_dPtrebin_2 = new TH1F("Resolution_R_dPtrebin_2", "Sigma Photon Resolution dPt vs R ", 88, Rbinning ) ;
563                 for (Int_t i = 1; i < 88 + 1 ; i ++){
564                         TF1 *f0 = new TF1("f0", "gaus", -25,25);
565                         TH1D *hu = Resolution_R_dPtrebin->ProjectionY("hu", i, i);
566                         hu->Fit(f0,"0RME");
567                         Double_t rp = f0->GetParameter(2);
568                         Double_t mp = f0->GetParameter(1);
569                         Double_t ymin = mp -(rp * 2);
570                         Double_t ymax = mp +(rp * 2);
571                         Double_t deviation = 100;
572                         Int_t counter = 0;
573                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
574                         while(deviation > precision && counter < 100){
575                                 f1->SetRange(ymin,ymax);
576                                 hu->Fit(f1,"0RME");
577                                 Double_t rp2 = f1->GetParameter(2);
578                                 if (rp2>rp){ deviation = rp2-rp;} 
579                                         else {deviation = rp -rp2 ;}
580                                 rp = rp2 ;
581                                 mp = f1->GetParameter(1);
582                                 ymin = mp -(rp * 2);
583                                 ymax = mp +(rp * 2);
584                                 counter++;
585                         }
586                         Double_t mean = f1->GetParameter(1);
587                         Double_t meanE = f1->GetParError(1);
588                         Double_t sigma = f1->GetParameter(2);
589                         Double_t sigmaE = f1->GetParError(2);
590                         
591                         Resolution_R_dPtrebin_1->SetBinContent(i, mean);
592                         Resolution_R_dPtrebin_1->SetBinError(i, meanE);
593                         Resolution_R_dPtrebin_2->SetBinContent(i, sigma);
594                         Resolution_R_dPtrebin_2->SetBinError(i, sigmaE);
595                         delete f1;
596                         delete f0;
597                 } //end of fitting 
598
599
600                 Double_t precisionPhi = 10E-10;
601 //********************************************* fitting for dPhiAbs vs R *************************************************************
602                 TH1F *Resolution_dPhiAbs_VS_Rrebin_1 = new TH1F("Resolution_dPhiAbs_VS_Rrebin_1", "Mean Photon Resolution dPhiabs vs R ", 88, Rbinning ) ;      
603                 TH1F *Resolution_dPhiAbs_VS_Rrebin_2 = new TH1F("Resolution_dPhiAbs_VS_Rrebin_2", "Sigma Photon Resolution dPhiabs vs R ", 88, Rbinning ) ;
604                 for (Int_t i = 1; i < 88 + 1 ; i ++){
605                         TF1 *f0 = new TF1("f0", "gaus", -0.5,0.5);
606                         TH1D *hp = Resolution_dPhiAbs_VS_Rrebin->ProjectionY("hp", i, i);
607                         hp->Fit(f0,"0RME");
608                         Double_t rp = f0->GetParameter(2);
609                         Double_t mp = f0->GetParameter(1);
610                         Double_t ymin = mp -(rp * 2);
611                         Double_t ymax = mp +(rp * 2);
612                         Double_t deviation = 100;
613                         Int_t counter = 0;
614                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
615                         while(deviation > precisionPhi && counter < 100){
616                                 f1->SetRange(ymin,ymax);
617                                 hp->Fit(f1,"0RME");
618                                 Double_t rp2 = f1->GetParameter(2);
619                                 if (rp2>rp){ deviation = rp2-rp;} 
620                                         else {deviation = rp -rp2 ;}
621                                 rp = rp2 ;
622                                 mp = f1->GetParameter(1);
623                                 ymin = mp -(rp * 2);
624                                 ymax = mp +(rp * 2);
625                                 counter++;
626                         }
627                         Double_t mean = f1->GetParameter(1);
628                         Double_t meanE = f1->GetParError(1);
629                         Double_t sigma = f1->GetParameter(2);
630                         Double_t sigmaE = f1->GetParError(2);
631                         
632                         Resolution_dPhiAbs_VS_Rrebin_1->SetBinContent(i, mean);
633                         Resolution_dPhiAbs_VS_Rrebin_1->SetBinError(i, meanE);
634                         Resolution_dPhiAbs_VS_Rrebin_2->SetBinContent(i, sigma);
635                         Resolution_dPhiAbs_VS_Rrebin_2->SetBinError(i, sigmaE);
636                         delete f1;
637                         delete f0;
638                 } //end of fitting 
639
640 //************************************************* dPt fitting for ITS bins Positron ************************************************************
641                 TH1F *Resolution_P_dPt_Pt_ITS0rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS0rebin_1", "mean Positron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning) ;       
642                 TH1F *Resolution_P_dPt_Pt_ITS0rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS0rebin_2", "sigma Positron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning) ;      
643                 for (Int_t i = 1; i < 30 + 1 ; i ++){
644                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
645                         TH1D *PITS0 = Resolution_P_dPt_Pt_ITS0rebin->ProjectionY("PITS0", i, i);
646                         PITS0->Fit(f0,"0RME");
647                         Double_t rp = f0->GetParameter(2);
648                         Double_t mp = f0->GetParameter(1);
649                         Double_t ymin = mp -(rp * 2.);
650                         Double_t ymax = mp + (rp * 2.);
651                         Double_t deviation = 100;
652                         Int_t counter = 0;
653                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
654                         while(deviation > precision && counter < 100){
655                                 f1->SetRange(ymin,ymax);
656                                 PITS0->Fit(f1,"0RME");
657                                 Double_t rp2 = f1->GetParameter(2);
658                                 if (rp2>rp){ deviation = rp2-rp;} 
659                                         else {deviation = rp -rp2 ;}
660                                 rp = rp2 ;
661                                 mp = f1->GetParameter(1);
662                                 ymin = mp -(rp * 2);
663                                 ymax = mp +(rp * 2);
664                                 counter++;
665                         }
666                         Double_t mean = f1->GetParameter(1);
667                         Double_t meanE = f1->GetParError(1);
668                         Double_t sigma = f1->GetParameter(2);
669                         Double_t sigmaE = f1->GetParError(2);
670                         
671                         Resolution_P_dPt_Pt_ITS0rebin_1->SetBinContent(i, mean);
672                         Resolution_P_dPt_Pt_ITS0rebin_1->SetBinError(i, meanE);
673                         Resolution_P_dPt_Pt_ITS0rebin_2->SetBinContent(i, sigma);
674                         Resolution_P_dPt_Pt_ITS0rebin_2->SetBinError(i, sigmaE);
675                         delete f1;
676                         delete f0;
677                 } //end of fitting 
678
679                 TH1F *Resolution_P_dPt_Pt_ITS1rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS1rebin_1", "mean Positron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning) ;       
680                 TH1F *Resolution_P_dPt_Pt_ITS1rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS1rebin_2", "sigma Positron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning) ;      
681                 for (Int_t i = 1; i < 30 + 1 ; i ++){
682                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
683                         TH1D *PITS1 = Resolution_P_dPt_Pt_ITS1rebin->ProjectionY("PITS1", i, i);
684                         PITS1->Fit(f0,"0RME");
685                         Double_t rp = f0->GetParameter(2);
686                         Double_t mp = f0->GetParameter(1);
687                         Double_t ymin = mp -(rp * 2.);
688                         Double_t ymax = mp + (rp * 2.);
689                         Double_t deviation = 100;
690                         Int_t counter = 0;
691                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
692                         while(deviation > precision && counter < 100){
693                                 f1->SetRange(ymin,ymax);
694                                 PITS1->Fit(f1,"0RME");
695                                 Double_t rp2 = f1->GetParameter(2);
696                                 if (rp2>rp){ deviation = rp2-rp;} 
697                                         else {deviation = rp -rp2 ;}
698                                 rp = rp2 ;
699                                 mp = f1->GetParameter(1);
700                                 ymin = mp -(rp * 2);
701                                 ymax = mp +(rp * 2);
702                                 counter++;
703                         }
704                         Double_t mean = f1->GetParameter(1);
705                         Double_t meanE = f1->GetParError(1);
706                         Double_t sigma = f1->GetParameter(2);
707                         Double_t sigmaE = f1->GetParError(2);
708                         
709                         Resolution_P_dPt_Pt_ITS1rebin_1->SetBinContent(i, mean);
710                         Resolution_P_dPt_Pt_ITS1rebin_1->SetBinError(i, meanE);
711                         Resolution_P_dPt_Pt_ITS1rebin_2->SetBinContent(i, sigma);
712                         Resolution_P_dPt_Pt_ITS1rebin_2->SetBinError(i, sigmaE);
713                         delete f1;
714                         delete f0;
715                 } //end of fitting 
716
717                 TH1F *Resolution_P_dPt_Pt_ITS2rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS2rebin_1", "mean Positron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning) ;       
718                 TH1F *Resolution_P_dPt_Pt_ITS2rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS2rebin_2", "sigma Positron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning) ;      
719                 for (Int_t i = 1; i < 30 + 1 ; i ++){
720                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
721                         TH1D *PITS2 = Resolution_P_dPt_Pt_ITS2rebin->ProjectionY("PITS2", i, i);
722                         PITS2->Fit(f0,"0RME");
723                         Double_t rp = f0->GetParameter(2);
724                         Double_t mp = f0->GetParameter(1);
725                         Double_t ymin = mp -(rp * 2.);
726                         Double_t ymax = mp + (rp * 2.);
727                         Double_t deviation = 100;
728                         Int_t counter = 0;
729                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
730                         while(deviation > precision && counter < 100){
731                                 f1->SetRange(ymin,ymax);
732                                 PITS2->Fit(f1,"0RME");
733                                 Double_t rp2 = f1->GetParameter(2);
734                                 if (rp2>rp){ deviation = rp2-rp;} 
735                                         else {deviation = rp -rp2 ;}
736                                 rp = rp2 ;
737                                 mp = f1->GetParameter(1);
738                                 ymin = mp -(rp * 2);
739                                 ymax = mp +(rp * 2);
740                                 counter++;
741                         }
742                         Double_t mean = f1->GetParameter(1);
743                         Double_t meanE = f1->GetParError(1);
744                         Double_t sigma = f1->GetParameter(2);
745                         Double_t sigmaE = f1->GetParError(2);
746                         
747                         Resolution_P_dPt_Pt_ITS2rebin_1->SetBinContent(i, mean);
748                         Resolution_P_dPt_Pt_ITS2rebin_1->SetBinError(i, meanE);
749                         Resolution_P_dPt_Pt_ITS2rebin_2->SetBinContent(i, sigma);
750                         Resolution_P_dPt_Pt_ITS2rebin_2->SetBinError(i, sigmaE);
751                         delete f1;
752                         delete f0;
753                 } //end of fitting 
754
755                 TH1F *Resolution_P_dPt_Pt_ITS3rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS3rebin_1", "mean Positron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning) ;       
756                 TH1F *Resolution_P_dPt_Pt_ITS3rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS3rebin_2", "sigma Positron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning) ;      
757                 for (Int_t i = 1; i < 30 + 1 ; i ++){
758                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
759                         TH1D *PITS3 = Resolution_P_dPt_Pt_ITS3rebin->ProjectionY("PITS3", i, i);
760                         PITS3->Fit(f0,"0RME");
761                         Double_t rp = f0->GetParameter(2);
762                         Double_t mp = f0->GetParameter(1);
763                         Double_t ymin = mp -(rp * 2.);
764                         Double_t ymax = mp + (rp * 2.);
765                         Double_t deviation = 100;
766                         Int_t counter = 0;
767                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
768                         while(deviation > precision && counter < 100){
769                                 f1->SetRange(ymin,ymax);
770                                 PITS3->Fit(f1,"0RME");
771                                 Double_t rp2 = f1->GetParameter(2);
772                                 if (rp2>rp){ deviation = rp2-rp;} 
773                                         else {deviation = rp -rp2 ;}
774                                 rp = rp2 ;
775                                 mp = f1->GetParameter(1);
776                                 ymin = mp -(rp * 2);
777                                 ymax = mp +(rp * 2);
778                                 counter++;
779                         }
780                         Double_t mean = f1->GetParameter(1);
781                         Double_t meanE = f1->GetParError(1);
782                         Double_t sigma = f1->GetParameter(2);
783                         Double_t sigmaE = f1->GetParError(2);
784                         
785                         Resolution_P_dPt_Pt_ITS3rebin_1->SetBinContent(i, mean);
786                         Resolution_P_dPt_Pt_ITS3rebin_1->SetBinError(i, meanE);
787                         Resolution_P_dPt_Pt_ITS3rebin_2->SetBinContent(i, sigma);
788                         Resolution_P_dPt_Pt_ITS3rebin_2->SetBinError(i, sigmaE);
789                         delete f1;
790                         delete f0;
791                 } //end of fitting 
792
793                 TH1F *Resolution_P_dPt_Pt_ITS4rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS4rebin_1", "mean Positron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning) ;       
794                 TH1F *Resolution_P_dPt_Pt_ITS4rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS4rebin_2", "sigma Positron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning) ;      
795                 for (Int_t i = 1; i < 30 + 1 ; i ++){
796                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
797                         TH1D *PITS4 = Resolution_P_dPt_Pt_ITS4rebin->ProjectionY("PITS4", i, i);
798                         PITS4->Fit(f0,"0RME");
799                         Double_t rp = f0->GetParameter(2);
800                         Double_t mp = f0->GetParameter(1);
801                         Double_t ymin = mp -(rp * 2.);
802                         Double_t ymax = mp + (rp * 2.);
803                         Double_t deviation = 100;
804                         Int_t counter = 0;
805                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
806                         while(deviation > precision && counter < 100){
807                                 f1->SetRange(ymin,ymax);
808                                 PITS4->Fit(f1,"0RME");
809                                 Double_t rp2 = f1->GetParameter(2);
810                                 if (rp2>rp){ deviation = rp2-rp;} 
811                                         else {deviation = rp -rp2 ;}
812                                 rp = rp2 ;
813                                 mp = f1->GetParameter(1);
814                                 ymin = mp -(rp * 2);
815                                 ymax = mp +(rp * 2);
816                                 counter++;
817                         }
818                         Double_t mean = f1->GetParameter(1);
819                         Double_t meanE = f1->GetParError(1);
820                         Double_t sigma = f1->GetParameter(2);
821                         Double_t sigmaE = f1->GetParError(2);
822                         
823                         Resolution_P_dPt_Pt_ITS4rebin_1->SetBinContent(i, mean);
824                         Resolution_P_dPt_Pt_ITS4rebin_1->SetBinError(i, meanE);
825                         Resolution_P_dPt_Pt_ITS4rebin_2->SetBinContent(i, sigma);
826                         Resolution_P_dPt_Pt_ITS4rebin_2->SetBinError(i, sigmaE);
827                         delete f1;
828                         delete f0;
829                 } //end of fitting 
830
831                 TH1F *Resolution_P_dPt_Pt_ITS5rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS5rebin_1", "mean Positron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning) ;       
832                 TH1F *Resolution_P_dPt_Pt_ITS5rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS5rebin_2", "mean Positron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning) ;       
833                 for (Int_t i = 1; i < 30 + 1 ; i ++){
834                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
835                         TH1D *PITS5 = Resolution_P_dPt_Pt_ITS5rebin->ProjectionY("PITS5", i, i);
836                         PITS5->Fit(f0,"0RME");
837                         Double_t rp = f0->GetParameter(2);
838                         Double_t mp = f0->GetParameter(1);
839                         Double_t ymin = mp -(rp * 2.);
840                         Double_t ymax = mp + (rp * 2.);
841                         Double_t deviation = 100;
842                         Int_t counter = 0;
843                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
844                         while(deviation > precision && counter < 100){
845                                 f1->SetRange(ymin,ymax);
846                                 PITS5->Fit(f1,"0RME");
847                                 Double_t rp2 = f1->GetParameter(2);
848                                 if (rp2>rp){ deviation = rp2-rp;} 
849                                         else {deviation = rp -rp2 ;}
850                                 rp = rp2 ;
851                                 mp = f1->GetParameter(1);
852                                 ymin = mp -(rp * 2);
853                                 ymax = mp +(rp * 2);
854                                 counter++;
855                         }
856                         Double_t mean = f1->GetParameter(1);
857                         Double_t meanE = f1->GetParError(1);
858                         Double_t sigma = f1->GetParameter(2);
859                         Double_t sigmaE = f1->GetParError(2);
860                         
861                         Resolution_P_dPt_Pt_ITS5rebin_1->SetBinContent(i, mean);
862                         Resolution_P_dPt_Pt_ITS5rebin_1->SetBinError(i, meanE);
863                         Resolution_P_dPt_Pt_ITS5rebin_2->SetBinContent(i, sigma);
864                         Resolution_P_dPt_Pt_ITS5rebin_2->SetBinError(i, sigmaE);
865                         delete f1;
866                         delete f0;
867                 } //end of fitting 
868
869                 TH1F *Resolution_P_dPt_Pt_ITS6rebin_1 = new TH1F("Resolution_P_dPt_Pt_ITS6rebin_1", "mean Positron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning) ;       
870                 TH1F *Resolution_P_dPt_Pt_ITS6rebin_2 = new TH1F("Resolution_P_dPt_Pt_ITS6rebin_2", "sigma Positron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning) ;      
871                 for (Int_t i = 1; i < 30 + 1 ; i ++){
872                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
873                         TH1D *PITS6 = Resolution_P_dPt_Pt_ITS6rebin->ProjectionY("PITS6", i, i);
874                         PITS6->Fit(f0,"0RME");
875                         Double_t rp = f0->GetParameter(2);
876                         Double_t mp = f0->GetParameter(1);
877                         Double_t ymin = mp -(rp * 2.);
878                         Double_t ymax = mp + (rp * 2.);
879                         Double_t deviation = 100;
880                         Int_t counter = 0;
881                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
882                         while(deviation > precision && counter < 100){
883                                 f1->SetRange(ymin,ymax);
884                                 PITS6->Fit(f1,"0RME");
885                                 Double_t rp2 = f1->GetParameter(2);
886                                 if (rp2>rp){ deviation = rp2-rp;} 
887                                         else {deviation = rp -rp2 ;}
888                                 rp = rp2 ;
889                                 mp = f1->GetParameter(1);
890                                 ymin = mp -(rp * 2);
891                                 ymax = mp +(rp * 2);
892                                 counter++;
893                         }
894                         Double_t mean = f1->GetParameter(1);
895                         Double_t meanE = f1->GetParError(1);
896                         Double_t sigma = f1->GetParameter(2);
897                         Double_t sigmaE = f1->GetParError(2);
898                         
899                         Resolution_P_dPt_Pt_ITS6rebin_1->SetBinContent(i, mean);
900                         Resolution_P_dPt_Pt_ITS6rebin_1->SetBinError(i, meanE);
901                         Resolution_P_dPt_Pt_ITS6rebin_2->SetBinContent(i, sigma);
902                         Resolution_P_dPt_Pt_ITS6rebin_2->SetBinError(i, sigmaE);
903                         delete f1;
904                         delete f0;
905                 } //end of fitting 
906
907 //*************************************** fitting dPt for ITS bins for Electron ***************************************
908                 TH1F *Resolution_E_dPt_Pt_ITS0rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS0rebin_1", "mean Electron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning) ;       
909                 TH1F *Resolution_E_dPt_Pt_ITS0rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS0rebin_2", "sigma Electron Resolution dPt vs Pt 0 ITS clusters", 30, ptbinning) ;      
910                 for (Int_t i = 1; i < 30 + 1 ; i ++){
911                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
912                         TH1D *EITS0 = Resolution_E_dPt_Pt_ITS0rebin->ProjectionY("EITS0", i, i);
913                         EITS0->Fit(f0,"0RME");
914                         Double_t rp = f0->GetParameter(2);
915                         Double_t mp = f0->GetParameter(1);
916                         Double_t ymin = mp -(rp * 2.);
917                         Double_t ymax = mp + (rp * 2.);
918                         Double_t deviation = 100;
919                         Int_t counter = 0;
920                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
921                         while(deviation > precision && counter < 100){
922                                 f1->SetRange(ymin,ymax);
923                                 EITS0->Fit(f1,"0RME");
924                                 Double_t rp2 = f1->GetParameter(2);
925                                 if (rp2>rp){ deviation = rp2-rp;} 
926                                         else {deviation = rp -rp2 ;}
927                                 rp = rp2 ;
928                                 mp = f1->GetParameter(1);
929                                 ymin = mp -(rp * 2);
930                                 ymax = mp +(rp * 2);
931                                 counter++;
932                         }
933                         Double_t mean = f1->GetParameter(1);
934                         Double_t meanE = f1->GetParError(1);
935                         Double_t sigma = f1->GetParameter(2);
936                         Double_t sigmaE = f1->GetParError(2);
937                         
938                         Resolution_E_dPt_Pt_ITS0rebin_1->SetBinContent(i, mean);
939                         Resolution_E_dPt_Pt_ITS0rebin_1->SetBinError(i, meanE);
940                         Resolution_E_dPt_Pt_ITS0rebin_2->SetBinContent(i, sigma);
941                         Resolution_E_dPt_Pt_ITS0rebin_2->SetBinError(i, sigmaE);
942                         delete f1;
943                         delete f0;
944                 } //end of fitting 
945
946                 TH1F *Resolution_E_dPt_Pt_ITS1rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS1rebin_1", "mean Electron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning) ;       
947                 TH1F *Resolution_E_dPt_Pt_ITS1rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS1rebin_2", "sigma Electron Resolution dPt vs Pt 1 ITS clusters", 30, ptbinning) ;      
948                 for (Int_t i = 1; i < 30 + 1 ; i ++){
949                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
950                         TH1D *EITS1 = Resolution_E_dPt_Pt_ITS1rebin->ProjectionY("EITS1", i, i);
951                         EITS1->Fit(f0,"0RME");
952                         Double_t rp = f0->GetParameter(2);
953                         Double_t mp = f0->GetParameter(1);
954                         Double_t ymin = mp -(rp * 2.);
955                         Double_t ymax = mp + (rp * 2.);
956                         Double_t deviation = 100;
957                         Int_t counter = 0;
958                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
959                         while(deviation > precision && counter < 100){
960                                 f1->SetRange(ymin,ymax);
961                                 EITS1->Fit(f1,"0RME");
962                                 Double_t rp2 = f1->GetParameter(2);
963                                 if (rp2>rp){ deviation = rp2-rp;} 
964                                         else {deviation = rp -rp2 ;}
965                                 rp = rp2 ;
966                                 mp = f1->GetParameter(1);
967                                 ymin = mp -(rp * 2);
968                                 ymax = mp +(rp * 2);
969                                 counter++;
970                         }
971                         Double_t mean = f1->GetParameter(1);
972                         Double_t meanE = f1->GetParError(1);
973                         Double_t sigma = f1->GetParameter(2);
974                         Double_t sigmaE = f1->GetParError(2);
975                         
976                         Resolution_E_dPt_Pt_ITS1rebin_1->SetBinContent(i, mean);
977                         Resolution_E_dPt_Pt_ITS1rebin_1->SetBinError(i, meanE);
978                         Resolution_E_dPt_Pt_ITS1rebin_2->SetBinContent(i, sigma);
979                         Resolution_E_dPt_Pt_ITS1rebin_2->SetBinError(i, sigmaE);
980                         delete f1;
981                         delete f0;
982                 } //end of fitting 
983
984                 TH1F *Resolution_E_dPt_Pt_ITS2rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS2rebin_1", "mean Electron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning) ;       
985                 TH1F *Resolution_E_dPt_Pt_ITS2rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS2rebin_2", "sigma Electron Resolution dPt vs Pt 2 ITS clusters", 30, ptbinning) ;      
986                 for (Int_t i = 1; i < 30 + 1 ; i ++){
987                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
988                         TH1D *EITS2 = Resolution_E_dPt_Pt_ITS2rebin->ProjectionY("EITS2", i, i);
989                         EITS2->Fit(f0,"0RME");
990                         Double_t rp = f0->GetParameter(2);
991                         Double_t mp = f0->GetParameter(1);
992                         Double_t ymin = mp -(rp * 2.);
993                         Double_t ymax = mp + (rp * 2.);
994                         Double_t deviation = 100;
995                         Int_t counter = 0;
996                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
997                         while(deviation > precision && counter < 100){
998                                 f1->SetRange(ymin,ymax);
999                                 EITS2->Fit(f1,"0RME");
1000                                 Double_t rp2 = f1->GetParameter(2);
1001                                 if (rp2>rp){ deviation = rp2-rp;} 
1002                                         else {deviation = rp -rp2 ;}
1003                                 rp = rp2 ;
1004                                 mp = f1->GetParameter(1);
1005                                 ymin = mp -(rp * 2);
1006                                 ymax = mp +(rp * 2);
1007                                 counter++;
1008                         }
1009                         Double_t mean = f1->GetParameter(1);
1010                         Double_t meanE = f1->GetParError(1);
1011                         Double_t sigma = f1->GetParameter(2);
1012                         Double_t sigmaE = f1->GetParError(2);
1013                         
1014                         Resolution_E_dPt_Pt_ITS2rebin_1->SetBinContent(i, mean);
1015                         Resolution_E_dPt_Pt_ITS2rebin_1->SetBinError(i, meanE);
1016                         Resolution_E_dPt_Pt_ITS2rebin_2->SetBinContent(i, sigma);
1017                         Resolution_E_dPt_Pt_ITS2rebin_2->SetBinError(i, sigmaE);
1018                         delete f1;
1019                         delete f0;
1020                 } //end of fitting 
1021
1022                 TH1F *Resolution_E_dPt_Pt_ITS3rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS3rebin_1", "mean Electron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning) ;       
1023                 TH1F *Resolution_E_dPt_Pt_ITS3rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS3rebin_2", "sigma Electron Resolution dPt vs Pt 3 ITS clusters", 30, ptbinning) ;      
1024                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1025                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1026                         TH1D *EITS3 = Resolution_E_dPt_Pt_ITS3rebin->ProjectionY("EITS3", i, i);
1027                         EITS3->Fit(f0,"0RME");
1028                         Double_t rp = f0->GetParameter(2);
1029                         Double_t mp = f0->GetParameter(1);
1030                         Double_t ymin = mp -(rp * 2.);
1031                         Double_t ymax = mp + (rp * 2.);
1032                         Double_t deviation = 100;
1033                         Int_t counter = 0;
1034                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1035                         while(deviation > precision && counter < 100){
1036                                 f1->SetRange(ymin,ymax);
1037                                 EITS3->Fit(f1,"0RME");
1038                                 Double_t rp2 = f1->GetParameter(2);
1039                                 if (rp2>rp){ deviation = rp2-rp;} 
1040                                         else {deviation = rp -rp2 ;}
1041                                 rp = rp2 ;
1042                                 mp = f1->GetParameter(1);
1043                                 ymin = mp -(rp * 2);
1044                                 ymax = mp +(rp * 2);
1045                                 counter++;
1046                         }
1047                         Double_t mean = f1->GetParameter(1);
1048                         Double_t meanE = f1->GetParError(1);
1049                         Double_t sigma = f1->GetParameter(2);
1050                         Double_t sigmaE = f1->GetParError(2);
1051                         
1052                         Resolution_E_dPt_Pt_ITS3rebin_1->SetBinContent(i, mean);
1053                         Resolution_E_dPt_Pt_ITS3rebin_1->SetBinError(i, meanE);
1054                         Resolution_E_dPt_Pt_ITS3rebin_2->SetBinContent(i, sigma);
1055                         Resolution_E_dPt_Pt_ITS3rebin_2->SetBinError(i, sigmaE);
1056                         delete f1;
1057                         delete f0;
1058                 } //end of fitting 
1059
1060                 TH1F *Resolution_E_dPt_Pt_ITS4rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS4rebin_1", "mean Electron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning) ;       
1061                 TH1F *Resolution_E_dPt_Pt_ITS4rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS4rebin_2", "sigma Electron Resolution dPt vs Pt 4 ITS clusters", 30, ptbinning) ;      
1062                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1063                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1064                         TH1D *EITS4 = Resolution_E_dPt_Pt_ITS4rebin->ProjectionY("EITS4", i, i);
1065                         EITS4->Fit(f0,"0RME");
1066                         Double_t rp = f0->GetParameter(2);
1067                         Double_t mp = f0->GetParameter(1);
1068                         Double_t ymin = mp -(rp * 2.);
1069                         Double_t ymax = mp + (rp * 2.);
1070                         Double_t deviation = 100;
1071                         Int_t counter = 0;
1072                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1073                         while(deviation > precision && counter < 100){
1074                                 f1->SetRange(ymin,ymax);
1075                                 EITS4->Fit(f1,"0RME");
1076                                 Double_t rp2 = f1->GetParameter(2);
1077                                 if (rp2>rp){ deviation = rp2-rp;} 
1078                                         else {deviation = rp -rp2 ;}
1079                                 rp = rp2 ;
1080                                 mp = f1->GetParameter(1);
1081                                 ymin = mp -(rp * 2);
1082                                 ymax = mp +(rp * 2);
1083                                 counter++;
1084                         }
1085                         Double_t mean = f1->GetParameter(1);
1086                         Double_t meanE = f1->GetParError(1);
1087                         Double_t sigma = f1->GetParameter(2);
1088                         Double_t sigmaE = f1->GetParError(2);
1089                         
1090                         Resolution_E_dPt_Pt_ITS4rebin_1->SetBinContent(i, mean);
1091                         Resolution_E_dPt_Pt_ITS4rebin_1->SetBinError(i, meanE);
1092                         Resolution_E_dPt_Pt_ITS4rebin_2->SetBinContent(i, sigma);
1093                         Resolution_E_dPt_Pt_ITS4rebin_2->SetBinError(i, sigmaE);
1094                         delete f1;
1095                         delete f0;
1096                 } //end of fitting 
1097
1098                 TH1F *Resolution_E_dPt_Pt_ITS5rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS5rebin_1", "mean Electron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning) ;       
1099                 TH1F *Resolution_E_dPt_Pt_ITS5rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS5rebin_2", "mean Electron Resolution dPt vs Pt 5 ITS clusters", 30, ptbinning) ;       
1100                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1101                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1102                         TH1D *EITS5 = Resolution_E_dPt_Pt_ITS5rebin->ProjectionY("EITS5", i, i);
1103                         EITS5->Fit(f0,"0RME");
1104                         Double_t rp = f0->GetParameter(2);
1105                         Double_t mp = f0->GetParameter(1);
1106                         Double_t ymin = mp -(rp * 2.);
1107                         Double_t ymax = mp + (rp * 2.);
1108                         Double_t deviation = 100;
1109                         Int_t counter = 0;
1110                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1111                         while(deviation > precision && counter < 100){
1112                                 f1->SetRange(ymin,ymax);
1113                                 EITS5->Fit(f1,"0RME");
1114                                 Double_t rp2 = f1->GetParameter(2);
1115                                 if (rp2>rp){ deviation = rp2-rp;} 
1116                                         else {deviation = rp -rp2 ;}
1117                                 rp = rp2 ;
1118                                 mp = f1->GetParameter(1);
1119                                 ymin = mp -(rp * 2);
1120                                 ymax = mp +(rp * 2);
1121                                 counter++;
1122                         }
1123                         Double_t mean = f1->GetParameter(1);
1124                         Double_t meanE = f1->GetParError(1);
1125                         Double_t sigma = f1->GetParameter(2);
1126                         Double_t sigmaE = f1->GetParError(2);
1127                         
1128                         Resolution_E_dPt_Pt_ITS5rebin_1->SetBinContent(i, mean);
1129                         Resolution_E_dPt_Pt_ITS5rebin_1->SetBinError(i, meanE);
1130                         Resolution_E_dPt_Pt_ITS5rebin_2->SetBinContent(i, sigma);
1131                         Resolution_E_dPt_Pt_ITS5rebin_2->SetBinError(i, sigmaE);
1132                         delete f1;
1133                         delete f0;
1134                 } //end of fitting 
1135
1136                 TH1F *Resolution_E_dPt_Pt_ITS6rebin_1 = new TH1F("Resolution_E_dPt_Pt_ITS6rebin_1", "mean Electron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning) ;       
1137                 TH1F *Resolution_E_dPt_Pt_ITS6rebin_2 = new TH1F("Resolution_E_dPt_Pt_ITS6rebin_2", "sigma Electron Resolution dPt vs Pt 6 ITS clusters", 30, ptbinning) ;      
1138                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1139                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1140                         TH1D *EITS6 = Resolution_E_dPt_Pt_ITS6rebin->ProjectionY("EITS6", i, i);
1141                         EITS6->Fit(f0,"0RME");
1142                         Double_t rp = f0->GetParameter(2);
1143                         Double_t mp = f0->GetParameter(1);
1144                         Double_t ymin = mp -(rp * 2.);
1145                         Double_t ymax = mp + (rp * 2.);
1146                         Double_t deviation = 100;
1147                         Int_t counter = 0;
1148                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1149                         while(deviation > precision && counter < 100){
1150                                 f1->SetRange(ymin,ymax);
1151                                 EITS6->Fit(f1,"0RME");
1152                                 Double_t rp2 = f1->GetParameter(2);
1153                                 if (rp2>rp){ deviation = rp2-rp;} 
1154                                         else {deviation = rp -rp2 ;}
1155                                 rp = rp2 ;
1156                                 mp = f1->GetParameter(1);
1157                                 ymin = mp -(rp * 2);
1158                                 ymax = mp +(rp * 2);
1159                                 counter++;
1160                         }
1161                         Double_t mean = f1->GetParameter(1);
1162                         Double_t meanE = f1->GetParError(1);
1163                         Double_t sigma = f1->GetParameter(2);
1164                         Double_t sigmaE = f1->GetParError(2);
1165                         
1166                         Resolution_E_dPt_Pt_ITS6rebin_1->SetBinContent(i, mean);
1167                         Resolution_E_dPt_Pt_ITS6rebin_1->SetBinError(i, meanE);
1168                         Resolution_E_dPt_Pt_ITS6rebin_2->SetBinContent(i, sigma);
1169                         Resolution_E_dPt_Pt_ITS6rebin_2->SetBinError(i, sigmaE);
1170                         delete f1;
1171                         delete f0;
1172                 } //end of fitting 
1173
1174
1175 //********************************** Fitting with TPC bins ****************************************
1176
1177                 TH1F *Resolution_E_dPt_Ptrebin_1 = new TH1F("Resolution_E_dPt_Ptrebin_1", "mean Electron Resolution dPt vs Pt", 30, ptbinning) ;        
1178                 TH1F *Resolution_E_dPt_Ptrebin_2 = new TH1F("Resolution_E_dPt_Ptrebin_2", "sigma Electron Resolution dPt vs Pt", 30, ptbinning) ;       
1179                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1180                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1181                         TH1D *PtbinE = Resolution_E_dPt_Ptrebin->ProjectionY("PtbinE", i, i);
1182                         PtbinE->Fit(f0,"0RME");
1183                         Double_t rp = f0->GetParameter(2);
1184                         Double_t mp = f0->GetParameter(1);
1185                         Double_t ymin = mp -(rp * 2.);
1186                         Double_t ymax = mp + (rp * 2.);
1187                         Double_t deviation = 100;
1188                         Int_t counter = 0;
1189                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1190                         while(deviation > precision && counter < 100){
1191                                 f1->SetRange(ymin,ymax);
1192                                 PtbinE->Fit(f1,"0RME");
1193                                 Double_t rp2 = f1->GetParameter(2);
1194                                 if (rp2>rp){ deviation = rp2-rp;} 
1195                                         else {deviation = rp -rp2 ;}
1196                                 rp = rp2 ;
1197                                 mp = f1->GetParameter(1);
1198                                 ymin = mp -(rp * 2);
1199                                 ymax = mp +(rp * 2);
1200                                 counter++;
1201                         }
1202                         Double_t mean = f1->GetParameter(1);
1203                         Double_t meanE = f1->GetParError(1);
1204                         Double_t sigma = f1->GetParameter(2);
1205                         Double_t sigmaE = f1->GetParError(2);
1206                         
1207                         Resolution_E_dPt_Ptrebin_1->SetBinContent(i, mean);
1208                         Resolution_E_dPt_Ptrebin_1->SetBinError(i, meanE);
1209                         Resolution_E_dPt_Ptrebin_2->SetBinContent(i, sigma);
1210                         Resolution_E_dPt_Ptrebin_2->SetBinError(i, sigmaE);
1211                         delete f1;
1212                         delete f0;
1213                 } //end of fitting 
1214
1215                 TH1F *Resolution_P_dPt_Ptrebin_1 = new TH1F("Resolution_P_dPt_Ptrebin_1", "mean Positron Resolution dPt vs Pt", 30, ptbinning) ;        
1216                 TH1F *Resolution_P_dPt_Ptrebin_2 = new TH1F("Resolution_P_dPt_Ptrebin_2", "sigma Positron Resolution dPt vs Pt", 30, ptbinning) ;       
1217                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1218                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1219                         TH1D *PtbinP = Resolution_P_dPt_Ptrebin->ProjectionY("PtbinP", i, i);
1220                         PtbinP->Fit(f0,"0RME");
1221                         Double_t rp = f0->GetParameter(2);
1222                         Double_t mp = f0->GetParameter(1);
1223                         Double_t ymin = mp -(rp * 2.);
1224                         Double_t ymax = mp + (rp * 2.);
1225                         Double_t deviation = 100;
1226                         Int_t counter = 0;
1227                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1228                         while(deviation > precision && counter < 100){
1229                                 f1->SetRange(ymin,ymax);
1230                                 PtbinP->Fit(f1,"0RME");
1231                                 Double_t rp2 = f1->GetParameter(2);
1232                                 if (rp2>rp){ deviation = rp2-rp;} 
1233                                         else {deviation = rp -rp2 ;}
1234                                 rp = rp2 ;
1235                                 mp = f1->GetParameter(1);
1236                                 ymin = mp -(rp * 2.);
1237                                 ymax = mp +(rp * 2.);
1238                                 counter++;
1239                         }
1240                         Double_t mean = f1->GetParameter(1);
1241                         Double_t meanE = f1->GetParError(1);
1242                         Double_t sigma = f1->GetParameter(2);
1243                         Double_t sigmaE = f1->GetParError(2);
1244                         
1245                         Resolution_P_dPt_Ptrebin_1->SetBinContent(i, mean);
1246                         Resolution_P_dPt_Ptrebin_1->SetBinError(i, meanE);
1247                         Resolution_P_dPt_Ptrebin_2->SetBinContent(i, sigma);
1248                         Resolution_P_dPt_Ptrebin_2->SetBinError(i, sigmaE);
1249                         delete f1;
1250                         delete f0;
1251                 } //end of fitting 
1252
1253                 TH1F *Resolution_Gamma_dPt_Ptrebin_1 = new TH1F("Resolution_Gamma_dPt_Ptrebin_1", "mean Gamma Resolution dPt vs Pt", 30, ptbinning) ;   
1254                 TH1F *Resolution_Gamma_dPt_Ptrebin_2 = new TH1F("Resolution_Gamma_dPt_Ptrebin_2", "sigma Gamma Resolution dPt vs Pt", 30, ptbinning) ;  
1255                 for (Int_t i = 1; i < 30 + 1 ; i ++){
1256                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1257                         TH1D *PtbinGamma = Resolution_Gamma_dPt_Ptrebin->ProjectionY("PtbinGamma", i, i);
1258                         PtbinGamma->Fit(f0,"0RME");
1259                         Double_t rp = f0->GetParameter(2);
1260                         Double_t mp = f0->GetParameter(1);
1261                         Double_t ymin = mp -(rp * 2.);
1262                         Double_t ymax = mp + (rp * 2.);
1263                         Double_t deviation = 100;
1264                         Int_t counter = 0;
1265                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1266                         while(deviation > precision && counter < 100){
1267                                 f1->SetRange(ymin,ymax);
1268                                 PtbinGamma->Fit(f1,"0RME");
1269                                 Double_t rp2 = f1->GetParameter(2);
1270                                 if (rp2>rp){ deviation = rp2-rp;} 
1271                                         else {deviation = rp -rp2 ;}
1272                                 rp = rp2 ;
1273                                 mp = f1->GetParameter(1);
1274                                 ymin = mp -(rp * 2);
1275                                 ymax = mp +(rp * 2);
1276                                 counter++;
1277                         }
1278                         Double_t mean = f1->GetParameter(1);
1279                         Double_t meanE = f1->GetParError(1);
1280                         Double_t sigma = f1->GetParameter(2);
1281                         Double_t sigmaE = f1->GetParError(2);
1282                         
1283                         Resolution_Gamma_dPt_Ptrebin_1->SetBinContent(i, mean);
1284                         Resolution_Gamma_dPt_Ptrebin_1->SetBinError(i, meanE);
1285                         Resolution_Gamma_dPt_Ptrebin_2->SetBinContent(i, sigma);
1286                         Resolution_Gamma_dPt_Ptrebin_2->SetBinError(i, sigmaE);
1287                         delete f1;
1288                         delete f0;
1289                 } //end of fitting 
1290
1291
1292 //******************************** Fitting for Phi binning *******************************************************************
1293
1294                 TH1F *Resolution_Gamma_dPt_Phi_1 = new TH1F("Resolution_Gamma_dPt_Phi_1", "mean Gamma Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ; 
1295                 TH1F *Resolution_Gamma_dPt_Phi_2 = new TH1F("Resolution_Gamma_dPt_Phi_2", "sigma Gamma Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ;        
1296                 for (Int_t i = 1; i < 100 + 1 ; i ++){
1297                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1298                         TH1D *PhibinGamma = Resolution_Gamma_dPt_Phi->ProjectionY("PhibinGamma", i, i);
1299                         PhibinGamma->Fit(f0,"0RME");
1300                         Double_t rp = f0->GetParameter(2);
1301                         Double_t mp = f0->GetParameter(1);
1302                         Double_t ymin = mp -(rp * 2);
1303                         Double_t ymax = mp +(rp * 2);
1304                         Double_t deviation = 100;
1305                         Int_t counter = 0;
1306                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1307                         while(deviation > precision && counter < 100){
1308                                 f1->SetRange(ymin,ymax);
1309                                 PhibinGamma->Fit(f1,"0RME");
1310                                 Double_t rp2 = f1->GetParameter(2);
1311                                 if (rp2>rp){ deviation = rp2-rp;} 
1312                                         else {deviation = rp -rp2 ;}
1313                                 rp = rp2 ;
1314                                 mp = f1->GetParameter(1);
1315                                 ymin = mp -(rp * 2);
1316                                 ymax = mp +(rp * 2);
1317                                 counter++;
1318                         }
1319                         Double_t mean = f1->GetParameter(1);
1320                         Double_t meanE = f1->GetParError(1);
1321                         Double_t sigma = f1->GetParameter(2);
1322                         Double_t sigmaE = f1->GetParError(2);
1323                         
1324                         Resolution_Gamma_dPt_Phi_1->SetBinContent(i, mean);
1325                         Resolution_Gamma_dPt_Phi_1->SetBinError(i, meanE);
1326                         Resolution_Gamma_dPt_Phi_2->SetBinContent(i, sigma);
1327                         Resolution_Gamma_dPt_Phi_2->SetBinError(i, sigmaE);
1328                         delete f1;
1329                         delete f0;
1330                 } //end of fitting 
1331
1332                 TH1F *Resolution_E_dPt_Phi_1 = new TH1F("Resolution_E_dPt_Phi_1", "mean Electron Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ;      
1333                 TH1F *Resolution_E_dPt_Phi_2 = new TH1F("Resolution_E_dPt_Phi_2", "sigma Electron Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ;     
1334                 for (Int_t i = 1; i < 100 + 1 ; i ++){
1335                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1336                         TH1D *PhibinE = Resolution_E_dPt_Phi->ProjectionY("PhibinE", i, i);
1337                         PhibinE->Fit(f0,"0RME");
1338                         Double_t rp = f0->GetParameter(2);
1339                         Double_t mp = f0->GetParameter(1);
1340                         Double_t ymin = mp -(rp * 2);
1341                         Double_t ymax = mp +(rp * 2);
1342                         Double_t deviation = 100;
1343                         Int_t counter = 0;
1344                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1345                         while(deviation > precision && counter < 100){
1346                                 f1->SetRange(ymin,ymax);
1347                                 PhibinE->Fit(f1,"0RME");
1348                                 Double_t rp2 = f1->GetParameter(2);
1349                                 if (rp2>rp){ deviation = rp2-rp;} 
1350                                         else {deviation = rp -rp2 ;}
1351                                 rp = rp2 ;
1352                                 mp = f1->GetParameter(1);
1353                                 ymin = mp -(rp * 2);
1354                                 ymax = mp +(rp * 2);
1355                                 counter++;
1356                         }
1357                         Double_t mean = f1->GetParameter(1);
1358                         Double_t meanE = f1->GetParError(1);
1359                         Double_t sigma = f1->GetParameter(2);
1360                         Double_t sigmaE = f1->GetParError(2);
1361                         
1362                         Resolution_E_dPt_Phi_1->SetBinContent(i, mean);
1363                         Resolution_E_dPt_Phi_1->SetBinError(i, meanE);
1364                         Resolution_E_dPt_Phi_2->SetBinContent(i, sigma);
1365                         Resolution_E_dPt_Phi_2->SetBinError(i, sigmaE);
1366                         delete f1;
1367                         delete f0;
1368                 } //end of fitting 
1369
1370                 TH1F *Resolution_P_dPt_Phi_1 = new TH1F("Resolution_P_dPt_Phi_1", "mean Positron Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ;      
1371                 TH1F *Resolution_P_dPt_Phi_2 = new TH1F("Resolution_P_dPt_Phi_2", "sigma Positron Resolution dPt vs Phi", 100, -TMath::Pi(), TMath::Pi()) ;     
1372                 for (Int_t i = 1; i < 100 + 1 ; i ++){
1373                         TF1 *f0 = new TF1("f0", "gaus", -10.,10.);
1374                         TH1D *PhibinP = Resolution_P_dPt_Phi->ProjectionY("PhibinP", i, i);
1375                         PhibinP->Fit(f0,"0RME");
1376                         Double_t rp = f0->GetParameter(2);
1377                         Double_t mp = f0->GetParameter(1);
1378                         Double_t ymin = mp -(rp * 2);
1379                         Double_t ymax = mp +(rp * 2);
1380                         Double_t deviation = 100;
1381                         Int_t counter = 0;
1382                         TF1* f1 = new TF1 ("f1", "gaus", ymin, ymax);
1383                         while(deviation > precision && counter < 100){
1384                                 f1->SetRange(ymin,ymax);
1385                                 PhibinP->Fit(f1,"0RME");
1386                                 Double_t rp2 = f1->GetParameter(2);
1387                                 if (rp2>rp){ deviation = rp2-rp;} 
1388                                         else {deviation = rp -rp2 ;}
1389                                 rp = rp2 ;
1390                                 mp = f1->GetParameter(1);
1391                                 ymin = mp -(rp * 2);
1392                                 ymax = mp +(rp * 2);
1393                                 counter++;
1394                         }
1395                         Double_t mean = f1->GetParameter(1);
1396                         Double_t meanE = f1->GetParError(1);
1397                         Double_t sigma = f1->GetParameter(2);
1398                         Double_t sigmaE = f1->GetParError(2);
1399                         
1400                         Resolution_P_dPt_Phi_1->SetBinContent(i, mean);
1401                         Resolution_P_dPt_Phi_1->SetBinError(i, meanE);
1402                         Resolution_P_dPt_Phi_2->SetBinContent(i, sigma);
1403                         Resolution_P_dPt_Phi_2->SetBinError(i, sigmaE);
1404                         delete f1;
1405                         delete f0;
1406                 } //end of fitting 
1407
1408
1409
1410 //********************************************************************************************************
1411 //*************************************** creating ps-file ***********************************************
1412 //********************************************************************************************************
1413 if(!SinglePlots) {      
1414                 TPostScript *ps_characteristics;
1415                 ps_characteristics = new TPostScript(Form("%s%s.ps",path,output),111);  
1416
1417                 //******************************* Performance *********************************************
1418
1419                 ps_characteristics->NewPage();
1420                 
1421                 TCanvas * c5 = new TCanvas("c5","",700,1000);  // gives the page size
1422                 pad_c5 = new TPad("pad_c4","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1423                 pad_c5->SetFillColor(0);
1424                 pad_c5->GetFrame()->SetFillColor(0);
1425                 pad_c5->SetBorderMode(0);
1426                 pad_c5->Divide(2,2);
1427                 pad_c5->Draw();
1428
1429
1430                 leg1 = new TLegend( 0.6,0.82,0.92,0.9);
1431                 leg1->SetTextSize(0.03);                        
1432                 leg1->SetFillColor(0);
1433                 leg1->AddEntry(Resolution_MC_Pt,("MC truth"));
1434                 leg1->AddEntry(Resolution_ESD_Pt,("MC reconstructed"));
1435                         pad_c5->cd(1)->SetLogy(1);
1436                         pad_c5->cd(1);
1437                                 DrawAutoGammaHistos( Resolution_MC_Pt, 
1438                                                                  Resolution_ESD_Pt, 
1439                                                                  "p_{t} distribution of the #gamma","p_{t} ","N_{#gamma}",
1440                                                                  kTRUE, 1.2,1,
1441                                                                  kFALSE,0. ,0.,
1442                                                                  kFALSE, 50.,100.);
1443                                 leg1->Draw();   
1444
1445                         pad_c5->cd(1)->Update();        
1446
1447                         pad_c5->cd(3);
1448                                 DrawAutoGammaHistos( Resolution_MC_Z, 
1449                                                                  Resolution_ESD_Z, 
1450                                                                  "Z distribution of conversion point","Z [cm] ","N_{#gamma}",
1451                                                                  kTRUE, 1.2,0,
1452                                                                  kFALSE,0. ,0.,
1453                                                                  kTRUE, 0.,200.);
1454                                 leg1->Draw();   
1455
1456                         pad_c5->cd(2)->Update();        
1457                 
1458                         pad_c5->cd(4);
1459                                 DrawAutoGammaHistos( Resolution_MC_R, 
1460                                                                  Resolution_ESD_R, 
1461                                                                  "R distribution of conversion point","R [cm] ","N_{#gamma}",
1462                                                                  kTRUE, 1.2,0,
1463                                                                  kFALSE,0. ,0.,
1464                                                                  kTRUE, 0.,200.);
1465                                 leg1->Draw();   
1466
1467                         pad_c5->cd(3)->Update();                        
1468                 c5->Update();
1469
1470                 //************************************ Resolution Gamma dPt vs Pt **********************************
1471                 ps_characteristics->NewPage();
1472                 TCanvas * c0 = new TCanvas("c0","",700,1000);  // gives the page size
1473                 pad_c0 = new TPad("pad_c0","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1474                 pad_c0->SetFillColor(0);
1475                 pad_c0->GetFrame()->SetFillColor(0);
1476                 pad_c0->SetBorderMode(0);
1477                 pad_c0->Divide(2,2);
1478                 pad_c0->Draw();
1479
1480                 pad_c0->cd(1)->SetLogz(1);
1481                 pad_c0->cd(1)->SetLogx(1);
1482                 pad_c0->cd(2)->SetLogz(1);
1483                 pad_c0->cd(2)->SetLogx(1);
1484
1485                 pad_c0->cd(1)->SetRightMargin(0.17);            
1486                 pad_c0->cd(1);
1487                         DrawAutoGammaHisto2D(   Resolution_Gamma_dPt_Pt,
1488                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1489                                                                 kFALSE, 10., 140.,
1490                                                                 kFALSE, 0., 100.);
1491                 pad_c0->cd(1)->Update();        
1492
1493                 pad_c0->cd(2)->SetRightMargin(0.17);            
1494                 pad_c0->cd(2);
1495                         DrawAutoGammaHisto2D(   Resolution_Gamma_dPt_Ptrebin,
1496                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1497                                                                 kFALSE, 10., 140.,
1498                                                                 kTRUE, 0., 100.);
1499                 pad_c0->cd(2)->Update();        
1500
1501
1502                 pad_c0->cd(3);
1503                         StylingSliceHistos(Resolution_Gamma_dPt_Ptrebin_1,0.8);
1504                         Resolution_Gamma_dPt_Ptrebin_1->SetMarkerColor(kRed+2);
1505                         Resolution_Gamma_dPt_Ptrebin_1->SetLineColor(kBlue-8);
1506                         DrawResolutionGammaHisto( Resolution_Gamma_dPt_Ptrebin_1, 
1507                                                                 "", "p_{t} [GeV/c]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
1508                                                                 kFALSE, 10., 140.,
1509                                                                 kTRUE, -2, 4.,
1510                                                                 kTRUE, 0.8, 100.);
1511                 pad_c0->cd(3)->Update();
1512
1513                 pad_c0->cd(4);
1514                         StylingSliceHistos(Resolution_Gamma_dPt_Ptrebin_2,0.8);
1515                         Resolution_Gamma_dPt_Ptrebin_2->SetMarkerColor(kRed+2);
1516                         Resolution_Gamma_dPt_Ptrebin_2->SetLineColor(kBlue-8);
1517                         DrawResolutionGammaHisto( Resolution_Gamma_dPt_Ptrebin_2, 
1518                                                         "", "p_{t} [GeV/c]", " #sigma dp_{t}/p_{t,MC} [%] ", 
1519                                                                 kFALSE, 10., 140.,
1520                                                                 kTRUE, 0, 16.,
1521                                                                 kTRUE, 0.8, 100.);
1522                 pad_c0->cd(4)->Update();
1523
1524                 c0->Update();
1525                 
1526
1527                 //************************************ Resolution E dPt vs Pt **********************************
1528                 ps_characteristics->NewPage();
1529                 
1530                 TCanvas * c1 = new TCanvas("c1","",700,1000);  // gives the page size
1531                 pad_c1 = new TPad("pad_c1","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1532                 pad_c1->SetFillColor(0);
1533                 pad_c1->GetFrame()->SetFillColor(0);
1534                 pad_c1->SetBorderMode(0);
1535                 pad_c1->Divide(2,2);
1536                 pad_c1->Draw();
1537
1538                 pad_c1->cd(1)->SetLogz(1);
1539                 pad_c1->cd(1)->SetLogx(1);
1540                 pad_c1->cd(2)->SetLogz(1);
1541                 pad_c1->cd(2)->SetLogx(1);
1542
1543                 pad_c1->cd(1)->SetRightMargin(0.17);            
1544                 pad_c1->cd(1);
1545                         DrawAutoGammaHisto2D(   Resolution_E_dPt_Pt,
1546                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1547                                                                 kFALSE, 10., 140.,
1548                                                                 kFALSE, 0., 100.);
1549                 pad_c1->cd(1)->Update();        
1550
1551                 pad_c1->cd(2)->SetRightMargin(0.17);            
1552                 pad_c1->cd(2);
1553                         DrawAutoGammaHisto2D(   Resolution_E_dPt_Ptrebin,
1554                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1555                                                                 kFALSE, 10., 140.,
1556                                                                 kTRUE, 0., 100.);
1557                 pad_c1->cd(2)->Update();        
1558
1559
1560                 pad_c1->cd(3);
1561                         StylingSliceHistos(Resolution_E_dPt_Ptrebin_1,0.8);
1562                         Resolution_E_dPt_Ptrebin_1->SetMarkerColor(kRed+2);
1563                         Resolution_E_dPt_Ptrebin_1->SetLineColor(kBlue-8);
1564                         DrawResolutionGammaHisto( Resolution_E_dPt_Ptrebin_1, 
1565                                                                 "", "p_{t} [GeV/c]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
1566                                                                 kFALSE, 10., 140.,
1567                                                                 kTRUE, -2, 2.,
1568                                                                 kTRUE, 0.8, 100.);
1569                 pad_c1->cd(3)->Update();
1570
1571                 pad_c1->cd(4);
1572                         StylingSliceHistos(Resolution_E_dPt_Ptrebin_2,0.8);
1573                         Resolution_E_dPt_Ptrebin_2->SetMarkerColor(kRed+2);
1574                         Resolution_E_dPt_Ptrebin_2->SetLineColor(kBlue-8);
1575                         DrawResolutionGammaHisto( Resolution_E_dPt_Ptrebin_2, 
1576                                                         "", "p_{t} [GeV/c]", " #sigma dp_{t}/p_{t,MC} [%]", 
1577                                                                 kFALSE, 10., 140.,
1578                                                                 kTRUE, 0, 15.,
1579                                                                 kTRUE, 0.8, 100.);
1580                 pad_c1->cd(4)->Update();
1581
1582                 c1->Update();
1583
1584                 //******************************* Resoltution E dPt vs Pt ITS dependent ***************************
1585
1586                 ps_characteristics->NewPage();
1587                 
1588                 TCanvas * c2 = new TCanvas("c2","",700,1000);  // gives the page size
1589                 pad_c2 = new TPad("pad_c2","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1590                 pad_c2->SetFillColor(0);
1591                 pad_c2->GetFrame()->SetFillColor(0);
1592                 pad_c2->SetBorderMode(0);
1593                 pad_c2->Divide(1,2);
1594                 pad_c2->Draw();
1595
1596
1597                 leg2 = new TLegend( 0.6,0.72,0.92,0.9);
1598                 leg2->SetTextSize(0.03);                        
1599                 leg2->SetFillColor(0);                  pad_c5->cd(1);
1600                 leg2->AddEntry(Resolution_E_dPt_Pt_ITS0rebin_1,("only TPC"));
1601 //              leg2->AddEntry(Resolution_E_dPt_Pt_ITS1rebin_1,("1 ITS cluster"));
1602                 leg2->AddEntry(Resolution_E_dPt_Pt_ITS2rebin_1,("2 ITS cluster"));
1603 //              leg2->AddEntry(Resolution_E_dPt_Pt_ITS3rebin_1,("3 ITS cluster"));
1604                 leg2->AddEntry(Resolution_E_dPt_Pt_ITS4rebin_1,("4 ITS cluster"));
1605                 leg2->AddEntry(Resolution_E_dPt_Pt_ITS5rebin_1,("5 ITS cluster"));
1606                 leg2->AddEntry(Resolution_E_dPt_Pt_ITS6rebin_1,("6 ITS cluster"));              
1607
1608                 pad_c2->cd(1);
1609                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS0rebin_1,0.8);
1610                         Resolution_E_dPt_Pt_ITS0rebin_1->SetMarkerColor(kRed+2);
1611                         Resolution_E_dPt_Pt_ITS0rebin_1->SetLineColor(kRed+2);
1612                         DrawResolutionGammaHisto( Resolution_E_dPt_Pt_ITS0rebin_1, 
1613                                                                 "", "p_{t} [GeV/c]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
1614                                                                 kFALSE, 10., 140.,
1615                                                                 kTRUE, -20, 20.,
1616                                                                 kTRUE, 0, 18.);
1617 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS1rebin_1,1);
1618                         Resolution_E_dPt_Pt_ITS1rebin_1->SetMarkerColor(kBlue+2);
1619                         Resolution_E_dPt_Pt_ITS1rebin_1->SetLineColor(kBlue+2);
1620                         Resolution_E_dPt_Pt_ITS1rebin_1->Draw("same");
1621 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS2rebin_1,0.8);
1622                         Resolution_E_dPt_Pt_ITS2rebin_1->SetMarkerColor(kViolet+2);
1623                         Resolution_E_dPt_Pt_ITS2rebin_1->SetLineColor(kViolet+2);
1624                         Resolution_E_dPt_Pt_ITS2rebin_1->Draw("same");
1625 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS3rebin_1,1);
1626                         Resolution_E_dPt_Pt_ITS3rebin_1->SetMarkerColor(kOrange+2);
1627                         Resolution_E_dPt_Pt_ITS3rebin_1->SetLineColor(kOrange+2);
1628                         Resolution_E_dPt_Pt_ITS3rebin_1->Draw("same");
1629 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS4rebin_1,0.8);
1630                         Resolution_E_dPt_Pt_ITS4rebin_1->SetMarkerColor(kCyan+2);
1631                         Resolution_E_dPt_Pt_ITS4rebin_1->SetLineColor(kCyan+2);
1632                         Resolution_E_dPt_Pt_ITS4rebin_1->Draw("same");
1633                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS5rebin_1,1);
1634                         Resolution_E_dPt_Pt_ITS5rebin_1->SetMarkerColor(kGreen+2);
1635                         Resolution_E_dPt_Pt_ITS5rebin_1->SetLineColor(kGreen+2);
1636                         Resolution_E_dPt_Pt_ITS5rebin_1->Draw("same");
1637                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS6rebin_1,0.8);
1638                         Resolution_E_dPt_Pt_ITS6rebin_1->SetMarkerColor(kMagenta+2);
1639                         Resolution_E_dPt_Pt_ITS6rebin_1->SetLineColor(kMagenta+2);
1640                         Resolution_E_dPt_Pt_ITS6rebin_1->Draw("same");
1641                         leg2->Draw("same");
1642                 pad_c2->cd(1)->Update();        
1643
1644                 pad_c2->cd(2);
1645                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS0rebin_2,0.8);
1646                         Resolution_E_dPt_Pt_ITS0rebin_2->SetMarkerColor(kRed+2);
1647                         Resolution_E_dPt_Pt_ITS0rebin_2->SetLineColor(kRed+2);
1648                         DrawResolutionGammaHisto( Resolution_E_dPt_Pt_ITS0rebin_2, 
1649                                                                 "", "p_{t} [GeV/c]", "#sigma dp_{t}/p_{t,MC} [%]", 
1650                                                                 kFALSE, 10., 140.,
1651                                                                 kTRUE, -1, 30.,
1652                                                                 kTRUE, 0, 18.);
1653 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS1rebin_2,1);
1654                         Resolution_E_dPt_Pt_ITS1rebin_2->SetMarkerColor(kBlue+2);
1655                         Resolution_E_dPt_Pt_ITS1rebin_2->SetLineColor(kBlue+2);
1656                         Resolution_E_dPt_Pt_ITS1rebin_2->Draw("same");
1657 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS2rebin_2,0.8);
1658                         Resolution_E_dPt_Pt_ITS2rebin_2->SetMarkerColor(kViolet+2);
1659                         Resolution_E_dPt_Pt_ITS2rebin_2->SetLineColor(kViolet+2);
1660                         Resolution_E_dPt_Pt_ITS2rebin_2->Draw("same");
1661 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS3rebin_2,1);
1662                         Resolution_E_dPt_Pt_ITS3rebin_2->SetMarkerColor(kOrange+2);
1663                         Resolution_E_dPt_Pt_ITS3rebin_2->SetLineColor(kOrange+2);
1664                         Resolution_E_dPt_Pt_ITS3rebin_2->Draw("same");
1665 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS4rebin_2,0.8);
1666                         Resolution_E_dPt_Pt_ITS4rebin_2->SetMarkerColor(kCyan+2);
1667                         Resolution_E_dPt_Pt_ITS4rebin_2->SetLineColor(kCyan+2);
1668                         Resolution_E_dPt_Pt_ITS4rebin_2->Draw("same");
1669                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS5rebin_2,0.8);
1670                         Resolution_E_dPt_Pt_ITS5rebin_2->SetMarkerColor(kGreen+2);
1671                         Resolution_E_dPt_Pt_ITS5rebin_2->SetLineColor(kGreen+2);
1672                         Resolution_E_dPt_Pt_ITS5rebin_2->Draw("same");
1673                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS6rebin_2,0.8);
1674                         Resolution_E_dPt_Pt_ITS6rebin_2->SetMarkerColor(kMagenta+2);
1675                         Resolution_E_dPt_Pt_ITS6rebin_2->SetLineColor(kMagenta+2);
1676                         Resolution_E_dPt_Pt_ITS6rebin_2->Draw("same");
1677                         leg2->Draw("same");
1678                 pad_c2->cd(2)->Update();        
1679
1680
1681                 c2->Update();
1682
1683                 //************************************ Resolution P dPt vs Pt **********************************
1684                 
1685                 ps_characteristics->NewPage();
1686                 
1687                 TCanvas * c3 = new TCanvas("c3","",700,1000);  // gives the page size
1688                 pad_c3 = new TPad("pad_c3","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1689                 pad_c3->SetFillColor(0);
1690                 pad_c3->GetFrame()->SetFillColor(0);
1691                 pad_c3->SetBorderMode(0);
1692                 pad_c3->Divide(2,2);
1693                 pad_c3->Draw();
1694
1695                 pad_c3->cd(1)->SetLogz(1);
1696                 pad_c3->cd(1)->SetLogx(1);
1697                 pad_c3->cd(2)->SetLogz(1);
1698                 pad_c3->cd(2)->SetLogx(1);
1699
1700                 pad_c3->cd(1)->SetRightMargin(0.17);            
1701                 pad_c3->cd(1);
1702                         DrawAutoGammaHisto2D(   Resolution_P_dPt_Pt,
1703                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1704                                                                 kFALSE, 10., 140.,
1705                                                                 kFALSE, 0., 100.);
1706                 pad_c3->cd(1)->Update();        
1707
1708                 pad_c3->cd(2)->SetRightMargin(0.17);            
1709                 pad_c3->cd(2);
1710                         DrawAutoGammaHisto2D(   Resolution_P_dPt_Ptrebin,
1711                                                                 "", "p_{t} [GeV/c]", "dp_{t}/p_{t,MC} [%]", "",
1712                                                                 kFALSE, 10., 140.,
1713                                                                 kTRUE, 0., 100.);
1714                 pad_c3->cd(2)->Update();        
1715
1716
1717                 pad_c3->cd(3);
1718                         StylingSliceHistos(Resolution_P_dPt_Ptrebin_1,0.8);
1719                         Resolution_P_dPt_Ptrebin_1->SetMarkerColor(kRed+2);
1720                         Resolution_P_dPt_Ptrebin_1->SetLineColor(kBlue-8)       ;       
1721                         DrawResolutionGammaHisto( Resolution_P_dPt_Ptrebin_1, 
1722                                                                 "", "p_{t} [GeV/c]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
1723                                                                 kFALSE, 10., 140.,
1724                                                                 kTRUE, -2, 4.,
1725                                                                 kTRUE, 0.8, 100.);
1726                 pad_c3->cd(3)->Update();
1727
1728                 pad_c3->cd(4);
1729                         StylingSliceHistos(Resolution_P_dPt_Ptrebin_2,0.8);
1730                         Resolution_P_dPt_Ptrebin_2->SetMarkerColor(kRed+2);
1731                         Resolution_P_dPt_Ptrebin_2->SetLineColor(kBlue-8);
1732                         DrawResolutionGammaHisto( Resolution_P_dPt_Ptrebin_2, 
1733                                                         "", "p_{t} [GeV/c]", " #sigma dp_{t}/p_{t,MC} [%]", 
1734                                                                 kFALSE, 10., 140.,
1735                                                                 kTRUE, 0, 16.,
1736                                                                 kTRUE, 0.8, 100.);
1737                 pad_c3->cd(4)->Update();
1738
1739                 c3->Update();
1740
1741                 //******************************* Resoltution P dPt vs Pt ITS dependent ***************************
1742
1743                 ps_characteristics->NewPage();
1744                 
1745                 TCanvas * c4 = new TCanvas("c4","",700,1000);  // gives the page size
1746                 pad_c4 = new TPad("pad_c4","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1747                 pad_c4->SetFillColor(0);
1748                 pad_c4->GetFrame()->SetFillColor(0);
1749                 pad_c4->SetBorderMode(0);
1750                 pad_c4->Divide(1,2);
1751                 pad_c4->Draw();
1752
1753                 pad_c4->cd(1);
1754                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS0rebin_1,0.8);
1755                         Resolution_P_dPt_Pt_ITS0rebin_1->SetMarkerColor(kRed+2);
1756                         Resolution_P_dPt_Pt_ITS0rebin_1->SetLineColor(kRed+2);
1757                         DrawResolutionGammaHisto( Resolution_P_dPt_Pt_ITS0rebin_1, 
1758                                                                 "", "p_{t} [GeV/c]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
1759                                                                 kFALSE, 10., 140.,
1760                                                                 kTRUE, -20, 20.,
1761                                                                 kTRUE, 0., 18.);
1762 /*                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS1rebin_1,1);
1763                         Resolution_P_dPt_Pt_ITS1rebin_1->SetMarkerColor(kBlue+2);
1764                         Resolution_P_dPt_Pt_ITS1rebin_1->SetLineColor(kBlue+2);
1765                         Resolution_P_dPt_Pt_ITS1rebin_1->Draw("same");
1766 */                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS2rebin_1,0.8);
1767                         Resolution_P_dPt_Pt_ITS2rebin_1->SetMarkerColor(kViolet+2);
1768                         Resolution_P_dPt_Pt_ITS2rebin_1->SetLineColor(kViolet+2);
1769                         Resolution_P_dPt_Pt_ITS2rebin_1->Draw("same");
1770 /*                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS3rebin_1,1);
1771                         Resolution_P_dPt_Pt_ITS3rebin_1->SetMarkerColor(kOrange+2);
1772                         Resolution_P_dPt_Pt_ITS3rebin_1->SetLineColor(kOrange+2);
1773                         Resolution_P_dPt_Pt_ITS3rebin_1->Draw("same");
1774 */                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS4rebin_1,0.8);
1775                         Resolution_P_dPt_Pt_ITS4rebin_1->SetMarkerColor(kCyan+2);
1776                         Resolution_P_dPt_Pt_ITS4rebin_1->SetLineColor(kCyan+2);
1777                         Resolution_P_dPt_Pt_ITS4rebin_1->Draw("same");
1778                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS5rebin_1,0.8);
1779                         Resolution_P_dPt_Pt_ITS5rebin_1->SetMarkerColor(kGreen+2);
1780                         Resolution_P_dPt_Pt_ITS5rebin_1->SetLineColor(kGreen+2);
1781                         Resolution_P_dPt_Pt_ITS5rebin_1->Draw("same");
1782                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS6rebin_1,0.8);
1783                         Resolution_P_dPt_Pt_ITS6rebin_1->SetMarkerColor(kMagenta+2);
1784                         Resolution_P_dPt_Pt_ITS6rebin_1->SetLineColor(kMagenta+2);
1785                         Resolution_P_dPt_Pt_ITS6rebin_1->Draw("same");
1786                         leg2->Draw("same");
1787                 pad_c4->cd(1)->Update();        
1788
1789                 pad_c4->cd(2);
1790                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS0rebin_2,0.8);
1791                         Resolution_P_dPt_Pt_ITS0rebin_2->SetMarkerColor(kRed+2);
1792                         Resolution_P_dPt_Pt_ITS0rebin_2->SetLineColor(kRed+2);
1793                         DrawResolutionGammaHisto( Resolution_P_dPt_Pt_ITS0rebin_2, 
1794                                                                 "", "p_{t} [GeV/c]", "#sigma dp_{t}/p_{t,MC} [%]", 
1795                                                                 kFALSE, 10., 140.,
1796                                                                 kTRUE, -1, 30.,
1797                                                                 kTRUE, 0., 18.);
1798 /*                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS1rebin_2,1);
1799                         Resolution_P_dPt_Pt_ITS1rebin_2->SetMarkerColor(kBlue+2);
1800                         Resolution_P_dPt_Pt_ITS1rebin_2->SetLineColor(kBlue+2);
1801                         Resolution_P_dPt_Pt_ITS1rebin_2->Draw("same");
1802 */                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS2rebin_2,0.8);
1803                         Resolution_P_dPt_Pt_ITS2rebin_2->SetMarkerColor(kViolet+2);
1804                         Resolution_P_dPt_Pt_ITS2rebin_2->SetLineColor(kViolet+2);
1805                         Resolution_P_dPt_Pt_ITS2rebin_2->Draw("same");
1806 /*                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS3rebin_2,1);
1807                         Resolution_P_dPt_Pt_ITS3rebin_2->SetMarkerColor(kOrange+2);
1808                         Resolution_P_dPt_Pt_ITS3rebin_2->SetLineColor(kOrange+2);
1809                         Resolution_P_dPt_Pt_ITS3rebin_2->Draw("same");
1810 */                      StylingSliceHistos(     Resolution_P_dPt_Pt_ITS4rebin_2,0.8);
1811                         Resolution_P_dPt_Pt_ITS4rebin_2->SetMarkerColor(kCyan+2);
1812                         Resolution_P_dPt_Pt_ITS4rebin_2->SetLineColor(kCyan+2);
1813                         Resolution_P_dPt_Pt_ITS4rebin_2->Draw("same");
1814                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS5rebin_2,1);
1815                         Resolution_P_dPt_Pt_ITS5rebin_2->SetMarkerColor(kGreen+2);
1816                         Resolution_P_dPt_Pt_ITS5rebin_2->SetLineColor(kGreen+2);
1817                         Resolution_P_dPt_Pt_ITS5rebin_2->Draw("same");
1818                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS6rebin_2,0.8);
1819                         Resolution_P_dPt_Pt_ITS6rebin_2->SetMarkerColor(kMagenta+2);
1820                         Resolution_P_dPt_Pt_ITS6rebin_2->SetLineColor(kMagenta+2);
1821                         Resolution_P_dPt_Pt_ITS6rebin_2->Draw("same");
1822                         leg2->Draw("same");
1823                 pad_c4->cd(2)->Update();        
1824                 c4->Update();
1825
1826
1827                 //************************************ Resolution dZAbs vs R **********************************
1828                 
1829                 ps_characteristics->NewPage();
1830                 
1831                 TCanvas * c6 = new TCanvas("c6","",700,1000);  // gives the page size
1832                 pad_c6 = new TPad("pad_c6","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1833                 pad_c6->SetFillColor(0);
1834                 pad_c6->GetFrame()->SetFillColor(0);
1835                 pad_c6->SetBorderMode(0);
1836                 pad_c6->Divide(2,2);
1837                 pad_c6->Draw();
1838
1839                 pad_c6->cd(1)->SetLogz(1);
1840                 pad_c6->cd(1)->SetLogx(1);
1841                 pad_c6->cd(2)->SetLogz(1);
1842                 pad_c6->cd(2)->SetLogx(1);
1843
1844                 pad_c6->cd(1)->SetRightMargin(0.17);            
1845                 pad_c6->cd(1);
1846                         DrawAutoGammaHisto2D(   Resolution_dZAbs_VS_R,
1847                                                                 "", "R [cm]", "dZ [cm]", "",
1848                                                                 kFALSE, 10., 140.,
1849                                                                 kTRUE, 2.5, 180.);
1850                 pad_c6->cd(1)->Update();        
1851
1852                 pad_c6->cd(2)->SetRightMargin(0.17);            
1853                 pad_c6->cd(2);
1854                         DrawAutoGammaHisto2D(   Resolution_dZAbs_VS_Rrebin,
1855                                                                 "", "R [cm]", "dZ [cm]", "",
1856                                                                 kFALSE, 10., 140.,
1857                                                                 kFALSE, 0., 180.);
1858                 pad_c6->cd(2)->Update();        
1859
1860
1861                 pad_c6->cd(3);
1862                         StylingSliceHistos(Resolution_dZAbs_VS_Rrebin_1,0.8);
1863                         Resolution_dZAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
1864                         Resolution_dZAbs_VS_Rrebin_1->SetLineColor(kBlue-8)     ;       
1865                         DrawResolutionGammaHisto( Resolution_dZAbs_VS_Rrebin_1, 
1866                                                                 "", "R [cm]", "Peak pos. dZ [cm]", 
1867                                                                 kFALSE, 10., 140.,
1868                                                                 kFALSE, -0.2, 0.2,
1869                                                                 kTRUE, 0.8, 120.);
1870                 pad_c6->cd(3)->Update();
1871
1872                 pad_c6->cd(4);
1873                         StylingSliceHistos(Resolution_dZAbs_VS_Rrebin_2,0.8);
1874                         Resolution_dZAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
1875                         Resolution_dZAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
1876                         DrawResolutionGammaHisto( Resolution_dZAbs_VS_Rrebin_2, 
1877                                                         "", "R [cm]", "#sigma dZ [cm]", 
1878                                                                 kFALSE, 10., 140.,
1879                                                                 kTRUE, 0., 3.5,
1880                                                                 kTRUE, 0.8, 120.);
1881                 pad_c6->cd(4)->Update();
1882
1883                 c6->Update();
1884
1885                 //************************************ Resolution dRAbs vs R **********************************
1886                 
1887                 ps_characteristics->NewPage();
1888                 
1889                 TCanvas * c7 = new TCanvas("c7","",700,1000);  // gives the page size
1890                 pad_c7 = new TPad("pad_c7","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1891                 pad_c7->SetFillColor(0);
1892                 pad_c7->GetFrame()->SetFillColor(0);
1893                 pad_c7->SetBorderMode(0);
1894                 pad_c7->Divide(2,2);
1895                 pad_c7->Draw();
1896
1897                 pad_c7->cd(1)->SetLogz(1);
1898                 pad_c7->cd(1)->SetLogx(1);
1899                 pad_c7->cd(2)->SetLogz(1);
1900                 pad_c7->cd(2)->SetLogx(1);
1901
1902                 pad_c7->cd(1)->SetRightMargin(0.17);            
1903                 pad_c7->cd(1);
1904                         DrawAutoGammaHisto2D(   Resolution_dRAbs_VS_R,
1905                                                                 "", "R [cm]", "dR [cm]", "",
1906                                                                 kFALSE, 10., 140.,
1907                                                                 kTRUE, 2.5, 180.);
1908                 pad_c7->cd(1)->Update();        
1909
1910                 pad_c7->cd(2)->SetRightMargin(0.17);            
1911                 pad_c7->cd(2);
1912                         DrawAutoGammaHisto2D(   Resolution_dRAbs_VS_Rrebin,
1913                                                                 "", "R [cm]", "dR [cm]", "",
1914                                                                 kFALSE, 10., 140.,
1915                                                                 kFALSE, 0., 180.);
1916                 pad_c7->cd(2)->Update();        
1917
1918
1919                 pad_c7->cd(3);
1920                         StylingSliceHistos(Resolution_dRAbs_VS_Rrebin_1,0.8);
1921                         Resolution_dRAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
1922                         Resolution_dRAbs_VS_Rrebin_1->SetLineColor(kBlue-8)     ;       
1923                         DrawResolutionGammaHisto( Resolution_dRAbs_VS_Rrebin_1, 
1924                                                                 "", "R [cm]", "Peak pos. dR [cm]", 
1925                                                                 kFALSE, 10., 140.,
1926                                                                 kFALSE, -1, 1.5,
1927                                                                 kTRUE, 0.8, 120.);
1928                 pad_c7->cd(3)->Update();
1929
1930                 pad_c7->cd(4);
1931                         StylingSliceHistos(Resolution_dRAbs_VS_Rrebin_2,0.8);
1932                         Resolution_dRAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
1933                         Resolution_dRAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
1934                         DrawResolutionGammaHisto( Resolution_dRAbs_VS_Rrebin_2, 
1935                                                         "", "R [cm]", "#sigma dR [cm]", 
1936                                                                 kFALSE, 10., 140.,
1937                                                                 kTRUE, 0., 3.5,
1938                                                                 kTRUE, 0.8, 120.);
1939                 pad_c7->cd(4)->Update();
1940
1941                 c7->Update();
1942
1943                 //************************************ Resolution dPhiAbs vs R **********************************
1944                 
1945                 ps_characteristics->NewPage();
1946                 
1947                 TCanvas * c8 = new TCanvas("c8","",700,1000);  // gives the page size
1948                 pad_c8 = new TPad("pad_c8","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
1949                 pad_c8->SetFillColor(0);
1950                 pad_c8->GetFrame()->SetFillColor(0);
1951                 pad_c8->SetBorderMode(0);
1952                 pad_c8->Divide(2,2);
1953                 pad_c8->Draw();
1954
1955                 pad_c8->cd(1)->SetLogz(1);
1956                 pad_c8->cd(1)->SetLogx(1);
1957                 pad_c8->cd(2)->SetLogz(1);
1958                 pad_c8->cd(2)->SetLogx(1);
1959
1960                 pad_c8->cd(1)->SetRightMargin(0.17);            
1961                 pad_c8->cd(1);
1962                         DrawAutoGammaHisto2D(   Resolution_dPhiAbs_VS_R,
1963                                                                 "", "R [cm]", "d#phi[rad]", "",
1964                                                                 kFALSE, 10., 140.,
1965                                                                 kTRUE, 2.5, 180.);
1966                 pad_c8->cd(1)->Update();        
1967
1968                 pad_c8->cd(2)->SetRightMargin(0.17);            
1969                 pad_c8->cd(2);
1970                         DrawAutoGammaHisto2D(   Resolution_dPhiAbs_VS_Rrebin,
1971                                                                 "", "R [cm]", "d#phi[rad]", "",
1972                                                                 kFALSE, 10., 140.,
1973                                                                 kTRUE, 0., 180.);
1974                 pad_c8->cd(2)->Update();        
1975
1976
1977                 pad_c8->cd(3);
1978                         StylingSliceHistos(Resolution_dPhiAbs_VS_Rrebin_1,0.8);
1979                         Resolution_dPhiAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
1980                         Resolution_dPhiAbs_VS_Rrebin_1->SetLineColor(kBlue-8)   ;       
1981                         DrawResolutionGammaHisto( Resolution_dPhiAbs_VS_Rrebin_1, 
1982                                                                 "", "R [cm]", "Peak pos. d#phi[rad]", 
1983                                                                 kFALSE, 10., 140.,
1984                                                                 kFALSE, -0.0005, 0.001,
1985                                                                 kTRUE, 0.8, 120.);
1986                 pad_c8->cd(3)->Update();
1987
1988                 pad_c8->cd(4);
1989                         StylingSliceHistos(Resolution_dPhiAbs_VS_Rrebin_2,0.8);
1990                         Resolution_dPhiAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
1991                         Resolution_dPhiAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
1992                         DrawResolutionGammaHisto( Resolution_dPhiAbs_VS_Rrebin_2, 
1993                                                         "", "R [cm]", "#sigma d#phi[rad]", 
1994                                                                 kFALSE, 10., 140.,
1995                                                                 kTRUE, 0.0, 0.01,
1996                                                                 kTRUE, 0.8, 120.);
1997                 pad_c8->cd(4)->Update();
1998
1999                 c8->Update();
2000
2001                 //************************************ Resolution dpt vs R **********************************
2002                 
2003                 ps_characteristics->NewPage();
2004                 
2005                 TCanvas * c9 = new TCanvas("c9","",700,1000);  // gives the page size
2006                 pad_c9 = new TPad("pad_c9","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
2007                 pad_c9->SetFillColor(0);
2008                 pad_c9->GetFrame()->SetFillColor(0);
2009                 pad_c9->SetBorderMode(0);
2010                 pad_c9->Divide(2,2);
2011                 pad_c9->Draw();
2012
2013                 pad_c9->cd(1)->SetLogz(1);
2014                 pad_c9->cd(1)->SetLogx(1);
2015                 pad_c9->cd(2)->SetLogz(1);
2016                 pad_c9->cd(2)->SetLogx(1);
2017
2018                 pad_c9->cd(1)->SetRightMargin(0.17);            
2019                 pad_c9->cd(1);
2020                         DrawAutoGammaHisto2D(   Resolution_R_dPt,
2021                                                                 "", "R [cm]", "dp_{t}/p_{t,MC} [%]", "",
2022                                                                 kFALSE, 10., 140.,
2023                                                                 kTRUE, 2.5, 180.);
2024                 pad_c9->cd(1)->Update();        
2025
2026                 pad_c9->cd(2)->SetRightMargin(0.17);            
2027                 pad_c9->cd(2);
2028                         DrawAutoGammaHisto2D(   Resolution_R_dPtrebin,
2029                                                                 "", "R [cm]", "dp_{t}/p_{t,MC} [%]", "",
2030                                                                 kFALSE, 10., 140.,
2031                                                                 kTRUE, 0., 180.);
2032                 pad_c9->cd(2)->Update();        
2033
2034
2035                 pad_c9->cd(3);
2036                         StylingSliceHistos(Resolution_R_dPtrebin_1,0.8);
2037                         Resolution_R_dPtrebin_1->SetMarkerColor(kRed+2);
2038                         Resolution_R_dPtrebin_1->SetLineColor(kBlue-8)  ;       
2039                         DrawResolutionGammaHisto( Resolution_R_dPtrebin_1, 
2040                                                                 "", "R [cm]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
2041                                                                 kFALSE, 10., 140.,
2042                                                                 kFALSE, -0.001, 0.001,
2043                                                                 kTRUE, 0.8, 120.);
2044                 pad_c9->cd(3)->Update();
2045
2046                 pad_c9->cd(4);
2047                         StylingSliceHistos(Resolution_R_dPtrebin_2,0.8);
2048                         Resolution_R_dPtrebin_2->SetMarkerColor(kRed+2);
2049                         Resolution_R_dPtrebin_2->SetLineColor(kBlue-8);
2050                         DrawResolutionGammaHisto( Resolution_R_dPtrebin_2, 
2051                                                         "", "R [cm]", "#sigma dp_{t}/p_{t,MC} [%]", 
2052                                                                 kFALSE, 10., 140.,
2053                                                                 kTRUE, 0., 5,
2054                                                                 kTRUE, 0.8, 120.);
2055                 pad_c9->cd(4)->Update();
2056
2057                 c9->Update();
2058
2059 //************************* Fitting for dPt in phi ********************************************************
2060                 ps_characteristics->NewPage();
2061                 
2062                 TCanvas * c10 = new TCanvas("c10","",700,1000);  // gives the page size
2063                 pad_c10 = new TPad("pad_c10","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
2064                 pad_c10->SetFillColor(0);
2065                 pad_c10->GetFrame()->SetFillColor(0);
2066                 pad_c10->SetBorderMode(0);
2067                 pad_c10->Divide(2,3);
2068                 pad_c10->Draw();
2069
2070
2071                 pad_c10->cd(1);
2072                         StylingSliceHistos(Resolution_Gamma_dPt_Phi_1,0.8);
2073                         Resolution_Gamma_dPt_Phi_1->SetMarkerColor(kRed+2);
2074                         Resolution_Gamma_dPt_Phi_1->SetLineColor(kBlue-8)       ;       
2075                         DrawResolutionGammaHisto( Resolution_Gamma_dPt_Phi_1, 
2076                                                                 "", "#phi [rad]", "Peak pos. dp_{t}/p_{t,MC} [%] Photon", 
2077                                                                 kFALSE, 10., 140.,
2078                                                                 kFALSE, 0., 1.8,
2079                                                                 kFALSE, 0.8, 180.);
2080                 pad_c10->cd(1)->Update();       
2081
2082                 pad_c10->cd(2);
2083                         StylingSliceHistos(Resolution_Gamma_dPt_Phi_2,0.8);
2084                         Resolution_Gamma_dPt_Phi_2->SetMarkerColor(kRed+2);
2085                         Resolution_Gamma_dPt_Phi_2->SetLineColor(kBlue-8)       ;       
2086                         DrawResolutionGammaHisto( Resolution_Gamma_dPt_Phi_2, 
2087                                                                 "", "#phi [rad]", "#sigma dp_{t}/p_{t,MC} [%] Photon", 
2088                                                                 kFALSE, 10., 140.,
2089                                                                 kTRUE, 0., 1.8,
2090                                                                 kFALSE, 0.8, 180.);             
2091                 pad_c10->cd(2)->Update();       
2092
2093                 pad_c10->cd(3);
2094                         StylingSliceHistos(Resolution_E_dPt_Phi_1,0.8);
2095                         Resolution_E_dPt_Phi_1->SetMarkerColor(kRed+2);
2096                         Resolution_E_dPt_Phi_1->SetLineColor(kBlue-8)   ;       
2097                         DrawResolutionGammaHisto( Resolution_E_dPt_Phi_1, 
2098                                                                 "", "#phi [rad]", "Peak pos. dp_{t}/p_{t,MC} [%] Electron", 
2099                                                                 kFALSE, 10., 140.,
2100                                                                 kFALSE, -0.001, 0.001,
2101                                                                 kFALSE, 0.8, 180.);
2102                 pad_c10->cd(3)->Update();       
2103
2104                 pad_c10->cd(4);
2105                         StylingSliceHistos(Resolution_E_dPt_Phi_2,0.8);
2106                         Resolution_E_dPt_Phi_2->SetMarkerColor(kRed+2);
2107                         Resolution_E_dPt_Phi_2->SetLineColor(kBlue-8)   ;       
2108                         DrawResolutionGammaHisto( Resolution_E_dPt_Phi_2, 
2109                                                                 "", "#phi [rad]", "#sigma dp_{t}/p_{t,MC} [%] Electron", 
2110                                                                 kFALSE, 10., 140.,
2111                                                                 kTRUE, 0., 1.8,
2112                                                                 kFALSE, 0.8, 180.);             
2113                 pad_c10->cd(4)->Update();       
2114
2115                 pad_c10->cd(5);
2116                         StylingSliceHistos(Resolution_P_dPt_Phi_1,0.8);
2117                         Resolution_P_dPt_Phi_1->SetMarkerColor(kRed+2);
2118                         Resolution_P_dPt_Phi_1->SetLineColor(kBlue-8)   ;       
2119                         DrawResolutionGammaHisto( Resolution_P_dPt_Phi_1, 
2120                                                                 "", "#phi [rad]", "Peak pos. dp_{t}/p_{t,MC} [%] Positron", 
2121                                                                 kFALSE, 10., 140.,
2122                                                                 kFALSE, -0.001, 0.001,
2123                                                                 kFALSE, 0.8, 180.);
2124                 pad_c10->cd(5)->Update();       
2125
2126                 pad_c10->cd(6);
2127                         StylingSliceHistos(Resolution_P_dPt_Phi_2,0.8);
2128                         Resolution_P_dPt_Phi_2->SetMarkerColor(kRed+2);
2129                         Resolution_P_dPt_Phi_2->SetLineColor(kBlue-8)   ;       
2130                         DrawResolutionGammaHisto( Resolution_P_dPt_Phi_2, 
2131                                                                 "", "#phi [rad]", "#sigma dp_{t}/p_{t,MC} [%] Positron", 
2132                                                                 kFALSE, 10., 140.,
2133                                                                 kTRUE, 0., 1.8,
2134                                                                 kFALSE, 0.8, 180.);             
2135                 pad_c10->cd(6)->Update();       
2136                 c10->Update();
2137
2138                 ps_characteristics->NewPage();
2139
2140 //******************************** TRD investigation ******************************************************             
2141                 TCanvas * c11 = new TCanvas("c11","",700,1000);  // gives the page size
2142                 pad_c11 = new TPad("pad_c11","",0.05,0.05,0.95,0.85,0);   // gives the size of the histo areas 
2143                 pad_c11->SetFillColor(0);
2144                 pad_c11->GetFrame()->SetFillColor(0);
2145                 pad_c11->SetBorderMode(0);
2146                 pad_c11->Divide(2,2);
2147                 pad_c11->Draw();
2148
2149                 pad_c11->cd(1)->SetLogz(1);
2150                 pad_c11->cd(1)->SetLogx(1);
2151                 pad_c11->cd(2)->SetLogz(1);
2152                 pad_c11->cd(2)->SetLogx(1);
2153                 pad_c11->cd(3)->SetLogz(1);
2154                 pad_c11->cd(3)->SetLogx(1);
2155                 pad_c11->cd(4)->SetLogz(1);
2156                 pad_c11->cd(4)->SetLogx(1);
2157
2158
2159                 pad_c11->cd(1)->SetRightMargin(0.17);           
2160                 pad_c11->cd(1);
2161                         DrawAutoGammaHisto2D(   Resolution_E_nTRDclusters_ESDPt,
2162                                                                 "", "p_{t} [GeV/c]", "N_{clusters} Electron", "",
2163                                                                 kFALSE, 10., 140.,
2164                                                                 kTRUE, 0.1, 180.);
2165                 pad_c11->cd(1)->Update();       
2166
2167                 pad_c11->cd(2)->SetRightMargin(0.17);           
2168                 pad_c11->cd(2);
2169                         DrawAutoGammaHisto2D(   Resolution_P_nTRDclusters_ESDPt,
2170                                                                 "", "p_{t} [GeV/c]", "N_{clusters} Positron", "",
2171                                                                 kFALSE, 10., 140.,
2172                                                                 kTRUE, 0.1, 180.);
2173                 pad_c11->cd(2)->Update();       
2174
2175                 pad_c11->cd(3)->SetRightMargin(0.17);           
2176                 pad_c11->cd(3);
2177                         DrawAutoGammaHisto2D(   Resolution_E_nTRDtracklets_ESDPt,
2178                                                                 "", "p_{t} [GeV/c]", "N_{tracklets} Electron", "",
2179                                                                 kFALSE, 10., 140.,
2180                                                                 kTRUE, 0.1, 180.);
2181                 pad_c11->cd(3)->Update();       
2182
2183                 pad_c11->cd(4)->SetRightMargin(0.17);           
2184                 pad_c11->cd(4);
2185                         DrawAutoGammaHisto2D(   Resolution_P_nTRDtracklets_ESDPt,
2186                                                                 "", "p_{t} [GeV/c]", "N_{tracklets} Positron", "",
2187                                                                 kFALSE, 10., 140.,
2188                                                                 kTRUE, 0.1, 180.);
2189                 pad_c11->cd(4)->Update();       
2190
2191         
2192                 c11->Update();
2193
2194
2195
2196
2197                 ps_characteristics->Close();
2198 }
2199
2200 //****************************************************************************************************************
2201 //************************************ single plotting for better resolution *************************************
2202 //****************************************************************************************************************
2203
2204
2205 if(SinglePlots){
2206
2207                 leg3 = new TLegend( 0.7,0.75,0.92,0.9);
2208                 leg3->SetTextSize(0.03);                        
2209                 leg3->SetFillColor(0);                  
2210                 leg3->AddEntry(Resolution_Gamma_dPt_Phi_2,("Photons"));         
2211                 leg3->AddEntry(Resolution_E_dPt_Phi_2,("Electrons"));
2212                 leg3->AddEntry(Resolution_P_dPt_Phi_2,("Positrons"));
2213
2214
2215                 
2216     // ----------------------- Resolution dPt vs Phi ------------------------------------------------------------
2217                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2218                 c2_2->cd();
2219                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2220                 pad_c11->SetFillColor(0);
2221                 pad_c11->GetFrame()->SetFillColor(0);
2222                 pad_c11->SetBorderMode(0);
2223                 pad_c11->Divide(1,2);
2224                 pad_c11->Draw();
2225                 pad_c11->cd(1);
2226                         pad_c11->cd(1)->SetBottomMargin(0.005);
2227                         StylingSliceHistos(Resolution_E_dPt_Phi_1,0.8);
2228                         Resolution_E_dPt_Phi_1->SetMarkerColor(kBlue+2);
2229                         Resolution_E_dPt_Phi_1->SetLineColor(kBlue-9)   ;       
2230                         DrawResolutionGammaHisto( Resolution_E_dPt_Phi_1, 
2231                                                                 "", "#phi [rad]", "Peak pos. dp_{t}/p_{t,MC} [%]", 
2232                                                                 kFALSE, 10., 140.,
2233                                                                 kFALSE, -0.001, 0.001,
2234                                                                 kFALSE, 0.8, 180.);             
2235                         StylingSliceHistos(Resolution_P_dPt_Phi_1,0.8);
2236                         Resolution_P_dPt_Phi_1->SetMarkerColor(kRed+2);
2237                         Resolution_P_dPt_Phi_1->SetLineColor(kRed-9)    ;       
2238                         Resolution_P_dPt_Phi_1->Draw("same");
2239                         StylingSliceHistos(Resolution_Gamma_dPt_Phi_1,0.8);
2240                         Resolution_Gamma_dPt_Phi_1->SetMarkerColor(kCyan+3);
2241                         Resolution_Gamma_dPt_Phi_1->SetLineColor(kCyan-9)       ;       
2242                         Resolution_Gamma_dPt_Phi_1->Draw("same");               
2243                         leg3->Draw("same");
2244                         DrawGammaLines(-TMath::Pi(), TMath::Pi(), 0,0,0.005);
2245                 pad_c11->cd(2)->Update();
2246                 pad_c11->cd(2);
2247                         pad_c11->cd(2)->SetTopMargin(0+0.01);
2248                         StylingSliceHistos(Resolution_E_dPt_Phi_2,0.8);
2249                         Resolution_E_dPt_Phi_2->SetMarkerColor(kBlue+2);
2250                         Resolution_E_dPt_Phi_2->SetLineColor(kBlue-9)   ;       
2251                         DrawResolutionGammaHisto( Resolution_E_dPt_Phi_2, 
2252                                                                 "", "#phi [rad]", "#sigma dp_{t}/p_{t,MC} [%]", 
2253                                                                 kFALSE, 10., 140.,
2254                                                                 kTRUE, 0, 6.,
2255                                                                 kFALSE, 0.8, 180.);             
2256                         StylingSliceHistos(Resolution_P_dPt_Phi_2,0.8);
2257                         Resolution_P_dPt_Phi_2->SetMarkerColor(kRed+2);
2258                         Resolution_P_dPt_Phi_2->SetLineColor(kRed-9)    ;       
2259                         Resolution_P_dPt_Phi_2->Draw("same");
2260                         StylingSliceHistos(Resolution_Gamma_dPt_Phi_2,0.8);
2261                         Resolution_Gamma_dPt_Phi_2->SetMarkerColor(kCyan+3);
2262                         Resolution_Gamma_dPt_Phi_2->SetLineColor(kCyan-9)       ;       
2263                         Resolution_Gamma_dPt_Phi_2->Draw("same");               
2264 //                      leg3->Draw("same");
2265                 c2_2->Update(); 
2266                 c2_2->SaveAs(Form("%s%s/Resolution_dPt_Phi_1.%s",path,suffix,suffix));
2267                 delete pad_c11; 
2268                 delete c2_2;
2269
2270         // ---------------------------- Resolution Electron, Gamma and Positron dPt s Pt -----------------------------------------      
2271                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2272                 c2_2->cd();
2273                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2274                 pad_c11->SetFillColor(0);
2275                 pad_c11->GetFrame()->SetFillColor(0);
2276                 pad_c11->SetBorderMode(0);
2277                 pad_c11->Divide(1,2);
2278                 pad_c11->Draw();
2279
2280                 pad_c11->cd(1);
2281                         pad_c11->cd(1)->SetBottomMargin(0.005);
2282                         StylingSliceHistos(Resolution_E_dPt_Ptrebin_1,0.8);
2283                         Resolution_E_dPt_Ptrebin_1->SetMarkerColor(kBlue+2);
2284                         Resolution_E_dPt_Ptrebin_1->SetLineColor(kBlue-8);
2285                         DrawResolutionGammaHisto( Resolution_E_dPt_Ptrebin_1, 
2286                                                         "", "p_{t} [GeV/c]", " Peak position dp_{t}/p_{t,MC} [%]", 
2287                                                                 kFALSE, 10., 140.,
2288                                                                 kTRUE, -1.9, 3.,
2289                                                                 kTRUE, 0.8, 10.);
2290                         StylingSliceHistos(Resolution_P_dPt_Ptrebin_1,0.8);
2291                         Resolution_P_dPt_Ptrebin_1->SetMarkerColor(kRed+2);
2292                         Resolution_P_dPt_Ptrebin_1->SetLineColor(kRed-9)        ;       
2293                         Resolution_P_dPt_Ptrebin_1->Draw("same");
2294                         StylingSliceHistos(Resolution_Gamma_dPt_Ptrebin_1,0.8);
2295                         Resolution_Gamma_dPt_Ptrebin_1->SetMarkerColor(kCyan+3);
2296                         Resolution_Gamma_dPt_Ptrebin_1->SetLineColor(kCyan-9)   ;       
2297                         Resolution_Gamma_dPt_Ptrebin_1->Draw("same");
2298                         DrawGammaLines(0.8, 50, 0,0,0.005);             
2299                         leg3->Draw("same");
2300                 pad_c11->cd(2)->Update();
2301                 pad_c11->cd(2);
2302                         pad_c11->cd(2)->SetTopMargin(0+0.01);
2303                         StylingSliceHistos(Resolution_E_dPt_Ptrebin_2,0.8);
2304                         Resolution_E_dPt_Ptrebin_2->SetMarkerColor(kBlue+2);
2305                         Resolution_E_dPt_Ptrebin_2->SetLineColor(kBlue-8);
2306                         DrawResolutionGammaHisto( Resolution_E_dPt_Ptrebin_2, 
2307                                                         "", "p_{t} [GeV/c]", " #sigma dp_{t}/p_{t,MC} [%]", 
2308                                                                 kFALSE, 10., 140.,
2309                                                                 kTRUE, 0, 21.,
2310                                                                 kTRUE, 0.8, 10.);
2311                         StylingSliceHistos(Resolution_P_dPt_Ptrebin_2,0.8);
2312                         Resolution_P_dPt_Ptrebin_2->SetMarkerColor(kRed+2);
2313                         Resolution_P_dPt_Ptrebin_2->SetLineColor(kRed-9)        ;       
2314                         Resolution_P_dPt_Ptrebin_2->Draw("same");
2315                         StylingSliceHistos(Resolution_Gamma_dPt_Ptrebin_2,0.8);
2316                         Resolution_Gamma_dPt_Ptrebin_2->SetMarkerColor(kCyan+3);
2317                         Resolution_Gamma_dPt_Ptrebin_2->SetLineColor(kCyan-9)   ;       
2318                         Resolution_Gamma_dPt_Ptrebin_2->Draw("same");           
2319                 pad_c11->cd(2)->Update();
2320                 c2_2->Update(); 
2321                 c2_2->SaveAs(Form("%s%s/Resolution_dPt_Pt_all.%s",path,suffix,suffix));
2322                 delete pad_c11; 
2323                 delete c2_2;
2324
2325         // ----------------------------- Resolution dPhiAbs vs R ---------------------------------------
2326                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2327                 c2_2->cd();
2328                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2329                 pad_c11->SetFillColor(0);
2330                 pad_c11->GetFrame()->SetFillColor(0);
2331                 pad_c11->SetBorderMode(0);
2332                 pad_c11->Divide(1,2);
2333                 pad_c11->Draw();
2334
2335                 pad_c11->cd(1);
2336                         pad_c11->cd(1)->SetBottomMargin(0.005);
2337                         StylingSliceHistos(Resolution_dPhiAbs_VS_Rrebin_1,0.8);
2338                         Resolution_dPhiAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
2339                         Resolution_dPhiAbs_VS_Rrebin_1->SetLineColor(kBlue-8)   ;       
2340                         DrawResolutionGammaHisto( Resolution_dPhiAbs_VS_Rrebin_1, 
2341                                                                 "", "R [cm]", "Peak position d#phi [rad]", 
2342                                                                 kFALSE, 10., 140.,
2343                                                                 kTRUE, -0.00038, 0.0004,
2344                                                                 kTRUE, 0.8, 120.);
2345                         DrawGammaLines(0.8, 120, 0,0,0.005);
2346                 pad_c11->cd(1)->Update();
2347                 pad_c11->cd(2);
2348                         pad_c11->cd(2)->SetTopMargin(0+0.04);
2349                         StylingSliceHistos(Resolution_dPhiAbs_VS_Rrebin_2,0.8);
2350                         Resolution_dPhiAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
2351                         Resolution_dPhiAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
2352                         DrawResolutionGammaHisto( Resolution_dPhiAbs_VS_Rrebin_2, 
2353                                                         "", "R [cm]", "#sigma d#phi [rad]", 
2354                                                                 kFALSE, 10., 140.,
2355                                                                 kFALSE, 0.0, 0.00375,
2356                                                                 kTRUE, 0.8, 120.);
2357                 pad_c11->cd(2)->Update();
2358                 c2_2->Update(); 
2359                 c2_2->SaveAs(Form("%s%s/Resolution_dphiAbs_R.%s",path,suffix,suffix));
2360                 delete pad_c11; 
2361                 delete c2_2;
2362
2363         // ----------------------------- Resolution dPt vs R -------------------------------
2364                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2365                 c2_2->cd();
2366                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2367                 pad_c11->SetFillColor(0);
2368                 pad_c11->GetFrame()->SetFillColor(0);
2369                 pad_c11->SetBorderMode(0);
2370                 pad_c11->Divide(1,2);
2371                 pad_c11->Draw();
2372
2373                 pad_c11->cd(1);
2374                         pad_c11->cd(1)->SetBottomMargin(0.005);
2375                         StylingSliceHistos(Resolution_R_dPtrebin_1,0.8);
2376                         Resolution_R_dPtrebin_1->SetMarkerColor(kRed+2);
2377                         Resolution_R_dPtrebin_1->SetLineColor(kBlue-8)  ;       
2378                         DrawResolutionGammaHisto( Resolution_R_dPtrebin_1, 
2379                                                                 "", "R [cm]", "Peak position dp_{t}/p_{t,MC} [%]", 
2380                                                                 kFALSE, 10., 140.,
2381                                                                 kTRUE, -1.7, 1.7,
2382                                                                 kTRUE, 0.8, 120.);
2383                         DrawGammaLines(0.8, 120, 0,0,0.005);
2384                 pad_c11->cd(2)->Update();
2385                 pad_c11->cd(2);
2386                         pad_c11->cd(2)->SetTopMargin(0+0.005);
2387                         StylingSliceHistos(Resolution_R_dPtrebin_2,0.8);
2388                         Resolution_R_dPtrebin_2->SetMarkerColor(kRed+2);
2389                         Resolution_R_dPtrebin_2->SetLineColor(kBlue-8);
2390                         DrawResolutionGammaHisto( Resolution_R_dPtrebin_2, 
2391                                                         "", "R [cm]", "#sigma dp_{t}/p_{t,MC} [%]", 
2392                                                                 kFALSE, 10., 140.,
2393                                                                 kTRUE, 0,4.15,
2394                                                                 kTRUE, 0.8, 120.);
2395                 pad_c11->cd(2)->Update();
2396                 c2_2->Update(); 
2397                 c2_2->SaveAs(Form("%s%s/Resolution_dPt_R.%s",path,suffix,suffix));
2398                 delete pad_c11; 
2399                 delete c2_2;
2400      
2401         // ---------------------------------- Resolution dRAbs vs R -------------------------------
2402                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2403                 c2_2->cd();
2404                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2405                 pad_c11->SetFillColor(0);
2406                 pad_c11->GetFrame()->SetFillColor(0);
2407                 pad_c11->SetBorderMode(0);
2408                 pad_c11->Divide(1,2);
2409                 pad_c11->Draw();
2410
2411                 pad_c11->cd(1);
2412                         pad_c11->cd(1)->SetBottomMargin(0.005);
2413                         StylingSliceHistos(Resolution_dRAbs_VS_Rrebin_1,0.8);
2414                         Resolution_dRAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
2415                         Resolution_dRAbs_VS_Rrebin_1->SetLineColor(kBlue-8)     ;       
2416                         DrawResolutionGammaHisto( Resolution_dRAbs_VS_Rrebin_1, 
2417                                                                 "", "R [cm]", "Peak pos. dR [cm]", 
2418                                                                 kFALSE, 10., 140.,
2419                                                                 kFALSE, -1, 1.5,
2420                                                                 kTRUE, 0.8, 120.);
2421                         DrawGammaLines(0.8, 120, 0,0,0.005);
2422                 pad_c11->cd(2)->Update();
2423                 pad_c11->cd(2);
2424                         pad_c11->cd(2)->SetTopMargin(0+0.01);
2425                         StylingSliceHistos(Resolution_dRAbs_VS_Rrebin_2,0.8);
2426                         Resolution_dRAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
2427                         Resolution_dRAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
2428                         DrawResolutionGammaHisto( Resolution_dRAbs_VS_Rrebin_2, 
2429                                                         "", "R [cm]", "#sigma dR [cm]", 
2430                                                                 kFALSE, 10., 140.,
2431                                                                 kTRUE, 0., 4.75,
2432                                                                 kTRUE, 0.8, 120.);
2433                 pad_c11->cd(2)->Update();
2434                 c2_2->Update(); 
2435                 c2_2->SaveAs(Form("%s%s/Resolution_dRAbs_R.%s",path,suffix,suffix));
2436                 delete pad_c11; 
2437                 delete c2_2;
2438
2439         // -------------------------------- Resolution dZAbs vs R ----------------------------- 
2440                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2441                 c2_2->cd();
2442                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2443                 pad_c11->SetFillColor(0);
2444                 pad_c11->GetFrame()->SetFillColor(0);
2445                 pad_c11->SetBorderMode(0);
2446                 pad_c11->Divide(1,2);
2447                 pad_c11->Draw();
2448
2449                 pad_c11->cd(1);
2450                         pad_c11->cd(1)->SetBottomMargin(0.005);
2451                         StylingSliceHistos(Resolution_dZAbs_VS_Rrebin_1,0.8);
2452                         Resolution_dZAbs_VS_Rrebin_1->SetMarkerColor(kRed+2);
2453                         Resolution_dZAbs_VS_Rrebin_1->SetLineColor(kBlue-8)     ;       
2454                         DrawResolutionGammaHisto( Resolution_dZAbs_VS_Rrebin_1, 
2455                                                                 "", "R [cm]", "Peak pos. dZ [cm]", 
2456                                                                 kFALSE, 10., 140.,
2457                                                                 kTRUE, -0.225, 0.2,
2458                                                                 kTRUE, 0.8, 120.);
2459                         DrawGammaLines(0.8, 120, 0,0,0.005);
2460                 pad_c11->cd(2)->Update();
2461                 pad_c11->cd(2);
2462                         pad_c11->cd(2)->SetTopMargin(0+0.005);
2463                         StylingSliceHistos(Resolution_dZAbs_VS_Rrebin_2,0.8);
2464                         Resolution_dZAbs_VS_Rrebin_2->SetMarkerColor(kRed+2);
2465                         Resolution_dZAbs_VS_Rrebin_2->SetLineColor(kBlue-8);
2466                         DrawResolutionGammaHisto( Resolution_dZAbs_VS_Rrebin_2, 
2467                                                         "", "R [cm]", "#sigma dZ [cm]", 
2468                                                                 kFALSE, 10., 140.,
2469                                                                 kTRUE, 0., 3.75,
2470                                                                 kTRUE, 0.8, 120.);
2471                 pad_c11->cd(2)->Update();
2472                 c2_2->Update(); 
2473                 c2_2->SaveAs(Form("%s%s/Resolution_dZAbs_R.%s",path,suffix,suffix));
2474                 delete pad_c11; 
2475                 delete c2_2;
2476
2477         // -------------------------------- Resolution dPt vs Pt for different ITS clusters -----------
2478                 TCanvas * c2_2 = new TCanvas("c2_2","",10,10,700,1000);  // gives the page size         
2479                 c2_2->cd();
2480                 pad_c11 = new TPad("pad_c11","",0,0,1,1,0);   // gives the size of the histo areas 
2481                 pad_c11->SetFillColor(0);
2482                 pad_c11->GetFrame()->SetFillColor(0);
2483                 pad_c11->SetBorderMode(0);
2484                 pad_c11->Divide(1,2);
2485                 pad_c11->Draw();
2486
2487                 pad_c11->cd(1);
2488                         pad_c11->cd(1)->SetBottomMargin(0.005);
2489                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS0rebin_2,0.8);
2490                         Resolution_E_dPt_Pt_ITS0rebin_2->SetMarkerColor(kRed+2);
2491                         Resolution_E_dPt_Pt_ITS0rebin_2->SetLineColor(kRed+2);
2492                         DrawResolutionGammaHisto( Resolution_E_dPt_Pt_ITS0rebin_2, 
2493                                                                 "", "p_{t} [GeV/c]", "#sigma dp_{t}/p_{t,MC} [%] for Electrons", 
2494                                                                 kFALSE, 10., 140.,
2495                                                                 kTRUE, -1, 30.,
2496                                                                 kTRUE, 0, 10.);
2497 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS1rebin_2,1);
2498                         Resolution_E_dPt_Pt_ITS1rebin_2->SetMarkerColor(kBlue+2);
2499                         Resolution_E_dPt_Pt_ITS1rebin_2->SetLineColor(kBlue+2);
2500                         Resolution_E_dPt_Pt_ITS1rebin_2->Draw("same");
2501 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS2rebin_2,0.8);
2502                         Resolution_E_dPt_Pt_ITS2rebin_2->SetMarkerColor(kViolet+2);
2503                         Resolution_E_dPt_Pt_ITS2rebin_2->SetLineColor(kViolet+2);
2504                         Resolution_E_dPt_Pt_ITS2rebin_2->Draw("same");
2505 /*                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS3rebin_2,1);
2506                         Resolution_E_dPt_Pt_ITS3rebin_2->SetMarkerColor(kOrange+2);
2507                         Resolution_E_dPt_Pt_ITS3rebin_2->SetLineColor(kOrange+2);
2508                         Resolution_E_dPt_Pt_ITS3rebin_2->Draw("same");
2509 */                      StylingSliceHistos(     Resolution_E_dPt_Pt_ITS4rebin_2,0.8);
2510                         Resolution_E_dPt_Pt_ITS4rebin_2->SetMarkerColor(kCyan+2);
2511                         Resolution_E_dPt_Pt_ITS4rebin_2->SetLineColor(kCyan+2);
2512                         Resolution_E_dPt_Pt_ITS4rebin_2->Draw("same");
2513                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS5rebin_2,0.8);
2514                         Resolution_E_dPt_Pt_ITS5rebin_2->SetMarkerColor(kGreen+2);
2515                         Resolution_E_dPt_Pt_ITS5rebin_2->SetLineColor(kGreen+2);
2516                         Resolution_E_dPt_Pt_ITS5rebin_2->Draw("same");
2517                         StylingSliceHistos(     Resolution_E_dPt_Pt_ITS6rebin_2,0.8);
2518                         Resolution_E_dPt_Pt_ITS6rebin_2->SetMarkerColor(kMagenta+2);
2519                         Resolution_E_dPt_Pt_ITS6rebin_2->SetLineColor(kMagenta+2);
2520                         Resolution_E_dPt_Pt_ITS6rebin_2->Draw("same");
2521                         leg2 = new TLegend( 0.7,0.72,0.92,0.9);
2522                         leg2->SetTextSize(0.03);                        
2523                         leg2->SetFillColor(0);                  
2524                         leg2->AddEntry(Resolution_E_dPt_Pt_ITS0rebin_2,("only TPC"));
2525         //              leg2->AddEntry(Resolution_E_dPt_Pt_ITS1rebin_2,("1 ITS cluster"));
2526                         leg2->AddEntry(Resolution_E_dPt_Pt_ITS2rebin_2,("2 ITS cluster"));
2527         //              leg2->AddEntry(Resolution_E_dPt_Pt_ITS3rebin_2,("3 ITS cluster"));
2528                         leg2->AddEntry(Resolution_E_dPt_Pt_ITS4rebin_2,("4 ITS cluster"));
2529                         leg2->AddEntry(Resolution_E_dPt_Pt_ITS5rebin_2,("5 ITS cluster"));
2530                         leg2->AddEntry(Resolution_E_dPt_Pt_ITS6rebin_2,("6 ITS cluster"));              
2531                         leg2->Draw("same");
2532                 pad_c11->cd(1)->Update();
2533                 pad_c11->cd(2);
2534                         pad_c11->cd(2)->SetTopMargin(0+0.01);
2535                         StylingSliceHistos(     Resolution_P_dPt_Pt_ITS0rebin_2,0.8);
2536                         Resolution_P_dPt_Pt_ITS0rebin_2->SetMarkerColor(kRed+2);
2537                         Resolution_P_dPt_Pt_ITS0rebin_2->SetLineColor(kRed+2);
2538                         DrawResolutionGammaHisto( Resolution_P_dPt_Pt_ITS0rebin_2, 
2539                                                &nb