adabc7c28ce9fbda44de9f6dd26b4c100ebbe50d
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / LambdaK0PbPb / AliAnalysisTaskPerformanceStrange.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 //              AliAnalysisTaskPerformanceStrange class
18 //    This task is for a performance study of V0 identification.
19 //                It works with MC info and ESD tree.
20 //                 Author: H.Ricaud, H.Ricaud@gsi.de
21 //-----------------------------------------------------------------
22
23 #include <Riostream.h>
24
25 #include <stdio.h>
26 #include <iostream>
27 #include "TChain.h"
28 #include "TTree.h"
29 #include "TH1F.h"
30 #include "TH2F.h"
31 //#include "TH3F.h"
32 #include "TF1.h"
33 #include "TList.h"
34 #include "TMath.h"
35 #include "TCanvas.h"
36
37 #include "AliAnalysisManager.h"
38
39 #include "AliPhysicsSelection.h"
40 #include "AliBackgroundSelection.h"
41
42 #include "AliESDVertex.h"
43 #include "AliESDEvent.h"
44 #include "AliESDInputHandler.h"
45 #include "AliESDtrack.h"
46 #include "AliESDv0.h"
47 #include "AliESDtrackCuts.h"
48 #include "AliESDpid.h"
49 #include "AliMultiplicity.h"
50
51 #include "AliAODEvent.h"
52 #include "AliAODVertex.h"
53 #include "AliAODTrack.h"
54 #include "AliAODv0.h"
55 #include "AliAODMCHeader.h"
56 #include "AliAODInputHandler.h"
57
58 //#include "AliV0vertexer.h"
59
60 #include "AliAODMCParticle.h"
61
62 #include "AliMCEventHandler.h"
63 #include "AliMCEvent.h"
64 #include "AliStack.h"
65 #include "AliGenEventHeader.h"
66
67 #include "AliLog.h"
68
69 #include "AliKFVertex.h"
70 #include "AliVertexerTracks.h"
71
72 #include "AliAnalysisTaskPerformanceStrange.h"
73 #include "AliAnalysisCentralitySelector.h"
74
75
76 ClassImp(AliAnalysisTaskPerformanceStrange)
77
78
79 //________________________________________________________________________
80 AliAnalysisTaskPerformanceStrange::AliAnalysisTaskPerformanceStrange()
81 : AliAnalysisTaskSE("TaskStrange"), fAnalysisMC(0), fAnalysisType("infoType"),  fCollidingSystems(0), fUsePID("infoPID"), fUseCut("infoCut"), fESD(0), fListHist(0), fCentrSelector(0),
82
83     fHistMCPrimaryVertexX(0),
84     fHistMCPrimaryVertexY(0),
85     fHistMCPrimaryVertexZ(0),
86     fHistMCMultiplicityPrimary(0),
87     fHistMCMultiplicityTracks(0),
88     fHistMCtracksProdRadiusK0s(0),
89     fHistMCtracksProdRadiusLambda(0),
90     fHistMCtracksProdRadiusAntiLambda(0),
91     fHistMCtracksDecayRadiusK0s(0),
92     fHistMCtracksDecayRadiusLambda(0),
93     fHistMCtracksDecayRadiusAntiLambda(0),
94     fHistMCPtAllK0s(0),
95     fHistMCPtAllLambda(0),
96     fHistMCPtAllAntiLambda(0),
97     fHistMCProdRadiusK0s(0),
98     fHistMCProdRadiusLambda(0),
99     fHistMCProdRadiusAntiLambda(0),
100     fHistMCRapK0s(0),
101     fHistMCRapInPtRangeK0s(0),
102     fHistMCRapLambda(0),
103     fHistMCRapInPtRangeLambda(0),
104     fHistMCRapAntiLambda(0),
105     fHistMCRapInPtRangeAntiLambda(0),
106     fHistMCRapXi(0),
107     fHistMCRapInPtRangeXi(0),
108     fHistMCRapPhi(0),
109     fHistMCRapInPtRangePhi(0),
110 ////////////////////////////////////////
111     fHistMCPtK0s(0),
112
113
114     fHistMCPtLambda(0),
115 ///////////////////////////////////////////
116
117     fHistMCPtLambdaFromSigma(0),
118     fHistMCPtAntiLambdaFromSigma(0),
119     fHistNTimesRecK0s(0),
120 //    fHistNTimesRecK0sMI(0),
121     fHistNTimesRecLambda(0),
122 //    fHistNTimesRecLambdaMI(0),
123     fHistNTimesRecAntiLambda(0),
124 //    fHistNTimesRecAntiLambdaMI(0),
125     fHistNTimesRecK0sVsPt(0),
126 //    fHistNTimesRecK0sVsPtMI(0),
127     fHistNTimesRecLambdaVsPt(0),
128 //    fHistNTimesRecLambdaVsPtMI(0),
129     fHistNTimesRecAntiLambdaVsPt(0),
130 //    fHistNTimesRecAntiLambdaVsPtMI(0),
131     fHistNumberEvents(0),
132     fHistTrackPerEvent(0),
133     fHistTrackletPerEvent(0),
134     fHistMCDaughterTrack(0),
135     fHistSPDPrimaryVertexZ(0),
136     fHistPrimaryVertexX(0),
137     fHistPrimaryVertexY(0),
138     fHistPrimaryVertexZ(0),
139     fHistPrimaryVertexResX(0),
140     fHistPrimaryVertexResY(0),
141     fHistPrimaryVertexResZ(0),
142     fHistPrimaryVertexPosXV0events(0), 
143     fHistPrimaryVertexPosYV0events(0), 
144     fHistPrimaryVertexPosZV0events(0),
145     fHistDaughterPt(0),
146     fHistDcaPosToPrimVertex(0),
147     fHistDcaNegToPrimVertex(0),
148     fHistDcaPosToPrimVertexZoom(0),
149     fHistDcaNegToPrimVertexZoom(0),
150     fHistRadiusV0(0),
151     fHistDecayLengthV0(0),
152     fHistDcaV0Daughters(0),
153     fHistChi2(0),
154     fHistCosPointAngle(0),
155     fHistCosPointAngleZoom(0),
156     fHistProdRadius(0),
157 //    fHistProdRadiusMI(0),
158     fHistV0Multiplicity(0),
159 //    fHistV0MultiplicityMI(0),
160     fHistChi2KFBeforeCutK0s(0), 
161     fHistChi2KFBeforeCutLambda(0), 
162     fHistChi2KFBeforeCutAntiLambda(0),
163     fHistChi2KFAfterCutK0s(0), 
164     fHistChi2KFAfterCutLambda(0), 
165     fHistChi2KFAfterCutAntiLambda(0),
166     fHistMassK0(0),
167 //    fHistMassK0MI(0),
168     fHistMassLambda(0),
169 //    fHistMassLambdaMI(0),
170     fHistMassAntiLambda(0),
171 //    fHistMassAntiLambdaMI(0),
172     fHistMassVsRadiusK0(0),
173 //    fHistMassVsRadiusK0MI(0),
174     fHistMassVsRadiusLambda(0),
175 //    fHistMassVsRadiusLambdaMI(0),
176     fHistMassVsRadiusAntiLambda(0),
177 //    fHistMassVsRadiusAntiLambdaMI(0),
178
179 ///////////////////////////////////////
180     fHistPtVsMassK0(0),
181 //    fHistPtVsMassK0MI(0),
182     fHistPtVsMassLambda(0),
183 ////////////////////////////////////////
184         fHistPzPtBeforeK0s(0),
185         fHistPzPtAfterK0s(0),
186         fHistPzPtBeforeLambda(0),
187         fHistPzPtAfterLambda(0),
188
189 //////////////////////////////////////////
190 //    fHistPtVsMassLambdaMI(0),
191 //    fHistPtVsMassAntiLambda(0),
192 //    fHistPtVsMassAntiLambdaMI(0),
193
194
195
196 //    fHistMultVsPtVsMassK0(0),
197 //    fHistMultVsPtVsMassLambda(0),
198 //    fHistMultVsPtVsMassAntiLambda(0),
199
200
201     fHistArmenterosPodolanski(0),
202 //    fHistArmenterosPodolanskiMI(0),
203     fHistNsigmaPosPionAntiLambda(0),
204     fHistNsigmaNegProtonAntiLambda(0),
205     fHistNsigmaPosProtonLambda(0),
206     fHistNsigmaNegPionLambda(0),
207     fHistNsigmaPosPionK0(0),
208     fHistNsigmaNegPionK0(0),
209     fHistAsMcRapK0(0),
210 //    fHistAsMcRapK0MI(0),
211     fHistAsMcRapLambda(0),
212 //    fHistAsMcRapLambdaMI(0),
213     fHistAsMcRapAntiLambda(0),
214 //    fHistAsMcRapAntiLambdaMI(0),
215
216 /////////////////////////////////////////////
217     fHistAsMcPtK0(0),
218
219 //    fHistAsMcPtK0MI(0),
220     fHistAsMcPtLambda(0),
221 //////////////////////////////////////////////
222
223
224 //    fHistAsMcPtAntiLambdaMI(0),
225     fHistAsMcPtZoomK0(0),
226 //    fHistAsMcPtZoomK0MI(0),
227     fHistAsMcPtZoomLambda(0),
228 //    fHistAsMcPtZoomLambdaMI(0),
229     fHistAsMcProdRadiusK0(0),
230 //    fHistAsMcProdRadiusK0MI(0),
231     fHistAsMcProdRadiusLambda(0),
232 //    fHistAsMcProdRadiusLambdaMI(0),
233     fHistAsMcProdRadiusAntiLambda(0),
234 //    fHistAsMcProdRadiusAntiLambdaMI(0),
235     fHistAsMcProdRadiusXvsYK0s(0),
236 //    fHistAsMcProdRadiusXvsYK0sMI(0),
237     fHistAsMcProdRadiusXvsYLambda(0),
238 //    fHistAsMcProdRadiusXvsYLambdaMI(0),
239     fHistAsMcProdRadiusXvsYAntiLambda(0),
240 //    fHistAsMcProdRadiusXvsYAntiLambdaMI(0),
241     fHistPidMcMassK0(0),
242 //    fHistPidMcMassK0MI(0),
243     fHistPidMcMassLambda(0),
244 //    fHistPidMcMassLambdaMI(0),
245     fHistPidMcMassAntiLambda(0),
246 //    fHistPidMcMassAntiLambdaMI(0),
247     fHistAsMcMassK0(0),
248 //    fHistAsMcMassK0MI(0),
249     fHistAsMcMassLambda(0),
250 //    fHistAsMcMassLambdaMI(0),
251     fHistAsMcMassAntiLambda(0),
252 //    fHistAsMcMassAntiLambdaMI(0),
253     fHistAsMcPtVsMassK0(0),
254 //    fHistAsMcPtVsMassK0MI(0),
255     fHistAsMcPtVsMassLambda(0),
256 //    fHistAsMcPtVsMassLambdaMI(0),
257     fHistAsMcPtVsMassAntiLambda(0),
258 //    fHistAsMcPtVsMassAntiLambdaMI(0),
259     fHistAsMcMassVsRadiusK0(0),
260 //    fHistAsMcMassVsRadiusK0MI(0),
261     fHistAsMcMassVsRadiusLambda(0),
262 //    fHistAsMcMassVsRadiusLambdaMI(0),
263     fHistAsMcMassVsRadiusAntiLambda(0),
264 //    fHistAsMcMassVsRadiusAntiLambdaMI(0),
265     fHistAsMcResxK0(0),
266     fHistAsMcResyK0(0),
267     fHistAsMcReszK0(0),
268     fHistAsMcResrVsRadiusK0(0),
269     fHistAsMcReszVsRadiusK0(0),
270 //    fHistAsMcResxK0MI(0),
271 //    fHistAsMcResyK0MI(0),
272  //   fHistAsMcReszK0MI(0),
273 //    fHistAsMcResrVsRadiusK0MI(0),
274 //    fHistAsMcReszVsRadiusK0MI(0),
275     fHistAsMcResxLambda(0),
276     fHistAsMcResyLambda(0),
277     fHistAsMcReszLambda(0),
278     fHistAsMcResrVsRadiusLambda(0),
279     fHistAsMcReszVsRadiusLambda(0),
280 //    fHistAsMcResxLambdaMI(0),
281 //    fHistAsMcResyLambdaMI(0),
282 //    fHistAsMcReszLambdaMI(0),
283 //    fHistAsMcResrVsRadiusLambdaMI(0),
284 //    fHistAsMcReszVsRadiusLambdaMI(0),
285     fHistAsMcResxAntiLambda(0),
286     fHistAsMcResyAntiLambda(0),
287     fHistAsMcReszAntiLambda(0),
288     fHistAsMcResrVsRadiusAntiLambda(0),
289     fHistAsMcReszVsRadiusAntiLambda(0),
290 //    fHistAsMcResxAntiLambdaMI(0),
291 //    fHistAsMcResyAntiLambdaMI(0),
292 //    fHistAsMcReszAntiLambdaMI(0),
293 //    fHistAsMcResrVsRadiusAntiLambdaMI(0),
294 //    fHistAsMcReszVsRadiusAntiLambdaMI(0),
295     fHistAsMcResPtK0(0),
296 //    fHistAsMcResPtK0MI(0),
297     fHistAsMcResPtLambda(0),
298 //    fHistAsMcResPtLambdaMI(0),
299     fHistAsMcResPtAntiLambda(0),
300 //    fHistAsMcResPtAntiLambdaMI(0),
301     fHistAsMcResPtVsRapK0(0),
302 //    fHistAsMcResPtVsRapK0MI(0),
303     fHistAsMcResPtVsRapLambda(0),
304 //    fHistAsMcResPtVsRapLambdaMI(0),
305     fHistAsMcResPtVsRapAntiLambda(0),
306 //    fHistAsMcResPtVsRapAntiLambdaMI(0),
307     fHistAsMcResPtVsPtK0(0),
308 //    fHistAsMcResPtVsPtK0MI(0),
309     fHistAsMcResPtVsPtLambda(0),
310 //    fHistAsMcResPtVsPtLambdaMI(0),
311     fHistAsMcResPtVsPtAntiLambda(0),
312 //    fHistAsMcResPtVsPtAntiLambdaMI(0),
313     fHistAsMcMotherPdgCodeK0s(0),
314 //    fHistAsMcMotherPdgCodeK0sMI(0),
315     fHistAsMcMotherPdgCodeLambda(0),
316 //    fHistAsMcMotherPdgCodeLambdaMI(0),
317     fHistAsMcMotherPdgCodeAntiLambda(0),
318 //    fHistAsMcMotherPdgCodeAntiLambdaMI(0),
319     fHistAsMcPtLambdaFromSigma(0),
320 //    fHistAsMcPtLambdaFromSigmaMI(0),
321     fHistAsMcPtAntiLambdaFromSigma(0),
322 //    fHistAsMcPtAntiLambdaFromSigmaMI(0),
323     fHistAsMcSecondaryPtVsRapK0s(0),
324 //    fHistAsMcSecondaryPtVsRapK0sMI(0),
325     fHistAsMcSecondaryPtVsRapLambda(0),
326 //    fHistAsMcSecondaryPtVsRapLambdaMI(0),
327     fHistAsMcSecondaryPtVsRapAntiLambda(0),
328 //    fHistAsMcSecondaryPtVsRapAntiLambdaMI(0),
329     fHistAsMcSecondaryProdRadiusK0s(0),
330 //    fHistAsMcSecondaryProdRadiusK0sMI(0),
331     fHistAsMcSecondaryProdRadiusLambda(0),
332 //    fHistAsMcSecondaryProdRadiusLambdaMI(0),
333     fHistAsMcSecondaryProdRadiusAntiLambda(0),
334 //    fHistAsMcSecondaryProdRadiusAntiLambdaMI(0),
335     fHistAsMcSecondaryProdRadiusXvsYK0s(0),
336 //    fHistAsMcSecondaryProdRadiusXvsYK0sMI(0),
337     fHistAsMcSecondaryProdRadiusXvsYLambda(0),
338 //    fHistAsMcSecondaryProdRadiusXvsYLambdaMI(0),
339     fHistAsMcSecondaryProdRadiusXvsYAntiLambda(0),
340 //    fHistAsMcSecondaryProdRadiusXvsYAntiLambdaMI(0),
341     fHistAsMcSecondaryMotherPdgCodeK0s(0),
342 //    fHistAsMcSecondaryMotherPdgCodeK0sMI(0),
343     fHistAsMcSecondaryMotherPdgCodeLambda(0),
344 //    fHistAsMcSecondaryMotherPdgCodeLambdaMI(0),
345     fHistAsMcSecondaryMotherPdgCodeAntiLambda(0),
346 //    fHistAsMcSecondaryMotherPdgCodeAntiLambdaMI(0),
347     fHistAsMcSecondaryPtLambdaFromSigma(0),
348 //    fHistAsMcSecondaryPtLambdaFromSigmaMI(0),
349     fHistAsMcSecondaryPtAntiLambdaFromSigma(0)
350 //    fHistAsMcSecondaryPtAntiLambdaFromSigmaMI(0)
351     
352 {
353   // Constructor
354
355   // New V0 cuts
356 /*  fCuts[0]=33;    // max allowed chi2
357   fCuts[1]=0.05;  // min allowed impact parameter for the 1st daughter
358   fCuts[2]=0.05;  // min allowed impact parameter for the 2nd daughter
359   fCuts[3]=0.5;   // max allowed DCA between the daughter tracks
360   fCuts[4]=0.00;  // max allowed cosine of V0's pointing angle
361   fCuts[5]=0.2;   // min radius of the fiducial volume
362   fCuts[6]=100;   // max radius of the fiducial volume
363 */
364 }
365
366
367
368
369
370 //________________________________________________________________________
371 AliAnalysisTaskPerformanceStrange::AliAnalysisTaskPerformanceStrange(const char *name)
372   : AliAnalysisTaskSE(name), fAnalysisMC(0), fAnalysisType("infoType"), fCollidingSystems(0), fUsePID("infoPID"), fUseCut("infocut"), fESD(0), fListHist(),fCentrSelector(0),
373     fHistMCPrimaryVertexX(0),
374     fHistMCPrimaryVertexY(0),
375     fHistMCPrimaryVertexZ(0),
376     fHistMCMultiplicityPrimary(0),
377     fHistMCMultiplicityTracks(0),
378     fHistMCtracksProdRadiusK0s(0),
379     fHistMCtracksProdRadiusLambda(0),
380     fHistMCtracksProdRadiusAntiLambda(0),
381     fHistMCtracksDecayRadiusK0s(0),
382     fHistMCtracksDecayRadiusLambda(0),
383     fHistMCtracksDecayRadiusAntiLambda(0),
384     fHistMCPtAllK0s(0),
385     fHistMCPtAllLambda(0),
386     fHistMCPtAllAntiLambda(0),
387     fHistMCProdRadiusK0s(0),
388     fHistMCProdRadiusLambda(0),
389     fHistMCProdRadiusAntiLambda(0),
390     fHistMCRapK0s(0),
391     fHistMCRapInPtRangeK0s(0),
392     fHistMCRapLambda(0),
393     fHistMCRapInPtRangeLambda(0),
394     fHistMCRapAntiLambda(0),
395     fHistMCRapInPtRangeAntiLambda(0),
396     fHistMCRapXi(0),
397     fHistMCRapInPtRangeXi(0),
398     fHistMCRapPhi(0),
399     fHistMCRapInPtRangePhi(0),
400
401 ////////////////////////////////////////////////
402     fHistMCPtK0s(0),
403
404     fHistMCPtLambda(0),
405 /////////////////////////////////////////////////
406
407     fHistMCPtLambdaFromSigma(0),
408     fHistMCPtAntiLambdaFromSigma(0),
409     fHistNTimesRecK0s(0),
410 //    fHistNTimesRecK0sMI(0),
411     fHistNTimesRecLambda(0),
412 //    fHistNTimesRecLambdaMI(0),
413     fHistNTimesRecAntiLambda(0),
414 //    fHistNTimesRecAntiLambdaMI(0),
415     fHistNTimesRecK0sVsPt(0),
416 //    fHistNTimesRecK0sVsPtMI(0),
417     fHistNTimesRecLambdaVsPt(0),
418 //    fHistNTimesRecLambdaVsPtMI(0),
419     fHistNTimesRecAntiLambdaVsPt(0),
420 //    fHistNTimesRecAntiLambdaVsPtMI(0),
421     fHistNumberEvents(0),
422     fHistTrackPerEvent(0),
423     fHistTrackletPerEvent(0),
424     fHistMCDaughterTrack(0),
425     fHistSPDPrimaryVertexZ(0),
426     fHistPrimaryVertexX(0),
427     fHistPrimaryVertexY(0),
428     fHistPrimaryVertexZ(0),
429     fHistPrimaryVertexResX(0),
430     fHistPrimaryVertexResY(0),
431     fHistPrimaryVertexResZ(0),
432     fHistPrimaryVertexPosXV0events(0), 
433     fHistPrimaryVertexPosYV0events(0), 
434     fHistPrimaryVertexPosZV0events(0),
435     fHistDaughterPt(0),
436     fHistDcaPosToPrimVertex(0),
437     fHistDcaNegToPrimVertex(0),
438     fHistDcaPosToPrimVertexZoom(0),
439     fHistDcaNegToPrimVertexZoom(0),
440     fHistRadiusV0(0),
441     fHistDecayLengthV0(0),
442     fHistDcaV0Daughters(0),
443     fHistChi2(0),
444     fHistCosPointAngle(0),
445     fHistCosPointAngleZoom(0),
446     fHistProdRadius(0),
447 //    fHistProdRadiusMI(0),
448     fHistV0Multiplicity(0),
449 //    fHistV0MultiplicityMI(0),
450     fHistChi2KFBeforeCutK0s(0), 
451     fHistChi2KFBeforeCutLambda(0), 
452     fHistChi2KFBeforeCutAntiLambda(0),
453     fHistChi2KFAfterCutK0s(0), 
454     fHistChi2KFAfterCutLambda(0), 
455     fHistChi2KFAfterCutAntiLambda(0),
456     fHistMassK0(0),
457 //    fHistMassK0MI(0),
458     fHistMassLambda(0),
459 //    fHistMassLambdaMI(0),
460     fHistMassAntiLambda(0),
461 //    fHistMassAntiLambdaMI(0),
462     fHistMassVsRadiusK0(0),
463 //    fHistMassVsRadiusK0MI(0),
464     fHistMassVsRadiusLambda(0),
465 //    fHistMassVsRadiusLambdaMI(0),
466     fHistMassVsRadiusAntiLambda(0),
467 //    fHistMassVsRadiusAntiLambdaMI(0),
468
469 /////////////////////////////////////////////
470     fHistPtVsMassK0(0),
471 //    fHistPtVsMassK0MI(0),
472     fHistPtVsMassLambda(0),
473 //    fHistPtVsMassLambdaMI(0),
474 ///////////////////////////////////////////////////
475         fHistPzPtBeforeK0s(0),
476         fHistPzPtAfterK0s(0),
477         fHistPzPtBeforeLambda(0),
478         fHistPzPtAfterLambda(0),
479
480 //////////////////////////////////////////
481
482 //    fHistMultVsPtVsMassK0(0),
483 //    fHistMultVsPtVsMassLambda(0),
484 //    fHistMultVsPtVsMassAntiLambda(0),
485
486
487     fHistArmenterosPodolanski(0),
488 //    fHistArmenterosPodolanskiMI(0),
489     fHistNsigmaPosPionAntiLambda(0),
490     fHistNsigmaNegProtonAntiLambda(0),
491     fHistNsigmaPosProtonLambda(0),
492     fHistNsigmaNegPionLambda(0),
493     fHistNsigmaPosPionK0(0),
494     fHistNsigmaNegPionK0(0),
495     fHistAsMcRapK0(0),
496 //    fHistAsMcRapK0MI(0),
497     fHistAsMcRapLambda(0),
498 //    fHistAsMcRapLambdaMI(0),
499     fHistAsMcRapAntiLambda(0),
500 //    fHistAsMcRapAntiLambdaMI(0),
501
502 ///////////////////////////////////
503     fHistAsMcPtK0(0),
504
505
506 //    fHistAsMcPtK0MI(0),
507     fHistAsMcPtLambda(0),
508
509 /////////////////////////////////////
510
511
512 //    fHistAsMcPtAntiLambdaMI(0),
513     fHistAsMcPtZoomK0(0),
514 //    fHistAsMcPtZoomK0MI(0),
515     fHistAsMcPtZoomLambda(0),
516 //    fHistAsMcPtZoomLambdaMI(0),
517     fHistAsMcProdRadiusK0(0),
518 //    fHistAsMcProdRadiusK0MI(0),
519     fHistAsMcProdRadiusLambda(0),
520 //    fHistAsMcProdRadiusLambdaMI(0),
521     fHistAsMcProdRadiusAntiLambda(0),
522 //    fHistAsMcProdRadiusAntiLambdaMI(0),
523     fHistAsMcProdRadiusXvsYK0s(0),
524 //    fHistAsMcProdRadiusXvsYK0sMI(0),
525     fHistAsMcProdRadiusXvsYLambda(0),
526 //    fHistAsMcProdRadiusXvsYLambdaMI(0),
527     fHistAsMcProdRadiusXvsYAntiLambda(0),
528 //    fHistAsMcProdRadiusXvsYAntiLambdaMI(0),
529     fHistPidMcMassK0(0),
530 //    fHistPidMcMassK0MI(0),
531     fHistPidMcMassLambda(0),
532 //    fHistPidMcMassLambdaMI(0),
533     fHistPidMcMassAntiLambda(0),
534 //    fHistPidMcMassAntiLambdaMI(0),
535     fHistAsMcMassK0(0),
536 //    fHistAsMcMassK0MI(0),
537     fHistAsMcMassLambda(0),
538 //    fHistAsMcMassLambdaMI(0),
539     fHistAsMcMassAntiLambda(0),
540 //    fHistAsMcMassAntiLambdaMI(0),
541     fHistAsMcPtVsMassK0(0),
542 //    fHistAsMcPtVsMassK0MI(0),
543     fHistAsMcPtVsMassLambda(0),
544 //    fHistAsMcPtVsMassLambdaMI(0),
545     fHistAsMcPtVsMassAntiLambda(0),
546 //    fHistAsMcPtVsMassAntiLambdaMI(0),
547     fHistAsMcMassVsRadiusK0(0),
548 //    fHistAsMcMassVsRadiusK0MI(0),
549     fHistAsMcMassVsRadiusLambda(0),
550 //    fHistAsMcMassVsRadiusLambdaMI(0),
551     fHistAsMcMassVsRadiusAntiLambda(0),
552 //    fHistAsMcMassVsRadiusAntiLambdaMI(0),
553     fHistAsMcResxK0(0),
554     fHistAsMcResyK0(0),
555     fHistAsMcReszK0(0),
556     fHistAsMcResrVsRadiusK0(0),
557     fHistAsMcReszVsRadiusK0(0),
558 //    fHistAsMcResxK0MI(0),
559 //    fHistAsMcResyK0MI(0),
560  //   fHistAsMcReszK0MI(0),
561 //    fHistAsMcResrVsRadiusK0MI(0),
562 //    fHistAsMcReszVsRadiusK0MI(0),
563     fHistAsMcResxLambda(0),
564     fHistAsMcResyLambda(0),
565     fHistAsMcReszLambda(0),
566     fHistAsMcResrVsRadiusLambda(0),
567     fHistAsMcReszVsRadiusLambda(0),
568 //    fHistAsMcResxLambdaMI(0),
569 //    fHistAsMcResyLambdaMI(0),
570 //    fHistAsMcReszLambdaMI(0),
571 //    fHistAsMcResrVsRadiusLambdaMI(0),
572 //    fHistAsMcReszVsRadiusLambdaMI(0),
573     fHistAsMcResxAntiLambda(0),
574     fHistAsMcResyAntiLambda(0),
575     fHistAsMcReszAntiLambda(0),
576     fHistAsMcResrVsRadiusAntiLambda(0),
577     fHistAsMcReszVsRadiusAntiLambda(0),
578 //    fHistAsMcResxAntiLambdaMI(0),
579 //    fHistAsMcResyAntiLambdaMI(0),
580 //    fHistAsMcReszAntiLambdaMI(0),
581 //    fHistAsMcResrVsRadiusAntiLambdaMI(0),
582 //    fHistAsMcReszVsRadiusAntiLambdaMI(0),
583     fHistAsMcResPtK0(0),
584 //    fHistAsMcResPtK0MI(0),
585     fHistAsMcResPtLambda(0),
586 //    fHistAsMcResPtLambdaMI(0),
587     fHistAsMcResPtAntiLambda(0),
588 //    fHistAsMcResPtAntiLambdaMI(0),
589     fHistAsMcResPtVsRapK0(0),
590 //    fHistAsMcResPtVsRapK0MI(0),
591     fHistAsMcResPtVsRapLambda(0),
592 //    fHistAsMcResPtVsRapLambdaMI(0),
593     fHistAsMcResPtVsRapAntiLambda(0),
594 //    fHistAsMcResPtVsRapAntiLambdaMI(0),
595     fHistAsMcResPtVsPtK0(0),
596 //    fHistAsMcResPtVsPtK0MI(0),
597     fHistAsMcResPtVsPtLambda(0),
598 //    fHistAsMcResPtVsPtLambdaMI(0),
599     fHistAsMcResPtVsPtAntiLambda(0),
600 //    fHistAsMcResPtVsPtAntiLambdaMI(0),
601     fHistAsMcMotherPdgCodeK0s(0),
602 //    fHistAsMcMotherPdgCodeK0sMI(0),
603     fHistAsMcMotherPdgCodeLambda(0),
604 //    fHistAsMcMotherPdgCodeLambdaMI(0),
605     fHistAsMcMotherPdgCodeAntiLambda(0),
606 //    fHistAsMcMotherPdgCodeAntiLambdaMI(0),
607     fHistAsMcPtLambdaFromSigma(0),
608 //    fHistAsMcPtLambdaFromSigmaMI(0),
609     fHistAsMcPtAntiLambdaFromSigma(0),
610 //    fHistAsMcPtAntiLambdaFromSigmaMI(0),
611     fHistAsMcSecondaryPtVsRapK0s(0),
612 //    fHistAsMcSecondaryPtVsRapK0sMI(0),
613     fHistAsMcSecondaryPtVsRapLambda(0),
614 //    fHistAsMcSecondaryPtVsRapLambdaMI(0),
615     fHistAsMcSecondaryPtVsRapAntiLambda(0),
616 //    fHistAsMcSecondaryPtVsRapAntiLambdaMI(0),
617     fHistAsMcSecondaryProdRadiusK0s(0),
618 //    fHistAsMcSecondaryProdRadiusK0sMI(0),
619     fHistAsMcSecondaryProdRadiusLambda(0),
620 //    fHistAsMcSecondaryProdRadiusLambdaMI(0),
621     fHistAsMcSecondaryProdRadiusAntiLambda(0),
622 //    fHistAsMcSecondaryProdRadiusAntiLambdaMI(0),
623     fHistAsMcSecondaryProdRadiusXvsYK0s(0),
624 //    fHistAsMcSecondaryProdRadiusXvsYK0sMI(0),
625     fHistAsMcSecondaryProdRadiusXvsYLambda(0),
626 //    fHistAsMcSecondaryProdRadiusXvsYLambdaMI(0),
627     fHistAsMcSecondaryProdRadiusXvsYAntiLambda(0),
628 //    fHistAsMcSecondaryProdRadiusXvsYAntiLambdaMI(0),
629     fHistAsMcSecondaryMotherPdgCodeK0s(0),
630 //    fHistAsMcSecondaryMotherPdgCodeK0sMI(0),
631     fHistAsMcSecondaryMotherPdgCodeLambda(0),
632 //    fHistAsMcSecondaryMotherPdgCodeLambdaMI(0),
633     fHistAsMcSecondaryMotherPdgCodeAntiLambda(0),
634 //    fHistAsMcSecondaryMotherPdgCodeAntiLambdaMI(0),
635     fHistAsMcSecondaryPtLambdaFromSigma(0),
636 //    fHistAsMcSecondaryPtLambdaFromSigmaMI(0),
637     fHistAsMcSecondaryPtAntiLambdaFromSigma(0)
638 //    fHistAsMcSecondaryPtAntiLambdaFromSigmaMI(0)
639     
640 {
641   // Constructor
642
643   //New V0 cuts
644 /*  fCuts[0]=33;    // max allowed chi2
645   fCuts[1]=0.05;  // min allowed impact parameter for the 1st daughter
646   fCuts[2]=0.05;  // min allowed impact parameter for the 2nd daughter
647   fCuts[3]=0.5;   // max allowed DCA between the daughter tracks
648   fCuts[4]=0.00;  // max allowed cosine of V0's pointing angle
649   fCuts[5]=0.2;   // min radius of the fiducial volume
650   fCuts[6]=100;   // max radius of the fiducial volume
651 */
652   // Define output slots only here
653   // Output slot #1 writes into a TList container
654   DefineOutput(1, TList::Class());
655   DefineOutput(2, AliAnalysisCentralitySelector::Class());
656
657 }
658
659 //________________________________________________________________________
660 void AliAnalysisTaskPerformanceStrange::UserCreateOutputObjects() 
661 {
662
663   //******************
664   // Create histograms
665   //*******************
666   fListHist = new TList();
667   fListHist->SetOwner();
668
669   // Bo: tbd: condition before allocation (i.e. if (!fHistMCMultiplicityPrimary){...} for each histo...
670
671
672
673   //***************
674   // MC histograms
675   //***************
676  
677   // Primary Vertex:
678   fHistMCPrimaryVertexX          = new TH1F("h1MCPrimaryVertexX", "MC Primary Vertex Position X;Primary Vertex Position X (cm);Events",100,-0.5,0.5);
679   fListHist->Add(fHistMCPrimaryVertexX);
680
681   fHistMCPrimaryVertexY          = new TH1F("h1MCPrimaryVertexY", "MC Primary Vertex Position Y;Primary Vertex Position Y (cm);Events",100,-0.5,0.5);
682   fListHist->Add(fHistMCPrimaryVertexY);
683
684   fHistMCPrimaryVertexZ          = new TH1F("h1MCPrimaryVertexZ", "MC Primary Vertex Position Z;Primary Vertex Position Z (cm);Events",200,-20,20);
685   fListHist->Add(fHistMCPrimaryVertexZ);
686   
687   // Multiplicity
688   fHistMCMultiplicityPrimary           = new TH1F("h1MCMultiplicityPrimary", "MC Primary Particles;NPrimary;Count", 201, -0.5, 200.5);
689   fListHist->Add(fHistMCMultiplicityPrimary);
690
691   fHistMCMultiplicityTracks            = new TH1F("h1MCMultiplicityTracks", "MC Tracks;Ntracks;Count", 201, -0.5, 200.5);
692   fListHist->Add(fHistMCMultiplicityTracks);
693
694   // Production Radius of non-primary particles:
695   fHistMCtracksProdRadiusK0s           = new TH2F("h2MCtracksProdRadiusK0s","Non-primary MC K^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
696   fListHist->Add(fHistMCtracksProdRadiusK0s);
697
698   fHistMCtracksProdRadiusLambda        = new TH2F("h2MCtracksProdRadiusLambda","Non-primary MC #Lambda^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
699   fListHist->Add(fHistMCtracksProdRadiusLambda);
700
701   fHistMCtracksProdRadiusAntiLambda    = new TH2F("h2MCtracksProdRadiusAntiLambda","Non-primary MC #bar{#Lambda}^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
702   fListHist->Add(fHistMCtracksProdRadiusAntiLambda);
703
704   // Decay Radius of non-primary particles:
705   fHistMCtracksDecayRadiusK0s          = new TH1F("h1MCtracksDecayRadiusK0s","Non-primary MC K^{0} Decay Radius;r (cm)",101,-1,100);
706   fListHist->Add(fHistMCtracksDecayRadiusK0s);
707
708   fHistMCtracksDecayRadiusLambda       = new TH1F("h1MCtracksDecayRadiusLambda","Non-primary MC #Lambda^{0} Decay Radius;r (cm)",101,-1,100);
709   fListHist->Add(fHistMCtracksDecayRadiusLambda);
710
711   fHistMCtracksDecayRadiusAntiLambda   = new TH1F("h1MCtracksDecayRadiusAntiLambda","Non-primary #bar{#Lambda}^{0} Decay Radius;r (cm)",100,1,101);
712   fListHist->Add(fHistMCtracksDecayRadiusAntiLambda);
713
714   // Pt Distribution of non-primary particles:
715   fHistMCPtAllK0s                      = new TH1F("h1MCPtAllK0s", "Non-primary MC K^{0};p_{t} (GeV/c);Counts",240,0,12);
716   fListHist->Add(fHistMCPtAllK0s);
717
718   fHistMCPtAllLambda                   = new TH1F("h1MCPtAllLambda", "Non-primary MC #Lambda^{0};p_{t} (GeV/c);Counts",240,0,12);
719   fListHist->Add(fHistMCPtAllLambda);
720
721   fHistMCPtAllAntiLambda               = new TH1F("h1MCPtAllAntiLambda", "Non-primary MC #bar{#Lambda}^{0};p_{t} (GeV/c);Counts",240,0,12);
722   fListHist->Add(fHistMCPtAllAntiLambda);
723
724   // Production Radius
725   fHistMCProdRadiusK0s                 = new TH1F("h1MCProdRadiusK0s", "MC K^{0} Production Radius;r (cm);Count", 400, -2, 2);
726   fListHist->Add(fHistMCProdRadiusK0s);
727
728   fHistMCProdRadiusLambda              = new TH1F("h1MCProdRadiusLambda", "MC #Lambda^{0} Production Radius;r (cm);Count", 400, -2, 2);
729   fListHist->Add(fHistMCProdRadiusLambda);
730
731    fHistMCProdRadiusAntiLambda         = new TH1F("h1MCProdRadiusAntiLambda", "MC #bar{#Lambda}^{0} Production Radius;r (cm);Count", 400, -2, 2);
732   fListHist->Add(fHistMCProdRadiusAntiLambda);
733
734
735   // Rapidity distribution:
736   fHistMCRapK0s                 = new TH1F("h1MCRapK0s", "K^{0};y",160,-4,4);
737   fListHist->Add(fHistMCRapK0s);
738
739   fHistMCRapInPtRangeK0s        = new TH1F("h1MCRapInPtRangeK0s", "K^{0};y",160,-4,4);
740   fListHist->Add(fHistMCRapInPtRangeK0s);
741
742   fHistMCRapLambda              = new TH1F("h1MCRapLambda", "#Lambda;y",160,-4,4);
743   fListHist->Add(fHistMCRapLambda);
744
745   fHistMCRapInPtRangeLambda     = new TH1F("h1MCRapInPtRangeLambda", "#Lambda;y",160,-4,4);
746   fListHist->Add(fHistMCRapInPtRangeLambda);
747
748   fHistMCRapAntiLambda          = new TH1F("h1MCRapAntiLambda", "#bar{#Lambda};y",160,-4,4);
749   fListHist->Add(fHistMCRapAntiLambda);
750
751   fHistMCRapInPtRangeAntiLambda = new TH1F("h1MCRapInPtRangeAntiLambda", "#bar{#Lambda};y",160,-4,4);
752   fListHist->Add(fHistMCRapInPtRangeAntiLambda);
753
754   fHistMCRapXi                  = new TH1F("h1MCRapXi", "Xi;y",160,-4,4);
755   fListHist->Add(fHistMCRapXi);
756
757   fHistMCRapInPtRangeXi         = new TH1F("h1MCRapInPtRangeXi", "Xi;y",160,-4,4);
758   fListHist->Add(fHistMCRapInPtRangeXi);
759
760   fHistMCRapPhi                  = new TH1F("h1MCRapPhi", "Phi;y",160,-4,4);
761   fListHist->Add(fHistMCRapPhi);
762
763   fHistMCRapInPtRangePhi         = new TH1F("h1MCRapInPtRangePhi", "Phi;y",160,-4,4);
764   fListHist->Add(fHistMCRapInPtRangePhi);
765
766
767   // Pt distribution:
768   fHistMCPtK0s               = new TH1F("h1MCPtK0s", "K^{0};p_{t} (GeV/c)",240,0,12);
769   fListHist->Add(fHistMCPtK0s);
770
771
772
773
774   fHistMCPtLambda            = new TH1F("h1MCPtLambda", "#Lambda^{0};p_{t} (GeV/c)",240,0,12);
775   fListHist->Add(fHistMCPtLambda);
776
777
778
779
780   // Pt distribution of Lambda coming from Sigma decay
781   fHistMCPtLambdaFromSigma      = new TH1F("h1MCPtLambdaFromSigma", "#Lambda^{0};p_{t} (GeV/c)",240,0,12);
782   fListHist->Add(fHistMCPtLambdaFromSigma);
783
784   fHistMCPtAntiLambdaFromSigma  = new TH1F("h1MCPtAntiLambdaFromSigma", "#Lambda^{0};p_{t} (GeV/c)",240,0,12);
785   fListHist->Add(fHistMCPtAntiLambdaFromSigma);
786  
787   // Multiple reconstruction studies
788   fHistNTimesRecK0s             = new TH1F("h1NTimesRecK0s","number of times a K0s is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
789   fListHist->Add(fHistNTimesRecK0s);
790 //  fHistNTimesRecK0sMI           = new TH1F("h1NTimesRecK0sMI","number of times a K0s MI is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
791 //  fListHist->Add(fHistNTimesRecK0sMI);
792
793   fHistNTimesRecLambda          = new TH1F("h1NTimesRecLambda","number of times a Lambda is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
794   fListHist->Add(fHistNTimesRecLambda);
795 //  fHistNTimesRecLambdaMI        = new TH1F("h1NTimesRecLambdaMI","number of times a Lambda MI is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
796 //  fListHist->Add(fHistNTimesRecLambdaMI);
797
798   fHistNTimesRecAntiLambda      = new TH1F("h1NTimesRecAntiLambda","number of times an AntiLambda is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
799   fListHist->Add(fHistNTimesRecAntiLambda);
800 //  fHistNTimesRecAntiLambdaMI    = new TH1F("h1NTimesRecAntiLambdaMI","number of times an AntiLambda  MI is reconstructed in -1<y<1;number of times;counts",500,-0.5,4.5);
801 //  fListHist->Add(fHistNTimesRecAntiLambdaMI);
802
803   fHistNTimesRecK0sVsPt         = new TH2F("h2NTimesRecK0sVsPt","NTimes versus Pt, K^{0} in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
804   fListHist->Add(fHistNTimesRecK0sVsPt);
805 //  fHistNTimesRecK0sVsPtMI       = new TH2F("h2NTimesRecK0sVsPtMI","NTimes versus Pt, K^{0}, on-the-fly finder, in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
806 //  fListHist->Add(fHistNTimesRecK0sVsPtMI);
807
808   fHistNTimesRecLambdaVsPt      = new TH2F("h2NTimesRecLambdaVsPt","NTimes versus Pt, #Lambda^{0} in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
809   fListHist->Add(fHistNTimesRecLambdaVsPt);
810 //  fHistNTimesRecLambdaVsPtMI    = new TH2F("h2NTimesRecLambdaVsPtMI","NTimes versus Pt, #Lambda^{0} on-the-fly finder in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
811 //  fListHist->Add(fHistNTimesRecLambdaVsPtMI);
812
813   fHistNTimesRecAntiLambdaVsPt  = new TH2F("h2NTimesRecAntiLambdaVsPt","NTimes versus Pt, #bar{#Lambda}^{0} in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
814   fListHist->Add(fHistNTimesRecAntiLambdaVsPt);
815 //  fHistNTimesRecAntiLambdaVsPtMI= new TH2F("h2NTimesRecAntiLambdaVsPtMI","NTimes versus Pt, #bar{#Lambda}^{0}, on-the-fly finder in -1<y<1;p_{t} (GeV/c);number of times",75,0,15,5,-0.5,4.5);
816 //  fListHist->Add(fHistNTimesRecAntiLambdaVsPtMI);
817
818   
819
820   //***********************************
821   // Reconstructed particles histograms
822   //***********************************
823
824   // Number of events;
825   fHistNumberEvents           = new TH1F("h1NumberEvents", "Number of events; index;Number of Events",10,0,10);
826   fListHist->Add(fHistNumberEvents);
827
828   // multiplicity
829   fHistTrackPerEvent           = new TH1F("h1TrackPerEvent", "Tracks per event;Number of Tracks;Number of Events",1000,0,1000);
830   fListHist->Add(fHistTrackPerEvent);
831
832   fHistTrackletPerEvent       = new TH1F("h1TrackletPerEvent", "Number of tracklets;Number of tracklets per events;Number of events",1000,0,1000);
833   fListHist->Add(fHistTrackletPerEvent);
834
835   fHistMCDaughterTrack         = new TH1F("h1MCDaughterTrack","Distribution of mc id for daughters;id tags;Counts",15,0,15);
836   fListHist->Add(fHistMCDaughterTrack);
837
838   // Primary Vertex:
839   fHistSPDPrimaryVertexZ          = new TH1F("h1SPDPrimaryVertexZ", "SPD Primary Vertex Position Z;Primary Vertex Position Z (cm);Events",200,-20,20);
840   fListHist->Add(fHistSPDPrimaryVertexZ);
841
842   fHistPrimaryVertexX          = new TH1F("h1PrimaryVertexX", "Primary Vertex Position X;Primary Vertex Position X (cm);Events",100,-0.5,0.5);
843   fListHist->Add(fHistPrimaryVertexX);
844
845   fHistPrimaryVertexY          = new TH1F("h1PrimaryVertexY", "Primary Vertex Position Y;Primary Vertex Position Y (cm);Events",100,-0.5,0.5);
846   fListHist->Add(fHistPrimaryVertexY);
847
848   fHistPrimaryVertexZ          = new TH1F("h1PrimaryVertexZ", "Primary Vertex Position Z;Primary Vertex Position Z (cm);Events",200,-20,20);
849   fListHist->Add(fHistPrimaryVertexZ);
850
851
852   // Primary vertex resolution
853   fHistPrimaryVertexResX          = new TH1F("h1PrimaryVertexResX", "Primary Vertex Resolution X;Primary Vertex Resolution X (cm);Events",100,-0.25,0.25);
854   fListHist->Add(fHistPrimaryVertexResX);
855
856   fHistPrimaryVertexResY          = new TH1F("h1PrimaryVertexResY", "Primary Vertex Resolution Y;Primary Vertex Resolution Y (cm);Events",100,-0.25,0.25);
857   fListHist->Add(fHistPrimaryVertexResY);
858
859   fHistPrimaryVertexResZ          = new TH1F("h1PrimaryVertexResZ", "Primary Vertex Resolution Z;Primary Vertex Resolution Z (cm);Events",200,-0.25,0.25);
860   fListHist->Add(fHistPrimaryVertexResZ);
861   
862
863   // Primary Vertex in events with V0 candidates:
864   fHistPrimaryVertexPosXV0events       = new TH1F("h1PrimaryVertexPosXV0events", "Primary Vertex Position X;Primary Vertex Position X (cm);Events",100,-0.5,0.5);
865   fListHist->Add(fHistPrimaryVertexPosXV0events);
866   fHistPrimaryVertexPosYV0events       = new TH1F("h1PrimaryVertexPosYV0events", "Primary Vertex Position Y;Primary Vertex Position Y (cm);Events",100,-0.5,0.5);
867   fListHist->Add(fHistPrimaryVertexPosYV0events);
868   fHistPrimaryVertexPosZV0events       = new TH1F("h1PrimaryVertexPosZV0events", "Primary Vertex Position Z;Primary Vertex Position Z (cm);Events",200,-20.0,20.0);
869   fListHist->Add(fHistPrimaryVertexPosZV0events);
870
871   // Daughters Pt:
872   fHistDaughterPt              = new TH2F("h2DaughterPt", "Daughter Pt;Positive Daughter Pt; Negative Daughter Pt",200,0,2,200,0,2);
873   fListHist->Add(fHistDaughterPt);
874
875   // Cut checks:
876   fHistDcaPosToPrimVertex      = new TH2F("h2DcaPosToPrimVertex", "Positive V0 daughter;dca(cm);Status",500,0,5,2,-0.5,1.5);
877   fListHist->Add(fHistDcaPosToPrimVertex);
878
879   fHistDcaNegToPrimVertex      = new TH2F("h2DcaNegToPrimVertex", "Negative V0 daughter;dca(cm);Status",500,0,5,2,-0.5,1.5);
880   fListHist->Add(fHistDcaNegToPrimVertex);
881
882   fHistDcaPosToPrimVertexZoom  = new TH2F("h2DcaPosToPrimVertexZoom", "Positive V0 daughter;dca(cm);Status",100,0,0.1,2,-0.5,1.5);
883   fListHist->Add(fHistDcaPosToPrimVertexZoom);
884
885   fHistDcaNegToPrimVertexZoom  = new TH2F("h2DcaNegToPrimVertexZoom", "Negative V0 daughter;dca(cm);Status",100,0,0.1,2,-0.5,1.5);
886   fListHist->Add(fHistDcaNegToPrimVertexZoom);
887
888   fHistRadiusV0                = new TH2F("h2RadiusV0", "Radius;Radius(cm);Status",1200,0,120,2,-0.5,1.5);
889   fListHist->Add(fHistRadiusV0);
890
891   fHistDecayLengthV0           = new TH2F("h2DecayLengthV0", "V0s decay Length;decay length(cm);Status", 240, 0, 120,2,-0.5,1.5);
892   fListHist->Add(fHistDecayLengthV0);
893
894   fHistDcaV0Daughters          = new TH2F("h2DcaV0Daughters", "DCA between daughters;dca(cm);Status", 160, 0, 4,2,-0.5,1.5);
895   fListHist->Add(fHistDcaV0Daughters);
896
897   fHistChi2                    = new TH2F("h2Chi2", "V0s chi2;chi2;Status", 33, 0, 33,2,-0.5,1.5);
898   fListHist->Add(fHistChi2);
899
900   fHistCosPointAngle           = new TH2F("h2CosPointAngle", "Cosine of V0's pointing angle", 100,0,1,2,-0.5,1.5);
901   fListHist->Add(fHistCosPointAngle);
902
903   fHistCosPointAngleZoom       = new TH2F("h2CosPointAngleZoom", "Cosine of V0's pointing angle", 100,0.9,1,2,-0.5,1.5);
904   fListHist->Add(fHistCosPointAngleZoom);
905
906   fHistProdRadius              = new TH2F("h2ProdRadius", "Production position;x (cm);y (cm)", 100,-50,50,100,-50,50);
907   fListHist->Add(fHistProdRadius);
908
909 //  fHistProdRadiusMI            = new TH2F("h2ProdRadiusMI", "Production position, V0s MI;x (cm);y (cm)", 100,-50,50,100,-50,50);
910 //  fListHist->Add(fHistProdRadiusMI);
911
912   // V0 Multiplicity
913   if (!fHistV0Multiplicity) {
914     if (fCollidingSystems)
915       fHistV0Multiplicity = new TH1F("fHistV0Multiplicity", "Multiplicity distribution;Number of Offline V0s;Events", 200, 0, 40000);
916     else
917       fHistV0Multiplicity = new TH1F("fHistV0Multiplicity", "Multiplicity distribution;Number of Offline V0s;Events", 10, 0, 10); 
918     fListHist->Add(fHistV0Multiplicity);
919   }
920
921 /*  if (!fHistV0MultiplicityMI) {
922     if (fCollidingSystems)
923       fHistV0MultiplicityMI = new TH1F("fHistV0MultiplicityMI", "Multiplicity distribution;Number of On-the-fly V0s;Events", 200, 0, 40000);
924     else
925       fHistV0MultiplicityMI = new TH1F("fHistV0MultiplicityMI", "Multiplicity distribution;Number of On-the-fly V0s;Events", 10, 0, 10); 
926     fListHist->Add(fHistV0MultiplicityMI);
927   }
928 */
929   // AliKF Chi2
930   fHistChi2KFBeforeCutK0s               = new TH2F("h1Chi2KFBeforeCutK0s", "K^{0}  candidates;#Chi^{2});Counts", 250, 0, 50, 2,-0.5,1.5);
931   fListHist->Add(fHistChi2KFBeforeCutK0s);
932   fHistChi2KFBeforeCutLambda            = new TH2F("h1Chi2KFBeforeCutLambda", "#Lambda^{0}  candidates;#Chi^{2};Counts", 250, 0, 50, 2,-0.5,1.5);
933   fListHist->Add(fHistChi2KFBeforeCutLambda);
934   fHistChi2KFBeforeCutAntiLambda        = new TH2F("h1Chi2KFBeforeCutAntiLambda", "#bar{#Lambda}^{0}  candidates;#Chi^{2};Counts", 250, 0, 50, 2,-0.5,1.5);
935   fListHist->Add(fHistChi2KFBeforeCutAntiLambda);
936
937   fHistChi2KFAfterCutK0s               = new TH2F("h1Chi2KFAfterCutK0s", "K^{0}  candidates;#Chi^{2});Counts", 250, 0, 50, 2,-0.5,1.5);
938   fListHist->Add(fHistChi2KFAfterCutK0s);
939   fHistChi2KFAfterCutLambda            = new TH2F("h1Chi2KFAfterCutLambda", "#Lambda^{0}  candidates;#Chi^{2};Counts", 250, 0, 50, 2,-0.5,1.5);
940   fListHist->Add(fHistChi2KFAfterCutLambda);
941   fHistChi2KFAfterCutAntiLambda        = new TH2F("h1Chi2KFAfterCutAntiLambda", "#bar{#Lambda}^{0} candidates;#Chi^{2};Counts", 250, 0, 50, 2,-0.5,1.5);
942   fListHist->Add(fHistChi2KFAfterCutAntiLambda);
943
944   // Mass:
945   fHistMassK0                   = new TH1F("h1MassK0", "K^{0} candidates;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
946   fListHist->Add(fHistMassK0);
947 //  fHistMassK0MI                 = new TH1F("h1MassK0MI", "K^{0} candidates;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
948 //  fListHist->Add(fHistMassK0MI);
949
950   fHistMassLambda               = new TH1F("h1MassLambda", "#Lambda^{0} candidates;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
951   fListHist->Add(fHistMassLambda);
952 //  fHistMassLambdaMI             = new TH1F("h1MassLambdaMI", "#Lambda^{0} candidates;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
953 //  fListHist->Add(fHistMassLambdaMI);
954
955   fHistMassAntiLambda           = new TH1F("h1MassAntiLambda", "#bar{#Lambda}^{0} candidates;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
956   fListHist->Add(fHistMassAntiLambda);
957 //  fHistMassAntiLambdaMI         = new TH1F("h1MassAntiLambdaMI", "#bar{#Lambda}^{0} candidates;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
958 //  fListHist->Add(fHistMassAntiLambdaMI);
959
960   // invariant mass vs radius
961   const Double_t radius[10] = {0.0,2.5,2.9,3.9,7.6,15.0,23.9,37.8,42.8,100.0};
962   Int_t lNbinRadius        = 9;
963   Int_t lNbinInvMassLambda = 300;
964
965   fHistMassVsRadiusK0           = new TH2F("h2MassVsRadiusK0", "K^{0} candidates;radius (cm);M(#pi^{+}#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 200, 0.4, 0.6);
966   fListHist->Add(fHistMassVsRadiusK0);
967
968 //  fHistMassVsRadiusK0MI         = new TH2F("h2MassVsRadiusK0MI", "K^{0} MI candidates;radius (cm);M(#pi^{+}#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 200, 0.4, 0.6);
969 //  fListHist->Add(fHistMassVsRadiusK0MI);
970   
971   fHistMassVsRadiusLambda       = new TH2F("h2MassVsRadiusLambda", "#Lambda candidates;radius (cm);M(p#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 140, 1.06, 1.2);
972   fListHist->Add(fHistMassVsRadiusLambda);
973
974 //  fHistMassVsRadiusLambdaMI     = new TH2F("h2MassVsRadiusLambdaMI", "#Lambda MI candidates;radius (cm);M(p#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 140, 1.06, 1.2);
975 //  fListHist->Add(fHistMassVsRadiusLambdaMI);
976
977   fHistMassVsRadiusAntiLambda   = new TH2F("h2MassVsRadiusAntiLambda", "#bar{#Lambda} candidates;radius (cm);M(#bar{p}#pi^{+}) (GeV/c^{2})",lNbinRadius,radius, 140, 1.06, 1.2);
978   fListHist->Add(fHistMassVsRadiusAntiLambda);
979
980 //  fHistMassVsRadiusAntiLambdaMI = new TH2F("h2MassVsRadiusAntiLambdaMI", "#bar{#Lambda} candidates;radius (cm);M(#bar{p}#pi^{+}) (GeV/c^{2})",lNbinRadius,radius, 140, 1.06, 1.2);
981 //  fListHist->Add(fHistMassVsRadiusAntiLambdaMI);
982
983   // Pt Vs Mass
984   fHistPtVsMassK0               = new TH2F("h2PtVsMassK0","K^{0} candidates;M(#pi^{+}#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",200, 0.4, 0.6,240,0,12);
985   fListHist->Add(fHistPtVsMassK0);
986 //  fHistPtVsMassK0MI             = new TH2F("h2PtVsMassK0MI","K^{0} MIcandidates;M(#pi^{+}#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",200, 0.4, 0.6,240,0,12);
987 //  fListHist->Add(fHistPtVsMassK0MI);
988
989   fHistPtVsMassLambda           = new TH2F("h2PtVsMassLambda","#Lambda^{0} candidates;M(p#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
990   fListHist->Add(fHistPtVsMassLambda);
991 //  fHistPtVsMassLambdaMI         = new TH2F("h2PtVsMassLambdaMI","#Lambda^{0} candidates;M(p#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
992 //  fListHist->Add(fHistPtVsMassLambdaMI);
993 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
994 fHistPzPtBeforeK0s      = new TH1F("h1PzPtBeforeK0s","K0s; Abs(pz/pt); count",1000,0,10);
995   fListHist->Add(fHistPzPtBeforeK0s);
996
997 fHistPzPtAfterK0s       = new TH1F("h1PzPtAfterK0s","K0s; Abs(pz/pt); count",1000,0,10);
998   fListHist->Add(fHistPzPtAfterK0s);
999
1000 fHistPzPtBeforeLambda   = new TH1F("h1PzPtBeforeLambda","#Lambda^{0}; Abs(pz/pt); count",1000,0,10);
1001   fListHist->Add(fHistPzPtBeforeLambda);
1002
1003 fHistPzPtAfterLambda    = new TH1F("h1PzPtAfterLambda","#Lambda^{0}; Abs(pz/pt); count",1000,0,10);
1004   fListHist->Add(fHistPzPtAfterLambda);
1005 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1006
1007   fHistArmenterosPodolanski     = new TH2F("h2ArmenterosPodolanski","Armenteros-Podolanski phase space;#alpha;p_{t} arm",100,-1.0,1.0,50,0,0.5);
1008 //  fHistArmenterosPodolanskiMI   = new TH2F("h2ArmenterosPodolanskiMI","Armenteros-Podolanski phase space;#alpha;p_{t} arm",100,-1.0,1.0,50,0,0.5);
1009
1010
1011   //PID
1012   fHistNsigmaPosPionAntiLambda   = new TH1F("h1NsigmaPosPionAntiLambda", "Positive daughter of Antilambda;NsigmaPion;Counts",25,0,5);
1013   fListHist->Add(fHistNsigmaPosPionAntiLambda);
1014
1015   fHistNsigmaNegProtonAntiLambda = new TH1F("h1NsigmaNegProtonAntiLambda", "Negative daughter of Antilambda;NsigmaProton;Counts",25,0,5);
1016   fListHist->Add(fHistNsigmaNegProtonAntiLambda);
1017   
1018   fHistNsigmaPosProtonLambda     = new TH1F("h1NsigmaPosProtonLambda", "Positive daughter of Lambda;NsigmaProton;Counts",25,0,5); 
1019   fListHist->Add(fHistNsigmaPosProtonLambda);
1020   
1021   fHistNsigmaNegPionLambda       = new TH1F("h1NsigmaNegPionLambda", "Negative daughter of Lambda;NsigmaPion;Counts",25,0,5);
1022   fListHist->Add(fHistNsigmaNegPionLambda);
1023   
1024   fHistNsigmaPosPionK0           = new TH1F("h1NsigmaPosPionK0", "Positive daughter of K0s;NsigmaPion;Counts",25,0,5);
1025   fListHist->Add(fHistNsigmaPosPionK0);
1026   
1027   fHistNsigmaNegPionK0           = new TH1F("h1NsigmaNegPionK0", "Negative daughter of K0s;NsigmaPion;Counts",25,0,5);
1028   fListHist->Add(fHistNsigmaNegPionK0);
1029
1030
1031   //********************************
1032   // Associated particles histograms
1033   //********************************
1034
1035   // Rap distribution
1036   fHistAsMcRapK0                = new TH1F("h1AsMcRapK0", "K^{0} associated;eta;Counts", 60, -1.5, 1.5);
1037   fListHist->Add(fHistAsMcRapK0);
1038 //  fHistAsMcRapK0MI              = new TH1F("h1AsMcRapK0MI", "K^{0} associated;eta;Counts", 60, -1.5, 1.5);
1039 //  fListHist->Add(fHistAsMcRapK0MI);
1040
1041   fHistAsMcRapLambda            = new TH1F("h1AsMcRapLambda", "#Lambda^{0} associated;eta;Counts", 60, -1.5, 1.5);
1042   fListHist->Add(fHistAsMcRapLambda);
1043 //  fHistAsMcRapLambdaMI          = new TH1F("h1AsMcRapLambdaMI", "#Lambda^{0} associated;eta;Counts", 60, -1.5, 1.5);
1044 //  fListHist->Add(fHistAsMcRapLambdaMI);
1045
1046   fHistAsMcRapAntiLambda        = new TH1F("h1AsMcRapAntiLambda", "#bar{#Lambda}^{0} associated;eta;Counts", 60, -1.5, 1.5);
1047   fListHist->Add(fHistAsMcRapAntiLambda);
1048  // fHistAsMcRapAntiLambdaMI      = new TH1F("h1AsMcRapAntiLambdaMI", "#bar{#Lambda}^{0} associated;eta;Counts", 60, -1.5, 1.5);
1049 //  fListHist->Add(fHistAsMcRapAntiLambdaMI);
1050
1051
1052   //Pt distribution
1053   fHistAsMcPtK0                = new TH1F("h1AsMcPtK0", "K^{0} associated;p_{t} (GeV/c);Counts", 240,0,12);
1054   fListHist->Add(fHistAsMcPtK0);
1055
1056
1057 //  fHistAsMcPtK0MI              = new TH1F("h1AsMcPtK0MI", "K^{0} associated;p_{t} (GeV/c);Counts", 240,0,12);
1058 //  fListHist->Add(fHistAsMcPtK0MI);
1059
1060   fHistAsMcPtLambda            = new TH1F("h1AsMcPtLambda", "#Lambda^{0} associated;p_{t} (GeV/c);Counts", 240,0,12);
1061   fListHist->Add(fHistAsMcPtLambda);
1062
1063
1064
1065 //  fHistAsMcPtAntiLambdaMI      = new TH1F("h1AsMcPtAntiLambdaMI", "#bar{#Lambda}^{0} associated;p_{t} (GeV/c);Counts", 240,0,12);
1066 //  fListHist->Add(fHistAsMcPtAntiLambdaMI);
1067
1068   fHistAsMcPtZoomK0            = new TH1F("h1AsMcPtZoomK0", "K^{0} candidates in -1 <y<1;p_{t} (GeV/c);Counts",20,0,1);
1069   fListHist->Add(fHistAsMcPtZoomK0);
1070 //  fHistAsMcPtZoomK0MI          = new TH1F("h1AsMcPtZoomK0MI", "K^{0} MI candidates in -1 <y<1;p_{t} (GeV/c);Counts",20,0,1);
1071 //  fListHist->Add(fHistAsMcPtZoomK0MI);
1072
1073   fHistAsMcPtZoomLambda        = new TH1F("h1AsMcPtZoomLambda", "#Lambda^{0} candidates in -1 <y<1;p_{t} (GeV/c);Counts",20,0,1);
1074   fListHist->Add(fHistAsMcPtZoomLambda);
1075 //  fHistAsMcPtZoomLambdaMI      = new TH1F("h1AsMcPtZoomLambdaMI", "#Lambda^{0} MI candidates in -1 <y<1;p_{t} (GeV/c);Counts",20,0,1);
1076 //  fListHist->Add(fHistAsMcPtZoomLambdaMI);
1077
1078
1079   // Radius distribution
1080   fHistAsMcProdRadiusK0               = new TH1F("h1AsMcProdRadiusK0", "K^{0} associated;r (cm);Counts", 500, 0, 100);
1081   fListHist->Add(fHistAsMcProdRadiusK0);
1082 //  fHistAsMcProdRadiusK0MI             = new TH1F("h1AsMcProdRadiusK0MI", "K^{0} associated;r (cm);Counts", 500, 0, 100);
1083 //  fListHist->Add(fHistAsMcProdRadiusK0MI);
1084
1085   fHistAsMcProdRadiusLambda           = new TH1F("h1AsMcProdRadiusLambda", "#Lambda^{0} associated;r (cm);Counts", 500, 0, 100);
1086   fListHist->Add(fHistAsMcProdRadiusLambda);
1087 //  fHistAsMcProdRadiusLambdaMI         = new TH1F("h1AsMcProdRadiusLambdaMI", "#Lambda^{0} associated;r (cm);Counts", 500, 0, 100);
1088 //  fListHist->Add(fHistAsMcProdRadiusLambdaMI);
1089
1090   fHistAsMcProdRadiusAntiLambda       = new TH1F("h1AsMcProdRadiusAntiLambda", "#bar{#Lambda}^{0} associated;r (cm);Counts", 500, 0, 100);
1091   fListHist->Add(fHistAsMcProdRadiusAntiLambda);
1092 //  fHistAsMcProdRadiusAntiLambdaMI     = new TH1F("h1AsMcProdRadiusAntiLambdaMI", "#bar{#Lambda}^{0} associated;r (cm);Counts", 500, 0, 100);
1093 //  fListHist->Add(fHistAsMcProdRadiusAntiLambdaMI);
1094
1095   fHistAsMcProdRadiusXvsYK0s          = new TH2F("h2AsMcProdRadiusXvsYK0s","Associated Secondary K^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1096   fListHist->Add(fHistAsMcProdRadiusXvsYK0s);
1097 //  fHistAsMcProdRadiusXvsYK0sMI        = new TH2F("h2AsMcProdRadiusXvsYK0sMI","Associated Secondary K^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1098 //  fListHist->Add(fHistAsMcProdRadiusXvsYK0sMI);
1099
1100   fHistAsMcProdRadiusXvsYLambda       = new TH2F("h2AsMcProdRadiusXvsYLambda","Associated Secondary #Lambda^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1101   fListHist->Add(fHistAsMcProdRadiusXvsYLambda);
1102 //  fHistAsMcProdRadiusXvsYLambdaMI     = new TH2F("h2AsMcProdRadiusXvsYLambdaMI","Associated Secondary #Lambda^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1103 //  fListHist->Add(fHistAsMcProdRadiusXvsYLambdaMI);
1104
1105   fHistAsMcProdRadiusXvsYAntiLambda   = new TH2F("h2AsMcProdRadiusXvsYAntiLambda","Associated Secondary #bar{#Lambda}^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1106   fListHist->Add(fHistAsMcProdRadiusXvsYAntiLambda);
1107 //  fHistAsMcProdRadiusXvsYAntiLambdaMI = new TH2F("h2AsMcProdRadiusXvsYAntiLambdaMI","Associated Secondary #bar{#Lambda}^{0} Production Radius;x (cm); y (cm)",200,-50,50,200,-50,50);
1108 //  fListHist->Add(fHistAsMcProdRadiusXvsYAntiLambdaMI);
1109
1110
1111
1112   // Mass
1113   fHistPidMcMassK0             = new TH1F("h1PidMcMassK0", "K^{0} MC PId checked;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
1114   fListHist->Add(fHistPidMcMassK0);
1115 //  fHistPidMcMassK0MI           = new TH1F("h1PidMcMassK0MI", "K^{0} MC PId checked;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
1116 //  fListHist->Add(fHistPidMcMassK0MI);
1117
1118   fHistPidMcMassLambda         = new TH1F("h1PidMcMassLambda", "#Lambda^{0} MC PId checked;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1119   fListHist->Add(fHistPidMcMassLambda);
1120 //  fHistPidMcMassLambdaMI       = new TH1F("h1PidMcMassLambdaMI", "#Lambda^{0} MC PId checked;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1121 //  fListHist->Add(fHistPidMcMassLambdaMI);
1122   
1123   fHistPidMcMassAntiLambda     = new TH1F("h1PidMcMassAntiLambda", "#bar{#Lambda}^{0} MC PId checked;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1124   fListHist->Add(fHistPidMcMassAntiLambda);
1125 //  fHistPidMcMassAntiLambdaMI   = new TH1F("h1PidMcMassAntiLambdaMI", "#bar{#Lambda}^{0} MC PId checked;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1126 //  fListHist->Add(fHistPidMcMassAntiLambdaMI);
1127
1128   fHistAsMcMassK0              = new TH1F("h1AsMcMassK0", "K^{0} associated;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
1129   fListHist->Add(fHistAsMcMassK0);
1130 //  fHistAsMcMassK0MI            = new TH1F("h1AsMcMassK0MI", "K^{0} associated;M(#pi^{+}#pi^{-}) (GeV/c^{2});Counts", 100, 0.4, 0.6);
1131 //  fListHist->Add(fHistAsMcMassK0MI);
1132   
1133   fHistAsMcMassLambda          = new TH1F("h1AsMcMassLambda", "#Lambda^{0} associated;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1134   fListHist->Add(fHistAsMcMassLambda);
1135 //  fHistAsMcMassLambdaMI        = new TH1F("h1AsMcMassLambdaMI", "#Lambda^{0} associated;M(p#pi^{-}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1136 //  fListHist->Add(fHistAsMcMassLambdaMI);
1137
1138   fHistAsMcMassAntiLambda      = new TH1F("h1AsMcMassAntiLambda", "#bar{#Lambda}^{0} associated;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1139   fListHist->Add(fHistAsMcMassAntiLambda);
1140 //  fHistAsMcMassAntiLambdaMI    = new TH1F("h1AsMcMassAntiLambdaMI", "#bar{#Lambda}^{0} associated;M(#bar{p}#pi^{+}) (GeV/c^{2});Counts", 75, 1.05, 1.2);
1141 //  fListHist->Add(fHistAsMcMassAntiLambdaMI);
1142
1143   //Pt versus Mass
1144   fHistAsMcPtVsMassK0               = new TH2F("h2AsMcPtVsMassK0","K^{0} associated;M(#pi^{+}#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",200, 0.4, 0.6,240,0,12);
1145   fListHist->Add(fHistAsMcPtVsMassK0);
1146 //  fHistAsMcPtVsMassK0MI             = new TH2F("h2AsMcPtVsMassK0MI","K^{0} MIassociated;M(#pi^{+}#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",200, 0.4, 0.6,240,0,12);
1147 //  fListHist->Add(fHistAsMcPtVsMassK0MI);
1148
1149   fHistAsMcPtVsMassLambda           = new TH2F("h2AsMcPtVsMassLambda","#Lambda^{0} associated;M(p#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
1150   fListHist->Add(fHistAsMcPtVsMassLambda);
1151 //  fHistAsMcPtVsMassLambdaMI         = new TH2F("h2AsMcPtVsMassLambdaMI","#Lambda^{0} associated;M(p#pi^{-}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
1152 //  fListHist->Add(fHistAsMcPtVsMassLambdaMI);
1153
1154   fHistAsMcPtVsMassAntiLambda       = new TH2F("h2AsMcPtVsMassAntiLambda","#bar{#Lambda}^{0} associated;M(#bar{p}#pi^{+}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
1155   fListHist->Add(fHistAsMcPtVsMassAntiLambda);
1156 //  fHistAsMcPtVsMassAntiLambdaMI     = new TH2F("h2AsMcPtVsMassAntiLambdaMI","#bar{#Lambda}^{0} associated;M(#bar{p}#pi^{+}) (GeV/c^{2});p_{t} (GeV/c)",140, 1.06, 1.2,240,0,12);
1157 //  fListHist->Add(fHistAsMcPtVsMassAntiLambdaMI);
1158
1159
1160   // invariant mass vs radius
1161   fHistAsMcMassVsRadiusK0             = new TH2F("h2AsMcMassVsRadiusK0", "K^{0} associated;radius (cm);M(#pi^{+}#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 500, 0.47, 0.52);
1162   fListHist->Add(fHistAsMcMassVsRadiusK0);
1163
1164 //  fHistAsMcMassVsRadiusK0MI           = new TH2F("h2AsMcMassVsRadiusK0MI", "K^{0} MI associated;radius (cm);M(#pi^{+}#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, 500, 0.47, 0.52);
1165 //  fListHist->Add(fHistAsMcMassVsRadiusK0MI);
1166   
1167   fHistAsMcMassVsRadiusLambda         = new TH2F("h2AsMcMassVsRadiusLambda", "#Lambda associated;radius (cm);M(p#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, lNbinInvMassLambda, 1.10, 1.13);
1168   fListHist->Add(fHistAsMcMassVsRadiusLambda);
1169
1170 //  fHistAsMcMassVsRadiusLambdaMI       = new TH2F("h2AsMcMassVsRadiusLambdaMI", "#Lambda MI associated;radius (cm);M(p#pi^{-}) (GeV/c^{2})",lNbinRadius,radius, lNbinInvMassLambda, 1.10, 1.13);
1171 //  fListHist->Add(fHistAsMcMassVsRadiusLambdaMI);
1172
1173   fHistAsMcMassVsRadiusAntiLambda     = new TH2F("h2AsMcMassVsRadiusAntiLambda", "#bar{#Lambda} associated;radius (cm);M(#bar{p}#pi^{+}) (GeV/c^{2})",lNbinRadius,radius,lNbinInvMassLambda , 1.10, 1.13);
1174   fListHist->Add(fHistAsMcMassVsRadiusAntiLambda);
1175   
1176 //  fHistAsMcMassVsRadiusAntiLambdaMI   = new TH2F("h2AsMcMassVsRadiusAntiLambdaMI", "#bar{#Lambda} MI associated;radius (cm);M(#bar{p}#pi^{+}) (GeV/c^{2})",lNbinRadius,radius,lNbinInvMassLambda , 1.10, 1.13);
1177 //  fListHist->Add(fHistAsMcMassVsRadiusAntiLambdaMI);
1178     
1179
1180   // Position Resolution
1181   fHistAsMcResxK0                     = new TH1F("h1AsMcResxK0", "K^{0} associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1182   fListHist->Add(fHistAsMcResxK0);
1183   fHistAsMcResyK0                     = new TH1F("h1AsMcResyK0", "K^{0} associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1184   fListHist->Add(fHistAsMcResyK0);
1185   fHistAsMcReszK0                     = new TH1F("h1AsMcReszK0", "K^{0} associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1186   fListHist->Add(fHistAsMcReszK0);
1187   fHistAsMcResrVsRadiusK0             = new TH2F("h2AsMcResrVsRadiusK0", "K^{0} associated;Radius (cm);#Delta r (cm)",200,0.0,50., 50, -0.25, 0.25);
1188   fListHist->Add(fHistAsMcResrVsRadiusK0);
1189   fHistAsMcReszVsRadiusK0             = new TH2F("h2AsMcReszVsRadiusK0", "K^{0} associated;Radius (cm);#Delta z (cm)",200,0.0,50.0, 50, -0.25, 0.25);
1190   fListHist->Add(fHistAsMcReszVsRadiusK0);
1191
1192 //  fHistAsMcResxK0MI                   = new TH1F("h1AsMcResxK0MI", "K^{0} MI associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1193 //  fListHist->Add(fHistAsMcResxK0MI);
1194 //  fHistAsMcResyK0MI                   = new TH1F("h1AsMcResyK0MI", "K^{0} MI associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1195 //  fListHist->Add(fHistAsMcResyK0MI);
1196 //  fHistAsMcReszK0MI                   = new TH1F("h1AsMcReszK0MI", "K^{0} MI associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1197 //  fListHist->Add(fHistAsMcReszK0MI);
1198 //  fHistAsMcResrVsRadiusK0MI           = new TH2F("h2AsMcResrVsRadiusK0MI", "K^{0} MI associated;Radius (cm);#Delta r (cm)",8,radius, 50, -0.25, 0.25);
1199 //  fListHist->Add(fHistAsMcResrVsRadiusK0MI);
1200 //  fHistAsMcReszVsRadiusK0MI           = new TH2F("h2AsMcReszVsRadiusK0MI", "K^{0} MI associated;Radius (cm);#Delta z (cm)",8,radius, 50, -0.25, 0.25);
1201 //  fListHist->Add(fHistAsMcReszVsRadiusK0MI);
1202
1203   fHistAsMcResxLambda                 = new TH1F("h1AsMcResxLambda", "#Lambda^{0} associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1204   fListHist->Add(fHistAsMcResxLambda);
1205   fHistAsMcResyLambda                 = new TH1F("h1AsMcResyLambda", "#Lambda^{0} associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1206   fListHist->Add(fHistAsMcResyLambda);
1207   fHistAsMcReszLambda                 = new TH1F("h1AsMcReszLambda", "#Lambda^{0} associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1208   fListHist->Add(fHistAsMcReszLambda);
1209   fHistAsMcResrVsRadiusLambda         = new TH2F("h2AsMcResrVsRadiusLambda", "#Lambda^{0} associated;Radius (cm);#Delta r (cm)",200,0.0,50.0, 50, -0.25, 0.25);
1210   fListHist->Add(fHistAsMcResrVsRadiusLambda);
1211   fHistAsMcReszVsRadiusLambda         = new TH2F("h2AsMcReszVsRadiusLambda", "#Lambda^{0} associated;Radius (cm);#Delta z (cm)",200,0.0,50.0, 50, -0.25, 0.25);
1212   fListHist->Add(fHistAsMcReszVsRadiusLambda);
1213
1214 //  fHistAsMcResxLambdaMI               = new TH1F("h1AsMcResxLambdaMI", "#Lambda^{0} MI associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1215 //  fListHist->Add(fHistAsMcResxLambdaMI);
1216 //  fHistAsMcResyLambdaMI               = new TH1F("h1AsMcResyLambdaMI", "#Lambda^{0} MI associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1217 //  fListHist->Add(fHistAsMcResyLambdaMI);
1218 //  fHistAsMcReszLambdaMI               = new TH1F("h1AsMcReszLambdaMI", "#Lambda^{0} MI associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1219 //  fListHist->Add(fHistAsMcReszLambdaMI);
1220 //  fHistAsMcResrVsRadiusLambdaMI       = new TH2F("h2AsMcResrVsRadiusLambdaMI", "#Lambda^{0} MI associated;Radius (cm);#Delta r (cm)",8,radius, 50, -0.25, 0.25);
1221 //  fListHist->Add(fHistAsMcResrVsRadiusLambdaMI);
1222 //  fHistAsMcReszVsRadiusLambdaMI       = new TH2F("h2AsMcReszVsRadiusLambdaMI", "#Lambda^{0} MI associated;Radius (cm);#Delta z (cm)",8,radius, 50, -0.25, 0.25);
1223 //  fListHist->Add(fHistAsMcReszVsRadiusLambdaMI);
1224
1225   fHistAsMcResxAntiLambda             = new TH1F("h1AsMcResxAntiLambda", "#bar{#Lambda}^{0} associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1226   fListHist->Add(fHistAsMcResxAntiLambda);
1227   fHistAsMcResyAntiLambda             = new TH1F("h1AsMcResyAntiLambda", "#bar{#Lambda}^{0} associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1228   fListHist->Add(fHistAsMcResyAntiLambda);
1229   fHistAsMcReszAntiLambda             = new TH1F("h1AsMcReszAntiLambda", "#bar{#Lambda}^{0} associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1230   fListHist->Add(fHistAsMcReszAntiLambda);
1231   fHistAsMcResrVsRadiusAntiLambda     = new TH2F("h2AsMcResrVsRadiusAntiLambda", "#bar{#Lambda}^{0} associated;Radius (cm);#Delta r (cm)",200,0.0,50.0, 50, -0.25, 0.25);
1232   fListHist->Add(fHistAsMcResrVsRadiusAntiLambda);
1233   fHistAsMcReszVsRadiusAntiLambda     = new TH2F("h2AsMcReszVsRadiusAntiLambda", "#bar{#Lambda}^{0} associated;Radius (cm);#Delta z (cm)",200,0.0,50.0, 50, -0.25, 0.25);
1234   fListHist->Add(fHistAsMcReszVsRadiusAntiLambda);
1235
1236 //  fHistAsMcResxAntiLambdaMI           = new TH1F("h1AsMcResxAntiLambdaMI", "#bar{#Lambda}^{0} MI associated;#Delta x (cm);Counts", 50, -0.25, 0.25);
1237 //  fListHist->Add(fHistAsMcResxAntiLambdaMI);
1238 //  fHistAsMcResyAntiLambdaMI           = new TH1F("h1AsMcResyAntiLambdaMI", "#bar{#Lambda}^{0} MI associated;#Delta y (cm);Counts", 50, -0.25, 0.25);
1239 //  fListHist->Add(fHistAsMcResyAntiLambdaMI);
1240 //  fHistAsMcReszAntiLambdaMI           = new TH1F("h1AsMcReszAntiLambdaMI", "#bar{#Lambda}^{0} MI associated;#Delta z (cm);Counts", 50, -0.25, 0.25);
1241 //  fListHist->Add(fHistAsMcReszAntiLambdaMI);
1242 //  fHistAsMcResrVsRadiusAntiLambdaMI   = new TH2F("h2AsMcResrVsRadiusAntiLambdaMI", "#bar{#Lambda}^{0} MI associated;Radius (cm);#Delta r (cm)",8,radius, 50, -0.25, 0.25);
1243 //  fListHist->Add(fHistAsMcResrVsRadiusAntiLambdaMI);
1244 //  fHistAsMcReszVsRadiusAntiLambdaMI   = new TH2F("h2AsMcReszVsRadiusAntiLambdaMI", "#bar{#Lambda}^{0} MI associated;Radius (cm);#Delta z (cm)",8,radius, 50, -0.25, 0.25);
1245 //  fListHist->Add(fHistAsMcReszVsRadiusAntiLambdaMI);
1246
1247   // Pt Resolution
1248   fHistAsMcResPtK0                   = new TH1F("h1AsMcResPtK0","Pt Resolution K^{0};#Delta Pt;Counts",200,-1,1);
1249   fListHist->Add(fHistAsMcResPtK0);
1250 //  fHistAsMcResPtK0MI                 = new TH1F("h1AsMcResPtK0MI","Pt Resolution K^{0} MI;#Delta Pt;Counts",200,-1,1);
1251 //  fListHist->Add(fHistAsMcResPtK0MI);
1252   
1253   fHistAsMcResPtLambda               = new TH1F("h1AsMcResPtLambda","Pt Resolution #Lambda^{0};#Delta Pt;Counts",200,-1,1);
1254   fListHist->Add(fHistAsMcResPtLambda);
1255 //  fHistAsMcResPtLambdaMI             = new TH1F("h1AsMcResPtLambdaMI","Pt Resolution #Lambda^{0} MI;#Delta Pt;Counts",200,-1,1);
1256 //  fListHist->Add(fHistAsMcResPtLambdaMI);
1257
1258   fHistAsMcResPtAntiLambda           = new TH1F("h1AsMcResPtAntiLambda","Pt Resolution #bar{#Lambda}^{0};#Delta Pt;Counts",200,-1,1);
1259   fListHist->Add(fHistAsMcResPtAntiLambda);
1260 //  fHistAsMcResPtAntiLambdaMI         = new TH1F("h1AsMcResPtAntiLambdaMI","Pt Resolution #bar{#Lambda}^{0} MI;#Delta Pt;Counts",200,-1,1);
1261 ///  fListHist->Add(fHistAsMcResPtAntiLambdaMI);
1262
1263
1264   fHistAsMcResPtVsRapK0              = new TH2F("h2AsMcResPtVsRapK0","Pt Resolution K^{0};#Delta Pt;Rap",200,-1,1,20,-1,1);
1265   fListHist->Add(fHistAsMcResPtVsRapK0);
1266 //  fHistAsMcResPtVsRapK0MI            = new TH2F("h2AsMcResPtVsRapK0MI","Pt Resolution K^{0} MI;#Delta Pt;Rap",200,-1,1,20,-1,1);
1267 //  fListHist->Add(fHistAsMcResPtVsRapK0MI);
1268   
1269   fHistAsMcResPtVsRapLambda          = new TH2F("h2AsMcResPtVsRapLambda","Pt Resolution #Lambda^{0};#Delta Pt;Rap",200,-1,1,20,-1,1);
1270   fListHist->Add(fHistAsMcResPtVsRapLambda);
1271 //  fHistAsMcResPtVsRapLambdaMI        = new TH2F("h2AsMcResPtVsRapLambdaMI","Pt Resolution #Lambda^{0} MI;#Delta Pt;Rap",200,-1,1,20,-1,1);
1272 //  fListHist->Add(fHistAsMcResPtVsRapLambdaMI);
1273
1274   fHistAsMcResPtVsRapAntiLambda      = new TH2F("h2AsMcResPtVsRapAntiLambda","Pt Resolution #bar{#Lambda}^{0};#Delta Pt;Rap",200,-1,1,20,-1,1);
1275   fListHist->Add(fHistAsMcResPtVsRapAntiLambda);
1276 //  fHistAsMcResPtVsRapAntiLambdaMI    = new TH2F("h2AsMcResPtVsRapAntiLambdaMI","Pt Resolution #bar{#Lambda}^{0} MI;#Delta Pt;Rap",200,-1,1,20,-1,1);
1277 //  fListHist->Add(fHistAsMcResPtVsRapAntiLambdaMI);
1278
1279
1280   fHistAsMcResPtVsPtK0               = new TH2F("h2AsMcResPtVsPtK0","Pt Resolution K^{0};#Delta Pt;Pt",600,-0.15,0.15,240,0,12);
1281   fListHist->Add(fHistAsMcResPtVsPtK0);
1282 //  fHistAsMcResPtVsPtK0MI             = new TH2F("h2AsMcResPtVsPtK0MI","Pt Resolution K^{0} MI;#Delta Pt;Pt",600,-0.15,0.15,240,0,12);
1283 //  fListHist->Add(fHistAsMcResPtVsPtK0MI);
1284     
1285   fHistAsMcResPtVsPtLambda           = new TH2F("h2AsMcResPtVsPtLambda","Pt Resolution #Lambda^{0};#Delta Pt;Pt",600,-0.15,0.15,240,0,12);
1286   fListHist->Add(fHistAsMcResPtVsPtLambda);
1287 //  fHistAsMcResPtVsPtLambdaMI         = new TH2F("h2AsMcResPtVsPtLambdaMI","Pt Resolution #Lambda^{0} MI;#Delta Pt;Pt",600,-0.15,0.15,240,0,12);
1288 //  fListHist->Add(fHistAsMcResPtVsPtLambdaMI);
1289
1290   fHistAsMcResPtVsPtAntiLambda       = new TH2F("h2AsMcResPtVsPtAntiLambda","Pt Resolution #bar{#Lambda}^{0};#Delta Pt;Pt",300,-0.15,0.15,240,0,12);
1291   fListHist->Add(fHistAsMcResPtVsPtAntiLambda);
1292 //  fHistAsMcResPtVsPtAntiLambdaMI     = new TH2F("h2AsMcResPtVsPtAntiLambdaMI","Pt Resolution #bar{#Lambda}^{0} MI;#Delta Pt;Pt",300,-0.15,0.15,240,0,12);
1293 //  fListHist->Add(fHistAsMcResPtVsPtAntiLambdaMI);
1294
1295
1296   // pdgcode of mother
1297   fHistAsMcMotherPdgCodeK0s           = new TH1F("h1AsMcMotherPdgCodeK0s","Mother of Associated K^{0};mother;counts",11,0,11);
1298   fListHist->Add(fHistAsMcMotherPdgCodeK0s);
1299 //  fHistAsMcMotherPdgCodeK0sMI         = new TH1F("h1AsMcMotherPdgCodeK0sMI","Mother of Associated K^{0} MI;mother;counts",11,0,11);
1300 //  fListHist->Add(fHistAsMcMotherPdgCodeK0sMI);
1301
1302   fHistAsMcMotherPdgCodeLambda        = new TH1F("h1AsMcMotherPdgCodeLambda","Mother of Associated #Lambda^{0};mother;counts",11,0,11);
1303   fListHist->Add(fHistAsMcMotherPdgCodeLambda);
1304 //  fHistAsMcMotherPdgCodeLambdaMI      = new TH1F("h1AsMcMotherPdgCodeLambdaMI","Mother of Associated #Lambda^{0} MI;mother;counts",11,0,11);
1305 //  fListHist->Add(fHistAsMcMotherPdgCodeLambdaMI);
1306
1307   fHistAsMcMotherPdgCodeAntiLambda    = new TH1F("h1AsMcMotherPdgCodeAntiLambda","Mother of Associated #bar{#Lambda}^{0};mother;counts",11,0,11);
1308   fListHist->Add(fHistAsMcMotherPdgCodeAntiLambda);
1309 //  fHistAsMcMotherPdgCodeAntiLambdaMI  = new TH1F("h1AsMcMotherPdgCodeAntiLambdaMI","Mother of Associated #bar{Lambda}^{0} MI;mother;counts",11,0,11);
1310 //  fListHist->Add(fHistAsMcMotherPdgCodeAntiLambdaMI);
1311
1312
1313   // Pt distribution Lambda from Sigma
1314   fHistAsMcPtLambdaFromSigma          = new TH1F("h1AsMcPtLambdaFromSigma","#Lambda}^{0} associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1315   fListHist->Add(fHistAsMcPtLambdaFromSigma);
1316 //  fHistAsMcPtLambdaFromSigmaMI        = new TH1F("h1AsMcPtLambdaFromSigmaMI","#Lambda^{0} MI associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1317 //  fListHist->Add(fHistAsMcPtLambdaFromSigmaMI);
1318
1319   fHistAsMcPtAntiLambdaFromSigma      = new TH1F("h1AsMcPtAntiLambdaFromSigma","#bar{#Lambda}^{0} associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1320   fListHist->Add(fHistAsMcPtAntiLambdaFromSigma);
1321 //  fHistAsMcPtAntiLambdaFromSigmaMI    = new TH1F("h1AsMcPtAntiLambdaFromSigmaMI","#bar{#Lambda}^{0} MI associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1322 //  fListHist->Add(fHistAsMcPtAntiLambdaFromSigmaMI);
1323
1324
1325   // Associated secondary particles:
1326   // Pt and rapidity distribution
1327   fHistAsMcSecondaryPtVsRapK0s          = new TH2F("h2AsMcSecondaryPtVsRapK0s", "K^{0} associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1328   fListHist->Add(fHistAsMcSecondaryPtVsRapK0s);
1329 //  fHistAsMcSecondaryPtVsRapK0sMI        = new TH2F("h2AsMcSecondaryPtVsRapK0sMI", "K^{0} MI associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1330 //  fListHist->Add(fHistAsMcSecondaryPtVsRapK0sMI);
1331
1332   fHistAsMcSecondaryPtVsRapLambda       = new TH2F("h2AsMcSecondaryPtVsRapLambda", "#Lambda^{0} associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1333   fListHist->Add(fHistAsMcSecondaryPtVsRapLambda);
1334 //  fHistAsMcSecondaryPtVsRapLambdaMI     = new TH2F("h2AsMcSecondaryPtVsRapLambdaMI", "#Lambda^{0} MI associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1335 //  fListHist->Add(fHistAsMcSecondaryPtVsRapLambdaMI);
1336
1337   fHistAsMcSecondaryPtVsRapAntiLambda   = new TH2F("h2AsMcSecondaryPtVsRapAntiLambda", "#bar{#Lambda}^{0} associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1338   fListHist->Add(fHistAsMcSecondaryPtVsRapAntiLambda);
1339 //  fHistAsMcSecondaryPtVsRapAntiLambdaMI = new TH2F("h2AsMcSecondaryPtVsRapAntiLambdaMI", "#bar{#Lambda}^{0} MI associated secondary;p_{t} (GeV/c);rapidity",240,0,12,30,-1.5,1.5);
1340 //  fListHist->Add(fHistAsMcSecondaryPtVsRapAntiLambdaMI);
1341
1342   // Production radius
1343   fHistAsMcSecondaryProdRadiusK0s              = new TH1F("h1AsMcSecondaryProdRadiusK0s", "K^{0} Production Radius;r (cm);Count", 170, -2, 15);
1344   fListHist->Add(fHistAsMcSecondaryProdRadiusK0s);
1345 //  fHistAsMcSecondaryProdRadiusK0sMI            = new TH1F("h1AsMcSecondaryProdRadiusK0sMI", "K^{0} MI Production Radius;r (cm);Count", 170, -2, 15);
1346 //  fListHist->Add(fHistAsMcSecondaryProdRadiusK0sMI);
1347
1348   fHistAsMcSecondaryProdRadiusLambda           = new TH1F("h1AsMcSecondaryProdRadiusLambda", "#Lambda^{0} Production Radius;r (cm);Count", 170, -2, 15);
1349   fListHist->Add(fHistAsMcSecondaryProdRadiusLambda);
1350 //  fHistAsMcSecondaryProdRadiusLambdaMI         = new TH1F("h1AsMcSecondaryProdRadiusLambdaMI", "#Lambda^{0} MI Production Radius;r (cm);Count", 170, -2, 15);
1351 //  fListHist->Add(fHistAsMcSecondaryProdRadiusLambdaMI);
1352
1353   fHistAsMcSecondaryProdRadiusAntiLambda       = new TH1F("h1AsMcSecondaryProdRadiusAntiLambda", "#bar{#Lambda}^{0} Production Radius;r (cm);Count", 170, -2, 15);
1354   fListHist->Add(fHistAsMcSecondaryProdRadiusAntiLambda);  
1355 //  fHistAsMcSecondaryProdRadiusAntiLambdaMI     = new TH1F("h1AsMcSecondaryProdRadiusAntiLambdaMI", "#bar{#Lambda}^{0} MI Production Radius;r (cm);Count", 170, -2, 15);
1356 //  fListHist->Add(fHistAsMcSecondaryProdRadiusAntiLambdaMI);
1357
1358   fHistAsMcSecondaryProdRadiusXvsYK0s          = new TH2F("h2AsMcSecondaryProdRadiusXvsYK0s","Associated Secondary K^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1359   fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYK0s);
1360 //  fHistAsMcSecondaryProdRadiusXvsYK0sMI        = new TH2F("h2AsMcSecondaryProdRadiusXvsYK0sMI","Associated Secondary K^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1361 //  fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYK0sMI);
1362
1363   fHistAsMcSecondaryProdRadiusXvsYLambda       = new TH2F("h2AsMcSecondaryProdRadiusXvsYLambda","Associated Secondary #Lambda^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1364   fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYLambda);
1365 //  fHistAsMcSecondaryProdRadiusXvsYLambdaMI     = new TH2F("h2AsMcSecondaryProdRadiusXvsYLambdaMI","Associated Secondary #Lambda^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1366 //  fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYLambdaMI);
1367
1368   fHistAsMcSecondaryProdRadiusXvsYAntiLambda   = new TH2F("h2AsMcSecondaryProdRadiusXvsYAntiLambda","Associated Secondary #bar{#Lambda}^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1369   fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYAntiLambda);
1370 //  fHistAsMcSecondaryProdRadiusXvsYAntiLambdaMI = new TH2F("h2AsMcSecondaryProdRadiusXvsYAntiLambdaMI","Associated Secondary #bar{#Lambda}^{0} Production Radius;x (cm); y (cm)",200,-20,20,200,-20,20);
1371 //  fListHist->Add(fHistAsMcSecondaryProdRadiusXvsYAntiLambdaMI);
1372
1373   fHistAsMcSecondaryMotherPdgCodeK0s           = new TH1F("h1AsMcSecondaryMotherPdgCodeK0s","Mother of Associated Secondary K^{0};mother;counts",11,0,11);
1374   fListHist->Add(fHistAsMcSecondaryMotherPdgCodeK0s);
1375 //  fHistAsMcSecondaryMotherPdgCodeK0sMI         = new TH1F("h1AsMcSecondaryMotherPdgCodeK0sMI","Mother of Associated Secondary K^{0} MI;mother;counts",11,0,11);
1376 //  fListHist->Add(fHistAsMcSecondaryMotherPdgCodeK0sMI);
1377
1378   fHistAsMcSecondaryMotherPdgCodeLambda        = new TH1F("h1AsMcSecondaryMotherPdgCodeLambda","Mother of Associated Secondary #Lambda^{0};mother;counts",11,0,11);
1379   fListHist->Add(fHistAsMcSecondaryMotherPdgCodeLambda);
1380 //  fHistAsMcSecondaryMotherPdgCodeLambdaMI      = new TH1F("h1AsMcSecondaryMotherPdgCodeLambdaMI","Mother of Associated Secondary #Lambda^{0} MI;mother;counts",11,0,11);
1381 //  fListHist->Add(fHistAsMcSecondaryMotherPdgCodeLambdaMI);
1382
1383   fHistAsMcSecondaryMotherPdgCodeAntiLambda    = new TH1F("h1AsMcSecondaryMotherPdgCodeAntiLambda","Mother of Associated Secondary #bar{#Lambda}^{0};mother;counts",11,0,11);
1384   fListHist->Add(fHistAsMcSecondaryMotherPdgCodeAntiLambda);
1385 //  fHistAsMcSecondaryMotherPdgCodeAntiLambdaMI  = new TH1F("h1AsMcSecondaryMotherPdgCodeAntiLambdaMI","Mother of Associated Secondary #bar{Lambda}^{0} MI;mother;counts",11,0,11);
1386 //  fListHist->Add(fHistAsMcSecondaryMotherPdgCodeAntiLambdaMI);
1387
1388   // Pt distribution Lambda from Sigma
1389   fHistAsMcSecondaryPtLambdaFromSigma          = new TH1F("h1AsMcSecondaryPtLambdaFromSigma","#Lambda}^{0} associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1390   fListHist->Add(fHistAsMcSecondaryPtLambdaFromSigma);
1391 //  fHistAsMcSecondaryPtLambdaFromSigmaMI        = new TH1F("h1AsMcSecondaryPtLambdaFromSigmaMI","#Lambda^{0} MI associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1392 //  fListHist->Add(fHistAsMcSecondaryPtLambdaFromSigmaMI);
1393
1394   fHistAsMcSecondaryPtAntiLambdaFromSigma      = new TH1F("h1AsMcSecondaryPtAntiLambdaFromSigma","#bar{#Lambda}^{0} associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1395   fListHist->Add(fHistAsMcSecondaryPtAntiLambdaFromSigma);
1396 //  fHistAsMcSecondaryPtAntiLambdaFromSigmaMI    = new TH1F("h1AsMcSecondaryPtAntiLambdaFromSigmaMI","#bar{#Lambda}^{0} MI associated from Sigma;p_{t} (GeV/c);Count",240,0,12);
1397 //  fListHist->Add(fHistAsMcSecondaryPtAntiLambdaFromSigmaMI);
1398
1399   PostData(1, fListHist);
1400   PostData(2, fCentrSelector);
1401
1402 }
1403
1404 //________________________________________________________________________
1405 void AliAnalysisTaskPerformanceStrange::UserExec(Option_t *) 
1406 {
1407   // Main loop
1408   // Called for each event
1409
1410   AliStack* stack = NULL;
1411   TClonesArray *mcArray = NULL;
1412   TArrayF mcPrimaryVtx;
1413
1414   fESD=(AliESDEvent *)InputEvent();
1415
1416   if (!fESD) {
1417     Printf("ERROR: fESD not available");
1418     return;
1419   }
1420
1421
1422   AliVEvent* lEvent = InputEvent();
1423   
1424   if (!lEvent) {
1425     Printf("ERROR: Event not available");
1426     return;
1427   }
1428
1429   fHistNumberEvents->Fill(0.5);
1430
1431   //******************
1432   // Trigger Selection ! Warning Works only for ESD, add protection in case of AOD loop
1433   //******************
1434
1435   Bool_t isSelected = 
1436     (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() 
1437      & AliVEvent::kMB);
1438   if (!isSelected) return;
1439   
1440   // Centrality selection
1441   static AliESDtrackCuts * trackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); // FIXME: make it a data member
1442   Bool_t isCentralitySelected = fCentrSelector->IsCentralityBinSelected(fESD,trackCuts); // FIXME esd track cuts if needed  
1443   if(!isCentralitySelected) return;
1444   // FIXME: add to hist number events another entry for centrality.
1445
1446  // Done by the AliPhysicsSelection Task ! Only the selected events are passed to this task
1447
1448   fHistNumberEvents->Fill(1.5);
1449
1450
1451   //*************************
1452   //End track multiplicity
1453   //*************************
1454
1455
1456   // Remove Events with no tracks
1457   //if (!(fESD->GetNumberOfTracks()))  return;
1458
1459   fHistNumberEvents->Fill(2.5);
1460   fHistTrackPerEvent->Fill(fESD->GetNumberOfTracks());
1461
1462   //*************************************
1463   // Cut used:
1464   //*************************************
1465       
1466   // Cut Rapidity:
1467   Double_t lCutRap  = 0.75;
1468
1469   // Cut AliKF Chi2 for Reconstructed particles
1470   Double_t cutChi2KF  = 1E3;
1471
1472   // If PID is used:
1473   Double_t lLimitPPID    = 0.7;
1474   Float_t cutNSigmaLowP  = 1E3;
1475   Float_t cutNSigmaHighP = 1E3;
1476   if (fUsePID.Contains("withPID")) {
1477     cutNSigmaLowP  = 5.0;
1478     cutNSigmaHighP = 3.0;
1479   }
1480
1481
1482   // Cut Daughters pt (GeV/c):
1483   Double_t cutMinPtDaughter = 0.160;
1484
1485   // Cut primary vertex:
1486   Double_t cutPrimVertex = 10.0;
1487
1488   // Min number of TPC clusters:
1489   Int_t nbMinTPCclusters = 80;
1490
1491   //*******************
1492   // PID parameters:
1493   //*******************
1494       
1495   Double_t fAlephParameters[5] = {0,0,0,0,0,};
1496
1497   fAlephParameters[0] = 0.0283086;
1498   fAlephParameters[1] = 2.63394e+01;
1499   fAlephParameters[2] = 5.04114e-11;
1500   fAlephParameters[3] = 2.12543e+00;
1501   fAlephParameters[4] = 4.88663e+00; 
1502
1503
1504   //*******************
1505   // Access MC:
1506   //*******************
1507   if (fAnalysisMC) {
1508     if(fAnalysisType == "ESD") {
1509       AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
1510       if (!eventHandler) {
1511         Printf("ERROR: Could not retrieve MC event handler");
1512         return;
1513       }    
1514       AliMCEvent* mcEvent = eventHandler->MCEvent();
1515       if (!mcEvent) {
1516         Printf("ERROR: Could not retrieve MC event");
1517         return;
1518       }    
1519       stack = mcEvent->Stack();
1520       if (!stack) {
1521         Printf("ERROR: Could not retrieve stack");
1522         return;
1523       }
1524       
1525       AliGenEventHeader* mcHeader=mcEvent->GenEventHeader();
1526       if(!mcHeader) return;
1527       mcHeader->PrimaryVertex(mcPrimaryVtx);
1528       
1529     }
1530     
1531     else if(fAnalysisType == "AOD") {
1532       
1533       // load MC particles
1534       mcArray = (TClonesArray*)fESD->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1535       if(!mcArray) {
1536         Printf("strange analysis::UserExec: MC particles branch not found!\n");
1537         return;
1538       }
1539       
1540       // load MC header
1541       AliAODMCHeader *mcHeader = 
1542         (AliAODMCHeader*)fESD->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1543       if(!mcHeader) {
1544         Printf("strange analysis::UserExec: MC header branch not found!\n");
1545         return;
1546       }
1547     }
1548
1549     // PID parameters for MC simulations:
1550     fAlephParameters[0] = 2.15898e+00/50.;
1551     fAlephParameters[1] = 1.75295e+01;
1552     fAlephParameters[2] = 3.40030e-09;
1553     fAlephParameters[3] = 1.96178e+00;
1554     fAlephParameters[4] = 3.91720e+00; 
1555   }
1556
1557
1558   //**********************************************
1559   // MC loop
1560   //**********************************************
1561
1562   Double_t lmcPrimVtxR      = 0;
1563
1564   Int_t lNbMCPrimary        = 0;
1565   Int_t lNbMCPart           = 0;
1566
1567   Int_t lPdgcodeCurrentPart = 0;
1568   Double_t lRapCurrentPart  = 0;
1569   Double_t lPtCurrentPart   = 0;
1570   
1571   Int_t lComeFromSigma      = 0;
1572
1573   
1574   // Production Radius
1575   Double_t mcPosX     = 0.0,  mcPosY      = 0.0,  mcPosZ      = 0.0;
1576   Double_t mcPosR     = 0.0;
1577
1578   // Decay Radius
1579   Double_t mcDecayPosX = 0, mcDecayPosY = 0, mcDecayPosR = 0;
1580
1581   // current mc particle 's mother
1582   Int_t iCurrentMother  = 0, lPdgCurrentMother    = 0;
1583   Bool_t lCurrentMotherIsPrimary;
1584
1585   // current mc particles 's daughter:
1586   Int_t lPdgCurrentDaughter0 = 0, lPdgCurrentDaughter1 = 0; 
1587
1588   // variables for multiple reconstruction studies:
1589   Int_t id0           = 0, id1          = 0;
1590   //Int_t lLabelTrackN  = 0, lLabelTrackP = 0;
1591   //Int_t lPartNMother  = 0, lPartPMother = 0;
1592   //Int_t lPartPMotherPDGcode      = 0;
1593   Int_t lNtimesReconstructedK0s   = 0, lNtimesReconstructedLambda   = 0, lNtimesReconstructedAntiLambda   = 0;
1594  // Int_t lNtimesReconstructedK0sMI = 0, lNtimesReconstructedLambdaMI = 0, lNtimesReconstructedAntiLambdaMI = 0;
1595
1596   //****************************
1597   // Start loop over MC particles
1598   if (fAnalysisMC) {
1599
1600     // Primary vertex
1601     fHistMCPrimaryVertexX->Fill(mcPrimaryVtx.At(0));
1602     fHistMCPrimaryVertexY->Fill(mcPrimaryVtx.At(1));
1603     fHistMCPrimaryVertexZ->Fill(mcPrimaryVtx.At(2));
1604     
1605     lmcPrimVtxR = TMath::Sqrt(mcPrimaryVtx.At(0)*mcPrimaryVtx.At(0)+mcPrimaryVtx.At(1)*mcPrimaryVtx.At(1));
1606   
1607
1608     if(fAnalysisType == "ESD") {
1609       
1610       lNbMCPrimary = stack->GetNprimary();
1611       lNbMCPart    = stack->GetNtrack();
1612       
1613       fHistMCMultiplicityPrimary->Fill(lNbMCPrimary);
1614       fHistMCMultiplicityTracks->Fill(lNbMCPart);
1615       
1616       
1617       for (Int_t iMc = 0; iMc < (stack->GetNtrack()); iMc++) {  
1618         TParticle *p0 = stack->Particle(iMc);
1619         if (!p0) {
1620           //Printf("ERROR: particle with label %d not found in stack (mc loop)", iMc);
1621           continue;
1622         }
1623         lPdgcodeCurrentPart = p0->GetPdgCode();
1624         
1625         // Keep only K0s, Lambda and AntiLambda, Xi and Phi:
1626         if ( (lPdgcodeCurrentPart != 310 ) && (lPdgcodeCurrentPart != 3122 ) && (lPdgcodeCurrentPart != -3122 ) && (lPdgcodeCurrentPart != 3312 ) && (lPdgcodeCurrentPart != -3312) && (lPdgcodeCurrentPart != -333) ) continue;
1627         
1628         lRapCurrentPart   = MyRapidity(p0->Energy(),p0->Pz());
1629         //lEtaCurrentPart   = p0->Eta();
1630         lPtCurrentPart    = p0->Pt();
1631
1632         iCurrentMother    = p0->GetFirstMother();
1633
1634 //      lPdgCurrentMother = stack->Particle(iCurrentMother)->GetPdgCode();
1635         if (iCurrentMother == -1){lPdgCurrentMother=0; } else {lPdgCurrentMother = stack->Particle(iCurrentMother)->GetPdgCode();}      
1636
1637         mcPosX = p0->Vx();
1638         mcPosY = p0->Vy();
1639         mcPosZ = p0->Vz();
1640         mcPosR = TMath::Sqrt(mcPosX*mcPosX+mcPosY*mcPosY);
1641         
1642         id0  = p0->GetDaughter(0);
1643         id1  = p0->GetDaughter(1);
1644
1645         // Decay Radius and Production Radius
1646         if ( id0 <= lNbMCPart && id0 > 0 && id1 <= lNbMCPart && id1 > 0) {
1647           TParticle *pDaughter0 = stack->Particle(id0);
1648           TParticle *pDaughter1 = stack->Particle(id1);
1649           lPdgCurrentDaughter0 = pDaughter0->GetPdgCode();
1650           lPdgCurrentDaughter1 = pDaughter1->GetPdgCode();
1651           
1652           mcDecayPosX = pDaughter0->Vx();
1653           mcDecayPosY = pDaughter0->Vy();
1654           mcDecayPosR = TMath::Sqrt(mcDecayPosX*mcDecayPosX+mcDecayPosY*mcDecayPosY);
1655         }
1656         else  {
1657           //FIXME: shouldn't this be a fatal?
1658           //Printf("ERROR: particle with label %d and/or %d not found in stack (mc loop)", id0,id1);
1659           mcDecayPosR = -1.0;
1660         }
1661         
1662         if (lPdgcodeCurrentPart==310)   {
1663           fHistMCtracksProdRadiusK0s->Fill(mcPosX,mcPosY);
1664           fHistMCtracksDecayRadiusK0s->Fill(mcDecayPosR);
1665           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllK0s->Fill(lPtCurrentPart);
1666         }
1667         else if (lPdgcodeCurrentPart==3122)  {
1668           fHistMCtracksProdRadiusLambda->Fill(mcPosX,mcPosY);
1669           fHistMCtracksDecayRadiusLambda->Fill(mcDecayPosR);
1670           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllLambda->Fill(lPtCurrentPart);
1671         }
1672         else if (lPdgcodeCurrentPart==-3122) {
1673           fHistMCtracksProdRadiusAntiLambda->Fill(mcPosX,mcPosY);
1674           fHistMCtracksDecayRadiusAntiLambda->Fill(mcDecayPosR);
1675           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllAntiLambda->Fill(lPtCurrentPart);
1676         }
1677         
1678           // FIXME: not sure if I understand this: is it correct?
1679         if ( ( ( TMath::Abs(lPdgCurrentMother) == 3212)  ||
1680                ( TMath::Abs(lPdgCurrentMother) == 3224)  ||
1681                ( TMath::Abs(lPdgCurrentMother) == 3214)  ||
1682                ( TMath::Abs(lPdgCurrentMother) == 3114) )
1683              && ( iCurrentMother <= lNbMCPrimary )
1684              ) lComeFromSigma = 1;
1685         else lComeFromSigma = 0;
1686         
1687         //*********************************************
1688         // Now keep only primary particles   
1689         if ( ( iMc > lNbMCPrimary ) && (!lComeFromSigma) ) continue;
1690
1691         //********************************************
1692         //check if V0 is reconstructed several times  
1693      
1694         lNtimesReconstructedK0s   = 0; lNtimesReconstructedLambda   = 0; lNtimesReconstructedAntiLambda   = 0;
1695         //lNtimesReconstructedK0sMI = 0; lNtimesReconstructedLambdaMI = 0; lNtimesReconstructedAntiLambdaMI = 0;
1696
1697         //for (Int_t jV0 = 0; jV0 < fESD->GetNumberOfV0s(); jV0++) {
1698         
1699         //lLabelTrackN  = 0; lLabelTrackP = 0;
1700         //lPartNMother  = 0; lPartPMother = 0;
1701         
1702         //AliESDv0    *vertexESD = ((AliESDEvent*)fESD)->GetV0(jV0);
1703         //if (!vertexESD) continue;
1704         
1705         //AliESDtrack *trackNESD = ((AliESDEvent*)fESD)->GetTrack(TMath::Abs(vertexESD->GetNindex()));
1706         //lLabelTrackN = (UInt_t)TMath::Abs(trackNESD->GetLabel());
1707         //if (lLabelTrackN!=id0 && lLabelTrackN!=id1) continue;
1708         
1709         //AliESDtrack *trackPESD = ((AliESDEvent*)fESD)->GetTrack(TMath::Abs(vertexESD->GetPindex()));
1710         //lLabelTrackP = (UInt_t)TMath::Abs(trackPESD->GetLabel());
1711         //if (lLabelTrackP!=id0 && lLabelTrackP!=id1) continue;
1712         
1713         //TParticle   *lPartNESD = stack->Particle(lLabelTrackN);
1714         //TParticle   *lPartPESD = stack->Particle(lLabelTrackP);
1715         //lPartNMother = lPartNESD->GetFirstMother();
1716         //lPartPMother = lPartPESD->GetFirstMother();
1717         
1718         //lPartPMotherPDGcode = stack->Particle(lPartPMother)->GetPdgCode();
1719         
1720         //switch (vertexESD->GetOnFlyStatus()){
1721         
1722         //case 0 : 
1723         //if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==310) ) lNtimesReconstructedK0s++;
1724         //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==3122) ) lNtimesReconstructedLambda++;
1725         //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==-3122) ) lNtimesReconstructedAntiLambda++;
1726         //break;
1727         
1728         //case 1 :
1729         //if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==310) ) lNtimesReconstructedK0sMI++;
1730         //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==3122) ) lNtimesReconstructedLambdaMI++;
1731         //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==-3122) ) lNtimesReconstructedAntiLambdaMI++;
1732         //break;
1733         
1734         //}     
1735         //} // end loop over reconstructed V0s inside MC loop
1736 ;
1737  
1738         // Rap distribution
1739         if (lPdgcodeCurrentPart==310) {
1740           fHistMCRapK0s->Fill(lRapCurrentPart);
1741           if (lPtCurrentPart < 0.2 && lPtCurrentPart < 3.0)
1742             fHistMCRapInPtRangeK0s->Fill(lRapCurrentPart);
1743         }
1744
1745         if (lPdgcodeCurrentPart==3122) {
1746           fHistMCRapLambda->Fill(lRapCurrentPart);
1747           if (lPtCurrentPart < 0.6 && lPtCurrentPart < 3.5)
1748             fHistMCRapInPtRangeLambda->Fill(lRapCurrentPart);
1749         }
1750
1751         if (lPdgcodeCurrentPart==-3122) {
1752           fHistMCRapAntiLambda->Fill(lRapCurrentPart);
1753           if (lPtCurrentPart < 0.6 && lPtCurrentPart < 3.5)
1754             fHistMCRapInPtRangeAntiLambda->Fill(lRapCurrentPart);
1755         }
1756
1757         if (lPdgcodeCurrentPart==3312 || lPdgcodeCurrentPart==-3312) {
1758           fHistMCRapXi->Fill(lRapCurrentPart);
1759           if (lPtCurrentPart < 0.6 && lPtCurrentPart < 3.0)
1760             fHistMCRapInPtRangeXi->Fill(lRapCurrentPart);
1761         }
1762
1763         if (lPdgcodeCurrentPart==333) {
1764           fHistMCRapPhi->Fill(lRapCurrentPart);
1765           if (lPtCurrentPart < 0.7 && lPtCurrentPart < 3.0)
1766             fHistMCRapInPtRangePhi->Fill(lRapCurrentPart);
1767         }
1768  
1769         // Rapidity Cut
1770         if (TMath::Abs(lRapCurrentPart) > lCutRap) continue;
1771  
1772         if (lPdgcodeCurrentPart==310) {
1773           fHistMCProdRadiusK0s->Fill(mcPosR);
1774
1775           fHistMCPtK0s->Fill(lPtCurrentPart);
1776
1777
1778
1779           fHistNTimesRecK0s->Fill(lNtimesReconstructedK0s);
1780         //  fHistNTimesRecK0sMI->Fill(lNtimesReconstructedK0s);
1781           fHistNTimesRecK0sVsPt->Fill(lPtCurrentPart,lNtimesReconstructedK0s);
1782         //  fHistNTimesRecK0sVsPtMI->Fill(lPtCurrentPart,lNtimesReconstructedK0sMI);
1783         }
1784         else 
1785         if (lPdgcodeCurrentPart==3122) {
1786           fHistMCProdRadiusLambda->Fill(mcPosR);
1787
1788           fHistMCPtLambda->Fill(lPtCurrentPart);          
1789
1790
1791           fHistNTimesRecLambda->Fill(lNtimesReconstructedLambda);
1792         //  fHistNTimesRecLambdaMI->Fill(lNtimesReconstructedLambdaMI);
1793           fHistNTimesRecLambdaVsPt->Fill(lPtCurrentPart,lNtimesReconstructedLambda);
1794          // fHistNTimesRecLambdaVsPtMI->Fill(lPtCurrentPart,lNtimesReconstructedLambdaMI);
1795           if (lComeFromSigma) fHistMCPtLambdaFromSigma->Fill(lPtCurrentPart);
1796
1797           //printf("found Lambda MC pT=%e\n",lPtCurrentPart);
1798           //printf("found Lambda MC Plabel=%d PPDGcode=%d Nlabel=%d NPDGcode=%d\n\n",id0,lPdgCurrentDaughter0,id1,lPdgCurrentDaughter1); 
1799           
1800         }
1801
1802         
1803       } // end loop ESD MC
1804       
1805     } // end ESD condition
1806
1807     else if(fAnalysisType == "AOD") {
1808       lNbMCPart = mcArray->GetEntriesFast();
1809       lNbMCPrimary = 0;
1810       
1811       fHistMCMultiplicityTracks->Fill(lNbMCPart);
1812       
1813       for (Int_t iMc = 0; iMc < lNbMCPart; iMc++) {  
1814         
1815         // Primary vertex TO DO !!
1816         //
1817         
1818         AliAODMCParticle *mcAODPart = (AliAODMCParticle*)mcArray->At(iMc);
1819         if (!mcAODPart) {
1820           //Printf("Strange analysis task (mc loop): particle with label %d not found", iMc);
1821           continue;
1822         }
1823         lPdgcodeCurrentPart = mcAODPart->GetPdgCode();
1824         if (mcAODPart->IsPhysicalPrimary()) {lNbMCPrimary = lNbMCPrimary +1;}
1825         
1826         // Keep only K0s, Lambda and AntiLambda:
1827         if ( (lPdgcodeCurrentPart != 310 ) && (lPdgcodeCurrentPart != 3122 ) && (lPdgcodeCurrentPart != -3122 ) ) continue;
1828         
1829         //lEtaCurrentPart   = mcAODPart->Eta();
1830         lRapCurrentPart   = mcAODPart->Y();
1831         lPtCurrentPart    = mcAODPart->Pt();
1832         iCurrentMother    = mcAODPart->GetMother();
1833         lPdgCurrentMother = ((AliAODMCParticle*)mcArray->At(iCurrentMother))->GetPdgCode();
1834         lCurrentMotherIsPrimary = ((AliAODMCParticle*)mcArray->At(iCurrentMother))->IsPhysicalPrimary();
1835         
1836         mcPosX = mcAODPart->Xv();
1837         mcPosY = mcAODPart->Yv();
1838         mcPosZ = mcAODPart->Zv();
1839         mcPosR = TMath::Sqrt(mcPosX*mcPosX+mcPosY*mcPosY);
1840         
1841         id0  = mcAODPart->GetDaughter(0);
1842         id1  = mcAODPart->GetDaughter(1);
1843         
1844         // Decay Radius and Production Radius
1845         if ( id0 <= lNbMCPart && id0 > 0 && id1 <= lNbMCPart && id1 > 0) {
1846           AliAODMCParticle *mcAODDaughter1 = (AliAODMCParticle*)mcArray->At(id1);
1847           if (!mcAODPart) {
1848             //Printf("Strange analysis task (mc loop): daughter not found");
1849             continue;
1850           }
1851           mcDecayPosX = mcAODDaughter1->Xv();
1852           mcDecayPosY = mcAODDaughter1->Yv();
1853           mcDecayPosR = TMath::Sqrt(mcDecayPosX*mcDecayPosX+mcDecayPosY*mcDecayPosY);
1854         }
1855         else  {
1856           //Printf("ERROR: particle with label %d and/or %d not found in stack (mc loop)", id0,id1);
1857           mcDecayPosR = -1.0;
1858         }
1859         
1860         if (lPdgcodeCurrentPart==310)   {
1861           fHistMCtracksProdRadiusK0s->Fill(mcPosX,mcPosY);
1862           fHistMCtracksDecayRadiusK0s->Fill(mcDecayPosR);
1863           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllK0s->Fill(lPtCurrentPart);
1864         }
1865         else if (lPdgcodeCurrentPart==3122)  {
1866           fHistMCtracksProdRadiusLambda->Fill(mcPosX,mcPosY);
1867           fHistMCtracksDecayRadiusLambda->Fill(mcDecayPosR);
1868           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllLambda->Fill(lPtCurrentPart);
1869         }
1870         else if (lPdgcodeCurrentPart==-3122) {
1871           fHistMCtracksProdRadiusAntiLambda->Fill(mcPosX,mcPosY);
1872           fHistMCtracksDecayRadiusAntiLambda->Fill(mcDecayPosR);
1873           if (TMath::Abs(lRapCurrentPart) < lCutRap) fHistMCPtAllAntiLambda->Fill(lPtCurrentPart);
1874         }
1875         
1876         if ( ( ( TMath::Abs(lPdgCurrentMother) == 3212)  ||
1877                ( TMath::Abs(lPdgCurrentMother) == 3224)  ||
1878                ( TMath::Abs(lPdgCurrentMother) == 3214)  ||
1879                ( TMath::Abs(lPdgCurrentMother) == 3114) )
1880              && (lCurrentMotherIsPrimary)
1881              ) lComeFromSigma = 1;
1882         else lComeFromSigma = 0;
1883       
1884         //*********************************************
1885         // Now keep only primary particles 
1886          
1887         // FIX IT !!!!    iMC is not defined !!!! FIX IT also in ESD/AOD loop !!
1888         if ( ( iMc > lNbMCPrimary ) && (!lComeFromSigma) ) continue;
1889
1890         //********************************************
1891         // check if V0 is reconstructed several times  
1892         
1893         //lNtimesReconstructedK0s   = 0; lNtimesReconstructedLambda   = 0; lNtimesReconstructedAntiLambda   = 0;
1894         //lNtimesReconstructedK0sMI = 0; lNtimesReconstructedLambdaMI = 0; lNtimesReconstructedAntiLambdaMI = 0;
1895             
1896         //for (Int_t jV0 = 0; jV0 < fESD->GetNumberOfV0s(); jV0++) {
1897         
1898         //lLabelTrackN  = 0; lLabelTrackP = 0;
1899         //lPartNMother  = 0; lPartPMother = 0;
1900
1901         //AliAODv0    *vertexAOD= ((AliAODEvent*)fESD)->GetV0(jV0);
1902         //if (!vertexAOD) continue;
1903         //printf("enter!!");
1904         //AliVParticle  *trackP  = ((AliVEvent*)fESD)->GetTrack(vertexAOD->GetPosID());
1905         //if (!trackP) continue;
1906         //lLabelTrackP = TMath::Abs(trackP->GetLabel());
1907         //if (lLabelTrackP!=id0 && lLabelTrackP!=id1) continue;
1908        
1909         //AliVParticle  *trackN  = ((AliVEvent*)fESD)->GetTrack(vertexAOD->GetNegID());
1910         //if (!trackN) continue;
1911         //lLabelTrackN = TMath::Abs(trackN->GetLabel());
1912         //if (lLabelTrackN!=id0 && lLabelTrackN!=id1) continue;
1913         
1914         //AliAODMCParticle *lPartNAOD = (AliAODMCParticle*)mcArray->At(lLabelTrackN);
1915         //if (!lPartNAOD) continue;
1916         //AliAODMCParticle *lPartPAOD = (AliAODMCParticle*)mcArray->At(lLabelTrackP);
1917         //if (!lPartPAOD) continue;
1918         
1919         //lPartNMother = lPartNAOD->GetMother();
1920         //lPartPMother = lPartPAOD->GetMother();
1921
1922         //lPartPMotherPDGcode = ((AliAODMCParticle*)mcArray->At(lPartPMother))->GetPdgCode();
1923         
1924         //switch (vertexAOD->GetOnFlyStatus()){
1925           
1926         //case 0 : 
1927           //if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==310) ) lNtimesReconstructedK0s++;
1928           //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==3122) ) lNtimesReconstructedLambda++;
1929           //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==-3122) ) lNtimesReconstructedAntiLambda++;
1930           //break;
1931           
1932         //case 1 :
1933           //if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==310) ) lNtimesReconstructedK0sMI++;
1934           //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==3122) ) lNtimesReconstructedLambdaMI++;
1935           //else if ( (lPartPMother==lPartNMother) && (lPartPMotherPDGcode==-3122) ) lNtimesReconstructedAntiLambdaMI++;
1936           //break;
1937           
1938        ///}     
1939       //} // end loop over reconstructed V0s inside MC loop
1940     
1941         if (TMath::Abs(lRapCurrentPart) > lCutRap) continue;
1942  
1943         if (lPdgcodeCurrentPart==310) {
1944           fHistMCProdRadiusK0s->Fill(mcPosR);
1945           fHistMCPtK0s->Fill(lPtCurrentPart);
1946           fHistNTimesRecK0s->Fill(lNtimesReconstructedK0s);
1947         //  fHistNTimesRecK0sMI->Fill(lNtimesReconstructedK0s);
1948           fHistNTimesRecK0sVsPt->Fill(lPtCurrentPart,lNtimesReconstructedK0s);
1949         //  fHistNTimesRecK0sVsPtMI->Fill(lPtCurrentPart,lNtimesReconstructedK0sMI);
1950         }
1951         else if (lPdgcodeCurrentPart==3122) {
1952           fHistMCProdRadiusLambda->Fill(mcPosR);
1953           fHistMCPtLambda->Fill(lPtCurrentPart);
1954           fHistNTimesRecLambda->Fill(lNtimesReconstructedLambda);
1955         //  fHistNTimesRecLambdaMI->Fill(lNtimesReconstructedLambdaMI);
1956           fHistNTimesRecLambdaVsPt->Fill(lPtCurrentPart,lNtimesReconstructedLambda);
1957         //  fHistNTimesRecLambdaVsPtMI->Fill(lPtCurrentPart,lNtimesReconstructedLambdaMI);
1958           if (lComeFromSigma) fHistMCPtLambdaFromSigma->Fill(lPtCurrentPart);
1959         }
1960         else if (lPdgcodeCurrentPart==-3122) {
1961           fHistMCProdRadiusAntiLambda->Fill(mcPosR);
1962           //fHistMCPtAntiLambda->Fill(lPtCurrentPart);
1963           fHistNTimesRecAntiLambda->Fill(lNtimesReconstructedAntiLambda);
1964         //  fHistNTimesRecAntiLambdaMI->Fill(lNtimesReconstructedAntiLambdaMI);
1965           fHistNTimesRecAntiLambdaVsPt->Fill(lPtCurrentPart,lNtimesReconstructedAntiLambda);
1966         //  fHistNTimesRecAntiLambdaVsPtMI->Fill(lPtCurrentPart,lNtimesReconstructedAntiLambdaMI);
1967           if (lComeFromSigma) fHistMCPtAntiLambdaFromSigma->Fill(lPtCurrentPart);
1968         }
1969
1970       } // end loop over AODMC particles 
1971       fHistMCMultiplicityPrimary->Fill(lNbMCPrimary);
1972       
1973     } // end AOD condition
1974
1975   } // End Loop over MC condition
1976
1977   
1978
1979
1980
1981   //************************************
1982   // ESD or AOD loop 
1983   //************************************
1984
1985   Double_t lMagneticField = 999;
1986
1987   //Multiplcity:
1988   Int_t    nv0sTot= 0, nv0s = 0;
1989 //  Int_t nv0sMI =0;   
1990   // Variables:
1991   Double_t  lV0Position[3];
1992  
1993   Double_t lDcaPosToPrimVertex = 0;
1994   Double_t lDcaNegToPrimVertex = 0;
1995   Double_t lDcaV0Daughters     = 0;
1996   Double_t lV0cosPointAngle    = 0;
1997   Double_t lChi2V0             = 0;
1998   Double_t lV0DecayLength      = 0;
1999   Double_t lV0Radius           = 0;
2000   Double_t lDcaV0ToPrimVertex  = 0;
2001   
2002   Int_t    lOnFlyStatus        = 0;
2003   //Float_t   tdcaPosToPrimVertexXYZ[2], tdcaNegToPrimVertexXYZ[2]; // ..[0] = Impact parameter in XY plane and ..[1] = Impact parameter in Z            
2004   //Double_t  tdcaDaughterToPrimVertex[2];                          // ..[0] = Pos and ..[1] = Neg
2005
2006   
2007
2008   Double_t lInvMassK0s = 0, lInvMassLambda = 0, lInvMassAntiLambda = 0;
2009   Double_t lPtK0s      = 0, lPtLambda      = 0, lPtAntiLambda      = 0;
2010   Double_t lRapK0s     = 0, lRapLambda     = 0, lRapAntiLambda     = 0;
2011   Double_t lEtaK0s     = 0, lEtaLambda     = 0, lEtaAntiLambda     = 0;
2012   Double_t lAlphaV0      = 0, lPtArmV0       = 0;
2013
2014   Double_t lPzK0s      = 0, lPzLambda      = 0, lPzAntiLambda      = 0;
2015
2016
2017   Double_t lV0Eta = 999;
2018   
2019   // to study Associated V0s:
2020   Int_t    lIndexTrackPos       = 0, lIndexTrackNeg         = 0;
2021   UInt_t   lLabelTrackPos       = 0, lLabelTrackNeg         = 0;
2022   Int_t    lCheckPIdK0Short     = 0, lCheckMcK0Short        = 0;
2023   Int_t    lCheckPIdLambda      = 0, lCheckMcLambda         = 0;
2024   Int_t    lCheckPIdAntiLambda  = 0, lCheckMcAntiLambda     = 0;
2025   Int_t    lCheckSecondaryK0s   = 0, lCheckSecondaryLambda  = 0, lCheckSecondaryAntiLambda  = 0;
2026   Int_t    lCheckGamma          = 0;
2027   Double_t mcPosMotherX         = 0, mcPosMotherY           = 0, mcPosMotherZ  = 0;
2028   Double_t mcPosMotherR         = 0;
2029   Double_t mcMotherPt           = 0;
2030
2031   Int_t lIndexPosMother        = 0;
2032   Int_t lIndexNegMother        = 0;
2033   Int_t lIndexMotherOfMother   = 0;
2034   Int_t lPDGCodePosDaughter    = 0;
2035   Int_t lPDGCodeNegDaughter    = 0;
2036   Int_t lPdgcodeMother         = 0;
2037   Int_t lPdgcodeMotherOfMother = 0;
2038
2039   // Reconstructed position
2040   Double_t rcPosXK0s        = 0,  rcPosYK0s        = 0, rcPosZK0s        = 0;
2041   Double_t rcPosRK0s        = 0;
2042   Double_t rcPosXLambda     = 0,  rcPosYLambda     = 0, rcPosZLambda     = 0;
2043   Double_t rcPosRLambda     = 0;
2044   Double_t rcPosXAntiLambda = 0,  rcPosYAntiLambda = 0, rcPosZAntiLambda = 0;
2045   Double_t rcPosRAntiLambda = 0;
2046
2047   // Pt resolution
2048   Double_t deltaPtK0s  = 0, deltaPtLambda  = 0, deltaPtAntiLambda  = 0;
2049
2050   // Daughters
2051   AliESDtrack  *myTrackPos  = NULL;
2052   AliESDtrack  *myTrackNeg  = NULL;
2053   AliVParticle *lVPartPos   = NULL;
2054   AliVParticle *lVPartNeg   = NULL;
2055
2056   // Daughters' momentum:
2057   Double_t  lMomPos[3] = {999,999,999};
2058   Double_t  lMomNeg[3] = {999,999,999};
2059   Double_t  lPtPos = 999, lPtNeg = 999;
2060   Double_t  lPPos = 999, lPNeg = 999;
2061
2062   // Inner Wall parameters:
2063   Double_t  lMomInnerWallPos =999, lMomInnerWallNeg = 999;
2064
2065   // AliKF Chi2 and Armenteros variables
2066   Double_t lChi2KFK0s  = 0, lChi2KFLambda = 0,  lChi2KFAntiLambda = 0;
2067   Double_t lAlphaV0K0s = 0, lAlphaV0Lambda = 0,  lAlphaV0AntiLambda = 0;
2068   Double_t lPtArmV0K0s = 0, lPtArmV0Lambda = 0,  lPtArmV0AntiLambda = 0;
2069   Double_t lQlPos   = 0, lQlNeg   = 0;
2070
2071
2072   // PID
2073   Float_t nSigmaPosPion   = 0;
2074   Float_t nSigmaNegPion   = 0;
2075
2076   Float_t nSigmaPosProton = 0;
2077   Float_t nSigmaNegProton = 0;
2078
2079   Int_t lCheckPIDK0sPosDaughter        = 0, lCheckPIDK0sNegDaughter        = 0;
2080   Int_t lCheckPIDLambdaPosDaughter     = 0, lCheckPIDLambdaNegDaughter     = 0;
2081   Int_t lCheckPIDAntiLambdaPosDaughter = 0, lCheckPIDAntiLambdaNegDaughter = 0;
2082
2083   
2084   
2085   //***********************
2086   // Primary Vertex cuts &
2087   // Magnetic field and Quality tracks cuts 
2088
2089   Double_t  lPrimaryVtxPosition[3];
2090   Double_t  lPrimaryVtxCov[6];
2091   Double_t  lPrimaryVtxChi2 = 999;
2092   Double_t  lResPrimaryVtxX = 999;
2093   Double_t  lResPrimaryVtxY = 999;
2094   Double_t  lResPrimaryVtxZ = 999;
2095      
2096   AliAODVertex *myPrimaryVertex = NULL;
2097   //const AliVVertex *mySPDPrimaryVertex = NULL;
2098
2099   AliESDtrackCuts *myTracksCuts = NULL;
2100      
2101   const AliMultiplicity *myMultiplicty = ((AliESDEvent*)fESD)->GetMultiplicity();
2102
2103   if(fAnalysisType == "ESD") {  
2104   
2105     // Best Primary Vertex:  
2106     const AliESDVertex *myBestPrimaryVertex = ((AliESDEvent*)fESD)->GetPrimaryVertex();
2107     myBestPrimaryVertex = ((AliESDEvent*)fESD)->GetPrimaryVertex();
2108     if (!myBestPrimaryVertex) return;
2109     if (!myBestPrimaryVertex->GetStatus()) return;
2110     fHistNumberEvents->Fill(3.5);
2111     myBestPrimaryVertex->GetXYZ(lPrimaryVtxPosition);
2112     myBestPrimaryVertex->GetCovMatrix(lPrimaryVtxCov);
2113     if ( ( TMath::Abs(lPrimaryVtxPosition[2]) ) > cutPrimVertex) return ;
2114     fHistNumberEvents->Fill(4.5);    
2115     lPrimaryVtxChi2 = myBestPrimaryVertex->GetChi2toNDF();
2116     lResPrimaryVtxX = myBestPrimaryVertex->GetXRes();
2117     lResPrimaryVtxY = myBestPrimaryVertex->GetYRes();
2118     lResPrimaryVtxZ = myBestPrimaryVertex->GetZRes();
2119
2120     // remove TPC-only primary vertex : retain only events with tracking + SPD vertex
2121     const AliESDVertex *mySPDPrimaryVertex = ((AliESDEvent*)fESD)->GetPrimaryVertexSPD();
2122     if (!mySPDPrimaryVertex) return;
2123     fHistSPDPrimaryVertexZ->Fill(mySPDPrimaryVertex->GetZ());
2124     const AliESDVertex *myPrimaryVertexTracking = ((AliESDEvent*)fESD)->GetPrimaryVertexTracks();
2125     if (!myPrimaryVertexTracking) return;
2126     if (!mySPDPrimaryVertex->GetStatus() && !myPrimaryVertexTracking->GetStatus() ) return;
2127     fHistNumberEvents->Fill(5.5);
2128
2129     
2130     myPrimaryVertex = new AliAODVertex(lPrimaryVtxPosition, lPrimaryVtxCov, lPrimaryVtxChi2, NULL, -1, AliAODVertex::kPrimary);
2131     if (!myPrimaryVertex) return;
2132
2133
2134      // Number of Tracklets:
2135     //const AliMultiplicity *myMultiplicty = ((AliESDEvent*)fESD)->GetMultiplicity();
2136     //if (myMultiplicty->GetNumberOfTracklets() < 10) return;
2137     fHistTrackletPerEvent->Fill(myMultiplicty->GetNumberOfTracklets());
2138
2139     lMagneticField = ((AliESDEvent*)fESD)->GetMagneticField();
2140
2141     myTracksCuts = new AliESDtrackCuts();
2142     // require TPC refit
2143     myTracksCuts->SetRequireTPCRefit(kTRUE);
2144     // minimum number of clusters in TPC
2145     myTracksCuts->SetMinNClustersTPC(nbMinTPCclusters);
2146
2147   }
2148   
2149   else if(fAnalysisType == "AOD") {
2150     printf("enter AOD!!");
2151     myPrimaryVertex = ((AliAODEvent*)fESD)->GetPrimaryVertex();
2152     if (!myPrimaryVertex) return;
2153
2154     lPrimaryVtxPosition[0] = myPrimaryVertex->GetX();
2155     lPrimaryVtxPosition[1] = myPrimaryVertex->GetY();
2156     lPrimaryVtxPosition[2] = myPrimaryVertex->GetZ();
2157
2158     // Cut on SPD vertex and fill histo Nevents: FIX it !
2159
2160      // Tracks cuts FIX IT !
2161
2162     // FIX it !!!
2163     lMagneticField = 999;   
2164
2165   }
2166
2167  
2168   fHistPrimaryVertexX->Fill(lPrimaryVtxPosition[0]);
2169   fHistPrimaryVertexY->Fill(lPrimaryVtxPosition[1]);
2170   fHistPrimaryVertexZ->Fill(lPrimaryVtxPosition[2]);
2171   //Double_t lrcPrimVtxR = TMath::Sqrt(lPrimaryVtxPosition[0]*lPrimaryVtxPosition[0]+lPrimaryVtxPosition[0]*lPrimaryVtxPosition[0]);
2172
2173   fHistPrimaryVertexResX->Fill(lResPrimaryVtxX);
2174   fHistPrimaryVertexResY->Fill(lResPrimaryVtxY);
2175   fHistPrimaryVertexResZ->Fill(lResPrimaryVtxZ);
2176
2177
2178   //***********************
2179   // AliKF Primary Vertex
2180
2181   AliKFVertex primaryVtxKF( *myPrimaryVertex );
2182   AliKFParticle::SetField(lMagneticField);
2183
2184
2185   //************************************
2186   // PID
2187
2188   AliESDpid *fESDpid = new AliESDpid(); // FIXME delete
2189   fESDpid->GetTPCResponse().SetBetheBlochParameters(fAlephParameters[0],fAlephParameters[1],fAlephParameters[2],fAlephParameters[3],fAlephParameters[4]); 
2190       
2191
2192
2193   //***Rerun the V0 finder
2194
2195 //  fESD->ResetV0s();
2196 //  AliV0vertexer v0Vertexer;
2197 //  v0Vertexer.SetCuts(fCuts);
2198 //  v0Vertexer.Tracks2V0vertices(fESD);
2199   
2200   //*************************
2201   // V0 loop
2202       
2203   nv0sTot = fESD->GetNumberOfV0s();
2204   if (!nv0sTot) fHistNumberEvents->Fill(6.5);
2205
2206   for (Int_t iV0 = 0; iV0 < nv0sTot; iV0++) {
2207     
2208     // ALiKF
2209     AliKFParticle* negPiKF = NULL;
2210     AliKFParticle* posPiKF = NULL;
2211     AliKFParticle* posPKF  = NULL;
2212     AliKFParticle* negAPKF = NULL;
2213
2214     
2215     lIndexPosMother     = 0; lIndexNegMother     = 0; lIndexMotherOfMother       = 0;
2216     lCheckPIdK0Short    = 0; lCheckMcK0Short     = 0; lCheckSecondaryK0s         = 0;
2217     lCheckPIdLambda     = 0; lCheckMcLambda      = 0; lCheckSecondaryLambda      = 0;
2218     lCheckPIdAntiLambda = 0; lCheckMcAntiLambda  = 0; lCheckSecondaryAntiLambda  = 0;       
2219     lComeFromSigma      = -1;
2220     
2221     
2222     if(fAnalysisType == "ESD") {
2223
2224
2225       AliESDv0 *v0 = ((AliESDEvent*)fESD)->GetV0(iV0);
2226       if (!v0) continue;
2227       
2228       // Primary vertex:
2229       fHistPrimaryVertexPosXV0events->Fill(lPrimaryVtxPosition[0]);
2230       fHistPrimaryVertexPosYV0events->Fill(lPrimaryVtxPosition[1]);
2231       fHistPrimaryVertexPosZV0events->Fill(lPrimaryVtxPosition[2]);
2232       
2233       // V0's Daughters
2234       lIndexTrackPos = TMath::Abs(v0->GetPindex());
2235       lIndexTrackNeg = TMath::Abs(v0->GetNindex());
2236       AliESDtrack *myTrackPosTest = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackPos);
2237       AliESDtrack *myTrackNegTest = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackNeg);
2238       if (!myTrackPosTest || !myTrackNegTest) {
2239         Printf("strange analysis::UserExec:: Error:Could not retreive one of the daughter track\n");
2240         continue;
2241       }
2242       // Remove like-sign
2243       if ( myTrackPosTest->GetSign() == myTrackNegTest->GetSign()){
2244         continue;
2245       } 
2246      
2247       // VO's main characteristics to check the reconstruction cuts
2248       lOnFlyStatus       = v0->GetOnFlyStatus();
2249       lChi2V0            = v0->GetChi2V0();
2250       lDcaV0Daughters    = v0->GetDcaV0Daughters();
2251       lDcaV0ToPrimVertex = v0->GetD(lPrimaryVtxPosition[0],lPrimaryVtxPosition[1],lPrimaryVtxPosition[2]);
2252       lV0cosPointAngle   = v0->GetV0CosineOfPointingAngle(lPrimaryVtxPosition[0],lPrimaryVtxPosition[1], lPrimaryVtxPosition[2]);
2253
2254       v0->GetXYZ(lV0Position[0], lV0Position[1], lV0Position[2]);
2255
2256       lV0Radius      = TMath::Sqrt(lV0Position[0]*lV0Position[0]+lV0Position[1]*lV0Position[1]);
2257       lV0DecayLength = TMath::Sqrt(TMath::Power(lV0Position[0] - lPrimaryVtxPosition[0],2) +
2258                                    TMath::Power(lV0Position[1] - lPrimaryVtxPosition[1],2) +
2259                                    TMath::Power(lV0Position[2] - lPrimaryVtxPosition[2],2 ));
2260
2261
2262       if( myTrackPosTest->GetSign() ==1){
2263         
2264         myTrackPos = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackPos);
2265         myTrackNeg = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackNeg);
2266
2267         // Daughters' momentum;
2268         v0->GetPPxPyPz(lMomPos[0],lMomPos[1],lMomPos[2]);
2269         v0->GetNPxPyPz(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
2270
2271         if (negPiKF) delete negPiKF; negPiKF=NULL;
2272         if (posPiKF) delete posPiKF; posPiKF=NULL;
2273         if (posPKF)  delete posPKF;  posPKF=NULL;
2274         if (negAPKF) delete negAPKF; negAPKF=NULL;
2275         
2276         negPiKF = new AliKFParticle( *(v0->GetParamN()) ,-211);
2277         posPiKF = new AliKFParticle( *(v0->GetParamP()) ,211);
2278         posPKF  = new AliKFParticle( *(v0->GetParamP()) ,2212);
2279         negAPKF = new AliKFParticle( *(v0->GetParamN()) ,-2212);
2280         
2281       }
2282            
2283       if( myTrackPosTest->GetSign() ==-1){
2284         
2285         myTrackPos = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackNeg);
2286         myTrackNeg = ((AliESDEvent*)fESD)->GetTrack(lIndexTrackPos);
2287
2288         // Daughters' momentum;
2289         v0->GetPPxPyPz(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
2290         v0->GetNPxPyPz(lMomPos[0],lMomPos[1],lMomPos[2]);
2291
2292         if (negPiKF) delete negPiKF; negPiKF=NULL;
2293         if (posPiKF) delete posPiKF; posPiKF=NULL;
2294         if (posPKF)  delete posPKF;  posPKF=NULL;
2295         if (negAPKF) delete negAPKF; negAPKF=NULL;
2296         
2297         negPiKF = new AliKFParticle( *(v0->GetParamP()) ,-211);
2298         posPiKF = new AliKFParticle( *(v0->GetParamN()) ,211);
2299         posPKF  = new AliKFParticle( *(v0->GetParamN()) ,2212);
2300         negAPKF = new AliKFParticle( *(v0->GetParamP()) ,-2212);
2301
2302       }
2303
2304       lLabelTrackPos = (UInt_t)TMath::Abs(myTrackPos->GetLabel());
2305       lLabelTrackNeg = (UInt_t)TMath::Abs(myTrackNeg->GetLabel());
2306
2307       // Daughters Pt and P:
2308       lPtPos = TMath::Sqrt(lMomPos[0]*lMomPos[0] + lMomPos[1]*lMomPos[1]);
2309       lPtNeg = TMath::Sqrt(lMomNeg[0]*lMomNeg[0] + lMomNeg[1]*lMomNeg[1]);
2310
2311       lPPos = TMath::Sqrt(lMomPos[0]*lMomPos[0] + lMomPos[1]*lMomPos[1] + lMomPos[2]*lMomPos[2]);
2312       lPNeg = TMath::Sqrt(lMomNeg[0]*lMomNeg[0] + lMomNeg[1]*lMomNeg[1] + lMomNeg[2]*lMomNeg[2]);
2313
2314       // Inner Wall parameter:
2315       const AliExternalTrackParam *myInnerWallTrackPos = myTrackPos->GetInnerParam(); 
2316       if(myInnerWallTrackPos) lMomInnerWallPos = myInnerWallTrackPos->GetP(); 
2317       const AliExternalTrackParam *myInnerWallTrackNeg = myTrackNeg->GetInnerParam(); 
2318       if(myInnerWallTrackNeg) lMomInnerWallNeg = myInnerWallTrackNeg->GetP(); 
2319               
2320       // DCA between daughter and Primary Vertex:
2321       if (myTrackPos) lDcaPosToPrimVertex = TMath::Abs(myTrackPos->GetD(lPrimaryVtxPosition[0],lPrimaryVtxPosition[1],lMagneticField) );
2322       
2323       if (myTrackNeg) lDcaNegToPrimVertex = TMath::Abs(myTrackNeg->GetD(lPrimaryVtxPosition[0],lPrimaryVtxPosition[1],lMagneticField) );
2324       
2325       // Quality tracks cuts:
2326       if ( !(myTracksCuts->IsSelected(myTrackPos)) || !(myTracksCuts->IsSelected(myTrackNeg)) ) {
2327         if (negPiKF) delete negPiKF; negPiKF=NULL;
2328         if (posPiKF) delete posPiKF; posPiKF=NULL;
2329         if (posPKF)  delete posPKF;  posPKF=NULL;
2330         if (negAPKF) delete negAPKF; negAPKF=NULL;  
2331         continue;
2332       }
2333       // Armenteros variables:
2334       lAlphaV0      =  v0->AlphaV0();
2335       lPtArmV0      =  v0->PtArmV0();
2336
2337       // Pseudorapidity:
2338       lV0Eta = v0->Eta();
2339       
2340       // PID
2341       if (fUsePID.Contains("withPID")) {
2342         nSigmaPosPion   = TMath::Abs(fESDpid->NumberOfSigmasTPC(myTrackPos,AliPID::kPion));
2343         
2344         nSigmaNegPion   = TMath::Abs(fESDpid->NumberOfSigmasTPC(myTrackNeg,AliPID::kPion));
2345
2346         nSigmaPosProton = TMath::Abs(fESDpid->NumberOfSigmasTPC(myTrackPos,AliPID::kProton));
2347         
2348         nSigmaNegProton = TMath::Abs(fESDpid->NumberOfSigmasTPC(myTrackNeg,AliPID::kProton));
2349       }
2350       else {
2351         nSigmaPosPion = 0; nSigmaNegPion =0; nSigmaPosProton = 0; nSigmaNegProton= 0;
2352       }
2353       
2354       
2355       
2356       // Monte-Carlo particle associated to reconstructed particles: 
2357       if (fAnalysisMC) {
2358         //if (lLabelTrackPos < 0 || lLabelTrackNeg < 0) continue;
2359         TParticle  *lMCESDPartPos  = stack->Particle(lLabelTrackPos);
2360         if(!lMCESDPartPos) { 
2361           Printf("no MC particle for positive and/or negative daughter\n");
2362           continue;
2363         }
2364         TParticle  *lMCESDPartNeg  = stack->Particle(lLabelTrackNeg);
2365         if (!lMCESDPartNeg) continue;
2366         lPDGCodePosDaughter = lMCESDPartPos->GetPdgCode();
2367         lPDGCodeNegDaughter = lMCESDPartNeg->GetPdgCode();
2368         lIndexPosMother = lMCESDPartPos->GetFirstMother();
2369         lIndexNegMother = lMCESDPartNeg->GetFirstMother();
2370         
2371         if (lIndexPosMother == -1) continue;
2372         TParticle  *lMCESDMother    = stack->Particle(lIndexPosMother);
2373         if (!lMCESDMother) continue;
2374         lPdgcodeMother         = lMCESDMother->GetPdgCode();
2375         lIndexMotherOfMother   = lMCESDMother->GetFirstMother();
2376         if (lIndexMotherOfMother ==-1) lPdgcodeMotherOfMother = 0;
2377         else {
2378           TParticle  *lMCESDMotherOfMother    = stack->Particle(lIndexMotherOfMother);
2379           if (!lMCESDMotherOfMother) continue;
2380           lPdgcodeMotherOfMother = lMCESDMotherOfMother->GetPdgCode();
2381         }
2382         
2383         mcPosX = lMCESDPartPos->Vx();
2384         mcPosY = lMCESDPartPos->Vy();
2385         mcPosZ = lMCESDPartPos->Vz();
2386         mcPosR = TMath::Sqrt(mcPosX*mcPosX+mcPosY*mcPosY);
2387         mcPosMotherX = lMCESDMother->Vx();
2388         mcPosMotherY = lMCESDMother->Vy();
2389         mcPosMotherZ = lMCESDMother->Vz();
2390         mcPosMotherR = TMath::Sqrt(mcPosMotherX*mcPosMotherX+mcPosMotherY*mcPosMotherY);
2391         
2392         mcMotherPt   = lMCESDMother->Pt();
2393       }
2394
2395     } // end ESD condition
2396
2397
2398     
2399     else if(fAnalysisType == "AOD") { 
2400
2401       AliAODv0     *myAODv0 = ((AliAODEvent*)fESD)->GetV0(iV0);
2402       if (!myAODv0) continue;
2403
2404       // Primary vertex:
2405       fHistPrimaryVertexPosXV0events->Fill(lPrimaryVtxPosition[0]);
2406       fHistPrimaryVertexPosYV0events->Fill(lPrimaryVtxPosition[1]);
2407       fHistPrimaryVertexPosZV0events->Fill(lPrimaryVtxPosition[2]);
2408       
2409
2410       //Multiplicity:
2411       if(!lOnFlyStatus) nv0s++;
2412 //      else  if(lOnFlyStatus) nv0sMI++;
2413
2414       // V0's Daughters
2415       lIndexTrackPos = TMath::Abs(myAODv0->GetPosID());
2416       lIndexTrackNeg = TMath::Abs(myAODv0->GetNegID());
2417       
2418       AliVParticle  *lVPartPosTest  = ((AliVEvent*)fESD)->GetTrack(lIndexTrackPos);
2419       AliVParticle  *lVPartNegTest  = ((AliVEvent*)fESD)->GetTrack(lIndexTrackNeg);
2420       //AliAODTrack  *lVPartPos  = ((AliAODEvent*)fESD)->GetTrack(lIndexTrackPos);
2421       //AliAODTrack  *lVPartNeg  = ((AliAODEvent*)fESD)->GetTrack(lIndexTrackNeg);
2422
2423       if (!lVPartPosTest ||(!lVPartNegTest )) {
2424         Printf("strange analysis::UserExec:: Could not retreive one of the daughter track\n");
2425         continue;
2426       }
2427
2428       // Quality cuts:
2429       // TO DO !!!!!!!
2430
2431       // TPC refit condition (done during reconstruction for Offline but not for On-the-fly)
2432       //if( !(lVPartPosTest->GetStatus() & AliAODTrack::kTPCrefit)) continue;      
2433       //if( !(lVPartNegTest->GetStatus() & AliAODTrack::kTPCrefit)) continue;
2434       
2435
2436       lDcaPosToPrimVertex = myAODv0->DcaPosToPrimVertex();      
2437       lDcaNegToPrimVertex = myAODv0->DcaNegToPrimVertex();
2438       lOnFlyStatus        = myAODv0->GetOnFlyStatus();
2439       lChi2V0             = myAODv0->Chi2V0();
2440       lDcaV0Daughters     = myAODv0->DcaV0Daughters();
2441       lDcaV0ToPrimVertex  = myAODv0->DcaV0ToPrimVertex();
2442       lV0DecayLength      = myAODv0->DecayLengthV0(lPrimaryVtxPosition);
2443       lV0cosPointAngle    = myAODv0->CosPointingAngle(lPrimaryVtxPosition);
2444       lV0Radius           = myAODv0->RadiusV0();
2445
2446       if( lVPartPosTest->Charge() ==1){
2447         
2448         lVPartPos = ((AliVEvent*)fESD)->GetTrack(lIndexTrackPos);
2449         lVPartNeg = ((AliVEvent*)fESD)->GetTrack(lIndexTrackNeg);
2450         
2451         
2452         if (negPiKF) delete negPiKF; negPiKF=NULL;
2453         if (posPiKF) delete posPiKF; posPiKF=NULL;
2454         if (posPKF)  delete posPKF; posPKF=NULL;
2455         if (negAPKF) delete negAPKF; negAPKF=NULL;
2456         
2457         //negPiKF = new AliKFParticle( *(myAODv0->GetParamN()) ,-211);
2458         //posPiKF = new AliKFParticle( *(myAODv0->GetParamP()) ,211);
2459         //posPKF  = new AliKFParticle( *(myAODv0->GetParamP()) ,2212);
2460         //negAPKF = new AliKFParticle( *(myAODv0->GetParamN()) ,-2212);
2461         // TO DO !!!!!!
2462         negPiKF = NULL;
2463         posPiKF = NULL;
2464         posPKF  = NULL;
2465         negAPKF = NULL;
2466         
2467       }
2468            
2469       if( lVPartPosTest->Charge() ==-1){
2470         
2471         lVPartPos = ((AliVEvent*)fESD)->GetTrack(lIndexTrackNeg);
2472         lVPartNeg = ((AliVEvent*)fESD)->GetTrack(lIndexTrackPos);
2473         
2474         if (negPiKF) delete negPiKF; negPiKF=NULL;
2475         if (posPiKF) delete posPiKF; posPiKF=NULL;
2476         if (posPKF)  delete posPKF; posPKF=NULL;
2477         if (negAPKF) delete negAPKF; negAPKF=NULL;
2478         
2479         //negPiKF = new AliKFParticle( *(myAODv0->GetParamP()) ,-211);
2480         //posPiKF = new AliKFParticle( *(myAODv0->GetParamN()) ,211);
2481         //posPKF  = new AliKFParticle( *(myAODv0->GetParamN()) ,2212);
2482         //negAPKF = new AliKFParticle( *(myAODv0->GetParamP()) ,-2212);
2483         negPiKF = NULL;
2484         posPiKF = NULL;
2485         posPKF  = NULL;
2486         negAPKF = NULL;
2487       }
2488
2489       lLabelTrackPos  = TMath::Abs(lVPartPos->GetLabel());
2490       lLabelTrackNeg  = TMath::Abs(lVPartNeg->GetLabel());
2491       
2492       // Armenteros variables:
2493       lAlphaV0   = myAODv0->AlphaV0();
2494       lPtArmV0   = myAODv0->PtArmV0();
2495
2496       // Pseudorapidity:
2497       lV0Eta = myAODv0->PseudoRapV0();
2498       
2499       // PID not accessible with AOD !
2500       nSigmaPosPion = 0; nSigmaNegPion =0; nSigmaPosProton = 0; nSigmaNegProton= 0;
2501
2502       
2503       // Monte-Carlo particle associated to reconstructed particles:  
2504       if (fAnalysisMC) {
2505         AliAODMCParticle *lMCAODPartPos = (AliAODMCParticle*)mcArray->At(lLabelTrackPos);
2506         if (!lMCAODPartPos) continue;
2507         AliAODMCParticle *lMCAODPartNeg = (AliAODMCParticle*)mcArray->At(lLabelTrackNeg);
2508         if(!lMCAODPartNeg) { 
2509          // Printf("strange analysis::UserExec:no MC particle for negative daughter\n");
2510           continue;
2511         }
2512         lPDGCodePosDaughter = lMCAODPartPos->GetPdgCode();
2513         lPDGCodeNegDaughter = lMCAODPartNeg->GetPdgCode();
2514         lIndexPosMother = lMCAODPartPos->GetMother();
2515         lIndexNegMother = lMCAODPartNeg->GetMother();
2516         
2517         AliAODMCParticle *lMCAODMother = (AliAODMCParticle*)mcArray->At(lIndexPosMother);
2518         lPdgcodeMother = lMCAODMother->GetPdgCode();
2519         lIndexMotherOfMother  = lMCAODMother->GetMother();
2520         if (lIndexMotherOfMother ==-1) lPdgcodeMotherOfMother = 0;
2521         else {
2522           lPdgcodeMotherOfMother   = ((AliAODMCParticle*)mcArray->At(lIndexMotherOfMother))->GetPdgCode();
2523         }
2524         
2525         mcPosX = lMCAODPartPos->Xv();
2526         mcPosY = lMCAODPartPos->Yv();
2527         mcPosZ = lMCAODPartPos->Zv();
2528         mcPosR = TMath::Sqrt(mcPosX*mcPosX+mcPosY*mcPosY);
2529         mcPosMotherX = lMCAODMother->Xv();
2530         mcPosMotherY = lMCAODMother->Yv();
2531         mcPosMotherZ = lMCAODMother->Zv();
2532         mcPosMotherR = TMath::Sqrt(mcPosMotherX*mcPosMotherX+mcPosMotherY*mcPosMotherY);
2533         mcMotherPt   = lMCAODMother->Pt();
2534       }
2535             
2536     } // end AOD condition
2537     
2538     
2539     // Multiplicity:
2540     if(!lOnFlyStatus) nv0s++;
2541 //    else  if(lOnFlyStatus) nv0sMI++;
2542
2543     // Daughter momentum cut: ! FIX it in case of AOD !
2544     if ( (lPtPos  < cutMinPtDaughter ) ||
2545          (lPtNeg  < cutMinPtDaughter )
2546          ) {
2547       if (negPiKF) delete negPiKF; negPiKF=NULL;
2548       if (posPiKF) delete posPiKF; posPiKF=NULL;
2549       if (posPKF)  delete posPKF;  posPKF=NULL;
2550       if (negAPKF) delete negAPKF; negAPKF=NULL;        
2551       continue;
2552     }
2553     
2554     AliKFParticle v0K0sKF;
2555     v0K0sKF+=(*negPiKF);
2556     v0K0sKF+=(*posPiKF);
2557     v0K0sKF.SetProductionVertex(primaryVtxKF);
2558     
2559     AliKFParticle v0LambdaKF;
2560     v0LambdaKF+=(*negPiKF);
2561     v0LambdaKF+=(*posPKF);      
2562     v0LambdaKF.SetProductionVertex(primaryVtxKF);
2563     
2564     AliKFParticle v0AntiLambdaKF;
2565     v0AntiLambdaKF+=(*posPiKF);
2566     v0AntiLambdaKF+=(*negAPKF);
2567     v0AntiLambdaKF.SetProductionVertex(primaryVtxKF);
2568     
2569     // Invariant mass
2570     lInvMassK0s        = v0K0sKF.GetMass();
2571     lInvMassLambda     = v0LambdaKF.GetMass();
2572     lInvMassAntiLambda = v0AntiLambdaKF.GetMass();
2573     
2574     // Rapidity:
2575     lRapK0s        = 0.5*TMath::Log((v0K0sKF.GetE()+v0K0sKF.GetPz())/(v0K0sKF.GetE()-v0K0sKF.GetPz()+1.e-13));
2576     lRapLambda     = 0.5*TMath::Log((v0LambdaKF.GetE()+v0LambdaKF.GetPz())/(v0LambdaKF.GetE()-v0LambdaKF.GetPz()+1.e-13));
2577     lRapAntiLambda = 0.5*TMath::Log((v0AntiLambdaKF.GetE()+v0AntiLambdaKF.GetPz())/(v0AntiLambdaKF.GetE()-v0AntiLambdaKF.GetPz()+1.e-13));
2578
2579     // Pseudo-rapidity
2580     lEtaK0s     = v0K0sKF.GetEta();
2581     lEtaLambda  = v0LambdaKF.GetEta();
2582     lEtaAntiLambda  = v0AntiLambdaKF.GetEta();
2583
2584     // Pz:
2585     lPzK0s        = v0K0sKF.GetPz();
2586     lPzLambda     = v0LambdaKF.GetPz();
2587     lPzAntiLambda = v0AntiLambdaKF.GetPz();
2588     
2589     // Pt:
2590     lPtK0s        = v0K0sKF.GetPt();
2591     lPtLambda     = v0LambdaKF.GetPt();
2592     lPtAntiLambda = v0AntiLambdaKF.GetPt();
2593
2594     if (lPtK0s==0) {
2595         if (negPiKF) delete negPiKF; negPiKF=NULL;
2596         if (posPiKF) delete posPiKF; posPiKF=NULL;
2597         if (posPKF)  delete posPKF;  posPKF=NULL;
2598         if (negAPKF) delete negAPKF; negAPKF=NULL;  
2599         continue;
2600     }
2601     if (lPtLambda==0) {
2602       if (negPiKF) delete negPiKF; negPiKF=NULL;
2603       if (posPiKF) delete posPiKF; posPiKF=NULL;
2604       if (posPKF)  delete posPKF;  posPKF=NULL;
2605       if (negAPKF) delete negAPKF; negAPKF=NULL;  
2606       continue;
2607     }
2608     // Pt Resolution
2609     deltaPtK0s        = (lPtK0s - mcMotherPt)/mcMotherPt;
2610     deltaPtLambda     = (lPtLambda - mcMotherPt)/mcMotherPt;
2611     deltaPtAntiLambda = (lPtAntiLambda - mcMotherPt)/mcMotherPt;
2612
2613     // KF Chi2
2614     lChi2KFK0s        = v0K0sKF.GetChi2();
2615     lChi2KFLambda     = v0LambdaKF.GetChi2();
2616     lChi2KFAntiLambda = v0AntiLambdaKF.GetChi2();
2617     
2618     // Reconstructed Position
2619     rcPosXK0s = v0K0sKF.GetX();
2620     rcPosYK0s = v0K0sKF.GetY(); 
2621     rcPosZK0s = v0K0sKF.GetZ();
2622     rcPosRK0s = TMath::Sqrt(rcPosXK0s*rcPosXK0s+rcPosYK0s*rcPosYK0s);
2623
2624     rcPosXLambda = v0LambdaKF.GetX(); 
2625     rcPosYLambda = v0LambdaKF.GetY(); 
2626     rcPosZLambda = v0LambdaKF.GetZ();
2627     rcPosRLambda = TMath::Sqrt(rcPosXLambda*rcPosXLambda+rcPosYLambda*rcPosYLambda); 
2628
2629     rcPosXAntiLambda = v0AntiLambdaKF.GetX();
2630     rcPosYAntiLambda = v0AntiLambdaKF.GetY(); 
2631     rcPosZAntiLambda = v0AntiLambdaKF.GetZ();
2632     rcPosRAntiLambda = TMath::Sqrt(rcPosXAntiLambda*rcPosXAntiLambda+rcPosYAntiLambda*rcPosYAntiLambda); 
2633
2634     TVector3 momPos(lMomPos[0],lMomPos[1],lMomPos[2]);
2635     TVector3 momNeg(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
2636     TVector3 momTotK0s(v0K0sKF.GetPx(),v0K0sKF.GetPy(),v0K0sKF.GetPz());
2637     TVector3 momTotLambda(v0LambdaKF.GetPx(),v0LambdaKF.GetPy(),v0LambdaKF.GetPz());
2638     TVector3 momTotAntiLambda(v0AntiLambdaKF.GetPx(),v0AntiLambdaKF.GetPy(),v0AntiLambdaKF.GetPz());
2639     
2640     lQlPos = momPos.Dot(momTotK0s)/momTotK0s.Mag();
2641     lQlNeg = momNeg.Dot(momTotK0s)/momTotK0s.Mag();
2642     lAlphaV0K0s = 1.-2./(1.+lQlPos/lQlNeg);
2643     lQlPos = momPos.Dot(momTotLambda)/momTotLambda.Mag();
2644     lQlNeg = momNeg.Dot(momTotLambda)/momTotLambda.Mag();
2645     lAlphaV0Lambda = 1.-2./(1.+lQlPos/lQlNeg);
2646     lQlPos = momPos.Dot(momTotAntiLambda)/momTotAntiLambda.Mag();
2647     lQlNeg = momNeg.Dot(momTotAntiLambda)/momTotAntiLambda.Mag();
2648     lAlphaV0AntiLambda = 1.-2./(1.+lQlPos/lQlNeg);
2649     
2650     lPtArmV0K0s = momPos.Perp(momTotK0s);
2651     lPtArmV0Lambda = momPos.Perp(momTotLambda);
2652     lPtArmV0AntiLambda = momPos.Perp(momTotAntiLambda);
2653     
2654     // Look for associated particles:
2655     if (fAnalysisMC) {
2656       if( (lIndexPosMother==-1) || (lIndexNegMother==-1) ) {
2657         fHistMCDaughterTrack->Fill(1);
2658       }
2659       
2660       else if( ( (lPDGCodePosDaughter==+211) && (lPDGCodeNegDaughter==-211) )    
2661                ) {
2662         lCheckPIdK0Short    = 1;
2663         fHistMCDaughterTrack->Fill(3);
2664         if ( (lIndexPosMother==lIndexNegMother) &&
2665              (lPdgcodeMother==310) ) {
2666           if (lIndexPosMother <= lNbMCPrimary) lCheckMcK0Short  = 1;
2667           else lCheckSecondaryK0s = 1;
2668         }
2669       }
2670       else if( ( (lPDGCodePosDaughter==+2212) && (lPDGCodeNegDaughter==-211)  )  
2671                ) {
2672         lCheckPIdLambda     = 1;
2673         fHistMCDaughterTrack->Fill(5);
2674         if ( (lIndexPosMother==lIndexNegMother) &&
2675              (lPdgcodeMother==3122)  ){
2676           if ( ( TMath::Abs(lPdgcodeMotherOfMother) == 3212) ||
2677                ( TMath::Abs(lPdgcodeMotherOfMother) == 3224) ||
2678                ( TMath::Abs(lPdgcodeMotherOfMother) == 3214) ||
2679                ( TMath::Abs(lPdgcodeMotherOfMother) == 3114)
2680                ) lComeFromSigma = 1;
2681           else lComeFromSigma = 0; 
2682           if ( (lIndexPosMother <= lNbMCPrimary) || 
2683              ( ( lIndexPosMother > lNbMCPrimary) && (lComeFromSigma) )
2684              ) lCheckMcLambda  = 1; 
2685           else lCheckSecondaryLambda    = 1;
2686         }
2687       }
2688       else if( ( (lPDGCodePosDaughter==211)   && (lPDGCodeNegDaughter==-2212) )      
2689                ) {
2690         lCheckPIdAntiLambda = 1;
2691         fHistMCDaughterTrack->Fill(7);
2692         if ( (lIndexPosMother==lIndexNegMother) &&
2693              (lPdgcodeMother==-3122) ) {
2694           if ( ( TMath::Abs(lPdgcodeMotherOfMother) == 3212) ||
2695                ( TMath::Abs(lPdgcodeMotherOfMother) == 3224) ||
2696                ( TMath::Abs(lPdgcodeMotherOfMother) == 3214) ||
2697                ( TMath::Abs(lPdgcodeMotherOfMother) == 3114)
2698                ) lComeFromSigma = 1;
2699           else lComeFromSigma = 0;  
2700           if ( (lIndexPosMother <= lNbMCPrimary) || 
2701              ( ( lIndexPosMother > lNbMCPrimary) && (lComeFromSigma) )
2702              ) lCheckMcAntiLambda  = 1;
2703           else lCheckSecondaryAntiLambda = 1;
2704         }
2705       }
2706       
2707       // Gamma conversion
2708       else if ( (lPDGCodePosDaughter==11) &&
2709                 (lPDGCodeNegDaughter==-11) &&
2710                 (lPdgcodeMother==22 ) )
2711         lCheckGamma = 1;
2712     } // end "look for associated particles  
2713    
2714     
2715     // Cuts:
2716 /*    if (fUseCut.Contains("yes")) {
2717       if ( (lDcaPosToPrimVertex < 0.036 ) ||
2718            (lDcaNegToPrimVertex < 0.036 ) ||
2719            (lDcaV0Daughters     > 0.5   ) ||
2720            (lV0cosPointAngle    < 0.999 ) 
2721            )    
2722         continue;
2723     }
2724 */
2725
2726 /*
2727       if ( (lDcaV0Daughters     > 0.3   ) ||
2728            (lV0cosPointAngle    < 0.998 )
2729
2730            )    continue;
2731 */
2732     // PID condition:
2733     lCheckPIDK0sPosDaughter        = 0, lCheckPIDK0sNegDaughter        = 0;
2734     lCheckPIDLambdaPosDaughter     = 0, lCheckPIDLambdaNegDaughter     = 0;
2735     lCheckPIDAntiLambdaPosDaughter = 0, lCheckPIDAntiLambdaNegDaughter = 0;
2736
2737     if (lMomInnerWallPos < lLimitPPID) {
2738       if (nSigmaPosPion < cutNSigmaLowP)   {
2739         lCheckPIDK0sPosDaughter        = 1;
2740         lCheckPIDAntiLambdaPosDaughter = 1;
2741       }
2742       if (nSigmaPosProton < cutNSigmaLowP) lCheckPIDLambdaPosDaughter    = 1;      
2743     }
2744
2745     else if (lMomInnerWallPos > lLimitPPID) {
2746       if (nSigmaPosPion < cutNSigmaHighP)   {
2747         lCheckPIDK0sPosDaughter        = 1;
2748         lCheckPIDAntiLambdaPosDaughter = 1;
2749       }
2750       if (nSigmaPosProton < cutNSigmaHighP) lCheckPIDLambdaPosDaughter    = 1;
2751     }
2752
2753     if (lMomInnerWallNeg < lLimitPPID) {
2754       if (nSigmaNegPion < cutNSigmaLowP)    {
2755         lCheckPIDK0sNegDaughter       = 1;
2756         lCheckPIDLambdaNegDaughter    = 1;
2757       }
2758       if (nSigmaNegProton < cutNSigmaLowP)  lCheckPIDAntiLambdaNegDaughter = 1;
2759       
2760     }
2761     else if (lMomInnerWallNeg > lLimitPPID) {
2762       if (nSigmaNegPion < cutNSigmaHighP)   {
2763         lCheckPIDK0sNegDaughter       = 1;
2764         lCheckPIDLambdaNegDaughter    = 1;
2765       }
2766       if (nSigmaNegProton < cutNSigmaHighP) lCheckPIDAntiLambdaNegDaughter = 1;
2767     }
2768     
2769     
2770     //*****************************
2771     // filling histograms
2772
2773     fHistDcaPosToPrimVertex->Fill(lDcaPosToPrimVertex,lOnFlyStatus);
2774     fHistDcaNegToPrimVertex->Fill(lDcaNegToPrimVertex,lOnFlyStatus);
2775     fHistDcaPosToPrimVertexZoom->Fill(lDcaPosToPrimVertex,lOnFlyStatus);
2776     fHistDcaNegToPrimVertexZoom->Fill(lDcaNegToPrimVertex,lOnFlyStatus);
2777     fHistRadiusV0->Fill(lV0Radius,lOnFlyStatus);
2778     fHistDecayLengthV0->Fill(lV0DecayLength,lOnFlyStatus);
2779     fHistDcaV0Daughters->Fill(lDcaV0Daughters,lOnFlyStatus);
2780     fHistChi2->Fill(lChi2V0,lOnFlyStatus);
2781     fHistCosPointAngle->Fill(lV0cosPointAngle,lOnFlyStatus);
2782     if (lV0cosPointAngle >= 0.9) fHistCosPointAngleZoom->Fill(lV0cosPointAngle,lOnFlyStatus);
2783     fHistChi2KFBeforeCutK0s->Fill(lChi2KFK0s,lOnFlyStatus); 
2784     fHistChi2KFBeforeCutLambda->Fill(lChi2KFLambda,lOnFlyStatus);
2785     fHistChi2KFBeforeCutAntiLambda->Fill(lChi2KFAntiLambda,lOnFlyStatus);
2786
2787
2788     // Histo versus Rap and armenteros plot
2789     if (!lOnFlyStatus){
2790       if (lCheckMcK0Short) fHistAsMcRapK0->Fill(lRapK0s);
2791       if (lCheckMcLambda) fHistAsMcRapLambda->Fill(lRapLambda);
2792       if (lCheckMcAntiLambda) fHistAsMcRapLambda->Fill(lRapAntiLambda);
2793 //      fHistArmenterosPodolanski->Fill(lAlphaV0,lPtArmV0);
2794 //      fHistDaughterPt->Fill(lPtPos,lPtNeg);
2795     }
2796 /*    else {
2797       if (lCheckMcK0Short) fHistAsMcRapK0MI->Fill(lRapK0s);
2798       if (lCheckMcLambda) fHistAsMcRapLambdaMI->Fill(lRapLambda);
2799       if (lCheckMcAntiLambda) fHistAsMcRapLambdaMI->Fill(lRapAntiLambda);
2800       fHistArmenterosPodolanskiMI->Fill(lAlphaV0,lPtArmV0);
2801     }*/
2802     
2803     
2804     // K0s associated histograms in |rap| < lCutRap:
2805
2806 ////////////////////////////
2807     if ( lCheckPIDK0sPosDaughter && lCheckPIDK0sNegDaughter
2808          && (lChi2KFK0s < cutChi2KF)) fHistPzPtBeforeK0s->Fill(TMath::Abs(lPzK0s/lPtK0s));
2809 /////////////////////////////
2810
2811     if ( lCheckPIDK0sPosDaughter && lCheckPIDK0sNegDaughter
2812          && (lChi2KFK0s < cutChi2KF) && (TMath::Abs(lPzK0s/lPtK0s)<0.7) )     {
2813
2814
2815
2816         fHistPzPtAfterK0s->Fill(TMath::Abs(lPzK0s/lPtK0s));
2817
2818
2819       
2820       fHistChi2KFAfterCutK0s->Fill(lChi2KFK0s,lOnFlyStatus);
2821
2822       if (TMath::Abs(lRapK0s) < lCutRap) {
2823
2824         fHistNsigmaPosPionK0->Fill(nSigmaPosPion);
2825         fHistNsigmaNegPionK0->Fill(nSigmaNegPion);
2826         
2827         switch (lOnFlyStatus){
2828         case 0 : 
2829           fHistMassK0->Fill(lInvMassK0s);
2830           fHistMassVsRadiusK0->Fill(rcPosRK0s,lInvMassK0s);
2831          fHistPtVsMassK0->Fill(lInvMassK0s,lPtK0s);
2832
2833
2834 //        fHistMultVsPtVsMassK0->Fill(multiplicity ,lInvMassK0s,lPtK0s);
2835           if(lCheckPIdK0Short) fHistPidMcMassK0->Fill(lInvMassK0s);
2836           if(lCheckMcK0Short) {
2837             fHistAsMcMassK0->Fill(lInvMassK0s);
2838             fHistAsMcPtK0->Fill(lPtK0s);
2839
2840
2841             fHistAsMcPtVsMassK0->Fill(lInvMassK0s,lPtK0s);
2842             if (lPtK0s <= 1) fHistAsMcPtZoomK0->Fill(lPtK0s);
2843             fHistAsMcMassVsRadiusK0->Fill(rcPosRK0s,lInvMassK0s);
2844             fHistAsMcResxK0->Fill(rcPosXK0s-mcPosX);
2845             fHistAsMcResyK0->Fill(rcPosYK0s-mcPosY);
2846             fHistAsMcReszK0->Fill(rcPosZK0s-mcPosZ);
2847             fHistAsMcResrVsRadiusK0->Fill(rcPosRK0s,rcPosRK0s-mcPosR);
2848             fHistAsMcReszVsRadiusK0->Fill(rcPosZK0s,rcPosZK0s-mcPosZ);
2849             fHistAsMcProdRadiusK0->Fill(mcPosMotherR);
2850             fHistAsMcProdRadiusXvsYK0s->Fill(mcPosMotherX,mcPosMotherY);
2851             fHistAsMcResPtK0->Fill(deltaPtK0s);
2852             fHistAsMcResPtVsRapK0->Fill(deltaPtK0s,lRapK0s);
2853             fHistAsMcResPtVsPtK0->Fill(deltaPtK0s,lPtK0s);
2854           }
2855           else if (lCheckSecondaryK0s) {
2856             fHistAsMcSecondaryPtVsRapK0s->Fill(lPtK0s,lRapK0s);
2857             fHistAsMcSecondaryProdRadiusK0s->Fill(mcPosMotherR);
2858             fHistAsMcSecondaryProdRadiusXvsYK0s->Fill(mcPosMotherX,mcPosMotherY);
2859             switch (lPdgcodeMotherOfMother) {
2860             case 130   : fHistAsMcSecondaryMotherPdgCodeK0s->Fill(0.5);break; // K0L
2861             case 321   : fHistAsMcSecondaryMotherPdgCodeK0s->Fill(1.5);break; // K+
2862             case -321  : fHistAsMcSecondaryMotherPdgCodeK0s->Fill(2.5);break; // K-
2863             case -3122 : fHistAsMcSecondaryMotherPdgCodeK0s->Fill(3.5);break; //AntiLambda
2864             default    : fHistAsMcSecondaryMotherPdgCodeK0s->Fill(6.5);break;
2865             }
2866           }
2867           break;
2868           
2869 /*      case 1 :
2870           fHistMassK0MI->Fill(lInvMassK0s);
2871           fHistMassVsRadiusK0MI->Fill(rcPosRK0s,lInvMassK0s);
2872           fHistPtVsMassK0MI->Fill(lInvMassK0s,lPtK0s);
2873           if(lCheckPIdK0Short) fHistPidMcMassK0MI->Fill(lInvMassK0s);
2874           if(lCheckMcK0Short) {
2875             fHistAsMcMassK0MI->Fill(lInvMassK0s);
2876             fHistAsMcPtK0MI->Fill(lPtK0s);
2877             fHistAsMcPtVsMassK0MI->Fill(lInvMassK0s,lPtK0s);
2878             if (lPtK0s <= 1) fHistAsMcPtZoomK0MI->Fill(lPtK0s);
2879             fHistAsMcMassVsRadiusK0MI->Fill(rcPosRK0s,lInvMassK0s);
2880             fHistAsMcResxK0MI->Fill(rcPosXK0s-mcPosX);
2881             fHistAsMcResyK0MI->Fill(rcPosYK0s-mcPosY);
2882             fHistAsMcReszK0MI->Fill(rcPosZK0s-mcPosZ);
2883             fHistAsMcResrVsRadiusK0MI->Fill(rcPosRK0s,rcPosRK0s-mcPosR);
2884             fHistAsMcReszVsRadiusK0MI->Fill(rcPosZK0s,rcPosZK0s-mcPosZ);
2885             fHistAsMcProdRadiusK0MI->Fill(mcPosMotherR);
2886             fHistAsMcProdRadiusXvsYK0sMI->Fill(mcPosMotherX,mcPosMotherY);
2887             fHistAsMcResPtK0MI->Fill(deltaPtK0s);
2888             fHistAsMcResPtVsRapK0MI->Fill(deltaPtK0s,lRapK0s);
2889             fHistAsMcResPtVsPtK0MI->Fill(deltaPtK0s,lPtK0s);
2890           }
2891           else if (lCheckSecondaryK0s) {
2892             fHistAsMcSecondaryPtVsRapK0sMI->Fill(lPtK0s,lRapK0s);
2893             fHistAsMcSecondaryProdRadiusK0sMI->Fill(mcPosMotherR); 
2894             fHistAsMcSecondaryProdRadiusXvsYK0sMI->Fill(mcPosMotherX,mcPosMotherY);
2895             switch (lPdgcodeMotherOfMother) {
2896             case 130   : fHistAsMcSecondaryMotherPdgCodeK0sMI->Fill(0.5);break; // K0L
2897             case 321   : fHistAsMcSecondaryMotherPdgCodeK0sMI->Fill(1.5);break; // K+
2898             case -321  : fHistAsMcSecondaryMotherPdgCodeK0sMI->Fill(2.5);break; // K-
2899             case -3122 : fHistAsMcSecondaryMotherPdgCodeK0sMI->Fill(3.5);break; //AntiLambda
2900             default    : fHistAsMcSecondaryMotherPdgCodeK0sMI->Fill(6.5);break;
2901             }
2902           }
2903           break;        */
2904         }
2905       } // end rapidity condition
2906     } // end nsigma condition
2907     
2908
2909     // Associated Lambda histograms in |rap| < lCutRap
2910
2911 ////////////////////////len koly kontrole Abs(Pz/Pt)
2912     if ( lCheckPIDLambdaPosDaughter && lCheckPIDLambdaNegDaughter
2913          && (lChi2KFLambda < cutChi2KF)) fHistPzPtBeforeLambda->Fill(TMath::Abs(lPzLambda/lPtLambda)); 
2914 ////////////////////////
2915
2916     if ( lCheckPIDLambdaPosDaughter && lCheckPIDLambdaNegDaughter
2917          && (lChi2KFLambda < cutChi2KF) && (TMath::Abs(lPzLambda/lPtLambda)<0.7) )  {
2918
2919  
2920
2921
2922         fHistPzPtAfterLambda->Fill(TMath::Abs(lPzLambda/lPtLambda));      
2923
2924       fHistChi2KFAfterCutLambda->Fill(lChi2KFLambda,lOnFlyStatus);
2925
2926       if (TMath::Abs(lRapLambda) < lCutRap) {
2927
2928         fHistNsigmaPosProtonLambda->Fill(nSigmaPosProton);
2929         fHistNsigmaNegPionLambda->Fill(nSigmaNegPion);
2930         switch (lOnFlyStatus){
2931         case 0 : 
2932           fHistMassLambda->Fill(lInvMassLambda);
2933           fHistMassVsRadiusLambda->Fill(rcPosRLambda,lInvMassLambda);
2934          fHistPtVsMassLambda->Fill(lInvMassLambda,lPtLambda);
2935
2936
2937
2938
2939 //          fHistMultVsPtVsMassLambda->Fill(multiplicity ,lInvMassLambda,lPtLambda);
2940           if(lCheckPIdLambda) fHistPidMcMassLambda->Fill(lInvMassLambda);
2941           
2942           if(lCheckMcLambda) {
2943             fHistAsMcMassLambda->Fill(lInvMassLambda);
2944             fHistAsMcPtLambda->Fill(lPtLambda);
2945
2946
2947             fHistAsMcPtVsMassLambda->Fill(lInvMassLambda,lPtLambda);
2948             if (lPtLambda <= 1) fHistAsMcPtZoomLambda->Fill(lPtLambda);
2949             fHistAsMcMassVsRadiusLambda->Fill(rcPosRLambda,lInvMassLambda);
2950             fHistAsMcResxLambda->Fill(rcPosXLambda-mcPosX);
2951             fHistAsMcResyLambda->Fill(rcPosYLambda-mcPosY);
2952             fHistAsMcReszLambda->Fill(rcPosZLambda-mcPosZ);
2953             fHistAsMcResrVsRadiusLambda->Fill(rcPosRLambda,rcPosRLambda-mcPosR);
2954             fHistAsMcReszVsRadiusLambda->Fill(rcPosZLambda,rcPosZLambda-mcPosZ);
2955             fHistAsMcProdRadiusLambda->Fill(mcPosMotherR);
2956             fHistAsMcProdRadiusXvsYLambda->Fill(mcPosMotherX,mcPosMotherY);
2957             fHistAsMcResPtLambda->Fill(deltaPtLambda);
2958             fHistAsMcResPtVsRapLambda->Fill(deltaPtLambda,lRapLambda);
2959             fHistAsMcResPtVsPtLambda->Fill(deltaPtLambda,lPtLambda);
2960             if (lComeFromSigma) fHistAsMcPtLambdaFromSigma->Fill(lPtLambda);
2961             switch (lPdgcodeMotherOfMother) {
2962             case 3222 : fHistAsMcMotherPdgCodeLambda->Fill(0.5); break; // Sigma +
2963             case 3212 : fHistAsMcMotherPdgCodeLambda->Fill(1.5); break; // Sigma 0
2964             case 3112 : fHistAsMcMotherPdgCodeLambda->Fill(2.5); break;// Sigma -
2965             case 3224 : fHistAsMcMotherPdgCodeLambda->Fill(3.5); break;// Sigma(1385) +
2966             case 3214 : fHistAsMcMotherPdgCodeLambda->Fill(4.5); break;// Sigma(1385) 0
2967             case 3114 : fHistAsMcMotherPdgCodeLambda->Fill(5.5); break;// Sigma(1385) -
2968             case 3322 : fHistAsMcMotherPdgCodeLambda->Fill(6.5); break; // Xi 0
2969             case 3312 : fHistAsMcMotherPdgCodeLambda->Fill(7.5); break; // Xi -
2970             case 3334 : fHistAsMcMotherPdgCodeLambda->Fill(8.5); break; // Omega
2971             case -1   : fHistAsMcMotherPdgCodeLambda->Fill(9.5); break;
2972             default   : fHistAsMcMotherPdgCodeLambda->Fill(10.5);break; 
2973             }
2974
2975             
2976             //printf("found Lambda RC dcaPos=%e dcaNeg=%e dcaDau=%e cosP=%e pT=%e mass=%e\n",lDcaPosToPrimVertex ,lDcaNegToPrimVertex ,lDcaV0Daughters,lV0cosPointAngle,lPtLambda,lInvMassLambda);
2977             //printf("found Lambda RC Pindex=%d  Nindex=%d  Plabel=%d  Nlabel=%d\n\n",lIndexTrackPos,lIndexTrackNeg,lLabelTrackPos,lLabelTrackNeg);
2978             
2979           }
2980           
2981           else if (lCheckSecondaryLambda) {
2982             fHistAsMcSecondaryPtVsRapLambda->Fill(lPtLambda,lRapLambda);
2983             fHistAsMcSecondaryProdRadiusLambda->Fill(mcPosMotherR); 
2984             fHistAsMcSecondaryProdRadiusXvsYLambda->Fill(mcPosMotherX,mcPosMotherY);
2985             if (lComeFromSigma) fHistAsMcSecondaryPtLambdaFromSigma->Fill(lPtLambda);
2986             printf(" lPdgcodeMotherOfMother= %d",lPdgcodeMotherOfMother);
2987             switch (lPdgcodeMotherOfMother) {
2988             case 3222 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(0.5); break;// Sigma +
2989             case 3212 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(1.5); break;// Sigma 0
2990             case 3112 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(2.5); break;// Sigma -
2991             case 3224 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(3.5); break;// Sigma(1385) +
2992             case 3214 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(4.5); break;// Sigma(1385) 0
2993             case 3114 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(5.5); break;// Sigma(1385) -
2994             case 3322 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(6.5); break; // Xi 0
2995             case 3312 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(7.5); break; // Xi -
2996             case 3334 : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(8.5); break; // Omega
2997             case -1   : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(9.5); break;
2998             default   : fHistAsMcSecondaryMotherPdgCodeLambda->Fill(10.5);break;
2999             }
3000           }
3001           break;
3002           
3003 /*      case 1 :
3004           fHistMassLambdaMI->Fill(lInvMassLambda);
3005           fHistMassVsRadiusLambdaMI->Fill(rcPosRLambda,lInvMassLambda);
3006           fHistPtVsMassLambdaMI->Fill(lInvMassLambda,lPtLambda);
3007           if(lCheckPIdLambda) fHistPidMcMassLambdaMI->Fill(lInvMassLambda);
3008           
3009           if(lCheckMcLambda) {
3010             fHistAsMcMassLambdaMI->Fill(lInvMassLambda);
3011             fHistAsMcPtLambdaMI->Fill(lPtLambda);
3012             fHistAsMcPtVsMassLambdaMI->Fill(lInvMassLambda,lPtLambda);
3013             fHistAsMcMassVsRadiusLambdaMI->Fill(rcPosRLambda,lInvMassLambda);
3014             fHistAsMcResxLambdaMI->Fill(rcPosXLambda-mcPosX);
3015             fHistAsMcResyLambdaMI->Fill(rcPosYLambda-mcPosY);
3016             fHistAsMcReszLambdaMI->Fill(rcPosZLambda-mcPosZ);
3017             fHistAsMcResrVsRadiusLambdaMI->Fill(rcPosRLambda,rcPosRLambda-mcPosR);
3018             fHistAsMcReszVsRadiusLambdaMI->Fill(rcPosZLambda,rcPosZLambda-mcPosZ);
3019             fHistAsMcProdRadiusLambdaMI->Fill(mcPosMotherR);
3020             fHistAsMcProdRadiusXvsYLambdaMI->Fill(mcPosMotherX,mcPosMotherY);
3021             fHistAsMcResPtLambdaMI->Fill(deltaPtLambda);
3022             fHistAsMcResPtVsRapLambdaMI->Fill(deltaPtLambda,lRapLambda);
3023             fHistAsMcResPtVsPtLambdaMI->Fill(deltaPtLambda,lPtLambda);
3024             if (lComeFromSigma) fHistAsMcPtLambdaFromSigmaMI->Fill(lPtLambda);
3025             switch (lPdgcodeMotherOfMother) {
3026             case 3222 : fHistAsMcMotherPdgCodeLambdaMI->Fill(0.5); break; // Sigma +
3027             case 3212 : fHistAsMcMotherPdgCodeLambdaMI->Fill(1.5); break; // Sigma 0
3028             case 3112 : fHistAsMcMotherPdgCodeLambdaMI->Fill(2.5); break;// Sigma -
3029             case 3224 : fHistAsMcMotherPdgCodeLambdaMI->Fill(3.5); break;// Sigma(1385) +
3030             case 3214 : fHistAsMcMotherPdgCodeLambdaMI->Fill(4.5); break;// Sigma(1385) 0
3031             case 3114 : fHistAsMcMotherPdgCodeLambdaMI->Fill(5.5); break;// Sigma(1385) -
3032             case 3322 : fHistAsMcMotherPdgCodeLambdaMI->Fill(6.5);break; // Xi 0
3033             case 3312 : fHistAsMcMotherPdgCodeLambdaMI->Fill(7.5);break; // Xi -
3034             case 3334 : fHistAsMcMotherPdgCodeLambdaMI->Fill(8.5);break; // Omega
3035             case -1   : fHistAsMcMotherPdgCodeLambdaMI->Fill(9.5);break;
3036             default   : fHistAsMcMotherPdgCodeLambdaMI->Fill(10.5);break;
3037             }
3038           }
3039           else if (lCheckSecondaryLambda) {
3040             fHistAsMcSecondaryPtVsRapLambdaMI->Fill(lPtLambda,lRapLambda);
3041             fHistAsMcSecondaryProdRadiusLambdaMI->Fill(mcPosMotherR); 
3042             fHistAsMcSecondaryProdRadiusXvsYLambdaMI->Fill(mcPosMotherX,mcPosMotherY);
3043             if (lComeFromSigma) fHistAsMcSecondaryPtLambdaFromSigmaMI->Fill(lPtLambda);
3044             switch (lPdgcodeMotherOfMother) {
3045             case 3222 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(0.5); break;// Sigma +
3046             case 3212 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(1.5); break;// Sigma 0
3047             case 3112 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(2.5); break;// Sigma -
3048             case 3224 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(3.5); break;// Sigma(1385) +
3049             case 3214 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(4.5); break;// Sigma(1385) 0
3050             case 3114 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(5.5); break;// Sigma(1385) -
3051             case 3322 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(6.5); break; // Xi 0
3052             case 3312 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(7.5); break; // Xi -
3053             case 3334 : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(8.5); break; // Omega
3054             case -1   : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(9.5); break;
3055             default   : fHistAsMcSecondaryMotherPdgCodeLambdaMI->Fill(10.5);break;
3056             }
3057           }
3058           break;        
3059         */
3060         }
3061       } // end rapidity condition
3062     } //end nsigma condition - lambda
3063
3064
3065     if (negPiKF) delete negPiKF; negPiKF= NULL;
3066     if (posPiKF) delete posPiKF; posPiKF= NULL;
3067     if (posPKF)  delete posPKF;  posPKF = NULL;
3068     if (negAPKF) delete negAPKF; negAPKF= NULL;
3069     
3070   } // end V0 loop
3071
3072   fHistV0Multiplicity->Fill(nv0s);
3073 //  fHistV0MultiplicityMI->Fill(nv0sMI);
3074
3075   if (fAnalysisType == "ESD") { if(myPrimaryVertex) delete myPrimaryVertex; }
3076
3077   if(myTracksCuts) delete myTracksCuts;
3078   
3079   // Post output data
3080   PostData(1, fListHist);
3081   PostData(2, fCentrSelector);
3082 }      
3083
3084 //________________________________________________________________________
3085 void AliAnalysisTaskPerformanceStrange::Terminate(Option_t *) 
3086 {/*
3087   // Draw result to the screen
3088   // Called once at the end of the query
3089
3090   TList *cRetrievedList = 0x0;
3091   cRetrievedList = (TList*)GetOutputData(1);
3092   
3093   if(!cRetrievedList){
3094     AliWarning("ERROR - AliAnalysisTaskPerformanceStrange: output data container list not available\n"); return;
3095   }
3096   
3097   
3098   fHistV0Multiplicity = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistV0Multiplicity"));
3099   if (!fHistV0Multiplicity) {
3100     Printf("ERROR: fHistV0Multiplicity not available");
3101     return;
3102   }
3103
3104   fHistV0MultiplicityMI = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistV0MultiplicityMI"));
3105   if (!fHistV0MultiplicityMI) {
3106     Printf("ERROR: fHistV0MultiplicityMI not available");
3107     return;
3108   }
3109
3110   TCanvas *canPerformanceStrange = new TCanvas("AliAnalysisTaskCheckV0","Multiplicity",10,10,510,510);
3111   canPerformanceStrange->Divide(2,1);
3112   if (fHistV0Multiplicity->GetMaximum() > 0.) canPerformanceStrange->cd(1)->SetLogy();
3113   fHistV0Multiplicity->SetMarkerStyle(25);
3114   fHistV0Multiplicity->DrawCopy("E");
3115   if (fHistV0MultiplicityMI->GetMaximum() > 0.) canPerformanceStrange->cd(2)->SetLogy();
3116   fHistV0MultiplicityMI->SetMarkerStyle(24);
3117   fHistV0MultiplicityMI->DrawCopy("E");
3118   
3119
3120 */ 
3121 }
3122
3123 //----------------------------------------------------------------------------
3124
3125 Double_t AliAnalysisTaskPerformanceStrange::MyRapidity(Double_t rE, Double_t rPz) const
3126 {
3127   // Local calculation for rapidity
3128   return 0.5*TMath::Log((rE+rPz)/(rE-rPz+1.e-13));
3129
3130 //----------------------------------------------------------------------------
3131