9acb2fbf4777c7487db10fb6a8e1d3024c824fa5
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / AliAnalysisTaskExtractCascade.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 // Modified version of AliAnalysisTaskCheckCascade.cxx.
19 // This is a 'hybrid' output version, in that it uses a classic TTree
20 // ROOT object to store the candidates, plus a couple of histograms filled on
21 // a per-event basis for storing variables too numerous to put in a tree.
22 //
23 //
24 //  --- Algorithm Description
25 //   1. Loop over primaries in stack to acquire generated charged Xi
26 //   2. Loop over stack to find Cascades, fill TH3Fs "PrimRawPt"s for Efficiency
27 //   3. Perform Physics Selection
28 //   4. Perform Primary Vertex |z|<10cm selection
29 //   5. Perform Primary Vertex NoTPCOnly vertexing selection
30 //   6. Perform Pileup Rejection
31 //   7. Analysis Loops:
32 //    7a. Fill TH3Fs "PrimAnalysisPt" for control purposes only
33 //
34 //  Please Report Any Bugs!
35 //
36 //   --- David Dobrigkeit Chinellato
37 //        (david.chinellato@gmail.com)
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 "AliESDpid.h"
70 #include "AliESDtrack.h"
71 #include "AliESDtrackCuts.h"
72 #include "AliInputEventHandler.h"
73 #include "AliAnalysisManager.h"
74 #include "AliMCEventHandler.h"
75 #include "AliMCEvent.h"
76 #include "AliStack.h"
77
78 #include "AliLightV0vertexer.h"
79 #include "AliLightCascadeVertexer.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 "AliAnalysisUtils.h"
89
90 #include "AliAnalysisTaskExtractCascade.h"
91
92 using std::cout;
93 using std::endl;
94
95 ClassImp(AliAnalysisTaskExtractCascade)
96
97 AliAnalysisTaskExtractCascade::AliAnalysisTaskExtractCascade()
98 : AliAnalysisTaskSE(), fListHist(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), fUtils(0),
99 fkIsNuclear   ( kFALSE ),
100 fkSwitchINT7  ( kFALSE ),
101 fCentralityEstimator("V0M"),
102 fkpAVertexSelection( kFALSE ),
103 fEtaRefMult ( 0.5 ),
104 fkRunVertexers ( kFALSE ),
105 fkDebugMode (kTRUE),
106 fkSelectCentrality (kFALSE),
107 fCentSel_Low(0.0),
108 fCentSel_High(0.0),
109 fLowPtCutoff(0.0),
110 //------------------------------------------------
111 // Tree Variables
112 //------------------------------------------------
113
114 fTreeCascVarCharge(0),
115 fTreeCascVarMassAsXi(0),
116 fTreeCascVarMassAsOmega(0),
117 fTreeCascVarPt(0),
118 fTreeCascVarPtMC(0),
119 fTreeCascVarRapMC(0),
120 fTreeCascVarRapXi(0),
121 fTreeCascVarRapOmega(0),
122 fTreeCascVarNegEta(0),
123 fTreeCascVarPosEta(0),
124 fTreeCascVarBachEta(0),
125 fTreeCascVarDCACascDaughters(0),
126 fTreeCascVarDCABachToPrimVtx(0),
127 fTreeCascVarDCAV0Daughters(0),
128 fTreeCascVarDCAV0ToPrimVtx(0),
129 fTreeCascVarDCAPosToPrimVtx(0),
130 fTreeCascVarDCANegToPrimVtx(0),
131 fTreeCascVarCascCosPointingAngle(0),
132 fTreeCascVarCascRadius(0),
133 fTreeCascVarV0Mass(0),
134 fTreeCascVarV0CosPointingAngle(0),
135 fTreeCascVarV0CosPointingAngleSpecial(0),
136 fTreeCascVarV0Radius(0),
137 fTreeCascVarLeastNbrClusters(0),
138 fTreeCascVarMultiplicity(0),
139 fTreeCascVarMultiplicityV0A(0),
140 fTreeCascVarMultiplicityZNA(0),
141 fTreeCascVarMultiplicityTRK(0),
142 fTreeCascVarMultiplicitySPD(0),
143 fTreeCascVarDistOverTotMom(0),
144 fTreeCascVarPID(0),
145 fTreeCascVarPIDBachelor(0),
146 fTreeCascVarPIDNegative(0),
147 fTreeCascVarPIDPositive(0),
148 fTreeCascVarBachTransMom(0),
149 fTreeCascVarPosTransMom(0),
150 fTreeCascVarNegTransMom(0),
151 fTreeCascVarPosTransMomMC(0),
152 fTreeCascVarNegTransMomMC(0),
153 fTreeCascVarNegNSigmaPion(0),
154 fTreeCascVarNegNSigmaProton(0),
155 fTreeCascVarPosNSigmaPion(0),
156 fTreeCascVarPosNSigmaProton(0),
157 fTreeCascVarBachNSigmaPion(0),
158 fTreeCascVarBachNSigmaKaon(0),
159
160 fTreeCascVarkITSRefitBachelor(0),
161 fTreeCascVarkITSRefitNegative(0),
162 fTreeCascVarkITSRefitPositive(0),
163
164 //Debug information
165 //Part A: EbyE info, Run number
166 fTreeCascVarRunNumber(0),
167 fTreeCascVarEventNumber(0),
168
169 //Part B: Shared Clusters
170 fTreeCascVarNegClusters(0),
171 fTreeCascVarPosClusters(0),
172 fTreeCascVarBachClusters(0),
173 fTreeCascVarNegSharedClusters(0),
174 fTreeCascVarPosSharedClusters(0),
175 fTreeCascVarBachSharedClusters(0),
176
177 //Part C: All momenta
178 fTreeCascVarNegPx(0),
179 fTreeCascVarNegPy(0),
180 fTreeCascVarNegPz(0),
181 fTreeCascVarPosPx(0),
182 fTreeCascVarPosPy(0),
183 fTreeCascVarPosPz(0),
184 fTreeCascVarBachPx(0),
185 fTreeCascVarBachPy(0),
186 fTreeCascVarBachPz(0),
187
188 fTreeCascVarV0DecayX(0),
189 fTreeCascVarV0DecayY(0),
190 fTreeCascVarV0DecayZ(0),
191
192 fTreeCascVarCascadeDecayX(0),
193 fTreeCascVarCascadeDecayY(0),
194 fTreeCascVarCascadeDecayZ(0),
195
196 fTreeCascVarBadCascadeJai(0),
197 fTreeCascVarDeltaDCA(0),
198
199 //------------------------------------------------
200 // HISTOGRAMS
201 // --- Filled on an Event-by-event basis
202 //------------------------------------------------
203 fHistV0MultiplicityBeforeTrigSel(0),
204 fHistV0MultiplicityForTrigEvt(0),
205 fHistV0MultiplicityForSelEvt(0),
206 fHistV0MultiplicityForSelEvtNoTPCOnly(0),
207 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup(0),
208 fHistMultiplicityBeforeTrigSel(0),
209 fHistMultiplicityForTrigEvt(0),
210 fHistMultiplicity(0),
211 fHistMultiplicityNoTPCOnly(0),
212 fHistMultiplicityNoTPCOnlyNoPileup(0),
213
214 //V0A Centrality
215 fHistMultiplicityV0ABeforeTrigSel(0),
216 fHistMultiplicityV0AForTrigEvt(0),
217 fHistMultiplicityV0A(0),
218 fHistMultiplicityV0ANoTPCOnly(0),
219 fHistMultiplicityV0ANoTPCOnlyNoPileup(0),
220
221 //ZNA Centrality
222 fHistMultiplicityZNABeforeTrigSel(0),
223 fHistMultiplicityZNAForTrigEvt(0),
224 fHistMultiplicityZNA(0),
225 fHistMultiplicityZNANoTPCOnly(0),
226 fHistMultiplicityZNANoTPCOnlyNoPileup(0),
227
228 //TRK Centrality
229 fHistMultiplicityTRKBeforeTrigSel(0),
230 fHistMultiplicityTRKForTrigEvt(0),
231 fHistMultiplicityTRK(0),
232 fHistMultiplicityTRKNoTPCOnly(0),
233 fHistMultiplicityTRKNoTPCOnlyNoPileup(0),
234
235 //SPD Centrality
236 fHistMultiplicitySPDBeforeTrigSel(0),
237 fHistMultiplicitySPDForTrigEvt(0),
238 fHistMultiplicitySPD(0),
239 fHistMultiplicitySPDNoTPCOnly(0),
240 fHistMultiplicitySPDNoTPCOnlyNoPileup(0),
241
242 fHistPVx(0),
243 fHistPVy(0),
244 fHistPVz(0),
245 fHistPVxAnalysis(0),
246 fHistPVyAnalysis(0),
247 fHistPVzAnalysis(0),
248
249 //Superlight !
250 fkLight(kTRUE),
251 fkSuperLight(kFALSE),
252 fCut_V0Radius(1.2),
253 fCut_CascRadius(0.6),
254 fCut_V0Mass(0.008),
255 fCut_V0CosPA(0.97),
256 fCut_CascCosPA(0.97),
257 fCut_DCANegToPV(0.03),
258 fCut_DCAPosToPV(0.03),
259 fCut_DCABachToPV(0.04),
260 fCut_DCAV0Daughters(1.5),
261 fCut_DCACascDaughters(1.3),
262 fCut_DCAV0ToPV(0.06),
263 fCut_CTau(15),
264 f2dHist_MassVsPt_XiMinus(0),
265 f2dHist_MassVsPt_XiPlus(0),
266 f2dHist_MassVsPt_OmegaMinus(0),
267 f2dHist_MassVsPt_OmegaPlus(0)
268 {
269     // Dummy Constructor
270 }
271
272 AliAnalysisTaskExtractCascade::AliAnalysisTaskExtractCascade(const char *name)
273 : AliAnalysisTaskSE(name), fListHist(0), fTreeCascade(0), fPIDResponse(0), fESDtrackCuts(0), fUtils(0),
274 fkIsNuclear   ( kFALSE ),
275 fkSwitchINT7  ( kFALSE ),
276 fCentralityEstimator("V0M"),
277 fkpAVertexSelection( kFALSE ),
278 fEtaRefMult ( 0.5 ),
279 fkRunVertexers ( kFALSE ),
280 fkDebugMode (kTRUE),
281 fkSelectCentrality (kFALSE),
282 fCentSel_Low(0.0),
283 fCentSel_High(0.0),
284 fLowPtCutoff(0.0),
285 //------------------------------------------------
286 // Tree Variables
287 //------------------------------------------------
288
289 fTreeCascVarCharge(0),
290 fTreeCascVarMassAsXi(0),
291 fTreeCascVarMassAsOmega(0),
292 fTreeCascVarPt(0),
293 fTreeCascVarPtMC(0),
294 fTreeCascVarRapMC(0),
295 fTreeCascVarRapXi(0),
296 fTreeCascVarRapOmega(0),
297 fTreeCascVarNegEta(0),
298 fTreeCascVarPosEta(0),
299 fTreeCascVarBachEta(0),
300 fTreeCascVarDCACascDaughters(0),
301 fTreeCascVarDCABachToPrimVtx(0),
302 fTreeCascVarDCAV0Daughters(0),
303 fTreeCascVarDCAV0ToPrimVtx(0),
304 fTreeCascVarDCAPosToPrimVtx(0),
305 fTreeCascVarDCANegToPrimVtx(0),
306 fTreeCascVarCascCosPointingAngle(0),
307 fTreeCascVarCascRadius(0),
308 fTreeCascVarV0Mass(0),
309 fTreeCascVarV0CosPointingAngle(0),
310 fTreeCascVarV0CosPointingAngleSpecial(0),
311 fTreeCascVarV0Radius(0),
312 fTreeCascVarLeastNbrClusters(0),
313 fTreeCascVarMultiplicity(0),
314 fTreeCascVarMultiplicityV0A(0),
315 fTreeCascVarMultiplicityZNA(0),
316 fTreeCascVarMultiplicityTRK(0),
317 fTreeCascVarMultiplicitySPD(0),
318 fTreeCascVarDistOverTotMom(0),
319 fTreeCascVarPID(0),
320 fTreeCascVarPIDBachelor(0),
321 fTreeCascVarPIDNegative(0),
322 fTreeCascVarPIDPositive(0),
323 fTreeCascVarBachTransMom(0),
324 fTreeCascVarPosTransMom(0),
325 fTreeCascVarNegTransMom(0),
326 fTreeCascVarPosTransMomMC(0),
327 fTreeCascVarNegTransMomMC(0),
328 fTreeCascVarNegNSigmaPion(0),
329 fTreeCascVarNegNSigmaProton(0),
330 fTreeCascVarPosNSigmaPion(0),
331 fTreeCascVarPosNSigmaProton(0),
332 fTreeCascVarBachNSigmaPion(0),
333 fTreeCascVarBachNSigmaKaon(0),
334
335 fTreeCascVarkITSRefitBachelor(0),
336 fTreeCascVarkITSRefitNegative(0),
337 fTreeCascVarkITSRefitPositive(0),
338
339 //Debug information
340 //Part A: EbyE info, Run number
341 fTreeCascVarRunNumber(0),
342 fTreeCascVarEventNumber(0),
343
344 //Part B: Shared Clusters
345 fTreeCascVarNegClusters(0),
346 fTreeCascVarPosClusters(0),
347 fTreeCascVarBachClusters(0),
348 fTreeCascVarNegSharedClusters(0),
349 fTreeCascVarPosSharedClusters(0),
350 fTreeCascVarBachSharedClusters(0),
351
352 //Part C: All momenta
353 fTreeCascVarNegPx(0),
354 fTreeCascVarNegPy(0),
355 fTreeCascVarNegPz(0),
356 fTreeCascVarPosPx(0),
357 fTreeCascVarPosPy(0),
358 fTreeCascVarPosPz(0),
359 fTreeCascVarBachPx(0),
360 fTreeCascVarBachPy(0),
361 fTreeCascVarBachPz(0),
362
363 fTreeCascVarV0DecayX(0),
364 fTreeCascVarV0DecayY(0),
365 fTreeCascVarV0DecayZ(0),
366
367 fTreeCascVarCascadeDecayX(0),
368 fTreeCascVarCascadeDecayY(0),
369 fTreeCascVarCascadeDecayZ(0),
370
371 fTreeCascVarBadCascadeJai(0),
372 fTreeCascVarDeltaDCA(0),
373
374
375 //------------------------------------------------
376 // HISTOGRAMS
377 // --- Filled on an Event-by-event basis
378 //------------------------------------------------
379 fHistV0MultiplicityBeforeTrigSel(0),
380 fHistV0MultiplicityForTrigEvt(0),
381 fHistV0MultiplicityForSelEvt(0),
382 fHistV0MultiplicityForSelEvtNoTPCOnly(0),
383 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup(0),
384 fHistMultiplicityBeforeTrigSel(0),
385 fHistMultiplicityForTrigEvt(0),
386 fHistMultiplicity(0),
387 fHistMultiplicityNoTPCOnly(0),
388 fHistMultiplicityNoTPCOnlyNoPileup(0),
389
390 //V0A Centrality
391 fHistMultiplicityV0ABeforeTrigSel(0),
392 fHistMultiplicityV0AForTrigEvt(0),
393 fHistMultiplicityV0A(0),
394 fHistMultiplicityV0ANoTPCOnly(0),
395 fHistMultiplicityV0ANoTPCOnlyNoPileup(0),
396
397 //ZNA Centrality
398 fHistMultiplicityZNABeforeTrigSel(0),
399 fHistMultiplicityZNAForTrigEvt(0),
400 fHistMultiplicityZNA(0),
401 fHistMultiplicityZNANoTPCOnly(0),
402 fHistMultiplicityZNANoTPCOnlyNoPileup(0),
403
404 //TRK Centrality
405 fHistMultiplicityTRKBeforeTrigSel(0),
406 fHistMultiplicityTRKForTrigEvt(0),
407 fHistMultiplicityTRK(0),
408 fHistMultiplicityTRKNoTPCOnly(0),
409 fHistMultiplicityTRKNoTPCOnlyNoPileup(0),
410
411 //SPD Centrality
412 fHistMultiplicitySPDBeforeTrigSel(0),
413 fHistMultiplicitySPDForTrigEvt(0),
414 fHistMultiplicitySPD(0),
415 fHistMultiplicitySPDNoTPCOnly(0),
416 fHistMultiplicitySPDNoTPCOnlyNoPileup(0),
417
418 fHistPVx(0),
419 fHistPVy(0),
420 fHistPVz(0),
421 fHistPVxAnalysis(0),
422 fHistPVyAnalysis(0),
423 fHistPVzAnalysis(0),
424
425 //Superlight !
426 fkLight(kTRUE),
427 fkSuperLight(kFALSE),
428 fCut_V0Radius(1.2),
429 fCut_CascRadius(0.6),
430 fCut_V0Mass(0.008),
431 fCut_V0CosPA(0.97),
432 fCut_CascCosPA(0.97),
433 fCut_DCANegToPV(0.03),
434 fCut_DCAPosToPV(0.03),
435 fCut_DCABachToPV(0.04),
436 fCut_DCAV0Daughters(1.5),
437 fCut_DCACascDaughters(1.3),
438 fCut_DCAV0ToPV(0.06),
439 fCut_CTau(15),
440 f2dHist_MassVsPt_XiMinus(0),
441 f2dHist_MassVsPt_XiPlus(0),
442 f2dHist_MassVsPt_OmegaMinus(0),
443 f2dHist_MassVsPt_OmegaPlus(0)
444
445 {
446     // Constructor
447     
448     //Set Variables for re-running the cascade vertexers (as done for MS paper)
449     
450     // New Loose : 1st step for the 7 TeV pp analysis
451     
452     fV0VertexerSels[0] =  33.  ;  // max allowed chi2
453     fV0VertexerSels[1] =   0.02;  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
454     fV0VertexerSels[2] =   0.02;  // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
455     fV0VertexerSels[3] =   2.0 ;  // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
456     fV0VertexerSels[4] =   0.95;  // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
457     fV0VertexerSels[5] =   1.0 ;  // min radius of the fiducial volume                 (LHC09a4 : 0.2)
458     fV0VertexerSels[6] = 200.  ;  // max radius of the fiducial volume                 (LHC09a4 : 100.0)
459     
460     fCascadeVertexerSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
461     fCascadeVertexerSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
462     fCascadeVertexerSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
463     fCascadeVertexerSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
464     fCascadeVertexerSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
465     fCascadeVertexerSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
466     fCascadeVertexerSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
467     fCascadeVertexerSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
468     
469     // Output slot #0 writes into a TList container (Cascade)
470     DefineOutput(1, TList::Class());
471     DefineOutput(2, TTree::Class());
472 }
473
474
475 AliAnalysisTaskExtractCascade::~AliAnalysisTaskExtractCascade()
476 {
477     //------------------------------------------------
478     // DESTRUCTOR
479     //------------------------------------------------
480     
481     if (fListHist){
482         delete fListHist;
483         fListHist = 0x0;
484     }
485     if (fTreeCascade){
486         delete fTreeCascade;
487         fTreeCascade = 0x0;
488     }
489     //cleanup esd track cuts object too...
490     if (fESDtrackCuts){
491         delete fESDtrackCuts;
492         fESDtrackCuts = 0x0;
493     }
494     if (fUtils){
495         delete fUtils;
496         fUtils = 0x0;
497     }
498     
499 }
500
501 //________________________________________________________________________
502 void AliAnalysisTaskExtractCascade::UserCreateOutputObjects()
503 {
504     OpenFile(2);
505     // Called once
506     
507     //------------------------------------------------
508     
509     fTreeCascade = new TTree("fTreeCascade","CascadeCandidates");
510     
511     //------------------------------------------------
512     // fTreeCascade Branch definitions - Cascade Tree
513     //------------------------------------------------
514     
515     //------------------------------------------------
516     // fTreeCascade Branch definitions
517     //------------------------------------------------
518     
519     //-----------BASIC-INFO---------------------------
520     /* 1*/              fTreeCascade->Branch("fTreeCascVarCharge",&fTreeCascVarCharge,"fTreeCascVarCharge/I");
521     /* 2*/              fTreeCascade->Branch("fTreeCascVarMassAsXi",&fTreeCascVarMassAsXi,"fTreeCascVarMassAsXi/F");
522     /* 3*/              fTreeCascade->Branch("fTreeCascVarMassAsOmega",&fTreeCascVarMassAsOmega,"fTreeCascVarMassAsOmega/F");
523     /* 4*/              fTreeCascade->Branch("fTreeCascVarPt",&fTreeCascVarPt,"fTreeCascVarPt/F");
524     /* 5*/              fTreeCascade->Branch("fTreeCascVarRapXi",&fTreeCascVarRapXi,"fTreeCascVarRapXi/F");
525     /* 6*/              fTreeCascade->Branch("fTreeCascVarRapOmega",&fTreeCascVarRapOmega,"fTreeCascVarRapOmega/F");
526     /* 7*/              fTreeCascade->Branch("fTreeCascVarNegEta",&fTreeCascVarNegEta,"fTreeCascVarNegEta/F");
527     /* 8*/              fTreeCascade->Branch("fTreeCascVarPosEta",&fTreeCascVarPosEta,"fTreeCascVarPosEta/F");
528     /* 9*/              fTreeCascade->Branch("fTreeCascVarBachEta",&fTreeCascVarBachEta,"fTreeCascVarBachEta/F");
529     //-----------INFO-FOR-CUTS------------------------
530     /*10*/              fTreeCascade->Branch("fTreeCascVarDCACascDaughters",&fTreeCascVarDCACascDaughters,"fTreeCascVarDCACascDaughters/F");
531     /*11*/              fTreeCascade->Branch("fTreeCascVarDCABachToPrimVtx",&fTreeCascVarDCABachToPrimVtx,"fTreeCascVarDCABachToPrimVtx/F");
532     /*12*/              fTreeCascade->Branch("fTreeCascVarDCAV0Daughters",&fTreeCascVarDCAV0Daughters,"fTreeCascVarDCAV0Daughters/F");
533     /*13*/              fTreeCascade->Branch("fTreeCascVarDCAV0ToPrimVtx",&fTreeCascVarDCAV0ToPrimVtx,"fTreeCascVarDCAV0ToPrimVtx/F");
534     /*14*/              fTreeCascade->Branch("fTreeCascVarDCAPosToPrimVtx",&fTreeCascVarDCAPosToPrimVtx,"fTreeCascVarDCAPosToPrimVtx/F");
535     /*15*/              fTreeCascade->Branch("fTreeCascVarDCANegToPrimVtx",&fTreeCascVarDCANegToPrimVtx,"fTreeCascVarDCANegToPrimVtx/F");
536     /*16*/              fTreeCascade->Branch("fTreeCascVarCascCosPointingAngle",&fTreeCascVarCascCosPointingAngle,"fTreeCascVarCascCosPointingAngle/F");
537     /*17*/              fTreeCascade->Branch("fTreeCascVarCascRadius",&fTreeCascVarCascRadius,"fTreeCascVarCascRadius/F");
538     /*18*/              fTreeCascade->Branch("fTreeCascVarV0Mass",&fTreeCascVarV0Mass,"fTreeCascVarV0Mass/F");
539     /*19*/              fTreeCascade->Branch("fTreeCascVarV0CosPointingAngle",&fTreeCascVarV0CosPointingAngle,"fTreeCascVarV0CosPointingAngle/F");
540     /*19*/              fTreeCascade->Branch("fTreeCascVarV0CosPointingAngleSpecial",&fTreeCascVarV0CosPointingAngleSpecial,"fTreeCascVarV0CosPointingAngleSpecial/F");
541     /*20*/              fTreeCascade->Branch("fTreeCascVarV0Radius",&fTreeCascVarV0Radius,"fTreeCascVarV0Radius/F");
542     /*21*/              fTreeCascade->Branch("fTreeCascVarLeastNbrClusters",&fTreeCascVarLeastNbrClusters,"fTreeCascVarLeastNbrClusters/I");
543     //-----------MULTIPLICITY-INFO--------------------
544     /*22*/              fTreeCascade->Branch("fTreeCascVarMultiplicity",&fTreeCascVarMultiplicity,"fTreeCascVarMultiplicity/I");
545     /*22*/              fTreeCascade->Branch("fTreeCascVarMultiplicityV0A",&fTreeCascVarMultiplicityV0A,"fTreeCascVarMultiplicityV0A/I");
546     /*22*/              fTreeCascade->Branch("fTreeCascVarMultiplicityZNA",&fTreeCascVarMultiplicityZNA,"fTreeCascVarMultiplicityZNA/I");
547     /*22*/              fTreeCascade->Branch("fTreeCascVarMultiplicityTRK",&fTreeCascVarMultiplicityTRK,"fTreeCascVarMultiplicityTRK/I");
548     /*22*/              fTreeCascade->Branch("fTreeCascVarMultiplicitySPD",&fTreeCascVarMultiplicitySPD,"fTreeCascVarMultiplicitySPD/I");
549     //-----------DECAY-LENGTH-INFO--------------------
550     /*23*/              fTreeCascade->Branch("fTreeCascVarDistOverTotMom",&fTreeCascVarDistOverTotMom,"fTreeCascVarDistOverTotMom/F");
551     //------------------------------------------------
552     /*24*/              fTreeCascade->Branch("fTreeCascVarNegNSigmaPion",&fTreeCascVarNegNSigmaPion,"fTreeCascVarNegNSigmaPion/F");
553     /*25*/              fTreeCascade->Branch("fTreeCascVarNegNSigmaProton",&fTreeCascVarNegNSigmaProton,"fTreeCascVarNegNSigmaProton/F");
554     /*26*/              fTreeCascade->Branch("fTreeCascVarPosNSigmaPion",&fTreeCascVarPosNSigmaPion,"fTreeCascVarPosNSigmaPion/F");
555     /*27*/              fTreeCascade->Branch("fTreeCascVarPosNSigmaProton",&fTreeCascVarPosNSigmaProton,"fTreeCascVarPosNSigmaProton/F");
556     /*28*/              fTreeCascade->Branch("fTreeCascVarBachNSigmaPion",&fTreeCascVarBachNSigmaPion,"fTreeCascVarBachNSigmaPion/F");
557     /*29*/              fTreeCascade->Branch("fTreeCascVarBachNSigmaKaon",&fTreeCascVarBachNSigmaKaon,"fTreeCascVarBachNSigmaKaon/F");
558     
559     //Commented out: not needed since all momenta provided! (less info)
560     /*30*/              //fTreeCascade->Branch("fTreeCascVarBachTransMom",&fTreeCascVarBachTransMom,"fTreeCascVarBachTransMom/F");
561     /*30*/              //fTreeCascade->Branch("fTreeCascVarPosTransMom",&fTreeCascVarPosTransMom,"fTreeCascVarPosTransMom/F");
562     /*31*/              //fTreeCascade->Branch("fTreeCascVarNegTransMom",&fTreeCascVarNegTransMom,"fTreeCascVarNegTransMom/F");
563     
564     /*29*/              fTreeCascade->Branch("fTreeCascVarkITSRefitBachelor",&fTreeCascVarkITSRefitBachelor,"fTreeCascVarkITSRefitBachelor/O");
565     /*29*/              fTreeCascade->Branch("fTreeCascVarkITSRefitNegative",&fTreeCascVarkITSRefitNegative,"fTreeCascVarkITSRefitNegative/O");
566     /*29*/              fTreeCascade->Branch("fTreeCascVarkITSRefitPositive",&fTreeCascVarkITSRefitPositive,"fTreeCascVarkITSRefitPositive/O");
567     
568     //-----------Debugging information----------------
569     
570     if(fkDebugMode){
571         //Only save this if requested - can be turned off
572         
573         //Part A: Event-by-event, run-by-run debugging
574         fTreeCascade->Branch("fTreeCascVarRunNumber",&fTreeCascVarRunNumber,"fTreeCascVarRunNumber/I");
575         fTreeCascade->Branch("fTreeCascVarEventNumber",&fTreeCascVarEventNumber,"fTreeCascVarEventNumber/l");
576         
577         //Part B: Shared Clusters for all daughter tracks
578         fTreeCascade->Branch("fTreeCascVarNegClusters",&fTreeCascVarNegClusters,"fTreeCascVarNegClusters/I");
579         fTreeCascade->Branch("fTreeCascVarPosClusters",&fTreeCascVarPosClusters,"fTreeCascVarPosClusters/I");
580         fTreeCascade->Branch("fTreeCascVarBachClusters",&fTreeCascVarBachClusters,"fTreeCascVarBachClusters/I");
581         fTreeCascade->Branch("fTreeCascVarNegSharedClusters",&fTreeCascVarNegSharedClusters,"fTreeCascVarNegSharedClusters/I");
582         fTreeCascade->Branch("fTreeCascVarPosSharedClusters",&fTreeCascVarPosSharedClusters,"fTreeCascVarPosSharedClusters/I");
583         fTreeCascade->Branch("fTreeCascVarBachSharedClusters",&fTreeCascVarBachSharedClusters,"fTreeCascVarBachSharedClusters/I");
584         
585         //Part C: All Momenta of all daughters
586         fTreeCascade->Branch("fTreeCascVarNegPx",&fTreeCascVarNegPx,"fTreeCascVarNegPx/F");
587         fTreeCascade->Branch("fTreeCascVarNegPy",&fTreeCascVarNegPy,"fTreeCascVarNegPy/F");
588         fTreeCascade->Branch("fTreeCascVarNegPz",&fTreeCascVarNegPz,"fTreeCascVarNegPz/F");
589         fTreeCascade->Branch("fTreeCascVarPosPx",&fTreeCascVarPosPx,"fTreeCascVarPosPx/F");
590         fTreeCascade->Branch("fTreeCascVarPosPy",&fTreeCascVarPosPy,"fTreeCascVarPosPy/F");
591         fTreeCascade->Branch("fTreeCascVarPosPz",&fTreeCascVarPosPz,"fTreeCascVarPosPz/F");
592         fTreeCascade->Branch("fTreeCascVarBachPx",&fTreeCascVarBachPx,"fTreeCascVarBachPx/F");
593         fTreeCascade->Branch("fTreeCascVarBachPy",&fTreeCascVarBachPy,"fTreeCascVarBachPy/F");
594         fTreeCascade->Branch("fTreeCascVarBachPz",&fTreeCascVarBachPz,"fTreeCascVarBachPz/F");
595         
596         //Part D: Decay positions
597         fTreeCascade->Branch("fTreeCascVarV0DecayX",&fTreeCascVarV0DecayX,"fTreeCascVarV0DecayX/F");
598         fTreeCascade->Branch("fTreeCascVarV0DecayY",&fTreeCascVarV0DecayY,"fTreeCascVarV0DecayY/F");
599         fTreeCascade->Branch("fTreeCascVarV0DecayZ",&fTreeCascVarV0DecayZ,"fTreeCascVarV0DecayZ/F");
600         fTreeCascade->Branch("fTreeCascVarCascadeDecayX",&fTreeCascVarCascadeDecayX,"fTreeCascVarCascadeDecayX/F");
601         fTreeCascade->Branch("fTreeCascVarCascadeDecayY",&fTreeCascVarCascadeDecayY,"fTreeCascVarCascadeDecayY/F");
602         fTreeCascade->Branch("fTreeCascVarCascadeDecayZ",&fTreeCascVarCascadeDecayZ,"fTreeCascVarCascadeDecayZ/F");
603         
604         fTreeCascade->Branch("fTreeCascVarBadCascadeJai",&fTreeCascVarBadCascadeJai,"fTreeCascVarBadCascadeJai/O");
605         fTreeCascade->Branch("fTreeCascVarDeltaDCA",&fTreeCascVarDeltaDCA,"fTreeCascVarDeltaDCA/F");
606         //------------------------------------------------
607     }
608     
609     //------------------------------------------------
610     // Particle Identification Setup
611     //------------------------------------------------
612     
613     AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
614     AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
615     fPIDResponse = inputHandler->GetPIDResponse();
616     
617     // Multiplicity
618     
619     if(! fESDtrackCuts ){
620         fESDtrackCuts = new AliESDtrackCuts();
621     }
622     if(! fUtils ){
623         fUtils = new AliAnalysisUtils();
624     }
625     
626     //------------------------------------------------
627     // V0 Multiplicity Histograms
628     //------------------------------------------------
629     
630     // Create histograms
631     OpenFile(1);
632     fListHist = new TList();
633     fListHist->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
634     
635     
636     if(! fHistV0MultiplicityBeforeTrigSel) {
637         fHistV0MultiplicityBeforeTrigSel = new TH1F("fHistV0MultiplicityBeforeTrigSel",
638                                                     "V0s per event (before Trig. Sel.);Nbr of V0s/Evt;Events",
639                                                     25, 0, 25);
640         fListHist->Add(fHistV0MultiplicityBeforeTrigSel);
641     }
642     
643     if(! fHistV0MultiplicityForTrigEvt) {
644         fHistV0MultiplicityForTrigEvt = new TH1F("fHistV0MultiplicityForTrigEvt",
645                                                  "V0s per event (for triggered evt);Nbr of V0s/Evt;Events",
646                                                  25, 0, 25);
647         fListHist->Add(fHistV0MultiplicityForTrigEvt);
648     }
649     
650     if(! fHistV0MultiplicityForSelEvt) {
651         fHistV0MultiplicityForSelEvt = new TH1F("fHistV0MultiplicityForSelEvt",
652                                                 "V0s per event;Nbr of V0s/Evt;Events",
653                                                 25, 0, 25);
654         fListHist->Add(fHistV0MultiplicityForSelEvt);
655     }
656     
657     if(! fHistV0MultiplicityForSelEvtNoTPCOnly) {
658         fHistV0MultiplicityForSelEvtNoTPCOnly = new TH1F("fHistV0MultiplicityForSelEvtNoTPCOnly",
659                                                          "V0s per event;Nbr of V0s/Evt;Events",
660                                                          25, 0, 25);
661         fListHist->Add(fHistV0MultiplicityForSelEvtNoTPCOnly);
662     }
663     if(! fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup) {
664         fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup",
665                                                                  "V0s per event;Nbr of V0s/Evt;Events",
666                                                                  25, 0, 25);
667         fListHist->Add(fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup);
668     }
669     
670     //------------------------------------------------
671     // Track Multiplicity Histograms
672     //------------------------------------------------
673     
674     if(! fHistMultiplicityBeforeTrigSel) {
675         fHistMultiplicityBeforeTrigSel = new TH1F("fHistMultiplicityBeforeTrigSel",
676                                                   "Tracks per event;Nbr of Tracks;Events",
677                                                   200, 0, 200);
678         fListHist->Add(fHistMultiplicityBeforeTrigSel);
679     }
680     if(! fHistMultiplicityForTrigEvt) {
681         fHistMultiplicityForTrigEvt = new TH1F("fHistMultiplicityForTrigEvt",
682                                                "Tracks per event;Nbr of Tracks;Events",
683                                                200, 0, 200);
684         fListHist->Add(fHistMultiplicityForTrigEvt);
685     }
686     if(! fHistMultiplicity) {
687         fHistMultiplicity = new TH1F("fHistMultiplicity",
688                                      "Tracks per event;Nbr of Tracks;Events",
689                                      200, 0, 200);
690         fListHist->Add(fHistMultiplicity);
691     }
692     if(! fHistMultiplicityNoTPCOnly) {
693         fHistMultiplicityNoTPCOnly = new TH1F("fHistMultiplicityNoTPCOnly",
694                                               "Tracks per event;Nbr of Tracks;Events",
695                                               200, 0, 200);
696         fListHist->Add(fHistMultiplicityNoTPCOnly);
697     }
698     if(! fHistMultiplicityNoTPCOnlyNoPileup) {
699         fHistMultiplicityNoTPCOnlyNoPileup = new TH1F("fHistMultiplicityNoTPCOnlyNoPileup",
700                                                       "Tracks per event;Nbr of Tracks;Events",
701                                                       200, 0, 200);
702         fListHist->Add(fHistMultiplicityNoTPCOnlyNoPileup);
703     }
704     
705     
706     //V0A Centrality (if PbPb / pPb)
707     if(! fHistMultiplicityV0ABeforeTrigSel) {
708         fHistMultiplicityV0ABeforeTrigSel = new TH1F("fHistMultiplicityV0ABeforeTrigSel",
709                                                      "Centrality Distribution: V0A;V0A Centrality;Events",
710                                                      200, 0, 200);
711         fListHist->Add(fHistMultiplicityV0ABeforeTrigSel);
712     }
713     if(! fHistMultiplicityV0AForTrigEvt) {
714         fHistMultiplicityV0AForTrigEvt = new TH1F("fHistMultiplicityV0AForTrigEvt",
715                                                   "Centrality Distribution: V0A;V0A Centrality;Events",
716                                                   200, 0, 200);
717         fListHist->Add(fHistMultiplicityV0AForTrigEvt);
718     }
719     if(! fHistMultiplicityV0A) {
720         fHistMultiplicityV0A = new TH1F("fHistMultiplicityV0A",
721                                         "Centrality Distribution: V0A;V0A Centrality;Events",
722                                         200, 0, 200);
723         fListHist->Add(fHistMultiplicityV0A);
724     }
725     if(! fHistMultiplicityV0ANoTPCOnly) {
726         fHistMultiplicityV0ANoTPCOnly = new TH1F("fHistMultiplicityV0ANoTPCOnly",
727                                                  "Centrality Distribution: V0A;V0A Centrality;Events",
728                                                  200, 0, 200);
729         fListHist->Add(fHistMultiplicityV0ANoTPCOnly);
730     }
731     if(! fHistMultiplicityV0ANoTPCOnlyNoPileup) {
732         fHistMultiplicityV0ANoTPCOnlyNoPileup = new TH1F("fHistMultiplicityV0ANoTPCOnlyNoPileup",
733                                                          "Centrality Distribution: V0A;V0A Centrality;Events",
734                                                          200, 0, 200);
735         fListHist->Add(fHistMultiplicityV0ANoTPCOnlyNoPileup);
736     }
737     
738     //ZNA Centrality (if PbPb / pPb)
739     if(! fHistMultiplicityZNABeforeTrigSel) {
740         fHistMultiplicityZNABeforeTrigSel = new TH1F("fHistMultiplicityZNABeforeTrigSel",
741                                                      "Centrality Distribution: ZNA;ZNA Centrality;Events",
742                                                      200, 0, 200);
743         fListHist->Add(fHistMultiplicityZNABeforeTrigSel);
744     }
745     if(! fHistMultiplicityZNAForTrigEvt) {
746         fHistMultiplicityZNAForTrigEvt = new TH1F("fHistMultiplicityZNAForTrigEvt",
747                                                   "Centrality Distribution: ZNA;ZNA Centrality;Events",
748                                                   200, 0, 200);
749         fListHist->Add(fHistMultiplicityZNAForTrigEvt);
750     }
751     if(! fHistMultiplicityZNA) {
752         fHistMultiplicityZNA = new TH1F("fHistMultiplicityZNA",
753                                         "Centrality Distribution: ZNA;ZNA Centrality;Events",
754                                         200, 0, 200);
755         fListHist->Add(fHistMultiplicityZNA);
756     }
757     if(! fHistMultiplicityZNANoTPCOnly) {
758         fHistMultiplicityZNANoTPCOnly = new TH1F("fHistMultiplicityZNANoTPCOnly",
759                                                  "Centrality Distribution: ZNA;ZNA Centrality;Events",
760                                                  200, 0, 200);
761         fListHist->Add(fHistMultiplicityZNANoTPCOnly);
762     }
763     if(! fHistMultiplicityZNANoTPCOnlyNoPileup) {
764         fHistMultiplicityZNANoTPCOnlyNoPileup = new TH1F("fHistMultiplicityZNANoTPCOnlyNoPileup",
765                                                          "Centrality Distribution: ZNA;ZNA Centrality;Events",
766                                                          200, 0, 200);
767         fListHist->Add(fHistMultiplicityZNANoTPCOnlyNoPileup);
768     }
769     
770     //TRK Centrality (if PbPb / pPb)
771     if(! fHistMultiplicityTRKBeforeTrigSel) {
772         fHistMultiplicityTRKBeforeTrigSel = new TH1F("fHistMultiplicityTRKBeforeTrigSel",
773                                                      "Centrality Distribution: TRK;TRK Centrality;Events",
774                                                      200, 0, 200);
775         fListHist->Add(fHistMultiplicityTRKBeforeTrigSel);
776     }
777     if(! fHistMultiplicityTRKForTrigEvt) {
778         fHistMultiplicityTRKForTrigEvt = new TH1F("fHistMultiplicityTRKForTrigEvt",
779                                                   "Centrality Distribution: TRK;TRK Centrality;Events",
780                                                   200, 0, 200);
781         fListHist->Add(fHistMultiplicityTRKForTrigEvt);
782     }
783     if(! fHistMultiplicityTRK) {
784         fHistMultiplicityTRK = new TH1F("fHistMultiplicityTRK",
785                                         "Centrality Distribution: TRK;TRK Centrality;Events",
786                                         200, 0, 200);
787         fListHist->Add(fHistMultiplicityTRK);
788     }
789     if(! fHistMultiplicityTRKNoTPCOnly) {
790         fHistMultiplicityTRKNoTPCOnly = new TH1F("fHistMultiplicityTRKNoTPCOnly",
791                                                  "Centrality Distribution: TRK;TRK Centrality;Events",
792                                                  200, 0, 200);
793         fListHist->Add(fHistMultiplicityTRKNoTPCOnly);
794     }
795     if(! fHistMultiplicityTRKNoTPCOnlyNoPileup) {
796         fHistMultiplicityTRKNoTPCOnlyNoPileup = new TH1F("fHistMultiplicityTRKNoTPCOnlyNoPileup",
797                                                          "Centrality Distribution: TRK;TRK Centrality;Events",
798                                                          200, 0, 200);
799         fListHist->Add(fHistMultiplicityTRKNoTPCOnlyNoPileup);
800     }
801     
802     //SPD Centrality (if PbPb / pPb)
803     if(! fHistMultiplicitySPDBeforeTrigSel) {
804         fHistMultiplicitySPDBeforeTrigSel = new TH1F("fHistMultiplicitySPDBeforeTrigSel",
805                                                      "Centrality Distribution: SPD;SPD Centrality;Events",
806                                                      200, 0, 200);
807         fListHist->Add(fHistMultiplicitySPDBeforeTrigSel);
808     }
809     if(! fHistMultiplicitySPDForTrigEvt) {
810         fHistMultiplicitySPDForTrigEvt = new TH1F("fHistMultiplicitySPDForTrigEvt",
811                                                   "Centrality Distribution: SPD;SPD Centrality;Events",
812                                                   200, 0, 200);
813         fListHist->Add(fHistMultiplicitySPDForTrigEvt);
814     }
815     if(! fHistMultiplicitySPD) {
816         fHistMultiplicitySPD = new TH1F("fHistMultiplicitySPD",
817                                         "Centrality Distribution: SPD;SPD Centrality;Events",
818                                         200, 0, 200);
819         fListHist->Add(fHistMultiplicitySPD);
820     }
821     if(! fHistMultiplicitySPDNoTPCOnly) {
822         fHistMultiplicitySPDNoTPCOnly = new TH1F("fHistMultiplicitySPDNoTPCOnly",
823                                                  "Centrality Distribution: SPD;SPD Centrality;Events",
824                                                  200, 0, 200);
825         fListHist->Add(fHistMultiplicitySPDNoTPCOnly);
826     }
827     if(! fHistMultiplicitySPDNoTPCOnlyNoPileup) {
828         fHistMultiplicitySPDNoTPCOnlyNoPileup = new TH1F("fHistMultiplicitySPDNoTPCOnlyNoPileup",
829                                                          "Centrality Distribution: SPD;SPD Centrality;Events",
830                                                          200, 0, 200);
831         fListHist->Add(fHistMultiplicitySPDNoTPCOnlyNoPileup);
832     }
833     
834     
835     //----------------------------------
836     // Primary Vertex Position Histos
837     //----------------------------------
838     
839     if(! fHistPVx) {
840         fHistPVx = new TH1F("fHistPVx",
841                             "PV x position;Nbr of Evts;x",
842                             2000, -0.5, 0.5);
843         fListHist->Add(fHistPVx);
844     }
845     if(! fHistPVy) {
846         fHistPVy = new TH1F("fHistPVy",
847                             "PV y position;Nbr of Evts;y",
848                             2000, -0.5, 0.5);
849         fListHist->Add(fHistPVy);
850     }
851     if(! fHistPVz) {
852         fHistPVz = new TH1F("fHistPVz",
853                             "PV z position;Nbr of Evts;z",
854                             400, -20, 20);
855         fListHist->Add(fHistPVz);
856     }
857     
858     if(! fHistPVxAnalysis) {
859         fHistPVxAnalysis = new TH1F("fHistPVxAnalysis",
860                                     "PV x position;Nbr of Evts;x",
861                                     2000, -0.5, 0.5);
862         fListHist->Add(fHistPVxAnalysis);
863     }
864     if(! fHistPVyAnalysis) {
865         fHistPVyAnalysis = new TH1F("fHistPVyAnalysis",
866                                     "PV y position;Nbr of Evts;y",
867                                     2000, -0.5, 0.5);
868         fListHist->Add(fHistPVyAnalysis);
869     }
870     if(! fHistPVzAnalysis) {
871         fHistPVzAnalysis = new TH1F("fHistPVzAnalysis",
872                                     "PV z position;Nbr of Evts;z",
873                                     400, -20, 20);
874         fListHist->Add(fHistPVzAnalysis);
875     }
876     
877     //Superlight analysis output for cross-checking
878     if(! f2dHist_MassVsPt_XiMinus) {
879         f2dHist_MassVsPt_XiMinus = new TH2F("f2dHist_MassVsPt_XiMinus","",
880                                             800,1.321-0.100,1.321+0.100,
881                                             100,0,10);
882         fListHist->Add(f2dHist_MassVsPt_XiMinus);
883     }
884     if(! f2dHist_MassVsPt_XiPlus) {
885         f2dHist_MassVsPt_XiPlus = new TH2F("f2dHist_MassVsPt_XiPlus","",
886                                            800,1.321-0.100,1.321+0.100,
887                                            100,0,10);
888         fListHist->Add(f2dHist_MassVsPt_XiPlus);
889     }
890     if(! f2dHist_MassVsPt_OmegaMinus) {
891         f2dHist_MassVsPt_OmegaMinus = new TH2F("f2dHist_MassVsPt_OmegaMinus","",
892                                                800,1.672-0.100,1.672+0.100,
893                                                100,0,10);
894         fListHist->Add(f2dHist_MassVsPt_OmegaMinus);
895     }
896     if(! f2dHist_MassVsPt_OmegaPlus) {
897         f2dHist_MassVsPt_OmegaPlus = new TH2F("f2dHist_MassVsPt_OmegaPlus","",
898                                               800,1.672-0.100,1.672+0.100,
899                                               100,0,10);
900         fListHist->Add(f2dHist_MassVsPt_OmegaPlus);
901     }
902     
903     //List of Histograms: Normal
904     PostData(1, fListHist);
905     
906     //TTree Object: Saved to base directory. Should cache to disk while saving.
907     //(Important to avoid excessive memory usage, particularly when merging)
908     PostData(2, fTreeCascade);
909     
910 }// end UserCreateOutputObjects
911
912
913 //________________________________________________________________________
914 void AliAnalysisTaskExtractCascade::UserExec(Option_t *)
915 {
916     // Main loop
917     // Called for each event
918     
919     AliESDEvent *lESDevent = 0x0;
920     
921     Int_t    lNumberOfV0s                      = -1;
922     Double_t lTrkgPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
923     Double_t lBestPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
924     Double_t lMagneticField                 = -10.;
925     
926     // Connect to the InputEvent
927     // After these lines, we should have an ESD/AOD event + the number of V0s in it.
928     
929     // Appropriate for ESD analysis!
930     
931     lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
932     if (!lESDevent) {
933         AliWarning("ERROR: lESDevent not available \n");
934         return;
935     }
936     
937     //--- Acquisition of exact event ID
938     fTreeCascVarRunNumber = lESDevent->GetRunNumber();
939     fTreeCascVarEventNumber =
940     ( ( ((ULong64_t)lESDevent->GetPeriodNumber() ) << 36 ) |
941      ( ((ULong64_t)lESDevent->GetOrbitNumber () ) << 12 ) |
942      ((ULong64_t)lESDevent->GetBunchCrossNumber() )  );
943     
944     
945     //------------------------------------------------
946     // Multiplicity Information Acquistion
947     //------------------------------------------------
948     
949     //REVISED multiplicity estimator after 'multiplicity day' (2011)
950     Int_t lMultiplicity = -100;
951     Int_t lMultiplicityV0A = -100;
952     Int_t lMultiplicityZNA = -100;
953     Int_t lMultiplicityTRK = -100;
954     Int_t lMultiplicitySPD = -100;
955     
956     //testing purposes
957     if(fkIsNuclear == kFALSE) lMultiplicity =  fESDtrackCuts->GetReferenceMultiplicity(lESDevent, AliESDtrackCuts::kTrackletsITSTPC,  fEtaRefMult );
958     
959     //---> If this is a nuclear collision, then go nuclear on "multiplicity" variable...
960     //---> Warning: Experimental
961     if(fkIsNuclear == kTRUE){
962         AliCentrality* centrality;
963         centrality = lESDevent->GetCentrality();
964         lMultiplicity = ( ( Int_t ) ( centrality->GetCentralityPercentile( fCentralityEstimator.Data() ) ) );
965         lMultiplicityV0A = ( ( Int_t ) ( centrality->GetCentralityPercentile(   "V0A" ) ) );
966         lMultiplicityZNA = ( ( Int_t ) ( centrality->GetCentralityPercentile(   "ZNA" ) ) );
967         lMultiplicityTRK = ( ( Int_t ) ( centrality->GetCentralityPercentile(   "TRK" ) ) );
968         lMultiplicitySPD = ( ( Int_t ) ( centrality->GetCentralityPercentile(   "CL1" ) ) );
969         if (centrality->GetQuality()>1) {
970             PostData(1, fListHist);
971             PostData(2, fTreeCascade);
972             return;
973         }
974     }
975     
976     if( fkSelectCentrality ){
977         if( lMultiplicity < fCentSel_Low || lMultiplicity >= fCentSel_High ){
978             //Event is outside desired centrality centrality in V0M!
979             PostData(1, fListHist);
980             PostData(2, fTreeCascade);
981             return;
982         }
983     }
984     
985     //Set variable for filling tree afterwards!
986     //---> pp case......: GetReferenceMultiplicity
987     //---> Pb-Pb case...: Centrality by V0M
988     
989     fTreeCascVarMultiplicity = lMultiplicity;
990     fTreeCascVarMultiplicityV0A = lMultiplicityV0A;
991     fTreeCascVarMultiplicityZNA = lMultiplicityZNA;
992     fTreeCascVarMultiplicityTRK = lMultiplicityTRK;
993     fTreeCascVarMultiplicitySPD = lMultiplicitySPD;
994     
995     fHistV0MultiplicityBeforeTrigSel->Fill ( lESDevent->GetNumberOfV0s() );
996     fHistMultiplicityBeforeTrigSel->Fill ( lMultiplicity );
997     fHistMultiplicityV0ABeforeTrigSel->Fill ( lMultiplicityV0A );
998     fHistMultiplicityZNABeforeTrigSel->Fill ( lMultiplicityZNA );
999     fHistMultiplicityTRKBeforeTrigSel->Fill ( lMultiplicityTRK );
1000     fHistMultiplicitySPDBeforeTrigSel->Fill ( lMultiplicitySPD );
1001     
1002     //------------------------------------------------
1003     // Physics Selection
1004     //------------------------------------------------
1005     
1006     UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1007     Bool_t isSelected = 0;
1008     isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
1009     
1010     //pA triggering: CINT7
1011     if( fkSwitchINT7 ) isSelected = (maskIsSelected & AliVEvent::kINT7) == AliVEvent::kINT7;
1012     
1013     //Standard Min-Bias Selection
1014     if ( ! isSelected ) {
1015         PostData(1, fListHist);
1016         PostData(2, fTreeCascade);
1017         return;
1018     }
1019     
1020     //------------------------------------------------
1021     // Rerun cascade vertexer!
1022     //------------------------------------------------
1023     
1024     if( fkRunVertexers ){
1025         lESDevent->ResetCascades();
1026         lESDevent->ResetV0s();
1027         
1028         AliLightV0vertexer lV0vtxer;
1029         AliLightCascadeVertexer lCascVtxer;
1030         
1031         lV0vtxer.SetDefaultCuts(fV0VertexerSels);
1032         lCascVtxer.SetDefaultCuts(fCascadeVertexerSels);
1033         
1034         lV0vtxer.Tracks2V0vertices(lESDevent);
1035         lCascVtxer.V0sTracks2CascadeVertices(lESDevent);
1036     }
1037     //------------------------------------------------
1038     // After Trigger Selection
1039     //------------------------------------------------
1040     
1041     lNumberOfV0s          = lESDevent->GetNumberOfV0s();
1042     
1043     //Set variable for filling tree afterwards!
1044     fHistV0MultiplicityForTrigEvt->Fill(lNumberOfV0s);
1045     fHistMultiplicityForTrigEvt->Fill ( lMultiplicity );
1046     fHistMultiplicityV0AForTrigEvt       ->Fill( lMultiplicityV0A  );
1047     fHistMultiplicityZNAForTrigEvt       ->Fill( lMultiplicityZNA  );
1048     fHistMultiplicityTRKForTrigEvt       ->Fill( lMultiplicityTRK  );
1049     fHistMultiplicitySPDForTrigEvt       ->Fill( lMultiplicitySPD  );
1050     
1051     //------------------------------------------------
1052     // Getting: Primary Vertex + MagField Info
1053     //------------------------------------------------
1054     
1055     const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
1056     // get the vtx stored in ESD found with tracks
1057     lPrimaryTrackingESDVtx->GetXYZ( lTrkgPrimaryVtxPos );
1058     
1059     const AliESDVertex *lPrimaryBestESDVtx = lESDevent->GetPrimaryVertex();
1060     // get the best primary vertex available for the event
1061     // As done in AliCascadeVertexer, we keep the one which is the best one available.
1062     // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
1063     // This one will be used for next calculations (DCA essentially)
1064     lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
1065     
1066     Double_t lPrimaryVtxPosition[3];
1067     const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
1068     lPrimaryVtxPosition[0] = primaryVtx->GetX();
1069     lPrimaryVtxPosition[1] = primaryVtx->GetY();
1070     lPrimaryVtxPosition[2] = primaryVtx->GetZ();
1071     fHistPVx->Fill( lPrimaryVtxPosition[0] );
1072     fHistPVy->Fill( lPrimaryVtxPosition[1] );
1073     fHistPVz->Fill( lPrimaryVtxPosition[2] );
1074     
1075     //------------------------------------------------
1076     // Primary Vertex Requirements Section:
1077     //  ---> pp and PbPb: Only requires |z|<10cm
1078     //  ---> pPb: all requirements checked at this stage
1079     //------------------------------------------------
1080     
1081     //Roberto's PV selection criteria, implemented 17th April 2013
1082     
1083     /* vertex selection */
1084     Bool_t fHasVertex = kFALSE;
1085     
1086     const AliESDVertex *vertex = lESDevent->GetPrimaryVertexTracks();
1087     if (vertex->GetNContributors() < 1) {
1088         vertex = lESDevent->GetPrimaryVertexSPD();
1089         if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
1090         else fHasVertex = kTRUE;
1091         TString vtxTyp = vertex->GetTitle();
1092         Double_t cov[6]={0};
1093         vertex->GetCovarianceMatrix(cov);
1094         Double_t zRes = TMath::Sqrt(cov[5]);
1095         if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
1096     }
1097     else fHasVertex = kTRUE;
1098     
1099     //Is First event in chunk rejection: Still present!
1100     if(fkpAVertexSelection==kTRUE && fHasVertex == kFALSE) {
1101         AliWarning("Pb / | PV does not satisfy selection criteria!");
1102         PostData(1, fListHist);
1103         PostData(2, fTreeCascade);
1104         return;
1105     }
1106     
1107     //Is First event in chunk rejection: Still present!
1108     if(fkpAVertexSelection==kTRUE && fUtils->IsFirstEventInChunk(lESDevent)) {
1109         AliWarning("Pb / | This is the first event in the chunk!");
1110         PostData(1, fListHist);
1111         PostData(2, fTreeCascade);
1112         return;
1113     }
1114     
1115     //17 April Fix: Always do primary vertex Z selection, after pA vertex selection from Roberto
1116     if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0) {
1117         AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
1118         PostData(1, fListHist);
1119         PostData(2, fTreeCascade);
1120         return;
1121     }
1122     
1123     
1124     lMagneticField = lESDevent->GetMagneticField( );
1125     fHistV0MultiplicityForSelEvt ->Fill( lNumberOfV0s );
1126     fHistMultiplicity->Fill(lMultiplicity);
1127     fHistMultiplicityV0A->Fill(lMultiplicityV0A);
1128     fHistMultiplicityZNA->Fill(lMultiplicityZNA);
1129     fHistMultiplicityTRK->Fill(lMultiplicityTRK);
1130     fHistMultiplicitySPD->Fill(lMultiplicitySPD);
1131     
1132     //------------------------------------------------
1133     // SKIP: Events with well-established PVtx
1134     //------------------------------------------------
1135         
1136     const AliESDVertex *lPrimaryTrackingESDVtxCheck = lESDevent->GetPrimaryVertexTracks();
1137     const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
1138     if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtxCheck->GetStatus() && fkpAVertexSelection==kFALSE ){
1139         AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1140         PostData(1, fListHist);
1141         PostData(2, fTreeCascade);
1142         return;
1143     }
1144     fHistV0MultiplicityForSelEvtNoTPCOnly ->Fill( lNumberOfV0s );
1145     fHistMultiplicityNoTPCOnly->Fill(lMultiplicity);
1146     fHistMultiplicityV0ANoTPCOnly->Fill(lMultiplicityV0A);
1147     fHistMultiplicityZNANoTPCOnly->Fill(lMultiplicityZNA);
1148     fHistMultiplicityTRKNoTPCOnly->Fill(lMultiplicityTRK);
1149     fHistMultiplicitySPDNoTPCOnly->Fill(lMultiplicitySPD);
1150     
1151     //------------------------------------------------
1152     // Pileup Rejection Studies
1153     //------------------------------------------------
1154     
1155     // FIXME : quality selection regarding pile-up rejection
1156     if(lESDevent->IsPileupFromSPD() && !fkIsNuclear ){// minContributors=3, minZdist=0.8, nSigmaZdist=3., nSigmaDiamXY=2., nSigmaDiamZ=5.  -> see http://alisoft.cern.ch/viewvc/trunk/STEER/AliESDEvent.h?root=AliRoot&r1=41914&r2=42199&pathrev=42199
1157         AliWarning("Pb / This is tagged as Pileup from SPD... return !");
1158         PostData(1, fListHist);
1159         PostData(2, fTreeCascade);
1160         return;
1161     }
1162     fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup ->Fill( lNumberOfV0s );
1163     fHistMultiplicityNoTPCOnlyNoPileup->Fill(lMultiplicity);
1164     fHistMultiplicityV0ANoTPCOnlyNoPileup->Fill(lMultiplicityV0A);
1165     fHistMultiplicityZNANoTPCOnlyNoPileup->Fill(lMultiplicityZNA);
1166     fHistMultiplicityTRKNoTPCOnlyNoPileup->Fill(lMultiplicityTRK);
1167     fHistMultiplicitySPDNoTPCOnlyNoPileup->Fill(lMultiplicitySPD);
1168     
1169     //Do control histograms without the IsFromVertexerZ events, but consider them in analysis...
1170     if( ! (lESDevent->GetPrimaryVertex()->IsFromVertexerZ() )    ){
1171         fHistPVxAnalysis->Fill( lPrimaryVtxPosition[0] );
1172         fHistPVyAnalysis->Fill( lPrimaryVtxPosition[1] );
1173         fHistPVzAnalysis->Fill( lPrimaryVtxPosition[2] );
1174     }
1175     
1176     //------------------------------------------------
1177     // MAIN CASCADE LOOP STARTS HERE
1178     //------------------------------------------------
1179     // Code Credit: Antonin Maire (thanks^100)
1180     // ---> This is an adaptation
1181     
1182     Long_t ncascades = 0;
1183         ncascades = lESDevent->GetNumberOfCascades();
1184     
1185     for (Int_t iXi = 0; iXi < ncascades; iXi++){
1186         //------------------------------------------------
1187         // Initializations
1188         //------------------------------------------------
1189         //Double_t lTrkgPrimaryVtxRadius3D = -500.0;
1190         //Double_t lBestPrimaryVtxRadius3D = -500.0;
1191         fTreeCascVarBadCascadeJai = kFALSE ;
1192         
1193         // - 1st part of initialisation : variables needed to store AliESDCascade data members
1194         Double_t lEffMassXi      = 0. ;
1195         //Double_t lChi2Xi         = -1. ;
1196         Double_t lDcaXiDaughters = -1. ;
1197         Double_t lXiCosineOfPointingAngle = -1. ;
1198         Double_t lPosXi[3] = { -1000.0, -1000.0, -1000.0 };
1199         Double_t lXiRadius = -1000. ;
1200         
1201         // - 2nd part of initialisation : Nbr of clusters within TPC for the 3 daughter cascade tracks
1202         Int_t    lPosTPCClusters    = -1; // For ESD only ...//FIXME : wait for availability in AOD
1203         Int_t    lNegTPCClusters    = -1; // For ESD only ...
1204         Int_t    lBachTPCClusters   = -1; // For ESD only ...
1205         
1206         // - 3rd part of initialisation : about V0 part in cascades
1207         Double_t lInvMassLambdaAsCascDghter = 0.;
1208         //Double_t lV0Chi2Xi         = -1. ;
1209         Double_t lDcaV0DaughtersXi = -1.;
1210                 
1211         Double_t lDcaBachToPrimVertexXi = -1., lDcaV0ToPrimVertexXi = -1.;
1212         Double_t lDcaPosToPrimVertexXi  = -1.;
1213         Double_t lDcaNegToPrimVertexXi  = -1.;
1214         Double_t lV0CosineOfPointingAngleXi = -1. ;
1215         Double_t lV0CosineOfPointingAngleXiSpecial = -1. ;
1216         Double_t lPosV0Xi[3] = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
1217         Double_t lV0RadiusXi = -1000.0;
1218         Double_t lV0quality  = 0.;
1219         
1220         // - 4th part of initialisation : Effective masses
1221         Double_t lInvMassXiMinus    = 0.;
1222         Double_t lInvMassXiPlus     = 0.;
1223         Double_t lInvMassOmegaMinus = 0.;
1224         Double_t lInvMassOmegaPlus  = 0.;
1225         
1226         // - 6th part of initialisation : extra info for QA
1227         Double_t lXiMomX       = 0. , lXiMomY = 0., lXiMomZ = 0.;
1228         Double_t lXiTransvMom  = 0. ;
1229         Double_t lXiTransvMomMC= 0. ;
1230         Double_t lXiTotMom     = 0. ;
1231                 
1232         Double_t lBachMomX       = 0., lBachMomY  = 0., lBachMomZ   = 0.;
1233         //Double_t lBachTransvMom  = 0.;
1234         //Double_t lBachTotMom     = 0.;
1235         
1236         fTreeCascVarNegNSigmaPion   = -100;
1237         fTreeCascVarNegNSigmaProton = -100;
1238         fTreeCascVarPosNSigmaPion   = -100;
1239         fTreeCascVarPosNSigmaProton = -100;
1240         fTreeCascVarBachNSigmaPion  = -100;
1241         fTreeCascVarBachNSigmaKaon  = -100;
1242         
1243         Short_t  lChargeXi = -2;
1244         //Double_t lV0toXiCosineOfPointingAngle = 0. ;
1245         
1246         Double_t lRapXi   = -20.0, lRapOmega = -20.0, lRapMC = -20.0; //  lEta = -20.0, lTheta = 360., lPhi = 720. ;
1247         //Double_t lAlphaXi = -200., lPtArmXi  = -200.0;
1248             
1249         // -------------------------------------
1250         // II.ESD - Calculation Part dedicated to Xi vertices (ESD)
1251         
1252         AliESDcascade *xi = lESDevent->GetCascade(iXi);
1253         if (!xi) continue;
1254         
1255         
1256         // - II.Step 1 : around primary vertex
1257         //-------------
1258         //lTrkgPrimaryVtxRadius3D = TMath::Sqrt(  lTrkgPrimaryVtxPos[0] * lTrkgPrimaryVtxPos[0] +
1259         //                                        lTrkgPrimaryVtxPos[1] * lTrkgPrimaryVtxPos[1] +
1260         //                                        lTrkgPrimaryVtxPos[2] * lTrkgPrimaryVtxPos[2] );
1261         
1262         //lBestPrimaryVtxRadius3D = TMath::Sqrt(  lBestPrimaryVtxPos[0] * lBestPrimaryVtxPos[0] +
1263         //                                        lBestPrimaryVtxPos[1] * lBestPrimaryVtxPos[1] +
1264         //                                        lBestPrimaryVtxPos[2] * lBestPrimaryVtxPos[2] );
1265         
1266                 // - II.Step 2 : Assigning the necessary variables for specific AliESDcascade data members (ESD)
1267                 //-------------
1268         lV0quality = 0.;
1269         xi->ChangeMassHypothesis(lV0quality , 3312); // default working hypothesis : cascade = Xi- decay
1270         
1271         lEffMassXi                      = xi->GetEffMassXi();
1272         //lChi2Xi                           = xi->GetChi2Xi();
1273         lDcaXiDaughters         = xi->GetDcaXiDaughters();
1274         lXiCosineOfPointingAngle                    = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0],
1275                                                                                       lBestPrimaryVtxPos[1],
1276                                                                                       lBestPrimaryVtxPos[2] );
1277         // Take care : the best available vertex should be used (like in AliCascadeVertexer)
1278         
1279         xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] );
1280         lXiRadius                       = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );
1281         
1282         fTreeCascVarCascadeDecayX = lPosXi[0];
1283         fTreeCascVarCascadeDecayY = lPosXi[1];
1284         fTreeCascVarCascadeDecayZ = lPosXi[2];
1285         
1286                 // - II.Step 3 : around the tracks : Bach + V0 (ESD)
1287                 // ~ Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
1288                 //-------------
1289                 
1290         UInt_t lIdxPosXi        = (UInt_t) TMath::Abs( xi->GetPindex() );
1291         UInt_t lIdxNegXi        = (UInt_t) TMath::Abs( xi->GetNindex() );
1292         UInt_t lBachIdx         = (UInt_t) TMath::Abs( xi->GetBindex() );
1293         // Care track label can be negative in MC production (linked with the track quality)
1294         // However = normally, not the case for track index ...
1295         
1296         // FIXME : rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
1297         if(lBachIdx == lIdxNegXi) {
1298             AliWarning("Pb / Idx(Bach. track) = Idx(Neg. track) ... continue!"); continue;
1299         }
1300         if(lBachIdx == lIdxPosXi) {
1301             AliWarning("Pb / Idx(Bach. track) = Idx(Pos. track) ... continue!"); continue;
1302         }
1303         
1304         AliESDtrack *pTrackXi           = lESDevent->GetTrack( lIdxPosXi );
1305         AliESDtrack *nTrackXi           = lESDevent->GetTrack( lIdxNegXi );
1306         AliESDtrack *bachTrackXi        = lESDevent->GetTrack( lBachIdx );
1307         
1308         if (!pTrackXi || !nTrackXi || !bachTrackXi ) {
1309             AliWarning("ERROR: Could not retrieve one of the 3 ESD daughter tracks of the cascade ...");
1310             continue;
1311         }
1312         
1313         fTreeCascVarPosEta = pTrackXi->Eta();
1314         fTreeCascVarNegEta = nTrackXi->Eta();
1315         fTreeCascVarBachEta = bachTrackXi->Eta();
1316         
1317         //Save shared clusters information
1318         fTreeCascVarNegSharedClusters = nTrackXi->GetTPCnclsS(0,159);
1319         fTreeCascVarPosSharedClusters = pTrackXi->GetTPCnclsS(0,159);
1320         fTreeCascVarBachSharedClusters = bachTrackXi->GetTPCnclsS(0,159);
1321         
1322         Double_t lBMom[3], lNMom[3], lPMom[3];
1323         xi->GetBPxPyPz( lBMom[0], lBMom[1], lBMom[2] );
1324         xi->GetPPxPyPz( lPMom[0], lPMom[1], lPMom[2] );
1325         xi->GetNPxPyPz( lNMom[0], lNMom[1], lNMom[2] );
1326         
1327         //Save all momentum information
1328         fTreeCascVarNegPx = lNMom[0];
1329         fTreeCascVarNegPy = lNMom[1];
1330         fTreeCascVarNegPz = lNMom[2];
1331         fTreeCascVarPosPx = lPMom[0];
1332         fTreeCascVarPosPy = lPMom[1];
1333         fTreeCascVarPosPz = lPMom[2];
1334         fTreeCascVarBachPx = lBMom[0];
1335         fTreeCascVarBachPy = lBMom[1];
1336         fTreeCascVarBachPz = lBMom[2];
1337         
1338         fTreeCascVarBachTransMom = TMath::Sqrt( lBMom[0]*lBMom[0] + lBMom[1]*lBMom[1] );
1339         fTreeCascVarPosTransMom  = TMath::Sqrt( lPMom[0]*lPMom[0] + lPMom[1]*lPMom[1] );
1340         fTreeCascVarNegTransMom  = TMath::Sqrt( lNMom[0]*lNMom[0] + lNMom[1]*lNMom[1] );
1341         
1342         //------------------------------------------------
1343         // TPC dEdx information
1344         //------------------------------------------------
1345         fTreeCascVarNegNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kPion   );
1346         fTreeCascVarNegNSigmaProton = fPIDResponse->NumberOfSigmasTPC( nTrackXi, AliPID::kProton );
1347         fTreeCascVarPosNSigmaPion   = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kPion );
1348         fTreeCascVarPosNSigmaProton = fPIDResponse->NumberOfSigmasTPC( pTrackXi, AliPID::kProton );
1349         fTreeCascVarBachNSigmaPion  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kPion );
1350         fTreeCascVarBachNSigmaKaon  = fPIDResponse->NumberOfSigmasTPC( bachTrackXi, AliPID::kKaon );
1351         
1352         //------------------------------------------------
1353         // TPC Number of clusters info
1354         // --- modified to save the smallest number
1355         // --- of TPC clusters for the 3 tracks
1356         //------------------------------------------------
1357         
1358         lPosTPCClusters   = pTrackXi->GetTPCNcls();
1359         lNegTPCClusters   = nTrackXi->GetTPCNcls();
1360         lBachTPCClusters  = bachTrackXi->GetTPCNcls();
1361         
1362         fTreeCascVarNegClusters = lNegTPCClusters;
1363         fTreeCascVarPosClusters = lPosTPCClusters;
1364         fTreeCascVarBachClusters = lBachTPCClusters;
1365         
1366         // 1 - Poor quality related to TPCrefit
1367         ULong_t pStatus    = pTrackXi->GetStatus();
1368         ULong_t nStatus    = nTrackXi->GetStatus();
1369         ULong_t bachStatus = bachTrackXi->GetStatus();
1370         
1371         fTreeCascVarkITSRefitBachelor = kTRUE;
1372         fTreeCascVarkITSRefitNegative = kTRUE;
1373         fTreeCascVarkITSRefitPositive = kTRUE;
1374         
1375         if ((pStatus&AliESDtrack::kTPCrefit)    == 0) { /*AliWarning("Pb / V0 Pos. track has no TPCrefit ... continue!"); */continue; }
1376         if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { /*AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); */continue; }
1377         if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { /*AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); */continue; }
1378         
1379         //Extra Debug Information: booleans for ITS refit
1380         if ((pStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitPositive = kFALSE; }
1381         if ((nStatus&AliESDtrack::kITSrefit)    == 0) { fTreeCascVarkITSRefitNegative = kFALSE; }
1382         if ((bachStatus&AliESDtrack::kITSrefit) == 0) { fTreeCascVarkITSRefitBachelor = kFALSE; }
1383         
1384         // 2 - Poor quality related to TPC clusters: lowest cut of 70 clusters
1385         if(lPosTPCClusters  < 70) { /*AliWarning("Pb / V0 Pos. track has less than 70 TPC clusters ... continue!"); */continue; }
1386         if(lNegTPCClusters  < 70) { /*AliWarning("Pb / V0 Neg. track has less than 70 TPC clusters ... continue!"); */continue; }
1387         if(lBachTPCClusters < 70) { /*AliWarning("Pb / Bach.   track has less than 70 TPC clusters ... continue!"); */continue; }
1388         Int_t leastnumberofclusters = 1000;
1389         if( lPosTPCClusters < leastnumberofclusters ) leastnumberofclusters = lPosTPCClusters;
1390         if( lNegTPCClusters < leastnumberofclusters ) leastnumberofclusters = lNegTPCClusters;
1391         if( lBachTPCClusters < leastnumberofclusters ) leastnumberofclusters = lBachTPCClusters;
1392         
1393         lInvMassLambdaAsCascDghter      = xi->GetEffMass();
1394         // This value shouldn't change, whatever the working hyp. is : Xi-, Xi+, Omega-, Omega+
1395         lDcaV0DaughtersXi               = xi->GetDcaV0Daughters();
1396         //lV0Chi2Xi                     = xi->GetChi2V0();
1397         
1398         lV0CosineOfPointingAngleXi      = xi->GetV0CosineOfPointingAngle( lBestPrimaryVtxPos[0],
1399                                                                      lBestPrimaryVtxPos[1],
1400                                                                      lBestPrimaryVtxPos[2] );
1401         //Modification: V0 CosPA wrt to Cascade decay vertex
1402         lV0CosineOfPointingAngleXiSpecial       = xi->GetV0CosineOfPointingAngle( lPosXi[0],
1403                                                                              lPosXi[1],
1404                                                                              lPosXi[2] );
1405         
1406         lDcaV0ToPrimVertexXi            = xi->GetD( lBestPrimaryVtxPos[0],
1407                                                lBestPrimaryVtxPos[1],
1408                                                lBestPrimaryVtxPos[2] );
1409                 
1410         lDcaBachToPrimVertexXi = TMath::Abs( bachTrackXi->GetD( lBestPrimaryVtxPos[0],
1411                                                                lBestPrimaryVtxPos[1],
1412                                                                lMagneticField  ) );
1413         // Note : AliExternalTrackParam::GetD returns an algebraic value ...
1414                 
1415         xi->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] );
1416         lV0RadiusXi             = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0]  +  lPosV0Xi[1]*lPosV0Xi[1] );
1417         
1418         fTreeCascVarV0DecayX = lPosV0Xi[0];
1419         fTreeCascVarV0DecayY = lPosV0Xi[1];
1420         fTreeCascVarV0DecayZ = lPosV0Xi[2];
1421         
1422         lDcaPosToPrimVertexXi   = TMath::Abs( pTrackXi  ->GetD( lBestPrimaryVtxPos[0],
1423                                                                lBestPrimaryVtxPos[1],
1424                                                                lMagneticField  )     );
1425         
1426         lDcaNegToPrimVertexXi   = TMath::Abs( nTrackXi  ->GetD( lBestPrimaryVtxPos[0],
1427                                                                lBestPrimaryVtxPos[1],
1428                                                                lMagneticField  )     );
1429                 
1430         // - II.Step 4 : around effective masses (ESD)
1431         // ~ change mass hypotheses to cover all the possibilities :  Xi-/+, Omega -/+
1432                 
1433         if( bachTrackXi->Charge() < 0 ) {
1434             lV0quality = 0.;
1435             xi->ChangeMassHypothesis(lV0quality , 3312);
1436             // Calculate the effective mass of the Xi- candidate.
1437             // pdg code 3312 = Xi-
1438             lInvMassXiMinus = xi->GetEffMassXi();
1439             
1440             lV0quality = 0.;
1441             xi->ChangeMassHypothesis(lV0quality , 3334);
1442             // Calculate the effective mass of the Xi- candidate.
1443             // pdg code 3334 = Omega-
1444             lInvMassOmegaMinus = xi->GetEffMassXi();
1445             
1446             lV0quality = 0.;
1447             xi->ChangeMassHypothesis(lV0quality , 3312);        // Back to default hyp.
1448         }// end if negative bachelor
1449         
1450         
1451         if( bachTrackXi->Charge() >  0 ){
1452             lV0quality = 0.;
1453             xi->ChangeMassHypothesis(lV0quality , -3312);
1454             // Calculate the effective mass of the Xi+ candidate.
1455             // pdg code -3312 = Xi+
1456             lInvMassXiPlus = xi->GetEffMassXi();
1457             
1458             lV0quality = 0.;
1459             xi->ChangeMassHypothesis(lV0quality , -3334);
1460             // Calculate the effective mass of the Xi+ candidate.
1461             // pdg code -3334  = Omega+
1462             lInvMassOmegaPlus = xi->GetEffMassXi();
1463             
1464             lV0quality = 0.;
1465             xi->ChangeMassHypothesis(lV0quality , -3312);       // Back to "default" hyp.
1466         }// end if positive bachelor
1467         // - II.Step 6 : extra info for QA (ESD)
1468         // miscellaneous pieces of info that may help regarding data quality assessment.
1469         //-------------
1470         
1471         xi->GetPxPyPz( lXiMomX, lXiMomY, lXiMomZ );
1472         lXiTransvMom    = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY );
1473         lXiTotMom       = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY   + lXiMomZ*lXiMomZ );
1474                 
1475         xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
1476         //lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY );
1477         //lBachTotMom   = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY  +  lBachMomZ*lBachMomZ  );
1478         
1479         lChargeXi = xi->Charge();
1480         
1481         //lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
1482         
1483         lRapXi    = xi->RapXi();
1484         lRapOmega = xi->RapOmega();
1485         //lEta      = xi->Eta();
1486         //lTheta    = xi->Theta() *180.0/TMath::Pi();
1487         //lPhi      = xi->Phi()   *180.0/TMath::Pi();
1488         //lAlphaXi  = xi->AlphaXi();
1489         //lPtArmXi  = xi->PtArmXi();
1490         
1491         //------------------------------------------------
1492         // Jai Salzwedel's femto-cut: better V0 exists
1493         //------------------------------------------------
1494         
1495         fTreeCascVarDeltaDCA = -100;
1496         Float_t DCAV0DaughtersDiff = -100;
1497         for (Int_t iv0=0; iv0<lESDevent->GetNumberOfV0s(); iv0++) {
1498             AliESDv0 *v0 = lESDevent->GetV0(iv0);
1499             UInt_t posV0TrackIdx = (UInt_t) v0->GetPindex();
1500             UInt_t negV0TrackIdx = (UInt_t) v0->GetNindex();
1501             if ((posV0TrackIdx == lIdxPosXi) && (negV0TrackIdx == lIdxNegXi)) continue;
1502             // if both tracks are the same ones as the cascades V0 daughter tracks, then the V0 belongs to the cascade being analysed; so avoid it
1503             if ((posV0TrackIdx == lIdxPosXi) || (negV0TrackIdx == lIdxNegXi)) {
1504                 DCAV0DaughtersDiff = lDcaV0DaughtersXi - v0->GetDcaV0Daughters();
1505                 if( fTreeCascVarDeltaDCA < DCAV0DaughtersDiff ) fTreeCascVarDeltaDCA = DCAV0DaughtersDiff;
1506                 if ( lDcaV0DaughtersXi > v0->GetDcaV0Daughters() )  {    // DCA comparison criterion
1507                     fTreeCascVarBadCascadeJai = kTRUE;
1508                 } //end DCA comparison
1509             } // end shares a daughter check
1510         } //end V0 loop
1511         
1512         //------------------------------------------------
1513         // Set Variables for adding to tree
1514         //------------------------------------------------
1515         
1516         /* 1*/          fTreeCascVarCharge      = lChargeXi;
1517         /* 2*/          if(lInvMassXiMinus!=0)    fTreeCascVarMassAsXi = lInvMassXiMinus;
1518         /* 2*/          if(lInvMassXiPlus!=0)     fTreeCascVarMassAsXi = lInvMassXiPlus;
1519         /* 3*/          if(lInvMassOmegaMinus!=0) fTreeCascVarMassAsOmega = lInvMassOmegaMinus;
1520         /* 3*/          if(lInvMassOmegaPlus!=0)  fTreeCascVarMassAsOmega = lInvMassOmegaPlus;
1521         /* 4*/          fTreeCascVarPt = lXiTransvMom;
1522         /* 4*/          fTreeCascVarPtMC = lXiTransvMomMC;
1523         /* 5*/          fTreeCascVarRapXi = lRapXi ;
1524         /* 5*/          fTreeCascVarRapMC = lRapMC ;
1525         /* 6*/          fTreeCascVarRapOmega = lRapOmega ;
1526         /* 7*/          fTreeCascVarDCACascDaughters = lDcaXiDaughters;
1527         /* 8*/          fTreeCascVarDCABachToPrimVtx = lDcaBachToPrimVertexXi;
1528         /* 9*/          fTreeCascVarDCAV0Daughters = lDcaV0DaughtersXi;
1529         /*10*/          fTreeCascVarDCAV0ToPrimVtx = lDcaV0ToPrimVertexXi;
1530         /*11*/          fTreeCascVarDCAPosToPrimVtx = lDcaPosToPrimVertexXi;
1531         /*12*/          fTreeCascVarDCANegToPrimVtx = lDcaNegToPrimVertexXi;
1532         /*13*/          fTreeCascVarCascCosPointingAngle = lXiCosineOfPointingAngle;
1533         /*14*/          fTreeCascVarCascRadius = lXiRadius;
1534         /*15*/          fTreeCascVarV0Mass = lInvMassLambdaAsCascDghter;
1535         /*16*/          fTreeCascVarV0CosPointingAngle = lV0CosineOfPointingAngleXi;
1536         /*16*/          fTreeCascVarV0CosPointingAngleSpecial = lV0CosineOfPointingAngleXiSpecial;
1537         /*17*/          fTreeCascVarV0Radius = lV0RadiusXi;
1538         /*20*/          fTreeCascVarLeastNbrClusters = leastnumberofclusters;
1539         /*21*/          fTreeCascVarMultiplicity = lMultiplicity; //multiplicity, whatever that may be
1540         
1541         /*23*/          fTreeCascVarDistOverTotMom = TMath::Sqrt(
1542                                                              TMath::Power( lPosXi[0] - lBestPrimaryVtxPos[0] , 2) +
1543                                                              TMath::Power( lPosXi[1] - lBestPrimaryVtxPos[1] , 2) +
1544                                                              TMath::Power( lPosXi[2] - lBestPrimaryVtxPos[2] , 2)
1545                                                              );
1546         /*23*/          fTreeCascVarDistOverTotMom /= (lXiTotMom+1e-13);
1547         
1548         //All vars not specified here: specified elsewhere!
1549         
1550         //------------------------------------------------
1551         // Fill Tree!
1552         //------------------------------------------------
1553         
1554         // The conditional is meant to decrease excessive
1555         // memory usage! Be careful when loosening the
1556         // cut!
1557         
1558         //Xi    Mass window: 150MeV wide
1559         //Omega mass window: 150MeV wide
1560         
1561         if( (fTreeCascVarMassAsXi<1.32+0.075&&fTreeCascVarMassAsXi>1.32-0.075) ||
1562            (fTreeCascVarMassAsOmega<1.68+0.075&&fTreeCascVarMassAsOmega>1.68-0.075) ){
1563             
1564             //All inclusive: save everything (OK for p-Pb, pp, NOT OK for Pb-Pb)
1565             if( !fkLight && !fkSuperLight ) fTreeCascade->Fill();
1566             //Intermediate mode: filter on dE/dx, rapidity, eta
1567             if(  fkLight && !fkSuperLight){
1568                 
1569                 //This cascade is useless until proven otherwise
1570                 Bool_t lSaveThisCascade = kFALSE;
1571                 
1572                 //Extra selections in case this is supposed to be super-filtered
1573                 //Inspired on tricks used for the V0 analysis in Pb-Pb
1574                 if (TMath::Abs(fTreeCascVarNegEta) < 0.8 &&
1575                     TMath::Abs(fTreeCascVarPosEta) < 0.8 &&
1576                     TMath::Abs(fTreeCascVarBachEta) < 0.8 &&
1577                     fTreeCascVarPt > fLowPtCutoff){ //beware ptMC and ptreco differences
1578                     
1579                     //Extra selections applied on a case-by-case basis:
1580                     // (1) XiMinus
1581                     if( fTreeCascVarCharge == -1 &&
1582                        TMath::Abs(fTreeCascVarMassAsXi-1.321)<0.60 &&
1583                        TMath::Abs(fTreeCascVarPosNSigmaProton) <= 4 &&
1584                        TMath::Abs(fTreeCascVarNegNSigmaPion  ) <= 4 &&
1585                        TMath::Abs(fTreeCascVarBachNSigmaPion ) <= 4 &&
1586                        TMath::Abs(fTreeCascVarRapXi          ) <= 0.5 ){
1587                         lSaveThisCascade = kTRUE;
1588                     }
1589                     // (2) XiPlus
1590                     if( fTreeCascVarCharge == +1 &&
1591                        TMath::Abs(fTreeCascVarMassAsXi-1.321)<0.60 &&
1592                        TMath::Abs(fTreeCascVarPosNSigmaPion  ) <= 4 &&
1593                        TMath::Abs(fTreeCascVarNegNSigmaProton) <= 4 &&
1594                        TMath::Abs(fTreeCascVarBachNSigmaPion ) <= 4 &&
1595                        TMath::Abs(fTreeCascVarRapXi          ) <= 0.5 ){
1596                         lSaveThisCascade = kTRUE;
1597                     }
1598                     // (3) OmegaMinus
1599                     if( fTreeCascVarCharge == -1 &&
1600                        TMath::Abs(fTreeCascVarMassAsOmega-1.672)<0.60 &&
1601                        TMath::Abs(fTreeCascVarPosNSigmaProton) <= 4 &&
1602                        TMath::Abs(fTreeCascVarNegNSigmaPion  ) <= 4 &&
1603                        TMath::Abs(fTreeCascVarBachNSigmaKaon ) <= 4 &&
1604                        TMath::Abs(fTreeCascVarRapOmega       ) <= 0.5 ){
1605                         lSaveThisCascade = kTRUE;
1606                     }
1607                     // (4) OmegaPlus
1608                     if( fTreeCascVarCharge == +1 &&
1609                        TMath::Abs(fTreeCascVarMassAsOmega-1.672)<0.60 &&
1610                        TMath::Abs(fTreeCascVarPosNSigmaPion    ) <= 4 &&
1611                        TMath::Abs(fTreeCascVarNegNSigmaProton  ) <= 4 &&
1612                        TMath::Abs(fTreeCascVarBachNSigmaKaon   ) <= 4 &&
1613                        TMath::Abs(fTreeCascVarRapOmega         ) <= 0.5 ){
1614                         lSaveThisCascade = kTRUE;
1615                     }
1616                 }
1617                 if (lSaveThisCascade) fTreeCascade -> Fill() ;
1618                 
1619             }
1620         }
1621         
1622         //------------------------------------------------
1623         // Fill tree over.
1624         //------------------------------------------------
1625         
1626         //------------------------------------------------
1627         // Super-lightweight mode filling
1628         //
1629         //  THIS MODE OVERRIDES LIGHT MODE
1630         //
1631         //  If fkSuperLight is kTRUE, only histograms are saved
1632         //
1633         //------------------------------------------------
1634         
1635         if( fkSuperLight ){
1636             //Conditionals
1637             if (
1638                 TMath::Abs(fTreeCascVarNegEta)  > 0.8 &&
1639                 TMath::Abs(fTreeCascVarPosEta)  > 0.8 &&
1640                 TMath::Abs(fTreeCascVarBachEta) > 0.8 &&
1641                 fTreeCascVarBachClusters >= 70 &&
1642                 fTreeCascVarNegClusters  >= 70 &&
1643                 fTreeCascVarPosClusters  >= 70 &&
1644                 fTreeCascVarV0Radius                      >= fCut_V0Radius &&
1645                 fTreeCascVarCascRadius                    >= fCut_CascRadius &&
1646                 TMath::Abs(fTreeCascVarV0Mass - 1.116)    <= fCut_V0Mass &&
1647                 fTreeCascVarV0CosPointingAngle            >= fCut_V0CosPA &&
1648                 fTreeCascVarCascCosPointingAngle          >= fCut_CascCosPA &&
1649                 fTreeCascVarDCANegToPrimVtx               >= fCut_DCANegToPV &&
1650                 fTreeCascVarDCAPosToPrimVtx               >= fCut_DCAPosToPV &&
1651                 fTreeCascVarDCABachToPrimVtx              >= fCut_DCABachToPV &&
1652                 fTreeCascVarDCAV0Daughters                <= fCut_DCAV0Daughters &&
1653                 fTreeCascVarDCACascDaughters              <= fCut_DCACascDaughters &&
1654                 fTreeCascVarDCAV0ToPrimVtx                >= fCut_DCAV0ToPV
1655                 ){
1656                 
1657                 //--- Case (1) - XiMinus --------------
1658                 if(
1659                    fTreeCascVarCharge == -1 &&
1660                    TMath::Abs(fTreeCascVarRapXi)<0.5 &&
1661                    fTreeCascVarDistOverTotMom*1.321 < fCut_CTau &&
1662                    TMath::Abs( fTreeCascVarNegNSigmaPion   ) < 4 &&
1663                    TMath::Abs( fTreeCascVarPosNSigmaProton ) < 4 &&
1664                    TMath::Abs( fTreeCascVarBachNSigmaPion  ) < 4
1665                    ){
1666                     f2dHist_MassVsPt_XiMinus -> Fill ( fTreeCascVarMassAsXi , fTreeCascVarPt );
1667                 }
1668                 //--- Case (2) - XiPlus ---------------
1669                 if(
1670                    fTreeCascVarCharge == +1 &&
1671                    TMath::Abs(fTreeCascVarRapXi)<0.5 &&
1672                    fTreeCascVarDistOverTotMom*1.321 < fCut_CTau &&
1673                    TMath::Abs( fTreeCascVarNegNSigmaProton   ) < 4 &&
1674                    TMath::Abs( fTreeCascVarPosNSigmaPion     ) < 4 &&
1675                    TMath::Abs( fTreeCascVarBachNSigmaPion    ) < 4
1676                    ){
1677                     f2dHist_MassVsPt_XiPlus -> Fill ( fTreeCascVarMassAsXi , fTreeCascVarPt );
1678                 }
1679                 //--- Case (3) - OmegaMinus -----------
1680                 if(
1681                    fTreeCascVarCharge == -1 &&
1682                    TMath::Abs(fTreeCascVarRapOmega)<0.5 &&
1683                    fTreeCascVarDistOverTotMom*1.672 < fCut_CTau &&
1684                    TMath::Abs( fTreeCascVarNegNSigmaPion   ) < 4 &&
1685                    TMath::Abs( fTreeCascVarPosNSigmaProton ) < 4 &&
1686                    TMath::Abs( fTreeCascVarBachNSigmaKaon  ) < 4
1687                    ){
1688                     f2dHist_MassVsPt_OmegaMinus -> Fill ( fTreeCascVarMassAsOmega , fTreeCascVarPt );
1689                 }
1690                 //--- Case (4) - OmegaPlus ------------
1691                 if(
1692                    fTreeCascVarCharge == +1 &&
1693                    TMath::Abs(fTreeCascVarRapOmega)<0.5 &&
1694                    fTreeCascVarDistOverTotMom*1.672 < fCut_CTau &&
1695                    TMath::Abs( fTreeCascVarNegNSigmaProton   ) < 4 &&
1696                    TMath::Abs( fTreeCascVarPosNSigmaPion     ) < 4 &&
1697                    TMath::Abs( fTreeCascVarBachNSigmaKaon    ) < 4
1698                    ){
1699                     f2dHist_MassVsPt_OmegaPlus -> Fill ( fTreeCascVarMassAsOmega , fTreeCascVarPt );
1700                 }
1701             }
1702         }
1703         
1704         
1705         //------------------------------------------------
1706         // End Super-lightweight mode
1707         //------------------------------------------------
1708         
1709         }// end of the Cascade loop (ESD or AOD)
1710     
1711     // Post output data.
1712     PostData(1, fListHist);
1713     PostData(2, fTreeCascade);
1714 }
1715
1716 //________________________________________________________________________
1717 void AliAnalysisTaskExtractCascade::Terminate(Option_t *)
1718 {
1719     // Draw result to the screen
1720     // Called once at the end of the query
1721     
1722     TList *cRetrievedList = 0x0;
1723     cRetrievedList = (TList*)GetOutputData(1);
1724     if(!cRetrievedList){
1725         Printf("ERROR - AliAnalysisTaskExtractCascade : ouput data container list not available\n");
1726         return;
1727     }
1728         
1729     fHistV0MultiplicityForTrigEvt = dynamic_cast<TH1F*> (  cRetrievedList->FindObject("fHistV0MultiplicityForTrigEvt")  );
1730     if (!fHistV0MultiplicityForTrigEvt) {
1731         Printf("ERROR - AliAnalysisTaskExtractCascade : fHistV0MultiplicityForTrigEvt not available");
1732         return;
1733     }
1734     
1735     TCanvas *canCheck = new TCanvas("AliAnalysisTaskExtractCascade","V0 Multiplicity",10,10,510,510);
1736     canCheck->cd(1)->SetLogy();
1737     
1738     fHistV0MultiplicityForTrigEvt->SetMarkerStyle(22);
1739     fHistV0MultiplicityForTrigEvt->DrawCopy("E");
1740 }
1741
1742 //----------------------------------------------------------------------------
1743
1744 Double_t AliAnalysisTaskExtractCascade::MyRapidity(Double_t rE, Double_t rPz) const
1745 {
1746     // Local calculation for rapidity
1747     Double_t ReturnValue = -100;
1748     if( (rE-rPz+1.e-13) != 0 && (rE+rPz) != 0 ){
1749         ReturnValue =  0.5*TMath::Log((rE+rPz)/(rE-rPz+1.e-13));
1750     }
1751     return ReturnValue;
1752 }