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