]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/STRANGENESS/Cascades/AliAnalysisTaskStrangenessVsMultiplicityMC.cxx
Minor Bug Fix
[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
81 #include "AliCFContainer.h"
82 #include "AliMultiplicity.h"
83 #include "AliAODMCParticle.h"
84 #include "AliESDcascade.h"
85 #include "AliAODcascade.h"
86 #include "AliESDUtils.h"
87 #include "AliGenEventHeader.h"
88 #include "AliAnalysisTaskSE.h"
89 #include "AliAnalysisUtils.h"
90 #include "AliAnalysisTaskStrangenessVsMultiplicityMC.h"
91
92 using std::cout;
93 using std::endl;
94
95 ClassImp(AliAnalysisTaskStrangenessVsMultiplicityMC)
96
97 AliAnalysisTaskStrangenessVsMultiplicityMC::AliAnalysisTaskStrangenessVsMultiplicityMC()
98   : AliAnalysisTaskSE(), fListHist(0), fTreeEvent(0), fTreeV0(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), 
99   fkSaveV0Tree      ( kFALSE ),
100   fkSaveCascadeTree ( kTRUE  ),
101   fkRunVertexers    ( kTRUE  ), 
102   //---> Variables for fTreeEvent
103   fAmplitude_V0A   (0),   
104   fAmplitude_V0C   (0),   
105   fAmplitude_V0AEq (0),   
106   fAmplitude_V0CEq (0),  
107   fCentrality_V0A(0), 
108   fCentrality_V0C(0), 
109   fCentrality_V0M(0), 
110   fCentrality_V0AEq(0), 
111   fCentrality_V0CEq(0), 
112   fCentrality_V0MEq(0), 
113   fRefMultEta5(0),
114   fRefMultEta8(0),
115   fTrueMultEta5(0),
116   fTrueMultEta8(0),
117   fTrueMultVZEROA(0),
118   fTrueMultVZEROC(0),
119   fRunNumber(0),
120   //---> Variables for fTreeCascade
121   fTreeCascVarCharge(0), 
122         fTreeCascVarMassAsXi(0),
123         fTreeCascVarMassAsOmega(0),
124         fTreeCascVarPt(0),
125         fTreeCascVarPtMC(0),
126         fTreeCascVarRapXi(0),
127         fTreeCascVarRapOmega(0),
128         fTreeCascVarRapMC(0),
129         fTreeCascVarNegEta(0),
130         fTreeCascVarPosEta(0),
131         fTreeCascVarBachEta(0),
132         fTreeCascVarDCACascDaughters(0),
133         fTreeCascVarDCABachToPrimVtx(0),
134         fTreeCascVarDCAV0Daughters(0),
135         fTreeCascVarDCAV0ToPrimVtx(0),
136         fTreeCascVarDCAPosToPrimVtx(0),
137         fTreeCascVarDCANegToPrimVtx(0),
138         fTreeCascVarCascCosPointingAngle(0),
139         fTreeCascVarCascRadius(0),
140         fTreeCascVarV0Mass(0),
141         fTreeCascVarV0CosPointingAngle(0),
142         fTreeCascVarV0CosPointingAngleSpecial(0),
143         fTreeCascVarV0Radius(0),
144   fTreeCascVarLeastNbrClusters(0),
145         fTreeCascVarDistOverTotMom(0),
146         fTreeCascVarNegNSigmaPion(0),
147         fTreeCascVarNegNSigmaProton(0),
148         fTreeCascVarPosNSigmaPion(0),
149         fTreeCascVarPosNSigmaProton(0),
150         fTreeCascVarBachNSigmaPion(0),
151         fTreeCascVarBachNSigmaKaon(0),
152         fTreeCascVarCentV0A(0),
153         fTreeCascVarCentV0C(0),
154         fTreeCascVarCentV0M(0),
155         fTreeCascVarCentV0AEq(0),
156         fTreeCascVarCentV0CEq(0),
157         fTreeCascVarCentV0MEq(0),
158         fTreeCascVarAmpV0A(0),
159         fTreeCascVarAmpV0C(0),
160         fTreeCascVarAmpV0AEq(0),
161         fTreeCascVarAmpV0CEq(0),
162   fTreeCascVarRefMultEta8(0),
163   fTreeCascVarRefMultEta5(0),
164   fTreeCascVarTrueMultEta5(0),
165   fTreeCascVarTrueMultEta8(0),
166   fTreeCascVarTrueMultVZEROA(0),
167   fTreeCascVarTrueMultVZEROC(0),
168   fTreeCascVarIsPhysicalPrimary(0), 
169   fTreeCascVarPID(0), 
170   //---> Histograms
171   fHistEventCounter(0), 
172   //---> MC Generated Histo (analysis level) 
173         fHistPt_GenXiMinus(0),
174         fHistPt_GenXiPlus(0),
175         fHistPt_GenOmegaMinus(0),
176         fHistPt_GenOmegaPlus(0),
177
178   //VsRefMult
179         fHistPtVsRefMultEta5_GenXiMinus(0),
180         fHistPtVsRefMultEta5_GenXiPlus(0),
181         fHistPtVsRefMultEta5_GenOmegaMinus(0),
182         fHistPtVsRefMultEta5_GenOmegaPlus(0),
183         fHistPtVsRefMultEta8_GenXiMinus(0),
184         fHistPtVsRefMultEta8_GenXiPlus(0),
185         fHistPtVsRefMultEta8_GenOmegaMinus(0),
186         fHistPtVsRefMultEta8_GenOmegaPlus(0),
187
188   //VsCentralities
189         fHistPtVsCentV0A_GenXiMinus(0),
190         fHistPtVsCentV0A_GenXiPlus(0),
191         fHistPtVsCentV0A_GenOmegaMinus(0),
192         fHistPtVsCentV0A_GenOmegaPlus(0),
193         fHistPtVsCentV0C_GenXiMinus(0),
194         fHistPtVsCentV0C_GenXiPlus(0),
195         fHistPtVsCentV0C_GenOmegaMinus(0),
196         fHistPtVsCentV0C_GenOmegaPlus(0),
197         fHistPtVsCentV0M_GenXiMinus(0),
198         fHistPtVsCentV0M_GenXiPlus(0),
199         fHistPtVsCentV0M_GenOmegaMinus(0),
200         fHistPtVsCentV0M_GenOmegaPlus(0),
201
202   //Equalized
203         fHistPtVsCentV0AEq_GenXiMinus(0),
204         fHistPtVsCentV0AEq_GenXiPlus(0),
205         fHistPtVsCentV0AEq_GenOmegaMinus(0),
206         fHistPtVsCentV0AEq_GenOmegaPlus(0),
207         fHistPtVsCentV0CEq_GenXiMinus(0),
208         fHistPtVsCentV0CEq_GenXiPlus(0),
209         fHistPtVsCentV0CEq_GenOmegaMinus(0),
210         fHistPtVsCentV0CEq_GenOmegaPlus(0),
211         fHistPtVsCentV0MEq_GenXiMinus(0),
212         fHistPtVsCentV0MEq_GenXiPlus(0),
213         fHistPtVsCentV0MEq_GenOmegaMinus(0),
214         fHistPtVsCentV0MEq_GenOmegaPlus(0),
215
216   //VsAmp
217         fHistPtVsAmpV0A_GenXiMinus(0),
218         fHistPtVsAmpV0A_GenXiPlus(0),
219         fHistPtVsAmpV0A_GenOmegaMinus(0),
220         fHistPtVsAmpV0A_GenOmegaPlus(0),
221         fHistPtVsAmpV0C_GenXiMinus(0),
222         fHistPtVsAmpV0C_GenXiPlus(0),
223         fHistPtVsAmpV0C_GenOmegaMinus(0),
224         fHistPtVsAmpV0C_GenOmegaPlus(0),
225         fHistPtVsAmpV0M_GenXiMinus(0),
226         fHistPtVsAmpV0M_GenXiPlus(0),
227         fHistPtVsAmpV0M_GenOmegaMinus(0),
228         fHistPtVsAmpV0M_GenOmegaPlus(0),
229   //Equalized Amps
230         fHistPtVsAmpV0AEq_GenXiMinus(0),
231         fHistPtVsAmpV0AEq_GenXiPlus(0),
232         fHistPtVsAmpV0AEq_GenOmegaMinus(0),
233         fHistPtVsAmpV0AEq_GenOmegaPlus(0),
234         fHistPtVsAmpV0CEq_GenXiMinus(0),
235         fHistPtVsAmpV0CEq_GenXiPlus(0),
236         fHistPtVsAmpV0CEq_GenOmegaMinus(0),
237         fHistPtVsAmpV0CEq_GenOmegaPlus(0),
238         fHistPtVsAmpV0MEq_GenXiMinus(0),
239         fHistPtVsAmpV0MEq_GenXiPlus(0),
240         fHistPtVsAmpV0MEq_GenOmegaMinus(0),
241         fHistPtVsAmpV0MEq_GenOmegaPlus(0)  
242
243 //------------------------------------------------
244 // Tree Variables 
245 {
246
247 }
248
249 AliAnalysisTaskStrangenessVsMultiplicityMC::AliAnalysisTaskStrangenessVsMultiplicityMC(const char *name) 
250   : AliAnalysisTaskSE(name), fListHist(0), fTreeEvent(0), fTreeV0(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), 
251   fkSaveV0Tree      ( kFALSE ),
252   fkSaveCascadeTree ( kTRUE  ), 
253   fkRunVertexers    ( kTRUE  ),
254   //---> Variables for fTreeEvent
255   fAmplitude_V0A (0),   
256   fAmplitude_V0C (0), 
257   fAmplitude_V0AEq (0),   
258   fAmplitude_V0CEq (0), 
259   fCentrality_V0A(0), 
260   fCentrality_V0C(0), 
261   fCentrality_V0M(0), 
262   fCentrality_V0AEq(0), 
263   fCentrality_V0CEq(0), 
264   fCentrality_V0MEq(0), 
265   fRefMultEta5(0),
266   fRefMultEta8(0),
267   fTrueMultEta5(0),
268   fTrueMultEta8(0),
269   fTrueMultVZEROA(0),
270   fTrueMultVZEROC(0),
271   fRunNumber(0),
272   //---> Variables for fTreeCascade
273   fTreeCascVarCharge(0), 
274         fTreeCascVarMassAsXi(0),
275         fTreeCascVarMassAsOmega(0),
276         fTreeCascVarPt(0),
277         fTreeCascVarPtMC(0),
278         fTreeCascVarRapXi(0),
279         fTreeCascVarRapOmega(0),
280         fTreeCascVarRapMC(0),
281         fTreeCascVarNegEta(0),
282         fTreeCascVarPosEta(0),
283         fTreeCascVarBachEta(0),
284         fTreeCascVarDCACascDaughters(0),
285         fTreeCascVarDCABachToPrimVtx(0),
286         fTreeCascVarDCAV0Daughters(0),
287         fTreeCascVarDCAV0ToPrimVtx(0),
288         fTreeCascVarDCAPosToPrimVtx(0),
289         fTreeCascVarDCANegToPrimVtx(0),
290         fTreeCascVarCascCosPointingAngle(0),
291         fTreeCascVarCascRadius(0),
292         fTreeCascVarV0Mass(0),
293         fTreeCascVarV0CosPointingAngle(0),
294         fTreeCascVarV0CosPointingAngleSpecial(0),
295         fTreeCascVarV0Radius(0),
296   fTreeCascVarLeastNbrClusters(0),
297         fTreeCascVarDistOverTotMom(0),
298         fTreeCascVarNegNSigmaPion(0),
299         fTreeCascVarNegNSigmaProton(0),
300         fTreeCascVarPosNSigmaPion(0),
301         fTreeCascVarPosNSigmaProton(0),
302         fTreeCascVarBachNSigmaPion(0),
303         fTreeCascVarBachNSigmaKaon(0),
304         fTreeCascVarCentV0A(0),
305         fTreeCascVarCentV0C(0),
306         fTreeCascVarCentV0M(0),
307         fTreeCascVarCentV0AEq(0),
308         fTreeCascVarCentV0CEq(0),
309         fTreeCascVarCentV0MEq(0),
310         fTreeCascVarAmpV0A(0),
311         fTreeCascVarAmpV0C(0),
312         fTreeCascVarAmpV0AEq(0),
313         fTreeCascVarAmpV0CEq(0),
314   fTreeCascVarRefMultEta8(0),
315   fTreeCascVarRefMultEta5(0),
316   fTreeCascVarTrueMultEta5(0),
317   fTreeCascVarTrueMultEta8(0),
318   fTreeCascVarTrueMultVZEROA(0),
319   fTreeCascVarTrueMultVZEROC(0),
320   fTreeCascVarIsPhysicalPrimary(0), 
321   fTreeCascVarPID(0), 
322   //---> Histograms
323   fHistEventCounter(0), 
324   //---> MC Generated Histo (analysis level) 
325         fHistPt_GenXiMinus(0),
326         fHistPt_GenXiPlus(0),
327         fHistPt_GenOmegaMinus(0),
328         fHistPt_GenOmegaPlus(0),
329
330   //VsRefMult
331         fHistPtVsRefMultEta5_GenXiMinus(0),
332         fHistPtVsRefMultEta5_GenXiPlus(0),
333         fHistPtVsRefMultEta5_GenOmegaMinus(0),
334         fHistPtVsRefMultEta5_GenOmegaPlus(0),
335         fHistPtVsRefMultEta8_GenXiMinus(0),
336         fHistPtVsRefMultEta8_GenXiPlus(0),
337         fHistPtVsRefMultEta8_GenOmegaMinus(0),
338         fHistPtVsRefMultEta8_GenOmegaPlus(0),
339
340   //VsCentralities
341         fHistPtVsCentV0A_GenXiMinus(0),
342         fHistPtVsCentV0A_GenXiPlus(0),
343         fHistPtVsCentV0A_GenOmegaMinus(0),
344         fHistPtVsCentV0A_GenOmegaPlus(0),
345         fHistPtVsCentV0C_GenXiMinus(0),
346         fHistPtVsCentV0C_GenXiPlus(0),
347         fHistPtVsCentV0C_GenOmegaMinus(0),
348         fHistPtVsCentV0C_GenOmegaPlus(0),
349         fHistPtVsCentV0M_GenXiMinus(0),
350         fHistPtVsCentV0M_GenXiPlus(0),
351         fHistPtVsCentV0M_GenOmegaMinus(0),
352         fHistPtVsCentV0M_GenOmegaPlus(0),
353
354   //Equalized
355         fHistPtVsCentV0AEq_GenXiMinus(0),
356         fHistPtVsCentV0AEq_GenXiPlus(0),
357         fHistPtVsCentV0AEq_GenOmegaMinus(0),
358         fHistPtVsCentV0AEq_GenOmegaPlus(0),
359         fHistPtVsCentV0CEq_GenXiMinus(0),
360         fHistPtVsCentV0CEq_GenXiPlus(0),
361         fHistPtVsCentV0CEq_GenOmegaMinus(0),
362         fHistPtVsCentV0CEq_GenOmegaPlus(0),
363         fHistPtVsCentV0MEq_GenXiMinus(0),
364         fHistPtVsCentV0MEq_GenXiPlus(0),
365         fHistPtVsCentV0MEq_GenOmegaMinus(0),
366         fHistPtVsCentV0MEq_GenOmegaPlus(0),
367
368   //VsAmp
369         fHistPtVsAmpV0A_GenXiMinus(0),
370         fHistPtVsAmpV0A_GenXiPlus(0),
371         fHistPtVsAmpV0A_GenOmegaMinus(0),
372         fHistPtVsAmpV0A_GenOmegaPlus(0),
373         fHistPtVsAmpV0C_GenXiMinus(0),
374         fHistPtVsAmpV0C_GenXiPlus(0),
375         fHistPtVsAmpV0C_GenOmegaMinus(0),
376         fHistPtVsAmpV0C_GenOmegaPlus(0),
377         fHistPtVsAmpV0M_GenXiMinus(0),
378         fHistPtVsAmpV0M_GenXiPlus(0),
379         fHistPtVsAmpV0M_GenOmegaMinus(0),
380         fHistPtVsAmpV0M_GenOmegaPlus(0),
381   //Equalized Amps
382         fHistPtVsAmpV0AEq_GenXiMinus(0),
383         fHistPtVsAmpV0AEq_GenXiPlus(0),
384         fHistPtVsAmpV0AEq_GenOmegaMinus(0),
385         fHistPtVsAmpV0AEq_GenOmegaPlus(0),
386         fHistPtVsAmpV0CEq_GenXiMinus(0),
387         fHistPtVsAmpV0CEq_GenXiPlus(0),
388         fHistPtVsAmpV0CEq_GenOmegaMinus(0),
389         fHistPtVsAmpV0CEq_GenOmegaPlus(0),
390         fHistPtVsAmpV0MEq_GenXiMinus(0),
391         fHistPtVsAmpV0MEq_GenXiPlus(0),
392         fHistPtVsAmpV0MEq_GenOmegaMinus(0),
393         fHistPtVsAmpV0MEq_GenOmegaPlus(0)
394 {
395
396   //Re-vertex: Will only apply for cascade candidates
397
398   fV0VertexerSels[0] =  33.  ;  // max allowed chi2
399   fV0VertexerSels[1] =   0.02;  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
400   fV0VertexerSels[2] =   0.02;  // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
401   fV0VertexerSels[4] =   0.95;  // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
402   fV0VertexerSels[5] =   1.0 ;  // min radius of the fiducial volume                 (LHC09a4 : 0.2)
403   fV0VertexerSels[6] = 200.  ;  // max radius of the fiducial volume                 (LHC09a4 : 100.0)
404         
405   fCascadeVertexerSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
406   fCascadeVertexerSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
407   fCascadeVertexerSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
408   fCascadeVertexerSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
409   fCascadeVertexerSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
410   fCascadeVertexerSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
411   fCascadeVertexerSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
412   fCascadeVertexerSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
413         
414
415   DefineOutput(1, TList::Class()); // Event Counter Histo
416   DefineOutput(2, TTree::Class()); // Event Tree
417   DefineOutput(3, TTree::Class()); // V0 Tree
418   DefineOutput(4, TTree::Class()); // Cascade Tree
419 }
420
421
422 AliAnalysisTaskStrangenessVsMultiplicityMC::~AliAnalysisTaskStrangenessVsMultiplicityMC()
423 {
424 //------------------------------------------------
425 // DESTRUCTOR
426 //------------------------------------------------
427
428    if (fListHist){
429       delete fListHist;
430       fListHist = 0x0;
431    }
432    if (fTreeEvent){
433       delete fTreeEvent;
434       fTreeEvent = 0x0;
435    }
436    if (fTreeV0){
437       delete fTreeV0;
438       fTreeV0 = 0x0;
439    }
440    if (fTreeCascade){
441       delete fTreeCascade;
442       fTreeCascade = 0x0;
443    }
444 }
445
446 //________________________________________________________________________
447 void AliAnalysisTaskStrangenessVsMultiplicityMC::UserCreateOutputObjects()
448 {
449
450    OpenFile(2); 
451    // Called once
452
453 //------------------------------------------------
454
455    fTreeEvent = new TTree("fTreeEvent","Event");
456
457 //------------------------------------------------
458 // fTree Branch definitions - Event by Event info
459 //------------------------------------------------
460
461 //-----------BASIC-INFO---------------------------
462
463   //--- VZERO Data (Integrated)
464   fTreeEvent->Branch("fAmplitude_V0A",&fAmplitude_V0A,"fAmplitude_V0A/F");
465   fTreeEvent->Branch("fAmplitude_V0C",&fAmplitude_V0C,"fAmplitude_V0C/F");
466   fTreeEvent->Branch("fAmplitude_V0AEq",&fAmplitude_V0AEq,"fAmplitude_V0AEq/F");
467   fTreeEvent->Branch("fAmplitude_V0CEq",&fAmplitude_V0CEq,"fAmplitude_V0CEq/F");
468
469   //Info from AliCentrality (not necessarily 'centrality' per se) 
470   fTreeEvent->Branch("fCentrality_V0A",&fCentrality_V0A,"fCentrality_V0A/F");
471   fTreeEvent->Branch("fCentrality_V0C",&fCentrality_V0C,"fCentrality_V0C/F");
472   fTreeEvent->Branch("fCentrality_V0M",&fCentrality_V0A,"fCentrality_V0M/F");
473   fTreeEvent->Branch("fCentrality_V0AEq",&fCentrality_V0AEq,"fCentrality_V0AEq/F");
474   fTreeEvent->Branch("fCentrality_V0CEq",&fCentrality_V0CEq,"fCentrality_V0CEq/F");
475   fTreeEvent->Branch("fCentrality_V0MEq",&fCentrality_V0AEq,"fCentrality_V0MEq/F");
476   
477   //Official GetReferenceMultiplicity
478   fTreeEvent->Branch("fRefMultEta5",&fRefMultEta5,"fRefMultEta5/I");
479   fTreeEvent->Branch("fRefMultEta8",&fRefMultEta8,"fRefMultEta8/I");
480
481   fTreeEvent->Branch("fTrueMultEta5",&fTrueMultEta5,"fTrueMultEta5/I");
482   fTreeEvent->Branch("fTrueMultEta8",&fTrueMultEta8,"fTrueMultEta8/I");
483   fTreeEvent->Branch("fTrueMultVZEROA",&fTrueMultVZEROA,"fTrueMultVZEROA/I");
484   fTreeEvent->Branch("fTrueMultVZEROC",&fTrueMultVZEROC,"fTrueMultVZEROC/I");
485
486   //Run Number
487   fTreeEvent->Branch("fRunNumber", &fRunNumber, "fRunNumber/I");
488
489   //Create Basic V0 Output Tree
490   fTreeV0 = new TTree( "fTreeV0", "V0 Candidates");
491
492   //Create Cascade output tree
493   fTreeCascade = new TTree("fTreeCascade","CascadeCandidates");
494
495 //------------------------------------------------
496 // fTreeCascade Branch definitions - Cascade Tree
497 //------------------------------------------------
498
499 //-----------BASIC-INFO---------------------------
500         fTreeCascade->Branch("fTreeCascVarCharge",&fTreeCascVarCharge,"fTreeCascVarCharge/I");  
501   fTreeCascade->Branch("fTreeCascVarMassAsXi",&fTreeCascVarMassAsXi,"fTreeCascVarMassAsXi/F");
502   fTreeCascade->Branch("fTreeCascVarMassAsOmega",&fTreeCascVarMassAsOmega,"fTreeCascVarMassAsOmega/F");
503   fTreeCascade->Branch("fTreeCascVarPt",&fTreeCascVarPt,"fTreeCascVarPt/F");
504   fTreeCascade->Branch("fTreeCascVarPtMC",&fTreeCascVarPtMC,"fTreeCascVarPtMC/F");
505   fTreeCascade->Branch("fTreeCascVarRapXi",&fTreeCascVarRapXi,"fTreeCascVarRapXi/F");
506   fTreeCascade->Branch("fTreeCascVarRapOmega",&fTreeCascVarRapOmega,"fTreeCascVarRapOmega/F");
507   fTreeCascade->Branch("fTreeCascVarRapMC",&fTreeCascVarRapMC,"fTreeCascVarRapMC/F");
508   fTreeCascade->Branch("fTreeCascVarNegEta",&fTreeCascVarNegEta,"fTreeCascVarNegEta/F");
509   fTreeCascade->Branch("fTreeCascVarPosEta",&fTreeCascVarPosEta,"fTreeCascVarPosEta/F");
510   fTreeCascade->Branch("fTreeCascVarBachEta",&fTreeCascVarBachEta,"fTreeCascVarBachEta/F");
511 //-----------INFO-FOR-CUTS------------------------
512   fTreeCascade->Branch("fTreeCascVarDCACascDaughters",&fTreeCascVarDCACascDaughters,"fTreeCascVarDCACascDaughters/F");
513   fTreeCascade->Branch("fTreeCascVarDCABachToPrimVtx",&fTreeCascVarDCABachToPrimVtx,"fTreeCascVarDCABachToPrimVtx/F");
514   fTreeCascade->Branch("fTreeCascVarDCAV0Daughters",&fTreeCascVarDCAV0Daughters,"fTreeCascVarDCAV0Daughters/F");
515   fTreeCascade->Branch("fTreeCascVarDCAV0ToPrimVtx",&fTreeCascVarDCAV0ToPrimVtx,"fTreeCascVarDCAV0ToPrimVtx/F");
516   fTreeCascade->Branch("fTreeCascVarDCAPosToPrimVtx",&fTreeCascVarDCAPosToPrimVtx,"fTreeCascVarDCAPosToPrimVtx/F");
517   fTreeCascade->Branch("fTreeCascVarDCANegToPrimVtx",&fTreeCascVarDCANegToPrimVtx,"fTreeCascVarDCANegToPrimVtx/F");
518   fTreeCascade->Branch("fTreeCascVarCascCosPointingAngle",&fTreeCascVarCascCosPointingAngle,"fTreeCascVarCascCosPointingAngle/F");
519   fTreeCascade->Branch("fTreeCascVarCascRadius",&fTreeCascVarCascRadius,"fTreeCascVarCascRadius/F");
520   fTreeCascade->Branch("fTreeCascVarV0Mass",&fTreeCascVarV0Mass,"fTreeCascVarV0Mass/F");
521   fTreeCascade->Branch("fTreeCascVarV0CosPointingAngle",&fTreeCascVarV0CosPointingAngle,"fTreeCascVarV0CosPointingAngle/F");
522   fTreeCascade->Branch("fTreeCascVarV0CosPointingAngleSpecial",&fTreeCascVarV0CosPointingAngleSpecial,"fTreeCascVarV0CosPointingAngleSpecial/F");
523   fTreeCascade->Branch("fTreeCascVarV0Radius",&fTreeCascVarV0Radius,"fTreeCascVarV0Radius/F");
524   fTreeCascade->Branch("fTreeCascVarLeastNbrClusters",&fTreeCascVarLeastNbrClusters,"fTreeCascVarLeastNbrClusters/I");
525 //-----------MULTIPLICITY-INFO--------------------
526   fTreeCascade->Branch("fTreeCascVarCentV0A",&fTreeCascVarCentV0A,"fTreeCascVarCentV0A/F");
527   fTreeCascade->Branch("fTreeCascVarCentV0C",&fTreeCascVarCentV0C,"fTreeCascVarCentV0C/F");
528   fTreeCascade->Branch("fTreeCascVarCentV0M",&fTreeCascVarCentV0M,"fTreeCascVarCentV0M/F");
529   fTreeCascade->Branch("fTreeCascVarCentV0AEq",&fTreeCascVarCentV0AEq,"fTreeCascVarCentV0AEq/F");
530   fTreeCascade->Branch("fTreeCascVarCentV0CEq",&fTreeCascVarCentV0CEq,"fTreeCascVarCentV0CEq/F");
531   fTreeCascade->Branch("fTreeCascVarCentV0MEq",&fTreeCascVarCentV0MEq,"fTreeCascVarCentV0MEq/F");
532   fTreeCascade->Branch("fTreeCascVarAmpV0A",&fTreeCascVarAmpV0A,"fTreeCascVarAmpV0A/F");
533   fTreeCascade->Branch("fTreeCascVarAmpV0C",&fTreeCascVarAmpV0C,"fTreeCascVarAmpV0C/F");
534   fTreeCascade->Branch("fTreeCascVarAmpV0AEq",&fTreeCascVarAmpV0AEq,"fTreeCascVarAmpV0AEq/F");
535   fTreeCascade->Branch("fTreeCascVarAmpV0CEq",&fTreeCascVarAmpV0CEq,"fTreeCascVarAmpV0CEq/F");
536   fTreeCascade->Branch("fTreeCascVarRefMultEta8",&fTreeCascVarRefMultEta8,"fTreeCascVarRefMultEta8/I");
537   fTreeCascade->Branch("fTreeCascVarRefMultEta5",&fTreeCascVarRefMultEta5,"fTreeCascVarRefMultEta5/I");
538   fTreeCascade->Branch("fTreeCascVarTrueMultEta5",&fTreeCascVarTrueMultEta5,"fTreeCascVarTrueMultEta5/I");
539   fTreeCascade->Branch("fTreeCascVarTrueMultEta8",&fTreeCascVarTrueMultEta8,"fTreeCascVarTrueMultEta8/I");
540   fTreeCascade->Branch("fTreeCascVarTrueMultVZEROA",&fTreeCascVarTrueMultVZEROA,"fTreeCascVarTrueMultVZEROA/I");
541   fTreeCascade->Branch("fTreeCascVarTrueMultVZEROC",&fTreeCascVarTrueMultVZEROC,"fTreeCascVarTrueMultVZEROC/I");
542   fTreeCascade->Branch("fTreeCascVarIsPhysicalPrimary",&fTreeCascVarIsPhysicalPrimary,"fTreeCascVarIsPhysicalPrimary/I");
543   fTreeCascade->Branch("fTreeCascVarPID",&fTreeCascVarPID,"fTreeCascVarPID/I");
544 //-----------DECAY-LENGTH-INFO--------------------
545   fTreeCascade->Branch("fTreeCascVarDistOverTotMom",&fTreeCascVarDistOverTotMom,"fTreeCascVarDistOverTotMom/F");
546 //------------------------------------------------
547   fTreeCascade->Branch("fTreeCascVarNegNSigmaPion",&fTreeCascVarNegNSigmaPion,"fTreeCascVarNegNSigmaPion/F");
548   fTreeCascade->Branch("fTreeCascVarNegNSigmaProton",&fTreeCascVarNegNSigmaProton,"fTreeCascVarNegNSigmaProton/F");
549   fTreeCascade->Branch("fTreeCascVarPosNSigmaPion",&fTreeCascVarPosNSigmaPion,"fTreeCascVarPosNSigmaPion/F");
550   fTreeCascade->Branch("fTreeCascVarPosNSigmaProton",&fTreeCascVarPosNSigmaProton,"fTreeCascVarPosNSigmaProton/F");
551   fTreeCascade->Branch("fTreeCascVarBachNSigmaPion",&fTreeCascVarBachNSigmaPion,"fTreeCascVarBachNSigmaPion/F");
552   fTreeCascade->Branch("fTreeCascVarBachNSigmaKaon",&fTreeCascVarBachNSigmaKaon,"fTreeCascVarBachNSigmaKaon/F");
553
554 //------------------------------------------------
555 // Particle Identification Setup
556 //------------------------------------------------
557   
558    AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
559    AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
560    fPIDResponse = inputHandler->GetPIDResponse();
561
562   // Multiplicity
563   if(! fESDtrackCuts ){
564     fESDtrackCuts = new AliESDtrackCuts();
565   }
566
567 //------------------------------------------------
568 // V0 Multiplicity Histograms
569 //------------------------------------------------
570
571    // Create histograms
572    OpenFile(1);
573    fListHist = new TList();
574    fListHist->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
575
576    if(! fHistEventCounter ) {
577     //Histogram Output: Event-by-Event
578     fHistEventCounter = new TH1D( "fHistEventCounter", ";Evt. Sel. Step;Count",5,0,5); 
579     fHistEventCounter->GetXaxis()->SetBinLabel(1, "Processed");
580     fHistEventCounter->GetXaxis()->SetBinLabel(2, "Phys-Sel");  
581     fHistEventCounter->GetXaxis()->SetBinLabel(3, "Has Vtx");  
582     fHistEventCounter->GetXaxis()->SetBinLabel(4, "Vtx |z|<10cm");  
583     fHistEventCounter->GetXaxis()->SetBinLabel(5, "Isn't Pileup");
584     fListHist->Add(fHistEventCounter); 
585    }
586
587   //Histograms for Efficiency corrections... a bunch of them 
588   //1D Histograms - Fine if efficiency doesn't change vs mult (expected) 
589   //---> Always filled for |y|<0.5 
590   if(! fHistPt_GenXiMinus ) {
591     fHistPt_GenXiMinus    = new TH1D( "fHistPt_GenXiMinus",    "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenXiMinus);    }
592   if(! fHistPt_GenXiPlus ) {
593      fHistPt_GenXiPlus     = new TH1D( "fHistPt_GenXiPlus",    "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenXiPlus);     }
594   if(! fHistPt_GenOmegaMinus ) {
595     fHistPt_GenOmegaMinus = new TH1D( "fHistPt_GenOmegaMinus", "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenOmegaMinus); }
596   if(! fHistPt_GenOmegaPlus ) {
597     fHistPt_GenOmegaPlus  = new TH1D( "fHistPt_GenOmegaPlus",  "Generated;p_{T} (GeV/c)",200,0,20);   fListHist->Add(fHistPt_GenOmegaPlus);  }
598   //2D Histos for vs Mult calculation 
599   if(! fHistPtVsRefMultEta5_GenXiMinus ) {
600     fHistPtVsRefMultEta5_GenXiMinus    = new TH2D( "fHistPtVsRefMultEta5_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenXiMinus);    }
601   if(! fHistPtVsRefMultEta5_GenXiPlus ) {
602     fHistPtVsRefMultEta5_GenXiPlus     = new TH2D( "fHistPtVsRefMultEta5_GenXiPlus",        "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenXiPlus);    }
603   if(! fHistPtVsRefMultEta5_GenOmegaMinus ) {
604     fHistPtVsRefMultEta5_GenOmegaMinus    = new TH2D( "fHistPtVsRefMultEta5_GenOmegaMinus", "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenOmegaMinus);    }
605   if(! fHistPtVsRefMultEta5_GenOmegaPlus ) {
606     fHistPtVsRefMultEta5_GenOmegaPlus     = new TH2D( "fHistPtVsRefMultEta5_GenOmegaPlus",  "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta5_GenOmegaPlus);    }
607   if(! fHistPtVsRefMultEta8_GenXiMinus ) {
608     fHistPtVsRefMultEta8_GenXiMinus    = new TH2D( "fHistPtVsRefMultEta8_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenXiMinus);    }
609   if(! fHistPtVsRefMultEta8_GenXiPlus ) {
610     fHistPtVsRefMultEta8_GenXiPlus     = new TH2D( "fHistPtVsRefMultEta8_GenXiPlus",        "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenXiPlus);    }
611   if(! fHistPtVsRefMultEta8_GenOmegaMinus ) {
612     fHistPtVsRefMultEta8_GenOmegaMinus    = new TH2D( "fHistPtVsRefMultEta8_GenOmegaMinus", "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenOmegaMinus);    }
613   if(! fHistPtVsRefMultEta8_GenOmegaPlus ) {
614     fHistPtVsRefMultEta8_GenOmegaPlus     = new TH2D( "fHistPtVsRefMultEta8_GenOmegaPlus",  "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   fListHist->Add(fHistPtVsRefMultEta8_GenOmegaPlus);    }
615
616   //Centralities: V0A, V0C, V0M, +Eq
617   if(! fHistPtVsCentV0A_GenXiMinus ) {
618     fHistPtVsCentV0A_GenXiMinus    = new TH2D( 
619     "fHistPtVsCentV0A_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
620     fListHist->Add(fHistPtVsCentV0A_GenXiMinus); }
621   if(! fHistPtVsCentV0A_GenXiPlus ) {
622     fHistPtVsCentV0A_GenXiPlus    = new TH2D( 
623     "fHistPtVsCentV0A_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
624     fListHist->Add(fHistPtVsCentV0A_GenXiPlus); }
625   if(! fHistPtVsCentV0A_GenOmegaMinus ) {
626     fHistPtVsCentV0A_GenOmegaMinus    = new TH2D( 
627     "fHistPtVsCentV0A_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
628     fListHist->Add(fHistPtVsCentV0A_GenOmegaMinus); }
629   if(! fHistPtVsCentV0A_GenOmegaPlus ) {
630     fHistPtVsCentV0A_GenOmegaPlus    = new TH2D( 
631     "fHistPtVsCentV0A_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
632     fListHist->Add(fHistPtVsCentV0A_GenOmegaPlus); }  
633
634   if(! fHistPtVsCentV0C_GenXiMinus ) {
635     fHistPtVsCentV0C_GenXiMinus    = new TH2D( 
636     "fHistPtVsCentV0C_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
637     fListHist->Add(fHistPtVsCentV0C_GenXiMinus); }
638   if(! fHistPtVsCentV0C_GenXiPlus ) {
639     fHistPtVsCentV0C_GenXiPlus    = new TH2D( 
640     "fHistPtVsCentV0C_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
641     fListHist->Add(fHistPtVsCentV0C_GenXiPlus); }
642   if(! fHistPtVsCentV0C_GenOmegaMinus ) {
643     fHistPtVsCentV0C_GenOmegaMinus    = new TH2D( 
644     "fHistPtVsCentV0C_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
645     fListHist->Add(fHistPtVsCentV0C_GenOmegaMinus); }
646   if(! fHistPtVsCentV0C_GenOmegaPlus ) {
647     fHistPtVsCentV0C_GenOmegaPlus    = new TH2D( 
648     "fHistPtVsCentV0C_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
649     fListHist->Add(fHistPtVsCentV0C_GenOmegaPlus); }  
650
651   if(! fHistPtVsCentV0M_GenXiMinus ) {
652     fHistPtVsCentV0M_GenXiMinus    = new TH2D( 
653     "fHistPtVsCentV0M_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
654     fListHist->Add(fHistPtVsCentV0M_GenXiMinus); }
655   if(! fHistPtVsCentV0M_GenXiPlus ) {
656     fHistPtVsCentV0M_GenXiPlus    = new TH2D( 
657     "fHistPtVsCentV0M_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
658     fListHist->Add(fHistPtVsCentV0M_GenXiPlus); }
659   if(! fHistPtVsCentV0M_GenOmegaMinus ) {
660     fHistPtVsCentV0M_GenOmegaMinus    = new TH2D( 
661     "fHistPtVsCentV0M_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
662     fListHist->Add(fHistPtVsCentV0M_GenOmegaMinus); }
663   if(! fHistPtVsCentV0M_GenOmegaPlus ) {
664     fHistPtVsCentV0M_GenOmegaPlus    = new TH2D( 
665     "fHistPtVsCentV0M_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
666     fListHist->Add(fHistPtVsCentV0M_GenOmegaPlus); }  
667
668   //Equalized
669   if(! fHistPtVsCentV0AEq_GenXiMinus ) {
670     fHistPtVsCentV0AEq_GenXiMinus    = new TH2D( 
671     "fHistPtVsCentV0AEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
672     fListHist->Add(fHistPtVsCentV0AEq_GenXiMinus); }
673   if(! fHistPtVsCentV0AEq_GenXiPlus ) {
674     fHistPtVsCentV0AEq_GenXiPlus    = new TH2D( 
675     "fHistPtVsCentV0AEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
676     fListHist->Add(fHistPtVsCentV0AEq_GenXiPlus); }
677   if(! fHistPtVsCentV0AEq_GenOmegaMinus ) {
678     fHistPtVsCentV0AEq_GenOmegaMinus    = new TH2D( 
679     "fHistPtVsCentV0AEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
680     fListHist->Add(fHistPtVsCentV0AEq_GenOmegaMinus); }
681   if(! fHistPtVsCentV0AEq_GenOmegaPlus ) {
682     fHistPtVsCentV0AEq_GenOmegaPlus    = new TH2D( 
683     "fHistPtVsCentV0AEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
684     fListHist->Add(fHistPtVsCentV0AEq_GenOmegaPlus); }  
685
686   if(! fHistPtVsCentV0CEq_GenXiMinus ) {
687     fHistPtVsCentV0CEq_GenXiMinus    = new TH2D( 
688     "fHistPtVsCentV0CEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
689     fListHist->Add(fHistPtVsCentV0CEq_GenXiMinus); }
690   if(! fHistPtVsCentV0CEq_GenXiPlus ) {
691     fHistPtVsCentV0CEq_GenXiPlus    = new TH2D( 
692     "fHistPtVsCentV0CEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
693     fListHist->Add(fHistPtVsCentV0CEq_GenXiPlus); }
694   if(! fHistPtVsCentV0CEq_GenOmegaMinus ) {
695     fHistPtVsCentV0CEq_GenOmegaMinus    = new TH2D( 
696     "fHistPtVsCentV0CEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
697     fListHist->Add(fHistPtVsCentV0CEq_GenOmegaMinus); }
698   if(! fHistPtVsCentV0CEq_GenOmegaPlus ) {
699     fHistPtVsCentV0CEq_GenOmegaPlus    = new TH2D( 
700     "fHistPtVsCentV0CEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
701     fListHist->Add(fHistPtVsCentV0CEq_GenOmegaPlus); }  
702
703   if(! fHistPtVsCentV0MEq_GenXiMinus ) {
704     fHistPtVsCentV0MEq_GenXiMinus    = new TH2D( 
705     "fHistPtVsCentV0MEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
706     fListHist->Add(fHistPtVsCentV0MEq_GenXiMinus); }
707   if(! fHistPtVsCentV0MEq_GenXiPlus ) {
708     fHistPtVsCentV0MEq_GenXiPlus    = new TH2D( 
709     "fHistPtVsCentV0MEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
710     fListHist->Add(fHistPtVsCentV0MEq_GenXiPlus); }
711   if(! fHistPtVsCentV0MEq_GenOmegaMinus ) {
712     fHistPtVsCentV0MEq_GenOmegaMinus    = new TH2D( 
713     "fHistPtVsCentV0MEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
714     fListHist->Add(fHistPtVsCentV0MEq_GenOmegaMinus); }
715   if(! fHistPtVsCentV0MEq_GenOmegaPlus ) {
716     fHistPtVsCentV0MEq_GenOmegaPlus    = new TH2D( 
717     "fHistPtVsCentV0MEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,100,0,100);   
718     fListHist->Add(fHistPtVsCentV0MEq_GenOmegaPlus); }  
719
720   //AMPLITUDES: V0A, V0C, V0M, +Eq
721   Double_t lMaxAmplitude = 2500; 
722   Long_t lAmplitudeBins = 10000;
723   if(! fHistPtVsAmpV0A_GenXiMinus ) {
724     fHistPtVsAmpV0A_GenXiMinus    = new TH2D( 
725     "fHistPtVsAmpV0A_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
726     fListHist->Add(fHistPtVsAmpV0A_GenXiMinus); }
727   if(! fHistPtVsAmpV0A_GenXiPlus ) {
728     fHistPtVsAmpV0A_GenXiPlus    = new TH2D( 
729     "fHistPtVsAmpV0A_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
730     fListHist->Add(fHistPtVsAmpV0A_GenXiPlus); }
731   if(! fHistPtVsAmpV0A_GenOmegaMinus ) {
732     fHistPtVsAmpV0A_GenOmegaMinus    = new TH2D( 
733     "fHistPtVsAmpV0A_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
734     fListHist->Add(fHistPtVsAmpV0A_GenOmegaMinus); }
735   if(! fHistPtVsAmpV0A_GenOmegaPlus ) {
736     fHistPtVsAmpV0A_GenOmegaPlus    = new TH2D( 
737     "fHistPtVsAmpV0A_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
738     fListHist->Add(fHistPtVsAmpV0A_GenOmegaPlus); }  
739
740   if(! fHistPtVsAmpV0C_GenXiMinus ) {
741     fHistPtVsAmpV0C_GenXiMinus    = new TH2D( 
742     "fHistPtVsAmpV0C_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
743     fListHist->Add(fHistPtVsAmpV0C_GenXiMinus); }
744   if(! fHistPtVsAmpV0C_GenXiPlus ) {
745     fHistPtVsAmpV0C_GenXiPlus    = new TH2D( 
746     "fHistPtVsAmpV0C_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
747     fListHist->Add(fHistPtVsAmpV0C_GenXiPlus); }
748   if(! fHistPtVsAmpV0C_GenOmegaMinus ) {
749     fHistPtVsAmpV0C_GenOmegaMinus    = new TH2D( 
750     "fHistPtVsAmpV0C_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
751     fListHist->Add(fHistPtVsAmpV0C_GenOmegaMinus); }
752   if(! fHistPtVsAmpV0C_GenOmegaPlus ) {
753     fHistPtVsAmpV0C_GenOmegaPlus    = new TH2D( 
754     "fHistPtVsAmpV0C_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
755     fListHist->Add(fHistPtVsAmpV0C_GenOmegaPlus); }  
756
757   if(! fHistPtVsAmpV0M_GenXiMinus ) {
758     fHistPtVsAmpV0M_GenXiMinus    = new TH2D( 
759     "fHistPtVsAmpV0M_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
760     fListHist->Add(fHistPtVsAmpV0M_GenXiMinus); }
761   if(! fHistPtVsAmpV0M_GenXiPlus ) {
762     fHistPtVsAmpV0M_GenXiPlus    = new TH2D( 
763     "fHistPtVsAmpV0M_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
764     fListHist->Add(fHistPtVsAmpV0M_GenXiPlus); }
765   if(! fHistPtVsAmpV0M_GenOmegaMinus ) {
766     fHistPtVsAmpV0M_GenOmegaMinus    = new TH2D( 
767     "fHistPtVsAmpV0M_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
768     fListHist->Add(fHistPtVsAmpV0M_GenOmegaMinus); }
769   if(! fHistPtVsAmpV0M_GenOmegaPlus ) {
770     fHistPtVsAmpV0M_GenOmegaPlus    = new TH2D( 
771     "fHistPtVsAmpV0M_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
772     fListHist->Add(fHistPtVsAmpV0M_GenOmegaPlus); }  
773
774   //Equalized
775   if(! fHistPtVsAmpV0AEq_GenXiMinus ) {
776     fHistPtVsAmpV0AEq_GenXiMinus    = new TH2D( 
777     "fHistPtVsAmpV0AEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
778     fListHist->Add(fHistPtVsAmpV0AEq_GenXiMinus); }
779   if(! fHistPtVsAmpV0AEq_GenXiPlus ) {
780     fHistPtVsAmpV0AEq_GenXiPlus    = new TH2D( 
781     "fHistPtVsAmpV0AEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
782     fListHist->Add(fHistPtVsAmpV0AEq_GenXiPlus); }
783   if(! fHistPtVsAmpV0AEq_GenOmegaMinus ) {
784     fHistPtVsAmpV0AEq_GenOmegaMinus    = new TH2D( 
785     "fHistPtVsAmpV0AEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
786     fListHist->Add(fHistPtVsAmpV0AEq_GenOmegaMinus); }
787   if(! fHistPtVsAmpV0AEq_GenOmegaPlus ) {
788     fHistPtVsAmpV0AEq_GenOmegaPlus    = new TH2D( 
789     "fHistPtVsAmpV0AEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
790     fListHist->Add(fHistPtVsAmpV0AEq_GenOmegaPlus); }  
791
792   if(! fHistPtVsAmpV0CEq_GenXiMinus ) {
793     fHistPtVsAmpV0CEq_GenXiMinus    = new TH2D( 
794     "fHistPtVsAmpV0CEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
795     fListHist->Add(fHistPtVsAmpV0CEq_GenXiMinus); }
796   if(! fHistPtVsAmpV0CEq_GenXiPlus ) {
797     fHistPtVsAmpV0CEq_GenXiPlus    = new TH2D( 
798     "fHistPtVsAmpV0CEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
799     fListHist->Add(fHistPtVsAmpV0CEq_GenXiPlus); }
800   if(! fHistPtVsAmpV0CEq_GenOmegaMinus ) {
801     fHistPtVsAmpV0CEq_GenOmegaMinus    = new TH2D( 
802     "fHistPtVsAmpV0CEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
803     fListHist->Add(fHistPtVsAmpV0CEq_GenOmegaMinus); }
804   if(! fHistPtVsAmpV0CEq_GenOmegaPlus ) {
805     fHistPtVsAmpV0CEq_GenOmegaPlus    = new TH2D( 
806     "fHistPtVsAmpV0CEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
807     fListHist->Add(fHistPtVsAmpV0CEq_GenOmegaPlus); }  
808
809   if(! fHistPtVsAmpV0MEq_GenXiMinus ) {
810     fHistPtVsAmpV0MEq_GenXiMinus    = new TH2D( 
811     "fHistPtVsAmpV0MEq_GenXiMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
812     fListHist->Add(fHistPtVsAmpV0MEq_GenXiMinus); }
813   if(! fHistPtVsAmpV0MEq_GenXiPlus ) {
814     fHistPtVsAmpV0MEq_GenXiPlus    = new TH2D( 
815     "fHistPtVsAmpV0MEq_GenXiPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
816     fListHist->Add(fHistPtVsAmpV0MEq_GenXiPlus); }
817   if(! fHistPtVsAmpV0MEq_GenOmegaMinus ) {
818     fHistPtVsAmpV0MEq_GenOmegaMinus    = new TH2D( 
819     "fHistPtVsAmpV0MEq_GenOmegaMinus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
820     fListHist->Add(fHistPtVsAmpV0MEq_GenOmegaMinus); }
821   if(! fHistPtVsAmpV0MEq_GenOmegaPlus ) {
822     fHistPtVsAmpV0MEq_GenOmegaPlus    = new TH2D( 
823     "fHistPtVsAmpV0MEq_GenOmegaPlus",       "Generated;p_{T} (GeV/c); Mult",200,0,20,lAmplitudeBins,0,lMaxAmplitude);   
824     fListHist->Add(fHistPtVsAmpV0MEq_GenOmegaPlus); }  
825
826    //List of Histograms: Normal
827    PostData(1, fListHist);
828
829    //TTree Object: Saved to base directory. Should cache to disk while saving. 
830    //(Important to avoid excessive memory usage, particularly when merging)
831    PostData(2, fTreeEvent);
832    PostData(3, fTreeV0);
833    PostData(4, fTreeCascade);
834
835 }// end UserCreateOutputObjects
836
837
838 //________________________________________________________________________
839 void AliAnalysisTaskStrangenessVsMultiplicityMC::UserExec(Option_t *) 
840 {
841   // Main loop
842   // Called for each event
843
844    AliESDEvent *lESDevent = 0x0;
845    AliMCEvent  *lMCevent  = 0x0; 
846    AliStack    *lMCstack  = 0x0; 
847   
848   // Connect to the InputEvent   
849   // After these lines, we should have an ESD/AOD event + the number of V0s in it.
850
851    // Appropriate for ESD analysis! 
852       
853    lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
854    if (!lESDevent) {
855       AliWarning("ERROR: lESDevent not available \n");
856       return;
857    }
858
859   //Get VZERO Information for multiplicity later
860   AliVVZERO* esdV0 = lESDevent->GetVZEROData();
861   if (!esdV0) {
862     AliError("AliVVZERO not available");
863     return;
864   }
865         
866   lMCevent = MCEvent();
867   if (!lMCevent) {
868     Printf("ERROR: Could not retrieve MC event \n");
869     cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;   
870     return;
871   }
872
873   lMCstack = lMCevent->Stack();
874   if (!lMCstack) {
875     Printf("ERROR: Could not retrieve MC stack \n");
876     cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
877     return;
878   }
879
880    fRunNumber = lESDevent->GetRunNumber();
881
882   Double_t lMagneticField = -10; 
883   lMagneticField = lESDevent->GetMagneticField( );
884
885 //------------------------------------------------
886 // Variable Definition
887 //------------------------------------------------
888
889 //------------------------------------------------
890 // Physics Selection
891 //------------------------------------------------
892   
893   fHistEventCounter->Fill(0.5); 
894
895   UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
896   Bool_t isSelected = 0;
897   isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
898   
899   //Standard Min-Bias Selection
900   if ( ! isSelected ) {
901     PostData(1, fListHist);
902     PostData(2, fTreeEvent);
903     PostData(3, fTreeV0);
904     PostData(4, fTreeCascade);
905     return;
906   }
907
908   fHistEventCounter->Fill(1.5);
909  
910   //------------------------------------------------
911   // Primary Vertex Requirements Section:
912   //  ---> pp: has vertex, |z|<10cm
913   //------------------------------------------------
914   
915   //classical Proton-proton like selection 
916   const AliESDVertex *lPrimaryBestESDVtx     = lESDevent->GetPrimaryVertex();   
917   const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
918   const AliESDVertex *lPrimarySPDVtx         = lESDevent->GetPrimaryVertexSPD();
919
920   Double_t lBestPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
921   lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
922
923   //Only accept if Tracking or SPD vertex is fine 
924   if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
925     AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
926     PostData(1, fListHist); 
927     PostData(2, fTreeEvent);
928     PostData(3, fTreeV0);
929     PostData(4, fTreeCascade);
930     return;
931   }
932
933   //Has SPD or Tracking Vertex
934   fHistEventCounter -> Fill(2.5); 
935
936   //Always do Primary Vertex Selection 
937   if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0) {
938     AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
939     PostData(1, fListHist); 
940     PostData(2, fTreeEvent);
941     PostData(3, fTreeV0);
942     PostData(4, fTreeCascade);
943     return;
944   }
945
946   //Fill Event selected counter
947   fHistEventCounter -> Fill(3.5);
948
949   //------------------------------------------------
950   // Check if this isn't pileup
951   //------------------------------------------------
952
953   if(lESDevent->IsPileupFromSPDInMultBins() ){
954     // minContributors=3, minZdist=0.8, nSigmaZdist=3., nSigmaDiamXY=2., nSigmaDiamZ=5.  
955     //-> see http://alisoft.cern.ch/viewvc/trunk/STEER/AliESDEvent.h?root=AliRoot&r1=41914&r2=42199&pathrev=42199
956     AliWarning("Pb / Event tagged as pile-up by SPD... return !"); 
957     PostData(1, fListHist); 
958     PostData(2, fTreeEvent);
959     PostData(3, fTreeV0);
960     PostData(4, fTreeCascade);
961     return; 
962   }
963   //Fill Event isn't pileup counter
964   fHistEventCounter -> Fill(4.5);
965
966 //------------------------------------------------
967 // Multiplicity Information Acquistion
968 //------------------------------------------------
969
970   //Monte Carlo Level information ! 
971   //--------- GENERATED NUMBER OF CHARGED PARTICLES
972   // ---> Variable Definition
973
974   Long_t lNchEta5   = 0; 
975   Long_t lNchEta8   = 0; 
976   Long_t lNchVZEROA = 0; 
977   Long_t lNchVZEROC = 0; 
978
979   //----- Loop on Stack ----------------------------------------------------------------
980   for (Int_t iCurrentLabelStack = 0;  iCurrentLabelStack < (lMCstack->GetNtrack()); iCurrentLabelStack++) 
981   {// This is the begining of the loop on tracks
982       TParticle* particleOne = lMCstack->Particle(iCurrentLabelStack);
983       if(!particleOne) continue;
984       if(!particleOne->GetPDG()) continue;
985       Double_t lThisCharge = particleOne->GetPDG()->Charge()/3.;
986       if(TMath::Abs(lThisCharge)<0.001) continue;
987       if(! (lMCstack->IsPhysicalPrimary(iCurrentLabelStack)) ) continue;
988      
989       //Double_t gpt = particleOne -> Pt();
990       Double_t geta = particleOne -> Eta(); 
991
992       if( TMath::Abs(geta) < 0.5 ) lNchEta5++; 
993       if( TMath::Abs(geta) < 0.8 ) lNchEta8++; 
994       if( 2.8 < geta && geta < 5.1 ) lNchVZEROA++; 
995       if(-3.7 < geta && geta <-1.7 ) lNchVZEROC++; 
996   }//End of loop on tracks
997
998   //Attribution 
999   fTrueMultEta5 = lNchEta5; 
1000   fTrueMultEta8 = lNchEta8; 
1001   fTrueMultVZEROA = lNchVZEROA; 
1002   fTrueMultVZEROC = lNchVZEROC; 
1003   //----- End Loop on Stack ------------------------------------------------------------
1004
1005   //Standard GetReferenceMultiplicity Estimator (0.5 and 0.8)
1006   fRefMultEta5 = fESDtrackCuts->GetReferenceMultiplicity(lESDevent, AliESDtrackCuts::kTrackletsITSTPC,0.5);
1007   fRefMultEta8 = fESDtrackCuts->GetReferenceMultiplicity(lESDevent, AliESDtrackCuts::kTrackletsITSTPC,0.8);
1008
1009   // VZERO PART
1010   Float_t  multV0A  = 0;            //  multiplicity from V0 reco side A
1011   Float_t  multV0C  = 0;            //  multiplicity from V0 reco side C
1012   Float_t  multV0AEq  = 0;          //  multiplicity from V0 reco side A
1013   Float_t  multV0CEq  = 0;          //  multiplicity from V0 reco side C
1014   Float_t  multV0ACorr  = 0;            //  multiplicity from V0 reco side A
1015   Float_t  multV0CCorr  = 0;            //  multiplicity from V0 reco side C
1016
1017   //Non-Equalized Signal: copy of multV0ACorr and multV0CCorr from AliCentralitySelectionTask
1018   //Getters for uncorrected multiplicity  
1019   multV0A=esdV0->GetMTotV0A();
1020   multV0C=esdV0->GetMTotV0C();
1021
1022   //Get Z vertex position of SPD vertex (why not Tracking if available?) 
1023   Float_t zvtx = lPrimarySPDVtx->GetZ(); 
1024
1025   //Acquire Corrected multV0A 
1026   multV0ACorr = AliESDUtils::GetCorrV0A(multV0A,zvtx);    
1027   multV0CCorr = AliESDUtils::GetCorrV0C(multV0C,zvtx);   
1028     
1029   //Copy to Event Tree for extra information 
1030   fAmplitude_V0A = multV0ACorr; 
1031   fAmplitude_V0C = multV0CCorr; 
1032
1033   // Equalized signals // From AliCentralitySelectionTask
1034   for(Int_t iCh = 4; iCh < 7; ++iCh) {
1035     Double_t mult = lESDevent->GetVZEROEqMultiplicity(iCh);
1036     multV0AEq += mult;
1037   }
1038   for(Int_t iCh = 0; iCh < 3; ++iCh) {
1039     Double_t mult = lESDevent->GetVZEROEqMultiplicity(iCh);
1040     multV0CEq += mult;
1041   }
1042   fAmplitude_V0AEq = multV0AEq; 
1043   fAmplitude_V0CEq = multV0CEq; 
1044
1045   fCentrality_V0A   = -100; 
1046   fCentrality_V0C   = -100; 
1047   fCentrality_V0M   = -100; 
1048   fCentrality_V0AEq = -100; 
1049   fCentrality_V0CEq = -100; 
1050   fCentrality_V0MEq = -100; 
1051
1052   //AliCentrality... Check if working? 
1053   AliCentrality* centrality;
1054   centrality = lESDevent->GetCentrality();
1055   if ( !(centrality->GetQuality()>1) ){ 
1056     fCentrality_V0A   = centrality->GetCentralityPercentile( "V0A"   ); 
1057     fCentrality_V0C   = centrality->GetCentralityPercentile( "V0C"   ); 
1058     fCentrality_V0M   = centrality->GetCentralityPercentile( "V0M"   ); 
1059     fCentrality_V0AEq = centrality->GetCentralityPercentile( "V0AEq" ); 
1060     fCentrality_V0CEq = centrality->GetCentralityPercentile( "V0CEq" ); 
1061     fCentrality_V0MEq = centrality->GetCentralityPercentile( "V0MEq" ); 
1062   }
1063   
1064   //Event-level fill 
1065   fTreeEvent->Fill() ;
1066   
1067 //------------------------------------------------
1068
1069 //------------------------------------------------
1070 // Fill Efficiency Denominators, please 
1071 //------------------------------------------------
1072
1073    Int_t    lThisPDG  = 0;
1074    Double_t lThisRap  = 0;
1075    Double_t lThisPt   = 0;
1076
1077 //----- Loop on Generated CASCADES ---------------
1078    for (Int_t ilab = 0;  ilab < (lMCstack->GetNtrack()); ilab++) 
1079    {// This is the begining of the loop on tracks
1080       
1081       TParticle* lPart = 0x0; 
1082       lPart = lMCstack->Particle( ilab );
1083       if(!lPart){
1084          Printf("Generated loop %d - MC TParticle pointer to current stack particle = 0x0 ! Skip ...\n", ilab );
1085          continue;
1086       }
1087
1088       lThisPDG = lPart->GetPdgCode();         
1089
1090       if ( (TMath::Abs(lThisPDG) == 3312) || (TMath::Abs(lThisPDG) == 3334) ) 
1091       {
1092         lThisRap   = MyRapidity(lPart->Energy(),lPart->Pz());
1093         lThisPt    = lPart->Pt();
1094
1095         //Use Physical Primaries only for filling These Histos
1096         if ( lMCstack->IsPhysicalPrimary(ilab)!=kTRUE ) continue;
1097
1098         if( lThisPDG ==  3312 && TMath::Abs(lThisRap) < 0.5 ){
1099           fHistPt_GenXiMinus                -> Fill (lThisPt);          
1100           fHistPtVsRefMultEta5_GenXiMinus   -> Fill (lThisPt, fRefMultEta5); 
1101           fHistPtVsRefMultEta8_GenXiMinus   -> Fill (lThisPt, fRefMultEta8);
1102           //Centralities 
1103           fHistPtVsCentV0A_GenXiMinus       -> Fill (lThisPt, fCentrality_V0A);  
1104           fHistPtVsCentV0C_GenXiMinus       -> Fill (lThisPt, fCentrality_V0C);  
1105           fHistPtVsCentV0M_GenXiMinus       -> Fill (lThisPt, fCentrality_V0M);  
1106           fHistPtVsCentV0AEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0AEq);  
1107           fHistPtVsCentV0CEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0CEq);  
1108           fHistPtVsCentV0MEq_GenXiMinus       -> Fill (lThisPt, fCentrality_V0MEq);  
1109           //Amplitudes 
1110           fHistPtVsAmpV0A_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0A);  
1111           fHistPtVsAmpV0C_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0C);  
1112           fHistPtVsAmpV0M_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1113           fHistPtVsAmpV0AEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1114           fHistPtVsAmpV0CEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1115           fHistPtVsAmpV0MEq_GenXiMinus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1116         }
1117         if( lThisPDG == -3312 && TMath::Abs(lThisRap) < 0.5 ){
1118           fHistPt_GenXiPlus                -> Fill (lThisPt);          
1119           fHistPtVsRefMultEta5_GenXiPlus   -> Fill (lThisPt, fRefMultEta5); 
1120           fHistPtVsRefMultEta8_GenXiPlus   -> Fill (lThisPt, fRefMultEta8);
1121           //Centralities 
1122           fHistPtVsCentV0A_GenXiPlus       -> Fill (lThisPt, fCentrality_V0A);  
1123           fHistPtVsCentV0C_GenXiPlus       -> Fill (lThisPt, fCentrality_V0C);  
1124           fHistPtVsCentV0M_GenXiPlus       -> Fill (lThisPt, fCentrality_V0M);  
1125           fHistPtVsCentV0AEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0AEq);  
1126           fHistPtVsCentV0CEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0CEq);  
1127           fHistPtVsCentV0MEq_GenXiPlus       -> Fill (lThisPt, fCentrality_V0MEq);  
1128           //Amplitudes 
1129           fHistPtVsAmpV0A_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0A);  
1130           fHistPtVsAmpV0C_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0C);  
1131           fHistPtVsAmpV0M_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1132           fHistPtVsAmpV0AEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1133           fHistPtVsAmpV0CEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1134           fHistPtVsAmpV0MEq_GenXiPlus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1135         }
1136         if( lThisPDG ==  3334 && TMath::Abs(lThisRap) < 0.5 ){
1137           fHistPt_GenOmegaMinus                -> Fill (lThisPt);          
1138           fHistPtVsRefMultEta5_GenOmegaMinus   -> Fill (lThisPt, fRefMultEta5); 
1139           fHistPtVsRefMultEta8_GenOmegaMinus   -> Fill (lThisPt, fRefMultEta8);
1140           //Centralities 
1141           fHistPtVsCentV0A_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0A);  
1142           fHistPtVsCentV0C_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0C);  
1143           fHistPtVsCentV0M_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0M);  
1144           fHistPtVsCentV0AEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0AEq);  
1145           fHistPtVsCentV0CEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0CEq);  
1146           fHistPtVsCentV0MEq_GenOmegaMinus       -> Fill (lThisPt, fCentrality_V0MEq);  
1147           //Amplitudes 
1148           fHistPtVsAmpV0A_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0A);  
1149           fHistPtVsAmpV0C_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0C);  
1150           fHistPtVsAmpV0M_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1151           fHistPtVsAmpV0AEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1152           fHistPtVsAmpV0CEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1153           fHistPtVsAmpV0MEq_GenOmegaMinus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1154         }
1155         if( lThisPDG == -3334 && TMath::Abs(lThisRap) < 0.5 ){
1156           fHistPt_GenOmegaPlus                -> Fill (lThisPt);          
1157           fHistPtVsRefMultEta5_GenOmegaPlus   -> Fill (lThisPt, fRefMultEta5); 
1158           fHistPtVsRefMultEta8_GenOmegaPlus   -> Fill (lThisPt, fRefMultEta8);
1159           //Centralities 
1160           fHistPtVsCentV0A_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0A);  
1161           fHistPtVsCentV0C_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0C);  
1162           fHistPtVsCentV0M_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0M);  
1163           fHistPtVsCentV0AEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0AEq);  
1164           fHistPtVsCentV0CEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0CEq);  
1165           fHistPtVsCentV0MEq_GenOmegaPlus       -> Fill (lThisPt, fCentrality_V0MEq);  
1166           //Amplitudes 
1167           fHistPtVsAmpV0A_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0A);  
1168           fHistPtVsAmpV0C_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0C);  
1169           fHistPtVsAmpV0M_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0A + fAmplitude_V0C);  
1170           fHistPtVsAmpV0AEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0AEq);  
1171           fHistPtVsAmpV0CEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0CEq);  
1172           fHistPtVsAmpV0MEq_GenOmegaPlus       -> Fill (lThisPt, fAmplitude_V0AEq + fAmplitude_V0CEq);  
1173         }
1174       }
1175    }//End of loop on tracks
1176 //----- End Loop on Cascades ------------------------------------------------------------
1177
1178 //------------------------------------------------
1179 // Rerun cascade vertexer! 
1180 //------------------------------------------------
1181     
1182   if( fkRunVertexers ){ 
1183     lESDevent->ResetCascades();
1184     lESDevent->ResetV0s();
1185
1186     AliV0vertexer lV0vtxer;
1187     AliCascadeVertexer lCascVtxer;
1188                   
1189     lV0vtxer.SetDefaultCuts(fV0VertexerSels);
1190     lCascVtxer.SetDefaultCuts(fCascadeVertexerSels);
1191
1192     lV0vtxer.Tracks2V0vertices(lESDevent);
1193     lCascVtxer.V0sTracks2CascadeVertices(lESDevent);
1194   }
1195
1196 //------------------------------------------------
1197 // MAIN CASCADE LOOP STARTS HERE
1198 //------------------------------------------------
1199 // Code Credit: Antonin Maire (thanks^100)
1200 // ---> This is an adaptation
1201
1202   Long_t ncascades = 0;
1203         ncascades = lESDevent->GetNumberOfCascades();
1204   
1205   for (Int_t iXi = 0; iXi < ncascades; iXi++){
1206     //------------------------------------------------
1207     // Initializations
1208     //------------------------------------------------  
1209           //Double_t lTrkgPrimaryVtxRadius3D = -500.0;
1210           //Double_t lBestPrimaryVtxRadius3D = -500.0;
1211
1212           // - 1st part of initialisation : variables needed to store AliESDCascade data members
1213           Double_t lEffMassXi      = 0. ;
1214           //Double_t lChi2Xi         = -1. ;
1215           Double_t lDcaXiDaughters = -1. ;
1216           Double_t lXiCosineOfPointingAngle = -1. ;
1217           Double_t lPosXi[3] = { -1000.0, -1000.0, -1000.0 };
1218           Double_t lXiRadius = -1000. ;
1219           
1220           // - 2nd part of initialisation : Nbr of clusters within TPC for the 3 daughter cascade tracks
1221           Int_t    lPosTPCClusters    = -1; // For ESD only ...//FIXME : wait for availability in AOD
1222           Int_t    lNegTPCClusters    = -1; // For ESD only ...
1223           Int_t    lBachTPCClusters   = -1; // For ESD only ...
1224                         
1225           // - 3rd part of initialisation : about V0 part in cascades
1226           Double_t lInvMassLambdaAsCascDghter = 0.;
1227           //Double_t lV0Chi2Xi         = -1. ;
1228           Double_t lDcaV0DaughtersXi = -1.;
1229                 
1230           Double_t lDcaBachToPrimVertexXi = -1., lDcaV0ToPrimVertexXi = -1.;
1231           Double_t lDcaPosToPrimVertexXi  = -1.;
1232           Double_t lDcaNegToPrimVertexXi  = -1.;
1233           Double_t lV0CosineOfPointingAngleXi = -1. ;
1234           Double_t lV0CosineOfPointingAngleXiSpecial = -1. ;
1235           Double_t lPosV0Xi[3] = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
1236           Double_t lV0RadiusXi = -1000.0;
1237           Double_t lV0quality  = 0.;
1238         
1239           // - 4th part of initialisation : Effective masses
1240           Double_t lInvMassXiMinus    = 0.;
1241           Double_t lInvMassXiPlus     = 0.;
1242           Double_t lInvMassOmegaMinus = 0.;
1243           Double_t lInvMassOmegaPlus  = 0.;
1244     
1245           // - 6th part of initialisation : extra info for QA
1246           Double_t lXiMomX       = 0. , lXiMomY = 0., lXiMomZ = 0.;
1247           Double_t lXiTransvMom  = 0. ;
1248           //Double_t lXiTransvMomMC= 0. ;
1249           Double_t lXiTotMom     = 0. ;
1250                 
1251           Double_t lBachMomX       = 0., lBachMomY  = 0., lBachMomZ   = 0.;
1252           //Double_t lBachTransvMom  = 0.;
1253           //Double_t lBachTotMom     = 0.;
1254
1255     fTreeCascVarNegNSigmaPion   = -100;
1256     fTreeCascVarNegNSigmaProton = -100;
1257     fTreeCascVarPosNSigmaPion   = -100;
1258     fTreeCascVarPosNSigmaProton = -100;
1259     fTreeCascVarBachNSigmaPion  = -100;
1260     fTreeCascVarBachNSigmaKaon  = -100;
1261         
1262           Short_t  lChargeXi = -2;
1263           //Double_t lV0toXiCosineOfPointingAngle = 0. ;
1264         
1265           Double_t lRapXi   = -20.0, lRapOmega = -20.0, lRapMC = -20;//  lEta = -20.0, lTheta = 360., lPhi = 720. ;
1266           //Double_t lAlphaXi = -200., lPtArmXi  = -200.0;
1267             
1268     // -------------------------------------
1269     // II.ESD - Calculation Part dedicated to Xi vertices (ESD)
1270     
1271           AliESDcascade *xi = lESDevent->GetCascade(iXi);
1272           if (!xi) continue;
1273         
1274                 // - II.Step 2 : Assigning the necessary variables for specific AliESDcascade data members (ESD)        
1275                 //-------------
1276           lV0quality = 0.;
1277           xi->ChangeMassHypothesis(lV0quality , 3312); // default working hypothesis : cascade = Xi- decay
1278
1279           lEffMassXi                    = xi->GetEffMassXi();
1280           //lChi2Xi                         = xi->GetChi2Xi();
1281           lDcaXiDaughters       = xi->GetDcaXiDaughters();
1282           lXiCosineOfPointingAngle                  = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0],
1283                                                                                  lBestPrimaryVtxPos[1],
1284                                                                                  lBestPrimaryVtxPos[2] );
1285                   // Take care : the best available vertex should be used (like in AliCascadeVertexer)
1286         
1287           xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
1288           lXiRadius                     = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );           
1289
1290                 // - II.Step 3 : around the tracks : Bach + V0 (ESD)
1291                 // ~ Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
1292                 //-------------
1293                 
1294         UInt_t lIdxPosXi        = (UInt_t) TMath::Abs( xi->GetPindex() );
1295         UInt_t lIdxNegXi        = (UInt_t) TMath::Abs( xi->GetNindex() );
1296         UInt_t lBachIdx         = (UInt_t) TMath::Abs( xi->GetBindex() );
1297                 // Care track label can be negative in MC production (linked with the track quality)
1298                 // However = normally, not the case for track index ...
1299           
1300           // FIXME : rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
1301           if(lBachIdx == lIdxNegXi) {
1302                   AliWarning("Pb / Idx(Bach. track) = Idx(Neg. track) ... continue!"); continue;
1303           }
1304     if(lBachIdx == lIdxPosXi) {
1305         AliWarning("Pb / Idx(Bach. track) = Idx(Pos. track) ... continue!"); continue;
1306           }
1307           
1308           AliESDtrack *pTrackXi         = lESDevent->GetTrack( lIdxPosXi );
1309           AliESDtrack *nTrackXi         = lESDevent->GetTrack( lIdxNegXi );
1310           AliESDtrack *bachTrackXi      = lESDevent->GetTrack( lBachIdx );
1311
1312           if (!pTrackXi || !nTrackXi || !bachTrackXi ) {
1313                   AliWarning("ERROR: Could not retrieve one of the 3 ESD daughter tracks of the cascade ...");
1314                   continue;
1315           }
1316
1317       fTreeCascVarPosEta = pTrackXi->Eta();
1318       fTreeCascVarNegEta = nTrackXi->Eta();
1319       fTreeCascVarBachEta = bachTrackXi->Eta();
1320       
1321       Double_t lBMom[3], lNMom[3], lPMom[3];
1322       xi->GetBPxPyPz( lBMom[0], lBMom[1], lBMom[2] );
1323       xi->GetPPxPyPz( lPMom[0], lPMom[1], lPMom[2] );
1324       xi->GetNPxPyPz( lNMom[0], lNMom[1], lNMom[2] );
1325       
1326       //fTreeCascVarBachTransMom = TMath::Sqrt( lBMom[0]*lBMom[0] + lBMom[1]*lBMom[1] );
1327       //fTreeCascVarPosTransMom  = TMath::Sqrt( lPMom[0]*lPMom[0] + lPMom[1]*lPMom[1] );
1328       //fTreeCascVarNegTransMom  = TMath::Sqrt( lNMom[0]*lNMom[0] + lNMom[1]*lNMom[1] );
1329   
1330     //------------------------------------------------
1331     // TPC dEdx information 
1332     //------------------------------------------------
1333     fTreeCascVarNegNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kPion   );
1334     fTreeCascVarNegNSigmaProton = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kProton );
1335     fTreeCascVarPosNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kPion );
1336     fTreeCascVarPosNSigmaProton = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kProton );
1337     fTreeCascVarBachNSigmaPion  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kPion );
1338     fTreeCascVarBachNSigmaKaon  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kKaon );
1339
1340     //------------------------------------------------
1341     // TPC Number of clusters info
1342     // --- modified to save the smallest number 
1343     // --- of TPC clusters for the 3 tracks
1344     //------------------------------------------------
1345               
1346           lPosTPCClusters   = pTrackXi->GetTPCNcls();
1347           lNegTPCClusters   = nTrackXi->GetTPCNcls();
1348           lBachTPCClusters  = bachTrackXi->GetTPCNcls(); 
1349
1350     // 1 - Poor quality related to TPCrefit
1351           ULong_t pStatus    = pTrackXi->GetStatus();
1352           ULong_t nStatus    = nTrackXi->GetStatus();
1353           ULong_t bachStatus = bachTrackXi->GetStatus();
1354
1355     //fTreeCascVarkITSRefitBachelor = kTRUE; 
1356     //fTreeCascVarkITSRefitNegative = kTRUE; 
1357     //fTreeCascVarkITSRefitPositive = kTRUE; 
1358
1359     if ((pStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Pos. track has no TPCrefit ... continue!"); continue; }
1360     if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
1361     if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
1362
1363     //Extra Debug Information: booleans for ITS refit
1364     //if ((pStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitPositive = kFALSE; }
1365     //if ((nStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitNegative = kFALSE; }
1366     //if ((bachStatus&AliESDtrack::kITSrefit) == 0) { fTreeCascVarkITSRefitBachelor = kFALSE; }
1367
1368           // 2 - Poor quality related to TPC clusters: lowest cut of 70 clusters
1369     if(lPosTPCClusters  < 70) { AliWarning("Pb / V0 Pos. track has less than 70 TPC clusters ... continue!"); continue; }
1370           if(lNegTPCClusters  < 70) { AliWarning("Pb / V0 Neg. track has less than 70 TPC clusters ... continue!"); continue; }
1371           if(lBachTPCClusters < 70) { AliWarning("Pb / Bach.   track has less than 70 TPC clusters ... continue!"); continue; }
1372           Int_t leastnumberofclusters = 1000; 
1373           if( lPosTPCClusters < leastnumberofclusters ) leastnumberofclusters = lPosTPCClusters;
1374           if( lNegTPCClusters < leastnumberofclusters ) leastnumberofclusters = lNegTPCClusters;
1375           if( lBachTPCClusters < leastnumberofclusters ) leastnumberofclusters = lBachTPCClusters;
1376
1377           lInvMassLambdaAsCascDghter    = xi->GetEffMass();
1378           // This value shouldn't change, whatever the working hyp. is : Xi-, Xi+, Omega-, Omega+
1379           lDcaV0DaughtersXi             = xi->GetDcaV0Daughters(); 
1380           //lV0Chi2Xi                   = xi->GetChi2V0();
1381         
1382           lV0CosineOfPointingAngleXi    = xi->GetV0CosineOfPointingAngle( lBestPrimaryVtxPos[0],
1383                                                                             lBestPrimaryVtxPos[1],
1384                                                                             lBestPrimaryVtxPos[2] );
1385     //Modification: V0 CosPA wrt to Cascade decay vertex
1386           lV0CosineOfPointingAngleXiSpecial     = xi->GetV0CosineOfPointingAngle( lPosXi[0],
1387                                                                             lPosXi[1],
1388                                                                             lPosXi[2] );
1389
1390           lDcaV0ToPrimVertexXi          = xi->GetD( lBestPrimaryVtxPos[0], 
1391                                                       lBestPrimaryVtxPos[1], 
1392                                                       lBestPrimaryVtxPos[2] );
1393                 
1394           lDcaBachToPrimVertexXi = TMath::Abs( bachTrackXi->GetD(       lBestPrimaryVtxPos[0], 
1395                                                                 lBestPrimaryVtxPos[1], 
1396                                                                 lMagneticField  ) ); 
1397                                           // Note : AliExternalTrackParam::GetD returns an algebraic value ...
1398                 
1399           xi->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] ); 
1400           lV0RadiusXi           = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0]  +  lPosV0Xi[1]*lPosV0Xi[1] );
1401         
1402           lDcaPosToPrimVertexXi         = TMath::Abs( pTrackXi  ->GetD( lBestPrimaryVtxPos[0], 
1403                                                                 lBestPrimaryVtxPos[1], 
1404                                                                 lMagneticField  )     ); 
1405         
1406           lDcaNegToPrimVertexXi         = TMath::Abs( nTrackXi  ->GetD( lBestPrimaryVtxPos[0], 
1407                                                                 lBestPrimaryVtxPos[1], 
1408                                                                 lMagneticField  )     ); 
1409                 
1410           // - II.Step 4 : around effective masses (ESD)
1411           // ~ change mass hypotheses to cover all the possibilities :  Xi-/+, Omega -/+
1412                 
1413           if( bachTrackXi->Charge() < 0 )       {
1414                   lV0quality = 0.;
1415                   xi->ChangeMassHypothesis(lV0quality , 3312);  
1416                           // Calculate the effective mass of the Xi- candidate. 
1417                           // pdg code 3312 = Xi-
1418                   lInvMassXiMinus = xi->GetEffMassXi();
1419                 
1420                   lV0quality = 0.;
1421                   xi->ChangeMassHypothesis(lV0quality , 3334);  
1422                           // Calculate the effective mass of the Xi- candidate. 
1423                           // pdg code 3334 = Omega-
1424                   lInvMassOmegaMinus = xi->GetEffMassXi();
1425                                         
1426                   lV0quality = 0.;
1427                   xi->ChangeMassHypothesis(lV0quality , 3312);  // Back to default hyp.
1428           }// end if negative bachelor
1429         
1430         
1431           if( bachTrackXi->Charge() >  0 ){
1432                   lV0quality = 0.;
1433                   xi->ChangeMassHypothesis(lV0quality , -3312);         
1434                           // Calculate the effective mass of the Xi+ candidate. 
1435                           // pdg code -3312 = Xi+
1436                   lInvMassXiPlus = xi->GetEffMassXi();
1437                 
1438                   lV0quality = 0.;
1439                   xi->ChangeMassHypothesis(lV0quality , -3334);         
1440                           // Calculate the effective mass of the Xi+ candidate. 
1441                           // pdg code -3334  = Omega+
1442                   lInvMassOmegaPlus = xi->GetEffMassXi();
1443                 
1444                   lV0quality = 0.;
1445                   xi->ChangeMassHypothesis(lV0quality , -3312);         // Back to "default" hyp.
1446           }// end if positive bachelor
1447                   // - II.Step 6 : extra info for QA (ESD)
1448                   // miscellaneous pieces of info that may help regarding data quality assessment.
1449                   //-------------
1450
1451           xi->GetPxPyPz( lXiMomX, lXiMomY, lXiMomZ );
1452                   lXiTransvMom          = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY );
1453                   lXiTotMom     = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY   + lXiMomZ*lXiMomZ );
1454                 
1455           xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
1456                   //lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY );
1457                   //lBachTotMom         = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY  +  lBachMomZ*lBachMomZ  );
1458
1459           lChargeXi = xi->Charge();
1460
1461           //lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
1462         
1463           lRapXi    = xi->RapXi();
1464           lRapOmega = xi->RapOmega();
1465           //lEta      = xi->Eta();
1466           //lTheta    = xi->Theta() *180.0/TMath::Pi();
1467           //lPhi      = xi->Phi()   *180.0/TMath::Pi();
1468           //lAlphaXi  = xi->AlphaXi();
1469           //lPtArmXi  = xi->PtArmXi();
1470
1471 //------------------------------------------------
1472 // Associate Cascade Candidates to Monte Carlo!
1473 //------------------------------------------------      
1474
1475 //Warning: Not using Continues... Need to fill tree later!
1476
1477   Double_t lXiTransvMomMC= 0. ; 
1478         Int_t lPDGCodeCascade = 0;      
1479         Int_t lPID_BachMother = 0;
1480         Int_t lPID_NegMother = 0;
1481         Int_t lPID_PosMother = 0;
1482   fTreeCascVarIsPhysicalPrimary = 0; // 0: not defined, any candidate may have this
1483
1484         if(fDebug > 5)
1485                 cout    << "MC EventNumber : " << lMCevent->Header()->GetEvent() 
1486                         << " / MC event Number in Run : " << lMCevent->Header()->GetEventNrInRun() << endl;
1487         
1488 //----------------------------------------
1489 // Regular MC ASSOCIATION STARTS HERE
1490 //----------------------------------------
1491
1492           Int_t lblPosV0Dghter = (Int_t) TMath::Abs( pTrackXi->GetLabel() );  
1493                   // Abs value = needed ! question of quality track association ...
1494           Int_t lblNegV0Dghter = (Int_t) TMath::Abs( nTrackXi->GetLabel() );
1495           Int_t lblBach        = (Int_t) TMath::Abs( bachTrackXi->GetLabel() );
1496
1497           TParticle* mcPosV0Dghter = lMCstack->Particle( lblPosV0Dghter );
1498           TParticle* mcNegV0Dghter = lMCstack->Particle( lblNegV0Dghter );
1499           TParticle* mcBach        = lMCstack->Particle( lblBach );
1500       
1501     //fTreeCascVarPosTransMomMC = mcPosV0Dghter->Pt();
1502     //fTreeCascVarNegTransMomMC = mcNegV0Dghter->Pt();
1503
1504           //fTreeCascVarPIDPositive = mcPosV0Dghter -> GetPdgCode();
1505           //fTreeCascVarPIDNegative = mcNegV0Dghter -> GetPdgCode();
1506           //fTreeCascVarPIDBachelor = mcBach->GetPdgCode();
1507
1508           // - Step 4.2 : level of the Xi daughters
1509                 
1510           Int_t lblMotherPosV0Dghter = mcPosV0Dghter->GetFirstMother() ; 
1511           Int_t lblMotherNegV0Dghter = mcNegV0Dghter->GetFirstMother();
1512         
1513           //Rather uncivilized: Open brackets for each 'continue'
1514           if(! (lblMotherPosV0Dghter != lblMotherNegV0Dghter) ) { // same mother
1515           if(! (lblMotherPosV0Dghter < 0) ) { // mother != primary (!= -1)
1516           if(! (lblMotherNegV0Dghter < 0) ) {
1517                                         
1518                 // mothers = Lambda candidate ... a priori
1519         
1520           TParticle* mcMotherPosV0Dghter = lMCstack->Particle( lblMotherPosV0Dghter );
1521           TParticle* mcMotherNegV0Dghter = lMCstack->Particle( lblMotherNegV0Dghter );
1522                         
1523           // - Step 4.3 : level of Xi candidate
1524         
1525           Int_t lblGdMotherPosV0Dghter =   mcMotherPosV0Dghter->GetFirstMother() ;
1526           Int_t lblGdMotherNegV0Dghter =   mcMotherNegV0Dghter->GetFirstMother() ;
1527                                 
1528                 if(! (lblGdMotherPosV0Dghter != lblGdMotherNegV0Dghter) ) {
1529                 if(! (lblGdMotherPosV0Dghter < 0) ) { // primary lambda ...
1530                 if(! (lblGdMotherNegV0Dghter < 0) ) { // primary lambda ...
1531
1532                   // Gd mothers = Xi candidate ... a priori
1533         
1534           TParticle* mcGdMotherPosV0Dghter = lMCstack->Particle( lblGdMotherPosV0Dghter );
1535           TParticle* mcGdMotherNegV0Dghter = lMCstack->Particle( lblGdMotherNegV0Dghter );
1536                                         
1537           Int_t lblMotherBach = (Int_t) TMath::Abs( mcBach->GetFirstMother()  );
1538         
1539   //            if( lblMotherBach != lblGdMotherPosV0Dghter ) continue; //same mother for bach and V0 daughters
1540                   if(!(lblMotherBach != lblGdMotherPosV0Dghter)) { //same mother for bach and V0 daughters
1541         
1542           TParticle* mcMotherBach = lMCstack->Particle( lblMotherBach );
1543         
1544     lPID_BachMother = mcMotherBach->GetPdgCode();
1545           lPID_NegMother = mcGdMotherPosV0Dghter->GetPdgCode();
1546           lPID_PosMother = mcGdMotherNegV0Dghter->GetPdgCode();
1547    
1548           if(lPID_BachMother==lPID_NegMother && lPID_BachMother==lPID_PosMother){ 
1549                   lPDGCodeCascade = lPID_BachMother; 
1550       lXiTransvMomMC = mcMotherBach->Pt();
1551       if( lMCstack->IsPhysicalPrimary       (lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 1; //Is Primary!
1552       if( lMCstack->IsSecondaryFromWeakDecay(lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 2; //Weak Decay!
1553       if( lMCstack->IsSecondaryFromMaterial (lblMotherBach) ) fTreeCascVarIsPhysicalPrimary = 3; //From Material!
1554       if ( (mcMotherBach->Energy() + mcMotherBach->Pz()) / (mcMotherBach->Energy() - mcMotherBach->Pz() +1.e-13) !=0 ){
1555         lRapMC = 0.5*TMath::Log( (mcMotherBach->Energy() + mcMotherBach->Pz()) / (mcMotherBach->Energy() - mcMotherBach->Pz() +1.e-13) );
1556       }
1557           }
1558
1559   }}}}}}} //Ends all conditionals above...
1560
1561 //----------------------------------------
1562 // Regular MC ASSOCIATION ENDS HERE
1563 //----------------------------------------
1564
1565
1566   //------------------------------------------------
1567   // Set Variables for adding to tree
1568   //------------------------------------------------            
1569         
1570           fTreeCascVarCharge    = lChargeXi;
1571           fTreeCascVarPID = lPDGCodeCascade; 
1572           if(lInvMassXiMinus!=0)    fTreeCascVarMassAsXi = lInvMassXiMinus;
1573           if(lInvMassXiPlus!=0)     fTreeCascVarMassAsXi = lInvMassXiPlus;
1574           if(lInvMassOmegaMinus!=0) fTreeCascVarMassAsOmega = lInvMassOmegaMinus;
1575           if(lInvMassOmegaPlus!=0)  fTreeCascVarMassAsOmega = lInvMassOmegaPlus;
1576           fTreeCascVarPt = lXiTransvMom;
1577           fTreeCascVarPtMC = lXiTransvMomMC;
1578           fTreeCascVarRapXi = lRapXi ;
1579           fTreeCascVarRapMC = lRapMC ;
1580           fTreeCascVarRapOmega = lRapOmega ;
1581           fTreeCascVarDCACascDaughters = lDcaXiDaughters;
1582           fTreeCascVarDCABachToPrimVtx = lDcaBachToPrimVertexXi;
1583           fTreeCascVarDCAV0Daughters = lDcaV0DaughtersXi;
1584           fTreeCascVarDCAV0ToPrimVtx = lDcaV0ToPrimVertexXi;
1585           fTreeCascVarDCAPosToPrimVtx = lDcaPosToPrimVertexXi;
1586           fTreeCascVarDCANegToPrimVtx = lDcaNegToPrimVertexXi;
1587           fTreeCascVarCascCosPointingAngle = lXiCosineOfPointingAngle;
1588           fTreeCascVarCascRadius = lXiRadius;
1589           fTreeCascVarV0Mass = lInvMassLambdaAsCascDghter;
1590           fTreeCascVarV0CosPointingAngle = lV0CosineOfPointingAngleXi;
1591           fTreeCascVarV0CosPointingAngleSpecial = lV0CosineOfPointingAngleXiSpecial;
1592           fTreeCascVarV0Radius = lV0RadiusXi;
1593           fTreeCascVarLeastNbrClusters = leastnumberofclusters;
1594
1595           //Copy Multiplicity information 
1596           fTreeCascVarCentV0A = fCentrality_V0A; 
1597           fTreeCascVarCentV0C = fCentrality_V0C; 
1598           fTreeCascVarCentV0M = fCentrality_V0M; 
1599           fTreeCascVarCentV0AEq = fCentrality_V0AEq; 
1600           fTreeCascVarCentV0CEq = fCentrality_V0CEq; 
1601           fTreeCascVarCentV0MEq = fCentrality_V0MEq; 
1602           fTreeCascVarAmpV0A = fAmplitude_V0A; 
1603           fTreeCascVarAmpV0C = fAmplitude_V0C; 
1604           fTreeCascVarAmpV0AEq = fAmplitude_V0AEq; 
1605           fTreeCascVarAmpV0CEq = fAmplitude_V0CEq; 
1606           fTreeCascVarRefMultEta8 = fRefMultEta8;
1607           fTreeCascVarRefMultEta5 = fRefMultEta5;
1608
1609           fTreeCascVarDistOverTotMom = TMath::Sqrt(
1610                                                 TMath::Power( lPosXi[0] - lBestPrimaryVtxPos[0] , 2) +
1611                                                 TMath::Power( lPosXi[1] - lBestPrimaryVtxPos[1] , 2) +
1612                                                 TMath::Power( lPosXi[2] - lBestPrimaryVtxPos[2] , 2)
1613                                         );
1614           fTreeCascVarDistOverTotMom /= (lXiTotMom+1e-13);
1615
1616 //All vars not specified here: specified elsewhere!
1617
1618 //------------------------------------------------
1619 // Fill Tree! 
1620 //------------------------------------------------
1621
1622 // The conditional is meant to decrease excessive
1623 // memory usage! Be careful when loosening the 
1624 // cut!
1625
1626   //Xi    Mass window: 150MeV wide
1627   //Omega mass window: 150MeV wide
1628
1629   if( fkSaveCascadeTree && ( (fTreeCascVarMassAsXi<1.32+0.075&&fTreeCascVarMassAsXi>1.32-0.075) ||
1630       (fTreeCascVarMassAsOmega<1.68+0.075&&fTreeCascVarMassAsOmega>1.68-0.075) ) ){
1631       fTreeCascade->Fill();
1632   }
1633
1634 //------------------------------------------------
1635 // Fill tree over.
1636 //------------------------------------------------
1637
1638         }// end of the Cascade loop (ESD or AOD)
1639
1640   // Post output data.
1641   PostData(1, fListHist); 
1642   PostData(2, fTreeEvent);
1643   PostData(3, fTreeV0);
1644   PostData(4, fTreeCascade);
1645 }
1646
1647 //________________________________________________________________________
1648 void AliAnalysisTaskStrangenessVsMultiplicityMC::Terminate(Option_t *)
1649 {
1650    // Draw result to the screen
1651    // Called once at the end of the query
1652
1653    TList *cRetrievedList = 0x0;
1654    cRetrievedList = (TList*)GetOutputData(1);
1655    if(!cRetrievedList){
1656       Printf("ERROR - AliAnalysisTaskStrangenessVsMultiplicityMC : ouput data container list not available\n");
1657       return;
1658    }    
1659         
1660    fHistEventCounter = dynamic_cast<TH1D*> (  cRetrievedList->FindObject("fHistEventCounter")  );
1661    if (!fHistEventCounter) {
1662       Printf("ERROR - AliAnalysisTaskStrangenessVsMultiplicityMC : fHistEventCounter not available");
1663       return;
1664    }
1665   
1666    TCanvas *canCheck = new TCanvas("AliAnalysisTaskStrangenessVsMultiplicityMC","V0 Multiplicity",10,10,510,510);
1667    canCheck->cd(1)->SetLogy();
1668
1669    fHistEventCounter->SetMarkerStyle(22);
1670    fHistEventCounter->DrawCopy("E");
1671 }
1672
1673 //----------------------------------------------------------------------------
1674
1675 Double_t AliAnalysisTaskStrangenessVsMultiplicityMC::MyRapidity(Double_t rE, Double_t rPz) const
1676 {
1677    // Local calculation for rapidity
1678    Double_t ReturnValue = -100;
1679    if( (rE-rPz+1.e-13) != 0 && (rE+rPz) != 0 ){ 
1680       ReturnValue =  0.5*TMath::Log((rE+rPz)/(rE-rPz+1.e-13));
1681    }
1682    return ReturnValue;
1683