]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/STRANGENESS/Cascades/AliAnalysisTaskStrangenessVsMultiplicityMC.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / AliAnalysisTaskStrangenessVsMultiplicityMC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17 //
18 // This task is meant to explore the possibility of using a VZERO amplitude
19 // based multiplicity estimator for proton-proton collisions. For this, two 
20 // main operation methods for this task are foreseen: 
21 // 
22 //  1) (under development) it should act as an auxiliary task and provide a 
23 //     calibrated estimator 
24 //
25 //  2) "Debug mode" which will also create a ROOT TTree object with event 
26 //     by event info potentially used for exploration / calibration. This 
27 //     includes the following info: 
28 //    
29 //      --- All VZERO Amplitudes (saved as Float_t) 
30 //      --- (optional) time for each channel
31 //      --- (optional) time width for each channel 
32 //      --- GetReferenceMultiplicity Estimator, |eta|<0.5 
33 //      --- GetReferenceMultiplicity Estimator, |eta|<0.8 
34 //      --- (if MC) True Multiplicity, |eta|<0.5
35 //      --- (if MC) True Multiplicity,  2.8 < eta < 5.8 (VZEROA region)
36 //      --- (if MC) True Multiplicity, -3.7 < eta <-1.7 (VZEROC region)
37 //      --- Run Number
38 //
39 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40
41 class TTree;
42 class TParticle;
43 class TVector3;
44
45 //class AliMCEventHandler;
46 //class AliMCEvent;
47 //class AliStack;
48
49 class AliESDVertex;
50 class AliAODVertex;
51 class AliESDv0;
52 class AliAODv0;
53
54 #include <Riostream.h>
55 #include "TList.h"
56 #include "TH1.h"
57 #include "TH2.h"
58 #include "TH3.h"
59 #include "TFile.h"
60 #include "THnSparse.h"
61 #include "TVector3.h"
62 #include "TCanvas.h"
63 #include "TMath.h"
64 #include "TLegend.h"
65 //#include "AliLog.h"
66
67 #include "AliESDEvent.h"
68 #include "AliAODEvent.h"
69 #include "AliV0vertexer.h"
70 #include "AliCascadeVertexer.h"
71 #include "AliESDpid.h"
72 #include "AliESDtrack.h"
73 #include "AliESDtrackCuts.h"
74 #include "AliInputEventHandler.h"
75 #include "AliAnalysisManager.h"
76 #include "AliMCEventHandler.h"
77 #include "AliMCEvent.h"
78 #include "AliStack.h"
79 #include "AliCentrality.h"
80 #include "AliPPVsMultUtils.h"
81 #include "AliPWG0Helper.h"
82 #include "AliCFContainer.h"
83 #include "AliMultiplicity.h"
84 #include "AliAODMCParticle.h"
85 #include "AliESDcascade.h"
86 #include "AliAODcascade.h"
87 #include "AliESDUtils.h"
88 #include "AliGenEventHeader.h"
89 #include "AliAnalysisTaskSE.h"
90 #include "AliAnalysisUtils.h"
91 #include "AliAnalysisTaskStrangenessVsMultiplicityMC.h"
92
93
94 using std::cout;
95 using std::endl;
96
97 ClassImp(AliAnalysisTaskStrangenessVsMultiplicityMC)
98
99 AliAnalysisTaskStrangenessVsMultiplicityMC::AliAnalysisTaskStrangenessVsMultiplicityMC()
100   : AliAnalysisTaskSE(), fListHist(0), fTreeEvent(0), fTreeV0(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), fPPVsMultUtils(0),
101   fkSaveV0Tree      ( kFALSE ),
102   fkSaveCascadeTree ( kTRUE  ),
103   fkRunVertexers    ( kTRUE  ),
104   fkSkipEventSelection( kFALSE ),
105   //---> Variables for fTreeEvent
106   fAmplitude_V0A   (0),   
107   fAmplitude_V0C   (0),   
108   fAmplitude_V0AEq (0),   
109   fAmplitude_V0CEq (0),  
110   fCentrality_V0A(0), 
111   fCentrality_V0C(0), 
112   fCentrality_V0M(0), 
113   fCentrality_V0AEq(0), 
114   fCentrality_V0CEq(0), 
115   fCentrality_V0MEq(0), 
116   fCustomCentrality_V0M(0),
117   fCustomCentrality_V0MEq(0),
118   fRefMultEta5(0),
119   fRefMultEta8(0),
120   fTrueMultEta5(0),
121   fTrueMultEta8(0),
122   fTrueMultVZEROA(0),
123   fTrueMultVZEROC(0),
124   fRunNumber(0),
125     fEvSel_HasAtLeastSPDVertex(0),
126     fEvSel_VtxZCut(0),
127     fEvSel_IsNotPileup(0),
128     fEvSel_IsNotPileupMV(0),
129     fEvSel_IsNotPileupInMultBins(0),
130     fEvSel_HasVtxContributor(0),
131     fEvSel_Triggered(0),
132     fEvSel_VtxZ(0), 
133     fEvSel_MCType(0), 
134   //---> Variables for fTreeV0
135         fTreeVariableChi2V0(0),
136         fTreeVariableDcaV0Daughters(0),
137         fTreeVariableDcaV0ToPrimVertex(0),
138         fTreeVariableDcaPosToPrimVertex(0),
139         fTreeVariableDcaNegToPrimVertex(0),
140         fTreeVariableV0CosineOfPointingAngle(0),
141         fTreeVariableV0Radius(0),
142         fTreeVariablePt(0),
143         fTreeVariablePtMC(0),
144         fTreeVariableRapK0Short(0),
145         fTreeVariableRapLambda(0),
146         fTreeVariableRapMC(0),
147         fTreeVariableInvMassK0s(0),
148         fTreeVariableInvMassLambda(0),
149         fTreeVariableInvMassAntiLambda(0),
150         fTreeVariableAlphaV0(0),
151         fTreeVariablePtArmV0(0),
152         fTreeVariableNegEta(0),
153         fTreeVariablePosEta(0),
154
155         fTreeVariableNSigmasPosProton(0),
156         fTreeVariableNSigmasPosPion(0),
157         fTreeVariableNSigmasNegProton(0),
158         fTreeVariableNSigmasNegPion(0),
159
160         fTreeVariableDistOverTotMom(0),
161         fTreeVariableLeastNbrCrossedRows(0),
162         fTreeVariableLeastRatioCrossedRowsOverFindable(0),
163         
164   fTreeVariableCentV0A(0),
165   fTreeVariableCentV0C(0),
166   fTreeVariableCentV0M(0),
167   fTreeVariableCentV0AEq(0),
168   fTreeVariableCentV0CEq(0),
169   fTreeVariableCentV0MEq(0),
170   fTreeVariableCustomCentV0M(0),
171   fTreeVariableAmpV0A(0),
172   fTreeVariableAmpV0C(0),
173   fTreeVariableAmpV0AEq(0),
174   fTreeVariableAmpV0CEq(0),
175   fTreeVariableRefMultEta8(0),
176   fTreeVariableRefMultEta5(0),
177   fTreeVariableRunNumber(0),
178
179   fTreeVariablePtMother(0),
180   fTreeVariablePID(0),
181   fTreeVariablePIDPositive(0),
182   fTreeVariablePIDNegative(0),
183   fTreeVariablePIDMother(0),
184   fTreeVariablePrimaryStatus(0),
185   fTreeVariablePrimaryStatusMother(0),
186   //---> Variables for fTreeCascade
187   fTreeCascVarCharge(0), 
188         fTreeCascVarMassAsXi(0),
189         fTreeCascVarMassAsOmega(0),
190         fTreeCascVarPt(0),
191         fTreeCascVarPtMC(0),
192         fTreeCascVarRapXi(0),
193         fTreeCascVarRapOmega(0),
194         fTreeCascVarRapMC(0),
195         fTreeCascVarNegEta(0),
196         fTreeCascVarPosEta(0),
197         fTreeCascVarBachEta(0),
198         fTreeCascVarDCACascDaughters(0),
199         fTreeCascVarDCABachToPrimVtx(0),
200         fTreeCascVarDCAV0Daughters(0),
201         fTreeCascVarDCAV0ToPrimVtx(0),
202         fTreeCascVarDCAPosToPrimVtx(0),
203         fTreeCascVarDCANegToPrimVtx(0),
204         fTreeCascVarCascCosPointingAngle(0),
205         fTreeCascVarCascRadius(0),
206         fTreeCascVarV0Mass(0),
207         fTreeCascVarV0CosPointingAngle(0),
208         fTreeCascVarV0CosPointingAngleSpecial(0),
209         fTreeCascVarV0Radius(0),
210   fTreeCascVarLeastNbrClusters(0),
211         fTreeCascVarDistOverTotMom(0),
212         fTreeCascVarNegNSigmaPion(0),
213         fTreeCascVarNegNSigmaProton(0),
214         fTreeCascVarPosNSigmaPion(0),
215         fTreeCascVarPosNSigmaProton(0),
216         fTreeCascVarBachNSigmaPion(0),
217         fTreeCascVarBachNSigmaKaon(0),
218         fTreeCascVarCentV0A(0),
219         fTreeCascVarCentV0C(0),
220         fTreeCascVarCentV0M(0),
221         fTreeCascVarCentV0AEq(0),
222         fTreeCascVarCentV0CEq(0),
223         fTreeCascVarCentV0MEq(0),
224         fTreeCascVarCustomCentV0M(0),
225         fTreeCascVarAmpV0A(0),
226         fTreeCascVarAmpV0C(0),
227         fTreeCascVarAmpV0AEq(0),
228         fTreeCascVarAmpV0CEq(0),
229   fTreeCascVarRefMultEta8(0),
230   fTreeCascVarRefMultEta5(0),
231   fTreeCascVarTrueMultEta5(0),
232   fTreeCascVarTrueMultEta8(0),
233   fTreeCascVarTrueMultVZEROA(0),
234   fTreeCascVarTrueMultVZEROC(0),
235   fTreeCascVarIsPhysicalPrimary(0), 
236   fTreeCascVarPID(0), 
237   fTreeCascVarRunNumber(0), 
238   //---> Histograms
239   fHistEventCounter(0), 
240   //---> MC Generated Histo (analysis level) 
241         fHistPt_GenK0Short(0),
242         fHistPt_GenLambda(0),
243         fHistPt_GenAntiLambda(0),
244         fHistPt_GenXiMinus(0),
245         fHistPt_GenXiPlus(0),
246         fHistPt_GenOmegaMinus(0),
247         fHistPt_GenOmegaPlus(0),
248
249   //VsRefMult
250         fHistPtVsRefMultEta5_GenXiMinus(0),
251         fHistPtVsRefMultEta5_GenXiPlus(0),
252         fHistPtVsRefMultEta5_GenOmegaMinus(0),
253         fHistPtVsRefMultEta5_GenOmegaPlus(0),
254         fHistPtVsRefMultEta8_GenXiMinus(0),
255         fHistPtVsRefMultEta8_GenXiPlus(0),
256         fHistPtVsRefMultEta8_GenOmegaMinus(0),
257         fHistPtVsRefMultEta8_GenOmegaPlus(0),
258
259   //VsCentralities
260         fHistPtVsCentV0A_GenXiMinus(0),
261         fHistPtVsCentV0A_GenXiPlus(0),
262         fHistPtVsCentV0A_GenOmegaMinus(0),
263         fHistPtVsCentV0A_GenOmegaPlus(0),
264         fHistPtVsCentV0C_GenXiMinus(0),
265         fHistPtVsCentV0C_GenXiPlus(0),
266         fHistPtVsCentV0C_GenOmegaMinus(0),
267         fHistPtVsCentV0C_GenOmegaPlus(0),
268         fHistPtVsCentV0M_GenXiMinus(0),
269         fHistPtVsCentV0M_GenXiPlus(0),
270         fHistPtVsCentV0M_GenOmegaMinus(0),
271         fHistPtVsCentV0M_GenOmegaPlus(0),
272
273   //Equalized
274         fHistPtVsCentV0AEq_GenXiMinus(0),
275         fHistPtVsCentV0AEq_GenXiPlus(0),
276         fHistPtVsCentV0AEq_GenOmegaMinus(0),
277         fHistPtVsCentV0AEq_GenOmegaPlus(0),
278         fHistPtVsCentV0CEq_GenXiMinus(0),
279         fHistPtVsCentV0CEq_GenXiPlus(0),
280         fHistPtVsCentV0CEq_GenOmegaMinus(0),
281         fHistPtVsCentV0CEq_GenOmegaPlus(0),
282         fHistPtVsCentV0MEq_GenXiMinus(0),
283         fHistPtVsCentV0MEq_GenXiPlus(0),
284         fHistPtVsCentV0MEq_GenOmegaMinus(0),
285         fHistPtVsCentV0MEq_GenOmegaPlus(0),
286
287   //VsAmp
288         fHistPtVsAmpV0A_GenXiMinus(0),
289         fHistPtVsAmpV0A_GenXiPlus(0),
290         fHistPtVsAmpV0A_GenOmegaMinus(0),
291         fHistPtVsAmpV0A_GenOmegaPlus(0),
292         fHistPtVsAmpV0C_GenXiMinus(0),
293         fHistPtVsAmpV0C_GenXiPlus(0),
294         fHistPtVsAmpV0C_GenOmegaMinus(0),
295         fHistPtVsAmpV0C_GenOmegaPlus(0),
296         fHistPtVsAmpV0M_GenXiMinus(0),
297         fHistPtVsAmpV0M_GenXiPlus(0),
298         fHistPtVsAmpV0M_GenOmegaMinus(0),
299         fHistPtVsAmpV0M_GenOmegaPlus(0),
300   //Equalized Amps
301         fHistPtVsAmpV0AEq_GenXiMinus(0),
302         fHistPtVsAmpV0AEq_GenXiPlus(0),
303         fHistPtVsAmpV0AEq_GenOmegaMinus(0),
304         fHistPtVsAmpV0AEq_GenOmegaPlus(0),
305         fHistPtVsAmpV0CEq_GenXiMinus(0),
306         fHistPtVsAmpV0CEq_GenXiPlus(0),
307         fHistPtVsAmpV0CEq_GenOmegaMinus(0),
308         fHistPtVsAmpV0CEq_GenOmegaPlus(0),
309         fHistPtVsAmpV0MEq_GenXiMinus(0),
310         fHistPtVsAmpV0MEq_GenXiPlus(0),
311         fHistPtVsAmpV0MEq_GenOmegaMinus(0),
312         fHistPtVsAmpV0MEq_GenOmegaPlus(0)  
313
314 //------------------------------------------------
315 // Tree Variables 
316 {
317
318 }
319
320 AliAnalysisTaskStrangenessVsMultiplicityMC::AliAnalysisTaskStrangenessVsMultiplicityMC(const char *name) 
321   : AliAnalysisTaskSE(name), fListHist(0), fTreeEvent(0), fTreeV0(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), fPPVsMultUtils(0),  
322   fkSaveV0Tree      ( kFALSE ),
323   fkSaveCascadeTree ( kTRUE  ), 
324   fkRunVertexers    ( kTRUE  ),
325   fkSkipEventSelection( kFALSE ),
326   //---> Variables for fTreeEvent
327   fAmplitude_V0A (0),   
328   fAmplitude_V0C (0), 
329   fAmplitude_V0AEq (0),   
330   fAmplitude_V0CEq (0), 
331   fCentrality_V0A(0), 
332   fCentrality_V0C(0), 
333   fCentrality_V0M(0), 
334   fCentrality_V0AEq(0), 
335   fCentrality_V0CEq(0), 
336   fCentrality_V0MEq(0), 
337   fCustomCentrality_V0M(0),
338   fCustomCentrality_V0MEq(0),
339   fRefMultEta5(0),
340   fRefMultEta8(0),
341   fTrueMultEta5(0),
342   fTrueMultEta8(0),
343   fTrueMultVZEROA(0),
344   fTrueMultVZEROC(0),
345   fRunNumber(0),
346     fEvSel_HasAtLeastSPDVertex(0),
347     fEvSel_VtxZCut(0),
348     fEvSel_IsNotPileup(0),
349     fEvSel_IsNotPileupMV(0),
350     fEvSel_IsNotPileupInMultBins(0),
351     fEvSel_HasVtxContributor(0),
352     fEvSel_Triggered(0),
353     fEvSel_VtxZ(0), 
354     fEvSel_MCType(0), 
355   //---> Variables for fTreeV0
356         fTreeVariableChi2V0(0),
357         fTreeVariableDcaV0Daughters(0),
358         fTreeVariableDcaV0ToPrimVertex(0),
359         fTreeVariableDcaPosToPrimVertex(0),
360         fTreeVariableDcaNegToPrimVertex(0),
361         fTreeVariableV0CosineOfPointingAngle(0),
362         fTreeVariableV0Radius(0),
363         fTreeVariablePt(0),
364         fTreeVariablePtMC(0),
365         fTreeVariableRapK0Short(0),
366         fTreeVariableRapLambda(0),
367         fTreeVariableRapMC(0),
368         fTreeVariableInvMassK0s(0),
369         fTreeVariableInvMassLambda(0),
370         fTreeVariableInvMassAntiLambda(0),
371         fTreeVariableAlphaV0(0),
372         fTreeVariablePtArmV0(0),
373         fTreeVariableNegEta(0),
374         fTreeVariablePosEta(0),
375
376         fTreeVariableNSigmasPosProton(0),
377         fTreeVariableNSigmasPosPion(0),
378         fTreeVariableNSigmasNegProton(0),
379         fTreeVariableNSigmasNegPion(0),
380
381         fTreeVariableDistOverTotMom(0),
382         fTreeVariableLeastNbrCrossedRows(0),
383         fTreeVariableLeastRatioCrossedRowsOverFindable(0),
384         
385   fTreeVariableCentV0A(0),
386   fTreeVariableCentV0C(0),
387   fTreeVariableCentV0M(0),
388   fTreeVariableCentV0AEq(0),
389   fTreeVariableCentV0CEq(0),
390   fTreeVariableCentV0MEq(0),
391   fTreeVariableCustomCentV0M(0),
392   fTreeVariableAmpV0A(0),
393   fTreeVariableAmpV0C(0),
394   fTreeVariableAmpV0AEq(0),
395   fTreeVariableAmpV0CEq(0),
396   fTreeVariableRefMultEta8(0),
397   fTreeVariableRefMultEta5(0),
398   fTreeVariableRunNumber(0),
399
400   fTreeVariablePtMother(0),
401   fTreeVariablePID(0),
402   fTreeVariablePIDPositive(0),
403   fTreeVariablePIDNegative(0),
404   fTreeVariablePIDMother(0),
405   fTreeVariablePrimaryStatus(0),
406   fTreeVariablePrimaryStatusMother(0),
407   //---> Variables for fTreeCascade
408   fTreeCascVarCharge(0), 
409         fTreeCascVarMassAsXi(0),
410         fTreeCascVarMassAsOmega(0),
411         fTreeCascVarPt(0),
412         fTreeCascVarPtMC(0),
413         fTreeCascVarRapXi(0),
414         fTreeCascVarRapOmega(0),
415         fTreeCascVarRapMC(0),
416         fTreeCascVarNegEta(0),
417         fTreeCascVarPosEta(0),
418         fTreeCascVarBachEta(0),
419         fTreeCascVarDCACascDaughters(0),
420         fTreeCascVarDCABachToPrimVtx(0),
421         fTreeCascVarDCAV0Daughters(0),
422         fTreeCascVarDCAV0ToPrimVtx(0),
423         fTreeCascVarDCAPosToPrimVtx(0),
424         fTreeCascVarDCANegToPrimVtx(0),
425         fTreeCascVarCascCosPointingAngle(0),
426         fTreeCascVarCascRadius(0),
427         fTreeCascVarV0Mass(0),
428         fTreeCascVarV0CosPointingAngle(0),
429         fTreeCascVarV0CosPointingAngleSpecial(0),
430         fTreeCascVarV0Radius(0),
431   fTreeCascVarLeastNbrClusters(0),
432         fTreeCascVarDistOverTotMom(0),
433         fTreeCascVarNegNSigmaPion(0),
434         fTreeCascVarNegNSigmaProton(0),
435         fTreeCascVarPosNSigmaPion(0),
436         fTreeCascVarPosNSigmaProton(0),
437         fTreeCascVarBachNSigmaPion(0),
438         fTreeCascVarBachNSigmaKaon(0),
439         fTreeCascVarCentV0A(0),
440         fTreeCascVarCentV0C(0),
441         fTreeCascVarCentV0M(0),
442         fTreeCascVarCentV0AEq(0),
443         fTreeCascVarCentV0CEq(0),
444         fTreeCascVarCentV0MEq(0),
445   fTreeCascVarCustomCentV0M(0),
446         fTreeCascVarAmpV0A(0),
447         fTreeCascVarAmpV0C(0),
448         fTreeCascVarAmpV0AEq(0),
449         fTreeCascVarAmpV0CEq(0),
450   fTreeCascVarRefMultEta8(0),
451   fTreeCascVarRefMultEta5(0),
452   fTreeCascVarTrueMultEta5(0),
453   fTreeCascVarTrueMultEta8(0),
454   fTreeCascVarTrueMultVZEROA(0),
455   fTreeCascVarTrueMultVZEROC(0),
456   fTreeCascVarIsPhysicalPrimary(0), 
457   fTreeCascVarPID(0), 
458   fTreeCascVarRunNumber(0), 
459   //---> Histograms
460   fHistEventCounter(0), 
461   //---> MC Generated Histo (analysis level) 
462         fHistPt_GenK0Short(0),
463         fHistPt_GenLambda(0),
464         fHistPt_GenAntiLambda(0),
465         fHistPt_GenXiMinus(0),
466         fHistPt_GenXiPlus(0),
467         fHistPt_GenOmegaMinus(0),
468         fHistPt_GenOmegaPlus(0),
469
470   //VsRefMult
471         fHistPtVsRefMultEta5_GenXiMinus(0),
472         fHistPtVsRefMultEta5_GenXiPlus(0),
473         fHistPtVsRefMultEta5_GenOmegaMinus(0),
474         fHistPtVsRefMultEta5_GenOmegaPlus(0),
475         fHistPtVsRefMultEta8_GenXiMinus(0),
476         fHistPtVsRefMultEta8_GenXiPlus(0),
477         fHistPtVsRefMultEta8_GenOmegaMinus(0),
478         fHistPtVsRefMultEta8_GenOmegaPlus(0),
479
480   //VsCentralities
481         fHistPtVsCentV0A_GenXiMinus(0),
482         fHistPtVsCentV0A_GenXiPlus(0),
483         fHistPtVsCentV0A_GenOmegaMinus(0),
484         fHistPtVsCentV0A_GenOmegaPlus(0),
485         fHistPtVsCentV0C_GenXiMinus(0),
486         fHistPtVsCentV0C_GenXiPlus(0),
487         fHistPtVsCentV0C_GenOmegaMinus(0),
488         fHistPtVsCentV0C_GenOmegaPlus(0),
489         fHistPtVsCentV0M_GenXiMinus(0),
490         fHistPtVsCentV0M_GenXiPlus(0),
491         fHistPtVsCentV0M_GenOmegaMinus(0),
492         fHistPtVsCentV0M_GenOmegaPlus(0),
493
494   //Equalized
495         fHistPtVsCentV0AEq_GenXiMinus(0),
496         fHistPtVsCentV0AEq_GenXiPlus(0),
497         fHistPtVsCentV0AEq_GenOmegaMinus(0),
498         fHistPtVsCentV0AEq_GenOmegaPlus(0),
499         fHistPtVsCentV0CEq_GenXiMinus(0),
500         fHistPtVsCentV0CEq_GenXiPlus(0),
501         fHistPtVsCentV0CEq_GenOmegaMinus(0),
502         fHistPtVsCentV0CEq_GenOmegaPlus(0),
503         fHistPtVsCentV0MEq_GenXiMinus(0),
504         fHistPtVsCentV0MEq_GenXiPlus(0),
505         fHistPtVsCentV0MEq_GenOmegaMinus(0),
506         fHistPtVsCentV0MEq_GenOmegaPlus(0),
507
508   //VsAmp
509         fHistPtVsAmpV0A_GenXiMinus(0),
510         fHistPtVsAmpV0A_GenXiPlus(0),
511         fHistPtVsAmpV0A_GenOmegaMinus(0),
512         fHistPtVsAmpV0A_GenOmegaPlus(0),
513         fHistPtVsAmpV0C_GenXiMinus(0),
514         fHistPtVsAmpV0C_GenXiPlus(0),
515         fHistPtVsAmpV0C_GenOmegaMinus(0),
516         fHistPtVsAmpV0C_GenOmegaPlus(0),
517         fHistPtVsAmpV0M_GenXiMinus(0),
518         fHistPtVsAmpV0M_GenXiPlus(0),
519         fHistPtVsAmpV0M_GenOmegaMinus(0),
520         fHistPtVsAmpV0M_GenOmegaPlus(0),
521   //Equalized Amps
522         fHistPtVsAmpV0AEq_GenXiMinus(0),
523         fHistPtVsAmpV0AEq_GenXiPlus(0),
524         fHistPtVsAmpV0AEq_GenOmegaMinus(0),
525         fHistPtVsAmpV0AEq_GenOmegaPlus(0),
526         fHistPtVsAmpV0CEq_GenXiMinus(0),
527         fHistPtVsAmpV0CEq_GenXiPlus(0),
528         fHistPtVsAmpV0CEq_GenOmegaMinus(0),
529         fHistPtVsAmpV0CEq_GenOmegaPlus(0),
530         fHistPtVsAmpV0MEq_GenXiMinus(0),
531         fHistPtVsAmpV0MEq_GenXiPlus(0),
532         fHistPtVsAmpV0MEq_GenOmegaMinus(0),
533         fHistPtVsAmpV0MEq_GenOmegaPlus(0)
534 {
535
536   //Re-vertex: Will only apply for cascade candidates
537
538   fV0VertexerSels[0] =  33.  ;  // max allowed chi2
539   fV0VertexerSels[1] =   0.02;  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
540   fV0VertexerSels[2] =   0.02;  // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
541   fV0VertexerSels[3] =   2.0 ;  // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
542   fV0VertexerSels[4] =   0.95;  // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
543   fV0VertexerSels[5] =   1.0 ;  // min radius of the fiducial volume                 (LHC09a4 : 0.2)
544   fV0VertexerSels[6] = 200.  ;  // max radius of the fiducial volume                 (LHC09a4 : 100.0)
545         
546   fCascadeVertexerSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
547   fCascadeVertexerSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
548   fCascadeVertexerSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
549   fCascadeVertexerSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
550   fCascadeVertexerSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
551   fCascadeVertexerSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
552   fCascadeVertexerSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
553   fCascadeVertexerSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
554         
555
556   DefineOutput(1, TList::Class()); // Event Counter Histo
557   DefineOutput(2, TTree::Class()); // Event Tree
558   DefineOutput(3, TTree::Class()); // V0 Tree
559   DefineOutput(4, TTree::Class()); // Cascade Tree
560 }
561
562
563 AliAnalysisTaskStrangenessVsMultiplicityMC::~AliAnalysisTaskStrangenessVsMultiplicityMC()
564 {
565 //------------------------------------------------
566 // DESTRUCTOR
567 //------------------------------------------------
568
569    if (fListHist){
570       delete fListHist;
571       fListHist = 0x0;
572    }
573    if (fTreeEvent){
574       delete fTreeEvent;
575       fTreeEvent = 0x0;
576    }
577    if (fTreeV0){
578       delete fTreeV0;
579       fTreeV0 = 0x0;
580    }
581    if (fTreeCascade){
582       delete fTreeCascade;
583       fTreeCascade = 0x0;
584    }
585     if (fPPVsMultUtils){
586         delete fPPVsMultUtils;
587         fPPVsMultUtils = 0x0;
588     }
589 }
590
591 //________________________________________________________________________
592 void AliAnalysisTaskStrangenessVsMultiplicityMC::UserCreateOutputObjects()
593 {
594
595    OpenFile(2); 
596    // Called once
597
598 //------------------------------------------------
599
600    fTreeEvent = new TTree("fTreeEvent","Event");
601
602 //------------------------------------------------
603 // fTree Branch definitions - Event by Event info
604 //------------------------------------------------
605
606 //-----------BASIC-INFO---------------------------
607
608   //--- VZERO Data (Integrated)
609   fTreeEvent->Branch("fAmplitude_V0A",&fAmplitude_V0A,"fAmplitude_V0A/F");
610   fTreeEvent->Branch("fAmplitude_V0C",&fAmplitude_V0C,"fAmplitude_V0C/F");
611   fTreeEvent->Branch("fAmplitude_V0AEq",&fAmplitude_V0AEq,"fAmplitude_V0AEq/F");
612   fTreeEvent->Branch("fAmplitude_V0CEq",&fAmplitude_V0CEq,"fAmplitude_V0CEq/F");
613
614   //Info from AliCentrality (not necessarily 'centrality' per se) 
615   fTreeEvent->Branch("fCentrality_V0A",&fCentrality_V0A,"fCentrality_V0A/F");
616   fTreeEvent->Branch("fCentrality_V0C",&fCentrality_V0C,"fCentrality_V0C/F");
617   fTreeEvent->Branch("fCentrality_V0M",&fCentrality_V0M,"fCentrality_V0M/F");
618   fTreeEvent->Branch("fCentrality_V0AEq",&fCentrality_V0AEq,"fCentrality_V0AEq/F");
619   fTreeEvent->Branch("fCentrality_V0CEq",&fCentrality_V0CEq,"fCentrality_V0CEq/F");
620   fTreeEvent->Branch("fCentrality_V0MEq",&fCentrality_V0MEq,"fCentrality_V0MEq/F");
621
622   fTreeEvent->Branch("fCustomCentrality_V0M",&fCustomCentrality_V0M,"fCustomCentrality_V0M/F");
623   fTreeEvent->Branch("fCustomCentrality_V0MEq",&fCustomCentrality_V0MEq,"fCustomCentrality_V0MEq/F");
624   
625   //Official GetReferenceMultiplicity
626   fTreeEvent->Branch("fRefMultEta5",&fRefMultEta5,"fRefMultEta5/I");
627   fTreeEvent->Branch("fRefMultEta8",&fRefMultEta8,"fRefMultEta8/I");
628
629   fTreeEvent->Branch("fTrueMultEta5",&fTrueMultEta5,"fTrueMultEta5/I");
630   fTreeEvent->Branch("fTrueMultEta8",&fTrueMultEta8,"fTrueMultEta8/I");
631   fTreeEvent->Branch("fTrueMultVZEROA",&fTrueMultVZEROA,"fTrueMultVZEROA/I");
632   fTreeEvent->Branch("fTrueMultVZEROC",&fTrueMultVZEROC,"fTrueMultVZEROC/I");
633
634   //Run Number
635   fTreeEvent->Branch("fRunNumber", &fRunNumber, "fRunNumber/I");
636     
637     //Booleans for Event Selection
638     fTreeEvent->Branch("fEvSel_HasAtLeastSPDVertex", &fEvSel_HasAtLeastSPDVertex, "fEvSel_HasAtLeastSPDVertex/O");
639     fTreeEvent->Branch("fEvSel_VtxZCut", &fEvSel_VtxZCut, "fEvSel_VtxZCut/O");
640     fTreeEvent->Branch("fEvSel_IsNotPileup", &fEvSel_IsNotPileup, "fEvSel_IsNotPileup/O");
641     fTreeEvent->Branch("fEvSel_IsNotPileupMV", &fEvSel_IsNotPileupMV, "fEvSel_IsNotPileupMV/O");
642     fTreeEvent->Branch("fEvSel_IsNotPileupInMultBins", &fEvSel_IsNotPileupInMultBins, "fEvSel_IsNotPileupInMultBins/O");
643     fTreeEvent->Branch("fEvSel_HasVtxContributor", &fEvSel_HasVtxContributor, "fEvSel_HasVtxContributor/O");
644     fTreeEvent->Branch("fEvSel_Triggered", &fEvSel_Triggered, "fEvSel_Triggered/O");
645     fTreeEvent->Branch("fEvSel_VtxZ", &fEvSel_VtxZ, "fEvSel_VtxZ/F");
646     fTreeEvent->Branch("fEvSel_MCType", &fEvSel_MCType, "fEvSel_MCType/I");
647     
648
649   //Create Basic V0 Output Tree
650   fTreeV0 = new TTree( "fTreeV0", "V0 Candidates");
651
652 //------------------------------------------------
653 // fTreeV0 Branch definitions
654 //------------------------------------------------
655
656 //-----------BASIC-INFO---------------------------
657   fTreeV0->Branch("fTreeVariableChi2V0",&fTreeVariableChi2V0,"fTreeVariableChi2V0/F");
658   fTreeV0->Branch("fTreeVariableDcaV0Daughters",&fTreeVariableDcaV0Daughters,"fTreeVariableDcaV0Daughters/F");
659   fTreeV0->Branch("fTreeVariableDcaV0ToPrimVertex",&fTreeVariableDcaV0ToPrimVertex,"fTreeVariableDcaV0ToPrimVertex/F");
660   fTreeV0->Branch("fTreeVariableDcaPosToPrimVertex",&fTreeVariableDcaPosToPrimVertex,"fTreeVariableDcaPosToPrimVertex/F");
661   fTreeV0->Branch("fTreeVariableDcaNegToPrimVertex",&fTreeVariableDcaNegToPrimVertex,"fTreeVariableDcaNegToPrimVertex/F");
662   fTreeV0->Branch("fTreeVariableV0Radius",&fTreeVariableV0Radius,"fTreeVariableV0Radius/F");
663   fTreeV0->Branch("fTreeVariablePt",&fTreeVariablePt,"fTreeVariablePt/F");
664   fTreeV0->Branch("fTreeVariablePtMC",&fTreeVariablePtMC,"fTreeVariablePtMC/F");
665   fTreeV0->Branch("fTreeVariableRapK0Short",&fTreeVariableRapK0Short,"fTreeVariableRapK0Short/F");
666   fTreeV0->Branch("fTreeVariableRapLambda",&fTreeVariableRapLambda,"fTreeVariableRapLambda/F");
667   fTreeV0->Branch("fTreeVariableRapMC",&fTreeVariableRapMC,"fTreeVariableRapMC/F");
668   fTreeV0->Branch("fTreeVariableInvMassK0s",&fTreeVariableInvMassK0s,"fTreeVariableInvMassK0s/F");
669   fTreeV0->Branch("fTreeVariableInvMassLambda",&fTreeVariableInvMassLambda,"fTreeVariableInvMassLambda/F");
670   fTreeV0->Branch("fTreeVariableInvMassAntiLambda",&fTreeVariableInvMassAntiLambda,"fTreeVariableInvMassAntiLambda/F");
671   fTreeV0->Branch("fTreeVariableV0CosineOfPointingAngle",&fTreeVariableV0CosineOfPointingAngle,"fTreeVariableV0CosineOfPointingAngle/F");
672   fTreeV0->Branch("fTreeVariableAlphaV0",&fTreeVariableAlphaV0,"fTreeVariableAlphaV0/F");
673   fTreeV0->Branch("fTreeVariablePtArmV0",&fTreeVariablePtArmV0,"fTreeVariablePtArmV0/F");
674   fTreeV0->Branch("fTreeVariableLeastNbrCrossedRows",&fTreeVariableLeastNbrCrossedRows,"fTreeVariableLeastNbrCrossedRows/I");
675   fTreeV0->Branch("fTreeVariableLeastRatioCrossedRowsOverFindable",&fTreeVariableLeastRatioCrossedRowsOverFindable,"fTreeVariableLeastRatioCrossedRowsOverFindable/F");
676   fTreeV0->Branch("fTreeVariableDistOverTotMom",&fTreeVariableDistOverTotMom,"fTreeVariableDistOverTotMom/F");
677   fTreeV0->Branch("fTreeVariableNSigmasPosProton",&fTreeVariableNSigmasPosProton,"fTreeVariableNSigmasPosProton/F");
678   fTreeV0->Branch("fTreeVariableNSigmasPosPion",&fTreeVariableNSigmasPosPion,"fTreeVariableNSigmasPosPion/F");
679   fTreeV0->Branch("fTreeVariableNSigmasNegProton",&fTreeVariableNSigmasNegProton,"fTreeVariableNSigmasNegProton/F");
680   fTreeV0->Branch("fTreeVariableNSigmasNegPion",&fTreeVariableNSigmasNegPion,"fTreeVariableNSigmasNegPion/F");
681   fTreeV0->Branch("fTreeVariableNegEta",&fTreeVariableNegEta,"fTreeVariableNegEta/F");
682   fTreeV0->Branch("fTreeVariablePosEta",&fTreeVariablePosEta,"fTreeVariablePosEta/F");
683 //-----------MULTIPLICITY-INFO--------------------
684   fTreeV0->Branch("fTreeVariableCentV0A",&fTreeVariableCentV0A,"fTreeVariableCentV0A/F");
685   fTreeV0->Branch("fTreeVariableCentV0C",&fTreeVariableCentV0C,"fTreeVariableCentV0C/F");
686   fTreeV0->Branch("fTreeVariableCentV0M",&fTreeVariableCentV0M,"fTreeVariableCentV0M/F");
687   fTreeV0->Branch("fTreeVariableCentV0AEq",&fTreeVariableCentV0AEq,"fTreeVariableCentV0AEq/F");
688   fTreeV0->Branch("fTreeVariableCentV0CEq",&fTreeVariableCentV0CEq,"fTreeVariableCentV0CEq/F");
689   fTreeV0->Branch("fTreeVariableCentV0MEq",&fTreeVariableCentV0MEq,"fTreeVariableCentV0MEq/F");
690   fTreeV0->Branch("fTreeVariableCustomCentV0M",&fTreeVariableCustomCentV0M,"fTreeVariableCustomCentV0M/F");
691   fTreeV0->Branch("fTreeVariableAmpV0A",&fTreeVariableAmpV0A,"fTreeVariableAmpV0A/F");
692   fTreeV0->Branch("fTreeVariableAmpV0C",&fTreeVariableAmpV0C,"fTreeVariableAmpV0C/F");
693   fTreeV0->Branch("fTreeVariableAmpV0AEq",&fTreeVariableAmpV0AEq,"fTreeVariableAmpV0AEq/F");
694   fTreeV0->Branch("fTreeVariableAmpV0CEq",&fTreeVariableAmpV0CEq,"fTreeVariableAmpV0CEq/F");
695   fTreeV0->Branch("fTreeVariableRefMultEta8",&fTreeVariableRefMultEta8,"fTreeVariableRefMultEta8/I");
696   fTreeV0->Branch("fTreeVariableRefMultEta5",&fTreeVariableRefMultEta5,"fTreeVariableRefMultEta5/I");
697   fTreeV0->Branch("fTreeVariableRunNumber",&fTreeVariableRunNumber,"fTreeVariableRunNumber/I");
698 //-----------MC Exclusive info--------------------
699   fTreeV0->Branch("fTreeVariablePtMother",&fTreeVariablePtMother,"fTreeVariablePtMother/F");
700   fTreeV0->Branch("fTreeVariablePID",&fTreeVariablePID,"fTreeVariablePID/I");
701   fTreeV0->Branch("fTreeVariablePIDPositive",&fTreeVariablePIDPositive,"fTreeVariablePIDPositive/I");
702   fTreeV0->Branch("fTreeVariablePIDNegative",&fTreeVariablePIDNegative,"fTreeVariablePIDNegative/I");
703   fTreeV0->Branch("fTreeVariablePIDMother",&fTreeVariablePIDMother,"fTreeVariablePIDMother/I");
704   fTreeV0->Branch("fTreeVariablePrimaryStatus",&fTreeVariablePrimaryStatus,"fTreeVariablePrimaryStatus/I");
705   fTreeV0->Branch("fTreeVariablePrimaryStatusMother",&fTreeVariablePrimaryStatusMother,"fTreeVariablePrimaryStatusMother/I");
706 //------------------------------------------------
707
708   //Create Cascade output tree
709   fTreeCascade = new TTree("fTreeCascade","CascadeCandidates");
710
711 //------------------------------------------------
712 // fTreeCascade Branch definitions - Cascade Tree
713 //------------------------------------------------
714
715 //-----------BASIC-INFO---------------------------
716         fTreeCascade->Branch("fTreeCascVarCharge",&fTreeCascVarCharge,"fTreeCascVarCharge/I");  
717   fTreeCascade->Branch("fTreeCascVarMassAsXi",&fTreeCascVarMassAsXi,"fTreeCascVarMassAsXi/F");
718   fTreeCascade->Branch("fTreeCascVarMassAsOmega",&fTreeCascVarMassAsOmega,"fTreeCascVarMassAsOmega/F");
719   fTreeCascade->Branch("fTreeCascVarPt",&fTreeCascVarPt,"fTreeCascVarPt/F");
720   fTreeCascade->Branch("fTreeCascVarPtMC",&fTreeCascVarPtMC,"fTreeCascVarPtMC/F");
721   fTreeCascade->Branch("fTreeCascVarRapXi",&fTreeCascVarRapXi,"fTreeCascVarRapXi/F");
722   fTreeCascade->Branch("fTreeCascVarRapOmega",&fTreeCascVarRapOmega,"fTreeCascVarRapOmega/F");
723   fTreeCascade->Branch("fTreeCascVarRapMC",&fTreeCascVarRapMC,"fTreeCascVarRapMC/F");
724   fTreeCascade->Branch("fTreeCascVarNegEta",&fTreeCascVarNegEta,"fTreeCascVarNegEta/F");
725   fTreeCascade->Branch("fTreeCascVarPosEta",&fTreeCascVarPosEta,"fTreeCascVarPosEta/F");
726   fTreeCascade->Branch("fTreeCascVarBachEta",&fTreeCascVarBachEta,"fTreeCascVarBachEta/F");
727 //-----------INFO-FOR-CUTS------------------------
728   fTreeCascade->Branch("fTreeCascVarDCACascDaughters",&fTreeCascVarDCACascDaughters,"fTreeCascVarDCACascDaughters/F");
729   fTreeCascade->Branch("fTreeCascVarDCABachToPrimVtx",&fTreeCascVarDCABachToPrimVtx,"fTreeCascVarDCABachToPrimVtx/F");
730   fTreeCascade->Branch("fTreeCascVarDCAV0Daughters",&fTreeCascVarDCAV0Daughters,"fTreeCascVarDCAV0Daughters/F");
731   fTreeCascade->Branch("fTreeCascVarDCAV0ToPrimVtx",&fTreeCascVarDCAV0ToPrimVtx,"fTreeCascVarDCAV0ToPrimVtx/F");
732   fTreeCascade->Branch("fTreeCascVarDCAPosToPrimVtx",&fTreeCascVarDCAPosToPrimVtx,"fTreeCascVarDCAPosToPrimVtx/F");
733   fTreeCascade->Branch("fTreeCascVarDCANegToPrimVtx",&fTreeCascVarDCANegToPrimVtx,"fTreeCascVarDCANegToPrimVtx/F");
734   fTreeCascade->Branch("fTreeCascVarCascCosPointingAngle",&fTreeCascVarCascCosPointingAngle,"fTreeCascVarCascCosPointingAngle/F");
735   fTreeCascade->Branch("fTreeCascVarCascRadius",&fTreeCascVarCascRadius,"fTreeCascVarCascRadius/F");
736   fTreeCascade->Branch("fTreeCascVarV0Mass",&fTreeCascVarV0Mass,"fTreeCascVarV0Mass/F");
737   fTreeCascade->Branch("fTreeCascVarV0CosPointingAngle",&fTreeCascVarV0CosPointingAngle,"fTreeCascVarV0CosPointingAngle/F");
738   fTreeCascade->Branch("fTreeCascVarV0CosPointingAngleSpecial",&fTreeCascVarV0CosPointingAngleSpecial,"fTreeCascVarV0CosPointingAngleSpecial/F");
739   fTreeCascade->Branch("fTreeCascVarV0Radius",&fTreeCascVarV0Radius,"fTreeCascVarV0Radius/F");
740   fTreeCascade->Branch("fTreeCascVarLeastNbrClusters",&fTreeCascVarLeastNbrClusters,"fTreeCascVarLeastNbrClusters/I");
741 //-----------MULTIPLICITY-INFO--------------------
742   fTreeCascade->Branch("fTreeCascVarCentV0A",&fTreeCascVarCentV0A,"fTreeCascVarCentV0A/F");
743   fTreeCascade->Branch("fTreeCascVarCentV0C",&fTreeCascVarCentV0C,"fTreeCascVarCentV0C/F");
744   fTreeCascade->Branch("fTreeCascVarCentV0M",&fTreeCascVarCentV0M,"fTreeCascVarCentV0M/F");
745   fTreeCascade->Branch("fTreeCascVarCentV0AEq",&fTreeCascVarCentV0AEq,"fTreeCascVarCentV0AEq/F");
746   fTreeCascade->Branch("fTreeCascVarCentV0CEq",&fTreeCascVarCentV0CEq,"fTreeCascVarCentV0CEq/F");
747   fTreeCascade->Branch("fTreeCascVarCentV0MEq",&fTreeCascVarCentV0MEq,"fTreeCascVarCentV0MEq/F");
748   fTreeCascade->Branch("fTreeCascVarCustomCentV0M",&fTreeCascVarCustomCentV0M,"fTreeCascVarCustomCentV0M/F");
749   fTreeCascade->Branch("fTreeCascVarAmpV0A",&fTreeCascVarAmpV0A,"fTreeCascVarAmpV0A/F");
750   fTreeCascade->Branch("fTreeCascVarAmpV0C",&fTreeCascVarAmpV0C,"fTreeCascVarAmpV0C/F");
751   fTreeCascade->Branch("fTreeCascVarAmpV0AEq",&fTreeCascVarAmpV0AEq,"fTreeCascVarAmpV0AEq/F");
752   fTreeCascade->Branch("fTreeCascVarAmpV0CEq",&fTreeCascVarAmpV0CEq,"fTreeCascVarAmpV0CEq/F");
753   fTreeCascade->Branch("fTreeCascVarRefMultEta8",&fTreeCascVarRefMultEta8,"fTreeCascVarRefMultEta8/I");
754   fTreeCascade->Branch("fTreeCascVarRefMultEta5",&fTreeCascVarRefMultEta5,"fTreeCascVarRefMultEta5/I");
755   fTreeCascade->Branch("fTreeCascVarTrueMultEta5",&fTreeCascVarTrueMultEta5,"fTreeCascVarTrueMultEta5/I");
756   fTreeCascade->Branch("fTreeCascVarTrueMultEta8",&fTreeCascVarTrueMultEta8,"fTreeCascVarTrueMultEta8/I");
757   fTreeCascade->Branch("fTreeCascVarTrueMultVZEROA",&fTreeCascVarTrueMultVZEROA,"fTreeCascVarTrueMultVZEROA/I");
758   fTreeCascade->Branch("fTreeCascVarTrueMultVZEROC",&fTreeCascVarTrueMultVZEROC,"fTreeCascVarTrueMultVZEROC/I");
759   fTreeCascade->Branch("fTreeCascVarIsPhysicalPrimary",&fTreeCascVarIsPhysicalPrimary,"fTreeCascVarIsPhysicalPrimary/I");
760   fTreeCascade->Branch("fTreeCascVarPID",&fTreeCascVarPID,"fTreeCascVarPID/I");
761   fTreeCascade->Branch("fTreeCascVarRunNumber",&fTreeCascVarRunNumber,"fTreeCascVarRunNumber/I");
762 //-----------DECAY-LENGTH-INFO--------------------
763   fTreeCascade->Branch("fTreeCascVarDistOverTotMom",&fTreeCascVarDistOverTotMom,"fTreeCascVarDistOverTotMom/F");
764 //------------------------------------------------
765   fTreeCascade->Branch("fTreeCascVarNegNSigmaPion",&fTreeCascVarNegNSigmaPion,"fTreeCascVarNegNSigmaPion/F");
766   fTreeCascade->Branch("fTreeCascVarNegNSigmaProton",&fTreeCascVarNegNSigmaProton,"fTreeCascVarNegNSigmaProton/F");
767   fTreeCascade->Branch("fTreeCascVarPosNSigmaPion",&fTreeCascVarPosNSigmaPion,"fTreeCascVarPosNSigmaPion/F");
768   fTreeCascade->Branch("fTreeCascVarPosNSigmaProton",&fTreeCascVarPosNSigmaProton,"fTreeCascVarPosNSigmaProton/F");
769   fTreeCascade->Branch("fTreeCascVarBachNSigmaPion",&fTreeCascVarBachNSigmaPion,"fTreeCascVarBachNSigmaPion/F");
770   fTreeCascade->Branch("fTreeCascVarBachNSigmaKaon",&fTreeCascVarBachNSigmaKaon,"fTreeCascVarBachNSigmaKaon/F");
771
772 //------------------------------------------------
773 // Particle Identification Setup
774 //------------------------------------------------
775   
776    AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
777    AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
778    fPIDResponse = inputHandler->GetPIDResponse();
779
780   // Multiplicity
781   if(! fESDtrackCuts ){
782     fESDtrackCuts = new AliESDtrackCuts();
783   }
784   if(! fPPVsMultUtils ){
785     fPPVsMultUtils = new AliPPVsMultUtils();
786   }
787
788 //------------------------------------------------
789 // V0 Multiplicity Histograms
790 //------------------------------------------------
791
792    // Create histograms
793    OpenFile(1);
794    fListHist = new TList();
795    fListHist->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
796
797    if(! fHistEventCounter ) {
798     //Histogram Output: Event-by-Event
799     fHistEventCounter = new TH1D( "fHistEventCounter", ";Evt. Sel. Step;Count",5,0,5); 
800     fHistEventCounter->GetXaxis()->SetBinLabel(1, "Processed");
801     fHistEventCounter->GetXaxis()->SetBinLabel(2, "Phys-Sel");  
802     fHistEventCounter->GetXaxis()->SetBinLabel(3, "Has Vtx");  
803     fHistEventCounter->GetXaxis()->SetBinLabel(4, "Vtx |z|<10cm");  
804     fHistEventCounter->GetXaxis()->SetBinLabel(5, "Isn't Pileup");
805     fListHist->Add(fHistEventCounter); 
806    }
807
808   //Histograms for Efficiency corrections... a bunch of them 
809   //1D Histograms - Fine if efficiency doesn't change vs mult (expected) 
810   //---> Always filled for |y|<0.5 
811   //V0s: basic Histos
812   if(! fHistPt_GenK0Short ) {
813     fHistPt_GenK0Short    = new TH1D( "fHistPt_GenK0Short",    "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenK0Short);    }
814   if(! fHistPt_GenLambda ) {
815     fHistPt_GenLambda     = new TH1D( "fHistPt_GenLambda",     "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenLambda);     }
816   if(! fHistPt_GenAntiLambda ) {
817     fHistPt_GenAntiLambda = new TH1D( "fHistPt_GenAntiLambda", "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenAntiLambda); }
818   //Cascades: basic Histos
819   if(! fHistPt_GenXiMinus ) {
820     fHistPt_GenXiMinus    = new TH1D( "fHistPt_GenXiMinus",    "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenXiMinus);    }
821   if(! fHistPt_GenXiPlus ) {
822      fHistPt_GenXiPlus     = new TH1D( "fHistPt_GenXiPlus",    "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenXiPlus);     }
823   if(! fHistPt_GenOmegaMinus ) {
824     fHistPt_GenOmegaMinus = new TH1D( "fHistPt_GenOmegaMinus", "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenOmegaMinus); }
825   if(! fHistPt_GenOmegaPlus ) {
826     fHistPt_GenOmegaPlus  = new TH1D( "fHistPt_GenOmegaPlus",  "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenOmegaPlus);  }
827   //2D Histos for vs Mult calculation 
828   if(! fHistPtVsRefMultEta5_GenXiMinus ) {
829     fHistPtVsRefMultEta5_GenXiMinus    = new TH2D( "fHistPtVsRefMultEta5_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenXiMinus);    }
830   if(! fHistPtVsRefMultEta5_GenXiPlus ) {
831     fHistPtVsRefMultEta5_GenXiPlus     = new TH2D( "fHistPtVsRefMultEta5_GenXiPlus",        "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenXiPlus);    }
832   if(! fHistPtVsRefMultEta5_GenOmegaMinus ) {
833     fHistPtVsRefMultEta5_GenOmegaMinus    = new TH2D( "fHistPtVsRefMultEta5_GenOmegaMinus", "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenOmegaMinus);    }
834   if(! fHistPtVsRefMultEta5_GenOmegaPlus ) {
835     fHistPtVsRefMultEta5_GenOmegaPlus     = new TH2D( "fHistPtVsRefMultEta5_GenOmegaPlus",  "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenOmegaPlus);    }
836   if(! fHistPtVsRefMultEta8_GenXiMinus ) {
837     fHistPtVsRefMultEta8_GenXiMinus    = new TH2D( "fHistPtVsRefMultEta8_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenXiMinus);    }
838   if(! fHistPtVsRefMultEta8_GenXiPlus ) {
839     fHistPtVsRefMultEta8_GenXiPlus     = new TH2D( "fHistPtVsRefMultEta8_GenXiPlus",        "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenXiPlus);    }
840   if(! fHistPtVsRefMultEta8_GenOmegaMinus ) {
841     fHistPtVsRefMultEta8_GenOmegaMinus    = new TH2D( "fHistPtVsRefMultEta8_GenOmegaMinus", "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenOmegaMinus);    }
842   if(! fHistPtVsRefMultEta8_GenOmegaPlus ) {
843     fHistPtVsRefMultEta8_GenOmegaPlus     = new TH2D( "fHistPtVsRefMultEta8_GenOmegaPlus",  "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenOmegaPlus);    }
844
845   //Centralities: V0A, V0C, V0M, +Eq
846   if(! fHistPtVsCentV0A_GenXiMinus ) {
847     fHistPtVsCentV0A_GenXiMinus    = new TH2D( 
848     "fHistPtVsCentV0A_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
849     fListHist->Add(fHistPtVsCentV0A_GenXiMinus); }
850   if(! fHistPtVsCentV0A_GenXiPlus ) {
851     fHistPtVsCentV0A_GenXiPlus    = new TH2D( 
852     "fHistPtVsCentV0A_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
853     fListHist->Add(fHistPtVsCentV0A_GenXiPlus); }
854   if(! fHistPtVsCentV0A_GenOmegaMinus ) {
855     fHistPtVsCentV0A_GenOmegaMinus    = new TH2D( 
856     "fHistPtVsCentV0A_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
857     fListHist->Add(fHistPtVsCentV0A_GenOmegaMinus); }
858   if(! fHistPtVsCentV0A_GenOmegaPlus ) {
859     fHistPtVsCentV0A_GenOmegaPlus    = new TH2D( 
860     "fHistPtVsCentV0A_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
861     fListHist->Add(fHistPtVsCentV0A_GenOmegaPlus); }  
862
863   if(! fHistPtVsCentV0C_GenXiMinus ) {
864     fHistPtVsCentV0C_GenXiMinus    = new TH2D( 
865     "fHistPtVsCentV0C_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
866     fListHist->Add(fHistPtVsCentV0C_GenXiMinus); }
867   if(! fHistPtVsCentV0C_GenXiPlus ) {
868     fHistPtVsCentV0C_GenXiPlus    = new TH2D( 
869     "fHistPtVsCentV0C_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
870     fListHist->Add(fHistPtVsCentV0C_GenXiPlus); }
871   if(! fHistPtVsCentV0C_GenOmegaMinus ) {
872     fHistPtVsCentV0C_GenOmegaMinus    = new TH2D( 
873     "fHistPtVsCentV0C_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
874     fListHist->Add(fHistPtVsCentV0C_GenOmegaMinus); }
875   if(! fHistPtVsCentV0C_GenOmegaPlus ) {
876     fHistPtVsCentV0C_GenOmegaPlus    = new TH2D( 
877     "fHistPtVsCentV0C_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
878     fListHist->Add(fHistPtVsCentV0C_GenOmegaPlus); }  
879
880   if(! fHistPtVsCentV0M_GenXiMinus ) {
881     fHistPtVsCentV0M_GenXiMinus    = new TH2D( 
882     "fHistPtVsCentV0M_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
883     fListHist->Add(fHistPtVsCentV0M_GenXiMinus); }
884   if(! fHistPtVsCentV0M_GenXiPlus ) {
885     fHistPtVsCentV0M_GenXiPlus    = new TH2D( 
886     "fHistPtVsCentV0M_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
887     fListHist->Add(fHistPtVsCentV0M_GenXiPlus); }
888   if(! fHistPtVsCentV0M_GenOmegaMinus ) {
889     fHistPtVsCentV0M_GenOmegaMinus    = new TH2D( 
890     "fHistPtVsCentV0M_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
891     fListHist->Add(fHistPtVsCentV0M_GenOmegaMinus); }
892   if(! fHistPtVsCentV0M_GenOmegaPlus ) {
893     fHistPtVsCentV0M_GenOmegaPlus    = new TH2D( 
894     "fHistPtVsCentV0M_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
895     fListHist->Add(fHistPtVsCentV0M_GenOmegaPlus); }  
896
897   //Equalized
898   if(! fHistPtVsCentV0AEq_GenXiMinus ) {
899     fHistPtVsCentV0AEq_GenXiMinus    = new TH2D( 
900     "fHistPtVsCentV0AEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
901     fListHist->Add(fHistPtVsCentV0AEq_GenXiMinus); }
902   if(! fHistPtVsCentV0AEq_GenXiPlus ) {
903     fHistPtVsCentV0AEq_GenXiPlus    = new TH2D( 
904     "fHistPtVsCentV0AEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
905     fListHist->Add(fHistPtVsCentV0AEq_GenXiPlus); }
906   if(! fHistPtVsCentV0AEq_GenOmegaMinus ) {
907     fHistPtVsCentV0AEq_GenOmegaMinus    = new TH2D( 
908     "fHistPtVsCentV0AEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
909     fListHist->Add(fHistPtVsCentV0AEq_GenOmegaMinus); }
910   if(! fHistPtVsCentV0AEq_GenOmegaPlus ) {
911     fHistPtVsCentV0AEq_GenOmegaPlus    = new TH2D( 
912     "fHistPtVsCentV0AEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
913     fListHist->Add(fHistPtVsCentV0AEq_GenOmegaPlus); }  
914
915   if(! fHistPtVsCentV0CEq_GenXiMinus ) {
916     fHistPtVsCentV0CEq_GenXiMinus    = new TH2D( 
917     "fHistPtVsCentV0CEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
918     fListHist->Add(fHistPtVsCentV0CEq_GenXiMinus); }
919   if(! fHistPtVsCentV0CEq_GenXiPlus ) {
920     fHistPtVsCentV0CEq_GenXiPlus    = new TH2D( 
921     "fHistPtVsCentV0CEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
922     fListHist->Add(fHistPtVsCentV0CEq_GenXiPlus); }
923   if(! fHistPtVsCentV0CEq_GenOmegaMinus ) {
924     fHistPtVsCentV0CEq_GenOmegaMinus    = new TH2D( 
925     "fHistPtVsCentV0CEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
926     fListHist->Add(fHistPtVsCentV0CEq_GenOmegaMinus); }
927   if(! fHistPtVsCentV0CEq_GenOmegaPlus ) {
928     fHistPtVsCentV0CEq_GenOmegaPlus    = new TH2D( 
929     "fHistPtVsCentV0CEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
930     fListHist->Add(fHistPtVsCentV0CEq_GenOmegaPlus); }  
931
932   if(! fHistPtVsCentV0MEq_GenXiMinus ) {
933     fHistPtVsCentV0MEq_GenXiMinus    = new TH2D( 
934     "fHistPtVsCentV0MEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
935     fListHist->Add(fHistPtVsCentV0MEq_GenXiMinus); }
936   if(! fHistPtVsCentV0MEq_GenXiPlus ) {
937     fHistPtVsCentV0MEq_GenXiPlus    = new TH2D( 
938     "fHistPtVsCentV0MEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
939     fListHist->Add(fHistPtVsCentV0MEq_GenXiPlus); }
940   if(! fHistPtVsCentV0MEq_GenOmegaMinus ) {
941     fHistPtVsCentV0MEq_GenOmegaMinus    = new TH2D( 
942     "fHistPtVsCentV0MEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
943     fListHist->Add(fHistPtVsCentV0MEq_GenOmegaMinus); }
944   if(! fHistPtVsCentV0MEq_GenOmegaPlus ) {
945     fHistPtVsCentV0MEq_GenOmegaPlus    = new TH2D( 
946     "fHistPtVsCentV0MEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
947     fListHist->Add(fHistPtVsCentV0MEq_GenOmegaPlus); }  
948
949   //AMPLITUDES: V0A, V0C, V0M, +Eq
950   Double_t lMaxAmplitude = 2500; 
951   Long_t lAmplitudeBins = 10000;
952   if(! fHistPtVsAmpV0A_GenXiMinus ) {
953     fHistPtVsAmpV0A_GenXiMinus    = new TH2D( 
954     "fHistPtVsAmpV0A_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
955     fListHist->Add(fHistPtVsAmpV0A_GenXiMinus); }
956   if(! fHistPtVsAmpV0A_GenXiPlus ) {
957     fHistPtVsAmpV0A_GenXiPlus    = new TH2D( 
958     "fHistPtVsAmpV0A_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
959     fListHist->Add(fHistPtVsAmpV0A_GenXiPlus); }
960   if(! fHistPtVsAmpV0A_GenOmegaMinus ) {
961     fHistPtVsAmpV0A_GenOmegaMinus    = new TH2D( 
962     "fHistPtVsAmpV0A_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
963     fListHist->Add(fHistPtVsAmpV0A_GenOmegaMinus); }
964   if(! fHistPtVsAmpV0A_GenOmegaPlus ) {
965     fHistPtVsAmpV0A_GenOmegaPlus    = new TH2D( 
966     "fHistPtVsAmpV0A_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
967     fListHist->Add(fHistPtVsAmpV0A_GenOmegaPlus); }  
968
969   if(! fHistPtVsAmpV0C_GenXiMinus ) {
970     fHistPtVsAmpV0C_GenXiMinus    = new TH2D( 
971     "fHistPtVsAmpV0C_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
972     fListHist->Add(fHistPtVsAmpV0C_GenXiMinus); }
973   if(! fHistPtVsAmpV0C_GenXiPlus ) {
974     fHistPtVsAmpV0C_GenXiPlus    = new TH2D( 
975     "fHistPtVsAmpV0C_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
976     fListHist->Add(fHistPtVsAmpV0C_GenXiPlus); }
977   if(! fHistPtVsAmpV0C_GenOmegaMinus ) {
978     fHistPtVsAmpV0C_GenOmegaMinus    = new TH2D( 
979     "fHistPtVsAmpV0C_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
980     fListHist->Add(fHistPtVsAmpV0C_GenOmegaMinus); }
981   if(! fHistPtVsAmpV0C_GenOmegaPlus ) {
982     fHistPtVsAmpV0C_GenOmegaPlus    = new TH2D( 
983     "fHistPtVsAmpV0C_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
984     fListHist->Add(fHistPtVsAmpV0C_GenOmegaPlus); }  
985
986   if(! fHistPtVsAmpV0M_GenXiMinus ) {
987     fHistPtVsAmpV0M_GenXiMinus    = new TH2D( 
988     "fHistPtVsAmpV0M_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
989     fListHist->Add(fHistPtVsAmpV0M_GenXiMinus); }
990   if(! fHistPtVsAmpV0M_GenXiPlus ) {
991     fHistPtVsAmpV0M_GenXiPlus    = new TH2D( 
992     "fHistPtVsAmpV0M_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
993     fListHist->Add(fHistPtVsAmpV0M_GenXiPlus); }
994   if(! fHistPtVsAmpV0M_GenOmegaMinus ) {
995     fHistPtVsAmpV0M_GenOmegaMinus    = new TH2D( 
996     "fHistPtVsAmpV0M_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
997     fListHist->Add(fHistPtVsAmpV0M_GenOmegaMinus); }
998   if(! fHistPtVsAmpV0M_GenOmegaPlus ) {
999     fHistPtVsAmpV0M_GenOmegaPlus    = new TH2D( 
1000     "fHistPtVsAmpV0M_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1001     fListHist->Add(fHistPtVsAmpV0M_GenOmegaPlus); }  
1002
1003   //Equalized
1004   if(! fHistPtVsAmpV0AEq_GenXiMinus ) {
1005     fHistPtVsAmpV0AEq_GenXiMinus    = new TH2D( 
1006     "fHistPtVsAmpV0AEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1007     fListHist->Add(fHistPtVsAmpV0AEq_GenXiMinus); }
1008   if(! fHistPtVsAmpV0AEq_GenXiPlus ) {
1009     fHistPtVsAmpV0AEq_GenXiPlus    = new TH2D( 
1010     "fHistPtVsAmpV0AEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1011     fListHist->Add(fHistPtVsAmpV0AEq_GenXiPlus); }
1012   if(! fHistPtVsAmpV0AEq_GenOmegaMinus ) {
1013     fHistPtVsAmpV0AEq_GenOmegaMinus    = new TH2D( 
1014     "fHistPtVsAmpV0AEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1015     fListHist->Add(fHistPtVsAmpV0AEq_GenOmegaMinus); }
1016   if(! fHistPtVsAmpV0AEq_GenOmegaPlus ) {
1017     fHistPtVsAmpV0AEq_GenOmegaPlus    = new TH2D( 
1018     "fHistPtVsAmpV0AEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1019     fListHist->Add(fHistPtVsAmpV0AEq_GenOmegaPlus); }  
1020
1021   if(! fHistPtVsAmpV0CEq_GenXiMinus ) {
1022     fHistPtVsAmpV0CEq_GenXiMinus    = new TH2D( 
1023     "fHistPtVsAmpV0CEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1024     fListHist->Add(fHistPtVsAmpV0CEq_GenXiMinus); }
1025   if(! fHistPtVsAmpV0CEq_GenXiPlus ) {
1026     fHistPtVsAmpV0CEq_GenXiPlus    = new TH2D( 
1027     "fHistPtVsAmpV0CEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1028     fListHist->Add(fHistPtVsAmpV0CEq_GenXiPlus); }
1029   if(! fHistPtVsAmpV0CEq_GenOmegaMinus ) {
1030     fHistPtVsAmpV0CEq_GenOmegaMinus    = new TH2D( 
1031     "fHistPtVsAmpV0CEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1032     fListHist->Add(fHistPtVsAmpV0CEq_GenOmegaMinus); }
1033   if(! fHistPtVsAmpV0CEq_GenOmegaPlus ) {
1034     fHistPtVsAmpV0CEq_GenOmegaPlus    = new TH2D( 
1035     "fHistPtVsAmpV0CEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1036     fListHist->Add(fHistPtVsAmpV0CEq_GenOmegaPlus); }  
1037
1038   if(! fHistPtVsAmpV0MEq_GenXiMinus ) {
1039     fHistPtVsAmpV0MEq_GenXiMinus    = new TH2D( 
1040     "fHistPtVsAmpV0MEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1041     fListHist->Add(fHistPtVsAmpV0MEq_GenXiMinus); }
1042   if(! fHistPtVsAmpV0MEq_GenXiPlus ) {
1043     fHistPtVsAmpV0MEq_GenXiPlus    = new TH2D( 
1044     "fHistPtVsAmpV0MEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1045     fListHist->Add(fHistPtVsAmpV0MEq_GenXiPlus); }
1046   if(! fHistPtVsAmpV0MEq_GenOmegaMinus ) {
1047     fHistPtVsAmpV0MEq_GenOmegaMinus    = new TH2D( 
1048     "fHistPtVsAmpV0MEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1049     fListHist->Add(fHistPtVsAmpV0MEq_GenOmegaMinus); }
1050   if(! fHistPtVsAmpV0MEq_GenOmegaPlus ) {
1051     fHistPtVsAmpV0MEq_GenOmegaPlus    = new TH2D( 
1052     "fHistPtVsAmpV0MEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
1053     fListHist->Add(fHistPtVsAmpV0MEq_GenOmegaPlus); }  
1054
1055    //List of Histograms: Normal
1056    PostData(1, fListHist);
1057
1058    //TTree Object: Saved to base directory. Should cache to disk while saving. 
1059    //(Important to avoid excessive memory usage, particularly when merging)
1060    PostData(2, fTreeEvent);
1061    PostData(3, fTreeV0);
1062    PostData(4, fTreeCascade);
1063
1064 }// end UserCreateOutputObjects
1065
1066
1067 //________________________________________________________________________
1068 void AliAnalysisTaskStrangenessVsMultiplicityMC::UserExec(Option_t *) 
1069 {
1070   // Main loop
1071   // Called for each event
1072
1073    AliESDEvent *lESDevent = 0x0;
1074    AliMCEvent  *lMCevent  = 0x0; 
1075    AliStack    *lMCstack  = 0x0; 
1076
1077     //Zero all booleans, etc
1078     fEvSel_HasAtLeastSPDVertex    = kFALSE;
1079     fEvSel_VtxZCut                = kFALSE;
1080     fEvSel_IsNotPileup            = kFALSE;
1081     fEvSel_IsNotPileupInMultBins  = kFALSE;
1082     fEvSel_HasVtxContributor      = kFALSE;
1083     fEvSel_Triggered              = kFALSE;
1084     fEvSel_VtxZ = -100; 
1085     fEvSel_MCType = -100; 
1086   // Connect to the InputEvent   
1087   // After these lines, we should have an ESD/AOD event + the number of V0s in it.
1088
1089    // Appropriate for ESD analysis! 
1090       
1091    lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
1092    if (!lESDevent) {
1093       AliWarning("ERROR: lESDevent not available \n");
1094       return;
1095    }
1096
1097   //Get VZERO Information for multiplicity later
1098   AliVVZERO* esdV0 = lESDevent->GetVZEROData();
1099   if (!esdV0) {
1100     AliError("AliVVZERO not available");
1101     return;
1102   }
1103         
1104   lMCevent = MCEvent();
1105   if (!lMCevent) {
1106     Printf("ERROR: Could not retrieve MC event \n");
1107     cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;   
1108     return;
1109   }
1110
1111   lMCstack = lMCevent->Stack();
1112   if (!lMCstack) {
1113     Printf("ERROR: Could not retrieve MC stack \n");
1114     cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
1115     return;
1116   }
1117
1118    fRunNumber = lESDevent->GetRunNumber();
1119
1120   Double_t lMagneticField = -10; 
1121   lMagneticField = lESDevent->GetMagneticField( );
1122
1123 //------------------------------------------------
1124 // MC type (ND, SD, DD) 
1125 //------------------------------------------------
1126
1127     AliGenEventHeader * header = lMCevent->GenEventHeader();
1128     Int_t processtype = AliPWG0Helper::GetPythiaEventProcessType(header);
1129     // non diffractive
1130     if (processtype !=92 && processtype !=93 && processtype != 94) fEvSel_MCType = 1;
1131     // single diffractive
1132     if ((processtype == 92 || processtype == 93)) fEvSel_MCType = 2;
1133     // double diffractive
1134     if (processtype == 94) fEvSel_MCType = 3;
1135
1136 //------------------------------------------------
1137 // Physics Selection
1138 //------------------------------------------------
1139   
1140   fHistEventCounter->Fill(0.5); 
1141
1142   UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1143   Bool_t isSelected = 0;
1144   isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
1145   fEvSel_Triggered = isSelected;
1146   
1147   //Standard Min-Bias Selection
1148   if ( (! isSelected) && (! fkSkipEventSelection ) ) {
1149     PostData(1, fListHist);
1150     PostData(2, fTreeEvent);
1151     PostData(3, fTreeV0);
1152     PostData(4, fTreeCascade);
1153     return;
1154   }
1155
1156   fHistEventCounter->Fill(1.5);
1157  
1158   //------------------------------------------------
1159   // Primary Vertex Requirements Section:
1160   //  ---> pp: has vertex, |z|<10cm
1161   //------------------------------------------------
1162   
1163   //classical Proton-proton like selection 
1164   const AliESDVertex *lPrimaryBestESDVtx     = lESDevent->GetPrimaryVertex();   
1165   const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
1166   const AliESDVertex *lPrimarySPDVtx         = lESDevent->GetPrimaryVertexSPD();
1167
1168   Double_t lBestPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
1169   lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
1170   fEvSel_VtxZ = lBestPrimaryVtxPos[2];
1171
1172   //Only accept if Tracking or SPD vertex is fine 
1173   if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() && !fkSkipEventSelection ){
1174     AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1175     PostData(1, fListHist); 
1176     PostData(2, fTreeEvent);
1177     PostData(3, fTreeV0);
1178     PostData(4, fTreeCascade);
1179     return;
1180   }
1181     
1182     if(! (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus()) ){
1183         //Passed selection!
1184         fEvSel_HasAtLeastSPDVertex = kTRUE;
1185     }
1186     
1187   //Has SPD or Tracking Vertex
1188   fHistEventCounter -> Fill(2.5); 
1189
1190   //Always do Primary Vertex Selection 
1191   if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 && !fkSkipEventSelection ) {
1192     AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
1193     PostData(1, fListHist); 
1194     PostData(2, fTreeEvent);
1195     PostData(3, fTreeV0);
1196     PostData(4, fTreeCascade);
1197     return;
1198   }
1199     
1200     if(TMath::Abs(lBestPrimaryVtxPos[2]) <= 10.0 ){
1201         //Passed selection!
1202         fEvSel_VtxZCut = kTRUE;
1203     }
1204
1205   //Fill Event selected counter
1206   fHistEventCounter -> Fill(3.5);
1207
1208   //------------------------------------------------
1209   // Check if this isn't pileup
1210   //------------------------------------------------
1211
1212   if(lESDevent->IsPileupFromSPD() && !fkSkipEventSelection ){
1213     // minContributors=3, minZdist=0.8, nSigmaZdist=3., nSigmaDiamXY=2., nSigmaDiamZ=5.  
1214     //-> see http://alisoft.cern.ch/viewvc/trunk/STEER/AliESDEvent.h?root=AliRoot&r1=41914&r2=42199&pathrev=42199
1215     AliWarning("Pb / Event tagged as pile-up by SPD... return !"); 
1216     PostData(1, fListHist); 
1217     PostData(2, fTreeEvent);
1218     PostData(3, fTreeV0);
1219     PostData(4, fTreeCascade);
1220     return; 
1221   }
1222     
1223     if( !lESDevent->IsPileupFromSPD()           ) fEvSel_IsNotPileup           = kTRUE;
1224     if( !lESDevent->IsPileupFromSPDInMultBins() ) fEvSel_IsNotPileupInMultBins = kTRUE;
1225     
1226     //First implementation of pileup from multi-vertexer (simple use of analysis utils)
1227     //if ( !fUtils->IsPileUpMV( lESDevent ) ) fEvSel_IsNotPileupMV = kTRUE;
1228     fEvSel_IsNotPileupMV = kFALSE ; //dummy
1229     
1230   //Fill Event isn't pileup counter
1231   fHistEventCounter -> Fill(4.5);
1232
1233 //------------------------------------------------
1234 // Multiplicity Information Acquistion
1235 //------------------------------------------------
1236
1237   //Monte Carlo Level information ! 
1238   //--------- GENERATED NUMBER OF CHARGED PARTICLES
1239   // ---> Variable Definition
1240
1241   Long_t lNchEta5   = 0; 
1242   Long_t lNchEta8   = 0; 
1243   Long_t lNchVZEROA = 0; 
1244   Long_t lNchVZEROC = 0; 
1245
1246   //----- Loop on Stack ----------------------------------------------------------------
1247   for (Int_t iCurrentLabelStack = 0;  iCurrentLabelStack < (lMCstack->GetNtrack()); iCurrentLabelStack++) 
1248   {// This is the begining of the loop on tracks
1249       TParticle* particleOne = lMCstack->Particle(iCurrentLabelStack);
1250       if(!particleOne) continue;
1251       if(!particleOne->GetPDG()) continue;
1252       Double_t lThisCharge = particleOne->GetPDG()->Charge()/3.;
1253       if(TMath::Abs(lThisCharge)<0.001) continue;
1254       if(! (lMCstack->IsPhysicalPrimary(iCurrentLabelStack)) ) continue;
1255      
1256       //Double_t gpt = particleOne -> Pt();
1257       Double_t geta = particleOne -> Eta(); 
1258
1259       if( TMath::Abs(geta) < 0.5 ) lNchEta5++; 
1260       if( TMath::Abs(geta) < 0.8 ) lNchEta8++; 
1261       if( 2.8 < geta && geta < 5.1 ) lNchVZEROA++; 
1262       if(-3.7 < geta && geta <-1.7 ) lNchVZEROC++; 
1263   }//End of loop on tracks
1264
1265   //Attribution 
1266   fTrueMultEta5 = lNchEta5; 
1267   fTrueMultEta8 = lNchEta8; 
1268   fTrueMultVZEROA = lNchVZEROA; 
1269   fTrueMultVZEROC = lNchVZEROC; 
1270   //----- End Loop on Stack ------------------------------------------------------------
1271
1272   //Standard GetReferenceMultiplicity Estimator (0.5 and 0.8)
1273   fRefMultEta5 = fESDtrackCuts->GetReferenceMultiplicity(lESDevent, AliESDtrackCuts::kTrackletsITSTPC,0.5);
1274   fRefMultEta8 = fESDtrackCuts->GetReferenceMultiplicity(lESDevent, AliESDtrackCuts::kTrackletsITSTPC,0.8);
1275
1276   // VZERO PART
1277   Float_t  multV0A  = 0;            //  multiplicity from V0 reco side A
1278   Float_t  multV0C  = 0;            //  multiplicity from V0 reco side C
1279   Float_t  multV0AEq  = 0;          //  multiplicity from V0 reco side A
1280   Float_t  multV0CEq  = 0;          //  multiplicity from V0 reco side C
1281   Float_t  multV0ACorr  = 0;            //  multiplicity from V0 reco side A
1282   Float_t  multV0CCorr  = 0;            //  multiplicity from V0 reco side C
1283
1284   //Non-Equalized Signal: copy of multV0ACorr and multV0CCorr from AliCentralitySelectionTask
1285   //Getters for uncorrected multiplicity  
1286   multV0A=esdV0->GetMTotV0A();
1287   multV0C=esdV0->GetMTotV0C();
1288
1289   //Get Z vertex position of SPD vertex (why not Tracking if available?) 
1290   Float_t zvtx = lPrimarySPDVtx->GetZ(); 
1291
1292   //Acquire Corrected multV0A 
1293   multV0ACorr = AliESDUtils::GetCorrV0A(multV0A,zvtx);    
1294   multV0CCorr = AliESDUtils::GetCorrV0C(multV0C,zvtx);   
1295     
1296   //Copy to Event Tree for extra information 
1297   fAmplitude_V0A = multV0ACorr; 
1298   fAmplitude_V0C = multV0CCorr; 
1299
1300   // Equalized signals // From AliCentralitySelectionTask
1301   for(Int_t iCh = 4; iCh < 7; ++iCh) {
1302     Double_t mult = lESDevent->GetVZEROEqMultiplicity(iCh);
1303     multV0AEq += mult;
1304   }
1305   for(Int_t iCh = 0; iCh < 3; ++iCh) {
1306     Double_t mult = lESDevent->GetVZEROEqMultiplicity(iCh);
1307     multV0CEq += mult;
1308   }
1309   fAmplitude_V0AEq = multV0AEq; 
1310   fAmplitude_V0CEq = multV0CEq; 
1311
1312   fCentrality_V0A   = -100; 
1313   fCentrality_V0C   = -100; 
1314   fCentrality_V0M   = -100; 
1315   fCentrality_V0AEq = -100; 
1316   fCentrality_V0CEq = -100; 
1317   fCentrality_V0MEq = -100; 
1318
1319   //AliCentrality... Check if working? 
1320   AliCentrality* centrality;
1321   centrality = lESDevent->GetCentrality();
1322   if ( !(centrality->GetQuality()>1) ){ 
1323     fCentrality_V0A   = centrality->GetCentralityPercentile( "V0A"   ); 
1324     fCentrality_V0C   = centrality->GetCentralityPercentile( "V0C"   ); 
1325     fCentrality_V0M   = centrality->GetCentralityPercentile( "V0M"   ); 
1326     fCentrality_V0AEq = centrality->GetCentralityPercentile( "V0AEq" ); 
1327     fCentrality_V0CEq = centrality->GetCentralityPercentile( "V0CEq" ); 
1328     fCentrality_V0MEq = centrality->GetCentralityPercentile( "V0MEq" ); 
1329   }
1330   
1331   fCustomCentrality_V0M = fPPVsMultUtils -> GetMultiplicityPercentile(lESDevent, "V0M");
1332   fCustomCentrality_V0MEq = fPPVsMultUtils -> GetMultiplicityPercentile(lESDevent, "V0MEq");
1333   
1334   fTreeVariableCustomCentV0M = fCustomCentrality_V0M; 
1335   fTreeCascVarCustomCentV0M  = fCustomCentrality_V0M; 
1336   
1337   //Event-level fill 
1338   fTreeEvent->Fill();
1339     
1340     //STOP HERE if skipping event selections (no point in doing the rest...)
1341     if( fkSkipEventSelection ){
1342         PostData(1, fListHist);
1343         PostData(2, fTreeEvent);
1344         PostData(3, fTreeV0);
1345         PostData(4, fTreeCascade);
1346         return;
1347     }
1348    
1349   
1350 //------------------------------------------------
1351
1352 //------------------------------------------------
1353 // Fill Efficiency Denominators, please 
1354 //------------------------------------------------
1355
1356    Int_t    lThisPDG  = 0;
1357    Double_t lThisRap  = 0;
1358    Double_t lThisPt   = 0;
1359
1360 //----- Loop on Generated CASCADES ---------------
1361    for (Int_t ilab = 0;  ilab < (lMCstack->GetNtrack()); ilab++) 
1362    {// This is the begining of the loop on tracks
1363       
1364       TParticle* lPart = 0x0; 
1365       lPart = lMCstack->Particle( ilab );
1366       if(!lPart){
1367          Printf("Generated loop %d - MC TParticle pointer to current stack particle = 0x0 ! Skip ...\n", ilab );
1368          continue;
1369       }
1370
1371       lThisPDG = lPart->GetPdgCode();         
1372
1373       if ( (TMath::Abs(lThisPDG) == 3312) || (TMath::Abs(lThisPDG) == 3334) || (TMath::Abs(lThisPDG) == 3122) || lThisPDG == 310 ) 
1374       {
1375         lThisRap   = MyRapidity(lPart->Energy(),lPart->Pz());
1376         lThisPt    = lPart->Pt();
1377
1378         //Use Physical Primaries only for filling These Histos
1379         if ( lMCstack->IsPhysicalPrimary(ilab)!=kTRUE ) continue;
1380
1381         if( lThisPDG ==   310 && TMath::Abs(lThisRap) < 0.5 ) fHistPt_GenK0Short       -> Fill ( lThisPt ); 
1382         if( lThisPDG ==  3122 && TMath::Abs(lThisRap) < 0.5 ) fHistPt_GenLambda     -> Fill ( lThisPt ); 
1383         if( lThisPDG == -3122 && TMath::Abs(lThisRap) < 0.5 ) fHistPt_GenAntiLambda -> Fill ( lThisPt ); 
1384
1385         if( lThisPDG ==  3312 && TMath::Abs(lThisRap) < 0.5 ){
1386           fHistPt_GenXiMinus                -> Fill (lThisPt);          
1387           fHistPtVsRefMultEta5_GenXiMinus   -> Fill (lThisPt, fRefMultEta5); 
1388           fHistPtVsRefMultEta8_GenXiMinus   -> Fill (lThisPt, fRefMultEta8);
1389           //Centralities 
1390           fHistPtVsCentV0A_GenXiMinus       -> Fill (lThisPt, fCentrality_V0A);  
1391           fHistPtVsCentV0C_GenXiMinus       -> Fill (lThisPt, fCentrality_V0C);  
1392           fHistPtVsCentV0M_GenXiMinus       -> Fill (lThisPt, fCentrality_V0M);  
1393           fHistPtVsCentV0AEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0AEq);  
1394           fHistPtVsCentV0CEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0CEq);  
1395           fHistPtVsCentV0MEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0MEq);  
1396           //Amplitudes 
1397           fHistPtVsAmpV0A_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0A);  
1398           fHistPtVsAmpV0C_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0C);  
1399           fHistPtVsAmpV0M_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1400           fHistPtVsAmpV0AEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1401           fHistPtVsAmpV0CEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1402           fHistPtVsAmpV0MEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1403         }
1404         if( lThisPDG == -3312 && TMath::Abs(lThisRap) < 0.5 ){
1405           fHistPt_GenXiPlus                -> Fill (lThisPt);          
1406           fHistPtVsRefMultEta5_GenXiPlus   -> Fill (lThisPt, fRefMultEta5); 
1407           fHistPtVsRefMultEta8_GenXiPlus   -> Fill (lThisPt, fRefMultEta8);
1408           //Centralities 
1409           fHistPtVsCentV0A_GenXiPlus       -> Fill (lThisPt, fCentrality_V0A);  
1410           fHistPtVsCentV0C_GenXiPlus       -> Fill (lThisPt, fCentrality_V0C);  
1411           fHistPtVsCentV0M_GenXiPlus       -> Fill (lThisPt, fCentrality_V0M);  
1412           fHistPtVsCentV0AEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0AEq);  
1413           fHistPtVsCentV0CEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0CEq);  
1414           fHistPtVsCentV0MEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0MEq);  
1415           //Amplitudes 
1416           fHistPtVsAmpV0A_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0A);  
1417           fHistPtVsAmpV0C_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0C);  
1418           fHistPtVsAmpV0M_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1419           fHistPtVsAmpV0AEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1420           fHistPtVsAmpV0CEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1421           fHistPtVsAmpV0MEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1422         }
1423         if( lThisPDG ==  3334 && TMath::Abs(lThisRap) < 0.5 ){
1424           fHistPt_GenOmegaMinus                -> Fill (lThisPt);          
1425           fHistPtVsRefMultEta5_GenOmegaMinus   -> Fill (lThisPt, fRefMultEta5); 
1426           fHistPtVsRefMultEta8_GenOmegaMinus   -> Fill (lThisPt, fRefMultEta8);
1427           //Centralities 
1428           fHistPtVsCentV0A_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0A);  
1429           fHistPtVsCentV0C_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0C);  
1430           fHistPtVsCentV0M_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0M);  
1431           fHistPtVsCentV0AEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0AEq);  
1432           fHistPtVsCentV0CEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0CEq);  
1433           fHistPtVsCentV0MEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0MEq);  
1434           //Amplitudes 
1435           fHistPtVsAmpV0A_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0A);  
1436           fHistPtVsAmpV0C_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0C);  
1437           fHistPtVsAmpV0M_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1438           fHistPtVsAmpV0AEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1439           fHistPtVsAmpV0CEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1440           fHistPtVsAmpV0MEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1441         }
1442         if( lThisPDG == -3334 && TMath::Abs(lThisRap) < 0.5 ){
1443           fHistPt_GenOmegaPlus                -> Fill (lThisPt);          
1444           fHistPtVsRefMultEta5_GenOmegaPlus   -> Fill (lThisPt, fRefMultEta5); 
1445           fHistPtVsRefMultEta8_GenOmegaPlus   -> Fill (lThisPt, fRefMultEta8);
1446           //Centralities 
1447           fHistPtVsCentV0A_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0A);  
1448           fHistPtVsCentV0C_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0C);  
1449           fHistPtVsCentV0M_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0M);  
1450           fHistPtVsCentV0AEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0AEq);  
1451           fHistPtVsCentV0CEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0CEq);  
1452           fHistPtVsCentV0MEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0MEq);  
1453           //Amplitudes 
1454           fHistPtVsAmpV0A_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0A);  
1455           fHistPtVsAmpV0C_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0C);  
1456           fHistPtVsAmpV0M_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1457           fHistPtVsAmpV0AEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1458           fHistPtVsAmpV0CEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1459           fHistPtVsAmpV0MEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1460         }
1461       }
1462    }//End of loop on tracks
1463 //----- End Loop on Cascades ------------------------------------------------------------
1464
1465 //------------------------------------------------
1466 // Fill V0 Tree as needed
1467 //------------------------------------------------
1468
1469 //Variable definition
1470    Int_t    lOnFlyStatus = 0;// nv0sOn = 0, nv0sOff = 0;
1471    Double_t lChi2V0 = 0;
1472    Double_t lDcaV0Daughters = 0, lDcaV0ToPrimVertex = 0;
1473    Double_t lDcaPosToPrimVertex = 0, lDcaNegToPrimVertex = 0;
1474    Double_t lV0CosineOfPointingAngle = 0;
1475    Double_t lV0Radius = 0, lPt = 0;
1476    Double_t lRapK0Short = 0, lRapLambda = 0;
1477    Double_t lInvMassK0s = 0, lInvMassLambda = 0, lInvMassAntiLambda = 0;
1478    Double_t lAlphaV0 = 0, lPtArmV0 = 0;
1479
1480    Double_t fMinV0Pt = 0; 
1481    Double_t fMaxV0Pt = 100; 
1482
1483    Int_t nv0s = 0;
1484    nv0s = lESDevent->GetNumberOfV0s();
1485
1486    for (Int_t iV0 = 0; iV0 < nv0s; iV0++) //extra-crazy test
1487    {// This is the begining of the V0 loop
1488       AliESDv0 *v0 = ((AliESDEvent*)lESDevent)->GetV0(iV0);
1489       if (!v0) continue;
1490
1491       Double_t tDecayVertexV0[3]; v0->GetXYZ(tDecayVertexV0[0],tDecayVertexV0[1],tDecayVertexV0[2]); 
1492
1493       Double_t tV0mom[3];
1494       v0->GetPxPyPz( tV0mom[0],tV0mom[1],tV0mom[2] ); 
1495       Double_t lV0TotalMomentum = TMath::Sqrt(
1496       tV0mom[0]*tV0mom[0]+tV0mom[1]*tV0mom[1]+tV0mom[2]*tV0mom[2] );
1497
1498       lV0Radius = TMath::Sqrt(tDecayVertexV0[0]*tDecayVertexV0[0]+tDecayVertexV0[1]*tDecayVertexV0[1]);
1499
1500       lPt = v0->Pt();
1501       lRapK0Short = v0->RapK0Short();
1502       lRapLambda  = v0->RapLambda();
1503       if ((lPt<fMinV0Pt)||(fMaxV0Pt<lPt)) continue;
1504
1505       UInt_t lKeyPos = (UInt_t)TMath::Abs(v0->GetPindex());
1506       UInt_t lKeyNeg = (UInt_t)TMath::Abs(v0->GetNindex());
1507
1508       Double_t lMomPos[3]; v0->GetPPxPyPz(lMomPos[0],lMomPos[1],lMomPos[2]);
1509       Double_t lMomNeg[3]; v0->GetNPxPyPz(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
1510
1511       AliESDtrack *pTrack=((AliESDEvent*)lESDevent)->GetTrack(lKeyPos);
1512       AliESDtrack *nTrack=((AliESDEvent*)lESDevent)->GetTrack(lKeyNeg);
1513       if (!pTrack || !nTrack) {
1514          Printf("ERROR: Could not retreive one of the daughter track");
1515          continue;
1516       }
1517
1518       //Daughter Eta for Eta selection, afterwards
1519       fTreeVariableNegEta = nTrack->Eta();
1520       fTreeVariablePosEta = pTrack->Eta();
1521
1522       // Filter like-sign V0 (next: add counter and distribution)
1523       if ( pTrack->GetSign() == nTrack->GetSign()){
1524          continue;
1525       } 
1526
1527       //________________________________________________________________________
1528       // Track quality cuts 
1529       Float_t lPosTrackCrossedRows = pTrack->GetTPCClusterInfo(2,1);
1530       Float_t lNegTrackCrossedRows = nTrack->GetTPCClusterInfo(2,1);
1531       fTreeVariableLeastNbrCrossedRows = (Int_t) lPosTrackCrossedRows;
1532       if( lNegTrackCrossedRows < fTreeVariableLeastNbrCrossedRows )
1533          fTreeVariableLeastNbrCrossedRows = (Int_t) lNegTrackCrossedRows;
1534
1535       // TPC refit condition (done during reconstruction for Offline but not for On-the-fly)
1536       if( !(pTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
1537       if( !(nTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
1538      
1539   
1540       if ( ( ( pTrack->GetTPCClusterInfo(2,1) ) < 70 ) || ( ( nTrack->GetTPCClusterInfo(2,1) ) < 70 ) ) continue;
1541         
1542       //GetKinkIndex condition
1543       if( pTrack->GetKinkIndex(0)>0 || nTrack->GetKinkIndex(0)>0 ) continue;
1544
1545       //Findable clusters > 0 condition
1546       if( pTrack->GetTPCNclsF()<=0 || nTrack->GetTPCNclsF()<=0 ) continue;
1547
1548       //Compute ratio Crossed Rows / Findable clusters
1549       //Note: above test avoids division by zero! 
1550       Float_t lPosTrackCrossedRowsOverFindable = lPosTrackCrossedRows / ((double)(pTrack->GetTPCNclsF())); 
1551       Float_t lNegTrackCrossedRowsOverFindable = lNegTrackCrossedRows / ((double)(nTrack->GetTPCNclsF())); 
1552
1553       fTreeVariableLeastRatioCrossedRowsOverFindable = lPosTrackCrossedRowsOverFindable;
1554       if( lNegTrackCrossedRowsOverFindable < fTreeVariableLeastRatioCrossedRowsOverFindable )
1555          fTreeVariableLeastRatioCrossedRowsOverFindable = lNegTrackCrossedRowsOverFindable;
1556
1557       //Lowest Cut Level for Ratio Crossed Rows / Findable = 0.8, set here
1558       if ( fTreeVariableLeastRatioCrossedRowsOverFindable < 0.8 ) continue;
1559
1560       //End track Quality Cuts
1561       //________________________________________________________________________
1562
1563       lDcaPosToPrimVertex = TMath::Abs(pTrack->GetD(lBestPrimaryVtxPos[0],
1564                                                         lBestPrimaryVtxPos[1],
1565                                                         lMagneticField) );
1566
1567       lDcaNegToPrimVertex = TMath::Abs(nTrack->GetD(lBestPrimaryVtxPos[0],
1568                                                         lBestPrimaryVtxPos[1],
1569                                                         lMagneticField) );
1570
1571       lOnFlyStatus = v0->GetOnFlyStatus();
1572       lChi2V0 = v0->GetChi2V0();
1573       lDcaV0Daughters = v0->GetDcaV0Daughters();
1574       lDcaV0ToPrimVertex = v0->GetD(lBestPrimaryVtxPos[0],lBestPrimaryVtxPos[1],lBestPrimaryVtxPos[2]);
1575       lV0CosineOfPointingAngle = v0->GetV0CosineOfPointingAngle(lBestPrimaryVtxPos[0],lBestPrimaryVtxPos[1],lBestPrimaryVtxPos[2]);
1576       fTreeVariableV0CosineOfPointingAngle=lV0CosineOfPointingAngle;
1577
1578       // Getting invariant mass infos directly from ESD
1579       v0->ChangeMassHypothesis(310);
1580       lInvMassK0s = v0->GetEffMass();
1581       v0->ChangeMassHypothesis(3122);
1582       lInvMassLambda = v0->GetEffMass();
1583       v0->ChangeMassHypothesis(-3122);
1584       lInvMassAntiLambda = v0->GetEffMass();
1585       lAlphaV0 = v0->AlphaV0();
1586       lPtArmV0 = v0->PtArmV0();
1587
1588
1589 //===============================================
1590 // Monte Carlo Association starts here
1591 //===============================================
1592
1593       //---> Set Everything to "I don't know" before starting
1594
1595       fTreeVariablePIDPositive = 0;
1596       fTreeVariablePIDNegative = 0;
1597
1598       fTreeVariablePtMother = -1;
1599       fTreeVariablePtMC = -1;
1600       fTreeVariableRapMC = -100;
1601
1602       fTreeVariablePID = -1; 
1603       fTreeVariablePIDMother = -1;
1604
1605       fTreeVariablePrimaryStatus = 0; 
1606       fTreeVariablePrimaryStatusMother = 0; 
1607     
1608       Int_t lblPosV0Dghter = (Int_t) TMath::Abs( pTrack->GetLabel() );
1609       Int_t lblNegV0Dghter = (Int_t) TMath::Abs( nTrack->GetLabel() );
1610                 
1611       TParticle* mcPosV0Dghter = lMCstack->Particle( lblPosV0Dghter );
1612       TParticle* mcNegV0Dghter = lMCstack->Particle( lblNegV0Dghter );
1613             
1614       Int_t lPIDPositive = mcPosV0Dghter -> GetPdgCode();
1615       Int_t lPIDNegative = mcNegV0Dghter -> GetPdgCode();
1616
1617       fTreeVariablePIDPositive = lPIDPositive;
1618       fTreeVariablePIDNegative = lPIDNegative;
1619
1620       Int_t lblMotherPosV0Dghter = mcPosV0Dghter->GetFirstMother() ; 
1621       Int_t lblMotherNegV0Dghter = mcNegV0Dghter->GetFirstMother();
1622     
1623       if( lblMotherPosV0Dghter == lblMotherNegV0Dghter && lblMotherPosV0Dghter > -1 ){
1624          //either label is fine, they're equal at this stage
1625          TParticle* pThisV0 = lMCstack->Particle( lblMotherPosV0Dghter ); 
1626          //Set tree variables
1627          fTreeVariablePID   = pThisV0->GetPdgCode(); //PDG Code
1628          fTreeVariablePtMC  = pThisV0->Pt(); //Perfect Pt
1629
1630          //Only Interested if it's a Lambda, AntiLambda or K0s 
1631          //Avoid the Junction Bug! PYTHIA has particles with Px=Py=Pz=E=0 occasionally, 
1632          //having particle code 88 (unrecognized by PDG), for documentation purposes.
1633          //Even ROOT's TParticle::Y() is not prepared to deal with that exception!
1634          //Note that TParticle::Pt() is immune (that would just return 0)...
1635          //Though granted that that should be extremely rare in this precise condition...
1636          if( TMath::Abs(fTreeVariablePID) == 3122 || fTreeVariablePID==310 ){
1637             fTreeVariableRapMC = pThisV0->Y(); //Perfect Y
1638          }
1639          if( lMCstack->IsPhysicalPrimary       (lblMotherPosV0Dghter) ) fTreeVariablePrimaryStatus = 1; //Is Primary!
1640          if( lMCstack->IsSecondaryFromWeakDecay(lblMotherPosV0Dghter) ) fTreeVariablePrimaryStatus = 2; //Weak Decay!
1641          if( lMCstack->IsSecondaryFromMaterial (lblMotherPosV0Dghter) ) fTreeVariablePrimaryStatus = 3; //Material Int!
1642          
1643          //Now we try to acquire the V0 parent particle, if possible
1644          Int_t lblThisV0Parent = pThisV0->GetFirstMother();
1645          if ( lblThisV0Parent > -1 ){ //if it has a parent, get it and store specs
1646             TParticle* pThisV0Parent = lMCstack->Particle( lblThisV0Parent );
1647             fTreeVariablePIDMother   = pThisV0Parent->GetPdgCode(); //V0 Mother PDG
1648             fTreeVariablePtMother    = pThisV0Parent->Pt();         //V0 Mother Pt
1649             //Primary Status for the V0 Mother particle 
1650             if( lMCstack->IsPhysicalPrimary       (lblThisV0Parent) ) fTreeVariablePrimaryStatusMother = 1; //Is Primary!
1651             if( lMCstack->IsSecondaryFromWeakDecay(lblThisV0Parent) ) fTreeVariablePrimaryStatusMother = 2; //Weak Decay!
1652             if( lMCstack->IsSecondaryFromMaterial (lblThisV0Parent) ) fTreeVariablePrimaryStatusMother = 3; //Material Int!
1653          }
1654       }
1655
1656       fTreeVariablePt = v0->Pt();
1657       fTreeVariableChi2V0 = lChi2V0; 
1658       fTreeVariableDcaV0ToPrimVertex = lDcaV0ToPrimVertex;
1659       fTreeVariableDcaV0Daughters = lDcaV0Daughters;
1660       fTreeVariableV0CosineOfPointingAngle = lV0CosineOfPointingAngle; 
1661       fTreeVariableV0Radius = lV0Radius;
1662       fTreeVariableDcaPosToPrimVertex = lDcaPosToPrimVertex;
1663       fTreeVariableDcaNegToPrimVertex = lDcaNegToPrimVertex;
1664       fTreeVariableInvMassK0s = lInvMassK0s;
1665       fTreeVariableInvMassLambda = lInvMassLambda;
1666       fTreeVariableInvMassAntiLambda = lInvMassAntiLambda;
1667       fTreeVariableRapK0Short = lRapK0Short;
1668       fTreeVariableRapLambda = lRapLambda;
1669       fTreeVariableAlphaV0 = lAlphaV0;
1670       fTreeVariablePtArmV0 = lPtArmV0;
1671
1672       //Official means of acquiring N-sigmas 
1673       fTreeVariableNSigmasPosProton = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kProton );
1674       fTreeVariableNSigmasPosPion   = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kPion );
1675       fTreeVariableNSigmasNegProton = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kProton );
1676       fTreeVariableNSigmasNegPion   = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kPion );
1677
1678 //This requires an Invariant Mass Hypothesis afterwards
1679       fTreeVariableDistOverTotMom = TMath::Sqrt(
1680                                                 TMath::Power( tDecayVertexV0[0] - lBestPrimaryVtxPos[0] , 2) +
1681                                                 TMath::Power( tDecayVertexV0[1] - lBestPrimaryVtxPos[1] , 2) +
1682                                                 TMath::Power( tDecayVertexV0[2] - lBestPrimaryVtxPos[2] , 2)
1683                                         );
1684       fTreeVariableDistOverTotMom /= (lV0TotalMomentum+1e-10); //avoid division by zero, to be sure
1685
1686       //Copy Multiplicity information 
1687       fTreeVariableCentV0A = fCentrality_V0A; 
1688       fTreeVariableCentV0C = fCentrality_V0C; 
1689       fTreeVariableCentV0M = fCentrality_V0M; 
1690       fTreeVariableCentV0AEq = fCentrality_V0AEq; 
1691       fTreeVariableCentV0CEq = fCentrality_V0CEq; 
1692       fTreeVariableCentV0MEq = fCentrality_V0MEq; 
1693       fTreeVariableAmpV0A = fAmplitude_V0A; 
1694       fTreeVariableAmpV0C = fAmplitude_V0C; 
1695       fTreeVariableAmpV0AEq = fAmplitude_V0AEq; 
1696       fTreeVariableAmpV0CEq = fAmplitude_V0CEq; 
1697       fTreeVariableRefMultEta8 = fRefMultEta8;
1698       fTreeVariableRefMultEta5 = fRefMultEta5;
1699       fTreeVariableRunNumber = fRunNumber; 
1700
1701 //------------------------------------------------
1702 // Fill Tree! 
1703 //------------------------------------------------
1704      
1705      // The conditionals are meant to decrease excessive
1706      // memory usage!
1707      
1708      //First Selection: Reject OnFly
1709      if( lOnFlyStatus == 0 ){
1710        //Second Selection: rough 20-sigma band, parametric.
1711        //K0Short: Enough to parametrize peak broadening with linear function.
1712        Double_t lUpperLimitK0Short = (5.63707e-01) + (1.14979e-02)*fTreeVariablePt;
1713        Double_t lLowerLimitK0Short = (4.30006e-01) - (1.10029e-02)*fTreeVariablePt;
1714        //Lambda: Linear (for higher pt) plus exponential (for low-pt broadening)
1715        //[0]+[1]*x+[2]*TMath::Exp(-[3]*x)
1716        Double_t lUpperLimitLambda = (1.13688e+00) + (5.27838e-03)*fTreeVariablePt + (8.42220e-02)*TMath::Exp(-(3.80595e+00)*fTreeVariablePt);
1717        Double_t lLowerLimitLambda = (1.09501e+00) - (5.23272e-03)*fTreeVariablePt - (7.52690e-02)*TMath::Exp(-(3.46339e+00)*fTreeVariablePt);
1718        //Do Selection
1719        if( (fTreeVariableInvMassLambda    < lUpperLimitLambda  && fTreeVariableInvMassLambda     > lLowerLimitLambda     ) ||
1720           (fTreeVariableInvMassAntiLambda < lUpperLimitLambda  && fTreeVariableInvMassAntiLambda > lLowerLimitLambda     ) ||
1721           (fTreeVariableInvMassK0s        < lUpperLimitK0Short && fTreeVariableInvMassK0s        > lLowerLimitK0Short    ) ){
1722          //Pre-selection in case this is AA...
1723          if ( TMath::Abs(fTreeVariableNegEta)<0.8 && TMath::Abs(fTreeVariablePosEta)<0.8 && fkSaveV0Tree ) fTreeV0->Fill();
1724        }
1725      }
1726    }// This is the end of the V0 loop
1727
1728 //------------------------------------------------
1729 // Fill V0 tree over.
1730 //------------------------------------------------
1731
1732 //------------------------------------------------
1733 // Rerun cascade vertexer! 
1734 //------------------------------------------------
1735     
1736   if( fkRunVertexers ){ 
1737     lESDevent->ResetCascades();
1738     lESDevent->ResetV0s();
1739
1740     AliV0vertexer lV0vtxer;
1741     AliCascadeVertexer lCascVtxer;
1742                   
1743     lV0vtxer.SetDefaultCuts(fV0VertexerSels);
1744     lCascVtxer.SetDefaultCuts(fCascadeVertexerSels);
1745
1746     lV0vtxer.Tracks2V0vertices(lESDevent);
1747     lCascVtxer.V0sTracks2CascadeVertices(lESDevent);
1748   }
1749
1750 //------------------------------------------------
1751 // MAIN CASCADE LOOP STARTS HERE
1752 //------------------------------------------------
1753 // Code Credit: Antonin Maire (thanks^100)
1754 // ---> This is an adaptation
1755
1756   Long_t ncascades = 0;
1757         ncascades = lESDevent->GetNumberOfCascades();
1758   
1759   for (Int_t iXi = 0; iXi < ncascades; iXi++){
1760     //------------------------------------------------
1761     // Initializations
1762     //------------------------------------------------  
1763           //Double_t lTrkgPrimaryVtxRadius3D = -500.0;
1764           //Double_t lBestPrimaryVtxRadius3D = -500.0;
1765
1766           // - 1st part of initialisation : variables needed to store AliESDCascade data members
1767           Double_t lEffMassXi      = 0. ;
1768           //Double_t lChi2Xi         = -1. ;
1769           Double_t lDcaXiDaughters = -1. ;
1770           Double_t lXiCosineOfPointingAngle = -1. ;
1771           Double_t lPosXi[3] = { -1000.0, -1000.0, -1000.0 };
1772           Double_t lXiRadius = -1000. ;
1773           
1774           // - 2nd part of initialisation : Nbr of clusters within TPC for the 3 daughter cascade tracks
1775           Int_t    lPosTPCClusters    = -1; // For ESD only ...//FIXME : wait for availability in AOD
1776           Int_t    lNegTPCClusters    = -1; // For ESD only ...
1777           Int_t    lBachTPCClusters   = -1; // For ESD only ...
1778                         
1779           // - 3rd part of initialisation : about V0 part in cascades
1780           Double_t lInvMassLambdaAsCascDghter = 0.;
1781           //Double_t lV0Chi2Xi         = -1. ;
1782           Double_t lDcaV0DaughtersXi = -1.;
1783                 
1784           Double_t lDcaBachToPrimVertexXi = -1., lDcaV0ToPrimVertexXi = -1.;
1785           Double_t lDcaPosToPrimVertexXi  = -1.;
1786           Double_t lDcaNegToPrimVertexXi  = -1.;
1787           Double_t lV0CosineOfPointingAngleXi = -1. ;
1788           Double_t lV0CosineOfPointingAngleXiSpecial = -1. ;
1789           Double_t lPosV0Xi[3] = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
1790           Double_t lV0RadiusXi = -1000.0;
1791           Double_t lV0quality  = 0.;
1792         
1793           // - 4th part of initialisation : Effective masses
1794           Double_t lInvMassXiMinus    = 0.;
1795           Double_t lInvMassXiPlus     = 0.;
1796           Double_t lInvMassOmegaMinus = 0.;
1797           Double_t lInvMassOmegaPlus  = 0.;
1798     
1799           // - 6th part of initialisation : extra info for QA
1800           Double_t lXiMomX       = 0. , lXiMomY = 0., lXiMomZ = 0.;
1801           Double_t lXiTransvMom  = 0. ;
1802           //Double_t lXiTransvMomMC= 0. ;
1803           Double_t lXiTotMom     = 0. ;
1804                 
1805           Double_t lBachMomX       = 0., lBachMomY  = 0., lBachMomZ   = 0.;
1806           //Double_t lBachTransvMom  = 0.;
1807           //Double_t lBachTotMom     = 0.;
1808
1809     fTreeCascVarNegNSigmaPion   = -100;
1810     fTreeCascVarNegNSigmaProton = -100;
1811     fTreeCascVarPosNSigmaPion   = -100;
1812     fTreeCascVarPosNSigmaProton = -100;
1813     fTreeCascVarBachNSigmaPion  = -100;
1814     fTreeCascVarBachNSigmaKaon  = -100;
1815         
1816           Short_t  lChargeXi = -2;
1817           //Double_t lV0toXiCosineOfPointingAngle = 0. ;
1818         
1819           Double_t lRapXi   = -20.0, lRapOmega = -20.0, lRapMC = -20;//  lEta = -20.0, lTheta = 360., lPhi = 720. ;
1820           //Double_t lAlphaXi = -200., lPtArmXi  = -200.0;
1821             
1822     // -------------------------------------
1823     // II.ESD - Calculation Part dedicated to Xi vertices (ESD)
1824     
1825           AliESDcascade *xi = lESDevent->GetCascade(iXi);
1826           if (!xi) continue;
1827         
1828                 // - II.Step 2 : Assigning the necessary variables for specific AliESDcascade data members (ESD)        
1829                 //-------------
1830           lV0quality = 0.;
1831           xi->ChangeMassHypothesis(lV0quality , 3312); // default working hypothesis : cascade = Xi- decay
1832
1833           lEffMassXi                    = xi->GetEffMassXi();
1834           //lChi2Xi                         = xi->GetChi2Xi();
1835           lDcaXiDaughters       = xi->GetDcaXiDaughters();
1836           lXiCosineOfPointingAngle                  = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0],
1837                                                                                  lBestPrimaryVtxPos[1],
1838                                                                                  lBestPrimaryVtxPos[2] );
1839                   // Take care : the best available vertex should be used (like in AliCascadeVertexer)
1840         
1841           xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
1842           lXiRadius                     = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );           
1843
1844                 // - II.Step 3 : around the tracks : Bach + V0 (ESD)
1845                 // ~ Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
1846                 //-------------
1847                 
1848         UInt_t lIdxPosXi        = (UInt_t) TMath::Abs( xi->GetPindex() );
1849         UInt_t lIdxNegXi        = (UInt_t) TMath::Abs( xi->GetNindex() );
1850         UInt_t lBachIdx         = (UInt_t) TMath::Abs( xi->GetBindex() );
1851                 // Care track label can be negative in MC production (linked with the track quality)
1852                 // However = normally, not the case for track index ...
1853           
1854           // FIXME : rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
1855           if(lBachIdx == lIdxNegXi) {
1856                   AliWarning("Pb / Idx(Bach. track) = Idx(Neg. track) ... continue!"); continue;
1857           }
1858     if(lBachIdx == lIdxPosXi) {
1859         AliWarning("Pb / Idx(Bach. track) = Idx(Pos. track) ... continue!"); continue;
1860           }
1861           
1862           AliESDtrack *pTrackXi         = lESDevent->GetTrack( lIdxPosXi );
1863           AliESDtrack *nTrackXi         = lESDevent->GetTrack( lIdxNegXi );
1864           AliESDtrack *bachTrackXi      = lESDevent->GetTrack( lBachIdx );
1865
1866           if (!pTrackXi || !nTrackXi || !bachTrackXi ) {
1867                   AliWarning("ERROR: Could not retrieve one of the 3 ESD daughter tracks of the cascade ...");
1868                   continue;
1869           }
1870
1871       fTreeCascVarPosEta = pTrackXi->Eta();
1872       fTreeCascVarNegEta = nTrackXi->Eta();
1873       fTreeCascVarBachEta = bachTrackXi->Eta();
1874       
1875       Double_t lBMom[3], lNMom[3], lPMom[3];
1876       xi->GetBPxPyPz( lBMom[0], lBMom[1], lBMom[2] );
1877       xi->GetPPxPyPz( lPMom[0], lPMom[1], lPMom[2] );
1878       xi->GetNPxPyPz( lNMom[0], lNMom[1], lNMom[2] );
1879       
1880       //fTreeCascVarBachTransMom = TMath::Sqrt( lBMom[0]*lBMom[0] + lBMom[1]*lBMom[1] );
1881       //fTreeCascVarPosTransMom  = TMath::Sqrt( lPMom[0]*lPMom[0] + lPMom[1]*lPMom[1] );
1882       //fTreeCascVarNegTransMom  = TMath::Sqrt( lNMom[0]*lNMom[0] + lNMom[1]*lNMom[1] );
1883   
1884     //------------------------------------------------
1885     // TPC dEdx information 
1886     //------------------------------------------------
1887     fTreeCascVarNegNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kPion   );
1888     fTreeCascVarNegNSigmaProton = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kProton );
1889     fTreeCascVarPosNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kPion );
1890     fTreeCascVarPosNSigmaProton = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kProton );
1891     fTreeCascVarBachNSigmaPion  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kPion );
1892     fTreeCascVarBachNSigmaKaon  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kKaon );
1893
1894     //------------------------------------------------
1895     // TPC Number of clusters info
1896     // --- modified to save the smallest number 
1897     // --- of TPC clusters for the 3 tracks
1898     //------------------------------------------------
1899               
1900           lPosTPCClusters   = pTrackXi->GetTPCNcls();
1901           lNegTPCClusters   = nTrackXi->GetTPCNcls();
1902           lBachTPCClusters  = bachTrackXi->GetTPCNcls(); 
1903
1904     // 1 - Poor quality related to TPCrefit
1905           ULong_t pStatus    = pTrackXi->GetStatus();
1906           ULong_t nStatus    = nTrackXi->GetStatus();
1907           ULong_t bachStatus = bachTrackXi->GetStatus();
1908
1909     //fTreeCascVarkITSRefitBachelor = kTRUE; 
1910     //fTreeCascVarkITSRefitNegative = kTRUE; 
1911     //fTreeCascVarkITSRefitPositive = kTRUE; 
1912
1913     if ((pStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Pos. track has no TPCrefit ... continue!"); continue; }
1914     if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
1915     if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
1916
1917     //Extra Debug Information: booleans for ITS refit
1918     //if ((pStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitPositive = kFALSE; }
1919     //if ((nStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitNegative = kFALSE; }
1920     //if ((bachStatus&AliESDtrack::kITSrefit) == 0) { fTreeCascVarkITSRefitBachelor = kFALSE; }
1921
1922           // 2 - Poor quality related to TPC clusters: lowest cut of 70 clusters
1923     if(lPosTPCClusters  < 70) { AliWarning("Pb / V0 Pos. track has less than 70 TPC clusters ... continue!"); continue; }
1924           if(lNegTPCClusters  < 70) { AliWarning("Pb / V0 Neg. track has less than 70 TPC clusters ... continue!"); continue; }
1925           if(lBachTPCClusters < 70) { AliWarning("Pb / Bach.   track has less than 70 TPC clusters ... continue!"); continue; }
1926           Int_t leastnumberofclusters = 1000; 
1927           if( lPosTPCClusters < leastnumberofclusters ) leastnumberofclusters = lPosTPCClusters;
1928           if( lNegTPCClusters < leastnumberofclusters ) leastnumberofclusters = lNegTPCClusters;
1929           if( lBachTPCClusters < leastnumberofclusters ) leastnumberofclusters = lBachTPCClusters;
1930
1931           lInvMassLambdaAsCascDghter    = xi->GetEffMass();
1932           // This value shouldn't change, whatever the working hyp. is : Xi-, Xi+, Omega-, Omega+
1933           lDcaV0DaughtersXi             = xi->GetDcaV0Daughters(); 
1934           //lV0Chi2Xi                   = xi->GetChi2V0();
1935         
1936           lV0CosineOfPointingAngleXi    = xi->GetV0CosineOfPointingAngle( lBestPrimaryVtxPos[0],
1937                                                                             lBestPrimaryVtxPos[1],
1938                                                                             lBestPrimaryVtxPos[2] );
1939     //Modification: V0 CosPA wrt to Cascade decay vertex
1940           lV0CosineOfPointingAngleXiSpecial     = xi->GetV0CosineOfPointingAngle( lPosXi[0],
1941                                                                             lPosXi[1],
1942                                                                             lPosXi[2] );
1943
1944           lDcaV0ToPrimVertexXi          = xi->GetD( lBestPrimaryVtxPos[0], 
1945                                                       lBestPrimaryVtxPos[1], 
1946                                                       lBestPrimaryVtxPos[2] );
1947                 
1948           lDcaBachToPrimVertexXi = TMath::Abs( bachTrackXi->GetD(       lBestPrimaryVtxPos[0], 
1949                                                                 lBestPrimaryVtxPos[1], 
1950                                                                 lMagneticField  ) ); 
1951                                           // Note : AliExternalTrackParam::GetD returns an algebraic value ...
1952                 
1953           xi->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] ); 
1954           lV0RadiusXi           = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0]  +  lPosV0Xi[1]*lPosV0Xi[1] );
1955         
1956           lDcaPosToPrimVertexXi         = TMath::Abs( pTrackXi  ->GetD( lBestPrimaryVtxPos[0], 
1957                                                                 lBestPrimaryVtxPos[1], 
1958                                                                 lMagneticField  )     ); 
1959         
1960           lDcaNegToPrimVertexXi         = TMath::Abs( nTrackXi  ->GetD( lBestPrimaryVtxPos[0], 
1961                                                                 lBestPrimaryVtxPos[1], 
1962                                                                 lMagneticField  )     ); 
1963                 
1964           // - II.Step 4 : around effective masses (ESD)
1965           // ~ change mass hypotheses to cover all the possibilities :  Xi-/+, Omega -/+
1966                 
1967           if( bachTrackXi->Charge() < 0 )       {
1968                   lV0quality = 0.;
1969                   xi->ChangeMassHypothesis(lV0quality , 3312);  
1970                           // Calculate the effective mass of the Xi- candidate. 
1971                           // pdg code 3312 = Xi-
1972                   lInvMassXiMinus = xi->GetEffMassXi();
1973                 
1974                   lV0quality = 0.;
1975                   xi->ChangeMassHypothesis(lV0quality , 3334);  
1976                           // Calculate the effective mass of the Xi- candidate. 
1977                           // pdg code 3334 = Omega-
1978                   lInvMassOmegaMinus = xi->GetEffMassXi();
1979                                         
1980                   lV0quality = 0.;
1981                   xi->ChangeMassHypothesis(lV0quality , 3312);  // Back to default hyp.
1982           }// end if negative bachelor
1983         
1984         
1985           if( bachTrackXi->Charge() >  0 ){
1986                   lV0quality = 0.;
1987                   xi->ChangeMassHypothesis(lV0quality , -3312);         
1988                           // Calculate the effective mass of the Xi+ candidate. 
1989                           // pdg code -3312 = Xi+
1990                   lInvMassXiPlus = xi->GetEffMassXi();
1991                 
1992                   lV0quality = 0.;
1993                   xi->ChangeMassHypothesis(lV0quality , -3334);         
1994                           // Calculate the effective mass of the Xi+ candidate. 
1995                           // pdg code -3334  = Omega+
1996                   lInvMassOmegaPlus = xi->GetEffMassXi();
1997                 
1998                   lV0quality = 0.;
1999                   xi->ChangeMassHypothesis(lV0quality , -3312);         // Back to "default" hyp.
2000           }// end if positive bachelor
2001                   // - II.Step 6 : extra info for QA (ESD)
2002                   // miscellaneous pieces of info that may help regarding data quality assessment.
2003                   //-------------
2004
2005           xi->GetPxPyPz( lXiMomX, lXiMomY, lXiMomZ );
2006                   lXiTransvMom          = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY );
2007                   lXiTotMom     = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY   + lXiMomZ*lXiMomZ );
2008                 
2009           xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
2010                   //lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY );
2011                   //lBachTotMom         = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY  +  lBachMomZ*lBachMomZ  );
2012
2013           lChargeXi = xi->Charge();
2014
2015           //lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
2016         
2017           lRapXi    = xi->RapXi();
2018           lRapOmega = xi->RapOmega();
2019           //lEta      = xi->Eta();
2020           //lTheta    = xi->Theta() *180.0/TMath::Pi();
2021           //lPhi      = xi->Phi()   *180.0/TMath::Pi();
2022           //lAlphaXi  = xi->AlphaXi();
2023           //lPtArmXi  = xi->PtArmXi();
2024
2025 //------------------------------------------------
2026 // Associate Cascade Candidates to Monte Carlo!
2027 //------------------------------------------------      
2028
2029 //Warning: Not using Continues... Need to fill tree later!
2030
2031   Double_t lXiTransvMomMC= 0. ; 
2032         Int_t lPDGCodeCascade = 0;      
2033         Int_t lPID_BachMother = 0;
2034         Int_t lPID_NegMother = 0;
2035         Int_t lPID_PosMother = 0;
2036   fTreeCascVarIsPhysicalPrimary = 0; // 0: not defined, any candidate may have this
2037
2038         if(fDebug > 5)
2039                 cout    << "MC EventNumber : " << lMCevent->Header()->GetEvent() 
2040                         << " / MC event Number in Run : " << lMCevent->Header()->GetEventNrInRun() << endl;
2041         
2042 //----------------------------------------
2043 // Regular MC ASSOCIATION STARTS HERE
2044 //----------------------------------------
2045
2046           Int_t lblPosV0Dghter = (Int_t) TMath::Abs( pTrackXi->GetLabel() );  
2047                   // Abs value = needed ! question of quality track association ...
2048           Int_t lblNegV0Dghter = (Int_t) TMath::Abs( nTrackXi->GetLabel() );
2049           Int_t lblBach        = (Int_t) TMath::Abs( bachTrackXi->GetLabel() );
2050
2051           TParticle* mcPosV0Dghter = lMCstack->Particle( lblPosV0Dghter );
2052           TParticle* mcNegV0Dghter = lMCstack->Particle( lblNegV0Dghter );
2053           TParticle* mcBach        = lMCstack->Particle( lblBach );
2054       
2055     //fTreeCascVarPosTransMomMC = mcPosV0Dghter->Pt();
2056     //fTreeCascVarNegTransMomMC = mcNegV0Dghter->Pt();
2057
2058           //fTreeCascVarPIDPositive = mcPosV0Dghter -> GetPdgCode();
2059           //fTreeCascVarPIDNegative = mcNegV0Dghter -> GetPdgCode();
2060           //fTreeCascVarPIDBachelor = mcBach->GetPdgCode();
2061
2062           // - Step 4.2 : level of the Xi daughters
2063                 
2064           Int_t lblMotherPosV0Dghter = mcPosV0Dghter->GetFirstMother() ; 
2065           Int_t lblMotherNegV0Dghter = mcNegV0Dghter->GetFirstMother();
2066         
2067           //Rather uncivilized: Open brackets for each 'continue'
2068           if(! (lblMotherPosV0Dghter != lblMotherNegV0Dghter) ) { // same mother
2069           if(! (lblMotherPosV0Dghter < 0) ) { // mother != primary (!= -1)
2070           if(! (lblMotherNegV0Dghter < 0) ) {
2071                                         
2072                 // mothers = Lambda candidate ... a priori
2073         
2074           TParticle* mcMotherPosV0Dghter = lMCstack->Particle( lblMotherPosV0Dghter );
2075           TParticle* mcMotherNegV0Dghter = lMCstack->Particle( lblMotherNegV0Dghter );
2076                         
2077           // - Step 4.3 : level of Xi candidate
2078         
2079           Int_t lblGdMotherPosV0Dghter =   mcMotherPosV0Dghter->GetFirstMother() ;
2080           Int_t lblGdMotherNegV0Dghter =   mcMotherNegV0Dghter->GetFirstMother() ;
2081                                 
2082                 if(! (lblGdMotherPosV0Dghter != lblGdMotherNegV0Dghter) ) {
2083                 if(! (lblGdMotherPosV0Dghter < 0) ) { // primary lambda ...
2084                 if(! (lblGdMotherNegV0Dghter < 0) ) { // primary lambda ...
2085
2086                   // Gd mothers = Xi candidate ... a priori
2087         
2088           TParticle* mcGdMotherPosV0Dghter = lMCstack->Particle( lblGdMotherPosV0Dghter );
2089           TParticle* mcGdMotherNegV0Dghter = lMCstack->Particle( lblGdMotherNegV0Dghter );
2090                                         
2091           Int_t lblMotherBach = (Int_t) TMath::Abs( mcBach->GetFirstMother()  );
2092         
2093   //            if( lblMotherBach != lblGdMotherPosV0Dghter ) continue; //same mother for bach and V0 daughters
2094                   if(!(lblMotherBach != lblGdMotherPosV0Dghter)) { //same mother for bach and V0 daughters
2095         
2096           TParticle* mcMotherBach = lMCstack->Particle( lblMotherBach );
2097         
2098     lPID_BachMother = mcMotherBach->GetPdgCode();
2099           lPID_NegMother = mcGdMotherPosV0Dghter->GetPdgCode();
2100           lPID_PosMother = mcGdMotherNegV0Dghter->GetPdgCode();
2101    
2102           if(lPID_BachMother==lPID_NegMother && lPID_BachMother==lPID_PosMother){ 
2103                   lPDGCodeCascade = lPID_BachMother; 
2104       lXiTransvMomMC = mcMotherBach->Pt();
2105       if( lMCstack->IsPhysicalPrimary       (lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 1; //Is Primary!
2106       if( lMCstack->IsSecondaryFromWeakDecay(lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 2; //Weak Decay!
2107       if( lMCstack->IsSecondaryFromMaterial (lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 3; //From Material!
2108       if ( (mcMotherBach->Energy() + mcMotherBach->Pz()) / (mcMotherBach->Energy() - mcMotherBach->Pz() +1.e-13) !=0 ){
2109         lRapMC = 0.5*TMath::Log( (mcMotherBach->Energy() + mcMotherBach->Pz()) / (mcMotherBach->Energy() - mcMotherBach->Pz() +1.e-13) );
2110       }
2111           }
2112
2113   }}}}}}} //Ends all conditionals above...
2114
2115 //----------------------------------------
2116 // Regular MC ASSOCIATION ENDS HERE
2117 //----------------------------------------
2118
2119
2120   //------------------------------------------------
2121   // Set Variables for adding to tree
2122   //------------------------------------------------            
2123         
2124           fTreeCascVarCharge    = lChargeXi;
2125           fTreeCascVarPID = lPDGCodeCascade; 
2126           if(lInvMassXiMinus!=0)    fTreeCascVarMassAsXi = lInvMassXiMinus;
2127           if(lInvMassXiPlus!=0)     fTreeCascVarMassAsXi = lInvMassXiPlus;
2128           if(lInvMassOmegaMinus!=0) fTreeCascVarMassAsOmega = lInvMassOmegaMinus;
2129           if(lInvMassOmegaPlus!=0)  fTreeCascVarMassAsOmega = lInvMassOmegaPlus;
2130           fTreeCascVarPt = lXiTransvMom;
2131           fTreeCascVarPtMC = lXiTransvMomMC;
2132           fTreeCascVarRapXi = lRapXi ;
2133           fTreeCascVarRapMC = lRapMC ;
2134           fTreeCascVarRapOmega = lRapOmega ;
2135           fTreeCascVarDCACascDaughters = lDcaXiDaughters;
2136           fTreeCascVarDCABachToPrimVtx = lDcaBachToPrimVertexXi;
2137           fTreeCascVarDCAV0Daughters = lDcaV0DaughtersXi;
2138           fTreeCascVarDCAV0ToPrimVtx = lDcaV0ToPrimVertexXi;
2139           fTreeCascVarDCAPosToPrimVtx = lDcaPosToPrimVertexXi;
2140           fTreeCascVarDCANegToPrimVtx = lDcaNegToPrimVertexXi;
2141           fTreeCascVarCascCosPointingAngle = lXiCosineOfPointingAngle;
2142           fTreeCascVarCascRadius = lXiRadius;
2143           fTreeCascVarV0Mass = lInvMassLambdaAsCascDghter;
2144           fTreeCascVarV0CosPointingAngle = lV0CosineOfPointingAngleXi;
2145           fTreeCascVarV0CosPointingAngleSpecial = lV0CosineOfPointingAngleXiSpecial;
2146           fTreeCascVarV0Radius = lV0RadiusXi;
2147           fTreeCascVarLeastNbrClusters = leastnumberofclusters;
2148
2149           //Copy Multiplicity information 
2150           fTreeCascVarCentV0A = fCentrality_V0A; 
2151           fTreeCascVarCentV0C = fCentrality_V0C; 
2152           fTreeCascVarCentV0M = fCentrality_V0M; 
2153           fTreeCascVarCentV0AEq = fCentrality_V0AEq; 
2154           fTreeCascVarCentV0CEq = fCentrality_V0CEq; 
2155           fTreeCascVarCentV0MEq = fCentrality_V0MEq; 
2156           fTreeCascVarAmpV0A = fAmplitude_V0A; 
2157           fTreeCascVarAmpV0C = fAmplitude_V0C; 
2158           fTreeCascVarAmpV0AEq = fAmplitude_V0AEq; 
2159           fTreeCascVarAmpV0CEq = fAmplitude_V0CEq; 
2160           fTreeCascVarRefMultEta8 = fRefMultEta8;
2161           fTreeCascVarRefMultEta5 = fRefMultEta5;
2162           fTreeCascVarRunNumber = fRunNumber; 
2163
2164           fTreeCascVarDistOverTotMom = TMath::Sqrt(
2165                                                 TMath::Power( lPosXi[0] - lBestPrimaryVtxPos[0] , 2) +
2166                                                 TMath::Power( lPosXi[1] - lBestPrimaryVtxPos[1] , 2) +
2167                                                 TMath::Power( lPosXi[2] - lBestPrimaryVtxPos[2] , 2)
2168                                         );
2169           fTreeCascVarDistOverTotMom /= (lXiTotMom+1e-13);
2170
2171 //All vars not specified here: specified elsewhere!
2172
2173 //------------------------------------------------
2174 // Fill Tree! 
2175 //------------------------------------------------
2176
2177 // The conditional is meant to decrease excessive
2178 // memory usage! Be careful when loosening the 
2179 // cut!
2180
2181   //Xi    Mass window: 150MeV wide
2182   //Omega mass window: 150MeV wide
2183
2184   if( fkSaveCascadeTree && ( (fTreeCascVarMassAsXi<1.32+0.075&&fTreeCascVarMassAsXi>1.32-0.075) ||
2185       (fTreeCascVarMassAsOmega<1.68+0.075&&fTreeCascVarMassAsOmega>1.68-0.075) ) ){
2186       fTreeCascade->Fill();
2187   }
2188
2189 //------------------------------------------------
2190 // Fill tree over.
2191 //------------------------------------------------
2192
2193         }// end of the Cascade loop (ESD or AOD)
2194
2195   // Post output data.
2196   PostData(1, fListHist); 
2197   PostData(2, fTreeEvent);
2198   PostData(3, fTreeV0);
2199   PostData(4, fTreeCascade);
2200 }
2201
2202 //________________________________________________________________________
2203 void AliAnalysisTaskStrangenessVsMultiplicityMC::Terminate(Option_t *)
2204 {
2205    // Draw result to the screen
2206    // Called once at the end of the query
2207
2208    TList *cRetrievedList = 0x0;
2209    cRetrievedList = (TList*)GetOutputData(1);
2210    if(!cRetrievedList){
2211       Printf("ERROR - AliAnalysisTaskStrangenessVsMultiplicityMC : ouput data container list not available\n");
2212       return;
2213    }    
2214         
2215    fHistEventCounter = dynamic_cast<TH1D*> (  cRetrievedList->FindObject("fHistEventCounter")  );
2216    if (!fHistEventCounter) {
2217       Printf("ERROR - AliAnalysisTaskStrangenessVsMultiplicityMC : fHistEventCounter not available");
2218       return;
2219    }
2220   
2221    TCanvas *canCheck = new TCanvas("AliAnalysisTaskStrangenessVsMultiplicityMC","V0 Multiplicity",10,10,510,510);
2222    canCheck->cd(1)->SetLogy();
2223
2224    fHistEventCounter->SetMarkerStyle(22);
2225    fHistEventCounter->DrawCopy("E");
2226 }
2227
2228 //----------------------------------------------------------------------------
2229
2230 Double_t AliAnalysisTaskStrangenessVsMultiplicityMC::MyRapidity(Double_t rE, Double_t rPz) const
2231 {
2232    // Local calculation for rapidity
2233    Double_t ReturnValue = -100;
2234    if( (rE-rPz+1.e-13) != 0 && (rE+rPz) != 0 ){ 
2235       ReturnValue =  0.5*TMath::Log((rE+rPz)/(rE-rPz+1.e-13));
2236    }
2237    return ReturnValue;
2238