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