8a133a8e10689a08ce0a8fbb5596abae338b085d
[u/mrichter/AliRoot.git] / PWG1 / ITS / AliAnalysisTaskITSTrackingCheck.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 // AliAnalysisTask to extract from ESD tracks the information
19 // on ITS tracking efficiency and resolutions.
20 //
21 // Author: A.Dainese, andrea.dainese@pd.infn.it
22 /////////////////////////////////////////////////////////////
23
24 #include <TStyle.h>
25 #include <TChain.h>
26 #include <TTree.h>
27 #include <TNtuple.h>
28 #include <TBranch.h>
29 #include <TClonesArray.h>
30 #include <TObjArray.h>
31 #include <TH1F.h>
32 #include <TH2F.h>  
33 #include <TCanvas.h>
34 #include <TParticle.h>
35
36 #include "AliAnalysisTask.h"
37 #include "AliAnalysisManager.h"
38
39 #include "AliMultiplicity.h"
40 #include "AliVertexerTracks.h"
41 #include "AliESDtrack.h"
42 #include "AliExternalTrackParam.h"
43 #include "AliESDVertex.h"
44 #include "AliESDEvent.h"
45 #include "AliESDfriend.h"
46 #include "AliESDInputHandler.h"
47 #include "AliESDInputHandlerRP.h"
48 #include "AliESDtrackCuts.h"
49 #include "AliTrackPointArray.h"
50 #include "../ITS/AliITSRecPoint.h"
51
52 #include "AliInputEventHandler.h"
53 #include "AliMCEventHandler.h"
54 #include "AliMCEvent.h"
55 #include "AliStack.h"
56 #include "AliLog.h"
57
58 #include "AliGenEventHeader.h" 
59 #include "AliAnalysisTaskITSTrackingCheck.h"
60
61
62 ClassImp(AliAnalysisTaskITSTrackingCheck)
63 AliAnalysisTaskITSTrackingCheck::AliAnalysisTaskITSTrackingCheck() : 
64 AliAnalysisTaskSE(), 
65 fReadMC(kFALSE),
66 fReadRPLabels(kFALSE),
67 fFillNtuples(kFALSE),
68 fUseITSSAforNtuples(kFALSE),
69 fUsePhysSel(kFALSE),
70 fESD(0), 
71 fOutput(0), 
72 fHistNEvents(0),
73 fHistNEventsFrac(0),
74 fHistNtracks(0),
75 fHistNclsITSMI(0),
76 fHistNclsITSSA(0),
77 fHistNclsITSSAInAcc(0),
78 fHistClusterMapITSMI(0),
79 fHistClusterMapITSMIok(0),
80 fHistClusterMapITSMIbad(0),
81 fHistClusterMapITSMIskipped(0),
82 fHistClusterMapITSMIoutinz(0),
83 fHistClusterMapITSMInorefit(0),
84 fHistClusterMapITSMInocls(0),
85 fHistClusterMapITSMIokoutinzbad(0),
86 fHistClusterMapITSSA(0),
87 fHistClusterMapITSSAok(0),
88 fHistClusterMapITSSAbad(0),
89 fHistClusterMapITSSAskipped(0),
90 fHistClusterMapITSSAoutinz(0),
91 fHistClusterMapITSSAnorefit(0),
92 fHistClusterMapITSSAnocls(0),
93 fHistClusterMapITSSAokoutinzbad(0),
94 fHistClusterMapITSSAInAcc(0),
95 fHistClusterMapITSSAokInAcc(0),
96 fHistClusterMapITSSAbadInAcc(0),
97 fHistClusterMapITSSAskippedInAcc(0),
98 fHistClusterMapITSSAoutinzInAcc(0),
99 fHistClusterMapITSSAnorefitInAcc(0),
100 fHistClusterMapITSSAnoclsInAcc(0),
101 fHistClusterMapITSSAokoutinzbadInAcc(0),
102 fHistClusterMapModuleITSSAokInAcc(0),
103 fHistClusterMapModuleITSSAbadInAcc(0),
104 fHistClusterMapModuleITSSAnoclsInAcc(0),
105 fHistClusterMapModuleITSMIokInAcc(0),
106 fHistClusterMapModuleITSMIbadInAcc(0),
107 fHistClusterMapModuleITSMInoclsInAcc(0),
108 fHistZatSPDouter0ok(0),
109 fHistZatSPDouter1ok(0),
110 fHistZatSPDouter2ok(0),
111 fHistZatSPDouter3ok(0),
112 fHistZatSPDouter0notok(0),
113 fHistZatSPDouter1notok(0),
114 fHistZatSPDouter2notok(0),
115 fHistZatSPDouter3notok(0),
116 fHistxlocSDDok(0),
117 fHistzlocSDDok(0),
118 fHistxlocVSmodSDDok(0),
119 fHistxlocSDDall(0),
120 fHistzlocSDDall(0),
121 fHistPhiTPCInAcc(0),
122 fHistPtTPC(0),
123 fHistPtTPCInAcc(0),
124 fHistPtTPCInAccMCtwoSPD(0),
125 fHistPtTPCInAccMConeSPD(0),
126 fHistdEdxVSPtTPCInAcc(0),
127 fHistdEdxVSPtITSTPCsel(0),
128 fHistPtVSphiTPCInAcc(0),
129 fHistPtTPCInAccNoTRDout(0),
130 fHistPtTPCInAccNoTOFout(0),
131 fHistPtTPCInAccWithPtTPCAtInnerWall(0),
132 fHistPtTPCInAccWithPtTPCAtVtx(0),
133 fHistDeltaPtTPC(0),
134 fHistPtTPCInAccP(0),
135 fHistPtTPCInAccS(0),
136 fHistPtTPCInAccPfromStrange(0),
137 fHistPtTPCInAccSfromStrange(0),
138 fHistPtTPCInAccSfromMat(0),
139 fHistPtITSMI2(0),
140 fHistPtITSMI3(0),
141 fHistPtITSMI4(0),
142 fHistPtITSMI5(0),
143 fHistPtITSMI6(0),
144 fHistPtITSMISPD(0),
145 fHistPtITSMIoneSPD(0),
146 fHistPtITSMI2InAcc(0),
147 fHistPtITSMI3InAcc(0),
148 fHistPtITSMI4InAcc(0),
149 fHistPtITSMI5InAcc(0),
150 fHistPtITSMI6InAcc(0),
151 fHistPtITSMISPDInAcc(0),
152 fHistPtITSMIoneSPDInAcc(0),
153 fHistPtITSMIoneSPDthreeSDDSSDInAcc(0),
154 fHistPtITSTPCsel(0),
155 fHistPtITSTPCselP(0),
156 fHistPtITSTPCselS(0),
157 fHistPtITSTPCselPfromStrange(0),
158 fHistPtITSTPCselSfromStrange(0),
159 fHistPtITSTPCselSfromMat(0),
160 fHistPtITSMI2InAccP(0),
161 fHistPtITSMI3InAccP(0),
162 fHistPtITSMI4InAccP(0),
163 fHistPtITSMI5InAccP(0),
164 fHistPtITSMI6InAccP(0),
165 fHistPtITSMISPDInAccP(0),
166 fHistPtITSMIoneSPDInAccP(0),
167 fHistPtITSMI2InAccS(0),
168 fHistPtITSMI3InAccS(0),
169 fHistPtITSMI4InAccS(0),
170 fHistPtITSMI5InAccS(0),
171 fHistPtITSMI6InAccS(0),
172 fHistPtITSMISPDInAccS(0),
173 fHistPtITSMIoneSPDInAccS(0),
174 fHistPtITSMIokbadoutinz6(0),
175 fHistPtITSMIokbadoutinz4InAcc(0),
176 fHistPtITSMIokbadoutinz5InAcc(0),
177 fHistPtITSMIokbadoutinz6InAcc(0),
178 fHistPhiITSMIokbadoutinz6InAcc(0),
179 fHistRProdVtxInAccP(0),
180 fHistRProdVtxInAccS(0),
181 fHistd0rphiTPCInAccP150200(0),
182 fHistd0rphiTPCInAccP500700(0),
183 fHistd0rphiTPCInAccP10001500(0),
184 fHistd0rphiTPCInAccS150200(0),
185 fHistd0rphiTPCInAccS500700(0),
186 fHistd0rphiTPCInAccS10001500(0),
187 fHistd0rphiITSMISPDInAccP150200(0),
188 fHistd0rphiITSMISPDInAccP500700(0),
189 fHistd0rphiITSMISPDInAccP10001500(0),
190 fHistd0rphiITSMISPDInAccS150200(0),
191 fHistd0rphiITSMISPDInAccS500700(0),
192 fHistd0rphiITSMISPDInAccS10001500(0),
193 fHistd0rphiITSMIoneSPDInAccP150200(0),
194 fHistd0rphiITSMIoneSPDInAccP350450(0),
195 fHistd0rphiITSMIoneSPDInAccP500700(0),
196 fHistd0rphiITSMIoneSPDInAccP10001500(0),
197 fHistd0rphiITSMIoneSPDInAccP25004000(0),
198 fHistd0rphiITSMIoneSPDInAccP40008000(0),
199 fHistd0zITSMIoneSPDInAccP150200(0),
200 fHistd0zITSMIoneSPDInAccP500700(0),
201 fHistd0zITSMIoneSPDInAccP10001500(0),
202 fHistd0zVSetaTPCInAccP10001500(0),
203 fHistd0rphiVSphiITSMIoneSPDInAccP10001500(0),
204 fHistd0rphiVSetaITSMIoneSPDInAccP10001500(0),
205 fHistd0rphiITSMIoneSPDInAccS150200(0),
206 fHistd0rphiITSMIoneSPDInAccS350450(0),
207 fHistd0rphiITSMIoneSPDInAccS500700(0),
208 fHistd0rphiITSMIoneSPDInAccS500700from22(0),
209 fHistd0rphiITSMIoneSPDInAccS500700from211(0),
210 fHistd0rphiITSMIoneSPDInAccS500700from310(0),
211 fHistd0rphiITSMIoneSPDInAccS500700from321(0),
212 fHistd0rphiITSMIoneSPDInAccS500700from3122(0),
213 fHistd0rphiITSMIoneSPDInAccS10001500(0),
214 fHistd0rphiITSMIoneSPDInAccS25004000(0),
215 fHistd0rphiITSMIoneSPDInAccS40008000(0),
216 fHistd0rphiITSMIoneSPDInAccS150200fromStrange(0),
217 fHistd0rphiITSMIoneSPDInAccS150200fromMat(0),
218 fHistd0rphiITSMIoneSPDInAccS350450fromStrange(0),
219 fHistd0rphiITSMIoneSPDInAccS350450fromMat(0),
220 fHistd0rphiITSMIoneSPDInAccS500700fromStrange(0),
221 fHistd0rphiITSMIoneSPDInAccS500700fromMat(0),
222 fHistd0rphiITSMIoneSPDInAccS10001500fromStrange(0),
223 fHistd0rphiITSMIoneSPDInAccS10001500fromMat(0),
224 fHistd0rphiITSMIoneSPDInAccS25004000fromStrange(0),
225 fHistd0rphiITSMIoneSPDInAccS25004000fromMat(0),
226 fHistd0rphiITSMIoneSPDInAccS40008000fromStrange(0),
227 fHistd0rphiITSMIoneSPDInAccS40008000fromMat(0),
228 fHistd0zITSMIoneSPDInAccS150200(0),
229 fHistd0zITSMIoneSPDInAccS500700(0),
230 fHistd0zITSMIoneSPDInAccS10001500(0),
231 fHistPDGMoth(0),
232 fHistPDGMoth150200(0),
233 fHistPDGMoth500700(0),
234 fHistPDGMoth10001500(0),
235 fHistPDGTrk(0),
236 fNtupleESDTracks(0),
237 fNtupleITSAlignExtra(0),
238 fNtupleITSAlignSPDTracklets(0),
239 fESDtrackCutsTPC(0),
240 fESDtrackCutsITSTPC(0)
241 {
242   // Constructor
243 }
244
245 //________________________________________________________________________
246 AliAnalysisTaskITSTrackingCheck::AliAnalysisTaskITSTrackingCheck(const char *name) : 
247 AliAnalysisTaskSE(name), 
248 fReadMC(kFALSE),
249 fReadRPLabels(kFALSE),
250 fFillNtuples(kFALSE),
251 fUseITSSAforNtuples(kFALSE),
252 fUsePhysSel(kFALSE),
253 fESD(0), 
254 fOutput(0), 
255 fHistNEvents(0),
256 fHistNEventsFrac(0),
257 fHistNtracks(0),
258 fHistNclsITSMI(0),
259 fHistNclsITSSA(0),
260 fHistNclsITSSAInAcc(0),
261 fHistClusterMapITSMI(0),
262 fHistClusterMapITSMIok(0),
263 fHistClusterMapITSMIbad(0),
264 fHistClusterMapITSMIskipped(0),
265 fHistClusterMapITSMIoutinz(0),
266 fHistClusterMapITSMInorefit(0),
267 fHistClusterMapITSMInocls(0),
268 fHistClusterMapITSMIokoutinzbad(0),
269 fHistClusterMapITSSA(0),
270 fHistClusterMapITSSAok(0),
271 fHistClusterMapITSSAbad(0),
272 fHistClusterMapITSSAskipped(0),
273 fHistClusterMapITSSAoutinz(0),
274 fHistClusterMapITSSAnorefit(0),
275 fHistClusterMapITSSAnocls(0),
276 fHistClusterMapITSSAokoutinzbad(0),
277 fHistClusterMapITSSAInAcc(0),
278 fHistClusterMapITSSAokInAcc(0),
279 fHistClusterMapITSSAbadInAcc(0),
280 fHistClusterMapITSSAskippedInAcc(0),
281 fHistClusterMapITSSAoutinzInAcc(0),
282 fHistClusterMapITSSAnorefitInAcc(0),
283 fHistClusterMapITSSAnoclsInAcc(0),
284 fHistClusterMapITSSAokoutinzbadInAcc(0),
285 fHistClusterMapModuleITSSAokInAcc(0),
286 fHistClusterMapModuleITSSAbadInAcc(0),
287 fHistClusterMapModuleITSSAnoclsInAcc(0),
288 fHistClusterMapModuleITSMIokInAcc(0),
289 fHistClusterMapModuleITSMIbadInAcc(0),
290 fHistClusterMapModuleITSMInoclsInAcc(0),
291 fHistZatSPDouter0ok(0),
292 fHistZatSPDouter1ok(0),
293 fHistZatSPDouter2ok(0),
294 fHistZatSPDouter3ok(0),
295 fHistZatSPDouter0notok(0),
296 fHistZatSPDouter1notok(0),
297 fHistZatSPDouter2notok(0),
298 fHistZatSPDouter3notok(0),
299 fHistxlocSDDok(0),
300 fHistzlocSDDok(0),
301 fHistxlocVSmodSDDok(0),
302 fHistxlocSDDall(0),
303 fHistzlocSDDall(0),
304 fHistPhiTPCInAcc(0),
305 fHistPtTPC(0),
306 fHistPtTPCInAcc(0),
307 fHistPtTPCInAccMCtwoSPD(0),
308 fHistPtTPCInAccMConeSPD(0),
309 fHistdEdxVSPtTPCInAcc(0),
310 fHistdEdxVSPtITSTPCsel(0),
311 fHistPtVSphiTPCInAcc(0),
312 fHistPtTPCInAccNoTRDout(0),
313 fHistPtTPCInAccNoTOFout(0),
314 fHistPtTPCInAccWithPtTPCAtInnerWall(0),
315 fHistPtTPCInAccWithPtTPCAtVtx(0),
316 fHistDeltaPtTPC(0),
317 fHistPtTPCInAccP(0),
318 fHistPtTPCInAccS(0),
319 fHistPtTPCInAccPfromStrange(0),
320 fHistPtTPCInAccSfromStrange(0),
321 fHistPtTPCInAccSfromMat(0),
322 fHistPtITSMI2(0),
323 fHistPtITSMI3(0),
324 fHistPtITSMI4(0),
325 fHistPtITSMI5(0),
326 fHistPtITSMI6(0),
327 fHistPtITSMISPD(0),
328 fHistPtITSMIoneSPD(0),
329 fHistPtITSMI2InAcc(0),
330 fHistPtITSMI3InAcc(0),
331 fHistPtITSMI4InAcc(0),
332 fHistPtITSMI5InAcc(0),
333 fHistPtITSMI6InAcc(0),
334 fHistPtITSMISPDInAcc(0),
335 fHistPtITSMIoneSPDInAcc(0),
336 fHistPtITSMIoneSPDthreeSDDSSDInAcc(0),
337 fHistPtITSTPCsel(0),
338 fHistPtITSTPCselP(0),
339 fHistPtITSTPCselS(0),
340 fHistPtITSTPCselPfromStrange(0),
341 fHistPtITSTPCselSfromStrange(0),
342 fHistPtITSTPCselSfromMat(0),
343 fHistPtITSMI2InAccP(0),
344 fHistPtITSMI3InAccP(0),
345 fHistPtITSMI4InAccP(0),
346 fHistPtITSMI5InAccP(0),
347 fHistPtITSMI6InAccP(0),
348 fHistPtITSMISPDInAccP(0),
349 fHistPtITSMIoneSPDInAccP(0),
350 fHistPtITSMI2InAccS(0),
351 fHistPtITSMI3InAccS(0),
352 fHistPtITSMI4InAccS(0),
353 fHistPtITSMI5InAccS(0),
354 fHistPtITSMI6InAccS(0),
355 fHistPtITSMISPDInAccS(0),
356 fHistPtITSMIoneSPDInAccS(0),
357 fHistPtITSMIokbadoutinz6(0),
358 fHistPtITSMIokbadoutinz4InAcc(0),
359 fHistPtITSMIokbadoutinz5InAcc(0),
360 fHistPtITSMIokbadoutinz6InAcc(0),
361 fHistPhiITSMIokbadoutinz6InAcc(0),
362 fHistRProdVtxInAccP(0),
363 fHistRProdVtxInAccS(0),
364 fHistd0rphiTPCInAccP150200(0),
365 fHistd0rphiTPCInAccP500700(0),
366 fHistd0rphiTPCInAccP10001500(0),
367 fHistd0rphiTPCInAccS150200(0),
368 fHistd0rphiTPCInAccS500700(0),
369 fHistd0rphiTPCInAccS10001500(0),
370 fHistd0rphiITSMISPDInAccP150200(0),
371 fHistd0rphiITSMISPDInAccP500700(0),
372 fHistd0rphiITSMISPDInAccP10001500(0),
373 fHistd0rphiITSMISPDInAccS150200(0),
374 fHistd0rphiITSMISPDInAccS500700(0),
375 fHistd0rphiITSMISPDInAccS10001500(0),
376 fHistd0rphiITSMIoneSPDInAccP150200(0),
377 fHistd0rphiITSMIoneSPDInAccP350450(0),
378 fHistd0rphiITSMIoneSPDInAccP500700(0),
379 fHistd0rphiITSMIoneSPDInAccP10001500(0),
380 fHistd0rphiITSMIoneSPDInAccP25004000(0),
381 fHistd0rphiITSMIoneSPDInAccP40008000(0),
382 fHistd0zITSMIoneSPDInAccP150200(0),
383 fHistd0zITSMIoneSPDInAccP500700(0),
384 fHistd0zITSMIoneSPDInAccP10001500(0),
385 fHistd0zVSetaTPCInAccP10001500(0),
386 fHistd0rphiVSphiITSMIoneSPDInAccP10001500(0),
387 fHistd0rphiVSetaITSMIoneSPDInAccP10001500(0),
388 fHistd0rphiITSMIoneSPDInAccS150200(0),
389 fHistd0rphiITSMIoneSPDInAccS350450(0),
390 fHistd0rphiITSMIoneSPDInAccS500700(0),
391 fHistd0rphiITSMIoneSPDInAccS500700from22(0),
392 fHistd0rphiITSMIoneSPDInAccS500700from211(0),
393 fHistd0rphiITSMIoneSPDInAccS500700from310(0),
394 fHistd0rphiITSMIoneSPDInAccS500700from321(0),
395 fHistd0rphiITSMIoneSPDInAccS500700from3122(0),
396 fHistd0rphiITSMIoneSPDInAccS10001500(0),
397 fHistd0rphiITSMIoneSPDInAccS25004000(0),
398 fHistd0rphiITSMIoneSPDInAccS40008000(0),
399 fHistd0rphiITSMIoneSPDInAccS150200fromStrange(0),
400 fHistd0rphiITSMIoneSPDInAccS150200fromMat(0),
401 fHistd0rphiITSMIoneSPDInAccS350450fromStrange(0),
402 fHistd0rphiITSMIoneSPDInAccS350450fromMat(0),
403 fHistd0rphiITSMIoneSPDInAccS500700fromStrange(0),
404 fHistd0rphiITSMIoneSPDInAccS500700fromMat(0),
405 fHistd0rphiITSMIoneSPDInAccS10001500fromStrange(0),
406 fHistd0rphiITSMIoneSPDInAccS10001500fromMat(0),
407 fHistd0rphiITSMIoneSPDInAccS25004000fromStrange(0),
408 fHistd0rphiITSMIoneSPDInAccS25004000fromMat(0),
409 fHistd0rphiITSMIoneSPDInAccS40008000fromStrange(0),
410 fHistd0rphiITSMIoneSPDInAccS40008000fromMat(0),
411 fHistd0zITSMIoneSPDInAccS150200(0),
412 fHistd0zITSMIoneSPDInAccS500700(0),
413 fHistd0zITSMIoneSPDInAccS10001500(0),
414 fHistPDGMoth(0),
415 fHistPDGMoth150200(0),
416 fHistPDGMoth500700(0),
417 fHistPDGMoth10001500(0),
418 fHistPDGTrk(0),
419 fNtupleESDTracks(0),
420 fNtupleITSAlignExtra(0),
421 fNtupleITSAlignSPDTracklets(0),
422 fESDtrackCutsTPC(0),
423 fESDtrackCutsITSTPC(0)
424 {
425   // Constructor
426
427   for(Int_t i=0; i<11; i++) fCountsPerPtBin[i]=0;
428
429   // Define input and output slots here
430   // Output slot #0 writes into a TList container
431   DefineOutput(1, TList::Class());  //My private output
432 }
433 //________________________________________________________________________
434 AliAnalysisTaskITSTrackingCheck::~AliAnalysisTaskITSTrackingCheck()
435 {
436   // Destructor
437
438   // histograms are in the output list and deleted when the output
439   // list is deleted by the TSelector dtor
440
441   if (fOutput) {
442     delete fOutput;
443     fOutput = 0;
444   }
445 }
446 //________________________________________________________________________
447 void AliAnalysisTaskITSTrackingCheck::UserCreateOutputObjects()
448 {
449   // Create histograms
450   // Called once
451
452   gStyle->SetHistLineWidth(2);
453
454   Int_t nPtBins=34;
455   Float_t xPtBins[35]={0,0.025,0.05,0.075,0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.325,0.35,0.375,0.4,0.5,0.6,0.7,0.8,1.0,1.5,2.,2.5,3,4,5,6,8,10,15,20,25,30};
456
457   for(Int_t i=0; i<11; i++) fCountsPerPtBin[i]=0;
458
459   // Several histograms are more conveniently managed in a TList
460   fOutput = new TList;
461   fOutput->SetOwner();
462
463   fHistPDGMoth = new TH1F("fHistPDGMoth","",4000,0,4000);
464   fOutput->Add(fHistPDGMoth);
465   fHistPDGMoth150200 = new TH1F("fHistPDGMoth150200","",4000,0,4000);
466   fOutput->Add(fHistPDGMoth150200);
467   fHistPDGMoth500700 = new TH1F("fHistPDGMoth500700","",4000,0,4000);
468   fOutput->Add(fHistPDGMoth500700);
469   fHistPDGMoth10001500 = new TH1F("fHistPDGMoth10001500","",4000,0,4000);
470   fOutput->Add(fHistPDGMoth10001500);
471   fHistPDGTrk = new TH1F("fHistPDGTrk","",4000,0,4000);
472   fOutput->Add(fHistPDGTrk);
473
474   fHistNEvents = new TH1F("fHistNEvents", "Events: -1 tot, 0 sel, 1 vSPD3D, 2 vSPDZ, 3 vSPD, 4 vTRK; Type; N Events",12, -1.5, 10.5);
475   fHistNEvents->SetMinimum(0);
476   fOutput->Add(fHistNEvents);
477
478   fHistNEventsFrac = (TH1F*)fHistNEvents->Clone("fHistNEventsFrac");
479   fOutput->Add(fHistNEventsFrac);
480
481   fHistNtracks = new TH1F("fHistNtracks", "N ESD tracks; N tracks; Events",5000, -0.5, 4999.5);
482   fHistNtracks->Sumw2();
483   fHistNtracks->SetMinimum(0);
484   fOutput->Add(fHistNtracks);
485
486   fHistNclsITSMI = new TH1F("fHistNclsITSMI", "N ITS clusters per track (MI); N clusters; Counts",7, -0.5, 6.5);
487   fHistNclsITSMI->Sumw2();
488   fHistNclsITSMI->SetMinimum(0);
489   fOutput->Add(fHistNclsITSMI);
490
491   fHistNclsITSSAInAcc = new TH1F("fHistNclsITSSAInAcc", "N ITS clusters per track (SA); N clusters; Counts",7, -0.5, 6.5);
492   fHistNclsITSSAInAcc->Sumw2();
493   fHistNclsITSSAInAcc->SetMinimum(0);
494   fOutput->Add(fHistNclsITSSAInAcc);  
495
496   fHistNclsITSSA = new TH1F("fHistNclsITSSA", "N ITS clusters per track (SA); N clusters; Counts",7, -0.5, 6.5);
497   fHistNclsITSSA->Sumw2();
498   fHistNclsITSSA->SetMinimum(0);
499   fOutput->Add(fHistNclsITSSA);  
500
501   fHistClusterMapITSMI = new TH1F("fHistClusterMapITSMI", "N tracks with point on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
502   fHistClusterMapITSMI->Sumw2();
503   fHistClusterMapITSMI->SetMinimum(0);
504   fOutput->Add(fHistClusterMapITSMI);
505   
506   fHistClusterMapITSSA = new TH1F("fHistClusterMapITSSA", "N tracks with point on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
507   fHistClusterMapITSSA->Sumw2();
508   fHistClusterMapITSSA->SetMinimum(0);
509   fOutput->Add(fHistClusterMapITSSA);
510
511   fHistClusterMapITSSAInAcc = new TH1F("fHistClusterMapITSSAInAcc", "N tracks with point on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
512   fHistClusterMapITSSAInAcc->Sumw2();
513   fHistClusterMapITSSAInAcc->SetMinimum(0);
514   fOutput->Add(fHistClusterMapITSSAInAcc);
515
516   fHistClusterMapITSMIok = new TH1F("fHistClusterMapITSMIok", "N tracks with ok on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
517   fHistClusterMapITSMIok->Sumw2();
518   fHistClusterMapITSMIok->SetMinimum(0);
519   fOutput->Add(fHistClusterMapITSMIok);
520   
521   fHistClusterMapITSSAokInAcc = new TH1F("fHistClusterMapITSSAokInAcc", "N tracks with ok on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
522   fHistClusterMapITSSAokInAcc->Sumw2();
523   fHistClusterMapITSSAokInAcc->SetMinimum(0);
524   fOutput->Add(fHistClusterMapITSSAokInAcc);
525
526   fHistClusterMapModuleITSSAokInAcc = new TH1F("fHistClusterMapModuleITSSAokInAcc", "N tracks with ok on Module (SA); Module; N tracks",2198, -0.5, 2197.5);
527   fHistClusterMapModuleITSSAokInAcc->SetMinimum(0);
528   fOutput->Add(fHistClusterMapModuleITSSAokInAcc);
529
530   fHistClusterMapModuleITSMIokInAcc = new TH1F("fHistClusterMapModuleITSMIokInAcc", "N tracks with ok on Module (MI); Module; N tracks",2198, -0.5, 2197.5);
531   fHistClusterMapModuleITSMIokInAcc->SetMinimum(0);
532   fOutput->Add(fHistClusterMapModuleITSMIokInAcc);
533
534   fHistClusterMapITSSAok = new TH1F("fHistClusterMapITSSAok", "N tracks with ok on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
535   fHistClusterMapITSSAok->Sumw2();
536   fHistClusterMapITSSAok->SetMinimum(0);
537   fOutput->Add(fHistClusterMapITSSAok);
538
539   fHistClusterMapITSMIbad = new TH1F("fHistClusterMapITSMIbad", "N tracks with bad on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
540   fHistClusterMapITSMIbad->Sumw2();
541   fHistClusterMapITSMIbad->SetMinimum(0);
542   fOutput->Add(fHistClusterMapITSMIbad);
543   
544   fHistClusterMapITSSAbadInAcc = new TH1F("fHistClusterMapITSSAbadInAcc", "N tracks with bad on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
545   fHistClusterMapITSSAbadInAcc->Sumw2();
546   fHistClusterMapITSSAbadInAcc->SetMinimum(0);
547   fOutput->Add(fHistClusterMapITSSAbadInAcc);
548
549   fHistClusterMapModuleITSSAbadInAcc = new TH1F("fHistClusterMapModuleITSSAbadInAcc", "N tracks with bad on Module (SA); Module; N tracks",2198, -0.5, 2197.5);
550   fHistClusterMapModuleITSSAbadInAcc->SetMinimum(0);
551   fOutput->Add(fHistClusterMapModuleITSSAbadInAcc);
552
553   fHistClusterMapModuleITSMIbadInAcc = new TH1F("fHistClusterMapModuleITSMIbadInAcc", "N tracks with bad on Module (MI); Module; N tracks",2198, -0.5, 2197.5);
554   fHistClusterMapModuleITSMIbadInAcc->SetMinimum(0);
555   fOutput->Add(fHistClusterMapModuleITSMIbadInAcc);
556
557   fHistClusterMapITSSAbad = new TH1F("fHistClusterMapITSSAbad", "N tracks with bad on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
558   fHistClusterMapITSSAbad->Sumw2();
559   fHistClusterMapITSSAbad->SetMinimum(0);
560   fOutput->Add(fHistClusterMapITSSAbad);
561
562   fHistClusterMapITSMIskipped = new TH1F("fHistClusterMapITSMIskipped", "N tracks with skip on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
563   fHistClusterMapITSMIskipped->Sumw2();
564   fHistClusterMapITSMIskipped->SetMinimum(0);
565   fOutput->Add(fHistClusterMapITSMIskipped);
566   
567   fHistClusterMapITSSAskippedInAcc = new TH1F("fHistClusterMapITSSAskippedInAcc", "N tracks with skip on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
568   fHistClusterMapITSSAskippedInAcc->Sumw2();
569   fHistClusterMapITSSAskippedInAcc->SetMinimum(0);
570   fOutput->Add(fHistClusterMapITSSAskippedInAcc);
571
572   fHistClusterMapITSSAskipped = new TH1F("fHistClusterMapITSSAskipped", "N tracks with skip on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
573   fHistClusterMapITSSAskipped->Sumw2();
574   fHistClusterMapITSSAskipped->SetMinimum(0);
575   fOutput->Add(fHistClusterMapITSSAskipped);
576
577   fHistClusterMapITSMIoutinz = new TH1F("fHistClusterMapITSMIoutinz", "N tracks out in z on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
578   fHistClusterMapITSMIoutinz->Sumw2();
579   fHistClusterMapITSMIoutinz->SetMinimum(0);
580   fOutput->Add(fHistClusterMapITSMIoutinz);
581   
582   fHistClusterMapITSSAoutinzInAcc = new TH1F("fHistClusterMapITSSAoutinzInAcc", "N tracks with out in z on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
583   fHistClusterMapITSSAoutinzInAcc->Sumw2();
584   fHistClusterMapITSSAoutinzInAcc->SetMinimum(0);
585   fOutput->Add(fHistClusterMapITSSAoutinzInAcc);
586
587   fHistClusterMapITSSAoutinz = new TH1F("fHistClusterMapITSSAoutinz", "N tracks with out in z on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
588   fHistClusterMapITSSAoutinz->Sumw2();
589   fHistClusterMapITSSAoutinz->SetMinimum(0);
590   fOutput->Add(fHistClusterMapITSSAoutinz);
591
592   fHistClusterMapITSSAokoutinzbad = new TH1F("fHistClusterMapITSSAokoutinzbad", "N tracks with cluster or bad zone or out in z (SA); Layer; N tracks",6, -0.5, 5.5);
593   fHistClusterMapITSSAokoutinzbad->Sumw2();
594   fHistClusterMapITSSAokoutinzbad->SetMinimum(0);
595   fOutput->Add(fHistClusterMapITSSAokoutinzbad);
596
597   fHistClusterMapITSMIokoutinzbad = new TH1F("fHistClusterMapITSMIokoutinzbad", "N tracks with cluster or bad zone or out in z (MI); Layer; N tracks",6, -0.5, 5.5);
598   fHistClusterMapITSMIokoutinzbad->Sumw2();
599   fHistClusterMapITSMIokoutinzbad->SetMinimum(0);
600   fOutput->Add(fHistClusterMapITSMIokoutinzbad);
601
602   fHistClusterMapITSSAokoutinzbadInAcc = new TH1F("fHistClusterMapITSSAokoutinzbadInAcc", "N tracks with cluster or bad zone or out in z (SA); Layer; N tracks",6, -0.5, 5.5);
603   fHistClusterMapITSSAokoutinzbadInAcc->Sumw2();
604   fHistClusterMapITSSAokoutinzbadInAcc->SetMinimum(0);
605   fOutput->Add(fHistClusterMapITSSAokoutinzbadInAcc);
606
607   fHistClusterMapITSMInorefit = new TH1F("fHistClusterMapITSMInorefit", "N tracks with norefit on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
608   fHistClusterMapITSMInorefit->Sumw2();
609   fHistClusterMapITSMInorefit->SetMinimum(0);
610   fOutput->Add(fHistClusterMapITSMInorefit);
611   
612   fHistClusterMapITSSAnorefitInAcc = new TH1F("fHistClusterMapITSSAnorefitInAcc", "N tracks with norefit on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
613   fHistClusterMapITSSAnorefitInAcc->Sumw2();
614   fHistClusterMapITSSAnorefitInAcc->SetMinimum(0);
615   fOutput->Add(fHistClusterMapITSSAnorefitInAcc);
616
617   fHistClusterMapITSSAnorefit = new TH1F("fHistClusterMapITSSAnorefit", "N tracks with norefit on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
618   fHistClusterMapITSSAnorefit->Sumw2();
619   fHistClusterMapITSSAnorefit->SetMinimum(0);
620   fOutput->Add(fHistClusterMapITSSAnorefit);
621
622   fHistClusterMapITSMInocls = new TH1F("fHistClusterMapITSMInocls", "N tracks with nocls on Layer (MI); Layer; N tracks",6, -0.5, 5.5);
623   fHistClusterMapITSMInocls->Sumw2();
624   fHistClusterMapITSMInocls->SetMinimum(0);
625   fOutput->Add(fHistClusterMapITSMInocls);
626   
627   fHistClusterMapITSSAnoclsInAcc = new TH1F("fHistClusterMapITSSAnoclsInAcc", "N tracks with nocls on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
628   fHistClusterMapITSSAnoclsInAcc->Sumw2();
629   fHistClusterMapITSSAnoclsInAcc->SetMinimum(0);
630   fOutput->Add(fHistClusterMapITSSAnoclsInAcc);
631   
632   fHistClusterMapModuleITSSAnoclsInAcc = new TH1F("fHistClusterMapModuleITSSAnoclsInAcc", "N tracks with nocls on Module (SA); Module; N tracks",2198, -0.5, 2197.5);
633   fHistClusterMapModuleITSSAnoclsInAcc->SetMinimum(0);
634   fOutput->Add(fHistClusterMapModuleITSSAnoclsInAcc);
635
636   fHistClusterMapModuleITSMInoclsInAcc = new TH1F("fHistClusterMapModuleITSMInoclsInAcc", "N tracks with nocls on Module (MI); Module; N tracks",2198, -0.5, 2197.5);
637   fHistClusterMapModuleITSMInoclsInAcc->SetMinimum(0);
638   fOutput->Add(fHistClusterMapModuleITSMInoclsInAcc);
639
640   fHistClusterMapITSSAnocls = new TH1F("fHistClusterMapITSSAnocls", "N tracks with nocls on Layer (SA); Layer; N tracks",6, -0.5, 5.5);
641   fHistClusterMapITSSAnocls->Sumw2();
642   fHistClusterMapITSSAnocls->SetMinimum(0);
643   fOutput->Add(fHistClusterMapITSSAnocls);
644   
645   
646   fHistZatSPDouter0ok = new TH1F("fHistZatSPDouter0ok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
647   fHistZatSPDouter0ok->Sumw2();
648   fHistZatSPDouter0ok->SetMinimum(0);
649   fOutput->Add(fHistZatSPDouter0ok);
650   fHistZatSPDouter1ok = new TH1F("fHistZatSPDouter1ok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
651   fHistZatSPDouter1ok->Sumw2();
652   fHistZatSPDouter1ok->SetMinimum(0);
653   fOutput->Add(fHistZatSPDouter1ok);
654   fHistZatSPDouter2ok = new TH1F("fHistZatSPDouter2ok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
655   fHistZatSPDouter2ok->Sumw2();
656   fHistZatSPDouter2ok->SetMinimum(0);
657   fOutput->Add(fHistZatSPDouter2ok);
658   fHistZatSPDouter3ok = new TH1F("fHistZatSPDouter3ok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
659   fHistZatSPDouter3ok->Sumw2();
660   fHistZatSPDouter3ok->SetMinimum(0);
661   fOutput->Add(fHistZatSPDouter3ok);
662   fHistZatSPDouter0notok = new TH1F("fHistZatSPDouter0notok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
663   fHistZatSPDouter0notok->Sumw2();
664   fHistZatSPDouter0notok->SetMinimum(0);
665   fOutput->Add(fHistZatSPDouter0notok);
666   fHistZatSPDouter1notok = new TH1F("fHistZatSPDouter1notok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
667   fHistZatSPDouter1notok->Sumw2();
668   fHistZatSPDouter1notok->SetMinimum(0);
669   fOutput->Add(fHistZatSPDouter1notok);
670   fHistZatSPDouter2notok = new TH1F("fHistZatSPDouter2notok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
671   fHistZatSPDouter2notok->Sumw2();
672   fHistZatSPDouter2notok->SetMinimum(0);
673   fOutput->Add(fHistZatSPDouter2notok);
674   fHistZatSPDouter3notok = new TH1F("fHistZatSPDouter3notok", "Track z at SPDouter radius; z [cm]; N tracks",3200,-16,16);
675   fHistZatSPDouter3notok->Sumw2();
676   fHistZatSPDouter3notok->SetMinimum(0);
677   fOutput->Add(fHistZatSPDouter3notok);
678   
679   fHistxlocSDDok = new TH1F("fHistxlocSDDok", "SDD points; xloc [cm]; N tracks",75, -3.75, 3.75);
680   fHistxlocSDDok->Sumw2();
681   fHistxlocSDDok->SetMinimum(0);
682   fOutput->Add(fHistxlocSDDok);
683
684   fHistxlocVSmodSDDok = new TH2F("fHistxlocVSmodSDDok", "SDD points; module; xloc [cm]",260,239.5,499.5,25, -3.75, 3.75);
685   fOutput->Add(fHistxlocVSmodSDDok);
686
687   fHistzlocSDDok = new TH1F("fHistzlocSDDok", "SDD points; zloc [cm]; N tracks",77, -3.85, 3.85);
688   fHistzlocSDDok->Sumw2();
689   fHistzlocSDDok->SetMinimum(0);
690   fOutput->Add(fHistzlocSDDok);
691   
692   fHistxlocSDDall = new TH1F("fHistxlocSDDall", "SDD points; xloc [cm]; N tracks",75, -3.75, 3.75);
693   fHistxlocSDDall->Sumw2();
694   fHistxlocSDDall->SetMinimum(0);
695   fOutput->Add(fHistxlocSDDall);
696
697   fHistzlocSDDall = new TH1F("fHistzlocSDDall", "SDD points; zloc [cm]; N tracks",77, -3.85, 3.85);
698   fHistzlocSDDall->Sumw2();
699   fHistzlocSDDall->SetMinimum(0);
700   fOutput->Add(fHistzlocSDDall);
701   
702
703   fHistPhiTPCInAcc = new TH1F("fHistPhiTPCInAcc","Azimuthal distribution of TPC tracks; #phi; N tracks",100, 0, 2.*3.1415);
704   fHistPhiTPCInAcc->Sumw2();
705   fHistPhiTPCInAcc->SetMinimum(0);
706   fOutput->Add(fHistPhiTPCInAcc);
707
708   fHistPhiITSMIokbadoutinz6InAcc = new TH1F("fHistPhiITSMIokbadoutinz6InAcc","Azimuthal distribution of ITSMI tracks with 6 layers OK; #phi; N tracks",100,0,2.*3.1415);
709   fHistPhiITSMIokbadoutinz6InAcc->Sumw2();
710   fHistPhiITSMIokbadoutinz6InAcc->SetMinimum(0);
711   fOutput->Add(fHistPhiITSMIokbadoutinz6InAcc);
712   
713   fHistPtTPC = new TH1F("fHistPtTPC","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
714   fHistPtTPC->Sumw2();
715   fHistPtTPC->SetMinimum(0);
716   fOutput->Add(fHistPtTPC);
717   
718   fHistPtITSMI6 = new TH1F("fHistPtITSMI6","pt distribution of ITSMI6 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
719   fHistPtITSMI6->Sumw2();
720   fHistPtITSMI6->SetMinimum(0);
721   fOutput->Add(fHistPtITSMI6);
722   
723   fHistPtITSMI5 = new TH1F("fHistPtITSMI5","pt distribution of ITSMI5 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
724   fHistPtITSMI5->Sumw2();
725   fHistPtITSMI5->SetMinimum(0);
726   fOutput->Add(fHistPtITSMI5);
727   
728   fHistPtITSMI4 = new TH1F("fHistPtITSMI4","pt distribution of ITSMI4 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
729   fHistPtITSMI4->Sumw2();
730   fHistPtITSMI4->SetMinimum(0);
731   fOutput->Add(fHistPtITSMI4);
732   
733   fHistPtITSMI3 = new TH1F("fHistPtITSMI3","pt distribution of ITSMI3 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
734   fHistPtITSMI3->Sumw2();
735   fHistPtITSMI3->SetMinimum(0);
736   fOutput->Add(fHistPtITSMI3);
737   
738   fHistPtITSMI2 = new TH1F("fHistPtITSMI2","pt distribution of ITSMI2 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
739   fHistPtITSMI2->Sumw2();
740   fHistPtITSMI2->SetMinimum(0);
741   fOutput->Add(fHistPtITSMI2);
742   
743   fHistPtITSMISPD = new TH1F("fHistPtITSMISPD","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
744   fHistPtITSMISPD->Sumw2();
745   fHistPtITSMISPD->SetMinimum(0);
746   fOutput->Add(fHistPtITSMISPD);
747
748   fHistPtITSMIoneSPD = new TH1F("fHistPtITSMIoneSPD","pt distribution of ITSMIoneSPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
749   fHistPtITSMIoneSPD->Sumw2();
750   fHistPtITSMIoneSPD->SetMinimum(0);
751   fOutput->Add(fHistPtITSMIoneSPD);
752
753   fHistPtTPCInAcc = new TH1F("fHistPtTPCInAcc","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
754   fHistPtTPCInAcc->Sumw2();
755   fHistPtTPCInAcc->SetMinimum(0);
756   fOutput->Add(fHistPtTPCInAcc);
757   
758   fHistPtTPCInAccMCtwoSPD = new TH1F("fHistPtTPCInAccMCtwoSPD","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
759   fHistPtTPCInAccMCtwoSPD->Sumw2();
760   fHistPtTPCInAccMCtwoSPD->SetMinimum(0);
761   fOutput->Add(fHistPtTPCInAccMCtwoSPD);
762   
763   fHistPtTPCInAccMConeSPD = new TH1F("fHistPtTPCInAccMConeSPD","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
764   fHistPtTPCInAccMConeSPD->Sumw2();
765   fHistPtTPCInAccMConeSPD->SetMinimum(0);
766   fOutput->Add(fHistPtTPCInAccMConeSPD);
767   
768   fHistdEdxVSPtTPCInAcc = new TH2F("fHistdEdxVSPtTPCInAcc","dE/dx distribution of TPC tracks; p_{t} [GeV/c]; TPC dE/dx",100,0,1,50,0,500);
769   fOutput->Add(fHistdEdxVSPtTPCInAcc);
770   
771   fHistdEdxVSPtITSTPCsel = new TH2F("fHistdEdxVSPtITSTPCsel","dE/dx distribution of TPC tracks; p_{t} [GeV/c]; ITS dE/dx",100,0,1,50,0,500);
772   fOutput->Add(fHistdEdxVSPtITSTPCsel);
773   
774   fHistPtVSphiTPCInAcc = new TH2F("fHistPtVSphiTPCInAcc","pt distribution of TPC tracks; phi; p_{t} [GeV/c]",18,0,6.28,20,0,0.5);
775   fHistPtVSphiTPCInAcc->SetMinimum(0);
776   fOutput->Add(fHistPtVSphiTPCInAcc);
777   
778   fHistPtTPCInAccNoTRDout = new TH1F("fHistPtTPCInAccNoTRDout","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
779   fHistPtTPCInAccNoTRDout->Sumw2();
780   fHistPtTPCInAccNoTRDout->SetMinimum(0);
781   fOutput->Add(fHistPtTPCInAccNoTRDout);
782   
783   fHistPtTPCInAccNoTOFout = new TH1F("fHistPtTPCInAccNoTOFout","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
784   fHistPtTPCInAccNoTOFout->Sumw2();
785   fHistPtTPCInAccNoTOFout->SetMinimum(0);
786   fOutput->Add(fHistPtTPCInAccNoTOFout);
787   
788   fHistPtTPCInAccWithPtTPCAtVtx = new TH1F("fHistPtTPCInAccWithPtTPCAtVtx","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
789   fHistPtTPCInAccWithPtTPCAtVtx->Sumw2();
790   fHistPtTPCInAccWithPtTPCAtVtx->SetMinimum(0);
791   fOutput->Add(fHistPtTPCInAccWithPtTPCAtVtx);
792   
793   fHistPtTPCInAccWithPtTPCAtInnerWall = new TH1F("fHistPtTPCInAccWithPtTPCAtInnerWall","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
794   fHistPtTPCInAccWithPtTPCAtInnerWall->Sumw2();
795   fHistPtTPCInAccWithPtTPCAtInnerWall->SetMinimum(0);
796   fOutput->Add(fHistPtTPCInAccWithPtTPCAtInnerWall);
797   
798   fHistDeltaPtTPC = new TH2F("fHistDeltaPtTPC","pt distribution of TPC tracks; p_{t} [GeV/c]; p_{t} TPC at vtx - p_{t} at inner wall [GeV/c]",100,0,1,50,-0.2,0.2);
799   fHistDeltaPtTPC->SetMinimum(0);
800   fOutput->Add(fHistDeltaPtTPC);
801   
802   fHistPtITSMI6InAcc = new TH1F("fHistPtITSMI6InAcc","pt distribution of ITSMI6 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
803   fHistPtITSMI6InAcc->Sumw2();
804   fHistPtITSMI6InAcc->SetMinimum(0);
805   fOutput->Add(fHistPtITSMI6InAcc);
806   
807   fHistPtITSMI5InAcc = new TH1F("fHistPtITSMI5InAcc","pt distribution of ITSMI5 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
808   fHistPtITSMI5InAcc->Sumw2();
809   fHistPtITSMI5InAcc->SetMinimum(0);
810   fOutput->Add(fHistPtITSMI5InAcc);
811   
812   fHistPtITSMI4InAcc = new TH1F("fHistPtITSMI4InAcc","pt distribution of ITSMI4 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
813   fHistPtITSMI4InAcc->Sumw2();
814   fHistPtITSMI4InAcc->SetMinimum(0);
815   fOutput->Add(fHistPtITSMI4InAcc);
816   
817   fHistPtITSMI3InAcc = new TH1F("fHistPtITSMI3InAcc","pt distribution of ITSMI3 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
818   fHistPtITSMI3InAcc->Sumw2();
819   fHistPtITSMI3InAcc->SetMinimum(0);
820   fOutput->Add(fHistPtITSMI3InAcc);
821   
822   fHistPtITSMI2InAcc = new TH1F("fHistPtITSMI2InAcc","pt distribution of ITSMI2 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
823   fHistPtITSMI2InAcc->Sumw2();
824   fHistPtITSMI2InAcc->SetMinimum(0);
825   fOutput->Add(fHistPtITSMI2InAcc);
826   
827   fHistPtITSMISPDInAcc = new TH1F("fHistPtITSMISPDInAcc","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
828   fHistPtITSMISPDInAcc->Sumw2();
829   fHistPtITSMISPDInAcc->SetMinimum(0);
830   fOutput->Add(fHistPtITSMISPDInAcc);
831   
832   fHistPtITSMIoneSPDInAcc = new TH1F("fHistPtITSMIoneSPDInAcc","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
833   fHistPtITSMIoneSPDInAcc->Sumw2();
834   fHistPtITSMIoneSPDInAcc->SetMinimum(0);
835   fOutput->Add(fHistPtITSMIoneSPDInAcc);
836
837   fHistPtITSMIoneSPDthreeSDDSSDInAcc = new TH1F("fHistPtITSMIoneSPDthreeSDDSSDInAcc","pt distribution of ITSMI tracks (>0 in SPD, >2 in SDD+SSD); p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
838   fHistPtITSMIoneSPDthreeSDDSSDInAcc->Sumw2();
839   fHistPtITSMIoneSPDthreeSDDSSDInAcc->SetMinimum(0);
840   fOutput->Add(fHistPtITSMIoneSPDthreeSDDSSDInAcc);
841
842   fHistPtITSTPCsel = new TH1F("fHistPtITSTPCsel","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
843   fHistPtITSTPCsel->Sumw2();
844   fHistPtITSTPCsel->SetMinimum(0);
845   fOutput->Add(fHistPtITSTPCsel);
846
847   fHistPtITSTPCselP = new TH1F("fHistPtITSTPCselP","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
848   fHistPtITSTPCselP->Sumw2();
849   fHistPtITSTPCselP->SetMinimum(0);
850   fOutput->Add(fHistPtITSTPCselP);
851
852   fHistPtITSTPCselS = new TH1F("fHistPtITSTPCselS","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
853   fHistPtITSTPCselS->Sumw2();
854   fHistPtITSTPCselS->SetMinimum(0);
855   fOutput->Add(fHistPtITSTPCselS);
856
857   fHistPtITSTPCselSfromStrange = new TH1F("fHistPtITSTPCselSfromStrange","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
858   fHistPtITSTPCselSfromStrange->Sumw2();
859   fHistPtITSTPCselSfromStrange->SetMinimum(0);
860   fOutput->Add(fHistPtITSTPCselSfromStrange);
861
862   fHistPtITSTPCselPfromStrange = new TH1F("fHistPtITSTPCselPfromStrange","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
863   fHistPtITSTPCselPfromStrange->Sumw2();
864   fHistPtITSTPCselPfromStrange->SetMinimum(0);
865   fOutput->Add(fHistPtITSTPCselPfromStrange);
866
867   fHistPtITSTPCselSfromMat = new TH1F("fHistPtITSTPCselSfromMat","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
868   fHistPtITSTPCselSfromMat->Sumw2();
869   fHistPtITSTPCselSfromMat->SetMinimum(0);
870   fOutput->Add(fHistPtITSTPCselSfromMat);
871
872   fHistPtTPCInAccP = new TH1F("fHistPtTPCInAccP","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
873   fHistPtTPCInAccP->Sumw2();
874   fHistPtTPCInAccP->SetMinimum(0);
875   fOutput->Add(fHistPtTPCInAccP);
876
877   fHistPtTPCInAccPfromStrange = new TH1F("fHistPtTPCInAccPfromStrange","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
878   fHistPtTPCInAccPfromStrange->Sumw2();
879   fHistPtTPCInAccPfromStrange->SetMinimum(0);
880   fOutput->Add(fHistPtTPCInAccPfromStrange);
881   
882   fHistPtITSMI6InAccP = new TH1F("fHistPtITSMI6InAccP","pt distribution of ITSMI6 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
883   fHistPtITSMI6InAccP->Sumw2();
884   fHistPtITSMI6InAccP->SetMinimum(0);
885   fOutput->Add(fHistPtITSMI6InAccP);
886   
887   fHistPtITSMI5InAccP = new TH1F("fHistPtITSMI5InAccP","pt distribution of ITSMI5 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
888   fHistPtITSMI5InAccP->Sumw2();
889   fHistPtITSMI5InAccP->SetMinimum(0);
890   fOutput->Add(fHistPtITSMI5InAccP);
891   
892   fHistPtITSMI4InAccP = new TH1F("fHistPtITSMI4InAccP","pt distribution of ITSMI4 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
893   fHistPtITSMI4InAccP->Sumw2();
894   fHistPtITSMI4InAccP->SetMinimum(0);
895   fOutput->Add(fHistPtITSMI4InAccP);
896   
897   fHistPtITSMI3InAccP = new TH1F("fHistPtITSMI3InAccP","pt distribution of ITSMI3 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
898   fHistPtITSMI3InAccP->Sumw2();
899   fHistPtITSMI3InAccP->SetMinimum(0);
900   fOutput->Add(fHistPtITSMI3InAccP);
901   
902   fHistPtITSMI2InAccP = new TH1F("fHistPtITSMI2InAccP","pt distribution of ITSMI2 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
903   fHistPtITSMI2InAccP->Sumw2();
904   fHistPtITSMI2InAccP->SetMinimum(0);
905   fOutput->Add(fHistPtITSMI2InAccP);
906   
907   fHistPtITSMISPDInAccP = new TH1F("fHistPtITSMISPDInAccP","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
908   fHistPtITSMISPDInAccP->Sumw2();
909   fHistPtITSMISPDInAccP->SetMinimum(0);
910   fOutput->Add(fHistPtITSMISPDInAccP);
911   
912   fHistPtITSMIoneSPDInAccP = new TH1F("fHistPtITSMIoneSPDInAccP","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
913   fHistPtITSMIoneSPDInAccP->Sumw2();
914   fHistPtITSMIoneSPDInAccP->SetMinimum(0);
915   fOutput->Add(fHistPtITSMIoneSPDInAccP);
916
917   fHistPtTPCInAccS = new TH1F("fHistPtTPCInAccS","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
918   fHistPtTPCInAccS->Sumw2();
919   fHistPtTPCInAccS->SetMinimum(0);
920   fOutput->Add(fHistPtTPCInAccS);
921   
922   fHistPtTPCInAccSfromStrange = new TH1F("fHistPtTPCInAccSfromStrange","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
923   fHistPtTPCInAccSfromStrange->Sumw2();
924   fHistPtTPCInAccSfromStrange->SetMinimum(0);
925   fOutput->Add(fHistPtTPCInAccSfromStrange);
926   
927   fHistPtTPCInAccSfromMat = new TH1F("fHistPtTPCInAccSfromMat","pt distribution of TPC tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
928   fHistPtTPCInAccSfromMat->Sumw2();
929   fHistPtTPCInAccSfromMat->SetMinimum(0);
930   fOutput->Add(fHistPtTPCInAccSfromMat);
931   
932   fHistPtITSMI6InAccS = new TH1F("fHistPtITSMI6InAccS","pt distribution of ITSMI6 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
933   fHistPtITSMI6InAccS->Sumw2();
934   fHistPtITSMI6InAccS->SetMinimum(0);
935   fOutput->Add(fHistPtITSMI6InAccS);
936   
937   fHistPtITSMI5InAccS = new TH1F("fHistPtITSMI5InAccS","pt distribution of ITSMI5 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
938   fHistPtITSMI5InAccS->Sumw2();
939   fHistPtITSMI5InAccS->SetMinimum(0);
940   fOutput->Add(fHistPtITSMI5InAccS);
941   
942   fHistPtITSMI4InAccS = new TH1F("fHistPtITSMI4InAccS","pt distribution of ITSMI4 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
943   fHistPtITSMI4InAccS->Sumw2();
944   fHistPtITSMI4InAccS->SetMinimum(0);
945   fOutput->Add(fHistPtITSMI4InAccS);
946   
947   fHistPtITSMI3InAccS = new TH1F("fHistPtITSMI3InAccS","pt distribution of ITSMI3 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
948   fHistPtITSMI3InAccS->Sumw2();
949   fHistPtITSMI3InAccS->SetMinimum(0);
950   fOutput->Add(fHistPtITSMI3InAccS);
951   
952   fHistPtITSMI2InAccS = new TH1F("fHistPtITSMI2InAccS","pt distribution of ITSMI2 tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
953   fHistPtITSMI2InAccS->Sumw2();
954   fHistPtITSMI2InAccS->SetMinimum(0);
955   fOutput->Add(fHistPtITSMI2InAccS);
956   
957   fHistPtITSMISPDInAccS = new TH1F("fHistPtITSMISPDInAccS","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
958   fHistPtITSMISPDInAccS->Sumw2();
959   fHistPtITSMISPDInAccS->SetMinimum(0);
960   fOutput->Add(fHistPtITSMISPDInAccS);
961   
962   fHistPtITSMIoneSPDInAccS = new TH1F("fHistPtITSMIoneSPDInAccS","pt distribution of ITSMISPD tracks; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
963   fHistPtITSMIoneSPDInAccS->Sumw2();
964   fHistPtITSMIoneSPDInAccS->SetMinimum(0);
965   fOutput->Add(fHistPtITSMIoneSPDInAccS);
966   
967   fHistPtITSMIokbadoutinz6 = new TH1F("fHistPtITSMIokbadoutinz6","pt distribution of ITSMI tracks with 6 layers OK; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
968   fHistPtITSMIokbadoutinz6->Sumw2();
969   fHistPtITSMIokbadoutinz6->SetMinimum(0);
970   fOutput->Add(fHistPtITSMIokbadoutinz6);
971
972   fHistPtITSMIokbadoutinz4InAcc = new TH1F("fHistPtITSMIokbadoutinz4InAcc","pt distribution of ITSMI tracks with 4 layers OK; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
973   fHistPtITSMIokbadoutinz4InAcc->Sumw2();
974   fHistPtITSMIokbadoutinz4InAcc->SetMinimum(0);
975   fOutput->Add(fHistPtITSMIokbadoutinz4InAcc);
976
977   fHistPtITSMIokbadoutinz5InAcc = new TH1F("fHistPtITSMIokbadoutinz5InAcc","pt distribution of ITSMI tracks with 5 layers OK; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
978   fHistPtITSMIokbadoutinz5InAcc->Sumw2();
979   fHistPtITSMIokbadoutinz5InAcc->SetMinimum(0);
980   fOutput->Add(fHistPtITSMIokbadoutinz5InAcc);
981
982   fHistPtITSMIokbadoutinz6InAcc = new TH1F("fHistPtITSMIokbadoutinz6InAcc","pt distribution of ITSMI tracks with 6 layers OK; p_{t} [GeV/c]; N tracks",nPtBins,xPtBins);
983   fHistPtITSMIokbadoutinz6InAcc->Sumw2();
984   fHistPtITSMIokbadoutinz6InAcc->SetMinimum(0);
985   fOutput->Add(fHistPtITSMIokbadoutinz6InAcc);
986
987   fHistRProdVtxInAccP = new TH1F("fHistRProdVtxInAccP","Radius of production vertex for primaries; r [cm]; N tracks",100,0,10);
988   fHistRProdVtxInAccP->Sumw2();
989   fHistRProdVtxInAccP->SetMinimum(0);
990   fOutput->Add(fHistRProdVtxInAccP);
991
992   fHistRProdVtxInAccS = new TH1F("fHistRProdVtxInAccS","Radius of production vertex for secondaries; r [cm]; N tracks",100,0,10);
993   fHistRProdVtxInAccS->Sumw2();
994   fHistRProdVtxInAccS->SetMinimum(0);
995   fOutput->Add(fHistRProdVtxInAccS);
996   
997   fHistd0rphiTPCInAccP150200 = new TH1F("fHistd0rphiTPCInAccP150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
998   fHistd0rphiTPCInAccP150200->Sumw2();
999   fHistd0rphiTPCInAccP150200->SetMinimum(0);
1000   fOutput->Add(fHistd0rphiTPCInAccP150200);
1001
1002   fHistd0rphiTPCInAccP500700 = new TH1F("fHistd0rphiTPCInAccP500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
1003   fHistd0rphiTPCInAccP500700->Sumw2();
1004   fHistd0rphiTPCInAccP500700->SetMinimum(0);
1005   fOutput->Add(fHistd0rphiTPCInAccP500700);
1006
1007   fHistd0rphiTPCInAccP10001500 = new TH1F("fHistd0rphiTPCInAccP10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
1008   fHistd0rphiTPCInAccP10001500->Sumw2();
1009   fHistd0rphiTPCInAccP10001500->SetMinimum(0);
1010   fOutput->Add(fHistd0rphiTPCInAccP10001500);
1011
1012   fHistd0rphiTPCInAccS150200 = new TH1F("fHistd0rphiTPCInAccS150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
1013   fHistd0rphiTPCInAccS150200->Sumw2();
1014   fHistd0rphiTPCInAccS150200->SetMinimum(0);
1015   fOutput->Add(fHistd0rphiTPCInAccS150200);
1016
1017   fHistd0rphiTPCInAccS500700 = new TH1F("fHistd0rphiTPCInAccS500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
1018   fHistd0rphiTPCInAccS500700->Sumw2();
1019   fHistd0rphiTPCInAccS500700->SetMinimum(0);
1020   fOutput->Add(fHistd0rphiTPCInAccS500700);
1021
1022   fHistd0rphiTPCInAccS10001500 = new TH1F("fHistd0rphiTPCInAccS10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-5,5);
1023   fHistd0rphiTPCInAccS10001500->Sumw2();
1024   fHistd0rphiTPCInAccS10001500->SetMinimum(0);
1025   fOutput->Add(fHistd0rphiTPCInAccS10001500);
1026
1027   fHistd0rphiITSMISPDInAccP150200 = new TH1F("fHistd0rphiITSMISPDInAccP150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1028   fHistd0rphiITSMISPDInAccP150200->Sumw2();
1029   fHistd0rphiITSMISPDInAccP150200->SetMinimum(0);
1030   fOutput->Add(fHistd0rphiITSMISPDInAccP150200);
1031
1032   fHistd0rphiITSMISPDInAccP500700 = new TH1F("fHistd0rphiITSMISPDInAccP500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1033   fHistd0rphiITSMISPDInAccP500700->Sumw2();
1034   fHistd0rphiITSMISPDInAccP500700->SetMinimum(0);
1035   fOutput->Add(fHistd0rphiITSMISPDInAccP500700);
1036
1037   fHistd0rphiITSMISPDInAccP10001500 = new TH1F("fHistd0rphiITSMISPDInAccP10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1038   fHistd0rphiITSMISPDInAccP10001500->Sumw2();
1039   fHistd0rphiITSMISPDInAccP10001500->SetMinimum(0);
1040   fOutput->Add(fHistd0rphiITSMISPDInAccP10001500);
1041
1042   fHistd0rphiITSMISPDInAccS150200 = new TH1F("fHistd0rphiITSMISPDInAccS150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1043   fHistd0rphiITSMISPDInAccS150200->Sumw2();
1044   fHistd0rphiITSMISPDInAccS150200->SetMinimum(0);
1045   fOutput->Add(fHistd0rphiITSMISPDInAccS150200);
1046
1047   fHistd0rphiITSMISPDInAccS500700 = new TH1F("fHistd0rphiITSMISPDInAccS500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1048   fHistd0rphiITSMISPDInAccS500700->Sumw2();
1049   fHistd0rphiITSMISPDInAccS500700->SetMinimum(0);
1050   fOutput->Add(fHistd0rphiITSMISPDInAccS500700);
1051
1052   fHistd0rphiITSMISPDInAccS10001500 = new TH1F("fHistd0rphiITSMISPDInAccS10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1053   fHistd0rphiITSMISPDInAccS10001500->Sumw2();
1054   fHistd0rphiITSMISPDInAccS10001500->SetMinimum(0);
1055   fOutput->Add(fHistd0rphiITSMISPDInAccS10001500);
1056
1057   fHistd0rphiITSMIoneSPDInAccP150200 = new TH1F("fHistd0rphiITSMIoneSPDInAccP150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1058   fHistd0rphiITSMIoneSPDInAccP150200->Sumw2();
1059   fHistd0rphiITSMIoneSPDInAccP150200->SetMinimum(0);
1060   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP150200);
1061
1062   fHistd0rphiITSMIoneSPDInAccP350450 = new TH1F("fHistd0rphiITSMIoneSPDInAccP350450","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1063   fHistd0rphiITSMIoneSPDInAccP350450->Sumw2();
1064   fHistd0rphiITSMIoneSPDInAccP350450->SetMinimum(0);
1065   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP350450);
1066
1067   fHistd0rphiITSMIoneSPDInAccP500700 = new TH1F("fHistd0rphiITSMIoneSPDInAccP500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1068   fHistd0rphiITSMIoneSPDInAccP500700->Sumw2();
1069   fHistd0rphiITSMIoneSPDInAccP500700->SetMinimum(0);
1070   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP500700);
1071
1072   fHistd0rphiITSMIoneSPDInAccP10001500 = new TH1F("fHistd0rphiITSMIoneSPDInAccP10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1073   fHistd0rphiITSMIoneSPDInAccP10001500->Sumw2();
1074   fHistd0rphiITSMIoneSPDInAccP10001500->SetMinimum(0);
1075   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP10001500);
1076
1077   fHistd0rphiITSMIoneSPDInAccP25004000 = new TH1F("fHistd0rphiITSMIoneSPDInAccP25004000","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1078   fHistd0rphiITSMIoneSPDInAccP25004000->Sumw2();
1079   fHistd0rphiITSMIoneSPDInAccP25004000->SetMinimum(0);
1080   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP25004000);
1081
1082   fHistd0rphiITSMIoneSPDInAccP40008000 = new TH1F("fHistd0rphiITSMIoneSPDInAccP40008000","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1083   fHistd0rphiITSMIoneSPDInAccP40008000->Sumw2();
1084   fHistd0rphiITSMIoneSPDInAccP40008000->SetMinimum(0);
1085   fOutput->Add(fHistd0rphiITSMIoneSPDInAccP40008000);
1086
1087   fHistd0zITSMIoneSPDInAccP150200 = new TH1F("fHistd0zITSMIoneSPDInAccP150200","Longitudinal imp. par. to VertexTracks for primaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1088   fHistd0zITSMIoneSPDInAccP150200->Sumw2();
1089   fHistd0zITSMIoneSPDInAccP150200->SetMinimum(0);
1090   fOutput->Add(fHistd0zITSMIoneSPDInAccP150200);
1091
1092   fHistd0zITSMIoneSPDInAccP500700 = new TH1F("fHistd0zITSMIoneSPDInAccP500700","Longitudinal imp. par. to VertexTracks for primaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1093   fHistd0zITSMIoneSPDInAccP500700->Sumw2();
1094   fHistd0zITSMIoneSPDInAccP500700->SetMinimum(0);
1095   fOutput->Add(fHistd0zITSMIoneSPDInAccP500700);
1096
1097   fHistd0zITSMIoneSPDInAccP10001500 = new TH1F("fHistd0zITSMIoneSPDInAccP10001500","Longitudinal imp. par. to VertexTracks for primaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1098   fHistd0zITSMIoneSPDInAccP10001500->Sumw2();
1099   fHistd0zITSMIoneSPDInAccP10001500->SetMinimum(0);
1100   fOutput->Add(fHistd0zITSMIoneSPDInAccP10001500);
1101
1102   fHistd0zVSetaTPCInAccP10001500 = new TH2F("fHistd0zVSetaTPCInAccP10001500","Long. imp. par. to VertexSPD for TPC tracks; d_{0} z [cm]; eta",100,-4,4,10,-1,1);
1103   fOutput->Add(fHistd0zVSetaTPCInAccP10001500);
1104
1105   fHistd0rphiVSphiITSMIoneSPDInAccP10001500 = new TH2F("fHistd0rphiVSphiITSMIoneSPDInAccP10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; phi",30,-0.3,0.3,40,0,2*3.1415);
1106   fOutput->Add(fHistd0rphiVSphiITSMIoneSPDInAccP10001500);
1107
1108   fHistd0rphiVSetaITSMIoneSPDInAccP10001500 = new TH2F("fHistd0rphiVSetaITSMIoneSPDInAccP10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; eta",30,-0.3,0.3,10,-1,1);
1109   fOutput->Add(fHistd0rphiVSetaITSMIoneSPDInAccP10001500);
1110
1111   fHistd0rphiITSMIoneSPDInAccS150200 = new TH1F("fHistd0rphiITSMIoneSPDInAccS150200","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1112   fHistd0rphiITSMIoneSPDInAccS150200->Sumw2();
1113   fHistd0rphiITSMIoneSPDInAccS150200->SetMinimum(0);
1114   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS150200);
1115
1116   fHistd0rphiITSMIoneSPDInAccS350450 = new TH1F("fHistd0rphiITSMIoneSPDInAccS350450","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1117   fHistd0rphiITSMIoneSPDInAccS350450->Sumw2();
1118   fHistd0rphiITSMIoneSPDInAccS350450->SetMinimum(0);
1119   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS350450);
1120
1121   fHistd0rphiITSMIoneSPDInAccS500700 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1122   fHistd0rphiITSMIoneSPDInAccS500700->Sumw2();
1123   fHistd0rphiITSMIoneSPDInAccS500700->SetMinimum(0);
1124   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700);
1125
1126   fHistd0rphiITSMIoneSPDInAccS500700from22 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700from22","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1127   fHistd0rphiITSMIoneSPDInAccS500700from22->Sumw2();
1128   fHistd0rphiITSMIoneSPDInAccS500700from22->SetMinimum(0);
1129   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700from22);
1130
1131   fHistd0rphiITSMIoneSPDInAccS500700from211 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700from211","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1132   fHistd0rphiITSMIoneSPDInAccS500700from211->Sumw2();
1133   fHistd0rphiITSMIoneSPDInAccS500700from211->SetMinimum(0);
1134   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700from211);
1135
1136   fHistd0rphiITSMIoneSPDInAccS500700from310 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700from310","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1137   fHistd0rphiITSMIoneSPDInAccS500700from310->Sumw2();
1138   fHistd0rphiITSMIoneSPDInAccS500700from310->SetMinimum(0);
1139   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700from310);
1140
1141   fHistd0rphiITSMIoneSPDInAccS500700from321 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700from321","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1142   fHistd0rphiITSMIoneSPDInAccS500700from321->Sumw2();
1143   fHistd0rphiITSMIoneSPDInAccS500700from321->SetMinimum(0);
1144   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700from321);
1145
1146   fHistd0rphiITSMIoneSPDInAccS500700from3122 = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700from3122","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1147   fHistd0rphiITSMIoneSPDInAccS500700from3122->Sumw2();
1148   fHistd0rphiITSMIoneSPDInAccS500700from3122->SetMinimum(0);
1149   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700from3122);
1150
1151   fHistd0rphiITSMIoneSPDInAccS10001500 = new TH1F("fHistd0rphiITSMIoneSPDInAccS10001500","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1152   fHistd0rphiITSMIoneSPDInAccS10001500->Sumw2();
1153   fHistd0rphiITSMIoneSPDInAccS10001500->SetMinimum(0);
1154   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS10001500);
1155
1156   fHistd0rphiITSMIoneSPDInAccS25004000 = new TH1F("fHistd0rphiITSMIoneSPDInAccS25004000","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1157   fHistd0rphiITSMIoneSPDInAccS25004000->Sumw2();
1158   fHistd0rphiITSMIoneSPDInAccS25004000->SetMinimum(0);
1159   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS25004000);
1160
1161   fHistd0rphiITSMIoneSPDInAccS40008000 = new TH1F("fHistd0rphiITSMIoneSPDInAccS40008000","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1162   fHistd0rphiITSMIoneSPDInAccS40008000->Sumw2();
1163   fHistd0rphiITSMIoneSPDInAccS40008000->SetMinimum(0);
1164   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS40008000);
1165
1166   fHistd0rphiITSMIoneSPDInAccS150200fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS150200fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1167   fHistd0rphiITSMIoneSPDInAccS150200fromStrange->Sumw2();
1168   fHistd0rphiITSMIoneSPDInAccS150200fromStrange->SetMinimum(0);
1169   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS150200fromStrange);
1170
1171   fHistd0rphiITSMIoneSPDInAccS150200fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS150200fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1172   fHistd0rphiITSMIoneSPDInAccS150200fromMat->Sumw2();
1173   fHistd0rphiITSMIoneSPDInAccS150200fromMat->SetMinimum(0);
1174   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS150200fromMat);
1175
1176   fHistd0rphiITSMIoneSPDInAccS350450fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS350450fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1177   fHistd0rphiITSMIoneSPDInAccS350450fromStrange->Sumw2();
1178   fHistd0rphiITSMIoneSPDInAccS350450fromStrange->SetMinimum(0);
1179   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS350450fromStrange);
1180
1181   fHistd0rphiITSMIoneSPDInAccS350450fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS350450fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1182   fHistd0rphiITSMIoneSPDInAccS350450fromMat->Sumw2();
1183   fHistd0rphiITSMIoneSPDInAccS350450fromMat->SetMinimum(0);
1184   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS350450fromMat);
1185
1186   fHistd0rphiITSMIoneSPDInAccS500700fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1187   fHistd0rphiITSMIoneSPDInAccS500700fromStrange->Sumw2();
1188   fHistd0rphiITSMIoneSPDInAccS500700fromStrange->SetMinimum(0);
1189   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700fromStrange);
1190
1191   fHistd0rphiITSMIoneSPDInAccS500700fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS500700fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1192   fHistd0rphiITSMIoneSPDInAccS500700fromMat->Sumw2();
1193   fHistd0rphiITSMIoneSPDInAccS500700fromMat->SetMinimum(0);
1194   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS500700fromMat);
1195
1196   fHistd0rphiITSMIoneSPDInAccS10001500fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS10001500fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1197   fHistd0rphiITSMIoneSPDInAccS10001500fromStrange->Sumw2();
1198   fHistd0rphiITSMIoneSPDInAccS10001500fromStrange->SetMinimum(0);
1199   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS10001500fromStrange);
1200
1201   fHistd0rphiITSMIoneSPDInAccS10001500fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS10001500fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1202   fHistd0rphiITSMIoneSPDInAccS10001500fromMat->Sumw2();
1203   fHistd0rphiITSMIoneSPDInAccS10001500fromMat->SetMinimum(0);
1204   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS10001500fromMat);
1205
1206   fHistd0rphiITSMIoneSPDInAccS25004000fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS25004000fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1207   fHistd0rphiITSMIoneSPDInAccS25004000fromStrange->Sumw2();
1208   fHistd0rphiITSMIoneSPDInAccS25004000fromStrange->SetMinimum(0);
1209   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS25004000fromStrange);
1210
1211   fHistd0rphiITSMIoneSPDInAccS25004000fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS25004000fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1212   fHistd0rphiITSMIoneSPDInAccS25004000fromMat->Sumw2();
1213   fHistd0rphiITSMIoneSPDInAccS25004000fromMat->SetMinimum(0);
1214   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS25004000fromMat);
1215
1216   fHistd0rphiITSMIoneSPDInAccS40008000fromStrange = new TH1F("fHistd0rphiITSMIoneSPDInAccS40008000fromStrange","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1217   fHistd0rphiITSMIoneSPDInAccS40008000fromStrange->Sumw2();
1218   fHistd0rphiITSMIoneSPDInAccS40008000fromStrange->SetMinimum(0);
1219   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS40008000fromStrange);
1220
1221   fHistd0rphiITSMIoneSPDInAccS40008000fromMat = new TH1F("fHistd0rphiITSMIoneSPDInAccS40008000fromMat","Transverse imp. par. to VertexTracks for primaries; d_{0} rphi [cm]; N tracks",300,-1.5,1.5);
1222   fHistd0rphiITSMIoneSPDInAccS40008000fromMat->Sumw2();
1223   fHistd0rphiITSMIoneSPDInAccS40008000fromMat->SetMinimum(0);
1224   fOutput->Add(fHistd0rphiITSMIoneSPDInAccS40008000fromMat);
1225
1226   
1227   fHistd0zITSMIoneSPDInAccS150200 = new TH1F("fHistd0zITSMIoneSPDInAccS150200","Longitudinal imp. par. to VertexTracks for secondaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1228   fHistd0zITSMIoneSPDInAccS150200->Sumw2();
1229   fHistd0zITSMIoneSPDInAccS150200->SetMinimum(0);
1230   fOutput->Add(fHistd0zITSMIoneSPDInAccS150200);
1231
1232   fHistd0zITSMIoneSPDInAccS500700 = new TH1F("fHistd0zITSMIoneSPDInAccS500700","Longitudinal imp. par. to VertexTracks for secondaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1233   fHistd0zITSMIoneSPDInAccS500700->Sumw2();
1234   fHistd0zITSMIoneSPDInAccS500700->SetMinimum(0);
1235   fOutput->Add(fHistd0zITSMIoneSPDInAccS500700);
1236
1237   fHistd0zITSMIoneSPDInAccS10001500 = new TH1F("fHistd0zITSMIoneSPDInAccS10001500","Longitudinal imp. par. to VertexTracks for secondaries; d_{0} z [cm]; N tracks",300,-1.5,1.5);
1238   fHistd0zITSMIoneSPDInAccS10001500->Sumw2();
1239   fHistd0zITSMIoneSPDInAccS10001500->SetMinimum(0);
1240   fOutput->Add(fHistd0zITSMIoneSPDInAccS10001500);
1241
1242
1243   // ntuples
1244   //
1245   fNtupleESDTracks = new TNtuple("fNtupleESDTracks","tracks","pt:eta:phi:d0:z0:sigmad0:sigmaz0:ptMC:pdgMC:pdgMCMoth:d0MC:d0MCv:z0MCv:sigmad0MCv:sigmaz0MCv:ITSflag:isPrimary:isTPCSel");  
1246   fOutput->Add(fNtupleESDTracks);
1247
1248   fNtupleITSAlignExtra = new TNtuple("fNtupleITSAlignExtra","ITS alignment checks: extra clusters","layer:x:y:z:dxy:dz:xloc:zloc:npoints:pt");  
1249   fOutput->Add(fNtupleITSAlignExtra);
1250
1251   fNtupleITSAlignSPDTracklets = new TNtuple("fNtupleITSAlignSPDTracklets","ITS alignment checks: SPD tracklets wrt SPD vertex","phi:theta:z:dxy:dz:pt");  
1252   fOutput->Add(fNtupleITSAlignSPDTracklets);
1253
1254   return;
1255 }
1256
1257 //________________________________________________________________________
1258 void AliAnalysisTaskITSTrackingCheck::UserExec(Option_t *) 
1259 {
1260   // Main loop
1261   // Called for each event
1262
1263   fESD = dynamic_cast<AliESDEvent*>(InputEvent());
1264
1265   if (!fESD) {
1266     Printf("ERROR: fESD not available");
1267     return;
1268   }
1269
1270
1271   fHistNEvents->Fill(-1);
1272
1273
1274   Bool_t isSelected = kTRUE;
1275   if(fUsePhysSel) {
1276     isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1277   }
1278   if(!isSelected) return;
1279
1280   
1281   //if(fESD->GetEventType()!=7) return;
1282
1283   // ***********  MC info ***************
1284   TArrayF mcVertex(3);
1285   mcVertex[0]=9999.; mcVertex[1]=9999.; mcVertex[2]=9999.;
1286   Float_t dNchdy=-999.;
1287
1288   TParticle *part=0;
1289   AliESDVertex *vertexMC=0;
1290   AliStack *stack=0;
1291   if (fReadMC) {
1292     AliMCEventHandler *eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
1293     if (!eventHandler) {
1294       Printf("ERROR: Could not retrieve MC event handler");
1295       return;
1296     }
1297     
1298     AliMCEvent* mcEvent = eventHandler->MCEvent();
1299     if (!mcEvent) {
1300       Printf("ERROR: Could not retrieve MC event");
1301       return;
1302     }
1303     
1304     stack = mcEvent->Stack();
1305     if (!stack) {
1306       AliDebug(AliLog::kError, "Stack not available");
1307       return;
1308     }
1309     
1310     AliHeader* header = mcEvent->Header();
1311     if (!header) {
1312       AliDebug(AliLog::kError, "Header not available");
1313       return;
1314     }
1315     AliGenEventHeader* genHeader = header->GenEventHeader();
1316     genHeader->PrimaryVertex(mcVertex);
1317
1318
1319     Int_t ngenpart = (Int_t)stack->GetNtrack();
1320     //printf("# generated particles = %d\n",ngenpart);
1321     dNchdy=0;
1322     for(Int_t ip=0; ip<ngenpart; ip++) {
1323       part = (TParticle*)stack->Particle(ip);
1324       // keep only electrons, muons, pions, kaons and protons
1325       Int_t apdg = TMath::Abs(part->GetPdgCode());
1326       if(apdg!=11 && apdg!=13 && apdg!=211 && apdg!=321 && apdg!=2212) continue;      
1327       // reject secondaries
1328       if(TMath::Sqrt((part->Vx()-mcVertex[0])*(part->Vx()-mcVertex[0])+(part->Vy()-mcVertex[1])*(part->Vy()-mcVertex[1]))>0.0010) continue;
1329       // reject incoming protons
1330       Double_t energy  = part->Energy();
1331       if(energy>900.) continue;
1332       Double_t pz = part->Pz();
1333       Double_t y = 0.5*TMath::Log((energy+pz+1.e-13)/(energy-pz+1.e-13));
1334       if(TMath::Abs(y)<1.0) dNchdy += 0.5; // count 1/2 of particles in |y|<1
1335     }
1336     //printf("# primary particles = %7.1f\n",dNchdy);
1337   } 
1338   // ***********  MC info ***************
1339   Double_t mcVtxPos[3]={mcVertex[0],mcVertex[1],mcVertex[2]},mcVtxSigma[3]={0,0,0};
1340   vertexMC = new AliESDVertex(mcVtxPos,mcVtxSigma);
1341
1342
1343
1344   //------- event selection --------
1345   Int_t   mincontrSPDvtx=1;
1346   Double_t maxzSPDvtx=20.;
1347   Double_t maxrSPDvtx=1.;
1348   Bool_t useTRKvtx=kTRUE;
1349   Bool_t useSPDvtxifNotTRK=kTRUE;
1350   Int_t   mincontrTRKvtx=1;
1351   //Double_t maxzTRKvtx=20.;
1352   //Double_t maxrTRKvtx=1.;
1353   //------- TPC track selection --------
1354   Int_t    minclsTPC=90;
1355   Double_t maxchi2perTPCcl=4.;
1356   Double_t minEtaInAcc=-0.8; // -0.8
1357   Double_t maxEtaInAcc=0.8; // 0.8
1358   Double_t maxdcaxy=2.4;//2.4;
1359   Double_t maxdcaz=3.2;//3.2;
1360   AliESDtrackCuts* esdtrackCutsTPC = new AliESDtrackCuts("esdtrackCutsTPC");
1361   esdtrackCutsTPC->SetMaxDCAToVertexXY(maxdcaxy);
1362   esdtrackCutsTPC->SetMaxDCAToVertexZ(maxdcaz);
1363   esdtrackCutsTPC->SetDCAToVertex2D(kTRUE);
1364   esdtrackCutsTPC->SetRequireSigmaToVertex(kFALSE);
1365   esdtrackCutsTPC->SetRequireTPCRefit(kFALSE);// cannot do it because status not copied in AliESDtrack::FillTPCOnlyTrack
1366   esdtrackCutsTPC->SetAcceptKinkDaughters(kFALSE);
1367   esdtrackCutsTPC->SetMinNClustersTPC(minclsTPC);
1368   esdtrackCutsTPC->SetMaxChi2PerClusterTPC(maxchi2perTPCcl);
1369   esdtrackCutsTPC->SetEtaRange(minEtaInAcc,maxEtaInAcc);
1370   SetESDtrackCutsTPC(esdtrackCutsTPC);
1371   //------- ITS+TPC track selection --------
1372   Double_t maxdcaxyITSTPC=0.2;
1373   Double_t maxdcazITSTPC=1.e6;
1374   AliESDtrackCuts* esdtrackCutsITSTPC = new AliESDtrackCuts("esdtrackCutsITSTPC");
1375   esdtrackCutsITSTPC->SetMaxDCAToVertexXY(maxdcaxyITSTPC);
1376   esdtrackCutsITSTPC->SetMaxDCAToVertexZ(maxdcazITSTPC);
1377   esdtrackCutsITSTPC->SetDCAToVertex2D(kFALSE);
1378   esdtrackCutsITSTPC->SetRequireSigmaToVertex(kFALSE);
1379   esdtrackCutsITSTPC->SetRequireITSRefit(kTRUE);
1380   esdtrackCutsITSTPC->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
1381                                                AliESDtrackCuts::kAny);
1382   esdtrackCutsITSTPC->SetAcceptKinkDaughters(kFALSE);
1383   esdtrackCutsITSTPC->SetMinNClustersTPC(minclsTPC);
1384   esdtrackCutsITSTPC->SetMaxChi2PerClusterTPC(maxchi2perTPCcl);
1385   esdtrackCutsITSTPC->SetEtaRange(minEtaInAcc,maxEtaInAcc);
1386   SetESDtrackCutsITSTPC(esdtrackCutsITSTPC);
1387   //---------------------------------------
1388   
1389
1390   //
1391   
1392   /*  
1393   // **********  Trigger *****************
1394   ULong64_t triggerMask;
1395   ULong64_t spdFO = (1 << 14);
1396   ULong64_t v0left = (1 << 11);
1397   ULong64_t v0right = (1 << 12);
1398   
1399   triggerMask=fESD->GetTriggerMask();
1400   // MB1: SPDFO || V0L || V0R
1401   Bool_t eventTriggered = (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right))); 
1402   //MB2: GFO && V0R
1403   //triggerMask & spdFO && ((triggerMask&v0left) || (triggerMask&v0right))
1404   // ************ Trigger ******************
1405   if(!eventTriggered) return;
1406   */
1407
1408
1409   fHistNEvents->Fill(0);
1410
1411   // SPD vertex
1412   const AliESDVertex *spdv=fESD->GetPrimaryVertexSPD();
1413   // Select good SPD vertices
1414   TString spdvtitle=spdv->GetTitle();
1415   //if(!spdvtitle.Contains("3D")) return;
1416   if(spdv->GetNContributors()<mincontrSPDvtx ||
1417      TMath::Abs(spdv->GetZv())>maxzSPDvtx ||  
1418      spdv->GetXv()*spdv->GetXv()+spdv->GetYv()*spdv->GetYv()>maxrSPDvtx) {
1419     delete esdtrackCutsTPC; esdtrackCutsTPC=0;
1420     delete esdtrackCutsITSTPC; esdtrackCutsITSTPC=0;
1421     return;
1422   }
1423
1424
1425   //
1426   // Tracks vertex
1427   const AliESDVertex *vertexESD = fESD->GetPrimaryVertexTracks();
1428
1429
1430   if(spdvtitle.Contains("3D")) {
1431     fHistNEvents->Fill(1);
1432     fHistNEvents->Fill(3);
1433   } else {
1434     fHistNEvents->Fill(2);
1435     fHistNEvents->Fill(3);
1436   }
1437   if(vertexESD) {
1438     if(vertexESD->GetStatus()) fHistNEvents->Fill(4);
1439   }
1440
1441   Int_t ntracks = fESD->GetNumberOfTracks();
1442   printf("Tracks # = %d\n",fESD->GetNumberOfTracks());
1443
1444   fHistNtracks->Fill(ntracks);
1445   // Post the data already here
1446   PostData(1, fOutput);
1447
1448   Int_t idet,status; Float_t xloc,zloc;
1449   Double_t rSPDouter=7.6,rSDDouter=23.9,rSSDouter=43.1;  
1450   Double_t zSPDouter=14.1,zSDDouter=29.7,zSSDouter=48.9;  
1451
1452   // loop on tracks
1453   for(Int_t itr=0; itr<ntracks; itr++) {
1454     AliESDtrack *track = fESD->GetTrack(itr);
1455     // remove kink daughters
1456     if(track->GetKinkIndex(0)>0) continue;
1457
1458     // remove tracks not reco in ITS or TPC
1459     if (!(track->GetStatus() & AliESDtrack::kITSin) &&
1460         !(track->GetStatus() & AliESDtrack::kTPCin)) continue;
1461
1462     Bool_t isPrimary=kTRUE,isFromMat=kFALSE,isFromStrange=kFALSE;
1463     Double_t rProdVtx=0,zProdVtx=0;
1464     Int_t pdgTrk=0,pdgMoth=0;
1465     Int_t nClsMCSPD=0;
1466   
1467     Int_t trkLabel = TMath::Abs(track->GetLabel());
1468     // check if it is primary
1469     if(fReadMC && stack) {
1470       isPrimary = stack->IsPhysicalPrimary(trkLabel);
1471       part = (TParticle*)stack->Particle(trkLabel);
1472       rProdVtx = TMath::Sqrt((part->Vx()-mcVertex[0])*(part->Vx()-mcVertex[0])+(part->Vy()-mcVertex[1])*(part->Vy()-mcVertex[1]));
1473       zProdVtx = TMath::Abs(part->Vz()-mcVertex[2]);
1474       //if(rProdVtx<2.8) isPrimary=kTRUE; // this could be tried
1475       pdgTrk = TMath::Abs(part->GetPdgCode());
1476       if(part->GetFirstMother()>=0) {
1477         TParticle* mm=stack->Particle(part->GetFirstMother());
1478         if(mm) pdgMoth = TMath::Abs(mm->GetPdgCode());
1479       }
1480       if(pdgMoth==310 || pdgMoth==321 || pdgMoth==3122 || pdgMoth==3312) isFromStrange=kTRUE;
1481       if(pdgMoth==211 || pdgMoth==22 || pdgMoth==2112 || pdgMoth==2212) isFromMat=kTRUE;
1482       nClsMCSPD = NumberOfITSClustersMC(trkLabel,240);
1483     }
1484
1485     Bool_t itsrefit=kFALSE,tpcrefit=kFALSE,itsfindable=kFALSE,itsfindableAcc=kFALSE;
1486     if ((track->GetStatus() & AliESDtrack::kITSrefit)) itsrefit=kTRUE;
1487     if ((track->GetStatus() & AliESDtrack::kTPCrefit)) tpcrefit=kTRUE;
1488     //if ((track->GetStatus() & AliESDtrack::kTPCin)) tpcrefit=kTRUE;
1489
1490     // remove tracks with kTPCin and not kTPCrefit 
1491     if ((track->GetStatus() & AliESDtrack::kTPCin) && !tpcrefit) continue;
1492
1493     AliESDtrack *trackTPC = 0;
1494     if(tpcrefit) trackTPC = AliESDtrackCuts::GetTPCOnlyTrack(fESD,itr);
1495     if(trackTPC) trackTPC->RelateToVertex(spdv,fESD->GetMagneticField(),100.); // relate it to the SPD vertex
1496    
1497
1498     Int_t nclsITS = track->GetNcls(0);
1499     Int_t nclsSDDSSD = 0;
1500     Int_t nclsokbadoutinzITS = 0;
1501     Bool_t outInZ=kFALSE;
1502     Bool_t skipTrack=kFALSE;
1503
1504     for(Int_t layer=0; layer<6; layer++) {
1505       if(layer>=2 && track->HasPointOnITSLayer(layer)) nclsSDDSSD++;
1506       if(layer==0 && !track->HasPointOnITSLayer(1)) continue;
1507       if(layer==1 && !track->HasPointOnITSLayer(0)) continue;
1508       track->GetITSModuleIndexInfo(layer,idet,status,xloc,zloc);
1509       if(status<0) continue;
1510       if(layer>=2) idet+=240; // add n SPD modules
1511       if(layer>=4) idet+=260; // add n SDD modules
1512       if(status==4) outInZ=kTRUE;
1513       
1514       if(layer==1 && tpcrefit && itsrefit) {
1515         Double_t xyz[3];
1516         track->GetXYZAt(rSPDouter,fESD->GetMagneticField(),xyz);
1517         if(status==1) {
1518           if(idet%4==0) fHistZatSPDouter0ok->Fill(xyz[2]);
1519           if(idet%4==1) fHistZatSPDouter1ok->Fill(xyz[2]);
1520           if(idet%4==2) fHistZatSPDouter2ok->Fill(xyz[2]);
1521           if(idet%4==3) fHistZatSPDouter3ok->Fill(xyz[2]);
1522         }
1523         if(status==2 || status==5) {
1524           if(idet%4==0) fHistZatSPDouter0notok->Fill(xyz[2]);
1525           if(idet%4==1) fHistZatSPDouter1notok->Fill(xyz[2]);
1526           if(idet%4==2) fHistZatSPDouter2notok->Fill(xyz[2]);
1527           if(idet%4==3) fHistZatSPDouter3notok->Fill(xyz[2]);
1528         }
1529       }
1530       // kill SDD clusters in MC
1531       if(fReadMC && (layer==2 || layer==3)) {
1532         Double_t qITS[4]; track->GetITSdEdxSamples(qITS);
1533         Double_t conv=3.34/5.43; 
1534         if(layer==2 && status==1 && qITS[0]*conv < 30.) status=5;
1535         if(layer==3 && status==1 && qITS[1]*conv < 30.) status=5;
1536       }
1537       if(tpcrefit) {
1538         if(trackTPC) if(!fESDtrackCutsTPC->AcceptTrack(trackTPC)) continue;
1539         if(status==1) fHistClusterMapITSMIok->Fill(layer);
1540         if(status==2) fHistClusterMapITSMIbad->Fill(layer);
1541         if(status==3) fHistClusterMapITSMIskipped->Fill(layer);
1542         if(status==4) fHistClusterMapITSMIoutinz->Fill(layer);
1543         if(status==5) fHistClusterMapITSMInocls->Fill(layer);
1544         if(status==6) fHistClusterMapITSMInorefit->Fill(layer);
1545         if(status==1 && !outInZ) fHistClusterMapModuleITSMIokInAcc->Fill(idet);
1546         if((status==2 || status==7) && !outInZ) fHistClusterMapModuleITSMIbadInAcc->Fill(idet);
1547         if(status==5 && !outInZ) fHistClusterMapModuleITSMInoclsInAcc->Fill(idet);
1548         if(status==1 || status==2 || status==4) {
1549           fHistClusterMapITSMIokoutinzbad->Fill(layer);
1550           nclsokbadoutinzITS++;
1551         }
1552         /*if(idet>=80 && idet<120) {
1553           Double_t xyz[3];
1554           track->GetXYZAt(6.8,fESD->GetMagneticField(),xyz);
1555           printf("det %d status %d phi %f z %f zloc %f xloc %f\n",idet,status,TMath::ATan2(xyz[1],xyz[0]),xyz[2],zloc,xloc);
1556           }*/
1557         if((layer==2 || layer==3) && status!=2 && status!=4) {
1558           //Float_t xlocCls;
1559           //Int_t nClsInMod = NumberOfITSClusters(idet,xlocCls);
1560           fHistxlocSDDall->Fill(xloc);
1561           fHistzlocSDDall->Fill(zloc);
1562           if(status==1  /*nClsInMod>0*/) {
1563             fHistxlocSDDok->Fill(xloc);
1564             fHistxlocVSmodSDDok->Fill(idet,xloc);
1565             fHistzlocSDDok->Fill(zloc);
1566           }     
1567         }
1568       } else {
1569         if(status==1) fHistClusterMapITSSAok->Fill(layer);
1570         if(status==2) fHistClusterMapITSSAbad->Fill(layer);
1571         if(status==3) fHistClusterMapITSSAskipped->Fill(layer);
1572         if(status==4) fHistClusterMapITSSAoutinz->Fill(layer);
1573         if(status==5) fHistClusterMapITSSAnocls->Fill(layer);
1574         if(status==6) fHistClusterMapITSSAnorefit->Fill(layer);
1575         if(status==1 || status==2 || status==4) fHistClusterMapITSSAokoutinzbad->Fill(layer);
1576         if(status==1 && !outInZ) {fHistClusterMapITSSAokInAcc->Fill(layer);fHistClusterMapModuleITSSAokInAcc->Fill(idet);}
1577         if((status==2 || status==7) && !outInZ) {fHistClusterMapITSSAbadInAcc->Fill(layer);fHistClusterMapModuleITSSAbadInAcc->Fill(idet);}
1578         if(status==3 && !outInZ) fHistClusterMapITSSAskippedInAcc->Fill(layer);
1579         if(status==4 && !outInZ) fHistClusterMapITSSAoutinzInAcc->Fill(layer);
1580         if(status==5 && !outInZ) {fHistClusterMapITSSAnoclsInAcc->Fill(layer);fHistClusterMapModuleITSSAnoclsInAcc->Fill(idet);}
1581         if(status==6 && !outInZ) fHistClusterMapITSSAnorefitInAcc->Fill(layer);
1582         if((status==1 || status==2 || status==4) && !outInZ) fHistClusterMapITSSAokoutinzbadInAcc->Fill(layer);
1583       }
1584       if(TESTBIT(track->GetITSClusterMap(),layer)) {
1585         if(tpcrefit) {
1586           fHistClusterMapITSMI->Fill(layer);
1587         } else {
1588           fHistClusterMapITSSA->Fill(layer);
1589           if(!outInZ) fHistClusterMapITSSAInAcc->Fill(layer);
1590         }
1591       }
1592       /*    
1593       // SKIP SDD MODULES LOW EFF
1594       if(
1595          idet==246 ||
1596          idet==247 ||
1597          idet==256 ||
1598          idet==261 ||
1599          idet==267 ||
1600          idet==333 ||
1601          idet==343 ||
1602          idet==346 ||
1603          idet==349 ||
1604          idet==376 ||
1605          idet==390 ||
1606          idet==392 ||
1607          idet==409 ||
1608          idet==411 ||
1609          idet==464 ||
1610          idet==468 ||
1611          idet==474 ||
1612          idet==469
1613          ) 
1614         skipTrack=kTRUE;
1615       */
1616          /*
1617       if(
1618          idet==245
1619          || idet==248
1620          || idet==253
1621          || idet==264
1622          || idet==276
1623          || idet==286
1624          || idet==287
1625          || idet==292
1626          || idet==295
1627          || idet==302
1628          || idet==305
1629          || idet==307
1630          || idet==315
1631          || idet==320
1632          || idet==330
1633          || idet==331
1634          || idet==341
1635          || idet==357
1636          || idet==368
1637          || idet==376
1638          || idet==377
1639          || idet==378
1640          || idet==379
1641          || idet==380
1642          || idet==381
1643          || idet==382
1644          || idet==383
1645          || idet==422
1646          || idet==444
1647          || idet==445
1648          || idet==450
1649          || idet==451
1650          || idet==452
1651          || idet==453
1652          || idet==455
1653          || idet==459
1654          || idet==469
1655          || idet==485
1656          || idet==493
1657          || idet==494
1658          || idet==495
1659          || idet==496
1660          || idet==497
1661          || idet==498
1662          || idet==499
1663          ) skipTrack=kTRUE;
1664       // SKIP SDD MODULES LOW EFF
1665       */
1666     }  
1667     if(skipTrack) {delete trackTPC; trackTPC=0; continue;}
1668
1669     // TPC track findable in ITS
1670     if(tpcrefit && trackTPC) { 
1671       if(fESDtrackCutsTPC->AcceptTrack(trackTPC)) {
1672         itsfindable=kTRUE;
1673         Double_t zAtSSDouter=100,zAtSDDouter=100,zAtSPDouter=100;
1674         track->GetZAt(rSSDouter,fESD->GetMagneticField(),zAtSSDouter);
1675         track->GetZAt(rSDDouter,fESD->GetMagneticField(),zAtSDDouter);
1676         track->GetZAt(rSPDouter,fESD->GetMagneticField(),zAtSPDouter);
1677         fHistPtTPC->Fill(track->Pt());  
1678         if(TMath::Abs(zAtSSDouter)<1.*zSSDouter &&
1679            TMath::Abs(zAtSDDouter)<1.*zSDDouter &&
1680            TMath::Abs(zAtSPDouter)<1.*zSPDouter) {
1681           itsfindableAcc=kTRUE;
1682           fHistdEdxVSPtTPCInAcc->Fill(track->Pt(),track->GetTPCsignal());
1683           fHistPtTPCInAcc->Fill(track->Pt());
1684           fHistPtVSphiTPCInAcc->Fill(track->Phi(),track->Pt());
1685           if(!(track->GetStatus()&AliESDtrack::kTRDout)) fHistPtTPCInAccNoTRDout->Fill(track->Pt()); 
1686           if(!(track->GetStatus()&AliESDtrack::kTOFout)) fHistPtTPCInAccNoTOFout->Fill(track->Pt()); 
1687           fHistPtTPCInAccWithPtTPCAtVtx->Fill(trackTPC->Pt());
1688           Double_t pTPCinnerwall[3];
1689           track->GetInnerPxPyPz(pTPCinnerwall);
1690           Double_t ptTPCinnerwall=TMath::Sqrt(pTPCinnerwall[0]*pTPCinnerwall[0]+pTPCinnerwall[1]*pTPCinnerwall[1]);
1691           fHistPtTPCInAccWithPtTPCAtInnerWall->Fill(ptTPCinnerwall);
1692           if(track->GetStatus()&AliESDtrack::kITSrefit && !(track->GetStatus()&AliESDtrack::kTOFout)) fHistDeltaPtTPC->Fill(trackTPC->P(),track->P()-trackTPC->P());
1693           fHistPhiTPCInAcc->Fill(track->Phi());  
1694           if(isPrimary) {
1695             fHistPtTPCInAccP->Fill(track->Pt());
1696             if(pdgTrk==321) fHistPtTPCInAccPfromStrange->Fill(track->Pt());
1697           } else {
1698             fHistPtTPCInAccS->Fill(track->Pt());
1699             if(isFromMat) fHistPtTPCInAccSfromMat->Fill(track->Pt());
1700             if(isFromStrange) fHistPtTPCInAccSfromStrange->Fill(track->Pt());
1701           }  
1702           if(nClsMCSPD==2) fHistPtTPCInAccMCtwoSPD->Fill(track->Pt());
1703           if(nClsMCSPD>=1) fHistPtTPCInAccMConeSPD->Fill(track->Pt());
1704           //if(isPrimary) {fHistRProdVtxInAccP->Fill(rProdVtx);} else {fHistRProdVtxInAccS->Fill(rProdVtx);}
1705         }
1706       }
1707     }
1708
1709
1710     if(useTRKvtx) {
1711       // we need the vertex to compute the impact parameters
1712       if(!vertexESD) {delete trackTPC; trackTPC=0; continue;}
1713       if(!(vertexESD->GetStatus()) || vertexESD->GetNContributors()<mincontrTRKvtx) {
1714         if(useSPDvtxifNotTRK) {
1715           vertexESD = fESD->GetPrimaryVertexSPD();
1716         } else {
1717           delete trackTPC; trackTPC=0; continue;
1718         }
1719       }
1720     }
1721
1722     // track prolonged in ITS with different conditions
1723     if(itsrefit) {
1724       if(itsfindable) {
1725         if(nclsITS==6) fHistPtITSMI6->Fill(track->Pt());
1726         if(nclsITS==5) fHistPtITSMI5->Fill(track->Pt());
1727         if(nclsITS==4) fHistPtITSMI4->Fill(track->Pt());
1728         if(nclsITS==3) fHistPtITSMI3->Fill(track->Pt());
1729         if(nclsITS==2) fHistPtITSMI2->Fill(track->Pt());
1730         if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1))
1731           fHistPtITSMISPD->Fill(track->Pt());
1732         if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1))
1733           fHistPtITSMIoneSPD->Fill(track->Pt());
1734         if(nclsokbadoutinzITS==6) fHistPtITSMIokbadoutinz6->Fill(track->Pt());
1735       }
1736       if(itsfindableAcc) {
1737         if(nclsITS==6) {
1738           fHistPtITSMI6InAcc->Fill(track->Pt());
1739           if(isPrimary) {fHistPtITSMI6InAccP->Fill(track->Pt());} else {fHistPtITSMI6InAccS->Fill(track->Pt());}  
1740         }
1741         if(nclsITS==5) {
1742           fHistPtITSMI5InAcc->Fill(track->Pt());
1743           if(isPrimary) {fHistPtITSMI5InAccP->Fill(track->Pt());} else {fHistPtITSMI5InAccS->Fill(track->Pt());}  
1744         }
1745         if(nclsITS==4) {
1746           fHistPtITSMI4InAcc->Fill(track->Pt());
1747           if(isPrimary) {fHistPtITSMI4InAccP->Fill(track->Pt());} else {fHistPtITSMI4InAccS->Fill(track->Pt());}  
1748         }
1749         if(nclsITS==3) {
1750           fHistPtITSMI3InAcc->Fill(track->Pt());
1751           if(isPrimary) {fHistPtITSMI3InAccP->Fill(track->Pt());} else {fHistPtITSMI3InAccS->Fill(track->Pt());}  
1752         }
1753         if(nclsITS==2) {
1754           fHistPtITSMI2InAcc->Fill(track->Pt());
1755           if(isPrimary) {fHistPtITSMI2InAccP->Fill(track->Pt());} else {fHistPtITSMI2InAccS->Fill(track->Pt());}  
1756         }
1757         if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)) {
1758           fHistPtITSMISPDInAcc->Fill(track->Pt());
1759           if(isPrimary) {fHistPtITSMISPDInAccP->Fill(track->Pt());} else {fHistPtITSMISPDInAccS->Fill(track->Pt());}  
1760         }
1761         if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) {
1762           fHistPtITSMIoneSPDInAcc->Fill(track->Pt());
1763           if(nclsSDDSSD>=3) fHistPtITSMIoneSPDthreeSDDSSDInAcc->Fill(track->Pt());
1764
1765           if(isPrimary) {fHistPtITSMIoneSPDInAccP->Fill(track->Pt());} else {fHistPtITSMIoneSPDInAccS->Fill(track->Pt());}  
1766         }
1767         if(nclsokbadoutinzITS==6) fHistPtITSMIokbadoutinz6InAcc->Fill(track->Pt());
1768         if(nclsokbadoutinzITS==5) fHistPtITSMIokbadoutinz5InAcc->Fill(track->Pt());
1769         if(nclsokbadoutinzITS==4) fHistPtITSMIokbadoutinz4InAcc->Fill(track->Pt());
1770         if(nclsokbadoutinzITS==6) fHistPhiITSMIokbadoutinz6InAcc->Fill(track->Phi());  
1771       }
1772     }
1773
1774     if(tpcrefit) {
1775       fHistNclsITSMI->Fill(nclsITS);
1776     } else {
1777       fHistNclsITSSA->Fill(nclsITS);
1778       if(!outInZ) fHistNclsITSSAInAcc->Fill(nclsITS);
1779     }
1780
1781     
1782     if((tpcrefit && fUseITSSAforNtuples) || // only ITS-SA for ntuples
1783        (!tpcrefit && !fUseITSSAforNtuples)) // only ITS-TPC for ntuples
1784       { delete trackTPC; trackTPC=0; continue; }
1785
1786     // impact parameter to VertexTracks
1787     Float_t d0z0[2],covd0z0[3];
1788     Double_t d0z0TPC[2],covd0z0TPC[3];
1789     if(useTRKvtx) {
1790       if(!track->RelateToVertex(vertexESD,fESD->GetMagneticField(),kVeryBig)) { delete trackTPC; trackTPC=0; continue; }
1791     } else { 
1792       //if(!track->RelateToVertex(vertexMC,fESD->GetMagneticField(),kVeryBig)) continue;
1793       if(!track->RelateToVertex(spdv,fESD->GetMagneticField(),kVeryBig)) { delete trackTPC; trackTPC=0; continue; }
1794     } 
1795     track->GetImpactParameters(d0z0,covd0z0);
1796     if(trackTPC) trackTPC->PropagateToDCA(spdv,fESD->GetMagneticField(),kVeryBig,d0z0TPC,covd0z0TPC);
1797     if(covd0z0[0]<0. || covd0z0[2]<0. || covd0z0TPC[0]<0. || covd0z0TPC[2]<0.) { delete trackTPC; trackTPC=0; continue; }
1798
1799
1800     // track that passes final ITS+TPC cuts
1801     if(itsfindableAcc && fESDtrackCutsITSTPC->AcceptTrack(track)) {
1802       fHistPtITSTPCsel->Fill(track->Pt());
1803       fHistdEdxVSPtITSTPCsel->Fill(track->Pt(),track->GetITSsignal());
1804       if(isPrimary) {
1805         fHistPtITSTPCselP->Fill(track->Pt());
1806         if(pdgTrk==321) fHistPtITSTPCselPfromStrange->Fill(track->Pt());
1807       } else {
1808         fHistPtITSTPCselS->Fill(track->Pt());
1809         if(isFromMat) fHistPtITSTPCselSfromMat->Fill(track->Pt());
1810         if(isFromStrange) fHistPtITSTPCselSfromStrange->Fill(track->Pt());
1811       }  
1812     }
1813     
1814
1815     // fill d0 histos
1816     if(((!fUseITSSAforNtuples&&itsfindableAcc) || fUseITSSAforNtuples) /*&& track->Charge()>0*/) {
1817       if(track->Pt()>0.150 && track->Pt()<0.200) {
1818         if(isPrimary) {
1819           fHistd0rphiTPCInAccP150200->Fill(d0z0TPC[0]);
1820           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1821             fHistd0rphiITSMISPDInAccP150200->Fill(d0z0[0]);
1822           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1823             //if(((track->HasPointOnITSLayer(0) && !track->HasPointOnITSLayer(1)) || (!track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1))) && itsrefit) {
1824             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP150200->Fill(d0z0[0]);
1825             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccP150200->Fill(d0z0[1]);
1826           }
1827         } else {
1828           fHistd0rphiTPCInAccS150200->Fill(d0z0TPC[0]);
1829           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1830             fHistd0rphiITSMISPDInAccS150200->Fill(d0z0[0]);
1831           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1832             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1833               fHistd0rphiITSMIoneSPDInAccS150200->Fill(d0z0[0]);
1834               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS150200fromStrange->Fill(d0z0[0]);
1835               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS150200fromMat->Fill(d0z0[0]);
1836             }
1837             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccS150200->Fill(d0z0[1]);
1838             if(TMath::Abs(d0z0[0])<0.1) fHistPDGMoth150200->Fill(pdgMoth);
1839           }
1840         }
1841       }
1842       if(track->Pt()>0.350 && track->Pt()<0.450) {
1843         if(isPrimary) {
1844           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1845             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP350450->Fill(d0z0[0]);
1846           }
1847         } else {
1848           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1849             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1850               fHistd0rphiITSMIoneSPDInAccS350450->Fill(d0z0[0]);
1851               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS350450fromStrange->Fill(d0z0[0]);
1852               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS350450fromMat->Fill(d0z0[0]);
1853             }
1854           }
1855         }
1856       }
1857       if(track->Pt()>0.500 && track->Pt()<0.700) {
1858         if(isPrimary) {
1859           fHistd0rphiTPCInAccP500700->Fill(d0z0TPC[0]);
1860           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1861             fHistd0rphiITSMISPDInAccP500700->Fill(d0z0[0]);
1862           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1863             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP500700->Fill(d0z0[0]);
1864             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccP500700->Fill(d0z0[1]);
1865           }
1866         } else {
1867           fHistd0rphiTPCInAccS500700->Fill(d0z0TPC[0]);
1868           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1869             fHistd0rphiITSMISPDInAccS500700->Fill(d0z0[0]);
1870           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1871             fHistPDGTrk->Fill(pdgTrk);
1872             fHistPDGMoth->Fill(pdgMoth);
1873             if(TMath::Abs(d0z0[0])<0.1) fHistPDGMoth500700->Fill(pdgMoth);
1874             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1875               fHistd0rphiITSMIoneSPDInAccS500700->Fill(d0z0[0]);
1876               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS500700fromStrange->Fill(d0z0[0]);
1877               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS500700fromMat->Fill(d0z0[0]);
1878             }
1879             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccS500700->Fill(d0z0[1]);
1880             if(pdgMoth==310) fHistd0rphiITSMIoneSPDInAccS500700from310->Fill(d0z0[0]);
1881             if(pdgMoth==321) fHistd0rphiITSMIoneSPDInAccS500700from321->Fill(d0z0[0]);
1882             if(pdgMoth==3122) fHistd0rphiITSMIoneSPDInAccS500700from3122->Fill(d0z0[0]);
1883             if(pdgMoth==211) fHistd0rphiITSMIoneSPDInAccS500700from211->Fill(d0z0[0]);
1884             if(pdgMoth==22) fHistd0rphiITSMIoneSPDInAccS500700from22->Fill(d0z0[0]);
1885             if(pdgMoth==211 && TMath::Abs(d0z0[0])>0.5) fHistRProdVtxInAccS->Fill(rProdVtx);
1886           }
1887         }
1888       }
1889       if(track->Pt()>1.000 && track->Pt()<1.500) {
1890         if(isPrimary) {
1891           fHistd0rphiTPCInAccP10001500->Fill(d0z0TPC[0]);
1892           fHistd0zVSetaTPCInAccP10001500->Fill(d0z0TPC[1],trackTPC->Eta());
1893
1894           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1895             fHistd0rphiITSMISPDInAccP10001500->Fill(d0z0[0]);
1896           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1897             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP10001500->Fill(d0z0[0]);
1898             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccP10001500->Fill(d0z0[1]);
1899             fHistd0rphiVSphiITSMIoneSPDInAccP10001500->Fill(d0z0[0],track->Phi());
1900             fHistd0rphiVSetaITSMIoneSPDInAccP10001500->Fill(d0z0[0],track->Eta());
1901           }
1902         } else {
1903           fHistd0rphiTPCInAccS10001500->Fill(d0z0TPC[0]);
1904           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1) && itsrefit)
1905             fHistd0rphiITSMISPDInAccS10001500->Fill(d0z0[0]);
1906           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1907             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1908               fHistd0rphiITSMIoneSPDInAccS10001500->Fill(d0z0[0]);
1909               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS10001500fromStrange->Fill(d0z0[0]);
1910               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS10001500fromMat->Fill(d0z0[0]);
1911             }
1912             if(TMath::Abs(d0z0[0])<maxdcaxyITSTPC) fHistd0zITSMIoneSPDInAccS10001500->Fill(d0z0[1]);
1913             if(TMath::Abs(d0z0[0])<0.1) fHistPDGMoth10001500->Fill(pdgMoth);
1914           }
1915         }
1916       }
1917       if(track->Pt()>2.500 && track->Pt()<4.000) {
1918         if(isPrimary) {
1919           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1920             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP25004000->Fill(d0z0[0]);
1921           }
1922         } else {
1923           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1924             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1925               fHistd0rphiITSMIoneSPDInAccS25004000->Fill(d0z0[0]);
1926               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS25004000fromStrange->Fill(d0z0[0]);
1927               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS25004000fromMat->Fill(d0z0[0]);
1928             }
1929           }
1930         }
1931       }
1932       if(track->Pt()>4.000 && track->Pt()<8.000) {
1933         if(isPrimary) {
1934           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1935             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) fHistd0rphiITSMIoneSPDInAccP40008000->Fill(d0z0[0]);
1936           }
1937         } else {
1938           if((track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)) && itsrefit) {
1939             if(TMath::Abs(d0z0[1])<maxdcazITSTPC) {
1940               fHistd0rphiITSMIoneSPDInAccS40008000->Fill(d0z0[0]);
1941               if(isFromStrange) fHistd0rphiITSMIoneSPDInAccS40008000fromStrange->Fill(d0z0[0]);
1942               if(isFromMat) fHistd0rphiITSMIoneSPDInAccS40008000fromMat->Fill(d0z0[0]);
1943             }
1944           }
1945         }
1946       }
1947
1948     }
1949
1950     if(trackTPC) { delete trackTPC; trackTPC=0; }
1951
1952     // encode ITS cluster map, including MC info
1953     Int_t iITSflag=MakeITSflag(track);
1954
1955     // if MC info is available: get particle properties
1956     Float_t ptMC=-999.,pdgMC=-999.,d0MC=-999.;
1957     Double_t d0z0MCv[2]={-999.,-999.},covd0z0MCv[3]={1.,1.,1.};
1958     if(fReadMC) {
1959       part = (TParticle*)stack->Particle(trkLabel);
1960       ptMC=part->Pt();
1961       pdgMC=part->GetPdgCode();
1962       d0MC=ParticleImpParMC(part,vertexMC,0.1*fESD->GetMagneticField());
1963       track->PropagateToDCA(vertexMC,fESD->GetMagneticField(),100.,d0z0MCv,covd0z0MCv);
1964       if(covd0z0MCv[0]<0. || covd0z0MCv[2]<0.) continue;
1965     }
1966
1967     Double_t sigmad0MCv=TMath::Sqrt(covd0z0MCv[0]);
1968     if(!itsrefit) sigmad0MCv *= -1.;
1969     Float_t isPrimaryFl = (isPrimary ? 1. : 0.);
1970     Float_t isTPCSelFl  = (itsfindableAcc ? 1. : 0.);
1971
1972     // fill ntuple with track properties
1973     if(fFillNtuples && SelectPt(track->Pt())) {
1974       Float_t fillArray[22]={track->Pt(),track->Eta(),track->Phi(),d0z0[0],d0z0[1],TMath::Sqrt(covd0z0[0]),TMath::Sqrt(covd0z0[2]),ptMC,pdgMC,pdgMoth,d0MC,d0z0MCv[0],d0z0MCv[1],sigmad0MCv,TMath::Sqrt(covd0z0MCv[2]),(Float_t)iITSflag,isPrimaryFl,isTPCSelFl};
1975       fNtupleESDTracks->Fill(fillArray);
1976     }
1977
1978     //---------------------------------------------    
1979     // AliTrackPoints: alignment checks
1980     // 
1981     if(!fFillNtuples) continue;
1982
1983     const AliTrackPointArray *array = track->GetTrackPointArray();
1984     if(!array) continue;
1985     AliTrackPoint point;
1986     Int_t pointOnLayer[6]={0,0,0,0,0,0};
1987     Int_t indexAssociated[6]={-1,-1,-1,-1,-1,-1},indexExtra=-1;
1988     Bool_t extra=kFALSE;
1989     Int_t layerId,layerExtra=-1;
1990     for(Int_t ipt=0; ipt<array->GetNPoints(); ipt++) {
1991       array->GetPoint(point,ipt);
1992       Float_t r = TMath::Sqrt(point.GetX()*point.GetX()+point.GetY()*point.GetY());
1993
1994       if(r>3 && r<6) {
1995         layerId = 0;
1996       } else if(r>6 && r<8) {
1997         layerId = 1;
1998       } else if(r>8 && r<18) {
1999         layerId = 2;
2000       } else if(r>18 && r<30) {
2001         layerId = 3;
2002       } else if(r>30 && r<40) {
2003         layerId = 4;
2004       } else if(r>40 && r<50) {
2005         layerId = 5;
2006       } else {
2007         layerId=100;
2008       }
2009
2010       // only ITS points
2011       if(layerId>5) continue;
2012
2013       if(!point.IsExtra()) {
2014         pointOnLayer[layerId]++;
2015         indexAssociated[layerId]=ipt;
2016       } else {
2017         // this is an extra cluster
2018         extra=kTRUE;
2019         layerExtra=layerId;
2020         indexExtra=ipt;
2021       }
2022     } // end loop on AliTrackPoints
2023
2024     TString vtitle = spdv->GetTitle();
2025     if(!vtitle.Contains("3D")) continue; 
2026
2027     // SPD tracklet
2028     if(indexAssociated[0]>=0 && indexAssociated[1]>=0) {
2029       AliTrackPoint pointSPD1,pointSPD2;
2030       array->GetPoint(pointSPD1,indexAssociated[0]);
2031       array->GetPoint(pointSPD2,indexAssociated[1]);
2032       Float_t phi=TMath::ATan2(pointSPD2.GetY()-pointSPD1.GetY(),pointSPD2.GetX()-pointSPD1.GetX());
2033       Float_t lambda=TMath::ATan((pointSPD2.GetZ()-pointSPD1.GetZ())/TMath::Sqrt((pointSPD2.GetX()-pointSPD1.GetX())*(pointSPD2.GetX()-pointSPD1.GetX())+(pointSPD2.GetY()-pointSPD1.GetY())*(pointSPD2.GetY()-pointSPD1.GetY())));
2034       Float_t theta=0.5*TMath::Pi()-lambda;
2035       TParticle particle(211,0,0,0,0,0,TMath::Cos(phi),TMath::Sin(phi),TMath::Tan(lambda),10.,pointSPD1.GetX(),pointSPD1.GetY(),pointSPD1.GetZ(),0);
2036       AliESDtrack tracklet(&particle);
2037       Float_t dz[2];
2038       // distance to primary SPD (only if 3D and high multiplicity)
2039       if(spdv->GetNContributors()>10) { 
2040         tracklet.GetDZ(spdv->GetXv(),spdv->GetYv(),spdv->GetZv(),0,dz);
2041         //tracklet.GetDZ(-0.07,0.25,spdv->GetZv(),0,dz);
2042         fNtupleITSAlignSPDTracklets->Fill(phi,theta,0.5*(pointSPD1.GetZ()+pointSPD2.GetZ()),dz[0],dz[1],track->Pt());
2043       }
2044     }
2045
2046     // distance to extra
2047     if(extra && spdv->GetNContributors()>4 && indexAssociated[layerExtra]>-1) {
2048       AliTrackPoint pointExtra,pointAssociated;
2049       array->GetPoint(pointAssociated,indexAssociated[layerExtra]);
2050       array->GetPoint(pointExtra,indexExtra);
2051       Float_t phiExtra = TMath::ATan2(pointExtra.GetY()-spdv->GetYv(),pointExtra.GetX()-spdv->GetXv());
2052       Float_t phiAssociated = TMath::ATan2(pointAssociated.GetY()-spdv->GetYv(),pointAssociated.GetX()-spdv->GetXv());
2053       Float_t rExtra = TMath::Sqrt((pointExtra.GetX()-spdv->GetXv())*(pointExtra.GetX()-spdv->GetXv())+(pointExtra.GetY()-spdv->GetYv())*(pointExtra.GetY()-spdv->GetYv()));
2054       Float_t rAssociated = TMath::Sqrt((pointAssociated.GetX()-spdv->GetXv())*(pointAssociated.GetX()-spdv->GetXv())+(pointAssociated.GetY()-spdv->GetYv())*(pointAssociated.GetY()-spdv->GetYv()));
2055       Float_t dzExtra[2];
2056       dzExtra[0] = (phiExtra-phiAssociated)*0.5*(rExtra+rAssociated);
2057       dzExtra[1] = pointExtra.GetZ()-pointAssociated.GetZ()-(rExtra-rAssociated)*(pointAssociated.GetZ()-spdv->GetZv())/rAssociated;
2058       Float_t xlocExtra=-100.,zlocExtra=-100.;
2059       fNtupleITSAlignExtra->Fill(layerExtra,pointExtra.GetX(),pointExtra.GetY(),pointExtra.GetZ(),dzExtra[0],dzExtra[1],xlocExtra,zlocExtra,nclsITS,track->Pt());  
2060     }
2061     
2062     if(trackTPC) { delete trackTPC; trackTPC=0; }
2063   } // end loop on tracks
2064   
2065   if(vertexMC) { delete vertexMC; vertexMC=0; }
2066
2067   delete esdtrackCutsTPC;    esdtrackCutsTPC=0;
2068   delete esdtrackCutsITSTPC; esdtrackCutsITSTPC=0;
2069
2070   return;
2071 }      
2072
2073 //________________________________________________________________________
2074 void AliAnalysisTaskITSTrackingCheck::Terminate(Option_t *) 
2075 {
2076   // Draw result to the screen
2077   // Called once at the end of the query
2078   fOutput = dynamic_cast<TList*> (GetOutputData(1));
2079   if (!fOutput) {     
2080     Printf("ERROR: fOutput not available");
2081     return;
2082   }
2083   fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEvents"));
2084   fHistNEventsFrac = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEventsFrac"));
2085   if(fHistNEvents && fHistNEventsFrac) {
2086     for(Int_t ibin=2; ibin<=fHistNEvents->GetNbinsX(); ibin++) {
2087       if(fHistNEvents->GetBinContent(2)) fHistNEventsFrac->SetBinContent(ibin,fHistNEvents->GetBinContent(ibin)/fHistNEvents->GetBinContent(2)); 
2088     }
2089   }
2090
2091   return;
2092 }
2093 //---------------------------------------------------------------------------
2094 Int_t AliAnalysisTaskITSTrackingCheck::NumberOfITSClustersMC(Int_t label,Int_t nModules) const
2095 {
2096   //
2097   // Return number of ITS clusters produced by MC particle with given label
2098   //
2099   
2100   AliESDInputHandlerRP *esdHRP = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
2101   if(!esdHRP) return -1;
2102   TTree *cTree = (TTree*)esdHRP->GetTreeR("ITS");
2103   if(!cTree) return -1;
2104   TClonesArray *clusters=0;
2105   cTree->SetBranchAddress("ITSRecPoints",&clusters);
2106   if(!clusters) return -1;
2107
2108   AliITSRecPoint *c=0;
2109   Int_t i,n,icl,lay,ilab;
2110   Int_t ncls[6]={0,0,0,0,0,0};
2111   Int_t nclstot=0;
2112
2113   for(i=0; i<nModules; i++) {
2114     cTree->GetEvent(i);
2115     n=clusters->GetEntriesFast();
2116     for (icl=0; icl<n; icl++) {
2117       c=(AliITSRecPoint*)clusters->UncheckedAt(icl);
2118       lay=c->GetLayer();
2119       //printf("mod %d lay %d xloc %f zloc %f\n",i,lay,c->GetDetLocalX(),c->GetDetLocalZ());
2120       for(ilab=0;ilab<3;ilab++) {
2121         if(c->GetLabel(ilab)==label) ncls[lay]++;
2122       }
2123     }
2124   }
2125   for(i=0;i<6;i++) { 
2126     //printf("%d\n",ncls[i]); 
2127     if(ncls[i]) nclstot++; 
2128   }
2129
2130   return nclstot;
2131 }
2132 //---------------------------------------------------------------------------
2133 Int_t AliAnalysisTaskITSTrackingCheck::NumberOfITSClusters(Int_t idet,Float_t &xloc) const
2134 {
2135   //
2136   // Return number of ITS clusters produced by MC particle with given label
2137   //
2138   
2139   AliESDInputHandlerRP *esdHRP = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
2140   if(!esdHRP) return -1;
2141   TTree *cTree = (TTree*)esdHRP->GetTreeR("ITS");
2142   if(!cTree) return -1;
2143   TClonesArray *clusters=0;   // new TClonesArray("AliITSRecPoint",10000);
2144   cTree->SetBranchAddress("ITSRecPoints",&clusters);
2145   if(!clusters) return -1;
2146
2147   AliITSRecPoint *c=0;
2148   Int_t n,icl;
2149
2150   cTree->GetEvent(idet);
2151   n=clusters->GetEntriesFast();
2152
2153   if(n==1) {
2154     for (icl=0; icl<n; icl++) {
2155       c=(AliITSRecPoint*)clusters->UncheckedAt(icl);
2156       xloc = c->GetDetLocalX();
2157     }
2158   }
2159   return n;
2160 }
2161 //---------------------------------------------------------------------------
2162 Double_t AliAnalysisTaskITSTrackingCheck::ParticleImpParMC(TParticle *part,
2163                                                            AliESDVertex *vert,
2164                                                            Double_t bzT) const
2165 {
2166   //
2167   // Return the MC value of the impact parameter
2168   //
2169  
2170   Double_t vx=part->Vx()-vert->GetX();
2171   Double_t vy=part->Vy()-vert->GetY();
2172       
2173   Double_t pt=part->Pt();     
2174   Double_t px=part->Px();     
2175   Double_t py=part->Py();     
2176   Double_t charge = (part->GetPdgCode()>0. ? 1. : -1.);
2177   if(TMath::Abs(part->GetPdgCode())<100) charge*=-1.;
2178
2179   if(px<0.000001) px=0.000001;     
2180   Double_t rAnd=((10./2.99792458)*pt/bzT)*100.;
2181   Double_t center[3],d0;
2182   center[0]=vx-(1./charge)*rAnd*(py/pt);
2183   center[1]=vy+(1./charge)*rAnd*(px/pt);
2184   center[2]=TMath::Sqrt(center[0]*center[0]+center[1]*center[1]);
2185   d0 = -center[2]+rAnd;
2186
2187   return d0;
2188 }
2189 //---------------------------------------------------------------------------
2190 Bool_t AliAnalysisTaskITSTrackingCheck::SelectPt(Double_t pt)
2191 {
2192   //
2193   // Keep only tracks in given pt bins
2194   // 
2195   Double_t ptlower[11]={0.15,0.29,0.49,0.75,0.9,1.9,3.5,6.5, 9.,19.,27.};
2196   Double_t ptupper[11]={0.16,0.31,0.51,0.85,1.1,2.1,4.5,7.5,11.,21.,33.};
2197
2198   for(Int_t i=0; i<11; i++) {
2199     if(pt>ptlower[i] && pt<ptupper[i]) {
2200       fCountsPerPtBin[i]++;
2201       return kTRUE;
2202     }
2203   }
2204   return kFALSE;
2205   //return kTRUE;
2206 }
2207 //---------------------------------------------------------------------------
2208 Int_t AliAnalysisTaskITSTrackingCheck::MakeITSflag(AliESDtrack *track) const {
2209   //
2210   // ITSflag takes the value 0 if the track has no cluster assigned in the SPDs, 
2211   // 1 (2) if one cluster is assigned in SPD1(2), 3 if two clusters are present. 
2212   // Then the same adding 10,20 or 30 for SDD and 100,200 or 300 for SSD
2213   //
2214   Int_t iITSflag=0;
2215   if(track->HasPointOnITSLayer(0)) iITSflag+=1;
2216   if(track->HasPointOnITSLayer(1)) iITSflag+=2;
2217   if(track->HasPointOnITSLayer(2)) iITSflag+=10;
2218   if(track->HasPointOnITSLayer(3)) iITSflag+=20;
2219   if(track->HasPointOnITSLayer(4)) iITSflag+=100;
2220   if(track->HasPointOnITSLayer(5)) iITSflag+=200;
2221   
2222   if(iITSflag==333 && track->GetNcls(0)<6)
2223     printf(" ERROR %d   %d\n",track->GetNcls(0),track->GetLabel());
2224   
2225   // number of associated ITS clusters
2226   iITSflag += 1000*track->GetNcls(0);
2227   
2228   // number of associated TPC clusters
2229   iITSflag += 100000*track->GetNcls(1);
2230   
2231   // if MC info and is available
2232   // write the number of ITS clusters produced by this track
2233   Int_t nITSclsMC=0;
2234   if(fReadMC && fReadRPLabels) {
2235     nITSclsMC = NumberOfITSClustersMC(TMath::Abs(track->GetLabel()));
2236     if(nITSclsMC>=0) iITSflag += 10000*nITSclsMC;    
2237     // flag fake tracks
2238     if(track->GetLabel()<0) iITSflag *= -1;
2239   }
2240
2241   return iITSflag;
2242 }
2243
2244
2245