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