5262ad51f67993db1d5a61b223fc9741c3073455
[u/mrichter/AliRoot.git] / PWGPP / 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 <AliAnalysisDataSlot.h>
28 #include <AliAnalysisDataContainer.h>
29 #include "AliAnalysisManager.h"
30 #include "TParticle.h"
31 #include "AliGeomManager.h"
32 #include "AliMultiplicity.h"
33 #include "AliTriggerClass.h"
34 #include "AliTriggerCluster.h"
35 #include "AliTriggerConfiguration.h"
36 #include "AliCDBManager.h"
37 #include "AliCDBEntry.h"
38 #include "AliTrackPointArray.h"
39 #include "AliMCEventHandler.h"
40 #include "AliGenEventHeader.h"
41 #include "AliMCEvent.h"
42 #include "AliStack.h"
43 #include "AliAODHandler.h"
44 #include "AliAODMCParticle.h"
45 #include "AliAODMCHeader.h"
46 #include "AliESDEvent.h"
47 #include "AliESDVertex.h"
48 #include "AliESDtrack.h"
49 #include "AliESDtrackCuts.h"
50 #include "AliAODEvent.h"
51 #include "AliAODTrack.h"   
52 #include "AliVertexerTracks.h"
53 #include "AliVVertex.h"
54 #include "AliVEvent.h"
55 #include "AliVTrack.h"
56 #include "AliPID.h"
57 #include "AliAnalysisTaskSEImpParRes.h"
58
59 ClassImp(AliAnalysisTaskSEImpParRes)
60
61 //________________________________________________________________________
62 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes():
63   AliAnalysisTaskSE(),
64   fIsAOD(kFALSE),
65   fReadMC(kFALSE),
66   fSelectedPdg(-1),
67   fUseDiamond(kFALSE),
68   fSkipTrack(kTRUE),
69   fMinMult(0),
70   fMaxMult(1000000),
71   fCheckSDDIsIn(0),
72   fTriggerClass(""),
73   fTrigConfig(0),
74   fOCDBPath(""),
75   fESDtrackCuts(0),
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   fOutputSinThetaRec(0),
93   fOutputSinThetaSkip(0),
94   fOutputallPointTrue(0),
95   fOutputpostvTracTrue(0),
96   fOutputnegtvTracTrue(0),
97   fOutputpullAllpointTrue(0),
98   fOutputphiAllpointSkip(0),
99   fOutputphiPostvtracSkip(0),
100   fOutputphiNegtvtracSkip(0),
101   fOutputparticlePID(0),
102   fOutputWithTrackCuts(0),
103   fOutputPt(0),
104   fNentries(0),
105   fEstimVtx(0)
106 {
107   //
108   // Default constructor
109   //
110 }
111
112 //________________________________________________________________________
113 AliAnalysisTaskSEImpParRes::AliAnalysisTaskSEImpParRes(const char *name):
114   AliAnalysisTaskSE(name),
115   fIsAOD(kFALSE),
116   fReadMC(kFALSE),
117   fSelectedPdg(-1),
118   fUseDiamond(kFALSE),
119   fSkipTrack(kTRUE),
120   fMinMult(0),
121   fMaxMult(1000000),
122   fCheckSDDIsIn(0),
123   fTriggerClass(""),
124   fTrigConfig(0),
125   fOCDBPath(""),
126   fESDtrackCuts(0),
127   fOutputitspureSARec(0),
128   fOutputitspureSASkip(0), 
129   fOutputallPointRec(0),
130   fOutputallPointSkip(0),
131   fOutputpartPointRec(0),
132   fOutputpartPointSkip(0),
133   fOutputonepointSPDRec(0),
134   fOutputonepointSPDSkip(0),
135   fOutputpostvTracRec(0),
136   fOutputpostvTracSkip(0),
137   fOutputnegtvTracRec(0),
138   fOutputnegtvTracSkip(0),
139   fOutputpullAllpointRec(0),
140   fOutputpullAllpointSkip(0),
141   fOutputOnlyRefitRec(0),
142   fOutputOnlyRefitSkip(0),
143   fOutputSinThetaRec(0),
144   fOutputSinThetaSkip(0),
145   fOutputallPointTrue(0),
146   fOutputpostvTracTrue(0),
147   fOutputnegtvTracTrue(0),
148   fOutputpullAllpointTrue(0),
149   fOutputphiAllpointSkip(0),
150   fOutputphiPostvtracSkip(0),
151   fOutputphiNegtvtracSkip(0),
152   fOutputparticlePID(0),
153   fOutputWithTrackCuts(0),
154   fOutputPt(0),
155   fNentries(0),
156   fEstimVtx(0)
157 {
158   //
159   // Default constructor
160   //
161
162   DefineOutput(1, TList::Class());  //My private output
163   DefineOutput(2, TList::Class());  //My private output
164   DefineOutput(3, TList::Class());  //My private output
165   DefineOutput(4, TList::Class());  //My private output
166   DefineOutput(5, TList::Class());
167   DefineOutput(6, TList::Class());  //My private output
168   DefineOutput(7, TList::Class());
169   DefineOutput(8, TList::Class());  //My private output
170   DefineOutput(9, TList::Class());  //My private output
171   DefineOutput(10, TList::Class());  //My private output
172   DefineOutput(11, TList::Class());  //My private output
173   DefineOutput(12, TList::Class());
174   DefineOutput(13, TList::Class());  //My private output
175   DefineOutput(14, TList::Class());
176   DefineOutput(15, TList::Class());  //My private output
177   DefineOutput(16, TList::Class());
178   DefineOutput(17, TList::Class());  //My private output
179   DefineOutput(18, TList::Class());
180   DefineOutput(19, TList::Class());  //My private output
181   DefineOutput(20, TList::Class());  //My private output
182   DefineOutput(21, TList::Class());
183   DefineOutput(22, TList::Class());  //My private output
184   DefineOutput(23, TList::Class());
185   DefineOutput(24, TList::Class());  //My private output
186   DefineOutput(25, TList::Class());
187   DefineOutput(26, TList::Class());  //My private output
188   DefineOutput(27, TList::Class());
189   DefineOutput(28, TH1F::Class());  //My private output
190   DefineOutput(29, TH1F::Class());
191   DefineOutput(30, TList::Class());
192   
193 }
194
195 //________________________________________________________________________
196 AliAnalysisTaskSEImpParRes::~AliAnalysisTaskSEImpParRes()
197 {
198   //
199   // default distructor  
200   // 
201   if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return; // RS
202   //
203   if (fESDtrackCuts) {    delete fESDtrackCuts;  fESDtrackCuts = 0;  }
204   if (fOutputitspureSARec)                      { delete fOutputitspureSARec; fOutputitspureSARec=0x0;}
205   if (fOutputitspureSASkip)                   { delete fOutputitspureSASkip; fOutputitspureSASkip=0x0;}
206   if (fOutputallPointRec)                        { delete fOutputallPointRec; fOutputallPointRec=0x0; }
207   if (fOutputallPointSkip)                     { delete fOutputallPointSkip; fOutputallPointSkip=0x0; }
208   if (fOutputpartPointRec)                     { delete fOutputpartPointRec; fOutputpartPointRec=0x0; }
209   if (fOutputpartPointSkip)                  { delete fOutputpartPointSkip; fOutputpartPointSkip=0x0; }
210   if (fOutputonepointSPDRec)                 { delete fOutputonepointSPDRec;fOutputonepointSPDRec=0x0;}
211   if (fOutputonepointSPDSkip)              { delete fOutputonepointSPDSkip;fOutputonepointSPDSkip=0x0;}
212   if (fOutputpostvTracRec)                      { delete fOutputpostvTracRec; fOutputpostvTracRec=0x0;}
213   if (fOutputpostvTracSkip)                  {  delete fOutputpostvTracSkip; fOutputpostvTracSkip=0x0;}
214   if (fOutputnegtvTracRec)                      { delete fOutputnegtvTracRec; fOutputnegtvTracRec=0x0;}
215   if (fOutputnegtvTracSkip)                   { delete fOutputnegtvTracSkip; fOutputnegtvTracSkip=0x0;}
216   if (fOutputpullAllpointRec)              {delete fOutputpullAllpointRec; fOutputpullAllpointRec=0x0;}
217   if (fOutputpullAllpointSkip)           {delete fOutputpullAllpointSkip; fOutputpullAllpointSkip=0x0;}
218   if (fOutputOnlyRefitRec)                       {delete fOutputOnlyRefitRec; fOutputOnlyRefitRec=0x0;}
219   if (fOutputOnlyRefitSkip)                    {delete fOutputOnlyRefitSkip; fOutputOnlyRefitSkip=0x0;}
220   if (fOutputSinThetaRec)                          {delete fOutputSinThetaRec; fOutputSinThetaRec=0x0;}  
221   if (fOutputSinThetaSkip)                       {delete fOutputSinThetaSkip; fOutputSinThetaSkip=0x0;}
222   if (fOutputallPointTrue)                       {delete fOutputallPointTrue; fOutputallPointTrue=0x0;}
223   if (fOutputpostvTracTrue)                     {delete fOutputpostvTracTrue;fOutputpostvTracTrue=0x0;}
224   if (fOutputnegtvTracTrue)                     {delete fOutputnegtvTracTrue;fOutputnegtvTracTrue=0x0;}
225   if (fOutputpullAllpointTrue)            {delete fOutputpullAllpointTrue;fOutputpullAllpointTrue=0x0;}
226   if (fOutputphiAllpointSkip)               {delete fOutputphiAllpointSkip;fOutputphiAllpointSkip=0x0;}
227   if (fOutputphiPostvtracSkip)            {delete fOutputphiPostvtracSkip;fOutputphiPostvtracSkip=0x0;}
228   if (fOutputphiNegtvtracSkip)            {delete fOutputphiNegtvtracSkip;fOutputphiNegtvtracSkip=0x0;}
229   if (fOutputparticlePID)                           {delete fOutputparticlePID;fOutputparticlePID=0x0;}
230   if (fOutputWithTrackCuts) {  delete fOutputWithTrackCuts; fOutputWithTrackCuts=0;}
231   if (fOutputPt)                                                      {delete fOutputPt;fOutputPt=0x0;}
232   if (fNentries)                                           { delete fNentries;     fNentries    =0x0; }
233   if (fEstimVtx)                                           { delete fEstimVtx;     fEstimVtx    =0x0; }
234
235
236 //______________________________________________________________________________________________________
237 void AliAnalysisTaskSEImpParRes::UserCreateOutputObjects()
238 {
239   // 
240   // Create the output container
241   //
242   
243   if(fDebug>1) printf("AnalysisTaskSEImpParRes::UserCreateOutputObjects() \n");
244   
245   // Several histograms are more conveniently managed in a TList
246   if (!fOutputitspureSARec) {
247     fOutputitspureSARec = new TList();
248     fOutputitspureSARec->SetOwner();
249     fOutputitspureSARec->SetName("ITSpureSARec");
250   }
251
252   if (!fOutputitspureSASkip) {
253     fOutputitspureSASkip = new TList();
254     fOutputitspureSASkip->SetOwner();
255     fOutputitspureSASkip->SetName("ITSpureSASkip");
256   }
257
258   if (!fOutputallPointRec) {
259     fOutputallPointRec = new TList();
260     fOutputallPointRec->SetOwner();
261     fOutputallPointRec->SetName("allpointRec");
262   }
263
264   if (!fOutputallPointSkip) {
265     fOutputallPointSkip = new TList();
266     fOutputallPointSkip->SetOwner();
267     fOutputallPointSkip->SetName("allpointSkip");
268   }
269
270   if (!fOutputpartPointRec) {
271     fOutputpartPointRec = new TList();
272     fOutputpartPointRec->SetOwner();
273     fOutputpartPointRec->SetName("partpointRec");
274   }
275
276   if (!fOutputpartPointSkip) {
277     fOutputpartPointSkip = new TList();
278     fOutputpartPointSkip->SetOwner();
279     fOutputpartPointSkip->SetName("partpointSkip");
280   }
281
282   if (!fOutputonepointSPDRec) {
283     fOutputonepointSPDRec = new TList();
284     fOutputonepointSPDRec->SetOwner();
285     fOutputonepointSPDRec->SetName("onepointSPDRec");
286   }
287
288   if (!fOutputonepointSPDSkip) {
289     fOutputonepointSPDSkip = new TList();
290     fOutputonepointSPDSkip->SetOwner();
291     fOutputonepointSPDSkip->SetName("onepointSPDSkip");
292   }
293
294   if (!fOutputpostvTracRec) {
295     fOutputpostvTracRec = new TList();
296     fOutputpostvTracRec->SetOwner();
297     fOutputpostvTracRec->SetName("postvtracRec");
298   }
299
300   if (!fOutputpostvTracSkip) {
301     fOutputpostvTracSkip = new TList();
302     fOutputpostvTracSkip->SetOwner();
303     fOutputpostvTracSkip->SetName("postvtracSkip");
304   }
305  
306   if (!fOutputnegtvTracRec) {
307     fOutputnegtvTracRec = new TList();
308     fOutputnegtvTracRec->SetOwner();
309     fOutputnegtvTracRec->SetName("negtvtracRe");
310   }
311
312   if (!fOutputnegtvTracSkip) {
313     fOutputnegtvTracSkip = new TList();
314     fOutputnegtvTracSkip->SetOwner();
315     fOutputnegtvTracSkip->SetName("negtvtracSkip");
316   }
317   
318   if (!fOutputpullAllpointSkip) {
319     fOutputpullAllpointSkip = new TList();
320     fOutputpullAllpointSkip->SetOwner();
321     fOutputpullAllpointSkip->SetName("pullAllpointSkip");
322   }
323   
324   if (!fOutputpullAllpointRec) {
325     fOutputpullAllpointRec = new TList();
326     fOutputpullAllpointRec->SetOwner();
327     fOutputpullAllpointRec->SetName("pullAllpointRec");
328   }
329   
330   if (!fOutputOnlyRefitRec) {
331     fOutputOnlyRefitRec = new TList();
332     fOutputOnlyRefitRec->SetOwner();
333     fOutputOnlyRefitRec->SetName("onlyRefitRec");
334   }
335   
336   if (!fOutputOnlyRefitSkip) {
337     fOutputOnlyRefitSkip = new TList();
338     fOutputOnlyRefitSkip->SetOwner();
339     fOutputOnlyRefitSkip->SetName("onlyRefitRec");
340   }
341   
342   if (!fOutputallPointTrue) {
343     fOutputallPointTrue = new TList();
344     fOutputallPointTrue->SetOwner();
345     fOutputallPointTrue->SetName("allpointTrue");
346   }
347   
348   if (!fOutputpostvTracTrue) {
349     fOutputpostvTracTrue = new TList();
350     fOutputpostvTracTrue->SetOwner();
351     fOutputpostvTracTrue->SetName("postvtracTrue");
352   }
353   
354   if (!fOutputnegtvTracTrue) {
355     fOutputnegtvTracTrue = new TList();
356     fOutputnegtvTracTrue->SetOwner();
357     fOutputnegtvTracTrue->SetName("negtvtracTrue");
358   }
359   
360   if (!fOutputpullAllpointTrue) {
361     fOutputpullAllpointTrue = new TList();
362     fOutputpullAllpointTrue->SetOwner();
363     fOutputpullAllpointTrue->SetName("pullAllpointTrue");
364   } 
365   
366   
367   if (!fOutputparticlePID) {
368     fOutputparticlePID = new TList();
369     fOutputparticlePID->SetOwner();
370     fOutputparticlePID->SetName("particlePID");
371   }
372  
373   if (!fOutputPt) {
374     fOutputPt = new TList();
375     fOutputPt->SetOwner();
376     fOutputPt->SetName("Pt");
377   }
378
379   if (!fOutputWithTrackCuts) {
380     fOutputWithTrackCuts = new TList();
381     fOutputWithTrackCuts->SetOwner();
382     fOutputWithTrackCuts->SetName("OutputWithESDTrackCuts");
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 d0rphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
404   const TString d0zTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
405   const TString d0rphiParticlPID = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
406   const TString d0zPrtilePID  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";
407
408   TString  named0itspureSArphiRec,named0itspureSAzRec,named0allpointrphiRec, named0allpointzRec,named0partpointrphiRec, named0partpointzRec,named0onepointSPDrphiRec, named0onepointSPDzRec,named0postvtracrphiRec, named0postvtraczRec,named0negtvtracrphiRec, named0negtvtraczRec,named0pt,named0pullAllpointrphiRec,named0pullAllpointzRec,named0onlyRefitrphiRec,named0onlyRefitzRec,named0pionPIDrphiRec, named0pionPIDzRec,named0kaonPIDrphiRec, named0kaonPIDzRec,named0protonPIDrphiRec, named0protonPIDzRec;
409  
410   TH1F *d0ITSpureSArphiRec=0,*d0ITSpureSAzRec=0,*d0AllpointrphiRec=0, *d0AllpointzRec=0,*d0PartpointrphiRec=0, *d0PartpointzRec=0,
411     *d0OnepointSPDrphiRec=0,*d0OnepointSPDzRec=0,*d0PostvtracrphiRec=0, *d0PostvtraczRec=0,*d0NegtvtracrphiRec=0, *d0NegtvtraczRec=0,*d0Pt=0,*d0PullAllpointrphiRec=0,*d0PullAllpointzRec=0,*d0OnlyRefitrphiRec=0,*d0OnlyRefitzRec=0,*d0PionPIDrphiRec=0,*d0PionPIDzRec=0,*d0KaonPIDrphiRec=0,*d0KaonPIDzRec=0,*d0ProtonPIDrphiRec=0,*d0ProtonPIDzRec=0;
412
413   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,named0pionPIDrphiSkip, named0pionPIDzSkip,named0kaonPIDrphiSkip, named0kaonPIDzSkip,named0protonPIDrphiSkip, named0protonPIDzSkip;
414
415   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,*d0PionPIDrphiSkip=0,*d0PionPIDzSkip=0,*d0KaonPIDrphiSkip=0,*d0KaonPIDzSkip=0,*d0ProtonPIDrphiSkip=0,*d0ProtonPIDzSkip=0;
416
417   TString named0DistrESDTCrphiRec, named0DistrESDTCrphiSkip, named0DistrESDTCrphiTrue, named0DistrESDTCzRec, named0DistrESDTCzSkip, named0DistrESDTCzTrue, named0PullESDTCrphiRec, named0PullESDTCrphiSkip, named0PullESDTCrphiTrue, named0PullESDTCzRec, named0PullESDTCzSkip, named0PullESDTCzTrue, named0ptESDTC;
418
419   TH1F *d0DistrESDTCrphiRec=0, *d0DistrESDTCrphiSkip=0, *d0DistrESDTCrphiTrue=0, *d0DistrESDTCzRec=0, *d0DistrESDTCzSkip=0, *d0DistrESDTCzTrue=0, *d0PullESDTCrphiRec=0, *d0PullESDTCrphiSkip=0, *d0PullESDTCrphiTrue=0, *d0PullESDTCzRec=0, *d0PullESDTCzSkip=0, *d0PullESDTCzTrue=0, *d0PtESDTC;
420
421   for(Int_t i=1; i<=nhist; i++) {
422    
423     named0itspureSArphiRec = "d0itspureSArphiRec_";
424     named0itspureSArphiRec += i;
425     named0itspureSAzRec = "d0itspureSAzRec_";
426     named0itspureSAzRec += i;
427     d0ITSpureSArphiRec = new TH1F(named0itspureSArphiRec.Data(), d0ITSpureSArphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
428     d0ITSpureSArphiRec->Sumw2();
429     d0ITSpureSArphiRec->SetMinimum(0);  
430     fOutputitspureSARec->Add(d0ITSpureSArphiRec);
431     d0ITSpureSAzRec = new TH1F(named0itspureSAzRec.Data(), d0ITSpureSAzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
432     d0ITSpureSAzRec->Sumw2();
433     d0ITSpureSAzRec->SetMinimum(0);  
434     fOutputitspureSARec->Add(d0ITSpureSAzRec);
435
436     named0itspureSArphiSkip = "d0itspureSArphiSkip_";
437     named0itspureSArphiSkip += i;
438     named0itspureSAzSkip = "d0itspureSAzSkip_";
439     named0itspureSAzSkip += i;
440     d0ITSpureSArphiSkip = new TH1F(named0itspureSArphiSkip.Data(), d0ITSpureSArphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));    d0ITSpureSArphiSkip->Sumw2();
441     d0ITSpureSArphiSkip->SetMinimum(0);  
442     fOutputitspureSASkip->Add(d0ITSpureSArphiSkip);
443     d0ITSpureSAzSkip = new TH1F(named0itspureSAzSkip.Data(), d0ITSpureSAzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
444     d0ITSpureSAzSkip->Sumw2();
445     d0ITSpureSAzSkip->SetMinimum(0);  
446     fOutputitspureSASkip->Add(d0ITSpureSAzSkip);
447
448     named0allpointrphiRec = "d0allpointrphiRec_";
449     named0allpointrphiRec += i;
450     named0allpointzRec = "d0allpointzRec_";
451     named0allpointzRec += i;
452     d0AllpointrphiRec = new TH1F(named0allpointrphiRec.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
453     d0AllpointrphiRec->Sumw2();
454     d0AllpointrphiRec->SetMinimum(0);  
455     fOutputallPointRec->Add(d0AllpointrphiRec);
456     d0AllpointzRec= new TH1F(named0allpointzRec.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
457     d0AllpointzRec->Sumw2();
458     d0AllpointzRec->SetMinimum(0);  
459     fOutputallPointRec->Add(d0AllpointzRec);
460
461     named0allpointrphiSkip = "d0allpointrphiSkip_";
462     named0allpointrphiSkip += i;
463     named0allpointzSkip = "d0allpointzSkip_";
464     named0allpointzSkip += i;
465     d0AllpointrphiSkip = new TH1F(named0allpointrphiSkip.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
466     d0AllpointrphiSkip->Sumw2();
467     d0AllpointrphiSkip->SetMinimum(0);  
468     fOutputallPointSkip->Add(d0AllpointrphiSkip);
469     d0AllpointzSkip = new TH1F(named0allpointzSkip.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
470     d0AllpointzSkip->Sumw2();
471     d0AllpointzSkip->SetMinimum(0);  
472     fOutputallPointSkip->Add(d0AllpointzSkip);
473
474     named0partpointrphiRec = "d0partpointrphiRec_";
475     named0partpointrphiRec += i;
476     named0partpointzRec = "d0partpointzRec_";
477     named0partpointzRec += i;
478     d0PartpointrphiRec = new TH1F(named0partpointrphiRec.Data(), d0partpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
479     d0PartpointrphiRec->Sumw2();
480     d0PartpointrphiRec->SetMinimum(0);  
481     fOutputpartPointRec->Add(d0PartpointrphiRec);
482     d0PartpointzRec = new TH1F(named0partpointzRec.Data(), d0partpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
483     d0PartpointzRec->Sumw2();
484     d0PartpointzRec->SetMinimum(0);  
485     fOutputpartPointRec->Add(d0PartpointzRec);
486
487     named0partpointrphiSkip = "d0partpointrphiSkip_";
488     named0partpointrphiSkip += i;
489     named0partpointzSkip = "d0partpointzSkip_";
490     named0partpointzSkip += i;
491     d0PartpointrphiSkip = new TH1F(named0partpointrphiSkip.Data(), d0partpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
492     d0PartpointrphiSkip->Sumw2();
493     d0PartpointrphiSkip->SetMinimum(0);  
494     fOutputpartPointSkip->Add(d0PartpointrphiSkip);
495     d0PartpointzSkip = new TH1F(named0partpointzSkip.Data(), d0partpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
496     d0PartpointzSkip->Sumw2();
497     d0PartpointzSkip->SetMinimum(0);  
498     fOutputpartPointSkip->Add(d0PartpointzSkip);
499
500     named0onepointSPDrphiRec = "d0onepointSPDrphiRec_";
501     named0onepointSPDrphiRec += i;
502     named0onepointSPDzRec = "d0onepointSPDzRec_";
503     named0onepointSPDzRec += i;
504     d0OnepointSPDrphiRec = new TH1F(named0onepointSPDrphiRec.Data(), d0onepointSPDrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
505     d0OnepointSPDrphiRec->Sumw2();
506     d0OnepointSPDrphiRec->SetMinimum(0);  
507     fOutputonepointSPDRec->Add(d0OnepointSPDrphiRec);
508     d0OnepointSPDzRec = new TH1F(named0onepointSPDzRec.Data(), d0onepointSPDzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
509     d0OnepointSPDzRec->Sumw2();
510     d0OnepointSPDzRec->SetMinimum(0);  
511     fOutputonepointSPDRec->Add(d0OnepointSPDzRec);
512
513     named0onepointSPDrphiSkip = "d0onepointSPDrphiSkip_";
514     named0onepointSPDrphiSkip += i;
515     named0onepointSPDzSkip = "d0onepointSPDzSkip_";
516     named0onepointSPDzSkip += i;
517     d0OnepointSPDrphiSkip = new TH1F(named0onepointSPDrphiSkip.Data(), d0onepointSPDrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
518     d0OnepointSPDrphiSkip->Sumw2();
519     d0OnepointSPDrphiSkip->SetMinimum(0);  
520     fOutputonepointSPDSkip->Add(d0OnepointSPDrphiSkip);
521     d0OnepointSPDzSkip = new TH1F(named0onepointSPDzSkip.Data(), d0onepointSPDzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
522     d0OnepointSPDzSkip->Sumw2();
523     d0OnepointSPDzSkip->SetMinimum(0);  
524     fOutputonepointSPDSkip->Add(d0OnepointSPDzSkip);
525
526     named0postvtracrphiRec = "d0postvtracrphiRec_";
527     named0postvtracrphiRec += i;
528     named0postvtraczRec = "d0postvtraczRec_";
529     named0postvtraczRec += i;
530     d0PostvtracrphiRec = new TH1F(named0postvtracrphiRec.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
531     d0PostvtracrphiRec->Sumw2();
532     d0PostvtracrphiRec->SetMinimum(0);  
533     fOutputpostvTracRec->Add(d0PostvtracrphiRec);
534     d0PostvtraczRec = new TH1F(named0postvtraczRec.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
535     d0PostvtraczRec->Sumw2();
536     d0PostvtraczRec->SetMinimum(0);  
537     fOutputpostvTracRec->Add(d0PostvtraczRec);
538
539     named0postvtracrphiSkip = "d0postvtracrphiSkip_";
540     named0postvtracrphiSkip += i;
541     named0postvtraczSkip = "d0postvtraczSkip_";
542     named0postvtraczSkip += i;
543     d0PostvtracrphiSkip = new TH1F(named0postvtracrphiSkip.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
544     d0PostvtracrphiSkip->Sumw2();
545     d0PostvtracrphiSkip->SetMinimum(0);  
546     fOutputpostvTracSkip->Add(d0PostvtracrphiSkip);
547     d0PostvtraczSkip = new TH1F(named0postvtraczSkip.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
548     d0PostvtraczSkip->Sumw2();
549     d0PostvtraczSkip->SetMinimum(0);  
550     fOutputpostvTracSkip->Add(d0PostvtraczSkip);
551
552     named0negtvtracrphiRec = "d0negtvtracrphiRec_";
553     named0negtvtracrphiRec += i;
554     named0negtvtraczRec = "d0negtvtraczRec_";
555     named0negtvtraczRec += i;
556     d0NegtvtracrphiRec = new TH1F(named0negtvtracrphiRec.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
557     d0NegtvtracrphiRec->Sumw2();
558     d0NegtvtracrphiRec->SetMinimum(0);  
559     fOutputnegtvTracRec->Add(d0NegtvtracrphiRec);
560     d0NegtvtraczRec = new TH1F(named0negtvtraczRec.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
561     d0NegtvtraczRec->Sumw2();
562     d0NegtvtraczRec->SetMinimum(0);  
563     fOutputnegtvTracRec->Add(d0NegtvtraczRec);
564
565     named0negtvtracrphiSkip = "d0negtvtracrphiSkip_";
566     named0negtvtracrphiSkip += i;
567     named0negtvtraczSkip = "d0negtvtraczSkip_";
568     named0negtvtraczSkip += i;
569     d0NegtvtracrphiSkip = new TH1F(named0negtvtracrphiSkip.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
570     d0NegtvtracrphiSkip->Sumw2();
571     d0NegtvtracrphiSkip->SetMinimum(0);  
572     fOutputnegtvTracSkip->Add(d0NegtvtracrphiSkip);
573     d0NegtvtraczSkip = new TH1F(named0negtvtraczSkip.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
574     d0NegtvtraczSkip->Sumw2();
575     d0NegtvtraczSkip->SetMinimum(0);  
576     fOutputnegtvTracSkip->Add(d0NegtvtraczSkip);
577
578     named0pullAllpointrphiSkip = "d0pullAllpointrphiSkip_";
579     named0pullAllpointrphiSkip +=i;
580     named0pullAllpointzSkip = "d0pullAllpointzSkip_";
581     named0pullAllpointzSkip +=i;
582     d0PullAllpointrphiSkip = new TH1F(named0pullAllpointrphiSkip.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
583     d0PullAllpointrphiSkip->Sumw2();
584     d0PullAllpointrphiSkip->SetMinimum(0);
585     fOutputpullAllpointSkip->Add(d0PullAllpointrphiSkip);
586     d0PullAllpointzSkip = new TH1F(named0pullAllpointzSkip.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
587     d0PullAllpointzSkip->Sumw2();
588     d0PullAllpointzSkip->SetMinimum(0);
589     fOutputpullAllpointSkip->Add(d0PullAllpointzSkip);
590
591     named0pullAllpointrphiRec = "d0pullAllpointrphiRec_";
592     named0pullAllpointrphiRec +=i;
593     named0pullAllpointzRec = "d0pullAllpointzRec_";
594     named0pullAllpointzRec +=i;
595     d0PullAllpointrphiRec = new TH1F(named0pullAllpointrphiRec.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
596     d0PullAllpointrphiRec->Sumw2();
597     d0PullAllpointrphiRec->SetMinimum(0);
598     fOutputpullAllpointRec->Add(d0PullAllpointrphiRec);
599     d0PullAllpointzRec = new TH1F(named0pullAllpointzRec.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
600     d0PullAllpointzRec->Sumw2();
601     d0PullAllpointzRec->SetMinimum(0);
602     fOutputpullAllpointRec->Add(d0PullAllpointzRec);
603
604     named0onlyRefitrphiRec = "d0onlyrefitrphiRec_";
605     named0onlyRefitrphiRec +=i;
606     named0onlyRefitzRec = "d0onlyrefitzRec_";
607     named0onlyRefitzRec +=i;
608     d0OnlyRefitrphiRec = new TH1F(named0onlyRefitrphiRec.Data(),d0onlyRefitrphiTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
609     d0OnlyRefitrphiRec->Sumw2();
610     d0OnlyRefitrphiRec->SetMinimum(0);
611     fOutputOnlyRefitRec->Add(d0OnlyRefitrphiRec);
612     d0OnlyRefitzRec = new TH1F(named0onlyRefitzRec.Data(),d0onlyRefitzTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
613     d0OnlyRefitzRec->Sumw2();
614     d0OnlyRefitzRec->SetMinimum(0);
615     fOutputOnlyRefitRec->Add(d0OnlyRefitzRec);
616
617     named0onlyRefitrphiSkip = "d0onlyrefitrphiSkip_";
618     named0onlyRefitrphiSkip +=i;
619     named0onlyRefitzSkip = "d0onlyrefitzSkip_";
620     named0onlyRefitzSkip +=i;
621     d0OnlyRefitrphiSkip = new TH1F(named0onlyRefitrphiSkip.Data(),d0onlyRefitrphiTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
622     d0OnlyRefitrphiSkip->Sumw2();
623     d0OnlyRefitrphiSkip->SetMinimum(0);
624     fOutputOnlyRefitSkip->Add(d0OnlyRefitrphiSkip);
625     d0OnlyRefitzSkip = new TH1F(named0onlyRefitzSkip.Data(),d0onlyRefitzTitle.Data(),400,-Getd0HistRange(i),Getd0HistRange(i));
626     d0OnlyRefitzSkip->Sumw2();
627     d0OnlyRefitzSkip->SetMinimum(0);
628     fOutputOnlyRefitSkip->Add(d0OnlyRefitzSkip);
629
630     named0allpointrphiTrue = "d0allpointrphiTrue_";
631     named0allpointrphiTrue += i;
632     named0allpointzTrue = "d0allpointzTrue_";
633     named0allpointzTrue += i;
634     d0AllpointrphiTrue = new TH1F(named0allpointrphiTrue.Data(), d0allpointrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
635     d0AllpointrphiTrue->Sumw2();
636     d0AllpointrphiTrue->SetMinimum(0);  
637     fOutputallPointTrue->Add(d0AllpointrphiTrue);
638     d0AllpointzTrue = new TH1F(named0allpointzTrue.Data(), d0allpointzTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
639     d0AllpointzTrue->Sumw2();
640     d0AllpointzTrue->SetMinimum(0);  
641     fOutputallPointTrue->Add(d0AllpointzTrue);
642
643     named0postvtracrphiTrue = "d0postvtracrphiTrue_";
644     named0postvtracrphiTrue += i;
645     named0postvtraczTrue = "d0postvtraczTrue_";
646     named0postvtraczTrue += i;
647     d0PostvtracrphiTrue = new TH1F(named0postvtracrphiTrue.Data(), d0postvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
648     d0PostvtracrphiTrue->Sumw2();
649     d0PostvtracrphiTrue->SetMinimum(0);  
650     fOutputpostvTracTrue->Add(d0PostvtracrphiTrue);
651     d0PostvtraczTrue = new TH1F(named0postvtraczTrue.Data(), d0postvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
652     d0PostvtraczTrue->Sumw2();
653     d0PostvtraczTrue->SetMinimum(0);  
654     fOutputpostvTracTrue->Add(d0PostvtraczTrue);
655
656     named0negtvtracrphiTrue = "d0negtvtracrphiTrue_";
657     named0negtvtracrphiTrue += i;
658     named0negtvtraczTrue = "d0negtvtraczTrue_";
659     named0negtvtraczTrue += i;
660     d0NegtvtracrphiTrue = new TH1F(named0negtvtracrphiTrue.Data(), d0negtvtracrphiTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
661     d0NegtvtracrphiTrue->Sumw2();
662     d0NegtvtracrphiTrue->SetMinimum(0);  
663     fOutputnegtvTracTrue->Add(d0NegtvtracrphiTrue);
664     d0NegtvtraczTrue = new TH1F(named0negtvtraczTrue.Data(), d0negtvtraczTitle.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
665     d0NegtvtraczTrue->Sumw2();
666     d0NegtvtraczTrue->SetMinimum(0);  
667     fOutputnegtvTracTrue->Add(d0NegtvtraczTrue);
668
669     named0pullAllpointrphiTrue = "d0pullAllpointrphiTrue_";
670     named0pullAllpointrphiTrue +=i;
671     named0pullAllpointzTrue = "d0pullAllpointzTrue_";
672     named0pullAllpointzTrue +=i;
673     d0PullAllpointrphiTrue = new TH1F(named0pullAllpointrphiTrue.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
674     d0PullAllpointrphiTrue->Sumw2();
675     d0PullAllpointrphiTrue->SetMinimum(0);
676     fOutputpullAllpointTrue->Add(d0PullAllpointrphiTrue);
677     d0PullAllpointzTrue = new TH1F(named0pullAllpointzTrue.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
678     d0PullAllpointzTrue->Sumw2();
679     d0PullAllpointzTrue->SetMinimum(0);
680     fOutputpullAllpointTrue->Add(d0PullAllpointzTrue);
681
682
683     named0pionPIDrphiRec = "d0pionPIDrphiRec_";
684     named0pionPIDrphiRec += i;
685     named0pionPIDzRec = "d0pionPIDzRec_";
686     named0pionPIDzRec += i;
687     d0PionPIDrphiRec = new TH1F(named0pionPIDrphiRec.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
688     d0PionPIDrphiRec->Sumw2();
689     d0PionPIDrphiRec->SetMinimum(0);  
690     fOutputparticlePID->Add(d0PionPIDrphiRec);
691     d0PionPIDzRec = new TH1F(named0pionPIDzRec.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
692     d0PionPIDzRec->Sumw2();
693     d0PionPIDzRec->SetMinimum(0);  
694     fOutputparticlePID->Add(d0PionPIDzRec);
695
696     named0pionPIDrphiSkip = "d0pionPIDrphiSkip_";
697     named0pionPIDrphiSkip += i;
698     named0pionPIDzSkip = "d0pionPIDzSkip_";
699     named0pionPIDzSkip += i;
700     d0PionPIDrphiSkip = new TH1F(named0pionPIDrphiSkip.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
701     d0PionPIDrphiSkip->Sumw2();
702     d0PionPIDrphiSkip->SetMinimum(0);  
703     fOutputparticlePID->Add(d0PionPIDrphiSkip);
704     d0PionPIDzSkip = new TH1F(named0pionPIDzSkip.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
705     d0PionPIDzSkip->Sumw2();
706     d0PionPIDzSkip->SetMinimum(0);  
707     fOutputparticlePID->Add(d0PionPIDzSkip);
708
709     named0kaonPIDrphiRec = "d0kaonPIDrphiRec_";
710     named0kaonPIDrphiRec += i;
711     named0kaonPIDzRec = "d0kaonPIDzRec_";
712     named0kaonPIDzRec += i;
713     d0KaonPIDrphiRec = new TH1F(named0kaonPIDrphiRec.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
714     d0KaonPIDrphiRec->Sumw2();
715     d0KaonPIDrphiRec->SetMinimum(0);  
716     fOutputparticlePID->Add(d0KaonPIDrphiRec);
717     d0KaonPIDzRec = new TH1F(named0kaonPIDzRec.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
718     d0KaonPIDzRec->Sumw2();
719     d0KaonPIDzRec->SetMinimum(0);  
720     fOutputparticlePID->Add(d0KaonPIDzRec);
721
722     named0kaonPIDrphiSkip = "d0kaonPIDrphiSkip_";
723     named0kaonPIDrphiSkip += i;
724     named0kaonPIDzSkip = "d0kaonPIDzSkip_";
725     named0kaonPIDzSkip += i;
726     d0KaonPIDrphiSkip = new TH1F(named0kaonPIDrphiSkip.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
727     d0KaonPIDrphiSkip->Sumw2();
728     d0KaonPIDrphiSkip->SetMinimum(0);  
729     fOutputparticlePID->Add(d0KaonPIDrphiSkip);
730     d0KaonPIDzSkip = new TH1F(named0kaonPIDzSkip.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
731     d0KaonPIDzSkip->Sumw2();
732     d0KaonPIDzSkip->SetMinimum(0);  
733     fOutputparticlePID->Add(d0KaonPIDzSkip);
734
735     named0protonPIDrphiRec = "d0protonPIDrphiRec_";
736     named0protonPIDrphiRec += i;
737     named0protonPIDzRec = "d0protonPIDzRec_";
738     named0protonPIDzRec += i;
739     d0ProtonPIDrphiRec = new TH1F(named0protonPIDrphiRec.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
740     d0ProtonPIDrphiRec->Sumw2();
741     d0ProtonPIDrphiRec->SetMinimum(0);  
742     fOutputparticlePID->Add(d0ProtonPIDrphiRec);
743     d0ProtonPIDzRec = new TH1F(named0protonPIDzRec.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
744     d0ProtonPIDzRec->Sumw2();
745     d0ProtonPIDzRec->SetMinimum(0);  
746     fOutputparticlePID->Add(d0ProtonPIDzRec);
747
748     named0protonPIDrphiSkip = "d0protonPIDrphiSkip_";
749     named0protonPIDrphiSkip += i;
750     named0protonPIDzSkip = "d0protonPIDzSkip_";
751     named0protonPIDzSkip += i;
752     d0ProtonPIDrphiSkip = new TH1F(named0protonPIDrphiSkip.Data(), d0rphiParticlPID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
753     d0ProtonPIDrphiSkip->Sumw2();
754     d0ProtonPIDrphiSkip->SetMinimum(0);  
755     fOutputparticlePID->Add(d0ProtonPIDrphiSkip);
756     d0ProtonPIDzSkip = new TH1F(named0protonPIDzSkip.Data(), d0zPrtilePID.Data(), 400, -Getd0HistRange(i), Getd0HistRange(i));
757     d0ProtonPIDzSkip->Sumw2();
758     d0ProtonPIDzSkip->SetMinimum(0);  
759     fOutputparticlePID->Add(d0ProtonPIDzSkip);
760
761     named0pt = "d0pt_";
762     named0pt += i;
763     d0Pt = new TH1F(named0pt.Data(), d0ptTitle.Data(), 100, 0, 35.);
764     d0Pt->Sumw2();
765     d0Pt->SetMinimum(0);  
766     fOutputPt->Add(d0Pt);
767
768     //foutputwithtrackcuts
769     named0DistrESDTCrphiRec = "d0DistrESDTCrphiRec_";
770     named0DistrESDTCrphiRec +=i;
771     named0DistrESDTCzRec = "d0DistrESDTCzRec_";
772     named0DistrESDTCzRec +=i;
773     d0DistrESDTCrphiRec = new TH1F(named0DistrESDTCrphiRec.Data(),d0allpointrphiTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
774     d0DistrESDTCrphiRec->Sumw2();
775     d0DistrESDTCrphiRec->SetMinimum(0);
776     fOutputWithTrackCuts->Add(d0DistrESDTCrphiRec);
777     d0DistrESDTCzRec = new TH1F(named0DistrESDTCzRec.Data(),d0allpointzTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
778     d0DistrESDTCzRec->Sumw2();
779     d0DistrESDTCzRec->SetMinimum(0);
780     fOutputWithTrackCuts->Add(d0DistrESDTCzRec);
781
782     named0DistrESDTCrphiSkip = "d0DistrESDTCrphiSkip_";
783     named0DistrESDTCrphiSkip +=i;
784     named0DistrESDTCzSkip = "d0DistrESDTCzSkip_";
785     named0DistrESDTCzSkip +=i;
786     d0DistrESDTCrphiSkip = new TH1F(named0DistrESDTCrphiSkip.Data(),d0allpointrphiTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
787     d0DistrESDTCrphiSkip->Sumw2();
788     d0DistrESDTCrphiSkip->SetMinimum(0);
789     fOutputWithTrackCuts->Add(d0DistrESDTCrphiSkip);
790     d0DistrESDTCzSkip = new TH1F(named0DistrESDTCzSkip.Data(),d0allpointzTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
791     d0DistrESDTCzSkip->Sumw2();
792     d0DistrESDTCzSkip->SetMinimum(0);
793     fOutputWithTrackCuts->Add(d0DistrESDTCzSkip);
794
795     named0DistrESDTCrphiTrue = "d0DistrESDTCrphiTrue_";
796     named0DistrESDTCrphiTrue +=i;
797     named0DistrESDTCzTrue = "d0DistrESDTCzTrue_";
798     named0DistrESDTCzTrue +=i;
799     d0DistrESDTCrphiTrue = new TH1F(named0DistrESDTCrphiTrue.Data(),d0allpointrphiTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
800     d0DistrESDTCrphiTrue->Sumw2();
801     d0DistrESDTCrphiTrue->SetMinimum(0);
802     fOutputWithTrackCuts->Add(d0DistrESDTCrphiTrue);
803     d0DistrESDTCzTrue = new TH1F(named0DistrESDTCzTrue.Data(),d0allpointzTitle.Data(),400, -Getd0HistRange(i), Getd0HistRange(i));
804     d0DistrESDTCzTrue->Sumw2();
805     d0DistrESDTCzTrue->SetMinimum(0);
806     fOutputWithTrackCuts->Add(d0DistrESDTCzTrue);
807
808     named0PullESDTCrphiRec = "d0PullESDTCrphiRec_";
809     named0PullESDTCrphiRec +=i;
810     named0PullESDTCzRec = "d0PullESDTCzRec_";
811     named0PullESDTCzRec +=i;
812     d0PullESDTCrphiRec = new TH1F(named0PullESDTCrphiRec.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
813     d0PullESDTCrphiRec->Sumw2();
814     d0PullESDTCrphiRec->SetMinimum(0);
815     fOutputWithTrackCuts->Add(d0PullESDTCrphiRec);
816     d0PullESDTCzRec = new TH1F(named0PullESDTCzRec.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
817     d0PullESDTCzRec->Sumw2();
818     d0PullESDTCzRec->SetMinimum(0);
819     fOutputWithTrackCuts->Add(d0PullESDTCzRec);
820
821     named0PullESDTCrphiSkip = "d0PullESDTCrphiSkip_";
822     named0PullESDTCrphiSkip +=i;
823     named0PullESDTCzSkip = "d0PullESDTCzSkip_";
824     named0PullESDTCzSkip +=i;
825     d0PullESDTCrphiSkip = new TH1F(named0PullESDTCrphiSkip.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
826     d0PullESDTCrphiSkip->Sumw2();
827     d0PullESDTCrphiSkip->SetMinimum(0);
828     fOutputWithTrackCuts->Add(d0PullESDTCrphiSkip);
829     d0PullESDTCzSkip = new TH1F(named0PullESDTCzSkip.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
830     d0PullESDTCzSkip->Sumw2();
831     d0PullESDTCzSkip->SetMinimum(0);
832     fOutputWithTrackCuts->Add(d0PullESDTCzSkip);
833
834     named0PullESDTCrphiTrue = "d0PullESDTCrphiTrue_";
835     named0PullESDTCrphiTrue +=i;
836     named0PullESDTCzTrue = "d0PullESDTCzTrue_";
837     named0PullESDTCzTrue +=i;
838     d0PullESDTCrphiTrue = new TH1F(named0PullESDTCrphiTrue.Data(),d0pullAllpointrphiTitle.Data(),400,-10.,10.);
839     d0PullESDTCrphiTrue->Sumw2();
840     d0PullESDTCrphiTrue->SetMinimum(0);
841     fOutputWithTrackCuts->Add(d0PullESDTCrphiTrue);
842     d0PullESDTCzTrue = new TH1F(named0PullESDTCzTrue.Data(),d0pullAllpointzTitle.Data(),400,-10.,10.);
843     d0PullESDTCzTrue->Sumw2();
844     d0PullESDTCzTrue->SetMinimum(0);
845     fOutputWithTrackCuts->Add(d0PullESDTCzTrue);
846
847     named0ptESDTC = "d0ptESDTC_";
848     named0ptESDTC += i;
849     d0PtESDTC = new TH1F(named0ptESDTC.Data(), d0ptTitle.Data(), 100, 0, 35.);
850     d0PtESDTC->Sumw2();
851     d0PtESDTC->SetMinimum(0);  
852     fOutputWithTrackCuts->Add(d0PtESDTC);
853
854
855   }
856
857   
858   if (!fOutputSinThetaRec){
859     fOutputSinThetaRec = new TList();
860     fOutputSinThetaRec->SetOwner();
861     fOutputSinThetaRec->SetName("thetaRec");
862   }
863   
864   if (!fOutputSinThetaSkip){
865     fOutputSinThetaSkip = new TList();
866     fOutputSinThetaSkip->SetOwner();
867     fOutputSinThetaSkip->SetName("thetaSkip");
868   }
869   
870   if (!fOutputphiAllpointSkip) {
871     fOutputphiAllpointSkip = new TList();
872     fOutputphiAllpointSkip->SetOwner();
873     fOutputphiAllpointSkip->SetName("phiallpointSkip");
874   }
875   
876   if (!fOutputphiPostvtracSkip) {
877     fOutputphiPostvtracSkip = new TList();
878     fOutputphiPostvtracSkip->SetOwner();
879     fOutputphiPostvtracSkip->SetName("postvtracSkip");
880   }
881   
882   if (!fOutputphiNegtvtracSkip) {
883     fOutputphiNegtvtracSkip = new TList();
884     fOutputphiNegtvtracSkip->SetOwner();
885     fOutputphiNegtvtracSkip->SetName("negtvtracSkip");
886   }
887   
888   
889   const TString d0sinThetarphiTitle ="d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
890   const TString d0sinThetazTitle ="d_{0} Distribution_z; d_{0} [#mum]; Entries";  
891   const TString d0phiAllpointrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
892   const TString d0phiAllpointzTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";    
893   const TString  d0phiPostvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
894   const TString d0phiPostvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";  
895   const TString  d0phiNegtvtracrphiTitle = "d_{0} Distribution_rphi; d_{0} [#mum]; Entries";
896   const TString d0phiNegtvtraczTitle  = "d_{0} Distribution_z; d_{0} [#mum]; Entries";   
897   TString named0sinThetaonerphiRec,named0sinThetaonezRec,named0sinThetatworphiRec,named0sinThetatwozRec,named0sinThetathreerphiRec,named0sinThetathreezRec,named0sinThetafourrphiRec,named0sinThetafourzRec,named0thetaForwardrphiRec,named0thetaForwardzRec,named0thetaBackwardrphiRec,named0thetaBackwardzRec;
898   
899   TH1F *d0SinThetaonerphiRec,*d0SinThetaonezRec,*d0SinThetatworphiRec,*d0SinThetatwozRec,*d0SinThetathreerphiRec,*d0SinThetathreezRec,*d0SinThetafourrphiRec,*d0SinThetafourzRec,*d0ThetaforwardrphiRec,*d0ThetaforwardzRec,*d0ThetabackwardrphiRec,*d0ThetabackwardzRec;
900   
901   TString  named0sinThetaonerphiSkip,named0sinThetaonezSkip,named0sinThetatworphiSkip,named0sinThetatwozSkip,named0sinThetathreerphiSkip,named0sinThetathreezSkip,named0sinThetafourrphiSkip,named0sinThetafourzSkip,named0phiAllpointrphiSkip, named0phiAllpointzSkip,named0phiPostvtracrphiSkip, named0phiPostvtraczSkip,named0phiNegtvtracrphiSkip,named0phiNegtvtraczSkip,named0thetaForwardrphiSkip,named0thetaForwardzSkip,named0thetaBackwardrphiSkip,named0thetaBackwardzSkip;
902   
903   TH1F*d0SinThetaonerphiSkip,*d0SinThetaonezSkip,*d0SinThetatworphiSkip,*d0SinThetatwozSkip,*d0SinThetathreerphiSkip,*d0SinThetathreezSkip,*d0SinThetafourrphiSkip,*d0SinThetafourzSkip, *d0PhiAllpointrphiSkip,*d0PhiAllpointzSkip,*d0PhiPostvtracrphiSkip,*d0PhiPostvtraczSkip,*d0PhiNegtvtracrphiSkip,*d0PhiNegtvtraczSkip,*d0ThetaforwardrphiSkip,*d0ThetaforwardzSkip,*d0ThetabackwardrphiSkip,*d0ThetabackwardzSkip;
904   
905   const Int_t nhistm=10;
906   for(Int_t i=0; i<=nhistm; i++) {
907     named0sinThetaonerphiRec = "d0sinthetaonerphiRec_";
908     named0sinThetaonerphiRec += i;
909     named0sinThetaonezRec ="d0sinthetaonezRec_";
910     named0sinThetaonezRec += i;
911     d0SinThetaonerphiRec = new TH1F(named0sinThetaonerphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
912     d0SinThetaonerphiRec->Sumw2();
913     d0SinThetaonerphiRec->SetMinimum(0);
914     fOutputSinThetaRec->Add(d0SinThetaonerphiRec);
915     d0SinThetaonezRec = new TH1F(named0sinThetaonezRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
916     d0SinThetaonezRec->Sumw2();
917     d0SinThetaonezRec->SetMinimum(0);
918     fOutputSinThetaRec->Add(d0SinThetaonezRec);
919     
920     named0sinThetatworphiRec = "d0sinthetatworphiRec_";
921     named0sinThetatworphiRec += i;
922     named0sinThetatwozRec ="d0sinthetatwozRec_";
923     named0sinThetatwozRec += i;
924     d0SinThetatworphiRec = new TH1F(named0sinThetatworphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
925     d0SinThetatworphiRec->Sumw2();
926     d0SinThetatworphiRec->SetMinimum(0);
927     fOutputSinThetaRec->Add(d0SinThetatworphiRec);
928     d0SinThetatwozRec = new TH1F(named0sinThetatwozRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
929     d0SinThetatwozRec->Sumw2();
930     d0SinThetatwozRec->SetMinimum(0);
931     fOutputSinThetaRec->Add(d0SinThetatwozRec);
932     
933     named0sinThetathreerphiRec = "d0sinthetathreerphiRec_";
934     named0sinThetathreerphiRec += i;
935     named0sinThetathreezRec ="d0sinthetathreezRec_";
936     named0sinThetathreezRec += i;
937     
938     d0SinThetathreerphiRec = new TH1F(named0sinThetathreerphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
939     d0SinThetathreerphiRec->Sumw2();
940     d0SinThetathreerphiRec->SetMinimum(0);
941     fOutputSinThetaRec->Add(d0SinThetathreerphiRec);
942     d0SinThetathreezRec = new TH1F(named0sinThetathreezRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
943     d0SinThetathreezRec->Sumw2();
944     d0SinThetathreezRec->SetMinimum(0);
945     fOutputSinThetaRec->Add(d0SinThetathreezRec);
946     
947     named0sinThetafourrphiRec = "d0sinthetafourrphiRec_";
948     named0sinThetafourrphiRec += i;
949     named0sinThetafourzRec ="d0sinthetafourzRec_";
950     named0sinThetafourzRec += i;
951     d0SinThetafourrphiRec = new TH1F(named0sinThetafourrphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
952     d0SinThetafourrphiRec->Sumw2();
953     d0SinThetafourrphiRec->SetMinimum(0);
954     fOutputSinThetaRec->Add(d0SinThetafourrphiRec);
955     d0SinThetafourzRec = new TH1F(named0sinThetafourzRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
956     d0SinThetafourzRec->Sumw2();
957     d0SinThetafourzRec->SetMinimum(0);
958     fOutputSinThetaRec->Add(d0SinThetafourzRec);
959
960     named0thetaForwardrphiRec = "d0thetaforwardrphiRec_";
961     named0thetaForwardrphiRec += i;
962     named0thetaForwardzRec ="d0thetaforwardzRec_";
963     named0thetaForwardzRec += i;
964     d0ThetaforwardrphiRec = new TH1F(named0thetaForwardrphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
965     d0ThetaforwardrphiRec->Sumw2();
966     d0ThetaforwardrphiRec->SetMinimum(0);
967     fOutputSinThetaRec->Add(d0ThetaforwardrphiRec);
968     d0ThetaforwardzRec = new TH1F(named0thetaForwardzRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
969     d0ThetaforwardzRec->Sumw2();
970     d0ThetaforwardzRec->SetMinimum(0);
971     fOutputSinThetaRec->Add(d0ThetaforwardzRec);
972
973     named0thetaBackwardrphiRec = "d0thetabackwardrphiRec_";
974     named0thetaBackwardrphiRec += i;
975     named0thetaBackwardzRec ="d0thetabackwardzRec_";
976     named0thetaBackwardzRec += i;
977     d0ThetabackwardrphiRec = new TH1F(named0thetaBackwardrphiRec.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
978     d0ThetabackwardrphiRec->Sumw2();
979     d0ThetabackwardrphiRec->SetMinimum(0);
980     fOutputSinThetaRec->Add(d0ThetabackwardrphiRec);
981     d0ThetabackwardzRec = new TH1F(named0thetaBackwardzRec.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
982     d0ThetabackwardzRec->Sumw2();
983     d0ThetabackwardzRec->SetMinimum(0);
984     fOutputSinThetaRec->Add(d0ThetabackwardzRec);
985     
986     named0sinThetaonerphiSkip = "d0sinthetaonerphiSkip_";
987     named0sinThetaonerphiSkip += i;
988     named0sinThetaonezSkip ="d0sinthetaonezSkip_";
989     named0sinThetaonezSkip += i;
990     d0SinThetaonerphiSkip = new TH1F(named0sinThetaonerphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
991     d0SinThetaonerphiSkip->Sumw2();
992     d0SinThetaonerphiSkip->SetMinimum(0);
993     fOutputSinThetaSkip->Add(d0SinThetaonerphiSkip);
994     d0SinThetaonezSkip = new TH1F(named0sinThetaonezSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
995     d0SinThetaonezSkip->Sumw2();
996     d0SinThetaonezSkip->SetMinimum(0);
997     fOutputSinThetaSkip->Add(d0SinThetaonezSkip);
998     
999     named0sinThetatworphiSkip = "d0sinthetatworphiSkip_";
1000     named0sinThetatworphiSkip += i;
1001     named0sinThetatwozSkip ="d0sinthetatwozSkip_";
1002     named0sinThetatwozSkip += i;
1003     d0SinThetatworphiSkip = new TH1F(named0sinThetatworphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
1004     d0SinThetatworphiSkip->Sumw2();
1005     d0SinThetatworphiSkip->SetMinimum(0);
1006     fOutputSinThetaSkip->Add(d0SinThetatworphiSkip);
1007     d0SinThetatwozSkip = new TH1F(named0sinThetatwozSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
1008     d0SinThetatwozSkip->Sumw2();
1009     d0SinThetatwozSkip->SetMinimum(0);
1010     fOutputSinThetaSkip->Add(d0SinThetatwozSkip);
1011     
1012     named0sinThetathreerphiSkip = "d0sinthetathreerphiSkip_";
1013     named0sinThetathreerphiSkip += i;
1014     named0sinThetathreezSkip ="d0sinthetathreezSkip_";
1015     named0sinThetathreezSkip += i;
1016     
1017     d0SinThetathreerphiSkip = new TH1F(named0sinThetathreerphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
1018     d0SinThetathreerphiSkip->Sumw2();
1019     d0SinThetathreerphiSkip->SetMinimum(0);
1020     fOutputSinThetaSkip->Add(d0SinThetathreerphiSkip);
1021     d0SinThetathreezSkip = new TH1F(named0sinThetathreezSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
1022     d0SinThetathreezSkip->Sumw2();
1023     d0SinThetathreezSkip->SetMinimum(0);
1024     fOutputSinThetaSkip->Add(d0SinThetathreezSkip);
1025     
1026     named0sinThetafourrphiSkip = "d0sinthetafourrphiSkip_";
1027     named0sinThetafourrphiSkip += i;
1028     named0sinThetafourzSkip ="d0sinthetafourzSkip_";
1029     named0sinThetafourzSkip += i;
1030     d0SinThetafourrphiSkip = new TH1F(named0sinThetafourrphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
1031     d0SinThetafourrphiSkip->Sumw2();
1032     d0SinThetafourrphiSkip->SetMinimum(0);
1033     fOutputSinThetaSkip->Add(d0SinThetafourrphiSkip);
1034     d0SinThetafourzSkip = new TH1F(named0sinThetafourzSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
1035     d0SinThetafourzSkip->Sumw2();
1036     d0SinThetafourzSkip->SetMinimum(0);
1037     fOutputSinThetaSkip->Add(d0SinThetafourzSkip);
1038
1039     named0thetaForwardrphiSkip = "d0thetaforwardrphiSkip_";
1040     named0thetaForwardrphiSkip += i;
1041     named0thetaForwardzSkip ="d0thetaforwardzSkip_";
1042     named0thetaForwardzSkip += i;
1043     d0ThetaforwardrphiSkip = new TH1F(named0thetaForwardrphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
1044     d0ThetaforwardrphiSkip->Sumw2();
1045     d0ThetaforwardrphiSkip->SetMinimum(0);
1046     fOutputSinThetaSkip->Add(d0ThetaforwardrphiSkip);
1047     d0ThetaforwardzSkip = new TH1F(named0thetaForwardzSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
1048     d0ThetaforwardzSkip->Sumw2();
1049     d0ThetaforwardzSkip->SetMinimum(0);
1050     fOutputSinThetaSkip->Add(d0ThetaforwardzSkip);
1051
1052     named0thetaBackwardrphiSkip = "d0thetabackwardrphiSkip_";
1053     named0thetaBackwardrphiSkip += i;
1054     named0thetaBackwardzSkip ="d0thetabackwardzSkip_";
1055     named0thetaBackwardzSkip += i;
1056     d0ThetabackwardrphiSkip = new TH1F(named0thetaBackwardrphiSkip.Data(),d0sinThetarphiTitle.Data(),400,-2000,2000);
1057     d0ThetabackwardrphiSkip->Sumw2();
1058     d0ThetabackwardrphiSkip->SetMinimum(0);
1059     fOutputSinThetaSkip->Add(d0ThetabackwardrphiSkip);
1060     d0ThetabackwardzSkip = new TH1F(named0thetaBackwardzSkip.Data(),d0sinThetazTitle.Data(),400,-2000,2000);
1061     d0ThetabackwardzSkip->Sumw2();
1062     d0ThetabackwardzSkip->SetMinimum(0);
1063     fOutputSinThetaSkip->Add(d0ThetabackwardzSkip);
1064
1065   }
1066
1067   const Int_t nhistphi=20;
1068   for(Int_t i=0; i<=nhistphi; i++) {
1069
1070     named0phiAllpointrphiSkip = "d0phiallpointrphiSkip_";
1071     named0phiAllpointrphiSkip += i;
1072     named0phiAllpointzSkip ="d0phiallpointzSkip_";
1073     named0phiAllpointzSkip += i;
1074     d0PhiAllpointrphiSkip = new TH1F(named0phiAllpointrphiSkip.Data(),d0phiAllpointrphiTitle.Data(),400,-2000,2000);
1075     d0PhiAllpointrphiSkip->Sumw2();
1076     d0PhiAllpointrphiSkip->SetMinimum(0);
1077     fOutputphiAllpointSkip->Add(d0PhiAllpointrphiSkip);
1078     d0PhiAllpointzSkip = new TH1F(named0phiAllpointzSkip.Data(),d0phiAllpointzTitle.Data(),400,-2000,2000);
1079     d0PhiAllpointzSkip->Sumw2();
1080     d0PhiAllpointzSkip->SetMinimum(0);
1081     fOutputphiAllpointSkip->Add(d0PhiAllpointzSkip);
1082
1083
1084     named0phiPostvtracrphiSkip = "d0phipostvtracrphiSkip_";
1085     named0phiPostvtracrphiSkip += i;
1086     named0phiPostvtraczSkip ="d0phipostvtraczSkip_";
1087     named0phiPostvtraczSkip += i;
1088     d0PhiPostvtracrphiSkip = new TH1F(named0phiPostvtracrphiSkip.Data(),d0phiPostvtracrphiTitle.Data(),400,-2000,2000);
1089     d0PhiPostvtracrphiSkip->Sumw2();
1090     d0PhiPostvtracrphiSkip->SetMinimum(0);
1091     fOutputphiPostvtracSkip->Add(d0PhiPostvtracrphiSkip);
1092     d0PhiPostvtraczSkip = new TH1F(named0phiPostvtraczSkip.Data(),d0phiPostvtraczTitle.Data(),400,-2000,2000);
1093     d0PhiPostvtraczSkip->Sumw2();
1094     d0PhiPostvtraczSkip->SetMinimum(0);
1095     fOutputphiPostvtracSkip->Add(d0PhiPostvtraczSkip);
1096
1097
1098     named0phiNegtvtracrphiSkip = "d0phinegtvtracrphiSkip_";
1099     named0phiNegtvtracrphiSkip += i;
1100     named0phiNegtvtraczSkip ="d0phinegtvtraczSkip_";
1101     named0phiNegtvtraczSkip += i;
1102     d0PhiNegtvtracrphiSkip = new TH1F(named0phiNegtvtracrphiSkip.Data(),d0phiNegtvtracrphiTitle.Data(),400,-2000,2000);
1103     d0PhiNegtvtracrphiSkip->Sumw2();
1104     d0PhiNegtvtracrphiSkip->SetMinimum(0);
1105     fOutputphiNegtvtracSkip->Add(d0PhiNegtvtracrphiSkip);
1106     d0PhiNegtvtraczSkip = new TH1F(named0phiNegtvtraczSkip.Data(),d0phiNegtvtraczTitle.Data(),400,-2000,2000);
1107     d0PhiNegtvtraczSkip->Sumw2();
1108     d0PhiNegtvtraczSkip->SetMinimum(0);
1109     fOutputphiNegtvtracSkip->Add(d0PhiNegtvtraczSkip);
1110   }
1111
1112   if(!fNentries) fNentries = new TH1F("hNentries", "number of entries", 26, 0., 40.);
1113   if(!fEstimVtx) fEstimVtx = new TH1F("vtxRes","Resolution of vertex",1000,-5000.,5000);
1114   PostData(1, fOutputitspureSARec);
1115   PostData(2, fOutputitspureSASkip);
1116   PostData(3, fOutputallPointRec);
1117   PostData(4, fOutputallPointSkip);
1118   PostData(5, fOutputpartPointRec);
1119   PostData(6, fOutputpartPointSkip);
1120   PostData(7, fOutputonepointSPDRec);
1121   PostData(8, fOutputonepointSPDSkip);
1122   PostData(9, fOutputpostvTracRec);
1123   PostData(10, fOutputpostvTracSkip);
1124   PostData(11, fOutputnegtvTracRec);
1125   PostData(12, fOutputnegtvTracSkip);
1126   PostData(13, fOutputpullAllpointRec);
1127   PostData(14, fOutputpullAllpointSkip);
1128   PostData(15, fOutputOnlyRefitRec);
1129   PostData(16, fOutputOnlyRefitSkip);
1130   PostData(17, fOutputSinThetaRec);
1131   PostData(18, fOutputSinThetaSkip);
1132   PostData(19, fOutputallPointTrue);
1133   PostData(20, fOutputpostvTracTrue);
1134   PostData(21, fOutputnegtvTracTrue);
1135   PostData(22, fOutputpullAllpointTrue);
1136   PostData(23, fOutputphiAllpointSkip);
1137   PostData(24, fOutputphiPostvtracSkip);
1138   PostData(25, fOutputphiNegtvtracSkip);
1139   PostData(26, fOutputparticlePID);
1140   PostData(27, fOutputPt);
1141   PostData(28, fNentries);
1142   PostData(29, fEstimVtx);  
1143   PostData(30, fOutputWithTrackCuts);
1144
1145   return;
1146 }
1147
1148 //________________________________________________________________________
1149 void AliAnalysisTaskSEImpParRes::UserExec(Option_t */*option*/)
1150 {
1151   //
1152   // Track selection and filling of d0 histograms
1153   //
1154   AliVEvent* event = dynamic_cast<AliVEvent*>(InputEvent());
1155   if (!event) {
1156     AliError("event not found. Nothing done!");
1157     return;
1158   }
1159
1160   // only events in the requested multiplicity range
1161   TString firedTriggerClasses="";
1162   Int_t runNumber=0;
1163   if(fIsAOD){
1164     Int_t nclsITS = 0;
1165     runNumber=((AliAODEvent*)event)->GetRunNumber();
1166     nclsITS = ((AliAODEvent*)event)->GetHeader()->GetNumberOfITSClusters(1);
1167     if(nclsITS<fMinMult || nclsITS>fMaxMult) return;
1168     firedTriggerClasses=((AliAODEvent*)event)->GetFiredTriggerClasses();
1169     if(!firedTriggerClasses.Contains(fTriggerClass.Data())) return;
1170   }
1171   else{
1172     runNumber=((AliESDEvent*)event)->GetRunNumber();
1173     if(!IsSelectedCentrality(((AliESDEvent*)event))) return;
1174     firedTriggerClasses=((AliESDEvent*)event)->GetFiredTriggerClasses();
1175     if(!firedTriggerClasses.Contains(fTriggerClass.Data())) return;
1176   }
1177
1178  
1179
1180   Bool_t sddIsIn=kTRUE;
1181   if(fCheckSDDIsIn) {
1182
1183     if(!fTrigConfig) {    
1184       AliCDBManager* man = AliCDBManager::Instance();
1185       if(fOCDBPath.Contains("OCDB")) { // when running in the QAtrain this is not called (OCBD is already set)
1186         man->SetDefaultStorage(fOCDBPath.Data());
1187         man->SetRun(runNumber);
1188       }
1189       if(!man) {      
1190         AliFatal("CDB not set but needed by AliAnalysisTaskITSTrackingCheck");
1191         return;    
1192       }  
1193       AliCDBEntry* eT=(AliCDBEntry*)man->Get("GRP/CTP/Config");    
1194       if(eT) {      
1195         fTrigConfig=(AliTriggerConfiguration*)eT->GetObject();    
1196       }    
1197       if(!eT || !fTrigConfig) {      
1198         AliError("Cannot retrieve CDB entry for GRP/CTP/Config");      
1199         return;    
1200       }
1201     }
1202
1203     if(fIsAOD){
1204       const TObjArray& classesArray=fTrigConfig->GetClasses();
1205       ULong64_t trigMask=((AliAODEvent*)event)->GetTriggerMask();
1206       Int_t nclasses = classesArray.GetEntriesFast();
1207       for(Int_t iclass=0; iclass < nclasses; iclass++ ) 
1208         {
1209           AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
1210           ULong64_t classMask=trclass->GetMask();
1211           if(trigMask & classMask)
1212             {
1213               TString detList=trclass->GetCluster()->GetDetectorsInCluster();
1214               if(detList.Contains("ITSSDD")) sddIsIn = kTRUE;
1215               else sddIsIn = kFALSE;
1216             }
1217         }
1218       //sddIsIn = kFALSE;
1219     }
1220     else sddIsIn=((AliESDEvent*)event)->IsDetectorInTriggerCluster("ITSSDD",fTrigConfig);
1221     if(fCheckSDDIsIn==1 && !sddIsIn) return;
1222     if(fCheckSDDIsIn==-1 && sddIsIn) return;
1223   }
1224
1225   fNentries->Fill(1);
1226
1227
1228   Int_t nTrks = event->GetNumberOfTracks();
1229   Bool_t highMult=(nTrks>500 ? kTRUE : kFALSE);
1230
1231   Double_t vtxTrue[3];
1232   AliStack *stack=0;
1233   TClonesArray *mcArray=0;
1234   AliESDVertex *vtxESDTrue=0;
1235   AliVVertex *vtxVSkip=0;
1236   AliVVertex *vtxVRec=0;  
1237   AliVVertex* primaryVtx=0;
1238
1239
1240   // event primary vertex
1241   AliVertexerTracks vertexer0(event->GetMagneticField());
1242   vertexer0.SetITSMode();
1243   vertexer0.SetMinClusters(3);
1244   if(highMult) vertexer0.SetITSMode(0.1,0.1,0.5,5,1,3.,100.,1000.,3.,30.,1,1);
1245   if(fUseDiamond){
1246     // diamond constraint
1247     Float_t diamondcovxy[3];
1248     event->GetDiamondCovXY(diamondcovxy);
1249     Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1250     Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
1251     AliESDVertex diamond(pos,cov,1.,1);
1252     vertexer0.SetVtxStart(&diamond);
1253   }
1254   vtxVRec=(AliVVertex*)vertexer0.FindPrimaryVertex(event);
1255   if(!vtxVRec) return;
1256   if(vtxVRec->GetNContributors()<1){
1257     delete vtxVRec; vtxVRec=NULL;
1258     return;
1259   }
1260   
1261   if (fReadMC) {
1262     if (fIsAOD){
1263       mcArray = dynamic_cast<TClonesArray*>(((AliAODEvent*)event)->FindListObject(AliAODMCParticle::StdBranchName()));
1264       if(!mcArray){
1265         AliError("Clould not find Monte-Carlo in AOD");
1266         return;
1267       }
1268       AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(((AliAODEvent*)(event))->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
1269       if (!mcHeader) {
1270         AliError("Could not find MC Header in AOD");
1271         return;
1272       }
1273       
1274       Double_t mcVertex[3]={9999.,9999.,9999.};
1275       mcHeader->GetVertex(mcVertex);
1276       vtxTrue[0]=mcVertex[0];vtxTrue[1]=mcVertex[1];vtxTrue[2]=mcVertex[2];
1277       Double_t sigmaTrue[3]={0., 0., 0.,};
1278       vtxESDTrue = new AliESDVertex(vtxTrue,sigmaTrue);
1279     }//end if isAOD
1280     else{
1281       AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
1282       if (!eventHandler) {
1283         Printf("ERROR: Could not retrieve MC event handler");
1284         return;
1285       }
1286       
1287       AliMCEvent* mcEvent = eventHandler->MCEvent();
1288       if (!mcEvent) {
1289         Printf("ERROR: Could not retrieve MC event");
1290         return;
1291       }
1292       
1293       stack = mcEvent->Stack();
1294       if (!stack) {
1295         AliDebug(AliLog::kError, "Stack not available");
1296         return;
1297       }
1298       
1299       //load MC header for ESD;//see $ALICE_ROOT/PWGPP/global/AliAnalysisTaskSEVertexESD.cxx
1300       AliHeader *mcHeader = eventHandler->MCEvent()->Header();
1301       if (!mcHeader) {
1302         AliDebug(AliLog::kError, "Header not available");
1303         return;
1304       }
1305
1306       AliGenEventHeader* genHeader = mcHeader->GenEventHeader();  
1307       TArrayF mcVertex(3);
1308       mcVertex[0]=9999.; mcVertex[1]=9999.; mcVertex[2]=9999.;
1309       genHeader->PrimaryVertex(mcVertex);
1310       vtxTrue[0]=mcVertex[0];vtxTrue[1]=mcVertex[1];vtxTrue[2]=mcVertex[2];
1311       Double_t sigmaTrue[3]={0., 0., 0.,};
1312       //mcHeader->GetVertex(vtxTrue);//note the vtxTrue is void here,so must need the next line.
1313       //AliESDVertex *vtxESDTrue = new AliESDVertex(vtxTrue,sigmaTrue);
1314       vtxESDTrue = new AliESDVertex(vtxTrue,sigmaTrue);
1315       
1316     }//end else (!isAOD)
1317   }
1318   
1319   Double_t beampiperadius=3.;
1320   AliVTrack *vtrack = 0;
1321   Int_t pdgCode=0;
1322   Int_t trkLabel;
1323   TParticle  *part =0;
1324   AliAODMCParticle *AODpart=0;
1325   Int_t npointsITS=0,npointsSPD=0;
1326   Int_t skipped[2];
1327   Double_t dzRec[2], covdzRec[3], dzRecSkip[2], covdzRecSkip[3],dzTrue[2], covdzTrue[3];
1328   Double_t pt;
1329   Int_t bin;
1330   Int_t nClsTotTPC=0;
1331   Bool_t haskITSrefit=kFALSE;
1332   Bool_t haskTPCrefit=kFALSE;
1333   Int_t charge=0;
1334   Double_t phi=0.;
1335   Double_t theta=0.;
1336   Double_t eta=0.;
1337
1338   
1339   for (Int_t it=0; it<nTrks; it++){ //start loop over tracks
1340     vtrack = (AliVTrack*)event->GetTrack(it);
1341     if(!vtrack) continue;
1342
1343     eta = vtrack->Eta();
1344     if(eta<-0.8 || eta>0.8) continue;
1345     
1346     npointsITS=0; npointsSPD=0;
1347     if(fIsAOD){
1348       haskITSrefit=(((AliAODTrack*)vtrack)->GetStatus()&AliESDtrack::kITSrefit);
1349       haskTPCrefit=(((AliAODTrack*)vtrack)->GetStatus()&AliESDtrack::kTPCrefit);
1350       nClsTotTPC=((AliAODTrack*)vtrack)->GetTPCNcls();
1351       if(!haskITSrefit) continue;
1352       for(Int_t ilayer=0; ilayer<6; ilayer++){
1353         if (ilayer<2 && ((AliAODTrack*)vtrack)->HasPointOnITSLayer(ilayer)) npointsSPD++;
1354         if (((AliAODTrack*)vtrack)->HasPointOnITSLayer(ilayer)) npointsITS++;  
1355       }
1356     }
1357     else {
1358       haskITSrefit=(((AliESDtrack*)vtrack)->GetStatus()&AliESDtrack::kITSrefit);
1359       haskTPCrefit=(((AliESDtrack*)vtrack)->GetStatus()&AliESDtrack::kTPCrefit);
1360       nClsTotTPC=((AliESDtrack*)vtrack)->GetTPCNcls();
1361       if(!haskITSrefit) continue;
1362       for (Int_t ilayer=0; ilayer<6; ilayer++){ 
1363         if (ilayer<2 && ((AliESDtrack*)vtrack)->HasPointOnITSLayer(ilayer)) npointsSPD++;
1364         if (((AliESDtrack*)vtrack)->HasPointOnITSLayer(ilayer)) npointsITS++;  
1365       }
1366     }
1367     charge=vtrack->Charge();
1368     phi=vtrack->Phi();
1369     theta=vtrack->Theta();
1370
1371     //MC
1372     if (fReadMC){
1373       trkLabel = vtrack->GetLabel();
1374       if(trkLabel<0) continue;
1375       if(fIsAOD && mcArray){
1376         AODpart = (AliAODMCParticle*)mcArray->At(trkLabel);
1377         if(!AODpart) printf("NOPART\n");
1378         pdgCode = TMath::Abs(AODpart->GetPdgCode());    
1379       }
1380       if(!fIsAOD && stack) {
1381         part = (TParticle*)stack->Particle(trkLabel);
1382         pdgCode = TMath::Abs(part->GetPdgCode());
1383       }
1384       //pdgCode = TMath::Abs(part->GetPdgCode());
1385       //printf("pdgCode===%d\n", pdgCode);
1386       if(fSelectedPdg>0 && pdgCode!=fSelectedPdg) continue;
1387     }
1388     
1389       
1390       //Get specific primary vertex--Reconstructed primary vertex do not include the track considering.
1391     AliVertexerTracks vertexer(event->GetMagneticField());
1392     vertexer.SetITSMode();
1393     vertexer.SetMinClusters(3);
1394     if(fUseDiamond){
1395       Float_t diamondcovxy[3];
1396       event->GetDiamondCovXY(diamondcovxy);
1397       Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1398       Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
1399       AliESDVertex diamond(pos,cov,1.,1);
1400       vertexer.SetVtxStart(&diamond);
1401     }
1402     skipped[0] = (Int_t)vtrack->GetID();
1403     vertexer.SetSkipTracks(1,skipped);      
1404     // create vertex with new!
1405     if(!highMult && fSkipTrack) {
1406       vtxVSkip = (AliVVertex*)vertexer.FindPrimaryVertex(event);
1407       if(!vtxVSkip) continue;
1408       if(vtxVSkip->GetNContributors()<1) {
1409         delete vtxVSkip; vtxVSkip=NULL;
1410         continue;
1411       }
1412     } // else {
1413       // vtxVSkip = new AliVVertex(); produce error!!!
1414       // } 
1415  
1416     pt = vtrack->Pt();
1417     bin = PtBin(pt);
1418  
1419     if(bin==-1) {
1420       delete vtxVSkip; vtxVSkip=NULL;
1421       continue;
1422     }
1423
1424     // Select primary particle if MC event (for ESD event), Rprod < 1 micron
1425     if(fReadMC){
1426       if(fIsAOD){
1427         if((AODpart->Xv()-vtxTrue[0])*(AODpart->Xv()-vtxTrue[0])+
1428            (AODpart->Yv()-vtxTrue[1])*(AODpart->Yv()-vtxTrue[1])
1429            > 0.0001*0.0001) {
1430           delete vtxVSkip; vtxVSkip=NULL;
1431           continue;
1432         }
1433       }
1434       else{
1435         if((part->Vx()-vtxTrue[0])*(part->Vx()-vtxTrue[0])+
1436            (part->Vy()-vtxTrue[1])*(part->Vy()-vtxTrue[1])
1437            > 0.0001*0.0001) {
1438           delete vtxVSkip; vtxVSkip=NULL;
1439           continue;
1440         }
1441       }
1442     }
1443     
1444     
1445     // compute impact patameters
1446     // wrt event vertex
1447     vtrack->PropagateToDCA(vtxVRec, event->GetMagneticField(), beampiperadius, dzRec, covdzRec);
1448     // wrt event vertex without this track
1449     if(!highMult && fSkipTrack) {
1450       vtrack->PropagateToDCA(vtxVSkip, event->GetMagneticField(), beampiperadius, dzRecSkip, covdzRecSkip);
1451     } else if(!fSkipTrack) {
1452       dzRecSkip[0]=dzRec[0]; 
1453       dzRecSkip[1]=dzRec[1];
1454       covdzRecSkip[0]=covdzRec[0];
1455       covdzRecSkip[1]=covdzRec[1];
1456       covdzRecSkip[2]=covdzRec[2];
1457     } else {
1458       dzRecSkip[0]=0; 
1459       dzRecSkip[1]=0;
1460       covdzRecSkip[0]=0;
1461       covdzRecSkip[1]=0;
1462       covdzRecSkip[2]=0;
1463     }
1464     //delete vtxVSkip; vtxVSkip=NULL; // not needed anymore
1465  
1466     if(fReadMC) vtrack->PropagateToDCA(vtxESDTrue, event->GetMagneticField(), beampiperadius, dzTrue, covdzTrue);
1467     if(covdzRec[0]<1.e-13 || covdzRec[2]<1.e-13 || covdzRecSkip[0]<1.e-13 || covdzRecSkip[2]<1.e-13) continue;
1468     if(fReadMC && (covdzTrue[0]<1.e-13 || covdzTrue[2]<1.e-13)) continue;
1469
1470
1471     // Bayesian PID only for ESD
1472     if(!fIsAOD && (npointsITS==6 || (npointsITS==4 && !sddIsIn))){
1473       Double_t prob[AliPID::kSPECIES];
1474       ((AliESDtrack*)(vtrack))->GetESDpid(prob);
1475       Double_t priors[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
1476       
1477       
1478       AliPID pid;
1479       pid.SetPriors(priors);
1480       pid.SetProbabilities(prob);
1481       
1482       // identify particle as the most probable    
1483       Double_t pelectron = pid.GetProbability(AliPID::kElectron);
1484       Double_t pmuon = pid.GetProbability(AliPID::kMuon);
1485       Double_t ppion = pid.GetProbability(AliPID::kPion);
1486       Double_t pkaon = pid.GetProbability(AliPID::kKaon);
1487       Double_t pproton = pid.GetProbability(AliPID::kProton);  
1488       
1489       if (ppion > pelectron &&
1490           ppion > pmuon  &&
1491           ppion > pkaon &&
1492           ppion > pproton ) {
1493         //esdPid =-kPDGelectron;
1494         char *named0PionPIDrphiRec = Form("d0pionPIDrphiRec_%d", bin);
1495         char *named0PionPIDzRec = Form("d0pionPIDzRec_%d", bin);
1496         char *named0PionPIDrphiSkip = Form("d0pionPIDrphiSkip_%d", bin);
1497         char *named0PionPIDzSkip = Form("d0pionPIDzSkip_%d", bin);
1498         ((TH1F*)(fOutputparticlePID->FindObject(named0PionPIDrphiRec)))->Fill(10000.*dzRec[0]);
1499         ((TH1F*)(fOutputparticlePID->FindObject(named0PionPIDzRec)))->Fill(10000.*dzRec[1]);
1500         ((TH1F*)(fOutputparticlePID->FindObject(named0PionPIDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1501         ((TH1F*)(fOutputparticlePID->FindObject(named0PionPIDzSkip)))->Fill(10000.*dzRecSkip[1]);
1502       }
1503       
1504       
1505       if (pkaon > pelectron &&
1506           pkaon > pmuon  &&
1507           pkaon > ppion &&
1508           pkaon > pproton ) {
1509         //esdPid =-kPDGelectron;
1510         char *named0KaonPIDrphiRec = Form("d0kaonPIDrphiRec_%d", bin);
1511         char *named0KaonPIDzRec = Form("d0kaonPIDzRec_%d", bin);
1512         char *named0KaonPIDrphiSkip = Form("d0kaonPIDrphiSkip_%d", bin);
1513         char *named0KaonPIDzSkip = Form("d0kaonPIDzSkip_%d", bin);
1514         ((TH1F*)(fOutputparticlePID->FindObject(named0KaonPIDrphiRec)))->Fill(10000.*dzRec[0]);
1515         ((TH1F*)(fOutputparticlePID->FindObject(named0KaonPIDzRec)))->Fill(10000.*dzRec[1]);
1516         ((TH1F*)(fOutputparticlePID->FindObject(named0KaonPIDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1517         ((TH1F*)(fOutputparticlePID->FindObject(named0KaonPIDzSkip)))->Fill(10000.*dzRecSkip[1]);
1518       }
1519       
1520       
1521       if (pproton > pelectron &&
1522           pproton >pmuon  &&
1523           pproton > ppion &&
1524           pproton > pkaon ) {
1525         //esdPid =-kPDGelectron;
1526         //if(p<0.5 && fReadMC){fEstimVtx->Fill(pdgCode);}
1527         char *named0ProtonPIDrphiRec = Form("d0protonPIDrphiRec_%d", bin);
1528         char *named0ProtonPIDzRec = Form("d0protonPIDzRec_%d", bin);
1529         char *named0ProtonPIDrphiSkip = Form("d0protonPIDrphiSkip_%d", bin);
1530         char *named0ProtonPIDzSkip = Form("d0protonPIDzSkip_%d", bin);
1531         ((TH1F*)(fOutputparticlePID->FindObject(named0ProtonPIDrphiRec)))->Fill(10000.*dzRec[0]);
1532         ((TH1F*)(fOutputparticlePID->FindObject(named0ProtonPIDzRec)))->Fill(10000.*dzRec[1]);
1533         ((TH1F*)(fOutputparticlePID->FindObject(named0ProtonPIDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1534         ((TH1F*)(fOutputparticlePID->FindObject(named0ProtonPIDzSkip)))->Fill(10000.*dzRecSkip[1]);
1535       }
1536     }
1537
1538     // ESD TRACK CUTS
1539     if(fReadMC) primaryVtx=vtxESDTrue;
1540     else if(fSkipTrack) primaryVtx=vtxVSkip;
1541     else primaryVtx=vtxVRec;
1542
1543     if(IsTrackSelected(vtrack,primaryVtx,fESDtrackCuts)){
1544
1545
1546       char *named0PtESDTC = Form("d0ptESDTC_%d",bin);
1547         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PtESDTC)))->Fill(pt);
1548
1549         char *named0DistrESDTCrphiRec = Form("d0DistrESDTCrphiRec_%d", bin);
1550         char *named0DistrESDTCrphiSkip = Form("d0DistrESDTCrphiSkip_%d", bin);
1551         char *named0DistrESDTCrphiTrue = Form("d0DistrESDTCrphiTrue_%d", bin);
1552         char *named0DistrESDTCzRec = Form("d0DistrESDTCzRec_%d", bin);
1553         char *named0DistrESDTCzSkip = Form("d0DistrESDTCzSkip_%d", bin);
1554         char *named0DistrESDTCzTrue = Form("d0DistrESDTCzTrue_%d", bin);
1555         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCrphiRec)))->Fill(10000.*dzRec[0]);
1556         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCzRec)))->Fill(10000.*dzRec[1]);
1557         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1558         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCzSkip)))->Fill(10000.*dzRecSkip[1]);
1559         
1560  
1561         if(fReadMC) {
1562           ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCrphiTrue)))->Fill(10000.*dzTrue[0]);
1563           ((TH1F*)(fOutputWithTrackCuts->FindObject(named0DistrESDTCzTrue)))->Fill(10000.*dzTrue[1]);
1564         }
1565         
1566         // pulls
1567         char *named0PullESDTCrphiRec = Form("d0PullESDTCrphiRec_%d", bin);
1568         char *named0PullESDTCrphiSkip = Form("d0PullESDTCrphiSkip_%d", bin);
1569         char *named0PullESDTCrphiTrue = Form("d0PullESDTCrphiTrue_%d", bin);
1570         char *named0PullESDTCzRec = Form("d0PullESDTCzRec_%d", bin);
1571         char *named0PullESDTCzSkip = Form("d0PullESDTCzSkip_%d", bin);
1572         char *named0PullESDTCzTrue = Form("d0PullESDTCzTrue_%d", bin);
1573         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCrphiRec)))->Fill(dzRec[0]/TMath::Sqrt(covdzRec[0]));    
1574         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCzRec)))->Fill(dzRec[1]/TMath::Sqrt(covdzRec[2]));
1575         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCrphiSkip)))->Fill(dzRecSkip[0]/TMath::Sqrt(covdzRecSkip[0]));
1576         ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCzSkip)))->Fill(dzRecSkip[1]/TMath::Sqrt(covdzRecSkip[2]));
1577         if(fReadMC) {
1578           ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCrphiTrue)))->Fill(dzTrue[0]/TMath::Sqrt(covdzTrue[0]));
1579           ((TH1F*)(fOutputWithTrackCuts->FindObject(named0PullESDTCzTrue)))->Fill(dzTrue[1]/TMath::Sqrt(covdzTrue[2]));
1580         }
1581         
1582         }
1583
1584     
1585
1586     // ITS standalone
1587     if (nClsTotTPC==0 && haskITSrefit && npointsSPD>0 && npointsITS>=4) {
1588       char *named0ITSpureSArphiRec = Form("d0itspureSArphiRec_%d", bin);
1589       char *named0ITSpureSArphiSkip = Form("d0itspureSArphiSkip_%d", bin);
1590       char *named0ITSpureSAzRec = Form("d0itspureSAzRec_%d", bin);
1591       char *named0ITSpureSAzSkip = Form("d0itspureSAzSkip_%d", bin);
1592       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSArphiRec)))->Fill(10000.*dzRec[0]);
1593       ((TH1F*)(fOutputitspureSARec->FindObject(named0ITSpureSAzRec)))->Fill(10000.*dzRec[1]);
1594       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSArphiSkip)))->Fill(10000.*dzRecSkip[0]);
1595       ((TH1F*)(fOutputitspureSASkip->FindObject(named0ITSpureSAzSkip)))->Fill(10000.*dzRecSkip[1]);
1596     }
1597
1598
1599    
1600     // ask for TPC refit
1601     if (!haskTPCrefit || nClsTotTPC<70) continue;
1602    
1603     // only ITS and TPC refit
1604     char *named0OnlyrefitrphiRec = Form("d0onlyrefitrphiRec_%d", bin);
1605     char *named0OnlyrefitrphiSkip = Form("d0onlyrefitrphiSkip_%d", bin);
1606     char *named0OnlyrefitzRec = Form("d0onlyrefitzRec_%d", bin);
1607     char *named0OnlyrefitzSkip = Form("d0onlyrefitzSkip_%d", bin);
1608     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitrphiRec)))->Fill(10000.*dzRec[0]);
1609     ((TH1F*)(fOutputOnlyRefitRec->FindObject(named0OnlyrefitzRec)))->Fill(10000.*dzRec[1]);
1610     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1611     ((TH1F*)(fOutputOnlyRefitSkip->FindObject(named0OnlyrefitzSkip)))->Fill(10000.*dzRecSkip[1]);  
1612    
1613
1614     if(npointsITS>=4 && npointsSPD>0) {
1615       char *named0PartpointrphiRec = Form("d0partpointrphiRec_%d", bin);
1616       char *named0PartpointrphiSkip = Form("d0partpointrphiSkip_%d", bin);
1617       char *named0PartpointzRec = Form("d0partpointzRec_%d", bin);
1618       char *named0PartpointzSkip = Form("d0partpointzSkip_%d", bin);
1619       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointrphiRec)))->Fill(10000.*dzRec[0]);
1620       ((TH1F*)(fOutputpartPointRec->FindObject(named0PartpointzRec)))->Fill(10000.*dzRec[1]);
1621       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1622       ((TH1F*)(fOutputpartPointSkip->FindObject(named0PartpointzSkip)))->Fill(10000.*dzRecSkip[1]);
1623     }
1624
1625     if(npointsSPD>0) {
1626       char *named0OnepointSPDrphiRec = Form("d0onepointSPDrphiRec_%d", bin);
1627       char *named0OnepointSPDrphiSkip = Form("d0onepointSPDrphiSkip_%d", bin);
1628       char *named0OnepointSPDzRec = Form("d0onepointSPDzRec_%d", bin);
1629       char *named0OnepointSPDzSkip = Form("d0onepointSPDzSkip_%d", bin);
1630       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDrphiRec)))->Fill(10000.*dzRec[0]);
1631       ((TH1F*)(fOutputonepointSPDRec->FindObject(named0OnepointSPDzRec)))->Fill(10000.*dzRec[1]);
1632       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1633       ((TH1F*)(fOutputonepointSPDSkip->FindObject(named0OnepointSPDzSkip)))->Fill(10000.*dzRecSkip[1]);
1634     }
1635
1636    
1637     if(npointsITS==6 || (npointsITS==4 && !sddIsIn)) {
1638       //pt
1639       char *named0Pt = Form("d0pt_%d",bin);
1640       ((TH1F*)(fOutputPt->FindObject(named0Pt)))->Fill(pt);
1641
1642
1643       // allpoint
1644       char *named0AllpointrphiRec = Form("d0allpointrphiRec_%d", bin);
1645       char *named0AllpointrphiSkip = Form("d0allpointrphiSkip_%d", bin);
1646       char *named0AllpointrphiTrue = Form("d0allpointrphiTrue_%d", bin);
1647       char *named0AllpointzRec = Form("d0allpointzRec_%d", bin);
1648       char *named0AllpointzSkip = Form("d0allpointzSkip_%d", bin);
1649       char *named0AllpointzTrue = Form("d0allpointzTrue_%d", bin);
1650       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointrphiRec)))->Fill(10000.*dzRec[0]);
1651       ((TH1F*)(fOutputallPointRec->FindObject(named0AllpointzRec)))->Fill(10000.*dzRec[1]);
1652       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1653       ((TH1F*)(fOutputallPointSkip->FindObject(named0AllpointzSkip)))->Fill(10000.*dzRecSkip[1]);
1654       if(fReadMC) {
1655         ((TH1F*)(fOutputallPointTrue->FindObject(named0AllpointrphiTrue)))->Fill(10000.*dzTrue[0]);
1656         ((TH1F*)(fOutputallPointTrue->FindObject(named0AllpointzTrue)))->Fill(10000.*dzTrue[1]);
1657       }
1658      
1659       // pulls
1660       char *named0PullAllpointrphiRec = Form("d0pullAllpointrphiRec_%d", bin);
1661       char *named0PullAllpointrphiSkip = Form("d0pullAllpointrphiSkip_%d", bin);
1662       char *named0PullAllpointrphiTrue = Form("d0pullAllpointrphiTrue_%d", bin);
1663       char *named0PullAllpointzRec = Form("d0pullAllpointzRec_%d", bin);
1664       char *named0PullAllpointzSkip = Form("d0pullAllpointzSkip_%d", bin);
1665       char *named0PullAllpointzTrue = Form("d0pullAllpointzTrue_%d", bin);
1666       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointrphiRec)))->Fill(dzRec[0]/TMath::Sqrt(covdzRec[0]));    
1667       ((TH1F*)(fOutputpullAllpointRec->FindObject(named0PullAllpointzRec)))->Fill(dzRec[1]/TMath::Sqrt(covdzRec[2]));
1668       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointrphiSkip)))->Fill(dzRecSkip[0]/TMath::Sqrt(covdzRecSkip[0]));
1669       ((TH1F*)(fOutputpullAllpointSkip->FindObject(named0PullAllpointzSkip)))->Fill(dzRecSkip[1]/TMath::Sqrt(covdzRecSkip[2]));
1670       if(fReadMC) {
1671         ((TH1F*)(fOutputpullAllpointTrue->FindObject(named0PullAllpointrphiTrue)))->Fill(dzTrue[0]/TMath::Sqrt(covdzTrue[0]));
1672         ((TH1F*)(fOutputpullAllpointTrue->FindObject(named0PullAllpointzTrue)))->Fill(dzTrue[1]/TMath::Sqrt(covdzTrue[2]));
1673       }
1674       //postive and negative track
1675       //Int_t charge=esdtrack->Charge();
1676       if(charge==1) {
1677         char *named0PostvtracrphiRec = Form("d0postvtracrphiRec_%d", bin);
1678         char *named0PostvtracrphiSkip = Form("d0postvtracrphiSkip_%d", bin);
1679         char *named0PostvtracrphiTrue = Form("d0postvtracrphiTrue_%d", bin);
1680         char *named0PostvtraczRec = Form("d0postvtraczRec_%d", bin);
1681         char *named0PostvtraczSkip = Form("d0postvtraczSkip_%d", bin);
1682         char *named0PostvtraczTrue = Form("d0postvtraczTrue_%d", bin);
1683         ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtracrphiRec)))->Fill(10000.*dzRec[0]);
1684         ((TH1F*)(fOutputpostvTracRec->FindObject(named0PostvtraczRec)))->Fill(10000.*dzRec[1]);
1685         ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1686         ((TH1F*)(fOutputpostvTracSkip->FindObject(named0PostvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
1687         if(fReadMC) {
1688           ((TH1F*)(fOutputpostvTracTrue->FindObject(named0PostvtracrphiTrue)))->Fill(10000.*dzTrue[0]);
1689           ((TH1F*)(fOutputpostvTracTrue->FindObject(named0PostvtraczTrue)))->Fill(10000.*dzTrue[1]);
1690         }
1691       }
1692      
1693       if(charge==-1) {
1694         char *named0NegtvtracrphiRec = Form("d0negtvtracrphiRec_%d", bin);
1695         char *named0NegtvtracrphiSkip = Form("d0negtvtracrphiSkip_%d", bin);
1696         char *named0NegtvtracrphiTrue = Form("d0negtvtracrphiTrue_%d", bin);
1697         char *named0NegtvtraczRec = Form("d0negtvtraczRec_%d", bin);
1698         char *named0NegtvtraczSkip = Form("d0negtvtraczSkip_%d", bin);
1699         char *named0NegtvtraczTrue = Form("d0negtvtraczTrue_%d", bin);
1700         ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtracrphiRec)))->Fill(10000.*dzRec[0]);
1701         ((TH1F*)(fOutputnegtvTracRec->FindObject(named0NegtvtraczRec)))->Fill(10000.*dzRec[1]);
1702         ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtracrphiSkip)))->Fill(10000.*dzRecSkip[0]);
1703         ((TH1F*)(fOutputnegtvTracSkip->FindObject(named0NegtvtraczSkip)))->Fill(10000.*dzRecSkip[1]);
1704         if(fReadMC) {
1705           ((TH1F*)(fOutputnegtvTracTrue->FindObject(named0NegtvtracrphiTrue)))->Fill(10000.*dzTrue[0]);
1706           ((TH1F*)(fOutputnegtvTracTrue->FindObject(named0NegtvtraczTrue)))->Fill(10000.*dzTrue[1]);   
1707         }    
1708       }
1709      
1710       // SinTheta
1711       //Double_t theta=esdtrack->Theta();
1712       Double_t Sintheta=TMath::Sin(theta);
1713       Double_t pi=TMath::Pi();
1714       Double_t halfpi=0.5*pi;
1715       Int_t thetabin = SinThetaBin(Sintheta);
1716       if(thetabin<0) continue;
1717       if(bin==4 && theta<halfpi){
1718         char *named0ThetaforwardrphiRec = Form("d0thetaforwardrphiRec_%d", thetabin);
1719         char *named0ThetaforwardzRec = Form("d0thetaforwardzRec_%d", thetabin);
1720         char *named0ThetaforwardrphiSkip = Form("d0thetaforwardrphiSkip_%d", thetabin);
1721         char *named0ThetaforwardzSkip = Form("d0thetaforwardzSkip_%d", thetabin);
1722         ((TH1F*)(fOutputSinThetaRec->FindObject(named0ThetaforwardrphiRec)))->Fill(10000*dzRec[0]);
1723         ((TH1F*)(fOutputSinThetaRec->FindObject(named0ThetaforwardzRec)))->Fill(10000*dzRec[1]);
1724         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0ThetaforwardrphiSkip)))->Fill(10000*dzRecSkip[0]);
1725         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0ThetaforwardzSkip)))->Fill(10000*dzRecSkip[1]);
1726       }
1727
1728       if(bin==4 && theta>halfpi){
1729         char *named0ThetabackwardrphiRec = Form("d0thetabackwardrphiRec_%d", thetabin);
1730         char *named0ThetabackwardzRec = Form("d0thetabackwardzRec_%d", thetabin);
1731         char *named0ThetabackwardrphiSkip = Form("d0thetabackwardrphiSkip_%d", thetabin);
1732         char *named0ThetabackwardzSkip = Form("d0thetabackwardzSkip_%d", thetabin);
1733         ((TH1F*)(fOutputSinThetaRec->FindObject(named0ThetabackwardrphiRec)))->Fill(10000*dzRec[0]);
1734         ((TH1F*)(fOutputSinThetaRec->FindObject(named0ThetabackwardzRec)))->Fill(10000*dzRec[1]);
1735         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0ThetabackwardrphiSkip)))->Fill(10000*dzRecSkip[0]);
1736         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0ThetabackwardzSkip)))->Fill(10000*dzRecSkip[1]);
1737       }
1738      
1739       if(bin==1) {
1740         char *named0SinthetaonerphiRec = Form("d0sinthetaonerphiRec_%d", thetabin);
1741         char *named0SinthetaonezRec = Form("d0sinthetaonezRec_%d", thetabin);
1742         char *named0SinthetaonerphiSkip = Form("d0sinthetaonerphiSkip_%d", thetabin);
1743         char *named0SinthetaonezSkip = Form("d0sinthetaonezSkip_%d", thetabin);
1744         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetaonerphiRec)))->Fill(10000*dzRec[0]);
1745         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetaonezRec)))->Fill(10000*dzRec[1]);
1746         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetaonerphiSkip)))->Fill(10000*dzRecSkip[0]);
1747         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetaonezSkip)))->Fill(10000*dzRecSkip[1]);
1748       }
1749      
1750       if(bin==5) {
1751         char *named0SinthetatworphiRec = Form("d0sinthetatworphiRec_%d", thetabin);
1752         char *named0SinthetatwozRec = Form("d0sinthetatwozRec_%d", thetabin);
1753         char *named0SinthetatworphiSkip = Form("d0sinthetatworphiSkip_%d", thetabin);
1754         char *named0SinthetatwozSkip = Form("d0sinthetatwozSkip_%d", thetabin);
1755         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetatworphiRec)))->Fill(10000*dzRec[0]);
1756         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetatwozRec)))->Fill(10000*dzRec[1]);
1757         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetatworphiSkip)))->Fill(10000*dzRecSkip[0]);
1758         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetatwozSkip)))->Fill(10000*dzRecSkip[1]);
1759       }
1760      
1761       if(bin==10) {
1762         char *named0SinthetathreerphiRec = Form("d0sinthetathreerphiRec_%d", thetabin);
1763         char *named0SinthetathreezRec = Form("d0sinthetathreezRec_%d", thetabin);
1764         char *named0SinthetathreerphiSkip = Form("d0sinthetathreerphiSkip_%d", thetabin);
1765         char *named0SinthetathreezSkip = Form("d0sinthetathreezSkip_%d", thetabin);
1766         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetathreerphiRec)))->Fill(10000*dzRec[0]);
1767         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetathreezRec)))->Fill(10000*dzRec[1]);
1768         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetathreerphiSkip)))->Fill(10000*dzRecSkip[0]);
1769         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetathreezSkip)))->Fill(10000*dzRecSkip[1]);
1770       }
1771      
1772       if(bin==15) {
1773         char *named0SinthetafourrphiRec = Form("d0sinthetafourrphiRec_%d", thetabin);
1774         char *named0SinthetafourzRec = Form("d0sinthetafourzRec_%d", thetabin);
1775         char *named0SinthetafourrphiSkip = Form("d0sinthetafourrphiSkip_%d", thetabin);
1776         char *named0SinthetafourzSkip = Form("d0sinthetafourzSkip_%d", thetabin);
1777         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetafourrphiRec)))->Fill(10000*dzRec[0]);
1778         ((TH1F*)(fOutputSinThetaRec->FindObject(named0SinthetafourzRec)))->Fill(10000*dzRec[1]);
1779         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetafourrphiSkip)))->Fill(10000*dzRecSkip[0]);
1780         ((TH1F*)(fOutputSinThetaSkip->FindObject(named0SinthetafourzSkip)))->Fill(10000*dzRecSkip[1]);
1781       }
1782      
1783       //Phi
1784       //Double_t phi=esdtrack->Phi();
1785       //Double_t pi=TMath::Pi();
1786       Int_t phibin=PhiBin(phi);
1787       if(phibin<0) continue;
1788       if(pt>0.34 && pt<0.5) {
1789         char *named0PhiallpointrphiSkip =Form("d0phiallpointrphiSkip_%d",phibin);
1790         char *named0PhiallpointzSkip = Form("d0phiallpointzSkip_%d",phibin);
1791         char *named0PhipostvtracrphiSkip =Form("d0phipostvtracrphiSkip_%d",phibin);
1792         char *named0PhipostvtraczSkip = Form("d0phipostvtraczSkip_%d",phibin);
1793         char *named0PhinegtvtracrphiSkip =Form("d0phinegtvtracrphiSkip_%d",phibin);
1794         char *named0PhinegtvtraczSkip = Form("d0phinegtvtraczSkip_%d",phibin);
1795         ((TH1F*)(fOutputphiAllpointSkip->FindObject(named0PhiallpointrphiSkip)))->Fill(10000*dzRecSkip[0]);
1796         ((TH1F*)(fOutputphiAllpointSkip->FindObject(named0PhiallpointzSkip)))->Fill(10000*dzRecSkip[1]);
1797         if(charge==+1) {
1798           ((TH1F*)(fOutputphiPostvtracSkip->FindObject(named0PhipostvtracrphiSkip)))->Fill(10000*dzRecSkip[0]);
1799           ((TH1F*)(fOutputphiPostvtracSkip->FindObject(named0PhipostvtraczSkip)))->Fill(10000*dzRecSkip[1]);
1800         }
1801         if(charge==-1) {
1802           ((TH1F*)(fOutputphiNegtvtracSkip->FindObject(named0PhinegtvtracrphiSkip)))->Fill(10000*dzRecSkip[0]);
1803           ((TH1F*)(fOutputphiNegtvtracSkip->FindObject(named0PhinegtvtraczSkip)))->Fill(10000*dzRecSkip[1]);
1804         }
1805       }
1806       
1807     }
1808
1809      
1810   }//end loop over tracks
1811
1812   //delete esdTrackCuts; esdTrackCuts=NULL;
1813   //delete primaryVtx; primaryVtx=NULL;
1814   delete vtxVSkip; vtxVSkip=NULL;
1815   delete vtxVRec;  vtxVRec=NULL;
1816   delete vtxESDTrue; vtxESDTrue=NULL;
1817   PostData(1, fOutputitspureSARec);
1818   PostData(2, fOutputitspureSASkip);
1819   PostData(3, fOutputallPointRec);
1820   PostData(4, fOutputallPointSkip);
1821   PostData(5, fOutputpartPointRec);
1822   PostData(6, fOutputpartPointSkip);
1823   PostData(7, fOutputonepointSPDRec);
1824   PostData(8, fOutputonepointSPDSkip);
1825   PostData(9, fOutputpostvTracRec);
1826   PostData(10, fOutputpostvTracSkip);
1827   PostData(11, fOutputnegtvTracRec);
1828   PostData(12, fOutputnegtvTracSkip);
1829   PostData(13, fOutputpullAllpointRec);
1830   PostData(14, fOutputpullAllpointSkip);
1831   PostData(15, fOutputOnlyRefitRec);
1832   PostData(16, fOutputOnlyRefitSkip);
1833   PostData(17, fOutputSinThetaRec);
1834   PostData(18, fOutputSinThetaSkip);
1835   PostData(19, fOutputallPointTrue);
1836   PostData(20, fOutputpostvTracTrue);
1837   PostData(21, fOutputnegtvTracTrue);
1838   PostData(22, fOutputpullAllpointTrue);
1839   PostData(23, fOutputphiAllpointSkip);
1840   PostData(24, fOutputphiPostvtracSkip);
1841   PostData(25, fOutputphiNegtvtracSkip);
1842   PostData(26, fOutputparticlePID);
1843   PostData(27, fOutputPt);
1844   PostData(28, fNentries);
1845   PostData(29, fEstimVtx); 
1846   PostData(30, fOutputWithTrackCuts);
1847
1848   return;
1849 }
1850
1851 //________________________________________________________________________
1852 Int_t AliAnalysisTaskSEImpParRes::PtBin(Double_t pt) const {
1853   //
1854   // return the number of the pt bin
1855   //
1856
1857   if (pt>0.22 && pt<0.23) return 1;
1858   if (pt>0.26 && pt<0.27) return 2; 
1859   if (pt>0.345 && pt<0.355) return 3;
1860   if (pt>0.45 && pt<0.46) return 4; 
1861   if (pt>0.55 && pt<0.56) return 5;
1862   if (pt>0.65 && pt<0.66) return 6; 
1863   if (pt>0.75 && pt<0.76) return 7; 
1864   if (pt>0.85 && pt<0.865) return 8; 
1865   if (pt>1.05 && pt<1.07) return 9;
1866   if (pt>1.25 && pt<1.30) return 10; 
1867   if (pt>1.4 && pt<1.55) return 11; 
1868   if (pt>1.6 && pt<1.8) return 12; 
1869   if (pt>1.8 && pt<2.0) return 13; 
1870   if (pt>2.1 && pt<2.3) return 14; 
1871   if (pt>2.34 && pt<2.64) return 15; 
1872   if (pt>2.65 && pt<3.0) return 16; 
1873   if (pt>3.1 && pt<4.) return 17; 
1874   if (pt>4.1 && pt<5.2) return 18; 
1875   if (pt>5.3 && pt<6.8)  return 19; 
1876   if (pt>7.0 && pt<8.8) return 20; 
1877   if (pt>9. && pt<11.) return 21;
1878   if (pt>11.1 && pt<14.) return 22; 
1879   if (pt>14.1  && pt<17.)  return 23;
1880   if (pt>17.2  && pt<21.8) return 24; 
1881   if (pt>22.1  && pt<29.)  return 25;
1882   if (pt>29.05  && pt<35.)  return 26;
1883   /*
1884     if (pt>0.22 && pt<0.23) return 1 ;
1885     if (pt>0.26 && pt<0.27) return 2 ; 
1886     if (pt>0.35 && pt<0.36) return 3 ;
1887     if (pt>0.45 && pt<0.46) return 4 ; 
1888     if (pt>0.55 && pt<0.56) return 5 ;
1889     if (pt>0.65 && pt<0.66) return 6 ; 
1890     if (pt>0.75 && pt<0.76) return 7 ; 
1891     if (pt>0.85 && pt<0.86) return 8 ; 
1892     if (pt>1.05 && pt<1.06) return 9 ;
1893     if (pt>1.25 && pt<1.27) return 10; 
1894     if (pt>1.45 && pt<1.47) return 11; 
1895     if (pt>1.65 && pt<1.67) return 12; 
1896     if (pt>1.85 && pt<1.87) return 13; 
1897     if (pt>2.15 && pt<2.17) return 14; 
1898     if (pt>2.45 && pt<2.48) return 15; 
1899     if (pt>2.65 && pt<2.67) return 16; 
1900     if (pt>2.85 && pt<2.87) return 17; 
1901     if (pt>3.25 && pt<3.27) return 18; 
1902     if (pt>3.75 && pt<3.8)  return 19; 
1903     if (pt>4.15 && pt<4.20) return 20; 
1904     if (pt>4.95 && pt<5.15) return 21;
1905     if (pt>5.35 && pt<5.55) return 22; 
1906     if (pt>6.0  && pt<6.8)  return 23;
1907     if (pt>8.5  && pt<10.5) return 24; 
1908     if (pt>12.  && pt<19.)  return 25;
1909     if (pt>21.  && pt<32.)  return 26;
1910   */  
1911   return -1; 
1912 }
1913
1914 //________________________________________________________________________
1915 Double_t AliAnalysisTaskSEImpParRes::Getd0HistRange(Int_t i) const {
1916   //
1917   // Return the range of the d0 histograms for each pt bin
1918   //
1919   if (i==1) return  2500.; 
1920   if (i==2) return  1800.;
1921   if (i==3) return  1750.;
1922   if (i==4) return  1200.;
1923   if (i==5) return  1000.;
1924   if (i==6) return  900.;
1925   if (i==7) return  850.;
1926   if (i==8) return  700.;
1927   if (i==9) return  650.;
1928   if (i==10) return 600.;
1929   if (i==11) return 550.;
1930   if (i==12) return 500.;
1931   if (i==13) return 450.;
1932   if (i==14) return 400.;
1933   if (i==15) return 390.;
1934   if (i==16) return 380.;
1935   if (i==17) return 380.;
1936   if (i==18) return 350.;
1937   if (i==19) return 320.;
1938   if (i==20) return 300.;
1939   if (i==21) return 290.;
1940   if (i==22) return 270.;
1941   if (i==23) return 250.;
1942   if (i==24) return 270.;
1943   if (i==25) return 279.;
1944   if (i==26) return 270.;
1945
1946   return 2000.;
1947 }
1948
1949 //________________________________________________________________________
1950 Int_t AliAnalysisTaskSEImpParRes::SinThetaBin(Double_t sintheta) const {  
1951   //
1952   // Return the number of the sinTheta bin
1953   // 
1954   if(sintheta>0.7 && sintheta<0.73) return 1;
1955   if(sintheta>0.73 && sintheta<0.76) return 2; 
1956   if(sintheta>0.76 && sintheta<0.79) return 3; 
1957   if(sintheta>0.79 && sintheta<0.82) return 4;
1958   if(sintheta>0.82 && sintheta<0.85) return 5;       
1959   if(sintheta>0.85 && sintheta<0.88) return 6; 
1960   if(sintheta>0.88 && sintheta<0.91) return 7;
1961   if(sintheta>0.91 && sintheta<0.94) return 8;       
1962   if(sintheta>0.94 && sintheta<0.97) return 9; 
1963   if(sintheta>0.97 && sintheta<1.0) return 10;  
1964   return -1;
1965 }
1966
1967 //___________________________________________________________________________
1968 Int_t AliAnalysisTaskSEImpParRes::PhiBin(Double_t phi) const { 
1969   Double_t pi=TMath::Pi();
1970   if(phi>2.*pi || phi<0.) return -1;
1971   if(phi<0.1*pi) return 1;
1972   if(phi<0.2*pi) return 2;
1973   if(phi<0.3*pi) return 3;
1974   if(phi<0.4*pi) return 4;
1975   if(phi<0.5*pi) return 5;
1976   if(phi<0.6*pi) return 6;
1977   if(phi<0.7*pi) return 7;
1978   if(phi<0.8*pi) return 8;
1979   if(phi<0.9*pi) return 9;
1980   if(phi<1.0*pi) return 10;
1981   if(phi<1.1*pi) return 11;
1982   if(phi<1.2*pi) return 12;
1983   if(phi<1.3*pi) return 13;
1984   if(phi<1.4*pi) return 14;
1985   if(phi<1.5*pi) return 15;
1986   if(phi<1.6*pi) return 16;
1987   if(phi<1.7*pi) return 17;
1988   if(phi<1.8*pi) return 18;
1989   if(phi<1.9*pi) return 19;
1990   if(phi<2.0*pi) return 20;
1991   return -1;
1992 }
1993 //___________________________________________________________________________
1994 void AliAnalysisTaskSEImpParRes::Terminate(Option_t */*option*/) {
1995   //
1996   // Terminate analysis
1997   //
1998
1999   if (fDebug>1) printf("AnalysisTaskSEImpParRes: Terminate() \n");
2000
2001   return;
2002 }
2003 //__________________________________________________________________________
2004 Int_t AliAnalysisTaskSEImpParRes::ClusterTypeOnITSLayer(AliESDtrack *track,
2005                                                         Int_t layer) const {
2006   //
2007   // Returns cluster type on ITS layer. Returns -1 if no cluster on this layer
2008   //
2009   Int_t ctype=-1;
2010
2011   if(layer<0 || layer>5) return ctype;
2012   if(!track->HasPointOnITSLayer(layer)) return ctype;
2013   
2014   const AliTrackPointArray *array = track->GetTrackPointArray();
2015   if(!array) {
2016     //    printf("No tracks points avaialble: check ESDfriends\n");
2017     return ctype;
2018   }
2019   AliTrackPoint point;
2020   Int_t ipt,volId,modId,layerId;
2021   for(ipt=0; ipt<array->GetNPoints(); ipt++) {
2022     array->GetPoint(point,ipt);
2023     volId = point.GetVolumeID();
2024     if(volId<=0) continue;
2025     layerId = AliGeomManager::VolUIDToLayer(volId,modId);
2026     if(layerId==layer+1 && !point.IsExtra()) {
2027       ctype = point.GetClusterType();
2028       break;
2029     }
2030   }
2031   return ctype;
2032 }
2033 //---------------------------------------------------------------------------
2034 Bool_t AliAnalysisTaskSEImpParRes::IsSelectedCentrality(AliESDEvent *esd) const
2035 {
2036   //
2037   // check if events is in the required multiplicity range
2038   //
2039
2040   const AliMultiplicity *alimult = esd->GetMultiplicity();
2041   Int_t ntrklets=1;
2042   Int_t nclsSPDouter=0;
2043   if(alimult) {
2044     ntrklets = alimult->GetNumberOfTracklets();
2045     nclsSPDouter = alimult->GetNumberOfITSClusters(1);
2046   }
2047
2048   if(nclsSPDouter<fMinMult || nclsSPDouter>fMaxMult) return kFALSE;
2049
2050
2051   return kTRUE;
2052 }
2053
2054 //----------------------------------------------------------------------------------
2055 Bool_t AliAnalysisTaskSEImpParRes::IsTrackSelected(AliVTrack *track, AliVVertex *primary, AliESDtrackCuts *cuts) const{
2056
2057   if(!cuts) return kTRUE;
2058   Bool_t retval = kTRUE;
2059   if(fIsAOD) {
2060     AliESDtrack esdTrack(track);
2061     esdTrack.SetTPCClusterMap(((AliAODTrack*)track)->GetTPCClusterMap());
2062     esdTrack.SetTPCSharedMap(((AliAODTrack*)track)->GetTPCSharedMap());
2063     esdTrack.SetTPCPointsF(((AliAODTrack*)track)->GetTPCNclsF());
2064     esdTrack.RelateToVertex((AliESDVertex*)primary,0.,3.);
2065     if(!cuts->IsSelected(&esdTrack)) retval = kFALSE;
2066   }
2067   else {
2068     AliESDtrack *esdTrack = (AliESDtrack*)track;
2069     if(!cuts->IsSelected(esdTrack)) retval = kFALSE;
2070   }
2071   return retval;
2072 }