]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/AliComparisonRes.cxx
Makin compiled macro
[u/mrichter/AliRoot.git] / PWG1 / AliComparisonRes.cxx
1 //------------------------------------------------------------------------------
2 // Implementation of AliComparisonRes class. It keeps information from 
3 // comparison of reconstructed and MC particle tracks. In addtion, 
4 // it keeps selection cuts used during comparison. The comparison 
5 // information is stored in the ROOT histograms. Analysis of these 
6 // histograms can be done by using Analyse() class function. The result of 
7 // the analysis (histograms/graphs) are stored in the folder which is
8 // a data member of AliComparisonRes.
9 //
10 // Author: J.Otwinowski 04/02/2008 
11 //------------------------------------------------------------------------------
12
13 /*
14  
15   // after running comparison task, read the file, and get component
16   gROOT->LoadMacro("$ALICE_ROOT/PWG1/Macros/LoadMyLibs.C");
17   LoadMyLibs();
18
19   TFile f("Output.root");
20   //AliComparisonRes * compObj = (AliComparisonRes*)f.Get("AliComparisonRes");
21   AliComparisonRes * compObj = (AliComparisonRes*)cOutput->FindObject("AliComparisonRes");
22  
23   // analyse comparison data
24   compObj->Analyse();
25
26   // the output histograms/graphs will be stored in the folder "folderRes" 
27   compObj->GetAnalysisFolder()->ls("*");
28
29   // user can save whole comparison object (or only folder with anlysed histograms) 
30   // in the seperate output file (e.g.)
31   TFile fout("Analysed_Res.root","recreate");
32   compObj->Write(); // compObj->GetAnalysisFolder()->Write();
33   fout.Close();
34
35 */
36
37 #include <iostream>
38
39 #include "TFile.h"
40 #include "TCint.h"
41 #include "TH3F.h"
42 #include "TH2F.h"
43 #include "TF1.h"
44 #include "TProfile.h"
45 #include "TProfile2D.h"
46 #include "TGraph2D.h"
47 #include "TCanvas.h"
48 #include "TGraph.h"
49
50 #include "AliESDEvent.h"   
51 #include "AliESD.h"
52 #include "AliESDfriend.h"
53 #include "AliESDfriendTrack.h"
54 #include "AliESDVertex.h"
55 #include "AliRecInfoCuts.h" 
56 #include "AliMCInfoCuts.h" 
57 #include "AliLog.h" 
58 #include "AliTracker.h" 
59
60 #include "AliMathBase.h"
61 #include "AliTreeDraw.h" 
62
63 #include "AliMCInfo.h" 
64 #include "AliESDRecInfo.h" 
65 #include "AliComparisonRes.h" 
66
67 using namespace std;
68
69 ClassImp(AliComparisonRes)
70
71 //_____________________________________________________________________________
72 AliComparisonRes::AliComparisonRes():
73   AliComparisonObject("AliComparisonRes"),
74
75   // Vertices
76   fMCVertex(0),  //-> MC primary vertex
77   fRecVertex(0), //-> Reconstructed primary vertex
78
79   // global observables
80   fPhiTanPtTPC(0),
81   fPhiTanPtTPCITS(0),
82
83   // Resolution 
84
85   // TPC only
86   fPtResolTPC(0),
87   fPtPullTPC(0),
88   fPhiResolTanTPC(0),
89   fTanResolTanTPC(0),
90   fPhiPullTanTPC(0),
91   fTanPullTanTPC(0),
92
93   // TPC+ITS
94   fPtResolTPCITS(0),
95   fPtPullTPCITS(0),
96   fPhiResolTanTPCITS(0),
97   fTanResolTanTPCITS(0),
98   fPhiPullTanTPCITS(0),
99   fTanPullTanTPCITS(0),
100
101   //
102   // Resolution constrained param
103   //
104   fCPhiResolTan(0),  // angular resolution -  constrained
105   fCTanResolTan(0),  // angular resolution -  constrained
106   fCPtResolTan(0),   // pt resolution      -  constrained
107   fCPhiPullTan(0),   // angular resolution -  constrained
108   fCTanPullTan(0),   // angular resolution -  constrained
109   fCPtPullTan(0),    // pt resolution      -  constrained
110
111   //
112   // Parametrisation histograms
113   //
114
115   f1Pt2ResolS1PtTPC(0),
116   f1Pt2ResolS1PtTPCITS(0),
117   fYResolS1PtTPC(0),
118   fYResolS1PtTPCITS(0),
119   fZResolS1PtTPC(0),
120   fZResolS1PtTPCITS(0),
121   fPhiResolS1PtTPC(0),
122   fPhiResolS1PtTPCITS(0),
123   fThetaResolS1PtTPC(0),
124   fThetaResolS1PtTPCITS(0),
125
126   // constrained
127   fC1Pt2ResolS1PtTPC(0),
128   fC1Pt2ResolS1PtTPCITS(0),
129   fCYResolS1PtTPC(0),
130   fCYResolS1PtTPCITS(0),
131   fCZResolS1PtTPC(0),
132   fCZResolS1PtTPCITS(0),
133   fCPhiResolS1PtTPC(0),
134   fCPhiResolS1PtTPCITS(0),
135   fCThetaResolS1PtTPC(0),
136   fCThetaResolS1PtTPCITS(0),
137
138   // Cuts 
139   fCutsRC(0),  
140   fCutsMC(0),  
141
142   // histogram folder 
143   fAnalysisFolder(0)
144 {
145   Init();
146 }
147
148 //_____________________________________________________________________________
149 AliComparisonRes::~AliComparisonRes(){
150   
151   // Vertices
152   if(fMCVertex) delete fMCVertex; fMCVertex=0;     
153   if(fRecVertex) delete fRecVertex; fRecVertex=0;     
154
155   // Global observables
156   //
157   if(fPhiTanPtTPC) delete fPhiTanPtTPC; fPhiTanPtTPC=0;     
158   if(fPhiTanPtTPCITS) delete fPhiTanPtTPCITS; fPhiTanPtTPCITS=0;     
159
160   // Resolution histograms
161   if(fPtResolTPC) delete fPtResolTPC; fPtResolTPC=0;     
162   if(fPtPullTPC) delete fPtPullTPC; fPtPullTPC=0;     
163   if(fPhiResolTanTPC) delete fPhiResolTanTPC; fPhiResolTanTPC=0;     
164   if(fTanResolTanTPC) delete fTanResolTanTPC; fTanResolTanTPC=0;     
165   if(fPhiPullTanTPC) delete fPhiPullTanTPC; fPhiPullTanTPC=0;     
166   if(fTanPullTanTPC) delete fTanPullTanTPC; fTanPullTanTPC=0;     
167
168   if(fPtResolTPCITS) delete fPtResolTPCITS; fPtResolTPCITS=0;     
169   if(fPtPullTPCITS) delete fPtPullTPCITS; fPtPullTPCITS=0;     
170   if(fPhiResolTanTPCITS) delete fPhiResolTanTPCITS; fPhiResolTanTPCITS=0;     
171   if(fTanResolTanTPCITS) delete fTanResolTanTPCITS; fTanResolTanTPCITS=0;     
172   if(fPhiPullTanTPCITS) delete fPhiPullTanTPCITS; fPhiPullTanTPCITS=0;     
173   if(fTanPullTanTPCITS) delete fTanPullTanTPCITS; fTanPullTanTPCITS=0;     
174   
175   // Resolution histograms (constrained param)
176   if(fCPhiResolTan) delete fCPhiResolTan; fCPhiResolTan=0;
177   if(fCTanResolTan) delete fCTanResolTan; fCTanResolTan=0;
178   if(fCPtResolTan)  delete fCPtResolTan;  fCPtResolTan=0; 
179   if(fCPhiPullTan)  delete fCPhiPullTan;  fCPhiPullTan=0;
180   if(fCTanPullTan)  delete fCTanPullTan;  fCTanPullTan=0;
181   if(fCPtPullTan)   delete fCPtPullTan;   fCPtPullTan=0;
182
183   // Parametrisation histograms
184   // 
185   if(f1Pt2ResolS1PtTPC) delete f1Pt2ResolS1PtTPC; f1Pt2ResolS1PtTPC=0;
186   if(f1Pt2ResolS1PtTPCITS) delete f1Pt2ResolS1PtTPCITS; f1Pt2ResolS1PtTPCITS=0;
187   if(fYResolS1PtTPC) delete fYResolS1PtTPC; fYResolS1PtTPC=0;
188   if(fYResolS1PtTPCITS) delete fYResolS1PtTPCITS; fYResolS1PtTPCITS=0;
189   if(fZResolS1PtTPC) delete fZResolS1PtTPC; fZResolS1PtTPC=0;
190   if(fZResolS1PtTPCITS) delete fZResolS1PtTPCITS; fZResolS1PtTPCITS=0;
191   if(fPhiResolS1PtTPC) delete fPhiResolS1PtTPC; fPhiResolS1PtTPC=0;
192   if(fPhiResolS1PtTPCITS) delete fPhiResolS1PtTPCITS; fPhiResolS1PtTPCITS=0;
193   if(fThetaResolS1PtTPC) delete fThetaResolS1PtTPC; fThetaResolS1PtTPC=0;
194   if(fThetaResolS1PtTPCITS) delete fThetaResolS1PtTPCITS; fThetaResolS1PtTPCITS=0;
195
196   // constrained
197   if(fC1Pt2ResolS1PtTPC) delete fC1Pt2ResolS1PtTPC; fC1Pt2ResolS1PtTPC=0;
198   if(fC1Pt2ResolS1PtTPCITS) delete fC1Pt2ResolS1PtTPCITS; fC1Pt2ResolS1PtTPCITS=0;
199   if(fCYResolS1PtTPC) delete fCYResolS1PtTPC; fCYResolS1PtTPC=0;
200   if(fCYResolS1PtTPCITS) delete fCYResolS1PtTPCITS; fCYResolS1PtTPCITS=0;
201   if(fCZResolS1PtTPC) delete fCZResolS1PtTPC; fCZResolS1PtTPC=0;
202   if(fCZResolS1PtTPCITS) delete fCZResolS1PtTPCITS; fCZResolS1PtTPCITS=0;
203   if(fCPhiResolS1PtTPC) delete fCPhiResolS1PtTPC; fCPhiResolS1PtTPC=0;
204   if(fCPhiResolS1PtTPCITS) delete fCPhiResolS1PtTPCITS; fCPhiResolS1PtTPCITS=0;
205   if(fCThetaResolS1PtTPC) delete fCThetaResolS1PtTPC; fCThetaResolS1PtTPC=0;
206   if(fCThetaResolS1PtTPCITS) delete fCThetaResolS1PtTPCITS; fCThetaResolS1PtTPCITS=0;
207
208   if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;
209 }
210
211 //_____________________________________________________________________________
212 void AliComparisonRes::Init(){
213
214   // Control histograms
215   fMCVertex = new TH3F("MCVertex","MC vertex Xv:Yv:Zv",100,-0.05,0.05,100,-0.05,0.05,100,-10,10);
216   fMCVertex->SetXTitle("Xv [cm]");
217   fMCVertex->SetYTitle("Yv [cm]");
218   fMCVertex->SetZTitle("Zv [cm]");
219
220   fRecVertex = new TH3F("RecVertex","Rec prim. vertex Xv:Yv:Zv",100,-0.01,0.01,100,-0.01,0.01,100,-0.5,0.5);
221   fRecVertex->SetXTitle("Xv [cm]");
222   fRecVertex->SetYTitle("Yv [cm]");
223   fRecVertex->SetZTitle("Zv [cm]");
224
225   //
226   fPhiTanPtTPC = new TH3F("PhiTanPtTPC","phi vs tan#theta vs pt - TPC only",200,-3.5,3.5,50,-2,2,100,0.1,3.0);
227   fPhiTanPtTPC->SetXTitle("#phi [rad]");
228   fPhiTanPtTPC->SetYTitle("tan#theta");
229   fPhiTanPtTPC->SetZTitle("p_{t} [GeV]");
230
231   fPhiTanPtTPCITS = new TH3F("PhiTanPtTPCITS","phi vs tan#theta vs pt - TPC+ITS",200,-3.5,3.5,50,-2,2,100,0.1,3.0);
232   fPhiTanPtTPCITS->SetXTitle("#phi [rad]");
233   fPhiTanPtTPCITS->SetYTitle("tan#theta");
234   fPhiTanPtTPCITS->SetZTitle("p_{t} [GeV]");
235
236   //
237   fPtResolTPC = new TH2F("PtResolTPC","pt resol",10, 0.1,3,200,-0.2,0.2);
238   fPtResolTPC->SetXTitle("p_{t} [GeV]");
239   fPtResolTPC->SetYTitle("#Deltap_{t}/p_{t}");
240
241   fPtPullTPC = new TH2F("fPtPullTPC","pt pull",10, 0.1,3,200,-6,6);
242   fPtPullTPC->SetXTitle("p_{t} [GeV]");
243   fPtPullTPC->SetYTitle("#Deltap_{t}/#Sigma");
244
245   fPhiResolTanTPC = new TH2F("PhiResolTanTPC","PhiResolTanTPC",50, -2,2,200,-0.025,0.025);   
246   fPhiResolTanTPC->SetXTitle("tan(#theta)");
247   fPhiResolTanTPC->SetYTitle("#Delta#phi [rad]");
248
249   fTanResolTanTPC = new TH2F("TanResolTanTPC","TanResolTanTPC",50, -2,2,200,-0.025,0.025);
250   fTanResolTanTPC->SetXTitle("tan(#theta)");
251   fTanResolTanTPC->SetYTitle("#Delta#theta [rad]");
252
253   fPhiPullTanTPC = new TH2F("PhiPullTanTPC","PhiPullTanTPC",50, -2,2,200,-5,5);   
254   fPhiPullTanTPC->SetXTitle("Tan(#theta)");
255   fPhiPullTanTPC->SetYTitle("#Delta#phi/#Sigma");
256
257   fTanPullTanTPC = new TH2F("TanPullTanTPC","TanPullTanTPC",50, -2,2,200,-5,5);
258   fTanPullTanTPC->SetXTitle("Tan(#theta)");
259   fTanPullTanTPC->SetYTitle("#Delta#theta/#Sigma");
260
261   fPtResolTPCITS = new TH2F("PtResolTPCITS","pt resol",10, 0.1,3,200,-0.2,0.2);
262   fPtResolTPCITS->SetXTitle("p_{t} [GeV]");
263   fPtResolTPCITS->SetYTitle("#Deltap_{t}/p_{t}");
264
265   fPtPullTPCITS = new TH2F("fPtPullTPCITS","pt pull",10, 0.1,3,200,-6,6);
266   fPtPullTPCITS->SetXTitle("p_{t} [GeV]");
267   fPtPullTPCITS->SetYTitle("#Deltap_{t}/#Sigma");
268
269   fPhiResolTanTPCITS = new TH2F("PhiResolTanTPCITS","PhiResolTanTPCITS",50, -2,2,200,-0.025,0.025);   
270   fPhiResolTanTPCITS->SetXTitle("tan(#theta)");
271   fPhiResolTanTPCITS->SetYTitle("#Delta#phi [rad]");
272
273   fTanResolTanTPCITS = new TH2F("TanResolTanTPCITS","TanResolTanTPCITS",50, -2,2,200,-0.025,0.025);
274   fTanResolTanTPCITS->SetXTitle("tan(#theta)");
275   fTanResolTanTPCITS->SetYTitle("#Delta#theta [rad]");
276
277   fPhiPullTanTPCITS = new TH2F("PhiPullTanTPCITS","PhiPullTanTPCITS",50, -2,2,200,-5,5);   
278   fPhiPullTanTPCITS->SetXTitle("Tan(#theta)");
279   fPhiPullTanTPCITS->SetYTitle("#Delta#phi/#Sigma");
280
281   fTanPullTanTPCITS = new TH2F("TanPullTanTPCITS","TanPullTanTPCITS",50, -2,2,200,-5,5);
282   fTanPullTanTPCITS->SetXTitle("Tan(#theta)");
283   fTanPullTanTPCITS->SetYTitle("#Delta#theta/#Sigma");
284
285   // Resolution constrained param
286   fCPhiResolTan = new TH2F("CPhiResolTan","CPhiResolTan",50, -2,2,200,-0.025,0.025);   
287   fCPhiResolTan->SetXTitle("tan(#theta)");
288   fCPhiResolTan->SetYTitle("#Delta#phi [rad]");
289
290   fCTanResolTan = new TH2F("CTanResolTan","CTanResolTan",50, -2,2,200,-0.025,0.025);
291   fCTanResolTan->SetXTitle("tan(#theta)");
292   fCTanResolTan->SetYTitle("#Delta#theta [rad]");
293
294   fCPtResolTan=new TH2F("CPtResol","CPtResol",50, -2,2,200,-0.2,0.2);    
295   fCPtResolTan->SetXTitle("Tan(#theta)");
296   fCPtResolTan->SetYTitle("#Deltap_{t}/p_{t}");
297
298   fCPhiPullTan = new TH2F("CPhiPullTan","CPhiPullTan",50, -2,2,200,-5,5);   
299   fCPhiPullTan->SetXTitle("Tan(#theta)");
300   fCPhiPullTan->SetYTitle("#Delta#phi/#Sigma");
301
302   fCTanPullTan = new TH2F("CTanPullTan","CTanPullTan",50, -2,2,200,-5,5);
303   fCTanPullTan->SetXTitle("Tan(#theta)");
304   fCTanPullTan->SetYTitle("#Delta#theta/#Sigma");
305
306   fCPtPullTan=new TH2F("CPtPull","CPtPull",50, -2,2,200,-5,5);    
307   fCPtPullTan->SetXTitle("Tan(#theta)");
308   fCPtPullTan->SetYTitle("(1/mcp_{t}-1/p_{t})/#Sigma");
309   
310   //
311   // Parametrisation histograms
312   // 
313
314   f1Pt2ResolS1PtTPC = new TH2F("f1Pt2ResolS1PtTPC","(1/mcpt-1/pt)/(1+1/mcpt)^2 vs sqrt(1/pt))",100,0,3,200,-0.010,0.010);  
315   f1Pt2ResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
316   f1Pt2ResolS1PtTPC->SetYTitle("(1/mcp_{t}-1/p_{t})/(1+1/mcp_{t})^2)");
317
318   f1Pt2ResolS1PtTPCITS = new TH2F("f1Pt2ResolS1PtTPCITS","(1/mcpt-1/pt)/(1+1/mcpt)^2 vs sqrt(1/pt))",100,0,3,200,-0.010,0.010);  
319   f1Pt2ResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
320   f1Pt2ResolS1PtTPCITS->SetYTitle("(1/mcp_{t}-1/p_{t})/(1+1/mcp_{t})^2)");
321
322   fYResolS1PtTPC = new TH2F("fYResolS1PtTPC","fYResolS1PtTPC",100, 0,3,200,-1.0,1.0);   
323   fYResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
324   fYResolS1PtTPC->SetYTitle("#DeltaY");
325
326   fYResolS1PtTPCITS = new TH2F("fYResolS1PtTPCITS","fYResolS1PtTPCITS",100, 0,3,200,-0.05,0.05);   
327   fYResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
328   fYResolS1PtTPCITS->SetYTitle("#DeltaY");
329
330   fZResolS1PtTPC = new TH2F("fZResolS1PtTPC","fZResolS1PtTPC",100, 0,3,200,-1.0,1.0);   
331   fZResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
332   fZResolS1PtTPC->SetYTitle("#DeltaZ");
333
334   fZResolS1PtTPCITS = new TH2F("fZResolS1PtTPCITS","fZResolS1PtTPCITS",100, 0,3,200,-0.05,0.05);   
335   fZResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
336   fZResolS1PtTPCITS->SetYTitle("#DeltaZ");
337
338   fPhiResolS1PtTPC = new TH2F("fPhiResolS1PtTPC","fPhiResolS1PtTPC",100, 0,3,200,-0.025,0.025);   
339   fPhiResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
340   fPhiResolS1PtTPC->SetYTitle("#Delta#phi");
341
342   fPhiResolS1PtTPCITS = new TH2F("fPhiResolS1PtTPCITS","fPhiResolS1PtTPCITS",100, 0,3,200,-0.01,0.01);   
343   fPhiResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
344   fPhiResolS1PtTPCITS->SetYTitle("#Delta#phi");
345
346   fThetaResolS1PtTPC = new TH2F("fThetaResolS1PtTPC","fThetaResolS1PtTPC",100, 0,3,200,-0.025,0.025);   
347   fThetaResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
348   fThetaResolS1PtTPC->SetYTitle("#Delta#theta");
349
350   fThetaResolS1PtTPCITS = new TH2F("fThetaResolS1PtTPCITS","fThetaResolS1PtTPCITS",100, 0,3,200,-0.01,0.01);   
351   fThetaResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
352   fThetaResolS1PtTPCITS->SetYTitle("#Delta#theta");
353   
354   // constrained
355   fC1Pt2ResolS1PtTPC = new TH2F("fC1Pt2ResolS1PtTPC","(1/mcpt-1/pt)/(1+1/mcpt)^2 vs 1/pt)",100,0,3,200,-0.010,0.010);  
356   fC1Pt2ResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
357   fC1Pt2ResolS1PtTPC->SetYTitle("(1/mcp_{t}-1/p_{t})/(1+1/mcp_{t})^2)");
358
359   fC1Pt2ResolS1PtTPCITS = new TH2F("fC1Pt2ResolS1PtTPCITS","(1/mcpt-1/pt)/(1+1/mcpt)^2 vs 1/pt)",100,0,3,200,-0.010,0.010);  
360   fC1Pt2ResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
361   fC1Pt2ResolS1PtTPCITS->SetYTitle("(1/mcp_{t}-1/p_{t})/(1+1/mcp_{t})^2)");
362
363   fCYResolS1PtTPC = new TH2F("fCYResolS1PtTPC","fCYResolS1PtTPC",100, 0,3,200,-1.0,1.0);   
364   fCYResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
365   fCYResolS1PtTPC->SetYTitle("#DeltaY");
366
367   fCYResolS1PtTPCITS = new TH2F("fCYResolS1PtTPCITS","fCYResolS1PtTPCITS",100, 0,3,200,-0.01,0.01);   
368   fCYResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
369   fCYResolS1PtTPCITS->SetYTitle("#DeltaY");
370
371   fCZResolS1PtTPC = new TH2F("fCZResolS1PtTPC","fCZResolS1PtTPC",100, 0,3,200,-1.0,1.0);   
372   fCZResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
373   fCZResolS1PtTPC->SetYTitle("#DeltaZ");
374
375   fCZResolS1PtTPCITS = new TH2F("fCZResolS1PtTPCITS","fCZResolS1PtTPCITS",100, 0,3,200,-0.025,0.025);   
376   fCZResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
377   fCZResolS1PtTPCITS->SetYTitle("#DeltaZ");
378
379   fCPhiResolS1PtTPC = new TH2F("fCPhiResolS1PtTPC","fCPhiResolS1PtTPC",100, 0,3,200,-0.025,0.025);   
380   fCPhiResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
381   fCPhiResolS1PtTPC->SetYTitle("#Delta#phi");
382
383   fCPhiResolS1PtTPCITS = new TH2F("fCPhiResolS1PtTPCITS","fCPhiResolS1PtTPCITS",100, 0,3,200,-0.003,0.003);   
384   fCPhiResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
385   fCPhiResolS1PtTPCITS->SetYTitle("#Delta#phi");
386
387   fCThetaResolS1PtTPC = new TH2F("fCThetaResolS1PtTPC","fCThetaResolS1PtTPC",100, 0,3,200,-0.025,0.025);   
388   fCThetaResolS1PtTPC->SetXTitle("#sqrt{1/mcp_{t}}");
389   fCThetaResolS1PtTPC->SetYTitle("#Delta#theta");
390
391   fCThetaResolS1PtTPCITS = new TH2F("fCThetaResolS1PtTPCITS","fCThetaResolS1PtTPCITS",100, 0,3,200,-0.005,0.005);   
392   fCThetaResolS1PtTPCITS->SetXTitle("#sqrt{1/mcp_{t}}");
393   fCThetaResolS1PtTPCITS->SetYTitle("#Delta#theta");
394
395   // Init cuts 
396   if(!fCutsMC) 
397     AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object");
398   if(!fCutsRC) 
399     AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object");
400
401   // init folder
402   fAnalysisFolder = CreateFolder("folderRes","Analysis Resolution Folder");
403 }
404
405 //_____________________________________________________________________________
406 void AliComparisonRes::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
407 {
408   // Fill resolution comparison information 
409   AliExternalTrackParam *track = 0;
410   Double_t field      = AliTracker::GetBz(); // nominal Bz field [kG]
411   Double_t kMaxD      = 123456.0; // max distance
412   AliESDVertex vertexMC;  // MC primary vertex
413
414   Int_t clusterITS[200];
415   Double_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
416
417   Float_t deltaPt, pullPt, deltaPhi,pullPhi, deltaTan, pullTan, delta1Pt2, deltaY1Pt, deltaZ1Pt, deltaPhi1Pt, deltaTheta1Pt; 
418   Float_t deltaPtTPC, pullPtTPC, deltaPhiTPC, pullPhiTPC, deltaTanTPC, pullTanTPC, delta1Pt2TPC, deltaY1PtTPC, deltaZ1PtTPC, deltaPhi1PtTPC, deltaTheta1PtTPC; 
419
420   Float_t mcpt = infoMC->GetParticle().Pt();
421   Float_t s1mcpt = TMath::Sqrt(1./infoMC->GetParticle().Pt());
422   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
423   Float_t eta =  infoMC->GetParticle().Eta();
424
425   // distance to Prim. vertex 
426   const Double_t* dv = infoMC->GetVDist(); 
427   Bool_t isPrim = TMath::Sqrt(dv[0]*dv[0] + dv[1]*dv[1])<fCutsMC->GetMaxR() && TMath::Abs(dv[2])<fCutsMC->GetMaxVz();
428
429   // Check selection cuts
430   if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return; 
431   if (!isPrim) return;
432   if (infoRC->GetStatus(1)!=3) return; // TPC refit
433   if (!infoRC->GetESDtrack()) return;  
434   if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
435
436   // calculate and set prim. vertex
437   vertexMC.SetXv( infoMC->GetParticle().Vx() - dv[0] );
438   vertexMC.SetYv( infoMC->GetParticle().Vy() - dv[1] );
439   vertexMC.SetZv( infoMC->GetParticle().Vz() - dv[2] );
440
441   // Fill MC vertex histo
442   fMCVertex->Fill(vertexMC.GetXv(),vertexMC.GetYv(),vertexMC.GetZv());
443
444    
445   // Fill Rec vertex histo
446   //fRecVertex->Fill(infoRC->GetESDvertex()->GetXv(),infoRC->GetESDvertex()->GetYv(),infoRC->GetESDvertex()->GetZv());
447   //printf("Rec vertex xv %f, yv %f, zv %f \n",infoRC->GetESDvertex()->GetXv(),infoRC->GetESDvertex()->GetYv(),infoRC->GetESDvertex()->GetZv());
448
449   deltaPt= (mcpt-infoRC->GetESDtrack()->Pt())/mcpt;  
450   pullPt= (1/mcpt-infoRC->GetESDtrack()->OneOverPt())/TMath::Sqrt(infoRC->GetESDtrack()->GetSigma1Pt2());  
451   deltaPhi = TMath::ATan2(infoRC->GetESDtrack()->Py(),infoRC->GetESDtrack()->Px())-
452                      TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
453   pullPhi = deltaPhi/TMath::Sqrt(infoRC->GetESDtrack()->GetSigmaSnp2()); 
454
455   deltaTan = TMath::ATan2(infoRC->GetESDtrack()->Pz(),infoRC->GetESDtrack()->Pt())-
456                      TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
457   pullTan = deltaTan/TMath::Sqrt(infoRC->GetESDtrack()->GetSigmaTgl2());
458
459   delta1Pt2 = (1/mcpt-infoRC->GetESDtrack()->OneOverPt())/TMath::Power(1+1/mcpt,2);       
460   deltaY1Pt = (infoMC->GetParticle().Vy()-infoRC->GetESDtrack()->GetY()) / (0.2+1/mcpt);
461   deltaZ1Pt = (infoMC->GetParticle().Vz()-infoRC->GetESDtrack()->GetZ()) / (0.2+1/mcpt);
462   deltaPhi1Pt = deltaPhi   / (0.1+1/mcpt);
463   deltaTheta1Pt = deltaTan / (0.1+1/mcpt);
464
465   // calculate track parameters at vertex
466   const AliExternalTrackParam *innerTPC =  0;
467   if ((innerTPC = infoRC->GetESDtrack()->GetTPCInnerParam()) != 0)
468   {
469     if ((track = new AliExternalTrackParam(*infoRC->GetESDtrack()->GetTPCInnerParam())) != 0 )
470     {
471       Bool_t bDCAStatus = track->PropagateToDCA(&vertexMC,field,kMaxD,dca,cov);
472
473       // Fill parametrisation histograms (only TPC track)
474       if(bDCAStatus) 
475           {
476                   
477                         deltaPtTPC= (mcpt-innerTPC->Pt())/mcpt;  
478                         pullPtTPC= (1/mcpt-innerTPC->OneOverPt())/TMath::Sqrt(innerTPC->GetSigma1Pt2());  
479                         deltaPhiTPC = TMath::ATan2(innerTPC->Py(),innerTPC->Px())-
480                                                                 TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
481                         pullPhiTPC = deltaPhiTPC/TMath::Sqrt(innerTPC->GetSigmaSnp2()); 
482
483                         deltaTanTPC = TMath::ATan2(innerTPC->Pz(),innerTPC->Pt())-
484                                                                 TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
485                         pullTanTPC = deltaTanTPC/TMath::Sqrt(infoRC->GetESDtrack()->GetSigmaTgl2());
486
487                         delta1Pt2TPC = (1/mcpt-innerTPC->OneOverPt())/TMath::Power(1+1/mcpt,2);       
488                         deltaY1PtTPC= (infoMC->GetParticle().Vy()-innerTPC->GetY()) / (0.2+1/mcpt);
489                         deltaZ1PtTPC = (infoMC->GetParticle().Vz()-innerTPC->GetZ()) / (0.2+1/mcpt);
490                         deltaPhi1PtTPC = deltaPhiTPC   / (0.1+1/mcpt);
491                         deltaTheta1PtTPC = deltaTanTPC / (0.1+1/mcpt);
492
493                 fPhiTanPtTPC->Fill(TMath::ATan2(innerTPC->Py(),innerTPC->Px()), 
494                                            TMath::ATan2(innerTPC->Pz(),innerTPC->Pt()),
495                                                            innerTPC->Pt()); 
496
497                         f1Pt2ResolS1PtTPC->Fill(s1mcpt,delta1Pt2TPC);
498                         fYResolS1PtTPC->Fill(s1mcpt,deltaY1PtTPC);
499                         fZResolS1PtTPC->Fill(s1mcpt,deltaZ1PtTPC);
500                         fPhiResolS1PtTPC->Fill(s1mcpt,deltaPhi1PtTPC);
501                         fThetaResolS1PtTPC->Fill(s1mcpt,deltaTheta1PtTPC);
502
503                 fPtResolTPC->Fill(mcpt,deltaPtTPC);
504                     fPtPullTPC->Fill(mcpt,pullPtTPC);
505                     fPhiResolTanTPC->Fill(tantheta,deltaPhiTPC);
506                     fPhiPullTanTPC->Fill(tantheta,pullPhiTPC);
507                     fTanResolTanTPC->Fill(tantheta,deltaTanTPC);
508                     fTanPullTanTPC->Fill(tantheta,pullTanTPC);
509           }
510           delete track;
511     }
512   }
513
514   // TPC and ITS clusters in the system
515   if(infoRC->GetESDtrack()->GetITSclusters(clusterITS)>fCutsRC->GetMinNClustersITS()) 
516   {
517           fPhiTanPtTPCITS->Fill(TMath::ATan2(infoRC->GetESDtrack()->Py(),infoRC->GetESDtrack()->Px()), 
518                                 TMath::ATan2(infoRC->GetESDtrack()->Pz(),infoRC->GetESDtrack()->Pt()), 
519                                 infoRC->GetESDtrack()->Pt()); 
520
521       f1Pt2ResolS1PtTPCITS->Fill(s1mcpt,delta1Pt2);
522       fYResolS1PtTPCITS->Fill(s1mcpt,deltaY1Pt);
523       fZResolS1PtTPCITS->Fill(s1mcpt,deltaZ1Pt);
524       fPhiResolS1PtTPCITS->Fill(s1mcpt,deltaPhi1Pt);
525       fThetaResolS1PtTPCITS->Fill(s1mcpt,deltaTheta1Pt);
526
527           fPtResolTPCITS->Fill(mcpt,deltaPt);
528           fPtPullTPCITS->Fill(mcpt,pullPt);
529
530           fPhiResolTanTPCITS->Fill(tantheta,deltaPhi);
531           fPhiPullTanTPCITS->Fill(tantheta,pullPhi);
532           fTanResolTanTPCITS->Fill(tantheta,deltaTan);
533           fTanPullTanTPCITS->Fill(tantheta,pullTan);
534   }
535 }
536
537 //_____________________________________________________________________________
538 void AliComparisonRes::ProcessConstrained(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
539 {
540   // Fill resolution comparison information (constarained parameters) 
541   //
542   AliExternalTrackParam *track = 0;
543   Double_t field      = AliTracker::GetBz(); // nominal Bz field [kG]
544   Double_t kMaxD      = 123456.0; // max distance
545   AliESDVertex vertexMC;  // MC primary vertex
546
547   Int_t clusterITS[200];
548   Double_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
549  
550   Float_t deltaPt, pullPt, deltaPhi, pullPhi, deltaTan, pullTan, delta1Pt2, deltaY1Pt, deltaZ1Pt, deltaPhi1Pt, deltaTheta1Pt; 
551   Float_t deltaPtTPC, pullPtTPC, deltaPhiTPC, deltaTanTPC, delta1Pt2TPC, deltaY1PtTPC, deltaZ1PtTPC, deltaPhi1PtTPC, deltaTheta1PtTPC; 
552
553   Float_t mcpt = infoMC->GetParticle().Pt();
554   Float_t s1mcpt = TMath::Sqrt(1./infoMC->GetParticle().Pt());
555   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
556
557   // distance to Prim. vertex 
558   const Double_t* dv = infoMC->GetVDist(); 
559   Bool_t isPrim = TMath::Sqrt(dv[0]*dv[0] + dv[1]*dv[1])<fCutsMC->GetMaxR() && TMath::Abs(dv[2])<fCutsMC->GetMaxVz();
560   
561   // Check selection cuts
562  
563   if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return; 
564   if (!isPrim) return;
565   if (infoRC->GetStatus(1)!=3) return;
566   if (!infoRC->GetESDtrack()) return;  
567   if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
568   if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
569
570 // calculate and set prim. vertex
571   vertexMC.SetXv( infoMC->GetParticle().Vx() - dv[0] );
572   vertexMC.SetYv( infoMC->GetParticle().Vy() - dv[1] );
573   vertexMC.SetZv( infoMC->GetParticle().Vz() - dv[2] );
574
575   // constrained parameters resolution
576   const AliExternalTrackParam * cparam = infoRC->GetESDtrack()->GetConstrainedParam();
577   deltaPt= (mcpt-cparam->Pt())/mcpt;  
578   pullPt= (1/mcpt-cparam->OneOverPt())/TMath::Sqrt(cparam->GetSigma1Pt2());          
579   deltaPhi = TMath::ATan2(cparam->Py(),cparam->Px())-
580                      TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
581   pullPhi = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2()); 
582   deltaTan = TMath::ATan2(cparam->Pz(),cparam->Pt())-TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
583   pullTan = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2()); 
584
585
586   delta1Pt2 = (1/mcpt-cparam->OneOverPt())/TMath::Power(1+1/mcpt,2);       
587
588   deltaY1Pt = (infoMC->GetParticle().Vy()-cparam->GetY()) / (0.2+1/mcpt);
589   deltaZ1Pt = (infoMC->GetParticle().Vz()-cparam->GetZ()) / (0.2+1/mcpt);
590   deltaPhi1Pt = deltaPhi   / (0.1+1/mcpt);
591   deltaTheta1Pt = deltaTan / (0.1+1/mcpt);
592
593   // calculate track parameters at vertex
594   const AliExternalTrackParam *innerTPC =  0;
595   if ((innerTPC = infoRC->GetESDtrack()->GetTPCInnerParam()) != 0)
596   {
597     if ((track = new AliExternalTrackParam(*infoRC->GetESDtrack()->GetTPCInnerParam())) != 0 )
598     {
599       Bool_t bDCAStatus = track->PropagateToDCA(&vertexMC,field,kMaxD,dca,cov);
600
601       // Fill parametrisation histograms (only TPC track)
602       if(bDCAStatus) 
603           {
604                   deltaPtTPC= (mcpt-innerTPC->Pt())/mcpt;  
605                   pullPtTPC= (1/mcpt-innerTPC->OneOverPt())/TMath::Sqrt(innerTPC->GetSigma1Pt2());  
606                   deltaPhiTPC = TMath::ATan2(innerTPC->Py(),innerTPC->Px())-
607                                                                 TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
608
609                   deltaTanTPC = TMath::ATan2(innerTPC->Pz(),innerTPC->Pt())-
610                                                                 TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
611
612                   delta1Pt2TPC = (1/mcpt-innerTPC->OneOverPt())/TMath::Power(1+1/mcpt,2);       
613                   deltaY1PtTPC= (infoMC->GetParticle().Vy()-innerTPC->GetY()) / (0.2+1/mcpt);
614                   deltaZ1PtTPC = (infoMC->GetParticle().Vz()-innerTPC->GetZ()) / (0.2+1/mcpt);
615                   deltaPhi1PtTPC = deltaPhiTPC   / (0.1+1/mcpt);
616                   deltaTheta1PtTPC = deltaTanTPC / (0.1+1/mcpt);
617
618           fC1Pt2ResolS1PtTPC->Fill(s1mcpt,delta1Pt2TPC);
619           fCYResolS1PtTPC->Fill(s1mcpt,deltaY1PtTPC);
620           fCZResolS1PtTPC->Fill(s1mcpt,deltaZ1PtTPC);
621           fCPhiResolS1PtTPC->Fill(s1mcpt,deltaPhi1PtTPC);
622           fCThetaResolS1PtTPC->Fill(s1mcpt,deltaTheta1PtTPC);
623           }
624           delete track;
625     }
626   }
627
628  // TPC and ITS in the system
629   if(infoRC->GetESDtrack()->GetITSclusters(clusterITS)>fCutsRC->GetMinNClustersITS()) 
630   {
631       fC1Pt2ResolS1PtTPCITS->Fill(s1mcpt,delta1Pt2);
632       fCYResolS1PtTPCITS->Fill(s1mcpt,deltaY1Pt);
633       fCZResolS1PtTPCITS->Fill(s1mcpt,deltaZ1Pt);
634       fCPhiResolS1PtTPCITS->Fill(s1mcpt,deltaPhi1Pt);
635       fCThetaResolS1PtTPCITS->Fill(s1mcpt,deltaTheta1Pt);
636
637           // Fill histograms
638           fCPtResolTan->Fill(tantheta,deltaPt);
639           fCPtPullTan->Fill(tantheta,pullPt);
640           fCPhiResolTan->Fill(tantheta,deltaPhi);
641           fCPhiPullTan->Fill(tantheta,pullPhi);
642           fCTanResolTan->Fill(tantheta,deltaTan);
643           fCTanPullTan->Fill(tantheta,pullTan);
644   }
645 }
646  
647 //_____________________________________________________________________________
648 void AliComparisonRes::Exec(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
649   
650   // Process comparison information 
651   Process(infoMC,infoRC);
652   ProcessConstrained(infoMC,infoRC);
653 }
654
655 //_____________________________________________________________________________
656 TH1F* AliComparisonRes::MakeResol(TH2F * his, Int_t integ, Bool_t type){
657   // Create resolution histograms
658  
659   TH1F *hisr, *hism;
660   if (!gPad) new TCanvas;
661   hisr = AliTreeDraw::CreateResHistoI(his,&hism,integ);
662   if (type) return hism;
663   else 
664     return hisr;
665 }
666
667 //_____________________________________________________________________________
668 void AliComparisonRes::Analyse(){
669   // Analyse comparison information and store output histograms
670   // in the folder "folderRes"
671   //
672  
673   TH1::AddDirectory(kFALSE);
674
675   AliComparisonRes * comp=this;
676   TH1F *hiss=0;
677   TObjArray *aFolderObj = new TObjArray;
678
679   // write results in the folder 
680
681   TCanvas * c = new TCanvas("Phi resol Tan","Phi resol Tan");
682   c->cd();
683   //
684   hiss = comp->MakeResol(comp->fPtResolTPC,1,0);
685   hiss->SetXTitle("p_{t} (GeV)");
686   hiss->SetYTitle("#sigmap_{t}/p_{t}");
687   hiss->Draw(); 
688   hiss->SetName("PtResolPtTPC");
689   
690   aFolderObj->Add(hiss);
691
692   //
693   hiss = comp->MakeResol(comp->fPtResolTPC,1,1);
694   hiss->SetXTitle("p_{t} (GeV)");
695   hiss->SetYTitle("mean #Deltap_{t}/p_{t}");
696   hiss->Draw(); 
697   hiss->SetName("PtMeanPtTPC");
698   
699   aFolderObj->Add(hiss);
700
701   //
702   hiss = comp->MakeResol(comp->fPhiResolTanTPC,1,0);
703   hiss->SetXTitle("Tan(#theta)");
704   hiss->SetYTitle("#sigma#phi (rad)");
705   hiss->Draw();
706   hiss->SetName("PhiResolTanTPC");
707
708   aFolderObj->Add(hiss);
709
710   //
711   hiss = comp->MakeResol(comp->fPhiResolTanTPC,1,1);
712   hiss->SetXTitle("Tan(#theta)");
713   hiss->SetYTitle("mean #Delta#phi (rad)");
714   hiss->Draw();
715   hiss->SetName("PhiMeanTanTPC");
716   
717
718   aFolderObj->Add(hiss);
719   //
720   hiss = comp->MakeResol(comp->fTanResolTanTPC,1,0);
721   hiss->SetXTitle("Tan(#theta)");
722   hiss->SetYTitle("#sigma#theta (rad)");
723   hiss->Draw();
724   hiss->SetName("ThetaResolTanTPC");
725   
726   aFolderObj->Add(hiss);
727
728   //
729   hiss = comp->MakeResol(comp->fTanResolTanTPC,1,1);
730   hiss->SetXTitle("Tan(#theta)");
731   hiss->SetYTitle("mean #Delta#theta (rad)");
732   hiss->Draw();
733   hiss->SetName("ThetaMeanTanTPC");
734   
735   aFolderObj->Add(hiss);
736
737   //
738   //
739   hiss = comp->MakeResol(comp->fPtResolTPCITS,1,0);
740   hiss->SetXTitle("p_{t}");
741   hiss->SetYTitle("#sigmap_{t}/p_{t}");
742   hiss->Draw(); 
743   hiss->SetName("PtResolPtTPCITS");
744   
745   aFolderObj->Add(hiss);
746
747   //
748   hiss = comp->MakeResol(comp->fPtResolTPCITS,1,1);
749   hiss->SetXTitle("p_{t}");
750   hiss->SetYTitle("mean #Deltap_{t}/p_{t}");
751   hiss->Draw(); 
752   hiss->SetName("PtMeanPtTPCITS");
753   
754   aFolderObj->Add(hiss);
755
756   //
757   hiss = comp->MakeResol(comp->fPhiResolTanTPCITS,1,0);
758   hiss->SetXTitle("Tan(#theta)");
759   hiss->SetYTitle("#sigma#phi (rad)");
760   hiss->Draw();
761   hiss->SetName("PhiResolTanTPCITS");
762   
763   aFolderObj->Add(hiss);
764
765   //
766   hiss = comp->MakeResol(comp->fPhiResolTanTPCITS,1,1);
767   hiss->SetXTitle("Tan(#theta)");
768   hiss->SetYTitle("mean #Delta#phi (rad)");
769   hiss->Draw();
770   hiss->SetName("PhiMeanTanTPCITS");
771   
772   aFolderObj->Add(hiss);
773
774   //
775   hiss = comp->MakeResol(comp->fTanResolTanTPCITS,1,0);
776   hiss->SetXTitle("Tan(#theta)");
777   hiss->SetYTitle("#sigma#theta (rad)");
778   hiss->Draw();
779   hiss->SetName("ThetaResolTanTPCITS");
780   
781   aFolderObj->Add(hiss);
782
783   //
784   hiss = comp->MakeResol(comp->fTanResolTanTPCITS,1,1);
785   hiss->SetXTitle("Tan(#theta)");
786   hiss->SetYTitle("mean #Delta#theta (rad)");
787   hiss->Draw();
788   hiss->SetName("ThetaMeanTanTPCITS");
789   
790   aFolderObj->Add(hiss);
791
792   //
793   //
794   hiss = comp->MakeResol(comp->fCPtResolTan,1,0);
795   hiss->SetXTitle("Tan(#theta)");
796   hiss->SetYTitle("#sigmap_{t}/p_{t}");
797   hiss->Draw(); 
798   hiss->SetName("CptResolTan");
799   
800   aFolderObj->Add(hiss);
801
802   hiss = comp->MakeResol(comp->fCPhiResolTan,1,0);
803   hiss->SetXTitle("Tan(#theta)");
804   hiss->SetYTitle("#sigma#phi (rad)");
805   hiss->Draw();
806   hiss->SetName("CPhiResolTan");
807   
808   aFolderObj->Add(hiss);
809   //
810   hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
811   hiss->SetXTitle("Tan(#theta)");
812   hiss->SetYTitle("#sigma#theta (rad)");
813   hiss->Draw();
814   hiss->SetName("CThetaResolTan");
815   
816   aFolderObj->Add(hiss);
817   //
818   hiss = comp->MakeResol(comp->fCPtPullTan,1,0);
819   hiss->SetXTitle("Tan(#theta)");
820   hiss->SetYTitle("1/mcp_{t}-1/p_{t}/#Sigma(1/p_{t})");
821   hiss->Draw();
822   hiss->SetName("CptPullTan");
823   
824   aFolderObj->Add(hiss);
825   //
826   hiss = comp->MakeResol(comp->fC1Pt2ResolS1PtTPC,1,0);
827   hiss->SetXTitle("#sqrt(1/mcp_{t})");
828   hiss->SetYTitle("1/mcp_{t}-1/p_{t}/(1+1/p_{t})^2");
829   hiss->Draw();
830   hiss->SetName("C1Pt2ResolS1PtTPC");
831   
832   aFolderObj->Add(hiss);
833
834   hiss = comp->MakeResol(comp->fC1Pt2ResolS1PtTPCITS,1,0);
835   hiss->SetXTitle("#sqrt(1/mcp_{t})");
836   hiss->SetYTitle("1/mcp_{t}-1/p_{t}/(1+1/p_{t})^2");
837   hiss->Draw();
838   hiss->SetName("C1Pt2ResolS1PtTPCITS");
839   
840   aFolderObj->Add(hiss);
841   //
842   hiss = comp->MakeResol(comp->fCYResolS1PtTPC,1,0);
843   hiss->SetXTitle("#sqrt(1/mcp_{t})");
844   hiss->SetYTitle("(mcy-y)/(0.2+1/mcp_{t})");
845   hiss->Draw();
846   hiss->SetName("CYResolS1PtTPC");
847   
848   aFolderObj->Add(hiss);
849
850   hiss = comp->MakeResol(comp->fCYResolS1PtTPCITS,1,0);
851   hiss->SetXTitle("#sqrt(1/mcp_{t})");
852   hiss->SetYTitle("(mcy-y)/(0.2+1/mcp_{t})");
853   hiss->Draw();
854   hiss->SetName("CYResolS1PtTPCITS");
855   
856   aFolderObj->Add(hiss);
857   //
858   hiss = comp->MakeResol(comp->fCZResolS1PtTPC,1,0);
859   hiss->SetXTitle("#sqrt(1/mcp_{t})");
860   hiss->SetYTitle("(mcz-z)/(0.2+1/mcp_{t})");
861   hiss->Draw();
862   hiss->SetName("CZResolS1PtTPC");
863   
864   aFolderObj->Add(hiss);
865
866   hiss = comp->MakeResol(comp->fCZResolS1PtTPCITS,1,0);
867   hiss->SetXTitle("#sqrt(1/mcp_{t})");
868   hiss->SetYTitle("(mcz-z)/(0.2+1/mcp_{t})");
869   hiss->Draw();
870   hiss->SetName("CZResolS1PtTPCITS");
871   
872   aFolderObj->Add(hiss);
873   //
874   hiss = comp->MakeResol(comp->fCPhiResolS1PtTPC,1,0);
875   hiss->SetXTitle("#sqrt(1/mcp_{t})");
876   hiss->SetYTitle("(mc#phi-#phi)/(0.1+1/mcp_{t})");
877   hiss->Draw();
878   hiss->SetName("CPhiResolS1PtTPC");
879   
880   aFolderObj->Add(hiss);
881
882   hiss = comp->MakeResol(comp->fCPhiResolS1PtTPCITS,1,0);
883   hiss->SetXTitle("#sqrt(1/mcp_{t})");
884   hiss->SetYTitle("(mc#phi-#phi)/(0.1+1/mcp_{t})");
885   hiss->Draw();
886   hiss->SetName("CPhiResolS1PtTPCITS");
887   
888   aFolderObj->Add(hiss);
889   //
890   hiss = comp->MakeResol(comp->fCThetaResolS1PtTPC,1,0);
891   hiss->SetXTitle("#sqrt(1/mcp_{t})");
892   hiss->SetYTitle("(mc#theta-#theta)/(0.1+1/mcp_{t})");
893   hiss->Draw();
894   hiss->SetName("CThetaResolS1PtTPC");
895   
896   aFolderObj->Add(hiss);
897
898   hiss = comp->MakeResol(comp->fCThetaResolS1PtTPCITS,1,0);
899   hiss->SetXTitle("#sqrt(1/mcp_{t})");
900   hiss->SetYTitle("(mc#theta-#theta)/(0.1+1/mcp_{t})");
901   hiss->Draw();
902   hiss->SetName("CThetaResolS1PtTPCITS");
903   
904   aFolderObj->Add(hiss);
905
906   //
907   hiss = comp->MakeResol(comp->f1Pt2ResolS1PtTPC,1,0);
908   hiss->SetXTitle("#sqrt(1/mcp_{t})");
909   hiss->SetYTitle("1/mcp_{t}-1/p_{t}/(1+1/p_{t})^2");
910   hiss->Draw();
911   hiss->SetName("OnePt2ResolS1PtTPC");
912   
913   aFolderObj->Add(hiss);
914
915   hiss = comp->MakeResol(comp->f1Pt2ResolS1PtTPCITS,1,0);
916   hiss->SetXTitle("#sqrt(1/mcp_{t})");
917   hiss->SetYTitle("1/mcp_{t}-1/p_{t}/(1+1/p_{t})^2");
918   hiss->Draw();
919   hiss->SetName("OnePt2ResolS1PtTPCITS");
920   
921   aFolderObj->Add(hiss);
922   //
923   hiss = comp->MakeResol(comp->fYResolS1PtTPC,1,0);
924   hiss->SetXTitle("#sqrt(1/mcp_{t})");
925   hiss->SetYTitle("(mcy-y)/(0.2+1/mcp_{t})");
926   hiss->Draw();
927   hiss->SetName("YResolS1PtTPC");
928   
929   aFolderObj->Add(hiss);
930
931   hiss = comp->MakeResol(comp->fYResolS1PtTPCITS,1,0);
932   hiss->SetXTitle("#sqrt(1/mcp_{t})");
933   hiss->SetYTitle("(mcy-y)/(0.2+1/mcp_{t})");
934   hiss->Draw();
935   hiss->SetName("YResolS1PtTPCITS");
936   
937   aFolderObj->Add(hiss);
938   //
939   hiss = comp->MakeResol(comp->fZResolS1PtTPC,1,0);
940   hiss->SetXTitle("#sqrt(1/mcp_{t})");
941   hiss->SetYTitle("(mcz-z)/(0.2+1/mcp_{t})");
942   hiss->Draw();
943   hiss->SetName("ZResolS1PtTPC");
944   
945   aFolderObj->Add(hiss);
946
947   hiss = comp->MakeResol(comp->fZResolS1PtTPCITS,1,0);
948   hiss->SetXTitle("#sqrt(1/mcp_{t})");
949   hiss->SetYTitle("(mcz-z)/(0.2+1/mcp_{t})");
950   hiss->Draw();
951   hiss->SetName("ZResolS1PtTPCITS");
952   
953   aFolderObj->Add(hiss);
954   //
955   hiss = comp->MakeResol(comp->fPhiResolS1PtTPC,1,0);
956   hiss->SetXTitle("#sqrt(1/mcp_{t})");
957   hiss->SetYTitle("(mc#phi-#phi)/(0.1+1/mcp_{t})");
958   hiss->Draw();
959   hiss->SetName("PhiResolS1PtTPC");
960   
961   aFolderObj->Add(hiss);
962
963   hiss = comp->MakeResol(comp->fPhiResolS1PtTPCITS,1,0);
964   hiss->SetXTitle("#sqrt(1/mcp_{t})");
965   hiss->SetYTitle("(mc#phi-#phi)/(0.1+1/mcp_{t})");
966   hiss->Draw();
967   hiss->SetName("PhiResolS1PtTPCITS");
968   
969   aFolderObj->Add(hiss);
970   //
971   hiss = comp->MakeResol(comp->fThetaResolS1PtTPC,1,0);
972   hiss->SetXTitle("#sqrt(1/mcp_{t})");
973   hiss->SetYTitle("(mc#theta-#theta)/(0.1+1/mcp_{t})");
974   hiss->Draw();
975   hiss->SetName("ThetaResolS1PtTPC");
976   
977   aFolderObj->Add(hiss);
978
979   hiss = comp->MakeResol(comp->fThetaResolS1PtTPCITS,1,0);
980   hiss->SetXTitle("#sqrt(1/mcp_{t})");
981   hiss->SetYTitle("(mc#theta-#theta)/(0.1+1/mcp_{t})");
982   hiss->Draw();
983   hiss->SetName("ThetaResolS1PtTPCITS");
984   
985   aFolderObj->Add(hiss);
986
987   // export objects to analysis folder
988   fAnalysisFolder = ExportToFolder(aFolderObj);
989
990   // delete only TObjArray
991   if(aFolderObj) delete aFolderObj;
992 }
993
994 //_____________________________________________________________________________
995 TFolder* AliComparisonRes::ExportToFolder(TObjArray * array) 
996 {
997   // recreate folder avery time and export objects to new one
998   //
999   AliComparisonRes * comp=this;
1000   TFolder *folder = comp->GetAnalysisFolder();
1001
1002   TString name, title;
1003   TFolder *newFolder = 0;
1004   Int_t i = 0;
1005   Int_t size = array->GetSize();
1006
1007   if(folder) { 
1008      // get name and title from old folder
1009      name = folder->GetName();  
1010      title = folder->GetTitle();  
1011
1012          // delete old one
1013      delete folder;
1014
1015          // create new one
1016      newFolder = CreateFolder(name.Data(),title.Data());
1017      newFolder->SetOwner();
1018
1019          // add objects to folder
1020      while(i < size) {
1021            newFolder->Add(array->At(i));
1022            i++;
1023          }
1024   }
1025
1026 return newFolder;
1027 }
1028
1029 //_____________________________________________________________________________
1030 Long64_t AliComparisonRes::Merge(TCollection* list) 
1031 {
1032   // Merge list of objects (needed by PROOF)
1033
1034   if (!list)
1035   return 0;
1036
1037   if (list->IsEmpty())
1038   return 1;
1039
1040   TIterator* iter = list->MakeIterator();
1041   TObject* obj = 0;
1042
1043   // collection of generated histograms
1044   Int_t count=0;
1045   while((obj = iter->Next()) != 0) 
1046   {
1047   AliComparisonRes* entry = dynamic_cast<AliComparisonRes*>(obj);
1048   if (entry == 0) continue; 
1049   
1050   fMCVertex->Add(entry->fMCVertex);
1051   fRecVertex->Add(entry->fRecVertex);
1052
1053   fPhiTanPtTPC->Add(entry->fPhiTanPtTPC);
1054   fPhiTanPtTPCITS->Add(entry->fPhiTanPtTPCITS);
1055
1056   fPtResolTPC->Add(entry->fPtResolTPC);
1057   fPtPullTPC->Add(entry->fPtPullTPC);
1058   fPhiResolTanTPC->Add(entry->fPhiResolTanTPC);
1059   fTanResolTanTPC->Add(entry->fTanResolTanTPC);
1060   fPhiPullTanTPC->Add(entry->fPhiPullTanTPC);
1061   fTanPullTanTPC->Add(entry->fTanPullTanTPC);
1062
1063   fPtResolTPCITS->Add(entry->fPtResolTPCITS);
1064   fPtPullTPCITS->Add(entry->fPtPullTPCITS);
1065   fPhiResolTanTPCITS->Add(entry->fPhiResolTanTPCITS);
1066   fTanResolTanTPCITS->Add(entry->fTanResolTanTPCITS);
1067   fPhiPullTanTPCITS->Add(entry->fPhiPullTanTPCITS);
1068   fTanPullTanTPCITS->Add(entry->fTanPullTanTPCITS);
1069
1070   // Histograms for 1/pt parameterisation
1071   f1Pt2ResolS1PtTPC->Add(entry->f1Pt2ResolS1PtTPC);
1072   fYResolS1PtTPC->Add(entry->fYResolS1PtTPC);
1073   fZResolS1PtTPC->Add(entry->fZResolS1PtTPC);
1074   fPhiResolS1PtTPC->Add(entry->fPhiResolS1PtTPC);
1075   fThetaResolS1PtTPC->Add(entry->fThetaResolS1PtTPC);
1076
1077   f1Pt2ResolS1PtTPCITS->Add(entry->f1Pt2ResolS1PtTPCITS);
1078   fYResolS1PtTPCITS->Add(entry->fYResolS1PtTPCITS);
1079   fZResolS1PtTPCITS->Add(entry->fZResolS1PtTPCITS);
1080   fPhiResolS1PtTPCITS->Add(entry->fPhiResolS1PtTPCITS);
1081   fThetaResolS1PtTPCITS->Add(entry->fThetaResolS1PtTPCITS);
1082
1083   // Resolution histograms (constrained param)
1084   fCPhiResolTan->Add(entry->fCPhiResolTan);
1085   fCTanResolTan->Add(entry->fCTanResolTan);
1086   fCPtResolTan->Add(entry->fCPtResolTan);
1087   fCPhiPullTan->Add(entry->fCPhiPullTan);
1088   fCTanPullTan->Add(entry->fCTanPullTan);
1089   fCPtPullTan->Add(entry->fCPtPullTan);
1090
1091   //  Histograms for 1/pt parameterisation (constrained)
1092   fC1Pt2ResolS1PtTPC->Add(entry->fC1Pt2ResolS1PtTPC);
1093   fCYResolS1PtTPC->Add(entry->fCYResolS1PtTPC);
1094   fCZResolS1PtTPC->Add(entry->fCZResolS1PtTPC);
1095   fCPhiResolS1PtTPC->Add(entry->fCPhiResolS1PtTPC);
1096   fCThetaResolS1PtTPC->Add(entry->fCThetaResolS1PtTPC);
1097
1098   fC1Pt2ResolS1PtTPCITS->Add(entry->fC1Pt2ResolS1PtTPCITS);
1099   fCYResolS1PtTPCITS->Add(entry->fCYResolS1PtTPCITS);
1100   fCZResolS1PtTPCITS->Add(entry->fCZResolS1PtTPCITS);
1101   fCPhiResolS1PtTPCITS->Add(entry->fCPhiResolS1PtTPCITS);
1102   fCThetaResolS1PtTPCITS->Add(entry->fCThetaResolS1PtTPCITS);
1103
1104   count++;
1105   }
1106
1107 return count;
1108 }
1109
1110 //_____________________________________________________________________________
1111 TFolder* AliComparisonRes::CreateFolder(TString name,TString title) { 
1112 // create folder for analysed histograms
1113 //
1114 TFolder *folder = 0;
1115   folder = new TFolder(name.Data(),title.Data());
1116
1117   return folder;
1118 }