]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/ITS/AliAnalysisTaskSEImpParRes.cxx
e03ee8b54e8a31ea759270c3aff42afb5c10f7fe
[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 <fstream.h>
25 #include <Riostream.h>
26 #include <TList.h>
27 #include <TH1F.h>
28
29 #include "AliAnalysisManager.h"
30 #include "AliMCEventHandler.h"
31 #include "AliMCEvent.h"
32 #include "AliStack.h"
33 #include "AliESDEvent.h"
34 #include "AliESDVertex.h"
35 #include "AliESDtrack.h"   
36 #include "AliVertexerTracks.h"
37 #include "AliAnalysisTaskSEImpParRes.h"
38
39 ClassImp(AliAnalysisTaskSEImpParRes)
40
41 //________________________________________________________________________
42 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes():
43 AliAnalysisTaskSE(),
44 fReadMC(kFALSE),
45 fSelectedPdg(-1),
46 fOutputitspureSARec(0),
47 fOutputitspureSASkip(0), 
48 fOutputallPointRec(0),
49 fOutputallPointSkip(0),
50 fOutputpartPointRec(0),
51 fOutputpartPointSkip(0),
52 fOutputonepointSPDRec(0),
53 fOutputonepointSPDSkip(0),
54 fOutputpostvTracRec(0),
55 fOutputpostvTracSkip(0),
56 fOutputnegtvTracRec(0),
57 fOutputnegtvTracSkip(0),
58 fOutputpullAllpointRec(0),
59 fOutputpullAllpointSkip(0),
60 fOutputOnlyRefitRec(0),
61 fOutputOnlyRefitSkip(0),
62 fOutputPt(0),
63 fNentries(0),
64 fEstimVtx(0)
65 {
66   //
67   // Default constructor
68   //
69 }
70
71 //________________________________________________________________________
72 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes(const char *name):
73 AliAnalysisTaskSE(name),
74 fReadMC(kFALSE),
75 fSelectedPdg(-1),
76 fOutputitspureSARec(0),
77 fOutputitspureSASkip(0), 
78 fOutputallPointRec(0),
79 fOutputallPointSkip(0),
80 fOutputpartPointRec(0),
81 fOutputpartPointSkip(0),
82 fOutputonepointSPDRec(0),
83 fOutputonepointSPDSkip(0),
84 fOutputpostvTracRec(0),
85 fOutputpostvTracSkip(0),
86 fOutputnegtvTracRec(0),
87 fOutputnegtvTracSkip(0),
88 fOutputpullAllpointRec(0),
89 fOutputpullAllpointSkip(0),
90 fOutputOnlyRefitRec(0),
91 fOutputOnlyRefitSkip(0),
92 fOutputPt(0),
93 fNentries(0),
94 fEstimVtx(0)
95 {
96   //
97   // Default constructor
98   //
99
100   DefineOutput(1, TList::Class());  //My private output
101   DefineOutput(2, TList::Class());  //My private output
102   DefineOutput(3, TList::Class());  //My private output
103   DefineOutput(4, TList::Class());  //My private output
104   DefineOutput(5, TList::Class());
105   DefineOutput(6, TList::Class());  //My private output
106   DefineOutput(7, TList::Class());
107   DefineOutput(8, TList::Class());  //My private output
108   DefineOutput(9, TList::Class());  //My private output
109   DefineOutput(10, TList::Class());  //My private output
110   DefineOutput(11, TList::Class());  //My private output
111   DefineOutput(12, TList::Class());
112   DefineOutput(13, TList::Class());  //My private output
113   DefineOutput(14, TList::Class());
114   DefineOutput(15, TList::Class());  //My private output
115   DefineOutput(16, TList::Class());
116   DefineOutput(17, TList::Class());  //My private output
117   DefineOutput(18, TH1F::Class());
118   DefineOutput(19, TH1F::Class());
119 }
120
121 //________________________________________________________________________
122 AliAnalysisTaskSEImpParRes::~AliAnalysisTaskSEImpParRes()
123 {
124   //
125   // default distructor  
126   // 
127   if (fOutputitspureSARec)            { delete fOutputitspureSARec; fOutputitspureSARec=0x0;}
128   if (fOutputitspureSASkip)         { delete fOutputitspureSASkip; fOutputitspureSASkip=0x0;}
129   if (fOutputallPointRec)              { delete fOutputallPointRec; fOutputallPointRec=0x0; }
130   if (fOutputallPointSkip)           { delete fOutputallPointSkip; fOutputallPointSkip=0x0; }
131   if (fOutputpartPointRec)           { delete fOutputpartPointRec; fOutputpartPointRec=0x0; }
132   if (fOutputpartPointSkip)        { delete fOutputpartPointSkip; fOutputpartPointSkip=0x0; }
133   if (fOutputonepointSPDRec)       { delete fOutputonepointSPDRec;fOutputonepointSPDRec=0x0;}
134   if (fOutputonepointSPDSkip)    { delete fOutputonepointSPDSkip;fOutputonepointSPDSkip=0x0;}
135   if (fOutputpostvTracRec)            { delete fOutputpostvTracRec; fOutputpostvTracRec=0x0;}
136   if (fOutputpostvTracSkip)        {  delete fOutputpostvTracSkip; fOutputpostvTracSkip=0x0;}
137   if (fOutputnegtvTracRec)            { delete fOutputnegtvTracRec; fOutputnegtvTracRec=0x0;}
138   if (fOutputnegtvTracSkip)         { delete fOutputnegtvTracSkip; fOutputnegtvTracSkip=0x0;}
139   if (fOutputpullAllpointRec)    {delete fOutputpullAllpointRec; fOutputpullAllpointRec=0x0;}
140   if (fOutputpullAllpointSkip) {delete fOutputpullAllpointSkip; fOutputpullAllpointSkip=0x0;}
141   if (fOutputOnlyRefitRec)             {delete fOutputOnlyRefitRec; fOutputOnlyRefitRec=0x0;}
142   if (fOutputOnlyRefitSkip)          {delete fOutputOnlyRefitSkip; fOutputOnlyRefitSkip=0x0;}
143   if (fOutputPt)                                          { delete fOutputPt; fOutputPt=0x0;}
144   if (fNentries)                                 { delete fNentries;     fNentries    =0x0; }
145   if (fEstimVtx)                                 { delete fEstimVtx;     fEstimVtx    =0x0; }
146
147
148
149 //________________________________________________________________________
150 void AliAnalysisTaskSEImpParRes::UserCreateOutputObjects()
151 {
152   // 
153   // Create the output container
154   //
155   
156   if(fDebug>1) printf("AnalysisTaskSEImpParRes::UserCreateOutputObjects() \n");
157   
158   // Several histograms are more conveniently managed in a TList
159   if (!fOutputitspureSARec) {
160     fOutputitspureSARec = new TList();
161     fOutputitspureSARec->SetOwner();
162     fOutputitspureSARec->SetName("ITSpureSARec");
163   }
164
165   if (!fOutputitspureSASkip) {
166     fOutputitspureSASkip = new TList();
167     fOutputitspureSASkip->SetOwner();
168     fOutputitspureSASkip->SetName("ITSpureSASkip");
169   }
170
171   if (!fOutputallPointRec) {
172     fOutputallPointRec = new TList();
173     fOutputallPointRec->SetOwner();
174     fOutputallPointRec->SetName("allpointRec");
175   }
176
177   if (!fOutputallPointSkip) {
178     fOutputallPointSkip = new TList();
179     fOutputallPointSkip->SetOwner();
180     fOutputallPointSkip->SetName("allpointSkip");
181   }
182
183   if (!fOutputpartPointRec) {
184     fOutputpartPointRec = new TList();
185     fOutputpartPointRec->SetOwner();
186     fOutputpartPointRec->SetName("partpointRec");
187   }
188
189   if (!fOutputpartPointSkip) {
190     fOutputpartPointSkip = new TList();
191     fOutputpartPointSkip->SetOwner();
192     fOutputpartPointSkip->SetName("partpointSkip");
193   }
194
195   if (!fOutputonepointSPDRec) {
196     fOutputonepointSPDRec = new TList();
197     fOutputonepointSPDRec->SetOwner();
198     fOutputonepointSPDRec->SetName("onepointSPDRec");
199   }
200
201   if (!fOutputonepointSPDSkip) {
202     fOutputonepointSPDSkip = new TList();
203     fOutputonepointSPDSkip->SetOwner();
204     fOutputonepointSPDSkip->SetName("onepointSPDSkip");
205   }
206
207   if (!fOutputpostvTracRec) {
208     fOutputpostvTracRec = new TList();
209     fOutputpostvTracRec->SetOwner();
210     fOutputpostvTracRec->SetName("postvtracRec");
211   }
212
213   if (!fOutputpostvTracSkip) {
214     fOutputpostvTracSkip = new TList();
215     fOutputpostvTracSkip->SetOwner();
216     fOutputpostvTracSkip->SetName("postvtracSkip");
217   }
218  
219   if (!fOutputnegtvTracRec) {
220     fOutputnegtvTracRec = new TList();
221     fOutputnegtvTracRec->SetOwner();
222     fOutputnegtvTracRec->SetName("negtvtracRe");
223   }
224
225   if (!fOutputnegtvTracSkip) {
226     fOutputnegtvTracSkip = new TList();
227     fOutputnegtvTracSkip->SetOwner();
228     fOutputnegtvTracSkip->SetName("negtvtracSkip");
229   }
230
231   if (!fOutputpullAllpointSkip) {
232     fOutputpullAllpointSkip = new TList();
233     fOutputpullAllpointSkip->SetOwner();
234     fOutputpullAllpointSkip->SetName("pullAllpointSkip");
235   }
236
237   if (!fOutputpullAllpointRec) {
238     fOutputpullAllpointRec = new TList();
239     fOutputpullAllpointRec->SetOwner();
240     fOutputpullAllpointRec->SetName("pullAllpointRec");
241   }
242
243   if (!fOutputOnlyRefitRec) {
244     fOutputOnlyRefitRec = new TList();
245     fOutputOnlyRefitRec->SetOwner();
246     fOutputOnlyRefitRec->SetName("onlyRefitRec");
247   }
248
249   if (!fOutputOnlyRefitSkip) {
250     fOutputOnlyRefitSkip = new TList();
251     fOutputOnlyRefitSkip->SetOwner();
252     fOutputOnlyRefitSkip->SetName("onlyRefitRec");
253   }
254
255   if (!fOutputPt) {
256     fOutputPt = new TList();
257     fOutputPt->SetOwner();
258     fOutputPt->SetName("Pt");
259   }
260
261   const Int_t nhist=26;
262   const TString d0ITSpureSArphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
263   const TString d0ITSpureSAzTitle = "d_0 Distribution_z; d_0 [#mum]; Entries";
264   const TString d0allpointrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
265   const TString d0allpointzTitle  = "d_0 Distribution_z; d_0 [#mum]; Entries";
266   const TString d0partpointrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
267   const TString d0partpointzTitle  = "d_0 Distribution_z; d_0 [#mum]; Entries";
268   const TString d0onepointSPDrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
269   const TString d0onepointSPDzTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
270   const TString d0postvtracrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
271   const TString d0postvtraczTitle  = "d_0 Distribution_z; d_0 [#mum]; Entries";
272   const TString d0negtvtracrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
273   const TString d0negtvtraczTitle  = "d_0 Distribution_z; d_0 [#mum]; Entries";
274   const TString d0pullAllpointrphiTitle = "d_0 Pull Distribution_rphi; d_0 pull; Entries";
275   const TString d0pullAllpointzTitle  = "d_0 Pull Distribution_z; d_0 pull; Entries";
276   const TString d0onlyRefitrphiTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
277   const TString d0onlyRefitzTitle  = "d_0 Distribution_z; d_0 [#mum]; Entries";
278   const TString d0ptTitle = "d_0 Distribution_rphi; d_0 [#mum]; Entries";
279   TString  named0itspureSArphiRec,named0itspureSAzRec,named0allpointrphiRec, named0allpointzRec,named0partpointrphiRec, named0partpointzRec,named0onepointSPDrphiRec, named0onepointSPDzRec,named0postvtracrphiRec, named0postvtraczRec,named0negtvtracrphiRec, named0negtvtraczRec,named0pt,named0pullAllpointrphiRec,named0pullAllpointzRec,named0onlyRefitrphiRec,named0onlyRefitzRec;
280   TH1F *d0ITSpureSArphiRec=0,*d0ITSpureSAzRec=0,*d0AllpointrphiRec=0, *d0AllpointzRec=0,*d0PartpointrphiRec=0, *d0PartpointzRec=0,
281     *d0OnepointSPDrphiRec=0,*d0OnepointSPDzRec=0,*d0PostvtracrphiRec=0, *d0PostvtraczRec=0,*d0NegtvtracrphiRec=0, *d0NegtvtraczRec=0,*d0Pt=0,*d0PullAllpointrphiRec,*d0PullAllpointzRec,*d0OnlyRefitrphiRec,*d0OnlyRefitzRec;
282
283   TString  named0itspureSArphiSkip,named0itspureSAzSkip,named0allpointrphiSkip, named0allpointzSkip,named0partpointrphiSkip, named0partpointzSkip,named0onepointSPDrphiSkip, named0onepointSPDzSkip,named0postvtracrphiSkip, named0postvtraczSkip,named0negtvtracrphiSkip, named0negtvtraczSkip,named0ptSkip,named0pullAllpointrphiSkip,named0pullAllpointzSkip,named0onlyRefitrphiSkip,named0onlyRefitzSkip;
284   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,*d0PullAllpointzSkip,*d0OnlyRefitrphiSkip,*d0OnlyRefitzSkip;
285
286
287   for(Int_t i=0; i<nhist; i++) {
288
289     named0itspureSArphiRec = "d0itspureSArphiRec_";
290     named0itspureSArphiRec += (i+1);
291     named0itspureSAzRec = "d0itspureSAzRec_";
292     named0itspureSAzRec += (i+1);
293     d0ITSpureSArphiRec = new TH1F(named0itspureSArphiRec.Data(), d0ITSpureSArphiTitle.Data(), 400, -2000., 2000.);
294     d0ITSpureSArphiRec->Sumw2();
295     d0ITSpureSArphiRec->SetMinimum(0);  
296     fOutputitspureSARec->Add(d0ITSpureSArphiRec);
297     d0ITSpureSAzRec = new TH1F(named0itspureSAzRec.Data(), d0ITSpureSAzTitle.Data(), 400, -2000., 2000.);
298     d0ITSpureSAzRec->Sumw2();
299     d0ITSpureSAzRec->SetMinimum(0);  
300     fOutputitspureSARec->Add(d0ITSpureSAzRec);
301
302     named0itspureSArphiSkip = "d0itspureSArphiSkip_";
303     named0itspureSArphiSkip += (i+1);
304     named0itspureSAzSkip = "d0itspureSAzSkip_";
305     named0itspureSAzSkip += (i+1);
306     d0ITSpureSArphiSkip = new TH1F(named0itspureSArphiSkip.Data(), d0ITSpureSArphiTitle.Data(), 400, -2000., 2000.);
307     d0ITSpureSArphiSkip->Sumw2();
308     d0ITSpureSArphiSkip->SetMinimum(0);  
309     fOutputitspureSASkip->Add(d0ITSpureSArphiSkip);
310     d0ITSpureSAzSkip = new TH1F(named0itspureSAzSkip.Data(), d0ITSpureSAzTitle.Data(), 400, -2000., 2000.);
311     d0ITSpureSAzSkip->Sumw2();
312     d0ITSpureSAzSkip->SetMinimum(0);  
313     fOutputitspureSASkip->Add(d0ITSpureSAzSkip);
314
315     named0allpointrphiRec = "d0allpointrphiRec_";
316     named0allpointrphiRec += (i+1);
317     named0allpointzRec = "d0allpointzRec_";
318     named0allpointzRec += (i+1);
319     d0AllpointrphiRec = new TH1F(named0allpointrphiRec.Data(), d0allpointrphiTitle.Data(), 400, -2000., 2000.);
320     d0AllpointrphiRec->Sumw2();
321     d0AllpointrphiRec->SetMinimum(0);  
322     fOutputallPointRec->Add(d0AllpointrphiRec);
323     d0AllpointzRec= new TH1F(named0allpointzRec.Data(), d0allpointzTitle.Data(), 400, -2000., 2000.);
324     d0AllpointzRec->Sumw2();
325     d0AllpointzRec->SetMinimum(0);  
326     fOutputallPointRec->Add(d0AllpointzRec);
327
328     named0allpointrphiSkip = "d0allpointrphiSkip_";
329     named0allpointrphiSkip += (i+1);
330     named0allpointzSkip = "d0allpointzSkip_";
331     named0allpointzSkip += (i+1);
332     d0AllpointrphiSkip = new TH1F(named0allpointrphiSkip.Data(), d0allpointrphiTitle.Data(), 400, -2000., 2000.);
333     d0AllpointrphiSkip->Sumw2();
334     d0AllpointrphiSkip->SetMinimum(0);  
335     fOutputallPointSkip->Add(d0AllpointrphiSkip);
336     d0AllpointzSkip = new TH1F(named0allpointzSkip.Data(), d0allpointzTitle.Data(), 400, -2000., 2000.);
337     d0AllpointzSkip->Sumw2();
338     d0AllpointzSkip->SetMinimum(0);  
339     fOutputallPointSkip->Add(d0AllpointzSkip);
340
341     named0partpointrphiRec = "d0partpointrphiRec_";
342     named0partpointrphiRec += (i+1);
343     named0partpointzRec = "d0partpointzRec_";
344     named0partpointzRec += (i+1);
345     d0PartpointrphiRec = new TH1F(named0partpointrphiRec.Data(), d0partpointrphiTitle.Data(), 400, -2000., 2000.);
346     d0PartpointrphiRec->Sumw2();
347     d0PartpointrphiRec->SetMinimum(0);  
348     fOutputpartPointRec->Add(d0PartpointrphiRec);
349     d0PartpointzRec = new TH1F(named0partpointzRec.Data(), d0partpointzTitle.Data(), 400, -2000., 2000.);
350     d0PartpointzRec->Sumw2();
351     d0PartpointzRec->SetMinimum(0);  
352     fOutputpartPointRec->Add(d0PartpointzRec);
353
354     named0partpointrphiSkip = "d0partpointrphiSkip_";
355     named0partpointrphiSkip += (i+1);
356     named0partpointzSkip = "d0partpointzSkip_";
357     named0partpointzSkip += (i+1);
358     d0PartpointrphiSkip = new TH1F(named0partpointrphiSkip.Data(), d0partpointrphiTitle.Data(), 400, -2000., 2000.);
359     d0PartpointrphiSkip->Sumw2();
360     d0PartpointrphiSkip->SetMinimum(0);  
361     fOutputpartPointSkip->Add(d0PartpointrphiSkip);
362     d0PartpointzSkip = new TH1F(named0partpointzSkip.Data(), d0partpointzTitle.Data(), 400, -2000., 2000.);
363     d0PartpointzSkip->Sumw2();
364     d0PartpointzSkip->SetMinimum(0);  
365     fOutputpartPointSkip->Add(d0PartpointzSkip);
366
367     named0onepointSPDrphiRec = "d0onepointSPDrphiRec_";
368     named0onepointSPDrphiRec += (i+1);
369     named0onepointSPDzRec = "d0onepointSPDzRec_";
370     named0onepointSPDzRec += (i+1);
371     d0OnepointSPDrphiRec = new TH1F(named0onepointSPDrphiRec.Data(), d0onepointSPDrphiTitle.Data(), 400, -2000., 2000.);
372     d0OnepointSPDrphiRec->Sumw2();
373     d0OnepointSPDrphiRec->SetMinimum(0);  
374     fOutputonepointSPDRec->Add(d0OnepointSPDrphiRec);
375     d0OnepointSPDzRec = new TH1F(named0onepointSPDzRec.Data(), d0onepointSPDzTitle.Data(), 400, -2000., 2000.);
376     d0OnepointSPDzRec->Sumw2();
377     d0OnepointSPDzRec->SetMinimum(0);  
378     fOutputonepointSPDRec->Add(d0OnepointSPDzRec);
379
380     named0onepointSPDrphiSkip = "d0onepointSPDrphiSkip_";
381     named0onepointSPDrphiSkip += (i+1);
382     named0onepointSPDzSkip = "d0onepointSPDzSkip_";
383     named0onepointSPDzSkip += (i+1);
384     d0OnepointSPDrphiSkip = new TH1F(named0onepointSPDrphiSkip.Data(), d0onepointSPDrphiTitle.Data(), 400, -2000., 2000.);
385     d0OnepointSPDrphiSkip->Sumw2();
386     d0OnepointSPDrphiSkip->SetMinimum(0);  
387     fOutputonepointSPDSkip->Add(d0OnepointSPDrphiSkip);
388     d0OnepointSPDzSkip = new TH1F(named0onepointSPDzSkip.Data(), d0onepointSPDzTitle.Data(), 400, -2000., 2000.);
389     d0OnepointSPDzSkip->Sumw2();
390     d0OnepointSPDzSkip->SetMinimum(0);  
391     fOutputonepointSPDSkip->Add(d0OnepointSPDzSkip);
392
393     named0postvtracrphiRec = "d0postvtracrphiRec_";
394     named0postvtracrphiRec += (i+1);
395     named0postvtraczRec = "d0postvtraczRec_";
396     named0postvtraczRec += (i+1);
397     d0PostvtracrphiRec = new TH1F(named0postvtracrphiRec.Data(), d0postvtracrphiTitle.Data(), 400, -2000., 2000.);
398     d0PostvtracrphiRec->Sumw2();
399     d0PostvtracrphiRec->SetMinimum(0);  
400     fOutputpostvTracRec->Add(d0PostvtracrphiRec);
401     d0PostvtraczRec = new TH1F(named0postvtraczRec.Data(), d0postvtraczTitle.Data(), 400, -2000., 2000.);
402     d0PostvtraczRec->Sumw2();
403     d0PostvtraczRec->SetMinimum(0);  
404     fOutputpostvTracRec->Add(d0PostvtraczRec);
405
406     named0postvtracrphiSkip = "d0postvtracrphiSkip_";
407     named0postvtracrphiSkip += (i+1);
408     named0postvtraczSkip = "d0postvtraczSkip_";
409     named0postvtraczSkip += (i+1);
410     d0PostvtracrphiSkip = new TH1F(named0postvtracrphiSkip.Data(), d0postvtracrphiTitle.Data(), 400, -2000., 2000.);
411     d0PostvtracrphiSkip->Sumw2();
412     d0PostvtracrphiSkip->SetMinimum(0);  
413     fOutputpostvTracSkip->Add(d0PostvtracrphiSkip);
414     d0PostvtraczSkip = new TH1F(named0postvtraczSkip.Data(), d0postvtraczTitle.Data(), 400, -2000., 2000.);
415     d0PostvtraczSkip->Sumw2();
416     d0PostvtraczSkip->SetMinimum(0);  
417     fOutputpostvTracSkip->Add(d0PostvtraczSkip);
418
419     named0negtvtracrphiRec = "d0negtvtracrphiRec_";
420     named0negtvtracrphiRec += (i+1);
421     named0negtvtraczRec = "d0negtvtraczRec_";
422     named0negtvtraczRec += (i+1);
423     d0NegtvtracrphiRec = new TH1F(named0negtvtracrphiRec.Data(), d0negtvtracrphiTitle.Data(), 400, -2000., 2000.);
424     d0NegtvtracrphiRec->Sumw2();
425     d0NegtvtracrphiRec->SetMinimum(0);  
426     fOutputnegtvTracRec->Add(d0NegtvtracrphiRec);
427     d0NegtvtraczRec = new TH1F(named0negtvtraczRec.Data(), d0negtvtraczTitle.Data(), 400, -2000., 2000.);
428     d0NegtvtraczRec->Sumw2();
429     d0NegtvtraczRec->SetMinimum(0);  
430     fOutputnegtvTracRec->Add(d0NegtvtraczRec);
431
432     named0negtvtracrphiSkip = "d0negtvtracrphiSkip_";
433     named0negtvtracrphiSkip += (i+1);
434     named0negtvtraczSkip = "d0negtvtraczSkip_";
435     named0negtvtraczSkip += (i+1);
436     d0NegtvtracrphiSkip = new TH1F(named0negtvtracrphiSkip.Data(), d0negtvtracrphiTitle.Data(), 400, -2000., 2000.);
437     d0NegtvtracrphiSkip->Sumw2();
438     d0NegtvtracrphiSkip->SetMinimum(0);  
439     fOutputnegtvTracSkip->Add(d0NegtvtracrphiSkip);
440     d0NegtvtraczSkip = new TH1F(named0negtvtraczSkip.Data(), d0negtvtraczTitle.Data(), 400, -2000., 2000.);
441     d0NegtvtraczSkip->Sumw2();
442     d0NegtvtraczSkip->SetMinimum(0);  
443     fOutputnegtvTracSkip->Add(d0NegtvtraczSkip);
444
445     named0pullAllpointrphiSkip = "d0pullAllpointrphiSkip_";
446     named0pullAllpointrphiSkip +=(i+1);
447     named0pullAllpointzSkip = "d0pullAllpointzSkip_";
448     named0pullAllpointzSkip +=(i+1);
449     d0PullAllpointrphiSkip = new TH1F(named0pullAllpointrphiSkip.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
450     d0PullAllpointrphiSkip->Sumw2();
451     d0PullAllpointrphiSkip->SetMinimum(0);
452     fOutputpullAllpointSkip->Add(d0PullAllpointrphiSkip);
453     d0PullAllpointzSkip = new TH1F(named0pullAllpointzSkip.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
454     d0PullAllpointzSkip->Sumw2();
455     d0PullAllpointzSkip->SetMinimum(0);
456     fOutputpullAllpointSkip->Add(d0PullAllpointzSkip);
457
458     named0pullAllpointrphiRec = "d0pullAllpointrphiRec_";
459     named0pullAllpointrphiRec +=(i+1);
460     named0pullAllpointzRec = "d0pullAllpointzRec_";
461     named0pullAllpointzRec +=(i+1);
462     d0PullAllpointrphiRec = new TH1F(named0pullAllpointrphiRec.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
463     d0PullAllpointrphiRec->Sumw2();
464     d0PullAllpointrphiRec->SetMinimum(0);
465     fOutputpullAllpointRec->Add(d0PullAllpointrphiRec);
466     d0PullAllpointzRec = new TH1F(named0pullAllpointzRec.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
467     d0PullAllpointzRec->Sumw2();
468     d0PullAllpointzRec->SetMinimum(0);
469     fOutputpullAllpointRec->Add(d0PullAllpointzRec);
470
471
472     named0onlyRefitrphiRec = "d0onlyrefitrphiRec_";
473     named0onlyRefitrphiRec +=(i+1);
474     named0onlyRefitzRec = "d0onlyrefitzRec_";
475     named0onlyRefitzRec +=(i+1);
476     d0OnlyRefitrphiRec = new TH1F(named0onlyRefitrphiRec.Data(),d0onlyRefitrphiTitle.Data(),400,-2000.,2000.);
477     d0OnlyRefitrphiRec->Sumw2();
478     d0OnlyRefitrphiRec->SetMinimum(0);
479     fOutputOnlyRefitRec->Add(d0OnlyRefitrphiRec);
480     d0OnlyRefitzRec = new TH1F(named0onlyRefitzRec.Data(),d0onlyRefitzTitle.Data(),400,-2000.,2000.);
481     d0OnlyRefitzRec->Sumw2();
482     d0OnlyRefitzRec->SetMinimum(0);
483     fOutputOnlyRefitRec->Add(d0OnlyRefitzRec);
484
485
486     named0onlyRefitrphiSkip = "d0onlyrefitrphiSkip_";
487     named0onlyRefitrphiSkip +=(i+1);
488     named0onlyRefitzSkip = "d0onlyrefitzSkip_";
489     named0onlyRefitzSkip +=(i+1);
490     d0OnlyRefitrphiSkip = new TH1F(named0onlyRefitrphiSkip.Data(),d0onlyRefitrphiTitle.Data(),400,-2000.,2000.);
491     d0OnlyRefitrphiSkip->Sumw2();
492     d0OnlyRefitrphiSkip->SetMinimum(0);
493     fOutputOnlyRefitSkip->Add(d0OnlyRefitrphiSkip);
494     d0OnlyRefitzSkip = new TH1F(named0onlyRefitzSkip.Data(),d0onlyRefitzTitle.Data(),400,-2000.,2000.);
495     d0OnlyRefitzSkip->Sumw2();
496     d0OnlyRefitzSkip->SetMinimum(0);
497     fOutputOnlyRefitSkip->Add(d0OnlyRefitzSkip);
498
499     named0pt = "d0pt_";
500     named0pt += (i+1);
501     d0Pt = new TH1F(named0pt.Data(), d0ptTitle.Data(), 100, 0, 35.);
502     d0Pt->Sumw2();
503     d0Pt->SetMinimum(0);  
504     fOutputPt->Add(d0Pt);
505
506   }
507
508   if(!fNentries) fNentries = new TH1F("hNentries", "number of entries", 26, 0., 40.);
509   if(!fEstimVtx) fEstimVtx = new TH1F("vtxRes","Resolution of vertex",400,-1000.,1000);
510
511   return;
512 }
513
514 //________________________________________________________________________
515 void AliAnalysisTaskSEImpParRes::UserExec(Option_t */*option*/)
516 {
517   //
518   // Track selection and filling of d0 histograms
519   //
520   AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
521   if (!esd) {
522     AliError("ESD event not found. Nothing done!");
523     return;
524   }
525
526   Float_t diamondcovxy[3];
527   esd->GetDiamondCovXY(diamondcovxy);
528   Double_t pos[3]={esd->GetDiamondX(),esd->GetDiamondY(),0.};
529   diamondcovxy[0]=0.05*0.05;
530   diamondcovxy[2]=0.05*0.05;
531   Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
532   AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
533
534   AliVertexerTracks *vertexer0 = new AliVertexerTracks(esd->GetMagneticField());
535   vertexer0->SetITSMode();
536   vertexer0->SetMinClusters(4);  
537   vertexer0->SetVtxStart(diamond);
538   AliESDVertex *vtxESDRec = (AliESDVertex*)vertexer0->FindPrimaryVertex(esd);
539   delete vertexer0; vertexer0=0;
540   if(vtxESDRec->GetNContributors()<1) return;
541
542
543   AliStack *stack=0; 
544   if (fReadMC) { 
545     AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); 
546     if (!eventHandler) { 
547       Printf("ERROR: Could not retrieve MC event handler"); 
548       return; 
549     } 
550
551     AliMCEvent* mcEvent = eventHandler->MCEvent(); 
552     if (!mcEvent) { 
553       Printf("ERROR: Could not retrieve MC event"); 
554       return; 
555     } 
556
557     stack = mcEvent->Stack(); 
558     if (!stack) { 
559       AliDebug(AliLog::kError, "Stack not available"); 
560       return; 
561     } 
562   } 
563
564   
565   Int_t nTrks = esd->GetNumberOfTracks();
566   for (Int_t it=0; it<nTrks; it++) {  // loop over tracks
567     // read track
568     AliESDtrack *esdtrack = esd->GetTrack(it);
569
570     // ask for ITS refit
571     if (!(esdtrack->GetStatus()&AliESDtrack::kITSrefit)) {
572       continue;
573     }
574     
575     Int_t pdgCode=0; 
576     if(fReadMC && stack) { 
577       Int_t trkLabel = esdtrack->GetLabel(); 
578       //Int_t trkLabel = TMath::Abs(esdtrack->GetLabel()); 
579       if(trkLabel<0) continue;
580       TParticle  *part = (TParticle*)stack->Particle(trkLabel); 
581       pdgCode = TMath::Abs(part->GetPdgCode()); 
582       //printf("pdgCode===%d\n", pdgCode);
583       if(fSelectedPdg>0 && pdgCode!=fSelectedPdg) continue;
584     }
585
586
587     Int_t npointsITS=0,npointsSPD=0;
588     for (Int_t i=0;i<6;i++){ 
589       if (i<2 && esdtrack->HasPointOnITSLayer(i)) npointsSPD +=1;
590       if (esdtrack->HasPointOnITSLayer(i)) npointsITS +=1;  
591     }
592
593     //Get specific primary vertex--Reconstructed primary vertex do not include the track considering.
594     AliVertexerTracks *vertexer = new AliVertexerTracks(esd->GetMagneticField());
595     vertexer->SetITSMode();
596     vertexer->SetMinClusters(4);
597     vertexer->SetVtxStart(diamond);
598     Int_t skipped[2];
599     skipped[0] = (Int_t)esdtrack->GetID();
600     vertexer->SetSkipTracks(1,skipped);      
601     AliESDVertex *vtxESDSkip = (AliESDVertex*)vertexer->FindPrimaryVertex(esd); 
602     delete vertexer; vertexer=NULL;
603     if(vtxESDSkip->GetNContributors()<1) continue;
604      
605
606     Double_t dzRec[2], covdzRec[3], dzRecSkip[2], covdzRecSkip[3];
607     Double_t beampiperadius=3.;
608     Double_t pt= esdtrack->Pt();
609     Int_t bin = PtBin(pt);
610
611     if(bin==-1) {
612       delete vtxESDSkip; vtxESDSkip = 0x0;
613       continue;
614     }
615
616
617     esdtrack->PropagateToDCA(vtxESDRec, esd->GetMagneticField(), beampiperadius, dzRec, covdzRec);
618     esdtrack->PropagateToDCA(vtxESDSkip, esd->GetMagneticField(), beampiperadius, dzRecSkip, covdzRecSkip);
619
620     if(covdzRec[0]<0 || covdzRec[2]<0 || covdzRecSkip[0]<0 || covdzRecSkip[2]<0) {
621       delete vtxESDSkip; vtxESDSkip = 0x0;
622       continue;
623     }
624       
625     //printf("Pt: %f GeV/c; Impact parameter: rphi %f cm  z %f cm\n", pt, dzRec[0], dzRec[1]);
626
627     /*
628     // RUBEN'S METHOD, NOT FULLY IMPLEMENTED YET    
629     Double_t      fIPCenIni[3], xyzDCA[3];
630     for (int i=3;i--;) fIPCenIni[i] = 0.;
631     //Int_t nTracks = nTrks - 1;
632     esdtrack->GetXYZ(xyzDCA);
633     //double pTrack = esdtrack->GetP();
634     double phiTrack = esdtrack->Phi();
635     double cs = TMath::Cos(phiTrack);
636     double sn = TMath::Sin(phiTrack);
637     double trDCA = (xyzDCA[0]-fIPCenIni[0])         *sn - (xyzDCA[1]-fIPCenIni[1])         *cs;  // track signed DCA to origin
638     double vtDCA = (vtxESDSkip->GetXv()-fIPCenIni[0])*sn - (vtxESDSkip->GetYv()-fIPCenIni[1])*cs;  // vertex signed DCA to origin
639     
640     // update the estimator values
641     //double estIP  = rvD*rtD;
642     double estVtx = vtDCA*( vtDCA- trDCA);
643     //double estTrc = rtD*(rtD - rvD);
644     //
645     //if (nTracks >= fMinTracksForIP) fEstimIP->Fill(phiTrack, estIP);
646     fEstimVtx->Fill(10000*estVtx);
647     //if (pTrack<1e-6) pTrack = GetTrackMinP()+1e6;
648     //fEstimTrc->Fill(1./pTrack,estTrc);
649     */
650
651
652     //fill the histgram with all particle 
653     //-------------------------------------------1----------------------------------------------
654     
655     /*
656     TString named0AllrphiRec=" ",named0AllzRec =" ";//named0AllrphiTrue=" ",named0AllzTrue =" ";
657       //named0AllrphiSkip=" ",named0AllzSkip =" ";
658       
659       named0AllrphiRec ="d0allrphiRec_";
660       named0AllrphiRec += bin;
661       named0AllzRec = "d0allzRec_";
662       named0AllzRec += bin;
663       ((TH1F*)(fOutputallRec->FindObject(named0AllrphiRec)))->Fill(10000*dzRec[0]);
664       ((TH1F*)(fOutputallRec->FindObject(named0AllzRec)))->Fill(10000*dzRec[1]);
665     */
666
667     //-------------------------------------------2----------------------------------------------
668     //TSting named0AllrphiRec = "d0allrphiRec_" + bin;
669     //TSting named0AllzRec = "d0allzRec_" + bin;
670     //((TH1F*)(fOutputallRec->FindObject(named0AllrphiRec.Data())))->Fill(10000.*dzRec[0]);
671     //((TH1F*)(fOutputallRec->FindObject(named0AllzRec.Data())))->Fill(10000.*dzRec[1]);
672
673     //-------------------------------------------3------------------------------------------------
674
675
676     // ITS standalone
677     if (!(esdtrack->GetStatus()&AliESDtrack::kTPCrefit) && (esdtrack->GetStatus()&AliESDtrack::kITSpureSA)
678         && npointsSPD>0 && npointsITS>=4) {
679       char *named0ITSpureSArphiRec = Form("d0itspureSArphiRec_%d", bin);
680       char *named0ITSpureSArphiSkip = Form("d0itspureSArphiSkip_%d", bin);
681       char *named0ITSpureSAzRec = Form("d0itspureSAzRec_%d", bin); 
682       char *named0ITSpureSAzSkip = Form("d0itspureSAzSkip_%d", bin); 
683       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSArphiRec)))->Fill(10000.*dzRec[0]);
684       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSAzRec)))->Fill(10000.*dzRec[1]);
685       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSArphiSkip)))->Fill(10000.*dzRecSkip[0]);
686       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSAzSkip)))->Fill(10000.*dzRecSkip[1]);
687     }
688
689     
690     // ask for TPC refit
691     if (!(esdtrack->GetStatus()&AliESDtrack::kTPCrefit) || esdtrack->GetNcls(1)<70) {
692       delete vtxESDSkip; vtxESDSkip = 0x0;
693       continue;
694     }
695
696     // only ITS and TPC refit
697     char *named0OnlyrefitrphiRec = Form("d0onlyrefitrphiRec_%d", bin);
698     char *named0OnlyrefitrphiSkip = Form("d0onlyrefitrphiSkip_%d", bin);
699     char *named0OnlyrefitzRec = Form("d0onlyrefitzRec_%d", bin);
700     char *named0OnlyrefitzSkip = Form("d0onlyrefitzSkip_%d", bin); 
701     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitrphiRec)))->Fill(10000.*dzRec[0]);
702     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitzRec)))->Fill(10000.*dzRec[1]);
703     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitrphiSkip)))->Fill(10000.*dzRecSkip[0]);
704     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitzSkip)))->Fill(10000.*dzRecSkip[1]);  
705     
706     // with 6 ITS points
707     if(npointsITS==6) {
708       char *named0AllpointrphiRec = Form("d0allpointrphiRec_%d", bin);
709       char *named0AllpointrphiSkip = Form("d0allpointrphiSkip_%d", bin);
710       char *named0AllpointzRec = Form("d0allpointzRec_%d", bin);
711       char *named0AllpointzSkip = Form("d0allpointzSkip_%d", bin); 
712       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointrphiRec)))->Fill(10000.*dzRec[0]);
713       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointzRec)))->Fill(10000.*dzRec[1]);
714       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
715       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointzSkip)))->Fill(10000.*dzRecSkip[1]);
716  
717       // pulls
718       char *named0PullAllpointrphiRec = Form("d0pullAllpointrphiRec_%d", bin);
719       char *named0PullAllpointrphiSkip = Form("d0pullAllpointrphiSkip_%d", bin);
720       char *named0PullAllpointzRec = Form("d0pullAllpointzRec_%d", bin);
721       char *named0PullAllpointzSkip = Form("d0pullAllpointzSkip_%d", bin); 
722       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointrphiRec)))->Fill(dzRec[0]/TMath::Sqrt(covdzRec[0]));
723       
724       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointzRec)))->Fill(dzRec[1]/TMath::Sqrt(covdzRec[2]));
725       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointrphiSkip)))->Fill(dzRecSkip[0]/TMath::Sqrt(covdzRecSkip[0]));
726       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointzSkip)))->Fill(dzRecSkip[1]/TMath::Sqrt(covdzRecSkip[2]));
727     }
728    
729     if(npointsITS>=4 && npointsSPD>0) {
730       char *named0PartpointrphiRec = Form("d0partpointrphiRec_%d", bin);
731       char *named0PartpointrphiSkip = Form("d0partpointrphiSkip_%d", bin);
732       char *named0PartpointzRec = Form("d0partpointzRec_%d", bin); 
733       char *named0PartpointzSkip = Form("d0partpointzSkip_%d", bin); 
734       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointrphiRec)))->Fill(10000.*dzRec[0]);
735       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointzRec)))->Fill(10000.*dzRec[1]);
736       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
737       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointzSkip)))->Fill(10000.*dzRecSkip[1]);
738     }
739
740     if(npointsSPD>0) {
741       char *named0OnepointSPDrphiRec = Form("d0onepointSPDrphiRec_%d", bin);
742       char *named0OnepointSPDrphiSkip = Form("d0onepointSPDrphiSkip_%d", bin);
743       char *named0OnepointSPDzRec = Form("d0onepointSPDzRec_%d", bin); 
744       char *named0OnepointSPDzSkip = Form("d0onepointSPDzSkip_%d", bin); 
745       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDrphiRec)))->Fill(10000.*dzRec[0]);
746       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDzRec)))->Fill(10000.*dzRec[1]);
747       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
748       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDzSkip)))->Fill(10000.*dzRecSkip[1]);
749     }
750
751     Short_t charge=esdtrack->Charge();
752     if(charge==1 && npointsITS==6) {
753       char *named0PostvtracrphiRec = Form("d0postvtracrphiRec_%d", bin);
754       char *named0PostvtracrphiSkip = Form("d0postvtracrphiSkip_%d", bin);
755       char *named0PostvtraczRec = Form("d0postvtraczRec_%d", bin); 
756       char *named0PostvtraczSkip = Form("d0postvtraczSkip_%d", bin); 
757       ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtracrphiRec)))->Fill(10000.*dzRec[0]);
758       ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtraczRec)))->Fill(10000.*dzRec[1]);
759       ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
760       ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
761     }
762
763     if(charge==-1 && npointsITS==6) {
764       char *named0NegtvtracrphiRec = Form("d0negtvtracrphiRec_%d", bin);
765       char *named0NegtvtracrphiSkip = Form("d0negtvtracrphiSkip_%d", bin);
766       char *named0NegtvtraczRec = Form("d0negtvtraczRec_%d", bin); 
767       char *named0NegtvtraczSkip = Form("d0negtvtraczSkip_%d", bin); 
768       ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtracrphiRec)))->Fill(10000.*dzRec[0]);
769       ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtraczRec)))->Fill(10000.*dzRec[1]);
770       ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
771       ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
772     }
773     char *named0Pt = Form("d0pt_%d",bin);
774     if(npointsITS==6) ((TH1F*)(fOutputPt->FindObject(named0Pt)))->Fill(pt);
775
776     delete vtxESDSkip; vtxESDSkip = 0x0;
777   }  // end loop of tracks
778   
779   delete diamond; diamond=NULL;
780   delete vtxESDRec; vtxESDRec = 0x0;
781   fNentries->Fill(1);
782   PostData(1, fOutputitspureSARec);
783   PostData(2, fOutputitspureSASkip);
784   PostData(3, fOutputallPointRec);
785   PostData(4, fOutputallPointSkip);
786   PostData(5, fOutputpartPointRec);
787   PostData(6, fOutputpartPointSkip);
788   PostData(7, fOutputonepointSPDRec);
789   PostData(8, fOutputonepointSPDSkip);
790   PostData(9, fOutputpostvTracRec);
791   PostData(10, fOutputpostvTracSkip);
792   PostData(11, fOutputnegtvTracRec);
793   PostData(12, fOutputnegtvTracSkip);
794   PostData(13, fOutputpullAllpointRec);
795   PostData(14, fOutputpullAllpointSkip);
796   PostData(15, fOutputOnlyRefitRec);
797   PostData(16, fOutputOnlyRefitSkip);
798   PostData(17, fOutputPt);
799   PostData(18, fNentries);
800   PostData(19,fEstimVtx);
801   
802   return;
803 }
804
805 //________________________________________________________________________
806 Int_t AliAnalysisTaskSEImpParRes::PtBin(Double_t pt) const {
807   //
808   // return the number of the pt bin
809   //
810
811   if (pt>0.22 && pt<0.23) return 1 ;
812   if (pt>0.26 && pt<0.27) return 2 ; 
813   if (pt>0.35 && pt<0.36) return 3 ;
814   if (pt>0.45 && pt<0.46) return 4 ; 
815   if (pt>0.55 && pt<0.56) return 5 ;
816   if (pt>0.65 && pt<0.66) return 6 ; 
817   if (pt>0.75 && pt<0.76) return 7 ; 
818   if (pt>0.85 && pt<0.865) return 8 ; 
819   if (pt>1.05 && pt<1.07) return 9 ;
820   if (pt>1.25 && pt<1.30) return 10; 
821   if (pt>1.4 && pt<1.55) return 11; 
822   if (pt>1.6 && pt<1.8) return 12; 
823   if (pt>1.8 && pt<2.0) return 13; 
824   if (pt>2.1 && pt<2.3) return 14; 
825   if (pt>2.34 && pt<2.64) return 15; 
826   if (pt>2.65 && pt<3.0) return 16; 
827   if (pt>3.1 && pt<4.) return 17; 
828   if (pt>4.1 && pt<5.2) return 18; 
829   if (pt>5.3 && pt<6.8)  return 19; 
830   if (pt>7.0 && pt<8.8) return 20; 
831   if (pt>9. && pt<30.) return 2;
832   if (pt>30.1 && pt<32.) return 22; 
833   if (pt>32.5  && pt<33.)  return 23;
834   if (pt>33.2  && pt<33.8) return 24; 
835   if (pt>33.9  && pt<34.)  return 25;
836   if (pt>34.05  && pt<35.)  return 26;
837
838   /*
839   if (pt>0.22 && pt<0.23) return 1 ;
840   if (pt>0.26 && pt<0.27) return 2 ; 
841   if (pt>0.35 && pt<0.36) return 3 ;
842   if (pt>0.45 && pt<0.46) return 4 ; 
843   if (pt>0.55 && pt<0.56) return 5 ;
844   if (pt>0.65 && pt<0.66) return 6 ; 
845   if (pt>0.75 && pt<0.76) return 7 ; 
846   if (pt>0.85 && pt<0.86) return 8 ; 
847   if (pt>1.05 && pt<1.06) return 9 ;
848   if (pt>1.25 && pt<1.27) return 10; 
849   if (pt>1.45 && pt<1.47) return 11; 
850   if (pt>1.65 && pt<1.67) return 12; 
851   if (pt>1.85 && pt<1.87) return 13; 
852   if (pt>2.15 && pt<2.17) return 14; 
853   if (pt>2.45 && pt<2.48) return 15; 
854   if (pt>2.65 && pt<2.67) return 16; 
855   if (pt>2.85 && pt<2.87) return 17; 
856   if (pt>3.25 && pt<3.27) return 18; 
857   if (pt>3.75 && pt<3.8)  return 19; 
858   if (pt>4.15 && pt<4.20) return 20; 
859   if (pt>4.95 && pt<5.15) return 21;
860   if (pt>5.35 && pt<5.55) return 22; 
861   if (pt>6.0  && pt<6.8)  return 23;
862   if (pt>8.5  && pt<10.5) return 24; 
863   if (pt>12.  && pt<19.)  return 25;
864   if (pt>21.  && pt<32.)  return 26;
865   */  
866   return -1; 
867 }
868
869 //_________________________________________________________________________
870 void AliAnalysisTaskSEImpParRes::Terminate(Option_t */*option*/) {
871   //
872   // Terminate analysis
873   //
874
875   if (fDebug>1) printf("AnalysisTaskSEImpParRes: Terminate() \n");
876
877   fOutputitspureSARec = dynamic_cast<TList*>(GetOutputData(1));
878   if (!fOutputitspureSARec) printf("ERROR: fOutputitspureSARec not available\n");
879
880   fOutputitspureSASkip = dynamic_cast<TList*>(GetOutputData(2));
881   if (!fOutputitspureSASkip) printf("ERROR: fOutputitspureSASkip not available\n");
882
883   fOutputallPointRec = dynamic_cast<TList*>(GetOutputData(3));
884   if (!fOutputallPointRec) printf("ERROR: fOutputallPointRec not available\n");
885
886   fOutputallPointSkip = dynamic_cast<TList*>(GetOutputData(4));
887   if (!fOutputallPointSkip) printf("ERROR: fOutputallPointSkip not available\n");
888
889   fOutputpartPointRec = dynamic_cast<TList*>(GetOutputData(5));
890   if (!fOutputpartPointRec) printf("ERROR: fOutputpartPointRec not available\n");
891
892   fOutputpartPointSkip = dynamic_cast<TList*>(GetOutputData(6));
893   if (!fOutputpartPointSkip) printf("ERROR: fOutputpartPointSkip not available\n");
894
895   fOutputonepointSPDRec = dynamic_cast<TList*>(GetOutputData(7));
896   if (!fOutputonepointSPDRec) printf("ERROR: fOutputonepointSPDSRec not available\n");
897
898   fOutputonepointSPDSkip = dynamic_cast<TList*>(GetOutputData(8));
899   if (!fOutputonepointSPDSkip) printf("ERROR: fOutputonepointSPDSkip not available\n");
900
901   fOutputpostvTracRec = dynamic_cast<TList*>(GetOutputData(9));
902   if (!fOutputpostvTracRec) printf("ERROR: fOutputpostvTracRec not available\n");
903
904   fOutputpostvTracSkip = dynamic_cast<TList*>(GetOutputData(10));
905   if (!fOutputpostvTracSkip) printf("ERROR: fOutputpostvTracSkip not available\n");
906
907   fOutputnegtvTracRec = dynamic_cast<TList*>(GetOutputData(11));
908   if (!fOutputnegtvTracRec) printf("ERROR: fOutputnegtvTracRec not available\n");
909
910   fOutputnegtvTracSkip = dynamic_cast<TList*>(GetOutputData(12));
911   if (!fOutputnegtvTracSkip) printf("ERROR: fOutputnegtvTracSkip not available\n");
912
913
914   fOutputpullAllpointRec = dynamic_cast<TList*>(GetOutputData(13));
915   if (!fOutputpullAllpointRec) printf("ERROR: fOutputpullAllpointRec not available\n");
916
917   fOutputpullAllpointSkip = dynamic_cast<TList*>(GetOutputData(14));
918   if (!fOutputpullAllpointSkip) printf("ERROR: fOutputpullAllpointSkip not available\n");
919
920   fOutputOnlyRefitRec = dynamic_cast<TList*>(GetOutputData(15));
921   if (!fOutputOnlyRefitRec) printf("ERROR: fOutputOnlyRefitRec not available\n");
922
923   fOutputOnlyRefitSkip = dynamic_cast<TList*>(GetOutputData(16));
924   if (!fOutputOnlyRefitSkip) printf("ERROR: fOutputOnlyRefitSkip not available\n");
925
926   fOutputPt = dynamic_cast<TList*>(GetOutputData(17));
927   if (!fOutputPt) printf("ERROR: fOutputPt not available\n");
928
929   fNentries = dynamic_cast<TH1F*>(GetOutputData(18));
930   if (!fNentries) printf("ERROR: fNentries not available\n");
931   
932   fEstimVtx = dynamic_cast<TH1F*>(GetOutputData(19));
933   if (!fEstimVtx) printf("ERROR: fEstimVtx not available\n");
934   
935   return;
936 }