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