]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/ITS/AliAnalysisTaskSEImpParRes.cxx
Added d0 vs phi and cluster type
[u/mrichter/AliRoot.git] / PWG1 / ITS / AliAnalysisTaskSEImpParRes.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /////////////////////////////////////////////////////////////
17 //
18 // AliAnalysisTaskSE for the study of the impact parameter resolution
19 //
20 // Authors:A.Dainese,    andrea.dainese@pd.infn.it
21 //     and Xianbao Yuan, yuanxb@iopp.ccnu.edu.cn; xianbao.yuan@pd.infn.it
22 /////////////////////////////////////////////////////////
23
24 #include <TList.h>
25 #include <TH1F.h>
26
27 #include "AliAnalysisManager.h"
28 #include "AliGeomManager.h"
29 #include "AliTrackPointArray.h"
30 #include "AliMCEventHandler.h"
31 #include "AliGenEventHeader.h"
32 #include "AliMCEvent.h"
33 #include "AliStack.h"
34 #include "AliESDEvent.h"
35 #include "AliESDVertex.h"
36 #include "AliESDtrack.h"   
37 #include "AliVertexerTracks.h"
38 #include "AliAnalysisTaskSEImpParRes.h"
39
40 ClassImp(AliAnalysisTaskSEImpParRes)
41
42 //________________________________________________________________________
43 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes():
44 AliAnalysisTaskSE(),
45 fReadMC(kFALSE),
46 fSelectedPdg(-1),
47 fUseDiamond(kFALSE),
48 fOutputitspureSARec(0),
49 fOutputitspureSASkip(0), 
50 fOutputallPointRec(0),
51 fOutputallPointSkip(0),
52 fOutputpartPointRec(0),
53 fOutputpartPointSkip(0),
54 fOutputonepointSPDRec(0),
55 fOutputonepointSPDSkip(0),
56 fOutputpostvTracRec(0),
57 fOutputpostvTracSkip(0),
58 fOutputnegtvTracRec(0),
59 fOutputnegtvTracSkip(0),
60 fOutputpullAllpointRec(0),
61 fOutputpullAllpointSkip(0),
62 fOutputOnlyRefitRec(0),
63 fOutputOnlyRefitSkip(0),
64 fOutputSinThetaRec(0),
65 fOutputSinThetaSkip(0),
66 fOutputallPointTrue(0),
67 fOutputpostvTracTrue(0),
68 fOutputnegtvTracTrue(0),
69 fOutputpullAllpointTrue(0),
70 fOutputphiAllpointSkip(0),
71 fOutputphiPostvtracSkip(0),
72 fOutputphiNegtvtracSkip(0),
73 fOutputclusterTypeSPD01Skip(0),
74 fOutputclusterTypeSPD02Skip(0),
75 fOutputclusterTypeSPD03Skip(0),
76 fOutputclusterTypeSPD11Skip(0),
77 fOutputclusterTypeSPD12Skip(0),
78 fOutputclusterTypeSPD13Skip(0),
79 fOutputPt(0),
80 fNentries(0),
81 fEstimVtx(0)
82 {
83   //
84   // Default constructor
85   //
86 }
87
88 //________________________________________________________________________
89 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes(const char *name):
90 AliAnalysisTaskSE(name),
91 fReadMC(kFALSE),
92 fSelectedPdg(-1),
93 fUseDiamond(kFALSE),
94 fOutputitspureSARec(0),
95 fOutputitspureSASkip(0), 
96 fOutputallPointRec(0),
97 fOutputallPointSkip(0),
98 fOutputpartPointRec(0),
99 fOutputpartPointSkip(0),
100 fOutputonepointSPDRec(0),
101 fOutputonepointSPDSkip(0),
102 fOutputpostvTracRec(0),
103 fOutputpostvTracSkip(0),
104 fOutputnegtvTracRec(0),
105 fOutputnegtvTracSkip(0),
106 fOutputpullAllpointRec(0),
107 fOutputpullAllpointSkip(0),
108 fOutputOnlyRefitRec(0),
109 fOutputOnlyRefitSkip(0),
110 fOutputSinThetaRec(0),
111 fOutputSinThetaSkip(0),
112 fOutputallPointTrue(0),
113 fOutputpostvTracTrue(0),
114 fOutputnegtvTracTrue(0),
115 fOutputpullAllpointTrue(0),
116 fOutputphiAllpointSkip(0),
117 fOutputphiPostvtracSkip(0),
118 fOutputphiNegtvtracSkip(0),
119 fOutputclusterTypeSPD01Skip(0),
120 fOutputclusterTypeSPD02Skip(0),
121 fOutputclusterTypeSPD03Skip(0),
122 fOutputclusterTypeSPD11Skip(0),
123 fOutputclusterTypeSPD12Skip(0),
124 fOutputclusterTypeSPD13Skip(0),
125 fOutputPt(0),
126 fNentries(0),
127 fEstimVtx(0)
128 {
129   //
130   // Default constructor
131   //
132
133   DefineOutput(1, TList::Class());  //My private output
134   DefineOutput(2, TList::Class());  //My private output
135   DefineOutput(3, TList::Class());  //My private output
136   DefineOutput(4, TList::Class());  //My private output
137   DefineOutput(5, TList::Class());
138   DefineOutput(6, TList::Class());  //My private output
139   DefineOutput(7, TList::Class());
140   DefineOutput(8, TList::Class());  //My private output
141   DefineOutput(9, TList::Class());  //My private output
142   DefineOutput(10, TList::Class());  //My private output
143   DefineOutput(11, TList::Class());  //My private output
144   DefineOutput(12, TList::Class());
145   DefineOutput(13, TList::Class());  //My private output
146   DefineOutput(14, TList::Class());
147   DefineOutput(15, TList::Class());  //My private output
148   DefineOutput(16, TList::Class());
149   DefineOutput(17, TList::Class());  //My private output
150   DefineOutput(18, TList::Class());
151   DefineOutput(19, TList::Class());  //My private output
152   DefineOutput(20, TList::Class());  //My private output
153   DefineOutput(21, TList::Class());
154   DefineOutput(22, TList::Class());  //My private output
155   DefineOutput(23, TList::Class());
156   DefineOutput(24, TList::Class());  //My private output
157   DefineOutput(25, TList::Class());
158   DefineOutput(26, TList::Class());  //My private output
159   DefineOutput(27, TList::Class());
160   DefineOutput(28, TList::Class());  //My private output
161   DefineOutput(29, TList::Class());
162   DefineOutput(30, TList::Class());  //My private output
163   DefineOutput(31, TList::Class());
164   DefineOutput(32, TList::Class());  //My private output
165   DefineOutput(33, TH1F::Class());
166   DefineOutput(34, TH1F::Class());
167 }
168
169 //________________________________________________________________________
170 AliAnalysisTaskSEImpParRes::~AliAnalysisTaskSEImpParRes()
171 {
172   //
173   // default distructor  
174   // 
175   if (fOutputitspureSARec)                      { delete fOutputitspureSARec; fOutputitspureSARec=0x0;}
176   if (fOutputitspureSASkip)                   { delete fOutputitspureSASkip; fOutputitspureSASkip=0x0;}
177   if (fOutputallPointRec)                        { delete fOutputallPointRec; fOutputallPointRec=0x0; }
178   if (fOutputallPointSkip)                     { delete fOutputallPointSkip; fOutputallPointSkip=0x0; }
179   if (fOutputpartPointRec)                     { delete fOutputpartPointRec; fOutputpartPointRec=0x0; }
180   if (fOutputpartPointSkip)                  { delete fOutputpartPointSkip; fOutputpartPointSkip=0x0; }
181   if (fOutputonepointSPDRec)                 { delete fOutputonepointSPDRec;fOutputonepointSPDRec=0x0;}
182   if (fOutputonepointSPDSkip)              { delete fOutputonepointSPDSkip;fOutputonepointSPDSkip=0x0;}
183   if (fOutputpostvTracRec)                      { delete fOutputpostvTracRec; fOutputpostvTracRec=0x0;}
184   if (fOutputpostvTracSkip)                  {  delete fOutputpostvTracSkip; fOutputpostvTracSkip=0x0;}
185   if (fOutputnegtvTracRec)                      { delete fOutputnegtvTracRec; fOutputnegtvTracRec=0x0;}
186   if (fOutputnegtvTracSkip)                   { delete fOutputnegtvTracSkip; fOutputnegtvTracSkip=0x0;}
187   if (fOutputpullAllpointRec)              {delete fOutputpullAllpointRec; fOutputpullAllpointRec=0x0;}
188   if (fOutputpullAllpointSkip)           {delete fOutputpullAllpointSkip; fOutputpullAllpointSkip=0x0;}
189   if (fOutputOnlyRefitRec)                       {delete fOutputOnlyRefitRec; fOutputOnlyRefitRec=0x0;}
190   if (fOutputOnlyRefitSkip)                    {delete fOutputOnlyRefitSkip; fOutputOnlyRefitSkip=0x0;}
191   if (fOutputSinThetaRec)                          {delete fOutputSinThetaRec; fOutputSinThetaRec=0x0;}  
192   if (fOutputSinThetaSkip)                       {delete fOutputSinThetaSkip; fOutputSinThetaSkip=0x0;}
193   if (fOutputallPointTrue)                       {delete fOutputallPointTrue; fOutputallPointTrue=0x0;}
194   if (fOutputpostvTracTrue)                     {delete fOutputpostvTracTrue;fOutputpostvTracTrue=0x0;}
195   if (fOutputnegtvTracTrue)                     {delete fOutputnegtvTracTrue;fOutputnegtvTracTrue=0x0;}
196   if (fOutputpullAllpointTrue)            {delete fOutputpullAllpointTrue;fOutputpullAllpointTrue=0x0;}
197   if (fOutputphiAllpointSkip)               {delete fOutputphiAllpointSkip;fOutputphiAllpointSkip=0x0;}
198   if (fOutputphiPostvtracSkip)             {delete fOutputphiPostvtracSkip;fOutputphiPostvtracSkip=0x0;}
199   if (fOutputphiNegtvtracSkip)            {delete fOutputphiNegtvtracSkip;fOutputphiNegtvtracSkip=0x0;}
200   if (fOutputclusterTypeSPD01Skip){delete fOutputclusterTypeSPD01Skip;fOutputclusterTypeSPD01Skip=0x0;}
201   if (fOutputclusterTypeSPD02Skip){delete fOutputclusterTypeSPD02Skip;fOutputclusterTypeSPD02Skip=0x0;}
202   if (fOutputclusterTypeSPD03Skip){delete fOutputclusterTypeSPD03Skip;fOutputclusterTypeSPD03Skip=0x0;}
203   if (fOutputclusterTypeSPD11Skip){delete fOutputclusterTypeSPD11Skip;fOutputclusterTypeSPD11Skip=0x0;}
204   if (fOutputclusterTypeSPD12Skip){delete fOutputclusterTypeSPD12Skip;fOutputclusterTypeSPD12Skip=0x0;}
205   if (fOutputclusterTypeSPD13Skip){delete fOutputclusterTypeSPD13Skip;fOutputclusterTypeSPD13Skip=0x0;}
206   if (fOutputPt)                                                      {delete fOutputPt;fOutputPt=0x0;}
207   if (fNentries)                                           { delete fNentries;     fNentries    =0x0; }
208   if (fEstimVtx)                                           { delete fEstimVtx;     fEstimVtx    =0x0; }
209
210
211
212 //________________________________________________________________________
213 void AliAnalysisTaskSEImpParRes::UserCreateOutputObjects()
214 {
215   // 
216   // Create the output container
217   //
218   
219   if(fDebug>1) printf("AnalysisTaskSEImpParRes::UserCreateOutputObjects() \n");
220   
221   // Several histograms are more conveniently managed in a TList
222   if (!fOutputitspureSARec) {
223     fOutputitspureSARec = new TList();
224     fOutputitspureSARec->SetOwner();
225     fOutputitspureSARec->SetName("ITSpureSARec");
226   }
227
228   if (!fOutputitspureSASkip) {
229     fOutputitspureSASkip = new TList();
230     fOutputitspureSASkip->SetOwner();
231     fOutputitspureSASkip->SetName("ITSpureSASkip");
232   }
233
234   if (!fOutputallPointRec) {
235     fOutputallPointRec = new TList();
236     fOutputallPointRec->SetOwner();
237     fOutputallPointRec->SetName("allpointRec");
238   }
239
240   if (!fOutputallPointSkip) {
241     fOutputallPointSkip = new TList();
242     fOutputallPointSkip->SetOwner();
243     fOutputallPointSkip->SetName("allpointSkip");
244   }
245
246   if (!fOutputpartPointRec) {
247     fOutputpartPointRec = new TList();
248     fOutputpartPointRec->SetOwner();
249     fOutputpartPointRec->SetName("partpointRec");
250   }
251
252   if (!fOutputpartPointSkip) {
253     fOutputpartPointSkip = new TList();
254     fOutputpartPointSkip->SetOwner();
255     fOutputpartPointSkip->SetName("partpointSkip");
256   }
257
258   if (!fOutputonepointSPDRec) {
259     fOutputonepointSPDRec = new TList();
260     fOutputonepointSPDRec->SetOwner();
261     fOutputonepointSPDRec->SetName("onepointSPDRec");
262   }
263
264   if (!fOutputonepointSPDSkip) {
265     fOutputonepointSPDSkip = new TList();
266     fOutputonepointSPDSkip->SetOwner();
267     fOutputonepointSPDSkip->SetName("onepointSPDSkip");
268   }
269
270   if (!fOutputpostvTracRec) {
271     fOutputpostvTracRec = new TList();
272     fOutputpostvTracRec->SetOwner();
273     fOutputpostvTracRec->SetName("postvtracRec");
274   }
275
276   if (!fOutputpostvTracSkip) {
277     fOutputpostvTracSkip = new TList();
278     fOutputpostvTracSkip->SetOwner();
279     fOutputpostvTracSkip->SetName("postvtracSkip");
280   }
281  
282   if (!fOutputnegtvTracRec) {
283     fOutputnegtvTracRec = new TList();
284     fOutputnegtvTracRec->SetOwner();
285     fOutputnegtvTracRec->SetName("negtvtracRe");
286   }
287
288   if (!fOutputnegtvTracSkip) {
289     fOutputnegtvTracSkip = new TList();
290     fOutputnegtvTracSkip->SetOwner();
291     fOutputnegtvTracSkip->SetName("negtvtracSkip");
292   }
293   
294   if (!fOutputpullAllpointSkip) {
295     fOutputpullAllpointSkip = new TList();
296     fOutputpullAllpointSkip->SetOwner();
297     fOutputpullAllpointSkip->SetName("pullAllpointSkip");
298   }
299   
300   if (!fOutputpullAllpointRec) {
301     fOutputpullAllpointRec = new TList();
302     fOutputpullAllpointRec->SetOwner();
303     fOutputpullAllpointRec->SetName("pullAllpointRec");
304   }
305   
306   if (!fOutputOnlyRefitRec) {
307     fOutputOnlyRefitRec = new TList();
308     fOutputOnlyRefitRec->SetOwner();
309     fOutputOnlyRefitRec->SetName("onlyRefitRec");
310   }
311   
312   if (!fOutputOnlyRefitSkip) {
313     fOutputOnlyRefitSkip = new TList();
314     fOutputOnlyRefitSkip->SetOwner();
315     fOutputOnlyRefitSkip->SetName("onlyRefitRec");
316   }
317   
318   if (!fOutputallPointTrue) {
319     fOutputallPointTrue = new TList();
320     fOutputallPointTrue->SetOwner();
321     fOutputallPointTrue->SetName("allpointTrue");
322   }
323   
324   if (!fOutputpostvTracTrue) {
325     fOutputpostvTracTrue = new TList();
326     fOutputpostvTracTrue->SetOwner();
327     fOutputpostvTracTrue->SetName("postvtracTrue");
328   }
329   
330   if (!fOutputnegtvTracTrue) {
331     fOutputnegtvTracTrue = new TList();
332     fOutputnegtvTracTrue->SetOwner();
333     fOutputnegtvTracTrue->SetName("negtvtracTrue");
334   }
335   
336   if (!fOutputpullAllpointTrue) {
337     fOutputpullAllpointTrue = new TList();
338     fOutputpullAllpointTrue->SetOwner();
339     fOutputpullAllpointTrue->SetName("pullAllpointTrue");
340   } 
341   
342   if (!fOutputclusterTypeSPD01Skip) {
343     fOutputclusterTypeSPD01Skip = new TList();
344     fOutputclusterTypeSPD01Skip->SetOwner();
345     fOutputclusterTypeSPD01Skip->SetName("clustertypeSPD01Skip");
346   }
347   
348   
349   if (!fOutputclusterTypeSPD02Skip) {
350     fOutputclusterTypeSPD02Skip = new TList();
351     fOutputclusterTypeSPD02Skip->SetOwner();
352     fOutputclusterTypeSPD02Skip->SetName("clustertypeSPD02Skip");
353   }
354   
355   if (!fOutputclusterTypeSPD03Skip) {
356     fOutputclusterTypeSPD03Skip = new TList();
357     fOutputclusterTypeSPD03Skip->SetOwner();
358     fOutputclusterTypeSPD03Skip->SetName("clustertypeSPD03Skip");
359   }
360   
361   if (!fOutputclusterTypeSPD11Skip) {
362     fOutputclusterTypeSPD11Skip = new TList();
363     fOutputclusterTypeSPD11Skip->SetOwner();
364     fOutputclusterTypeSPD11Skip->SetName("clustertypeSPD11Skip");
365   }
366   
367   if (!fOutputclusterTypeSPD12Skip) {
368     fOutputclusterTypeSPD12Skip = new TList();
369     fOutputclusterTypeSPD12Skip->SetOwner();
370     fOutputclusterTypeSPD12Skip->SetName("clustertypeSPD12Skip");
371   }
372   
373   if (!fOutputclusterTypeSPD13Skip) {
374     fOutputclusterTypeSPD13Skip = new TList();
375     fOutputclusterTypeSPD13Skip->SetOwner();
376     fOutputclusterTypeSPD13Skip->SetName("clustertypeSPD13Skip");
377   }
378
379   if (!fOutputPt) {
380     fOutputPt = new TList();
381     fOutputPt->SetOwner();
382     fOutputPt->SetName("Pt");
383   }
384
385   const Int_t nhist=26;
386   const TString d0ITSpureSArphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
387   const TString d0ITSpureSAzTitle = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
388   const TString d0allpointrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
389   const TString d0allpointzTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
390   const TString d0partpointrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
391   const TString d0partpointzTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
392   const TString d0onepointSPDrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
393   const TString d0onepointSPDzTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
394   const TString d0postvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
395   const TString d0postvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
396   const TString d0negtvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
397   const TString d0negtvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
398   const TString d0pullAllpointrphiTitle = "d_{0} Pull Distribution_rphi; d_{0} pull; Entries";
399   const TString d0pullAllpointzTitle  = "d_{0} Pull Distribution_z; d_{0} pull; Entries";
400   const TString d0onlyRefitrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
401   const TString d0onlyRefitzTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
402   const TString d0ptTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
403   const TString d0clusterTypeSPD01rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
404   const TString d0clusterTypeSPD01zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries"; 
405   const TString d0clusterTypeSPD02rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
406   const TString d0clusterTypeSPD02zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
407   const TString d0clusterTypeSPD03rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
408   const TString d0clusterTypeSPD03zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
409   const TString d0clusterTypeSPD11rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
410   const TString d0clusterTypeSPD11zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
411   const TString d0clusterTypeSPD12rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
412   const TString d0clusterTypeSPD12zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
413   const TString d0clusterTypeSPD13rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
414   const TString d0clusterTypeSPD13zTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
415   const TString d0rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
416   const TString d0zTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
417
418   TString  named0itspureSArphiRec,named0itspureSAzRec,named0allpointrphiRec, named0allpointzRec,named0partpointrphiRec, named0partpointzRec,named0onepointSPDrphiRec, named0onepointSPDzRec,named0postvtracrphiRec, named0postvtraczRec,named0negtvtracrphiRec, named0negtvtraczRec,named0pt,named0pullAllpointrphiRec,named0pullAllpointzRec,named0onlyRefitrphiRec,named0onlyRefitzRec;
419  
420   TH1F *d0ITSpureSArphiRec=0,*d0ITSpureSAzRec=0,*d0AllpointrphiRec=0, *d0AllpointzRec=0,*d0PartpointrphiRec=0, *d0PartpointzRec=0,
421     *d0OnepointSPDrphiRec=0,*d0OnepointSPDzRec=0,*d0PostvtracrphiRec=0, *d0PostvtraczRec=0,*d0NegtvtracrphiRec=0, *d0NegtvtraczRec=0,*d0Pt=0,*d0PullAllpointrphiRec=0,*d0PullAllpointzRec=0,*d0OnlyRefitrphiRec=0,*d0OnlyRefitzRec=0;
422
423   TString  named0itspureSArphiSkip,named0itspureSAzSkip,named0allpointrphiSkip, named0allpointzSkip,named0partpointrphiSkip, named0partpointzSkip,named0onepointSPDrphiSkip, named0onepointSPDzSkip,named0postvtracrphiSkip, named0postvtraczSkip,named0negtvtracrphiSkip, named0negtvtraczSkip,named0ptSkip,named0pullAllpointrphiSkip,named0pullAllpointzSkip,named0onlyRefitrphiSkip,named0onlyRefitzSkip,named0allpointrphiTrue, named0allpointzTrue,named0postvtracrphiTrue, named0postvtraczTrue,named0negtvtracrphiTrue, named0negtvtraczTrue,named0pullAllpointrphiTrue,named0pullAllpointzTrue,named0clusterTypeSPD01rphiSkip,named0clusterTypeSPD01zSkip,named0clusterTypeSPD02rphiSkip,named0clusterTypeSPD02zSkip,named0clusterTypeSPD03rphiSkip,named0clusterTypeSPD03zSkip,named0clusterTypeSPD11rphiSkip,named0clusterTypeSPD11zSkip,named0clusterTypeSPD12rphiSkip,named0clusterTypeSPD12zSkip,named0clusterTypeSPD13rphiSkip,named0clusterTypeSPD13zSkip;
424
425   TH1F *d0ITSpureSArphiSkip=0,*d0ITSpureSAzSkip=0,*d0AllpointrphiSkip=0, *d0AllpointzSkip=0,*d0PartpointrphiSkip=0, *d0PartpointzSkip=0,*d0OnepointSPDrphiSkip=0,*d0OnepointSPDzSkip=0,*d0PostvtracrphiSkip=0, *d0PostvtraczSkip=0,*d0NegtvtracrphiSkip=0,*d0NegtvtraczSkip=0,*d0PullAllpointrphiSkip=0,*d0PullAllpointzSkip=0,*d0OnlyRefitrphiSkip=0,*d0OnlyRefitzSkip=0,*d0AllpointrphiTrue=0, *d0AllpointzTrue=0,*d0PostvtracrphiTrue=0, *d0PostvtraczTrue=0,*d0NegtvtracrphiTrue=0,*d0NegtvtraczTrue=0,*d0PullAllpointrphiTrue,*d0PullAllpointzTrue,*d0ClustertypeSPD01rphiSkip=0,*d0ClustertypeSPD01zSkip=0,*d0ClustertypeSPD02rphiSkip=0,*d0ClustertypeSPD02zSkip=0,*d0ClustertypeSPD03rphiSkip=0,*d0ClustertypeSPD03zSkip=0,*d0ClustertypeSPD11rphiSkip=0,*d0ClustertypeSPD11zSkip=0,*d0ClustertypeSPD12rphiSkip=0,*d0ClustertypeSPD12zSkip=0,*d0ClustertypeSPD13rphiSkip=0,*d0ClustertypeSPD13zSkip=0;
426
427   for(Int_t i=1; i<=nhist; i++) {
428
429     named0itspureSArphiRec = "d0itspureSArphiRec_";
430     named0itspureSArphiRec += i;
431     named0itspureSAzRec = "d0itspureSAzRec_";
432     named0itspureSAzRec += i;
433     d0ITSpureSArphiRec = new TH1F(named0itspureSArphiRec.Data(), d0ITSpureSArphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
434     d0ITSpureSArphiRec->Sumw2();
435     d0ITSpureSArphiRec->SetMinimum(0);  
436     fOutputitspureSARec->Add(d0ITSpureSArphiRec);
437     d0ITSpureSAzRec = new TH1F(named0itspureSAzRec.Data(), d0ITSpureSAzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
438     d0ITSpureSAzRec->Sumw2();
439     d0ITSpureSAzRec->SetMinimum(0);  
440     fOutputitspureSARec->Add(d0ITSpureSAzRec);
441
442     named0itspureSArphiSkip = "d0itspureSArphiSkip_";
443     named0itspureSArphiSkip += i;
444     named0itspureSAzSkip = "d0itspureSAzSkip_";
445     named0itspureSAzSkip += i;
446     d0ITSpureSArphiSkip = new TH1F(named0itspureSArphiSkip.Data(), d0ITSpureSArphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
447     d0ITSpureSArphiSkip->Sumw2();
448     d0ITSpureSArphiSkip->SetMinimum(0);  
449     fOutputitspureSASkip->Add(d0ITSpureSArphiSkip);
450     d0ITSpureSAzSkip = new TH1F(named0itspureSAzSkip.Data(), d0ITSpureSAzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
451     d0ITSpureSAzSkip->Sumw2();
452     d0ITSpureSAzSkip->SetMinimum(0);  
453     fOutputitspureSASkip->Add(d0ITSpureSAzSkip);
454
455     named0allpointrphiRec = "d0allpointrphiRec_";
456     named0allpointrphiRec += i;
457     named0allpointzRec = "d0allpointzRec_";
458     named0allpointzRec += i;
459     d0AllpointrphiRec = new TH1F(named0allpointrphiRec.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
460     d0AllpointrphiRec->Sumw2();
461     d0AllpointrphiRec->SetMinimum(0);  
462     fOutputallPointRec->Add(d0AllpointrphiRec);
463     d0AllpointzRec= new TH1F(named0allpointzRec.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
464     d0AllpointzRec->Sumw2();
465     d0AllpointzRec->SetMinimum(0);  
466     fOutputallPointRec->Add(d0AllpointzRec);
467
468     named0allpointrphiSkip = "d0allpointrphiSkip_";
469     named0allpointrphiSkip += i;
470     named0allpointzSkip = "d0allpointzSkip_";
471     named0allpointzSkip += i;
472     d0AllpointrphiSkip = new TH1F(named0allpointrphiSkip.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
473     d0AllpointrphiSkip->Sumw2();
474     d0AllpointrphiSkip->SetMinimum(0);  
475     fOutputallPointSkip->Add(d0AllpointrphiSkip);
476     d0AllpointzSkip = new TH1F(named0allpointzSkip.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
477     d0AllpointzSkip->Sumw2();
478     d0AllpointzSkip->SetMinimum(0);  
479     fOutputallPointSkip->Add(d0AllpointzSkip);
480
481     named0partpointrphiRec = "d0partpointrphiRec_";
482     named0partpointrphiRec += i;
483     named0partpointzRec = "d0partpointzRec_";
484     named0partpointzRec += i;
485     d0PartpointrphiRec = new TH1F(named0partpointrphiRec.Data(), d0partpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
486     d0PartpointrphiRec->Sumw2();
487     d0PartpointrphiRec->SetMinimum(0);  
488     fOutputpartPointRec->Add(d0PartpointrphiRec);
489     d0PartpointzRec = new TH1F(named0partpointzRec.Data(), d0partpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
490     d0PartpointzRec->Sumw2();
491     d0PartpointzRec->SetMinimum(0);  
492     fOutputpartPointRec->Add(d0PartpointzRec);
493
494     named0partpointrphiSkip = "d0partpointrphiSkip_";
495     named0partpointrphiSkip += i;
496     named0partpointzSkip = "d0partpointzSkip_";
497     named0partpointzSkip += i;
498     d0PartpointrphiSkip = new TH1F(named0partpointrphiSkip.Data(), d0partpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
499     d0PartpointrphiSkip->Sumw2();
500     d0PartpointrphiSkip->SetMinimum(0);  
501     fOutputpartPointSkip->Add(d0PartpointrphiSkip);
502     d0PartpointzSkip = new TH1F(named0partpointzSkip.Data(), d0partpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
503     d0PartpointzSkip->Sumw2();
504     d0PartpointzSkip->SetMinimum(0);  
505     fOutputpartPointSkip->Add(d0PartpointzSkip);
506
507     named0onepointSPDrphiRec = "d0onepointSPDrphiRec_";
508     named0onepointSPDrphiRec += i;
509     named0onepointSPDzRec = "d0onepointSPDzRec_";
510     named0onepointSPDzRec += i;
511     d0OnepointSPDrphiRec = new TH1F(named0onepointSPDrphiRec.Data(), d0onepointSPDrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
512     d0OnepointSPDrphiRec->Sumw2();
513     d0OnepointSPDrphiRec->SetMinimum(0);  
514     fOutputonepointSPDRec->Add(d0OnepointSPDrphiRec);
515     d0OnepointSPDzRec = new TH1F(named0onepointSPDzRec.Data(), d0onepointSPDzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
516     d0OnepointSPDzRec->Sumw2();
517     d0OnepointSPDzRec->SetMinimum(0);  
518     fOutputonepointSPDRec->Add(d0OnepointSPDzRec);
519
520     named0onepointSPDrphiSkip = "d0onepointSPDrphiSkip_";
521     named0onepointSPDrphiSkip += i;
522     named0onepointSPDzSkip = "d0onepointSPDzSkip_";
523     named0onepointSPDzSkip += i;
524     d0OnepointSPDrphiSkip = new TH1F(named0onepointSPDrphiSkip.Data(), d0onepointSPDrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
525     d0OnepointSPDrphiSkip->Sumw2();
526     d0OnepointSPDrphiSkip->SetMinimum(0);  
527     fOutputonepointSPDSkip->Add(d0OnepointSPDrphiSkip);
528     d0OnepointSPDzSkip = new TH1F(named0onepointSPDzSkip.Data(), d0onepointSPDzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
529     d0OnepointSPDzSkip->Sumw2();
530     d0OnepointSPDzSkip->SetMinimum(0);  
531     fOutputonepointSPDSkip->Add(d0OnepointSPDzSkip);
532
533     named0postvtracrphiRec = "d0postvtracrphiRec_";
534     named0postvtracrphiRec += i;
535     named0postvtraczRec = "d0postvtraczRec_";
536     named0postvtraczRec += i;
537     d0PostvtracrphiRec = new TH1F(named0postvtracrphiRec.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
538     d0PostvtracrphiRec->Sumw2();
539     d0PostvtracrphiRec->SetMinimum(0);  
540     fOutputpostvTracRec->Add(d0PostvtracrphiRec);
541     d0PostvtraczRec = new TH1F(named0postvtraczRec.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
542     d0PostvtraczRec->Sumw2();
543     d0PostvtraczRec->SetMinimum(0);  
544     fOutputpostvTracRec->Add(d0PostvtraczRec);
545
546     named0postvtracrphiSkip = "d0postvtracrphiSkip_";
547     named0postvtracrphiSkip += i;
548     named0postvtraczSkip = "d0postvtraczSkip_";
549     named0postvtraczSkip += i;
550     d0PostvtracrphiSkip = new TH1F(named0postvtracrphiSkip.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
551     d0PostvtracrphiSkip->Sumw2();
552     d0PostvtracrphiSkip->SetMinimum(0);  
553     fOutputpostvTracSkip->Add(d0PostvtracrphiSkip);
554     d0PostvtraczSkip = new TH1F(named0postvtraczSkip.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
555     d0PostvtraczSkip->Sumw2();
556     d0PostvtraczSkip->SetMinimum(0);  
557     fOutputpostvTracSkip->Add(d0PostvtraczSkip);
558
559     named0negtvtracrphiRec = "d0negtvtracrphiRec_";
560     named0negtvtracrphiRec += i;
561     named0negtvtraczRec = "d0negtvtraczRec_";
562     named0negtvtraczRec += i;
563     d0NegtvtracrphiRec = new TH1F(named0negtvtracrphiRec.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
564     d0NegtvtracrphiRec->Sumw2();
565     d0NegtvtracrphiRec->SetMinimum(0);  
566     fOutputnegtvTracRec->Add(d0NegtvtracrphiRec);
567     d0NegtvtraczRec = new TH1F(named0negtvtraczRec.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
568     d0NegtvtraczRec->Sumw2();
569     d0NegtvtraczRec->SetMinimum(0);  
570     fOutputnegtvTracRec->Add(d0NegtvtraczRec);
571
572     named0negtvtracrphiSkip = "d0negtvtracrphiSkip_";
573     named0negtvtracrphiSkip += i;
574     named0negtvtraczSkip = "d0negtvtraczSkip_";
575     named0negtvtraczSkip += i;
576     d0NegtvtracrphiSkip = new TH1F(named0negtvtracrphiSkip.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
577     d0NegtvtracrphiSkip->Sumw2();
578     d0NegtvtracrphiSkip->SetMinimum(0);  
579     fOutputnegtvTracSkip->Add(d0NegtvtracrphiSkip);
580     d0NegtvtraczSkip = new TH1F(named0negtvtraczSkip.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
581     d0NegtvtraczSkip->Sumw2();
582     d0NegtvtraczSkip->SetMinimum(0);  
583     fOutputnegtvTracSkip->Add(d0NegtvtraczSkip);
584
585     named0pullAllpointrphiSkip = "d0pullAllpointrphiSkip_";
586     named0pullAllpointrphiSkip +=i;
587     named0pullAllpointzSkip = "d0pullAllpointzSkip_";
588     named0pullAllpointzSkip +=i;
589     d0PullAllpointrphiSkip = new TH1F(named0pullAllpointrphiSkip.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
590     d0PullAllpointrphiSkip->Sumw2();
591     d0PullAllpointrphiSkip->SetMinimum(0);
592     fOutputpullAllpointSkip->Add(d0PullAllpointrphiSkip);
593     d0PullAllpointzSkip = new TH1F(named0pullAllpointzSkip.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
594     d0PullAllpointzSkip->Sumw2();
595     d0PullAllpointzSkip->SetMinimum(0);
596     fOutputpullAllpointSkip->Add(d0PullAllpointzSkip);
597
598     named0pullAllpointrphiRec = "d0pullAllpointrphiRec_";
599     named0pullAllpointrphiRec +=i;
600     named0pullAllpointzRec = "d0pullAllpointzRec_";
601     named0pullAllpointzRec +=i;
602     d0PullAllpointrphiRec = new TH1F(named0pullAllpointrphiRec.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
603     d0PullAllpointrphiRec->Sumw2();
604     d0PullAllpointrphiRec->SetMinimum(0);
605     fOutputpullAllpointRec->Add(d0PullAllpointrphiRec);
606     d0PullAllpointzRec = new TH1F(named0pullAllpointzRec.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
607     d0PullAllpointzRec->Sumw2();
608     d0PullAllpointzRec->SetMinimum(0);
609     fOutputpullAllpointRec->Add(d0PullAllpointzRec);
610
611
612     named0onlyRefitrphiRec = "d0onlyrefitrphiRec_";
613     named0onlyRefitrphiRec +=i;
614     named0onlyRefitzRec = "d0onlyrefitzRec_";
615     named0onlyRefitzRec +=i;
616     d0OnlyRefitrphiRec = new TH1F(named0onlyRefitrphiRec.Data(),d0onlyRefitrphiTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
617     d0OnlyRefitrphiRec->Sumw2();
618     d0OnlyRefitrphiRec->SetMinimum(0);
619     fOutputOnlyRefitRec->Add(d0OnlyRefitrphiRec);
620     d0OnlyRefitzRec = new TH1F(named0onlyRefitzRec.Data(),d0onlyRefitzTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
621     d0OnlyRefitzRec->Sumw2();
622     d0OnlyRefitzRec->SetMinimum(0);
623     fOutputOnlyRefitRec->Add(d0OnlyRefitzRec);
624
625
626     named0onlyRefitrphiSkip = "d0onlyrefitrphiSkip_";
627     named0onlyRefitrphiSkip +=i;
628     named0onlyRefitzSkip = "d0onlyrefitzSkip_";
629     named0onlyRefitzSkip +=i;
630     d0OnlyRefitrphiSkip = new TH1F(named0onlyRefitrphiSkip.Data(),d0onlyRefitrphiTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
631     d0OnlyRefitrphiSkip->Sumw2();
632     d0OnlyRefitrphiSkip->SetMinimum(0);
633     fOutputOnlyRefitSkip->Add(d0OnlyRefitrphiSkip);
634     d0OnlyRefitzSkip = new TH1F(named0onlyRefitzSkip.Data(),d0onlyRefitzTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
635     d0OnlyRefitzSkip->Sumw2();
636     d0OnlyRefitzSkip->SetMinimum(0);
637     fOutputOnlyRefitSkip->Add(d0OnlyRefitzSkip);
638
639     named0allpointrphiTrue = "d0allpointrphiTrue_";
640     named0allpointrphiTrue += i;
641     named0allpointzTrue = "d0allpointzTrue_";
642     named0allpointzTrue += i;
643     d0AllpointrphiTrue = new TH1F(named0allpointrphiTrue.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
644     d0AllpointrphiTrue->Sumw2();
645     d0AllpointrphiTrue->SetMinimum(0);  
646     fOutputallPointTrue->Add(d0AllpointrphiTrue);
647     d0AllpointzTrue = new TH1F(named0allpointzTrue.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
648     d0AllpointzTrue->Sumw2();
649     d0AllpointzTrue->SetMinimum(0);  
650     fOutputallPointTrue->Add(d0AllpointzTrue);
651
652     named0postvtracrphiTrue = "d0postvtracrphiTrue_";
653     named0postvtracrphiTrue += i;
654     named0postvtraczTrue = "d0postvtraczTrue_";
655     named0postvtraczTrue += i;
656     d0PostvtracrphiTrue = new TH1F(named0postvtracrphiTrue.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
657     d0PostvtracrphiTrue->Sumw2();
658     d0PostvtracrphiTrue->SetMinimum(0);  
659     fOutputpostvTracTrue->Add(d0PostvtracrphiTrue);
660     d0PostvtraczTrue = new TH1F(named0postvtraczTrue.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
661     d0PostvtraczTrue->Sumw2();
662     d0PostvtraczTrue->SetMinimum(0);  
663     fOutputpostvTracTrue->Add(d0PostvtraczTrue);
664
665     named0negtvtracrphiTrue = "d0negtvtracrphiTrue_";
666     named0negtvtracrphiTrue += i;
667     named0negtvtraczTrue = "d0negtvtraczTrue_";
668     named0negtvtraczTrue += i;
669     d0NegtvtracrphiTrue = new TH1F(named0negtvtracrphiTrue.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
670     d0NegtvtracrphiTrue->Sumw2();
671     d0NegtvtracrphiTrue->SetMinimum(0);  
672     fOutputnegtvTracTrue->Add(d0NegtvtracrphiTrue);
673     d0NegtvtraczTrue = new TH1F(named0negtvtraczTrue.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
674     d0NegtvtraczTrue->Sumw2();
675     d0NegtvtraczTrue->SetMinimum(0);  
676     fOutputnegtvTracTrue->Add(d0NegtvtraczTrue);
677
678     named0pullAllpointrphiTrue = "d0pullAllpointrphiTrue_";
679     named0pullAllpointrphiTrue +=i;
680     named0pullAllpointzTrue = "d0pullAllpointzTrue_";
681     named0pullAllpointzTrue +=i;
682     d0PullAllpointrphiTrue = new TH1F(named0pullAllpointrphiTrue.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
683     d0PullAllpointrphiTrue->Sumw2();
684     d0PullAllpointrphiTrue->SetMinimum(0);
685     fOutputpullAllpointTrue->Add(d0PullAllpointrphiTrue);
686     d0PullAllpointzTrue = new TH1F(named0pullAllpointzTrue.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
687     d0PullAllpointzTrue->Sumw2();
688     d0PullAllpointzTrue->SetMinimum(0);
689     fOutputpullAllpointTrue->Add(d0PullAllpointzTrue);
690
691     named0clusterTypeSPD01rphiSkip = "d0clustertypeSPD01rphiSkip_";
692     named0clusterTypeSPD01rphiSkip +=i;
693     named0clusterTypeSPD01zSkip = "d0clustertypeSPD01zSkip_";
694     named0clusterTypeSPD01zSkip +=i;
695     d0ClustertypeSPD01rphiSkip = new TH1F(named0clusterTypeSPD01rphiSkip.Data(),d0clusterTypeSPD01rphiTitle.Data(),400,-10.,10.);
696     d0ClustertypeSPD01rphiSkip->Sumw2();
697     d0ClustertypeSPD01rphiSkip->SetMinimum(0);
698     fOutputclusterTypeSPD01Skip->Add(d0ClustertypeSPD01rphiSkip);
699     d0ClustertypeSPD01zSkip = new TH1F(named0clusterTypeSPD01zSkip.Data(),d0clusterTypeSPD01zTitle.Data(),400,-10.,10.);
700     d0ClustertypeSPD01zSkip->Sumw2();
701     d0ClustertypeSPD01zSkip->SetMinimum(0);
702     fOutputclusterTypeSPD01Skip->Add(d0ClustertypeSPD01zSkip);
703
704     named0clusterTypeSPD02rphiSkip = "d0clustertypeSPD02rphiSkip_";
705     named0clusterTypeSPD02rphiSkip +=i;
706     named0clusterTypeSPD02zSkip = "d0clustertypeSPD02zSkip_";
707     named0clusterTypeSPD02zSkip +=i;
708     d0ClustertypeSPD02rphiSkip = new TH1F(named0clusterTypeSPD02rphiSkip.Data(),d0clusterTypeSPD02rphiTitle.Data(),400,-10.,10.);
709     d0ClustertypeSPD02rphiSkip->Sumw2();
710     d0ClustertypeSPD02rphiSkip->SetMinimum(0);
711     fOutputclusterTypeSPD02Skip->Add(d0ClustertypeSPD02rphiSkip);
712     d0ClustertypeSPD02zSkip = new TH1F(named0clusterTypeSPD02zSkip.Data(),d0clusterTypeSPD02zTitle.Data(),400,-10.,10.);
713     d0ClustertypeSPD02zSkip->Sumw2();
714     d0ClustertypeSPD02zSkip->SetMinimum(0);
715     fOutputclusterTypeSPD02Skip->Add(d0ClustertypeSPD02zSkip);
716
717     named0clusterTypeSPD03rphiSkip = "d0clustertypeSPD03rphiSkip_";
718     named0clusterTypeSPD03rphiSkip +=i;
719     named0clusterTypeSPD03zSkip = "d0clustertypeSPD03zSkip_";
720     named0clusterTypeSPD03zSkip +=i;
721     d0ClustertypeSPD03rphiSkip = new TH1F(named0clusterTypeSPD03rphiSkip.Data(),d0clusterTypeSPD03rphiTitle.Data(),400,-10.,10.);
722     d0ClustertypeSPD03rphiSkip->Sumw2();
723     d0ClustertypeSPD03rphiSkip->SetMinimum(0);
724     fOutputclusterTypeSPD03Skip->Add(d0ClustertypeSPD03rphiSkip);
725     d0ClustertypeSPD03zSkip = new TH1F(named0clusterTypeSPD03zSkip.Data(),d0clusterTypeSPD03zTitle.Data(),400,-10.,10.);
726     d0ClustertypeSPD03zSkip->Sumw2();
727     d0ClustertypeSPD03zSkip->SetMinimum(0);
728     fOutputclusterTypeSPD03Skip->Add(d0ClustertypeSPD03zSkip);
729
730     named0clusterTypeSPD11rphiSkip = "d0clustertypeSPD11rphiSkip_";
731     named0clusterTypeSPD11rphiSkip +=i;
732     named0clusterTypeSPD11zSkip = "d0clustertypeSPD11zSkip_";
733     named0clusterTypeSPD11zSkip +=i;
734     d0ClustertypeSPD11rphiSkip = new TH1F(named0clusterTypeSPD11rphiSkip.Data(),d0clusterTypeSPD11rphiTitle.Data(),400,-10.,10.);
735     d0ClustertypeSPD11rphiSkip->Sumw2();
736     d0ClustertypeSPD11rphiSkip->SetMinimum(0);
737     fOutputclusterTypeSPD11Skip->Add(d0ClustertypeSPD11rphiSkip);
738     d0ClustertypeSPD11zSkip = new TH1F(named0clusterTypeSPD11zSkip.Data(),d0clusterTypeSPD11zTitle.Data(),400,-10.,10.);
739     d0ClustertypeSPD11zSkip->Sumw2();
740     d0ClustertypeSPD11zSkip->SetMinimum(0);
741     fOutputclusterTypeSPD11Skip->Add(d0ClustertypeSPD11zSkip);
742
743     named0clusterTypeSPD12rphiSkip = "d0clustertypeSPD12rphiSkip_";
744     named0clusterTypeSPD12rphiSkip +=i;
745     named0clusterTypeSPD12zSkip = "d0clustertypeSPD12zSkip_";
746     named0clusterTypeSPD12zSkip +=i;
747     d0ClustertypeSPD12rphiSkip = new TH1F(named0clusterTypeSPD12rphiSkip.Data(),d0clusterTypeSPD12rphiTitle.Data(),400,-10.,10.);
748     d0ClustertypeSPD12rphiSkip->Sumw2();
749     d0ClustertypeSPD12rphiSkip->SetMinimum(0);
750     fOutputclusterTypeSPD12Skip->Add(d0ClustertypeSPD12rphiSkip);
751     d0ClustertypeSPD12zSkip = new TH1F(named0clusterTypeSPD12zSkip.Data(),d0clusterTypeSPD12zTitle.Data(),400,-10.,10.);
752     d0ClustertypeSPD12zSkip->Sumw2();
753     d0ClustertypeSPD12zSkip->SetMinimum(0);
754     fOutputclusterTypeSPD12Skip->Add(d0ClustertypeSPD12zSkip);
755
756     named0clusterTypeSPD13rphiSkip = "d0clustertypeSPD13rphiSkip_";
757     named0clusterTypeSPD13rphiSkip +=i;
758     named0clusterTypeSPD13zSkip = "d0clustertypeSPD13zSkip_";
759     named0clusterTypeSPD13zSkip +=i;
760     d0ClustertypeSPD13rphiSkip = new TH1F(named0clusterTypeSPD13rphiSkip.Data(),d0clusterTypeSPD13rphiTitle.Data(),400,-10.,10.);
761     d0ClustertypeSPD13rphiSkip->Sumw2();
762     d0ClustertypeSPD13rphiSkip->SetMinimum(0);
763     fOutputclusterTypeSPD13Skip->Add(d0ClustertypeSPD13rphiSkip);
764     d0ClustertypeSPD13zSkip = new TH1F(named0clusterTypeSPD13zSkip.Data(),d0clusterTypeSPD13zTitle.Data(),400,-10.,10.);
765     d0ClustertypeSPD13zSkip->Sumw2();
766     d0ClustertypeSPD13zSkip->SetMinimum(0);
767     fOutputclusterTypeSPD13Skip->Add(d0ClustertypeSPD13zSkip);
768
769     named0pt = "d0pt_";
770     named0pt += i;
771     d0Pt = new TH1F(named0pt.Data(), d0ptTitle.Data(), 100, 0, 35.);
772     d0Pt->Sumw2();
773     d0Pt->SetMinimum(0);  
774     fOutputPt->Add(d0Pt);
775   }
776
777   const Int_t nhistm=10;
778   for(Int_t i=0; i<=nhistm; i++) {
779     if (!fOutputSinThetaRec){
780       fOutputSinThetaRec = new TList();
781       fOutputSinThetaRec->SetOwner();
782       fOutputSinThetaRec->SetName("thetaRec");
783     }
784     
785     if (!fOutputSinThetaSkip){
786       fOutputSinThetaSkip = new TList();
787       fOutputSinThetaSkip->SetOwner();
788       fOutputSinThetaSkip->SetName("thetaSkip");
789     }
790
791     if (!fOutputphiAllpointSkip) {
792       fOutputphiAllpointSkip = new TList();
793       fOutputphiAllpointSkip->SetOwner();
794       fOutputphiAllpointSkip->SetName("phiallpointSkip");
795     }
796     
797     if (!fOutputphiPostvtracSkip) {
798       fOutputphiPostvtracSkip = new TList();
799       fOutputphiPostvtracSkip->SetOwner();
800       fOutputphiPostvtracSkip->SetName("postvtracSkip");
801     }
802     
803     if (!fOutputphiNegtvtracSkip) {
804       fOutputphiNegtvtracSkip = new TList();
805       fOutputphiNegtvtracSkip->SetOwner();
806       fOutputphiNegtvtracSkip->SetName("negtvtracSkip");
807     }
808     
809     const TString d0sinThetarphiTitle ="d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
810     const TString d0sinThetazTitle ="d_{0} Distribution_z; d_{0} [#mum]; Entries";  
811     const TString d0phiAllpointrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
812     const TString d0phiAllpointzTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";    
813     const TString  d0phiPostvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
814     const TString d0phiPostvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";  
815     const TString  d0phiNegtvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
816     const TString d0phiNegtvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";   
817     TString named0sinThetaonerphiRec,named0sinThetaonezRec,named0sinThetatworphiRec,named0sinThetatwozRec,named0sinThetathreerphiRec,named0sinThetathreezRec,named0sinThetafourrphiRec,named0sinThetafourzRec;
818     
819     TH1F *d0SinThetaonerphiRec,*d0SinThetaonezRec,*d0SinThetatworphiRec,*d0SinThetatwozRec,*d0SinThetathreerphiRec,*d0SinThetathreezRec,*d0SinThetafourrphiRec,*d0SinThetafourzRec;
820     
821     TString  named0sinThetaonerphiSkip,named0sinThetaonezSkip,named0sinThetatworphiSkip,named0sinThetatwozSkip,named0sinThetathreerphiSkip,named0sinThetathreezSkip,named0sinThetafourrphiSkip,named0sinThetafourzSkip,named0phiAllpointrphiSkip, named0phiAllpointzSkip,named0phiPostvtracrphiSkip, named0phiPostvtraczSkip,named0phiNegtvtracrphiSkip,named0phiNegtvtraczSkip;
822     
823     TH1F*d0SinThetaonerphiSkip,*d0SinThetaonezSkip,*d0SinThetatworphiSkip,*d0SinThetatwozSkip,*d0SinThetathreerphiSkip,*d0SinThetathreezSkip,*d0SinThetafourrphiSkip,*d0SinThetafourzSkip, *d0PhiAllpointrphiSkip,*d0PhiAllpointzSkip,*d0PhiPostvtracrphiSkip,*d0PhiPostvtraczSkip,*d0PhiNegtvtracrphiSkip,*d0PhiNegtvtraczSkip;
824
825     named0sinThetaonerphiRec = "d0sinthetaonerphiRec_";
826     named0sinThetaonerphiRec += i;
827     named0sinThetaonezRec ="d0sinthetaonezRec_";
828     named0sinThetaonezRec += i;
829     d0SinThetaonerphiRec = new TH1F(named0sinThetaonerphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
830     d0SinThetaonerphiRec->Sumw2();
831     d0SinThetaonerphiRec->SetMinimum(0);
832     fOutputSinThetaRec->Add(d0SinThetaonerphiRec);
833     d0SinThetaonezRec = new TH1F(named0sinThetaonezRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
834     d0SinThetaonezRec->Sumw2();
835     d0SinThetaonezRec->SetMinimum(0);
836     fOutputSinThetaRec->Add(d0SinThetaonezRec);
837     
838     named0sinThetatworphiRec = "d0sinthetatworphiRec_";
839     named0sinThetatworphiRec += i;
840     named0sinThetatwozRec ="d0sinthetatwozRec_";
841     named0sinThetatwozRec += i;
842     d0SinThetatworphiRec = new TH1F(named0sinThetatworphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
843     d0SinThetatworphiRec->Sumw2();
844     d0SinThetatworphiRec->SetMinimum(0);
845     fOutputSinThetaRec->Add(d0SinThetatworphiRec);
846     d0SinThetatwozRec = new TH1F(named0sinThetatwozRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
847     d0SinThetatwozRec->Sumw2();
848     d0SinThetatwozRec->SetMinimum(0);
849     fOutputSinThetaRec->Add(d0SinThetatwozRec);
850     
851     named0sinThetathreerphiRec = "d0sinthetathreerphiRec_";
852     named0sinThetathreerphiRec += i;
853     named0sinThetathreezRec ="d0sinthetathreezRec_";
854     named0sinThetathreezRec += i;
855     
856     d0SinThetathreerphiRec = new TH1F(named0sinThetathreerphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
857     d0SinThetathreerphiRec->Sumw2();
858     d0SinThetathreerphiRec->SetMinimum(0);
859     fOutputSinThetaRec->Add(d0SinThetathreerphiRec);
860     d0SinThetathreezRec = new TH1F(named0sinThetathreezRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
861     d0SinThetathreezRec->Sumw2();
862     d0SinThetathreezRec->SetMinimum(0);
863     fOutputSinThetaRec->Add(d0SinThetathreezRec);
864     
865     named0sinThetafourrphiRec = "d0sinthetafourrphiRec_";
866     named0sinThetafourrphiRec += i;
867     named0sinThetafourzRec ="d0sinthetafourzRec_";
868     named0sinThetafourzRec += i;
869     d0SinThetafourrphiRec = new TH1F(named0sinThetafourrphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
870     d0SinThetafourrphiRec->Sumw2();
871     d0SinThetafourrphiRec->SetMinimum(0);
872     fOutputSinThetaRec->Add(d0SinThetafourrphiRec);
873     d0SinThetafourzRec = new TH1F(named0sinThetafourzRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
874     d0SinThetafourzRec->Sumw2();
875     d0SinThetafourzRec->SetMinimum(0);
876     fOutputSinThetaRec->Add(d0SinThetafourzRec);
877     
878     named0sinThetaonerphiSkip = "d0sinthetaonerphiSkip_";
879     named0sinThetaonerphiSkip += i;
880     named0sinThetaonezSkip ="d0sinthetaonezSkip_";
881     named0sinThetaonezSkip += i;
882     d0SinThetaonerphiSkip = new TH1F(named0sinThetaonerphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
883     d0SinThetaonerphiSkip->Sumw2();
884     d0SinThetaonerphiSkip->SetMinimum(0);
885     fOutputSinThetaSkip->Add(d0SinThetaonerphiSkip);
886     d0SinThetaonezSkip = new TH1F(named0sinThetaonezSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
887     d0SinThetaonezSkip->Sumw2();
888     d0SinThetaonezSkip->SetMinimum(0);
889     fOutputSinThetaSkip->Add(d0SinThetaonezSkip);
890     
891     named0sinThetatworphiSkip = "d0sinthetatworphiSkip_";
892     named0sinThetatworphiSkip += i;
893     named0sinThetatwozSkip ="d0sinthetatwozSkip_";
894     named0sinThetatwozSkip += i;
895     d0SinThetatworphiSkip = new TH1F(named0sinThetatworphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
896     d0SinThetatworphiSkip->Sumw2();
897     d0SinThetatworphiSkip->SetMinimum(0);
898     fOutputSinThetaSkip->Add(d0SinThetatworphiSkip);
899     d0SinThetatwozSkip = new TH1F(named0sinThetatwozSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
900     d0SinThetatwozSkip->Sumw2();
901     d0SinThetatwozSkip->SetMinimum(0);
902     fOutputSinThetaSkip->Add(d0SinThetatwozSkip);
903     
904     named0sinThetathreerphiSkip = "d0sinthetathreerphiSkip_";
905     named0sinThetathreerphiSkip += i;
906     named0sinThetathreezSkip ="d0sinthetathreezSkip_";
907     named0sinThetathreezSkip += i;
908     
909     d0SinThetathreerphiSkip = new TH1F(named0sinThetathreerphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
910     d0SinThetathreerphiSkip->Sumw2();
911     d0SinThetathreerphiSkip->SetMinimum(0);
912     fOutputSinThetaSkip->Add(d0SinThetathreerphiSkip);
913     d0SinThetathreezSkip = new TH1F(named0sinThetathreezSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
914     d0SinThetathreezSkip->Sumw2();
915     d0SinThetathreezSkip->SetMinimum(0);
916     fOutputSinThetaSkip->Add(d0SinThetathreezSkip);
917     
918     named0sinThetafourrphiSkip = "d0sinthetafourrphiSkip_";
919     named0sinThetafourrphiSkip += i;
920     named0sinThetafourzSkip ="d0sinthetafourzSkip_";
921     named0sinThetafourzSkip += i;
922     d0SinThetafourrphiSkip = new TH1F(named0sinThetafourrphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
923     d0SinThetafourrphiSkip->Sumw2();
924     d0SinThetafourrphiSkip->SetMinimum(0);
925     fOutputSinThetaSkip->Add(d0SinThetafourrphiSkip);
926     d0SinThetafourzSkip = new TH1F(named0sinThetafourzSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
927     d0SinThetafourzSkip->Sumw2();
928     d0SinThetafourzSkip->SetMinimum(0);
929     fOutputSinThetaSkip->Add(d0SinThetafourzSkip);
930
931     named0phiAllpointrphiSkip = "d0phiallpointrphiSkip_";
932     named0phiAllpointrphiSkip += i;
933     named0phiAllpointzSkip ="d0phiallpointzSkip_";
934     named0phiAllpointzSkip += i;
935     d0PhiAllpointrphiSkip = new TH1F(named0phiAllpointrphiSkip.Data(),d0phiAllpointrphiTitle.Data(),400,-2000,2000);
936     d0PhiAllpointrphiSkip->Sumw2();
937     d0PhiAllpointrphiSkip->SetMinimum(0);
938     fOutputphiAllpointSkip->Add(d0PhiAllpointrphiSkip);
939     d0PhiAllpointzSkip = new TH1F(named0phiAllpointzSkip.Data(),d0phiAllpointzTitle.Data(),400,-2000,2000);
940     d0PhiAllpointzSkip->Sumw2();
941     d0PhiAllpointzSkip->SetMinimum(0);
942     fOutputphiAllpointSkip->Add(d0PhiAllpointzSkip);
943
944
945     named0phiPostvtracrphiSkip = "d0phipostvtracrphiSkip_";
946     named0phiPostvtracrphiSkip += i;
947     named0phiPostvtraczSkip ="d0phipostvtraczSkip_";
948     named0phiPostvtraczSkip += i;
949     d0PhiPostvtracrphiSkip = new TH1F(named0phiPostvtracrphiSkip.Data(),d0phiPostvtracrphiTitle.Data(),400,-2000,2000);
950     d0PhiPostvtracrphiSkip->Sumw2();
951     d0PhiPostvtracrphiSkip->SetMinimum(0);
952     fOutputphiPostvtracSkip->Add(d0PhiPostvtracrphiSkip);
953     d0PhiPostvtraczSkip = new TH1F(named0phiPostvtraczSkip.Data(),d0phiPostvtraczTitle.Data(),400,-2000,2000);
954     d0PhiPostvtraczSkip->Sumw2();
955     d0PhiPostvtraczSkip->SetMinimum(0);
956     fOutputphiPostvtracSkip->Add(d0PhiPostvtraczSkip);
957
958
959     named0phiNegtvtracrphiSkip = "d0phinegtvtracrphiSkip_";
960     named0phiNegtvtracrphiSkip += i;
961     named0phiNegtvtraczSkip ="d0phinegtvtraczSkip_";
962     named0phiNegtvtraczSkip += i;
963     d0PhiNegtvtracrphiSkip = new TH1F(named0phiNegtvtracrphiSkip.Data(),d0phiNegtvtracrphiTitle.Data(),400,-2000,2000);
964     d0PhiNegtvtracrphiSkip->Sumw2();
965     d0PhiNegtvtracrphiSkip->SetMinimum(0);
966     fOutputphiNegtvtracSkip->Add(d0PhiNegtvtracrphiSkip);
967     d0PhiNegtvtraczSkip = new TH1F(named0phiNegtvtraczSkip.Data(),d0phiNegtvtraczTitle.Data(),400,-2000,2000);
968     d0PhiNegtvtraczSkip->Sumw2();
969     d0PhiNegtvtraczSkip->SetMinimum(0);
970     fOutputphiNegtvtracSkip->Add(d0PhiNegtvtraczSkip);
971   }
972
973   if(!fNentries) fNentries = new TH1F("hNentries", "number of entries", 26, 0., 40.);
974   if(!fEstimVtx) fEstimVtx = new TH1F("vtxRes","Resolution of vertex",400,-1000.,1000);
975   return;
976 }
977
978 //________________________________________________________________________
979 void AliAnalysisTaskSEImpParRes::UserExec(Option_t */*option*/)
980 {
981   //
982   // Track selection and filling of d0 histograms
983   //
984   AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
985   if (!esd) {
986     AliError("ESD event not found. Nothing done!");
987     return;
988   }
989
990   Float_t diamondcovxy[3];
991   esd->GetDiamondCovXY(diamondcovxy);
992   Double_t pos[3]={esd->GetDiamondX(),esd->GetDiamondY(),0.};
993   //diamondcovxy[0]=0.05*0.05;
994   //diamondcovxy[2]=0.05*0.05;
995   Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
996   AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
997
998   AliVertexerTracks *vertexer0 = new AliVertexerTracks(esd->GetMagneticField());
999   vertexer0->SetITSMode();
1000   vertexer0->SetMinClusters(4);  
1001   if(fUseDiamond) vertexer0->SetVtxStart(diamond);
1002   AliESDVertex *vtxESDRec = (AliESDVertex*)vertexer0->FindPrimaryVertex(esd);
1003   delete vertexer0; vertexer0=0;
1004   if(vtxESDRec->GetNContributors()<1) return;
1005
1006   AliStack *stack=0;
1007   AliESDVertex *vtxESDTrue=0;
1008    if (fReadMC) { 
1009     AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); 
1010     if (!eventHandler) { 
1011       Printf("ERROR: Could not retrieve MC event handler"); 
1012       return; 
1013     } 
1014
1015     AliMCEvent* mcEvent = eventHandler->MCEvent(); 
1016     if (!mcEvent) { 
1017       Printf("ERROR: Could not retrieve MC event"); 
1018       return; 
1019     } 
1020
1021     stack = mcEvent->Stack(); 
1022     if (!stack) { 
1023       AliDebug(AliLog::kError, "Stack not available"); 
1024       return; 
1025     } 
1026
1027     //load MC header for ESD;//see $ALICE_ROOT/PWG1/global/AliAnalysisTaskSEVertexESD.cxx
1028     AliHeader *mcHeader = eventHandler->MCEvent()->Header();
1029     if (!mcHeader) {
1030       AliDebug(AliLog::kError, "Header not available");
1031       return;
1032     }
1033
1034     AliGenEventHeader* genHeader = mcHeader->GenEventHeader();
1035     Double_t vtxTrue[3];
1036     TArrayF mcVertex(3);
1037     mcVertex[0]=9999.; mcVertex[1]=9999.; mcVertex[2]=9999.;
1038     genHeader->PrimaryVertex(mcVertex);
1039     vtxTrue[0]=mcVertex[0];vtxTrue[1]=mcVertex[1];vtxTrue[2]=mcVertex[2];
1040     Double_t sigmaTrue[3]={0., 0., 0.,};
1041     //mcHeader->GetVertex(vtxTrue);//note the vtxTrue is void here,so must need the next line.
1042     //AliESDVertex *vtxESDTrue = new AliESDVertex(vtxTrue,sigmaTrue);
1043     vtxESDTrue = new AliESDVertex(vtxTrue,sigmaTrue);
1044     }
1045
1046   Int_t nTrks = esd->GetNumberOfTracks();
1047   for (Int_t it=0; it<nTrks; it++) {  // loop over tracks
1048     // read track
1049     AliESDtrack *esdtrack = esd->GetTrack(it);
1050
1051     // ask for ITS refit
1052     if (!(esdtrack->GetStatus()&AliESDtrack::kITSrefit)) {
1053       continue;
1054     }
1055     
1056     Int_t pdgCode=0; 
1057     if(fReadMC && stack) { 
1058       Int_t trkLabel = esdtrack->GetLabel(); 
1059       //Int_t trkLabel = TMath::Abs(esdtrack->GetLabel()); 
1060       if(trkLabel<0) continue;
1061       TParticle  *part = (TParticle*)stack->Particle(trkLabel); 
1062       pdgCode = TMath::Abs(part->GetPdgCode()); 
1063       //printf("pdgCode===%d\n", pdgCode);
1064       if(fSelectedPdg>0 && pdgCode!=fSelectedPdg) continue;
1065     }
1066
1067
1068     Int_t npointsITS=0,npointsSPD=0;
1069     for (Int_t i=0;i<6;i++){ 
1070       if (i<2 && esdtrack->HasPointOnITSLayer(i)) npointsSPD +=1;
1071       if (esdtrack->HasPointOnITSLayer(i)) npointsITS +=1;  
1072     }
1073
1074     //Get specific primary vertex--Reconstructed primary vertex do not include the track considering.
1075     AliVertexerTracks *vertexer = new AliVertexerTracks(esd->GetMagneticField());
1076     vertexer->SetITSMode();
1077     vertexer->SetMinClusters(4);
1078     if(fUseDiamond) vertexer->SetVtxStart(diamond);
1079     Int_t skipped[2];
1080     skipped[0] = (Int_t)esdtrack->GetID();
1081     vertexer->SetSkipTracks(1,skipped);      
1082     AliESDVertex *vtxESDSkip = (AliESDVertex*)vertexer->FindPrimaryVertex(esd); 
1083     delete vertexer; vertexer=NULL;
1084     if(vtxESDSkip->GetNContributors()<1) continue;
1085      
1086
1087     Double_t dzRec[2], covdzRec[3], dzRecSkip[2], covdzRecSkip[3],dzTrue[2], covdzTrue[3];
1088     Double_t beampiperadius=3.;
1089     Double_t pt= esdtrack->Pt();
1090     Int_t bin = PtBin(pt);
1091
1092     if(bin==-1) {
1093       delete vtxESDSkip; vtxESDSkip = 0x0;
1094       continue;
1095     }
1096
1097     esdtrack->PropagateToDCA(vtxESDRec, esd->GetMagneticField(), beampiperadius, dzRec, covdzRec);
1098     esdtrack->PropagateToDCA(vtxESDSkip, esd->GetMagneticField(), beampiperadius, dzRecSkip, covdzRecSkip);
1099     if(fReadMC) esdtrack->PropagateToDCA(vtxESDTrue, esd->GetMagneticField(), beampiperadius, dzTrue, covdzTrue);
1100     if(covdzRec[0]<0 || covdzRec[2]<0 || covdzRecSkip[0]<0 || covdzRecSkip[2]<0) {
1101       delete vtxESDSkip; vtxESDSkip = 0x0;
1102       continue;
1103     }
1104       
1105     //printf("Pt: %f GeV/c; Impact parameter: rphi %f cm  z %f cm\n", pt, dzRec[0], dzRec[1]);
1106
1107     /*
1108     // RUBEN'S METHOD, NOT FULLY IMPLEMENTED YET    
1109     Double_t      fIPCenIni[3], xyzDCA[3];
1110     for (int i=3;i--;) fIPCenIni[i] = 0.;
1111     //Int_t nTracks = nTrks - 1;
1112     esdtrack->GetXYZ(xyzDCA);
1113     //double pTrack = esdtrack->GetP();
1114     double phiTrack = esdtrack->Phi();
1115     double cs = TMath::Cos(phiTrack);
1116     double sn = TMath::Sin(phiTrack);
1117     double trDCA = (xyzDCA[0]-fIPCenIni[0])         *sn - (xyzDCA[1]-fIPCenIni[1])         *cs;  // track signed DCA to origin
1118     double vtDCA = (vtxESDSkip->GetXv()-fIPCenIni[0])*sn - (vtxESDSkip->GetYv()-fIPCenIni[1])*cs;  // vertex signed DCA to origin
1119     
1120     // update the estimator values
1121     //double estIP  = rvD*rtD;
1122     double estVtx = vtDCA*( vtDCA- trDCA);
1123     //double estTrc = rtD*(rtD - rvD);
1124     //
1125     //if (nTracks >= fMinTracksForIP) fEstimIP->Fill(phiTrack, estIP);
1126     fEstimVtx->Fill(10000*estVtx);
1127     //if (pTrack<1e-6) pTrack = GetTrackMinP()+1e6;
1128     //fEstimTrc->Fill(1./pTrack,estTrc);
1129     */
1130
1131
1132     //fill the histgram with all particle 
1133     //-------------------------------------------1----------------------------------------------
1134     
1135     /*
1136     TString named0AllrphiRec=" ",named0AllzRec =" ";//named0AllrphiTrue=" ",named0AllzTrue =" ";
1137       //named0AllrphiSkip=" ",named0AllzSkip =" ";
1138       
1139       named0AllrphiRec ="d0allrphiRec_";
1140       named0AllrphiRec += bin;
1141       named0AllzRec = "d0allzRec_";
1142       named0AllzRec += bin;
1143       ((TH1F*)(fOutputallRec->FindObject(named0AllrphiRec)))->Fill(10000*dzRec[0]);
1144       ((TH1F*)(fOutputallRec->FindObject(named0AllzRec)))->Fill(10000*dzRec[1]);
1145     */
1146
1147     //-------------------------------------------2----------------------------------------------
1148     //TSting named0AllrphiRec = "d0allrphiRec_" + bin;
1149     //TSting named0AllzRec = "d0allzRec_" + bin;
1150     //((TH1F*)(fOutputallRec->FindObject(named0AllrphiRec.Data())))->Fill(10000.*dzRec[0]);
1151     //((TH1F*)(fOutputallRec->FindObject(named0AllzRec.Data())))->Fill(10000.*dzRec[1]);
1152
1153     //-------------------------------------------3------------------------------------------------
1154
1155
1156     // ITS standalone
1157     if (!(esdtrack->GetStatus()&AliESDtrack::kTPCrefit) && (esdtrack->GetStatus()&AliESDtrack::kITSpureSA)
1158         && npointsSPD>0 && npointsITS>=4) {
1159       char *named0ITSpureSArphiRec = Form("d0itspureSArphiRec_%d", bin);
1160       char *named0ITSpureSArphiSkip = Form("d0itspureSArphiSkip_%d", bin);
1161       char *named0ITSpureSAzRec = Form("d0itspureSAzRec_%d", bin); 
1162       char *named0ITSpureSAzSkip = Form("d0itspureSAzSkip_%d", bin); 
1163       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSArphiRec)))->Fill(10000.*dzRec[0]);
1164       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSAzRec)))->Fill(10000.*dzRec[1]);
1165       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSArphiSkip)))->Fill(10000.*dzRecSkip[0]);
1166       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSAzSkip)))->Fill(10000.*dzRecSkip[1]);
1167     }
1168
1169     
1170     // ask for TPC refit
1171     if (!(esdtrack->GetStatus()&AliESDtrack::kTPCrefit) || esdtrack->GetNcls(1)<70) {
1172       delete vtxESDSkip; vtxESDSkip = 0x0;
1173       continue;
1174     }
1175
1176     // only ITS and TPC refit
1177     char *named0OnlyrefitrphiRec = Form("d0onlyrefitrphiRec_%d", bin);
1178     char *named0OnlyrefitrphiSkip = Form("d0onlyrefitrphiSkip_%d", bin);
1179     char *named0OnlyrefitzRec = Form("d0onlyrefitzRec_%d", bin);
1180     char *named0OnlyrefitzSkip = Form("d0onlyrefitzSkip_%d", bin); 
1181     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitrphiRec)))->Fill(10000.*dzRec[0]);
1182     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitzRec)))->Fill(10000.*dzRec[1]);
1183     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1184     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitzSkip)))->Fill(10000.*dzRecSkip[1]);  
1185    
1186
1187     if(npointsITS>=4 && npointsSPD>0) {
1188       char *named0PartpointrphiRec = Form("d0partpointrphiRec_%d", bin);
1189       char *named0PartpointrphiSkip = Form("d0partpointrphiSkip_%d", bin);
1190       char *named0PartpointzRec = Form("d0partpointzRec_%d", bin); 
1191       char *named0PartpointzSkip = Form("d0partpointzSkip_%d", bin); 
1192       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointrphiRec)))->Fill(10000.*dzRec[0]);
1193       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointzRec)))->Fill(10000.*dzRec[1]);
1194       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1195       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointzSkip)))->Fill(10000.*dzRecSkip[1]);
1196     }
1197
1198     if(npointsSPD>0) {
1199       char *named0OnepointSPDrphiRec = Form("d0onepointSPDrphiRec_%d", bin);
1200       char *named0OnepointSPDrphiSkip = Form("d0onepointSPDrphiSkip_%d", bin);
1201       char *named0OnepointSPDzRec = Form("d0onepointSPDzRec_%d", bin); 
1202       char *named0OnepointSPDzSkip = Form("d0onepointSPDzSkip_%d", bin); 
1203       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDrphiRec)))->Fill(10000.*dzRec[0]);
1204       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDzRec)))->Fill(10000.*dzRec[1]);
1205       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1206       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDzSkip)))->Fill(10000.*dzRecSkip[1]);
1207     }
1208
1209     // with 6 ITS points (including different selection)
1210     if(npointsITS==6) {
1211
1212        //pt 
1213       char *named0Pt = Form("d0pt_%d",bin);
1214       ((TH1F*)(fOutputPt->FindObject(named0Pt)))->Fill(pt);
1215
1216       // allpoint
1217       char *named0AllpointrphiRec = Form("d0allpointrphiRec_%d", bin);
1218       char *named0AllpointrphiSkip = Form("d0allpointrphiSkip_%d", bin);
1219       char *named0AllpointrphiTrue = Form("d0allpointrphiTrue_%d", bin);
1220       char *named0AllpointzRec = Form("d0allpointzRec_%d", bin);
1221       char *named0AllpointzSkip = Form("d0allpointzSkip_%d", bin); 
1222       char *named0AllpointzTrue = Form("d0allpointzTrue_%d", bin);
1223       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointrphiRec)))->Fill(10000.*dzRec[0]);
1224       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointzRec)))->Fill(10000.*dzRec[1]);
1225       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1226       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointzSkip)))->Fill(10000.*dzRecSkip[1]);
1227       ((TH1F*)(fOutputallPointTrue->FindObject(named0AllpointrphiTrue)))->Fill(10000.*dzTrue[0]);
1228       ((TH1F*)(fOutputallPointTrue->FindObject(named0AllpointzTrue)))->Fill(10000.*dzTrue[1]);
1229       
1230       // pulls
1231       char *named0PullAllpointrphiRec = Form("d0pullAllpointrphiRec_%d", bin);
1232       char *named0PullAllpointrphiSkip = Form("d0pullAllpointrphiSkip_%d", bin);
1233       char *named0PullAllpointrphiTrue = Form("d0pullAllpointrphiTrue_%d", bin);
1234       char *named0PullAllpointzRec = Form("d0pullAllpointzRec_%d", bin);
1235       char *named0PullAllpointzSkip = Form("d0pullAllpointzSkip_%d", bin); 
1236       char *named0PullAllpointzTrue = Form("d0pullAllpointzTrue_%d", bin);
1237       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointrphiRec)))->Fill(dzRec[0]/TMath::Sqrt(covdzRec[0]));     
1238       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointzRec)))->Fill(dzRec[1]/TMath::Sqrt(covdzRec[2]));
1239       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointrphiSkip)))->Fill(dzRecSkip[0]/TMath::Sqrt(covdzRecSkip[0]));
1240       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointzSkip)))->Fill(dzRecSkip[1]/TMath::Sqrt(covdzRecSkip[2]));
1241       ((TH1F*)(fOutputpullAllpointTrue->FindObject(named0PullAllpointrphiTrue)))->Fill(dzTrue[0]/TMath::Sqrt(covdzTrue[0]));
1242       ((TH1F*)(fOutputpullAllpointTrue->FindObject(named0PullAllpointzTrue)))->Fill(dzTrue[1]/TMath::Sqrt(covdzTrue[2]));
1243       
1244       //postive and negative track
1245       Short_t charge=esdtrack->Charge();
1246       if(charge==1 ) {
1247         char *named0PostvtracrphiRec = Form("d0postvtracrphiRec_%d", bin);
1248         char *named0PostvtracrphiSkip = Form("d0postvtracrphiSkip_%d", bin);
1249         char *named0PostvtracrphiTrue = Form("d0postvtracrphiTrue_%d", bin);
1250         char *named0PostvtraczRec = Form("d0postvtraczRec_%d", bin); 
1251         char *named0PostvtraczSkip = Form("d0postvtraczSkip_%d", bin);
1252         char *named0PostvtraczTrue = Form("d0postvtraczTrue_%d", bin);
1253         ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtracrphiRec)))->Fill(10000.*dzRec[0]);
1254         ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtraczRec)))->Fill(10000.*dzRec[1]);
1255         ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1256         ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
1257         ((TH1F*)(fOutputpostvTracTrue->FindObject(named0PostvtracrphiTrue)))->Fill(10000.*dzTrue[0]);
1258         ((TH1F*)(fOutputpostvTracTrue->FindObject(named0PostvtraczTrue)))->Fill(10000.*dzTrue[1]);
1259       }
1260       
1261       if(charge==-1 ) {
1262         char *named0NegtvtracrphiRec = Form("d0negtvtracrphiRec_%d", bin);
1263         char *named0NegtvtracrphiSkip = Form("d0negtvtracrphiSkip_%d", bin);
1264         char *named0NegtvtracrphiTrue = Form("d0negtvtracrphiTrue_%d", bin);
1265         char *named0NegtvtraczRec = Form("d0negtvtraczRec_%d", bin); 
1266         char *named0NegtvtraczSkip = Form("d0negtvtraczSkip_%d", bin);
1267         char *named0NegtvtraczTrue = Form("d0negtvtraczTrue_%d", bin);
1268         ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtracrphiRec)))->Fill(10000.*dzRec[0]);
1269         ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtraczRec)))->Fill(10000.*dzRec[1]);
1270         ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1271         ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
1272         ((TH1F*)(fOutputnegtvTracTrue->FindObject(named0NegtvtracrphiTrue)))->Fill(10000.*dzTrue[0]);
1273         ((TH1F*)(fOutputnegtvTracTrue->FindObject(named0NegtvtraczTrue)))->Fill(10000.*dzTrue[1]);      
1274       }    
1275       
1276       // SinTheta 
1277       Double_t theta=esdtrack->Theta(); 
1278       Double_t Sintheta=TMath::Sin(theta);
1279       Int_t thetabin = SinThetaBin(Sintheta);
1280       if(thetabin<0) {delete vtxESDSkip;continue;}
1281       
1282       if(bin==1) {
1283         char *named0SinthetaonerphiRec = Form("d0sinthetaonerphiRec_%d", thetabin);
1284         char *named0SinthetaonezRec = Form("d0sinthetaonezRec_%d", thetabin);
1285         char *named0SinthetaonerphiSkip = Form("d0sinthetaonerphiSkip_%d", thetabin);
1286         char *named0SinthetaonezSkip = Form("d0sinthetaonezSkip_%d", thetabin);
1287         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetaonerphiRec)))->Fill(10000*dzRec[0]);
1288         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetaonezRec)))->Fill(10000*dzRec[1]);
1289         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetaonerphiSkip)))->Fill(10000*dzRecSkip[0]);
1290         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetaonezSkip)))->Fill(10000*dzRecSkip[1]);
1291       }
1292       
1293       if(bin==5) {
1294         char *named0SinthetatworphiRec = Form("d0sinthetatworphiRec_%d", thetabin);
1295         char *named0SinthetatwozRec = Form("d0sinthetatwozRec_%d", thetabin);
1296         char *named0SinthetatworphiSkip = Form("d0sinthetatworphiSkip_%d", thetabin);
1297         char *named0SinthetatwozSkip = Form("d0sinthetatwozSkip_%d", thetabin);
1298         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetatworphiRec)))->Fill(10000*dzRec[0]);
1299         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetatwozRec)))->Fill(10000*dzRec[1]);
1300         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetatworphiSkip)))->Fill(10000*dzRecSkip[0]);
1301         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetatwozSkip)))->Fill(10000*dzRecSkip[1]);
1302       }
1303       
1304       if(bin==10) {
1305         char *named0SinthetathreerphiRec = Form("d0sinthetathreerphiRec_%d", thetabin);
1306         char *named0SinthetathreezRec = Form("d0sinthetathreezRec_%d", thetabin);
1307         char *named0SinthetathreerphiSkip = Form("d0sinthetathreerphiSkip_%d", thetabin);
1308         char *named0SinthetathreezSkip = Form("d0sinthetathreezSkip_%d", thetabin);
1309         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetathreerphiRec)))->Fill(10000*dzRec[0]);
1310         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetathreezRec)))->Fill(10000*dzRec[1]);
1311         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetathreerphiSkip)))->Fill(10000*dzRecSkip[0]);
1312         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetathreezSkip)))->Fill(10000*dzRecSkip[1]);
1313       }
1314       
1315       if(bin==15) {
1316         char *named0SinthetafourrphiRec = Form("d0sinthetafourrphiRec_%d", thetabin);
1317         char *named0SinthetafourzRec = Form("d0sinthetafourzRec_%d", thetabin);
1318         char *named0SinthetafourrphiSkip = Form("d0sinthetafourrphiSkip_%d", thetabin);
1319         char *named0SinthetafourzSkip = Form("d0sinthetafourzSkip_%d", thetabin);
1320         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetafourrphiRec)))->Fill(10000*dzRec[0]);
1321         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetafourzRec)))->Fill(10000*dzRec[1]);
1322         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetafourrphiSkip)))->Fill(10000*dzRecSkip[0]);
1323         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetafourzSkip)))->Fill(10000*dzRecSkip[1]);
1324       }
1325       
1326       //Phi
1327       Double_t phi=esdtrack->Phi(); 
1328       //Double_t pi=TMath::Pi();
1329       Int_t phibin=PhiBin(phi);
1330       if(phibin<0) {delete vtxESDSkip;continue;}
1331       if(pt>0.4 && pt<0.6){
1332         char *named0PhiallpointrphiSkip =Form("d0phiallpointrphiSkip_%d",phibin);
1333         char *named0PhiallpointzSkip = Form("d0phiallpointzSkip_%d",phibin);
1334         char *named0PhipostvtracrphiSkip =Form("d0phipostvtracrphiSkip_%d",phibin);
1335         char *named0PhipostvtraczSkip = Form("d0phipostvtraczSkip_%d",phibin);
1336         char *named0PhinegtvtracrphiSkip =Form("d0phinegtvtracrphiSkip_%d",phibin);
1337         char *named0PhinegtvtraczSkip = Form("d0phinegtvtraczSkip_%d",phibin);
1338         ((TH1F*)(fOutputphiAllpointSkip->FindObject(named0PhiallpointrphiSkip)))->Fill(10000*dzRecSkip[0]);
1339         ((TH1F*)(fOutputphiAllpointSkip->FindObject(named0PhiallpointzSkip)))->Fill(10000*dzRecSkip[1]);
1340         ((TH1F*)(fOutputphiPostvtracSkip->FindObject(named0PhipostvtracrphiSkip)))->Fill(10000*dzRecSkip[0]);
1341         ((TH1F*)(fOutputphiPostvtracSkip->FindObject(named0PhipostvtraczSkip)))->Fill(10000*dzRecSkip[1]);
1342         ((TH1F*)(fOutputphiNegtvtracSkip->FindObject(named0PhinegtvtracrphiSkip)))->Fill(10000*dzRecSkip[0]);
1343         ((TH1F*)(fOutputphiNegtvtracSkip->FindObject(named0PhinegtvtraczSkip)))->Fill(10000*dzRecSkip[1]);
1344       }
1345       
1346       //cluster type
1347       Int_t ctypeSPD0 = ClusterTypeOnITSLayer(esdtrack,0);
1348       if(ctypeSPD0==-1) {delete vtxESDSkip;continue;}
1349       Int_t ctypeSPD1 = ClusterTypeOnITSLayer(esdtrack,1);
1350       if(ctypeSPD1==-1) {delete vtxESDSkip;continue;}
1351
1352       if(ctypeSPD0==1) {
1353         char *named0ClustertypeSPD01rphiSkip = Form("d0clustertypeSPD01rphiSkip_%d",phibin);
1354         char *named0ClustertypeSPD01zSkip = Form("d0clustertypeSPD01rphiSkip_%d",phibin);
1355         ((TH1F*)(fOutputclusterTypeSPD01Skip->FindObject(named0ClustertypeSPD01rphiSkip)))->Fill(10000*dzRecSkip[0]);
1356         ((TH1F*)(fOutputclusterTypeSPD01Skip->FindObject(named0ClustertypeSPD01zSkip)))->Fill(10000*dzRecSkip[1]);
1357       }
1358       
1359       if(ctypeSPD0==2) {
1360         char *named0ClustertypeSPD02rphiSkip = Form("d0clustertypeSPD02rphiSkip_%d",phibin);
1361         char *named0ClustertypeSPD02zSkip = Form("d0clustertypeSPD02rphiSkip_%d",phibin);
1362         ((TH1F*)(fOutputclusterTypeSPD02Skip->FindObject(named0ClustertypeSPD02rphiSkip)))->Fill(10000*dzRecSkip[0]);
1363         ((TH1F*)(fOutputclusterTypeSPD02Skip->FindObject(named0ClustertypeSPD02zSkip)))->Fill(10000*dzRecSkip[1]);
1364       }
1365       
1366       if(ctypeSPD0==3) {
1367         char *named0ClustertypeSPD03rphiSkip = Form("d0clustertypeSPD03rphiSkip_%d",phibin);
1368         char *named0ClustertypeSPD03zSkip = Form("d0clustertypeSPD03zSkip_%d",phibin);
1369         ((TH1F*)(fOutputclusterTypeSPD03Skip->FindObject(named0ClustertypeSPD03rphiSkip)))->Fill(10000*dzRecSkip[0]);
1370         ((TH1F*)(fOutputclusterTypeSPD03Skip->FindObject(named0ClustertypeSPD03zSkip)))->Fill(10000*dzRecSkip[1]);
1371       }
1372       
1373       if(ctypeSPD1==1){
1374         char *named0ClustertypeSPD11rphiSkip = Form("d0clustertypeSPD11rphiSkip_%d",phibin);
1375         char *named0ClustertypeSPD11zSkip = Form("d0clustertypeSPD11rphiSkip_%d",phibin);
1376         ((TH1F*)(fOutputclusterTypeSPD11Skip->FindObject(named0ClustertypeSPD11rphiSkip)))->Fill(10000*dzRecSkip[0]);
1377         ((TH1F*)(fOutputclusterTypeSPD11Skip->FindObject(named0ClustertypeSPD11zSkip)))->Fill(10000*dzRecSkip[1]);
1378       } 
1379       if(ctypeSPD1==2){
1380         char *named0ClustertypeSPD12rphiSkip = Form("d0clustertypeSPD12rphiSkip_%d",phibin);
1381         char *named0ClustertypeSPD12zSkip = Form("d0clustertypeSPD12rphiSkip_%d",phibin);
1382         ((TH1F*)(fOutputclusterTypeSPD12Skip->FindObject(named0ClustertypeSPD12rphiSkip)))->Fill(10000*dzRecSkip[0]);
1383         ((TH1F*)(fOutputclusterTypeSPD12Skip->FindObject(named0ClustertypeSPD12zSkip)))->Fill(10000*dzRecSkip[1]);
1384       } 
1385       
1386       if(ctypeSPD1==3){
1387         char *named0ClustertypeSPD13rphiSkip = Form("d0clustertypeSPD13rphiSkip_%d",phibin);
1388         char *named0ClustertypeSPD13zSkip = Form("d0clustertypeSPD13rphiSkip_%d",phibin);
1389         ((TH1F*)(fOutputclusterTypeSPD13Skip->FindObject(named0ClustertypeSPD13rphiSkip)))->Fill(10000*dzRecSkip[0]);
1390         ((TH1F*)(fOutputclusterTypeSPD13Skip->FindObject(named0ClustertypeSPD13zSkip)))->Fill(10000*dzRecSkip[1]);
1391       }  
1392     }
1393     
1394     delete vtxESDSkip; vtxESDSkip = 0x0;
1395   }  // end loop of tracks
1396   
1397   delete diamond; diamond=NULL;
1398   delete vtxESDRec; vtxESDRec = 0x0;
1399   delete vtxESDTrue;vtxESDTrue = 0x0;
1400   fNentries->Fill(1);
1401   PostData(1, fOutputitspureSARec);
1402   PostData(2, fOutputitspureSASkip);
1403   PostData(3, fOutputallPointRec);
1404   PostData(4, fOutputallPointSkip);
1405   PostData(5, fOutputpartPointRec);
1406   PostData(6, fOutputpartPointSkip);
1407   PostData(7, fOutputonepointSPDRec);
1408   PostData(8, fOutputonepointSPDSkip);
1409   PostData(9, fOutputpostvTracRec);
1410   PostData(10, fOutputpostvTracSkip);
1411   PostData(11, fOutputnegtvTracRec);
1412   PostData(12, fOutputnegtvTracSkip);
1413   PostData(13, fOutputpullAllpointRec);
1414   PostData(14, fOutputpullAllpointSkip);
1415   PostData(15, fOutputOnlyRefitRec);
1416   PostData(16, fOutputOnlyRefitSkip);
1417   PostData(17, fOutputSinThetaRec);
1418   PostData(18, fOutputSinThetaSkip);
1419   PostData(19, fOutputallPointTrue);
1420   PostData(20, fOutputpostvTracTrue);
1421   PostData(21, fOutputnegtvTracTrue);
1422   PostData(22, fOutputpullAllpointTrue);
1423   PostData(23, fOutputphiAllpointSkip);
1424   PostData(24, fOutputphiPostvtracSkip);
1425   PostData(25, fOutputphiNegtvtracSkip);
1426   PostData(26, fOutputclusterTypeSPD01Skip);
1427   PostData(27, fOutputclusterTypeSPD02Skip);
1428   PostData(28, fOutputclusterTypeSPD03Skip);
1429   PostData(29, fOutputclusterTypeSPD11Skip);
1430   PostData(30, fOutputclusterTypeSPD12Skip);
1431   PostData(31, fOutputclusterTypeSPD13Skip);
1432   PostData(32, fOutputPt);
1433   PostData(33, fNentries);
1434   PostData(34, fEstimVtx);
1435   
1436   return;
1437 }
1438
1439 //________________________________________________________________________
1440 Int_t AliAnalysisTaskSEImpParRes::PtBin(Double_t pt) const {
1441   //
1442   // return the number of the pt bin
1443   //
1444
1445   if (pt>0.22 && pt<0.23) return 1;
1446   if (pt>0.26 && pt<0.27) return 2; 
1447   if (pt>0.35 && pt<0.36) return 3;
1448   if (pt>0.45 && pt<0.46) return 4; 
1449   if (pt>0.55 && pt<0.56) return 5;
1450   if (pt>0.65 && pt<0.66) return 6; 
1451   if (pt>0.75 && pt<0.76) return 7; 
1452   if (pt>0.85 && pt<0.865) return 8; 
1453   if (pt>1.05 && pt<1.07) return 9;
1454   if (pt>1.25 && pt<1.30) return 10; 
1455   if (pt>1.4 && pt<1.55) return 11; 
1456   if (pt>1.6 && pt<1.8) return 12; 
1457   if (pt>1.8 && pt<2.0) return 13; 
1458   if (pt>2.1 && pt<2.3) return 14; 
1459   if (pt>2.34 && pt<2.64) return 15; 
1460   if (pt>2.65 && pt<3.0) return 16; 
1461   if (pt>3.1 && pt<4.) return 17; 
1462   if (pt>4.1 && pt<5.2) return 18; 
1463   if (pt>5.3 && pt<6.8)  return 19; 
1464   if (pt>7.0 && pt<8.8) return 20; 
1465   if (pt>9. && pt<11.) return 21;
1466   if (pt>11.1 && pt<14.) return 22; 
1467   if (pt>14.1  && pt<17.)  return 23;
1468   if (pt>17.2  && pt<21.8) return 24; 
1469   if (pt>22.1  && pt<29.)  return 25;
1470   if (pt>29.05  && pt<35.)  return 26;
1471   /*
1472   if (pt>0.22 && pt<0.23) return 1 ;
1473   if (pt>0.26 && pt<0.27) return 2 ; 
1474   if (pt>0.35 && pt<0.36) return 3 ;
1475   if (pt>0.45 && pt<0.46) return 4 ; 
1476   if (pt>0.55 && pt<0.56) return 5 ;
1477   if (pt>0.65 && pt<0.66) return 6 ; 
1478   if (pt>0.75 && pt<0.76) return 7 ; 
1479   if (pt>0.85 && pt<0.86) return 8 ; 
1480   if (pt>1.05 && pt<1.06) return 9 ;
1481   if (pt>1.25 && pt<1.27) return 10; 
1482   if (pt>1.45 && pt<1.47) return 11; 
1483   if (pt>1.65 && pt<1.67) return 12; 
1484   if (pt>1.85 && pt<1.87) return 13; 
1485   if (pt>2.15 && pt<2.17) return 14; 
1486   if (pt>2.45 && pt<2.48) return 15; 
1487   if (pt>2.65 && pt<2.67) return 16; 
1488   if (pt>2.85 && pt<2.87) return 17; 
1489   if (pt>3.25 && pt<3.27) return 18; 
1490   if (pt>3.75 && pt<3.8)  return 19; 
1491   if (pt>4.15 && pt<4.20) return 20; 
1492   if (pt>4.95 && pt<5.15) return 21;
1493   if (pt>5.35 && pt<5.55) return 22; 
1494   if (pt>6.0  && pt<6.8)  return 23;
1495   if (pt>8.5  && pt<10.5) return 24; 
1496   if (pt>12.  && pt<19.)  return 25;
1497   if (pt>21.  && pt<32.)  return 26;
1498   */  
1499   return -1; 
1500 }
1501
1502 //________________________________________________________________________
1503 Double_t AliAnalysisTaskSEImpParRes::Getd0HistRange(Int_t i) const {
1504   //
1505   // Return the range of the d0 histograms for each pt bin
1506   //
1507   if (i==1) return  2500.; 
1508   if (i==2) return  1800.;
1509   if (i==3) return  1750.;
1510   if (i==4) return  1200.;
1511   if (i==5) return  1000.;
1512   if (i==6) return  900.;
1513   if (i==7) return  850.;
1514   if (i==8) return  700.;
1515   if (i==9) return  650.;
1516   if (i==10) return 600.;
1517   if (i==11) return 550.;
1518   if (i==12) return 500.;
1519   if (i==13) return 450.;
1520   if (i==14) return 400.;
1521   if (i==15) return 390.;
1522   if (i==16) return 380.;
1523   if (i==17) return 380.;
1524   if (i==18) return 350.;
1525   if (i==19) return 320.;
1526   if (i==20) return 300.;
1527   if (i==21) return 290.;
1528   if (i==22) return 270.;
1529   if (i==23) return 250.;
1530   if (i==24) return 270.;
1531   if (i==25) return 279.;
1532   if (i==26) return 270.;
1533
1534   return 2000.;
1535 }
1536
1537 //________________________________________________________________________
1538 Int_t AliAnalysisTaskSEImpParRes::SinThetaBin(Double_t sintheta) const {  
1539   //
1540   // Return the number of the sinTheta bin
1541   // 
1542   if(sintheta>0.7 && sintheta<0.73) return 1;
1543   if(sintheta>0.73 && sintheta<0.76) return 2; 
1544   if(sintheta>0.76 && sintheta<0.79) return 3; 
1545   if(sintheta>0.79 && sintheta<0.82) return 4;
1546   if(sintheta>0.82 && sintheta<0.85) return 5;       
1547   if(sintheta>0.85 && sintheta<0.88) return 6; 
1548   if(sintheta>0.88 && sintheta<0.91) return 7;
1549   if(sintheta>0.91 && sintheta<0.94) return 8;       
1550   if(sintheta>0.94 && sintheta<0.97) return 9; 
1551   if(sintheta>0.97 && sintheta<1.0) return 10;  
1552   return -1;
1553 }
1554
1555 //___________________________________________________________________________
1556 Int_t AliAnalysisTaskSEImpParRes::PhiBin(Double_t phi) const { 
1557   Double_t pi=TMath::Pi();
1558   if(phi>2.*pi || phi<0.) return -1;
1559   if(phi<0.2*pi) return 1;
1560   if(phi<0.4*pi) return 2;
1561   if(phi<0.6*pi) return 3;
1562   if(phi<0.8*pi) return 4;
1563   if(phi<1.0*pi) return 5;
1564   if(phi<1.2*pi) return 6;
1565   if(phi<1.4*pi) return 7;
1566   if(phi<1.6*pi) return 8;
1567   if(phi<1.8*pi) return 9;
1568   if(phi<2.*pi) return 10;
1569   return -1;
1570 }
1571
1572 //___________________________________________________________________________
1573 void AliAnalysisTaskSEImpParRes::Terminate(Option_t */*option*/) {
1574   //
1575   // Terminate analysis
1576   //
1577
1578   if (fDebug>1) printf("AnalysisTaskSEImpParRes: Terminate() \n");
1579
1580   fOutputitspureSARec = dynamic_cast<TList*>(GetOutputData(1));
1581   if (!fOutputitspureSARec) printf("ERROR: fOutputitspureSARec not available\n");
1582
1583   fOutputitspureSASkip = dynamic_cast<TList*>(GetOutputData(2));
1584   if (!fOutputitspureSASkip) printf("ERROR: fOutputitspureSASkip not available\n");
1585
1586   fOutputallPointRec = dynamic_cast<TList*>(GetOutputData(3));
1587   if (!fOutputallPointRec) printf("ERROR: fOutputallPointRec not available\n");
1588
1589   fOutputallPointSkip = dynamic_cast<TList*>(GetOutputData(4));
1590   if (!fOutputallPointSkip) printf("ERROR: fOutputallPointSkip not available\n");
1591
1592   fOutputpartPointRec = dynamic_cast<TList*>(GetOutputData(5));
1593   if (!fOutputpartPointRec) printf("ERROR: fOutputpartPointRec not available\n");
1594
1595   fOutputpartPointSkip = dynamic_cast<TList*>(GetOutputData(6));
1596   if (!fOutputpartPointSkip) printf("ERROR: fOutputpartPointSkip not available\n");
1597
1598   fOutputonepointSPDRec = dynamic_cast<TList*>(GetOutputData(7));
1599   if (!fOutputonepointSPDRec) printf("ERROR: fOutputonepointSPDSRec not available\n");
1600
1601   fOutputonepointSPDSkip = dynamic_cast<TList*>(GetOutputData(8));
1602   if (!fOutputonepointSPDSkip) printf("ERROR: fOutputonepointSPDSkip not available\n");
1603
1604   fOutputpostvTracRec = dynamic_cast<TList*>(GetOutputData(9));
1605   if (!fOutputpostvTracRec) printf("ERROR: fOutputpostvTracRec not available\n");
1606
1607   fOutputpostvTracSkip = dynamic_cast<TList*>(GetOutputData(10));
1608   if (!fOutputpostvTracSkip) printf("ERROR: fOutputpostvTracSkip not available\n");
1609
1610   fOutputnegtvTracRec = dynamic_cast<TList*>(GetOutputData(11));
1611   if (!fOutputnegtvTracRec) printf("ERROR: fOutputnegtvTracRec not available\n");
1612
1613   fOutputnegtvTracSkip = dynamic_cast<TList*>(GetOutputData(12));
1614   if (!fOutputnegtvTracSkip) printf("ERROR: fOutputnegtvTracSkip not available\n");
1615
1616
1617   fOutputpullAllpointRec = dynamic_cast<TList*>(GetOutputData(13));
1618   if (!fOutputpullAllpointRec) printf("ERROR: fOutputpullAllpointRec not available\n");
1619
1620   fOutputpullAllpointSkip = dynamic_cast<TList*>(GetOutputData(14));
1621   if (!fOutputpullAllpointSkip) printf("ERROR: fOutputpullAllpointSkip not available\n");
1622
1623   fOutputOnlyRefitRec = dynamic_cast<TList*>(GetOutputData(15));
1624   if (!fOutputOnlyRefitRec) printf("ERROR: fOutputOnlyRefitRec not available\n");
1625
1626   fOutputOnlyRefitSkip = dynamic_cast<TList*>(GetOutputData(16));
1627   if (!fOutputOnlyRefitSkip) printf("ERROR: fOutputOnlyRefitSkip not available\n");
1628  
1629   fOutputSinThetaRec = dynamic_cast<TList*>(GetOutputData(17));
1630   if (!fOutputSinThetaRec) printf("ERROR:fOutputSinThetaRec not available\n");
1631
1632   fOutputSinThetaSkip = dynamic_cast<TList*>(GetOutputData(18));
1633   if (!fOutputSinThetaSkip) printf("ERROR:fOutputSinThetaSkip not available\n");
1634   
1635   fOutputallPointTrue = dynamic_cast<TList*>(GetOutputData(19));
1636   if (!fOutputallPointTrue) printf("ERROR:fOutputallPointTrue not available\n");
1637   
1638   fOutputpostvTracTrue = dynamic_cast<TList*>(GetOutputData(20));
1639   if (!fOutputpostvTracTrue) printf("ERROR:fOutputpostvTracTrue not available\n");
1640   
1641   fOutputnegtvTracTrue = dynamic_cast<TList*>(GetOutputData(21));
1642   if (!fOutputnegtvTracTrue) printf("ERROR:fOutputnegtvTracTrue not available\n");
1643   
1644   fOutputpullAllpointTrue = dynamic_cast<TList*>(GetOutputData(22));
1645   if (!fOutputpullAllpointTrue) printf("ERROR:fOutputpullAllpointTrue not available\n");
1646   
1647   fOutputphiAllpointSkip = dynamic_cast<TList*>(GetOutputData(23));
1648   if (!fOutputphiAllpointSkip) printf("ERROR:fOutputphiAllpointSkip not available\n");
1649   
1650   fOutputphiPostvtracSkip = dynamic_cast<TList*>(GetOutputData(24));
1651   if (!fOutputphiPostvtracSkip) printf("ERROR:fOutputphiPostvtracSkip not available\n");
1652   
1653   fOutputphiNegtvtracSkip = dynamic_cast<TList*>(GetOutputData(25));
1654   if (!fOutputphiNegtvtracSkip) printf("ERROR:fOutputphiNegtvtracSkip not available\n");
1655   
1656   fOutputclusterTypeSPD01Skip = dynamic_cast<TList*>(GetOutputData(26));
1657   if (!fOutputclusterTypeSPD01Skip) printf("ERROR:fOutputclusterTypeSPD01Skip not available\n");
1658   
1659   fOutputclusterTypeSPD02Skip = dynamic_cast<TList*>(GetOutputData(27));
1660   if (!fOutputclusterTypeSPD02Skip) printf("ERROR:fOutputclusterTypeSPD02Skip not available\n");
1661   
1662   fOutputclusterTypeSPD03Skip = dynamic_cast<TList*>(GetOutputData(28));
1663   if (!fOutputclusterTypeSPD03Skip) printf("ERROR:fOutputclusterTypeSPD03Skip not available\n");
1664   
1665   fOutputclusterTypeSPD11Skip = dynamic_cast<TList*>(GetOutputData(29));
1666   if (!fOutputclusterTypeSPD11Skip) printf("ERROR:fOutputclusterTypeSPD11Skip not available\n");
1667   
1668   fOutputclusterTypeSPD12Skip = dynamic_cast<TList*>(GetOutputData(30));
1669   if (!fOutputclusterTypeSPD12Skip) printf("ERROR:fOutputclusterTypeSPD12Skip not available\n");
1670   
1671   fOutputclusterTypeSPD13Skip = dynamic_cast<TList*>(GetOutputData(31));
1672   if (!fOutputclusterTypeSPD13Skip) printf("ERROR:fOutputclusterTypeSPD13Skip not available\n");
1673   
1674   fOutputPt = dynamic_cast<TList*>(GetOutputData(32));
1675   if (!fOutputPt) printf("ERROR: fOutputPt not available\n");
1676   
1677   fNentries = dynamic_cast<TH1F*>(GetOutputData(33));
1678   if (!fNentries) printf("ERROR: fNentries not available\n");
1679   
1680   fEstimVtx = dynamic_cast<TH1F*>(GetOutputData(34));
1681   if (!fEstimVtx) printf("ERROR: fEstimVtx not available\n");
1682   return;
1683 }
1684
1685
1686 Int_t AliAnalysisTaskSEImpParRes::ClusterTypeOnITSLayer(AliESDtrack *track,Int_t layer) const {
1687 //
1688 // Returns cluster type on ITS layer. Returns -1 if no cluster on this layer
1689 //
1690    Int_t ctype=-1;
1691
1692   if(layer<0 || layer>5) return ctype;
1693   if(!track->HasPointOnITSLayer(layer)) return ctype;
1694
1695   const AliTrackPointArray *array = track->GetTrackPointArray();
1696     if(!array) {
1697       printf("No tracks points avaialble: check ESDfriends\n");
1698       return ctype;
1699    }
1700   AliTrackPoint point;
1701   Int_t ipt,volId,modId,layerId;
1702    for(ipt=0; ipt<array->GetNPoints(); ipt++) {
1703       array->GetPoint(point,ipt);
1704       volId = point.GetVolumeID();
1705       if(volId<=0) continue;
1706       layerId = AliGeomManager::VolUIDToLayer(volId,modId);
1707       if(layerId==layer+1 && !point.IsExtra()) {
1708            ctype = point.GetClusterType();
1709            break;
1710       }
1711   }
1712    return ctype;
1713
1714