]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/STRANGENESS/Cascades/AliAnalysisTaskCheckCascadepp276.cxx
Modified tasks to run also on p-Pb data (D.Colella)
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / AliAnalysisTaskCheckCascadepp276.cxx
1 /**************************************************************************
2  *  Authors : Antonin Maire, Boris Hippolyte                              *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 //-----------------------------------------------------------------
15 //            AliAnalysisTaskCheckCascadepp276 class
16 //
17 //            Origin AliAnalysisTaskCheckCascade which has four roles :
18 //              1. QAing the Cascades from ESD and AOD
19 //                 Origin:  AliAnalysisTaskESDCheckV0 by Boris Hippolyte Nov2007, hippolyt@in2p3.fr
20 //              2. Prepare the plots which stand as raw material for yield extraction (wi/wo PID)
21 //              3. Supply an AliCFContainer meant to define the optimised topological selections
22 //              4. Rough azimuthal correlation study (Eta, Phi)
23 //              Adapted to Cascade : A.Maire Mar2008, antonin.maire@ires.in2p3.fr
24 //              Modified :           A.Maire Mar2010 
25 //
26 //              Adapted to PbPb analysis: M. Nicassio, maria.nicassio@ba.infn.it
27 //               Feb-August2011
28 //                - Physics selection moved to the run.C macro
29 //                - Centrality selection added (+ setters) and histos
30 //                - flag and setters added (CF container usage, vertex range)
31 //                - histo added and histo/container binning changed 
32 //                - protection in the destructor for CAF usage          
33 //                - AliWarning disabled
34 //                - number of tracklets from AOD also          
35 //                - automatic settings for PID
36 //               September2011
37 //                - proper time histos/container added (V0 and Cascades)
38 //                - cosine PA V0 wrt Xi vertex in the container  
39 //               November2011
40 //                - re-run V0's and cascade's vertexers (SetCuts instead SetDefaultCuts!!)
41 //                - problems of libraries on Grid --> code copied in the task (from AliRoot v5-10-AN
42 //                  where new pt dependent V0's cosPA cut implemented by Iouri) 
43 //                - AOD analysis part completed 
44 //
45 //
46 //              Adapted to pp 2.76 TeV analysis: D. Colella, domenico.colella@ba.infn.it
47 //               Gen-now 2012
48 //                - Physics selection re-moved here (mainly for normalization in the efficiency calcuation)
49 //                - Centrality selection deleted
50 //
51 //
52 //             Adapted to pPb 5.02 TeV analysis: D. Colella, domenico.colella@ba.infn.it
53 //               Aug-Sep 2014
54 //               - Added the parameter fCollidingSystem, to distingish between pp and pPb procedures
55 //               - 
56 //
57 //
58 //
59 //-----------------------------------------------------------------
60
61 class TTree;
62 class TParticle;
63 class TVector3;
64
65 class AliESDVertex;
66 class AliAODVertex;
67 class AliESDv0;
68 class AliAODv0;
69
70 #include <Riostream.h>
71 #include "TList.h"
72 #include "TH1.h"
73 #include "TH2.h"
74 #include "TH3.h"
75 #include "THnSparse.h"
76 #include "TVector3.h"
77 #include "TCanvas.h"
78 #include "TMath.h"
79 #include "TLegend.h"
80
81 #include "AliLog.h"
82 #include "AliESDEvent.h"
83 #include "AliAODEvent.h"
84 #include "AliV0vertexer.h"
85 #include "AliCascadeVertexer.h"
86 #include "AliESDtrackCuts.h"
87 #include "AliPIDResponse.h"
88
89 #include "AliESDVZERO.h"
90
91 #include "AliInputEventHandler.h"
92 #include "AliAnalysisManager.h"
93 #include "AliMCEventHandler.h"
94 #include "AliESDInputHandler.h" 
95 #include "AliAODInputHandler.h"
96 #include "AliCFContainer.h"
97 #include "AliMultiplicity.h"
98
99 #include "AliESDcascade.h"
100 #include "AliAODcascade.h"
101 #include "AliAODTrack.h"
102 #include "AliAnalysisUtils.h"
103
104 #include "AliAnalysisTaskCheckCascadepp276.h"
105
106
107 using std::cout;
108 using std::endl;
109
110 ClassImp(AliAnalysisTaskCheckCascadepp276)
111
112
113
114 //________________________________________________________________________
115 AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276() 
116   : AliAnalysisTaskSE(), 
117     fAnalysisType               ("ESD"),
118     fESDtrackCuts               (0),
119     fUtils                      (0),
120     fCollidingSystem            ("pp"),
121     fPIDResponse                (0),
122     fkRerunV0CascVertexers      (0),
123     fkSDDSelectionOn            (kTRUE),
124     fkQualityCutZprimVtxPos     (kTRUE),
125     fkQualityCutNoTPConlyPrimVtx(kTRUE),
126     fkQualityCutTPCrefit        (kTRUE),
127     fkQualityCutnTPCcls         (kTRUE),
128     fkQualityCutPileup          (kTRUE),
129     fwithSDD                    (kTRUE),
130     fMinnTPCcls                 (0),
131     fkExtraSelections           (0),
132     fVtxRange                   (0),
133     fVtxRangeMin                (0),
134     fMinPtCutOnDaughterTracks   (0),
135     fEtaCutOnDaughterTracks     (0),
136
137     // - Plots initialisation
138     fListHistCascade(0),
139       // Cascades multiplicity plots
140       fHistCascadeMultiplicityBeforeAnySel(0),
141       fHistCascadeMultiplicityAfterSDDSel(0),
142       fHistCascadeMultiplicityAfterPhysicsSel(0),
143       fHistCascadeMultiplicityForSelEvtNoTPCOnly(0),
144       fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
145       fHistCascadeMultiplicityAfterVertexCutSel(0),
146       // Tracks multiplicity plots
147       fHistTrackMultiplicityBeforeAnySel(0),
148       fHistTrackMultiplicityAfterSDDSel(0),
149       fHistTrackMultiplicityAfterPhysicsSel(0),
150       fHistTrackMultiplicityForSelEvtNoTPCOnly(0),
151       fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
152       fHistTrackMultiplicityAfterVertexCutSel(0),
153       // Vertex position plots (BestVertex)
154       fHistPVx(0), fHistPVy(0), fHistPVz(0),
155       fHistPVxAnalysis(0), fHistPVyAnalysis(0), fHistPVzAnalysis(0),    
156       // TPC cluster distributions for daughters
157       fHistPosV0TPCClusters(0), 
158       fHistNegV0TPCClusters(0), 
159       fHistBachTPCClusters(0),
160       // Cut's variables distributions
161       fHistEffMassXi(0), 
162       fHistDcaXiDaughters(0), 
163       fHistDcaBachToPrimVertex(0), 
164       fHistXiCosineOfPointingAngle(0), 
165       fHistXiRadius(0),
166       fHistMassLambdaAsCascDghter(0),
167       fHistDcaV0DaughtersXi(0),
168       fHistDcaV0ToPrimVertexXi(0), 
169       fHistV0CosineOfPointingAngleXi(0),
170       fHistV0RadiusXi(0),
171       fHistDcaPosToPrimVertexXi(0), 
172       fHistDcaNegToPrimVertexXi(0), 
173       // Invariant mass distributions
174       fHistMassXiMinus(0), fHistMassXiPlus(0), fHistMassOmegaMinus(0), fHistMassOmegaPlus(0),
175       // Transverse and total momentum distributions
176       fHistXiTransvMom(0), fHistXiTotMom(0), fHistBachTransvMomXi(0), fHistBachTotMomXi(0),
177       // Others QA plots
178       fHistChargeXi(0),
179       fHistV0toXiCosineOfPointingAngle(0),
180       fHistRapXi(0), fHistRapOmega(0), 
181       fHistEtaXi(0), fHistEtaBachXi(0), fHistEtaPosXi(0), fHistEtaNegXi(0),
182       fHistThetaXi(0), 
183       fHistPhiXi(0),
184       f2dHistArmenteros(0),                     
185       f2dHistEffMassLambdaVsEffMassXiMinus(0), f2dHistEffMassXiVsEffMassOmegaMinus(0),
186       f2dHistEffMassLambdaVsEffMassXiPlus(0),  f2dHistEffMassXiVsEffMassOmegaPlus(0),
187       f2dHistXiRadiusVsEffMassXiMinus(0),      f2dHistXiRadiusVsEffMassXiPlus(0),
188       f2dHistXiRadiusVsEffMassOmegaMinus(0),   f2dHistXiRadiusVsEffMassOmegaPlus(0),
189       f2dHistTPCdEdxOfCascDghters(0),
190       f2dHistDcaXiDaughtersvsInvMass(0), 
191       f2dHistDcaBachToPrimVertexvsInvMass(0), 
192       f2dHistXiCosineOfPointingAnglevsInvMass(0),
193       f2dHistMassLambdaAsCascDghtervsInvMass(0),
194       f2dHistDcaV0DaughtersXivsInvMass(0),
195       f2dHistDcaV0ToPrimVertexXivsInvMass(0),
196       // Containers for cuts study 
197       fCFContCascadePIDXiMinus(0),
198       fCFContCascadePIDXiPlus(0),
199       fCFContCascadePIDOmegaMinus(0),
200       fCFContCascadePIDOmegaPlus(0),
201       fCFContCascadeCuts(0)
202     
203     {
204      // Dummy Constructor
205         for(Int_t iV0selIdx   = 0; iV0selIdx   < 7; iV0selIdx++   ) { fV0Sels          [iV0selIdx   ] = -1.; }
206         for(Int_t iCascSelIdx = 0; iCascSelIdx < 8; iCascSelIdx++ ) { fCascSels        [iCascSelIdx ] = -1.; }
207     }
208
209
210 //________________________________________________________________________
211 AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276(const char *name) 
212   : AliAnalysisTaskSE(name), 
213     fAnalysisType               ("ESD"), 
214     fESDtrackCuts               (0), 
215     fUtils                      (0),
216     fCollidingSystem            ("pp"),
217     fPIDResponse                (0),
218     fkRerunV0CascVertexers      (0),
219     fkSDDSelectionOn            (kTRUE),
220     fkQualityCutZprimVtxPos     (kTRUE),
221     fkQualityCutNoTPConlyPrimVtx(kTRUE),
222     fkQualityCutTPCrefit        (kTRUE),
223     fkQualityCutnTPCcls         (kTRUE),
224     fkQualityCutPileup          (kTRUE),
225     fwithSDD                    (kTRUE),
226     fMinnTPCcls                 (0),
227     fkExtraSelections           (0),
228     fVtxRange                   (0),
229     fVtxRangeMin                (0),
230     fMinPtCutOnDaughterTracks   (0),
231     fEtaCutOnDaughterTracks     (0),
232      
233     // - Plots initialisation
234     fListHistCascade(0),
235
236       // Cascades multiplicity plots
237       fHistCascadeMultiplicityBeforeAnySel(0),
238       fHistCascadeMultiplicityAfterSDDSel(0),
239       fHistCascadeMultiplicityAfterPhysicsSel(0),
240       fHistCascadeMultiplicityForSelEvtNoTPCOnly(0),
241       fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
242       fHistCascadeMultiplicityAfterVertexCutSel(0),
243       // Tracks multiplicity plots
244       fHistTrackMultiplicityBeforeAnySel(0),
245       fHistTrackMultiplicityAfterSDDSel(0),
246       fHistTrackMultiplicityAfterPhysicsSel(0),
247       fHistTrackMultiplicityForSelEvtNoTPCOnly(0),
248       fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
249       fHistTrackMultiplicityAfterVertexCutSel(0),
250       // Vertex position plots (BestVertex)
251       fHistPVx(0), fHistPVy(0), fHistPVz(0),
252       fHistPVxAnalysis(0), fHistPVyAnalysis(0), fHistPVzAnalysis(0),
253       // TPC cluster distributions for daughters
254       fHistPosV0TPCClusters(0), fHistNegV0TPCClusters(0), fHistBachTPCClusters(0),
255       // Cut's variables distributions
256       fHistEffMassXi(0),
257       fHistDcaXiDaughters(0),
258       fHistDcaBachToPrimVertex(0),
259       fHistXiCosineOfPointingAngle(0),
260       fHistXiRadius(0),
261       fHistMassLambdaAsCascDghter(0),
262       fHistDcaV0DaughtersXi(0),
263       fHistDcaV0ToPrimVertexXi(0),
264       fHistV0CosineOfPointingAngleXi(0),
265       fHistV0RadiusXi(0),
266       fHistDcaPosToPrimVertexXi(0),
267       fHistDcaNegToPrimVertexXi(0),
268       // Invariant mass distributions
269       fHistMassXiMinus(0), fHistMassXiPlus(0), fHistMassOmegaMinus(0), fHistMassOmegaPlus(0),
270       // Transverse and total momentum distributions
271       fHistXiTransvMom(0), fHistXiTotMom(0), fHistBachTransvMomXi(0), fHistBachTotMomXi(0),
272       // Others QA plots
273       fHistChargeXi(0),
274       fHistV0toXiCosineOfPointingAngle(0),
275       fHistRapXi(0), fHistRapOmega(0),
276       fHistEtaXi(0), fHistEtaBachXi(0), fHistEtaPosXi(0), fHistEtaNegXi(0),
277       fHistThetaXi(0),
278       fHistPhiXi(0),
279       f2dHistArmenteros(0),
280       f2dHistEffMassLambdaVsEffMassXiMinus(0), f2dHistEffMassXiVsEffMassOmegaMinus(0),
281       f2dHistEffMassLambdaVsEffMassXiPlus(0),  f2dHistEffMassXiVsEffMassOmegaPlus(0),
282       f2dHistXiRadiusVsEffMassXiMinus(0),      f2dHistXiRadiusVsEffMassXiPlus(0),
283       f2dHistXiRadiusVsEffMassOmegaMinus(0),   f2dHistXiRadiusVsEffMassOmegaPlus(0),
284       f2dHistTPCdEdxOfCascDghters(0),
285       f2dHistDcaXiDaughtersvsInvMass(0),
286       f2dHistDcaBachToPrimVertexvsInvMass(0),
287       f2dHistXiCosineOfPointingAnglevsInvMass(0),
288       f2dHistMassLambdaAsCascDghtervsInvMass(0),
289       f2dHistDcaV0DaughtersXivsInvMass(0),
290       f2dHistDcaV0ToPrimVertexXivsInvMass(0),
291       // Containers for cuts study 
292       fCFContCascadePIDXiMinus(0),
293       fCFContCascadePIDXiPlus(0),
294       fCFContCascadePIDOmegaMinus(0),
295       fCFContCascadePIDOmegaPlus(0),
296       fCFContCascadeCuts(0)
297     
298     //_____Costructor____
299     {
300      // Define input and output slots here
301      // Input slot #0 works with a TChain
302      // DefineInput(0, TChain::Class());
303      // Output slot #1 writes into a TList container (cascade)
304      if (fCollidingSystem == "pp") {
305          fV0Sels[0] =  33.  ;     // max allowed chi2
306          fV0Sels[1] =   0.01;     // min allowed impact parameter for the 1st daughter 
307          fV0Sels[2] =   0.01;     // min allowed impact parameter for the 2nd daughter 
308          fV0Sels[3] =   1.5;      // max allowed DCA between the daughter tracks       
309          fV0Sels[4] =   0.9;      // min allowed cosine of V0's pointing angle - This is pT dependent        
310          fV0Sels[5] =   0.2;      // min radius of the fiducial volume                 
311          fV0Sels[6] = 200.;       // max radius of the fiducial volume                 
312          fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
313          fCascSels[1] =   0.01;   // min allowed V0 impact parameter                    
314          fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
315          fCascSels[3] =   0.01;   // min allowed bachelor's impact parameter          
316          fCascSels[4] =   2.0;    // max allowed DCA between the V0 and the bachelor    
317          fCascSels[5] =   0.95;   // min allowed cosine of the cascade pointing angle   
318          fCascSels[6] =   0.2;    // min radius of the fiducial volume                  
319          fCascSels[7] = 100.;     // max radius of the fiducial volume 
320      } else if (fCollidingSystem == "pPb") {
321          fV0Sels[0] =  33.  ;     // max allowed chi2
322          fV0Sels[1] =   0.02;     // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
323          fV0Sels[2] =   0.02;     // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
324          fV0Sels[3] =   2.0 ;     // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
325          fV0Sels[4] =   0.95;     // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
326          fV0Sels[5] =   1.0 ;     // min radius of the fiducial volume                 (LHC09a4 : 0.2)
327          fV0Sels[6] = 200.  ;     // max radius of the fiducial volume                 (LHC09a4 : 100.0)
328          fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
329          fCascSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
330          fCascSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
331          fCascSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
332          fCascSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
333          fCascSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
334          fCascSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
335          fCascSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
336      }
337      // Output slot #0 writes into a TList container (Cascade)
338      DefineOutput(1, TList::Class());
339      DefineOutput(2, AliCFContainer::Class());
340      DefineOutput(3, AliCFContainer::Class());
341      DefineOutput(4, AliCFContainer::Class());
342      DefineOutput(5, AliCFContainer::Class());
343      DefineOutput(6, AliCFContainer::Class());
344      AliLog::SetClassDebugLevel("AliAnalysisTaskCheckCascadepp276",1);
345     } 
346
347
348     //_____Destructor_____
349     AliAnalysisTaskCheckCascadepp276::~AliAnalysisTaskCheckCascadepp276() {
350       // For all TH1, 2, 3 HnSparse and CFContainer are in the fListCascade TList.
351       // They will be deleted when fListCascade is deleted by the TSelector dtor
352       // Because of TList::SetOwner() ...   
353        if (fListHistCascade && !AliAnalysisManager::GetAnalysisManager()->IsProofMode())           { delete fListHistCascade; fListHistCascade = 0x0; }
354        if (fCFContCascadePIDXiMinus && !AliAnalysisManager::GetAnalysisManager()->IsProofMode())   { delete fCFContCascadePIDXiMinus; fCFContCascadePIDXiMinus = 0x0; }
355        if (fCFContCascadePIDXiPlus && !AliAnalysisManager::GetAnalysisManager()->IsProofMode())    { delete fCFContCascadePIDXiPlus; fCFContCascadePIDXiPlus = 0x0; }
356        if (fCFContCascadePIDOmegaMinus && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){ delete fCFContCascadePIDOmegaMinus; fCFContCascadePIDOmegaMinus = 0x0; }
357        if (fCFContCascadePIDOmegaPlus && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { delete fCFContCascadePIDOmegaPlus; fCFContCascadePIDOmegaPlus = 0x0; }  
358        if (fCFContCascadeCuts && !AliAnalysisManager::GetAnalysisManager()->IsProofMode())         { delete fCFContCascadeCuts; fCFContCascadeCuts = 0x0; }
359        if (fESDtrackCuts)                                                                          { delete fESDtrackCuts; fESDtrackCuts = 0x0; }
360     }
361
362
363 //________________________________________________________________________
364 void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
365   // Create histograms
366   // Called once
367
368
369  fListHistCascade = new TList();
370  fListHistCascade->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
371
372  //-----------------------------------------------
373  // Particle Identification Setup (new PID object)
374  //-----------------------------------------------
375  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
376  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
377  fPIDResponse = inputHandler->GetPIDResponse();
378  // Only used to get the number of primary reconstructed tracks
379  if (fAnalysisType == "ESD" && (! fESDtrackCuts )){
380    fESDtrackCuts = new AliESDtrackCuts();
381  }
382
383  //---------------------------------------------------
384  // Initialize cuts to re-run V0 and cascade vertexers
385  //---------------------------------------------------
386  // Not validated; to be checked
387  if (fCollidingSystem == "pp") {
388       fV0Sels[0] =  33.  ;     // max allowed chi2
389       fV0Sels[1] =   0.01;     // min allowed impact parameter for the 1st daughter 
390       fV0Sels[2] =   0.01;     // min allowed impact parameter for the 2nd daughter 
391       fV0Sels[3] =   1.5;      // max allowed DCA between the daughter tracks       
392       fV0Sels[4] =   0.9;      // min allowed cosine of V0's pointing angle         
393       fV0Sels[5] =   0.2;      // min radius of the fiducial volume                 
394       fV0Sels[6] = 200.;       // max radius of the fiducial volume                 
395       fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
396       fCascSels[1] =   0.01;   // min allowed V0 impact parameter                    
397       fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
398       fCascSels[3] =   0.01;   // min allowed bachelor's impact parameter          
399       fCascSels[4] =   2.0;    // max allowed DCA between the V0 and the bachelor    
400       fCascSels[5] =   0.95;   // min allowed cosine of the cascade pointing angle   
401       fCascSels[6] =   0.2;    // min radius of the fiducial volume                  
402       fCascSels[7] = 100.;     // max radius of the fiducial volume 
403  } else if (fCollidingSystem == "pPb") {
404       fV0Sels[0] =  33.  ;     // max allowed chi2
405       fV0Sels[1] =   0.02;     // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
406       fV0Sels[2] =   0.02;     // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
407       fV0Sels[3] =   2.0 ;     // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
408       fV0Sels[4] =   0.95;     // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
409       fV0Sels[5] =   1.0 ;     // min radius of the fiducial volume                 (LHC09a4 : 0.2)
410       fV0Sels[6] = 200.  ;     // max radius of the fiducial volume                 (LHC09a4 : 100.0)
411       fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
412       fCascSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
413       fCascSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
414       fCascSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
415       fCascSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
416       fCascSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
417       fCascSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
418       fCascSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
419  }
420
421  //----------------------
422  // Initialize the histos
423  //----------------------
424  
425  // - Cascades multiplicity plots 
426  if(! fHistCascadeMultiplicityBeforeAnySel) {
427         fHistCascadeMultiplicityBeforeAnySel = new TH1F("fHistCascadeMultiplicityBeforeAnySel",
428                         "Cascades per event (before any selections);Nbr of Cascades/Evt;Events",                
429                         20, 0, 20);
430         fListHistCascade->Add(fHistCascadeMultiplicityBeforeAnySel);
431  }
432  if(! fHistCascadeMultiplicityAfterSDDSel) {
433         fHistCascadeMultiplicityAfterSDDSel = new TH1F("fHistCascadeMultiplicityAfterSDDSel", 
434                         "Cascades per event (after the SDD selection);Nbr of Cascades/Evt;Events", 
435                         20, 0, 20);             
436         fListHistCascade->Add(fHistCascadeMultiplicityAfterSDDSel);
437  }
438  if(! fHistCascadeMultiplicityAfterPhysicsSel) {
439         fHistCascadeMultiplicityAfterPhysicsSel = new TH1F("fHistCascadeMultiplicityAfterPhysicsSel",
440                         "Cascades per event (after physics selection);Nbr of Cascades/Evt;Events",
441                         20, 0, 20);
442         fListHistCascade->Add(fHistCascadeMultiplicityAfterPhysicsSel);
443  }
444  if(! fHistCascadeMultiplicityForSelEvtNoTPCOnly) {
445         fHistCascadeMultiplicityForSelEvtNoTPCOnly = new TH1F("fHistCascadeMultiplicityForSelEvtNoTPCOnly",
446                         "Cascades per event (for selected events with well-established PV);Nbr of Cascades/Evt;Events",
447                         20, 0, 20);
448         fListHistCascade->Add(fHistCascadeMultiplicityForSelEvtNoTPCOnly);
449  }
450  if(! fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup) {
451         fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup",
452                         "Cascades per event (for selected events with well-establisched PV and no pile-up);Nbr of Cascades/Evt;Events",
453                         20, 0, 20);
454         fListHistCascade->Add(fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup);
455  }
456  if(! fHistCascadeMultiplicityAfterVertexCutSel) {
457         fHistCascadeMultiplicityAfterVertexCutSel = new TH1F("fHistCascadeMultiplicityAfterVertexCutSel",
458                                                              "Cascades per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
459                                                              20, 0, 20);
460         fListHistCascade->Add(fHistCascadeMultiplicityAfterVertexCutSel);
461  }
462  // - Tracks multiplicity plots 
463  if(! fHistTrackMultiplicityBeforeAnySel) {
464         fHistTrackMultiplicityBeforeAnySel = new TH1F("fHistTrackMultiplicityBeforeAnySel", 
465                         "Tracks per event (before any selections);Nbr of Cascades/Evt;Events", 
466                         100, 0, 100);           
467         fListHistCascade->Add(fHistTrackMultiplicityBeforeAnySel);
468  } 
469  if(! fHistTrackMultiplicityAfterSDDSel) {
470         fHistTrackMultiplicityAfterSDDSel = new TH1F("fHistTrackMultiplicityAfterSDDSel",                  
471                         "Tracks per event (after the SDD selection);Nbr of Cascades/Evt;Events",
472                         100, 0, 100);
473         fListHistCascade->Add(fHistTrackMultiplicityAfterSDDSel);
474  }
475  if(! fHistTrackMultiplicityAfterPhysicsSel) {
476         fHistTrackMultiplicityAfterPhysicsSel = new TH1F("fHistTrackMultiplicityAfterPhysicsSel",
477                         "Tracks per event (after physics selection);Nbr of Cascades/Evt;Events",
478                         100, 0, 100);
479         fListHistCascade->Add(fHistTrackMultiplicityAfterPhysicsSel);
480  }
481  if(! fHistTrackMultiplicityForSelEvtNoTPCOnly) {
482         fHistTrackMultiplicityForSelEvtNoTPCOnly = new TH1F("fHistTrackMultiplicityForSelEvtNoTPCOnly",
483                         "Tracks per event (for selected events with well-established PV);Nbr of Cascades/Evt;Events",
484                         100, 0, 100);
485         fListHistCascade->Add(fHistTrackMultiplicityForSelEvtNoTPCOnly);
486  }
487  if(! fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup) {
488         fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup",
489                         "Tracks per event (for selected events with well-establisched PV and no pile-up);Nbr of Cascades/Evt;Events",
490                         100, 0, 100);
491         fListHistCascade->Add(fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup);
492  }
493  if(! fHistTrackMultiplicityAfterVertexCutSel) {
494         fHistTrackMultiplicityAfterVertexCutSel = new TH1F("fHistTrackMultiplicityAfterVertexCutSel",
495                                                            "Tracks per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
496                                                            100, 0, 100);
497         fListHistCascade->Add(fHistTrackMultiplicityAfterVertexCutSel);
498  }
499  // - Vertex position plots
500  if(! fHistPVx ){
501         fHistPVx = new TH1F("fHistPVx", "Best PV position in x; x (cm); Events", 2000, -0.5, 0.5);
502         fListHistCascade->Add(fHistPVx);
503  }
504  if(! fHistPVy ){
505         fHistPVy = new TH1F("fHistPVy", "Best PV position in y; y (cm); Events", 2000, -0.5, 0.5);
506         fListHistCascade->Add(fHistPVy);
507  }
508  if(! fHistPVz ){
509         fHistPVz = new TH1F("fHistPVz", "Best PV position in z; z (cm); Events", 400, -20, 20);
510         fListHistCascade->Add(fHistPVz);
511  } 
512  if(! fHistPVxAnalysis ){
513         fHistPVxAnalysis = new TH1F("fHistPVxAnalysis", "Best PV position in x (after events selections); x (cm); Events", 2000, -0.5, 0.5);
514         fListHistCascade->Add(fHistPVxAnalysis);
515  }
516  if(! fHistPVyAnalysis ){
517         fHistPVyAnalysis = new TH1F("fHistPVyAnalysis", "Best PV position in y (after events selections); y (cm); Events", 2000, -0.5, 0.5);
518         fListHistCascade->Add(fHistPVyAnalysis);
519  }
520  if(! fHistPVzAnalysis ){
521         fHistPVzAnalysis = new TH1F("fHistPVzAnalysis", "Best PV position in z (after events selections); z (cm); Events", 400, -20, 20);
522         fListHistCascade->Add(fHistPVzAnalysis);
523  }
524  // - TPC clusetr sdistributions for daughters (histos for events containing at least ONE CASCADE)
525  if(! fHistPosV0TPCClusters ){
526         fHistPosV0TPCClusters = new TH1F("fHistPosV0TPCClusters", "TPC clusters for Pos. V0 daughter track, in Casc; Nbr of TPC clusters (V0 Pos.); Track counts", 165, 0.0, 165.0);
527         fListHistCascade->Add(fHistPosV0TPCClusters);
528  }
529  if(! fHistNegV0TPCClusters ){
530         fHistNegV0TPCClusters = new TH1F("fHistNegV0TPCClusters", "TPC clusters for Neg. V0 daughter track, in Casc; Nbr of TPC clusters (V0 Neg.); Track counts", 165, 0.0, 165.0);
531         fListHistCascade->Add(fHistNegV0TPCClusters);
532  }
533  if(! fHistBachTPCClusters ){
534         fHistBachTPCClusters = new TH1F("fHistBachTPCClusters", "TPC clusters for Bachelor track; Nbr of TPC clusters (Bach); Track counts", 165, 0.0, 165.0);
535         fListHistCascade->Add(fHistBachTPCClusters);
536  }
537  // - Cut's variables distributions (typical histos for cascades): as example only for the Xi (both particle and anti-particle)
538  if(! fHistEffMassXi) {
539      fHistEffMassXi = new TH1F("fHistEffMassXi", "Xi candidates; Invariant Mass (GeV/c^{2}); Counts", 400, 1.2, 2.0);
540      fListHistCascade->Add(fHistEffMassXi);
541  }  
542  if(! fHistDcaXiDaughters ){
543      fHistDcaXiDaughters = new TH1F("fHistDcaXiDaughters", "DCA between Xi daughters; DCA (cm); Counts", 210, 0., 2.1);
544      fListHistCascade->Add(fHistDcaXiDaughters);
545  }
546  if(! fHistDcaBachToPrimVertex) {
547      fHistDcaBachToPrimVertex = new TH1F("fHistDcaBachToPrimVertex", "Impact parameter of Bach. to Prim. Vertex; DCA (cm); Counts", 250, 0., 0.25);
548      fListHistCascade->Add(fHistDcaBachToPrimVertex);
549  }
550  if(! fHistXiCosineOfPointingAngle) {
551      fHistXiCosineOfPointingAngle = new TH1F("fHistXiCosineOfPointingAngle", "Cosine of Xi Pointing Angle; Cos (Xi Point.Angl); Counts", 601, 0.94, 1.0001);
552      fListHistCascade->Add(fHistXiCosineOfPointingAngle);
553  }
554  if(! fHistXiRadius ){
555      fHistXiRadius = new TH1F("fHistXiRadius", "Cascade decay transv. radius; r (cm); Counts" , 2050, 0., 205.0);
556      fListHistCascade->Add(fHistXiRadius);
557  }
558  if(! fHistMassLambdaAsCascDghter) {
559      fHistMassLambdaAsCascDghter = new TH1F("fHistMassLambdaAsCascDghter", "#Lambda associated to cascade candidates; Eff. Mass (GeV/c^{2}); Counts", 300, 1.0, 1.3);
560      fListHistCascade->Add(fHistMassLambdaAsCascDghter);
561  }
562  if(! fHistDcaV0DaughtersXi) {
563      fHistDcaV0DaughtersXi = new TH1F("fHistDcaV0DaughtersXi", "DCA between V0 daughters, in cascade; DCA (cm); Counts", 320, 0., 1.6);
564      fListHistCascade->Add(fHistDcaV0DaughtersXi);
565  }
566  if(! fHistDcaV0ToPrimVertexXi) {
567      fHistDcaV0ToPrimVertexXi = new TH1F("fHistDcaV0ToPrimVertexXi", "Impact parameter of V0  to Prim. Vertex, in cascade; DCA (cm); Counts", 200, 0., 1.);
568      fListHistCascade->Add(fHistDcaV0ToPrimVertexXi);
569  }
570  if(! fHistV0CosineOfPointingAngleXi) {
571      fHistV0CosineOfPointingAngleXi = new TH1F("fHistV0CosineOfPointingAngleXi", "Cosine of V0 Pointing Angle, in cascade; Cos(V0 Point. Angl); Counts", 201, 0.8, 1.001);
572      fListHistCascade->Add(fHistV0CosineOfPointingAngleXi);
573  }
574  if(! fHistV0RadiusXi) {
575      fHistV0RadiusXi = new TH1F("fHistV0RadiusXi", "V0 decay radius, in cascade; radius (cm); Counts", 2050, 0., 205.0);
576      fListHistCascade->Add(fHistV0RadiusXi);
577  }
578  if(! fHistDcaPosToPrimVertexXi) {
579      fHistDcaPosToPrimVertexXi = new TH1F("fHistDcaPosToPrimVertexXi", "Impact parameter of V0 pos daughter to Prim. Vertex; DCA (cm); Counts", 300, 0, 3);
580      fListHistCascade->Add(fHistDcaPosToPrimVertexXi);
581  }
582  if(! fHistDcaNegToPrimVertexXi) {
583      fHistDcaNegToPrimVertexXi = new TH1F("fHistDcaNegToPrimVertexXi", "Impact parameter of V0 neg daughter to Prim. Vertex; DCA (cm); Counts", 300, 0, 3);
584      fListHistCascade->Add(fHistDcaNegToPrimVertexXi);
585  }
586  // - Effective mass histos for cascades.
587     //By cascade hyp  
588  if(! fHistMassXiMinus) {
589      fHistMassXiMinus = new TH1F("fHistMassXiMinus", "#Xi^{-} candidates; M( #Lambda , #pi^{-} ) (GeV/c^{2});Counts", 400, 1.2, 2.0);
590      fListHistCascade->Add(fHistMassXiMinus);
591  } 
592  if(! fHistMassXiPlus) {
593      fHistMassXiPlus = new TH1F("fHistMassXiPlus", "#Xi^{+} candidates; M( #bar{#Lambda}^{0} , #pi^{+} ) (GeV/c^{2});Counts", 400, 1.2, 2.0);
594      fListHistCascade->Add(fHistMassXiPlus);
595  }
596  if(! fHistMassOmegaMinus) {
597      fHistMassOmegaMinus = new TH1F("fHistMassOmegaMinus", "#Omega^{-} candidates; M( #Lambda , K^{-} ) (GeV/c^{2});Counts", 500, 1.5, 2.5);
598      fListHistCascade->Add(fHistMassOmegaMinus);
599  }
600  if(! fHistMassOmegaPlus) {
601      fHistMassOmegaPlus = new TH1F("fHistMassOmegaPlus", "#Omega^{+} candidates;M( #bar{#Lambda}^{0} , K^{+} ) (GeV/c^{2}); Counts", 500, 1.5, 2.5);
602      fListHistCascade->Add(fHistMassOmegaPlus);
603  }
604  // - Transverse and total momentum distributions
605  if(! fHistXiTransvMom ){
606      fHistXiTransvMom = new TH1F("fHistXiTransvMom", "#Xi transverse momentum (cand. around the mass peak); p_{t}(#Xi) (GeV/c); Counts", 100, 0.0, 10.0);
607      fListHistCascade->Add(fHistXiTransvMom);
608  }
609  if(! fHistXiTotMom ){
610      fHistXiTotMom = new TH1F("fHistXiTotMom", "#Xi momentum norm (cand. around the mass peak); p_{tot}(#Xi) (GeV/c); Counts", 150, 0.0, 15.0);
611      fListHistCascade->Add(fHistXiTotMom);
612  }
613  if(! fHistBachTransvMomXi ){
614      fHistBachTransvMomXi = new TH1F("fHistBachTransvMomXi", "#Xi Bach. transverse momentum (cand. around the mass peak); p_{t}(Bach.) (GeV/c); Counts", 100, 0.0, 5.0);
615      fListHistCascade->Add(fHistBachTransvMomXi);
616  }
617  if(! fHistBachTotMomXi ){
618      fHistBachTotMomXi = new TH1F("fHistBachTotMomXi", "#Xi Bach. momentum norm (cand. around the mass peak); p_{tot}(Bach.) (GeV/c); Counts", 100, 0.0, 5.0);
619      fListHistCascade->Add(fHistBachTotMomXi);
620  }
621  // - Others QA plots
622     //TH1
623  if(! fHistChargeXi ){
624      fHistChargeXi = new TH1F("fHistChargeXi", "Charge of Xi candidates; Sign; Counts", 5, -2.0, 3.0);
625      fListHistCascade->Add(fHistChargeXi);
626  }
627  if(! fHistV0toXiCosineOfPointingAngle) {
628      fHistV0toXiCosineOfPointingAngle = new TH1F("fHistV0toXiCosineOfPointingAngle", "Cos. of V0 Ptng Angl / Xi vtx ; Cos(V0 Point. Angl / Xi vtx); Counts", 1101, 0.89, 1.0001);
629      fListHistCascade->Add(fHistV0toXiCosineOfPointingAngle);
630  }
631  if(! fHistRapXi ){
632      fHistRapXi = new TH1F("fHistRapXi", "Rapidity of #Xi candidates (around the mass peak); y; Counts", 20, -1.0, 1.0);
633      fListHistCascade->Add(fHistRapXi);
634  }
635  if(! fHistRapOmega ){
636      fHistRapOmega = new TH1F("fHistRapOmega", "Rapidity of #Omega candidates (around the mass peak); y; Counts", 20, -1.0, 1.0);
637      fListHistCascade->Add(fHistRapOmega);
638  }
639  if(! fHistEtaXi ){
640      fHistEtaXi = new TH1F("fHistEtaXi", "Pseudo-rap. of #Xi candidates (around the mass peak); #eta; Counts", 20, -1.0, 1.0);
641      fListHistCascade->Add(fHistEtaXi);
642  }
643  if(! fHistEtaBachXi){
644      fHistEtaBachXi = new TH1F("fHistEtaBachXi", "Pseudo-rap. of #Xi bachelor; #eta; Counts", 40, -2.0, 2.0);
645      fListHistCascade->Add(fHistEtaBachXi);
646  }
647  if(! fHistEtaPosXi){
648      fHistEtaPosXi = new TH1F("fHistEtaPosXi", "Pseudo-rap. of #Xi positive meson daughter; #eta; Counts", 40, -2.0, 2.0);
649      fListHistCascade->Add(fHistEtaPosXi);
650  }
651  if(! fHistEtaNegXi){
652      fHistEtaNegXi = new TH1F("fHistEtaNegXi", "Pseudo-rap. of #Xi negative meson daughter; #eta; Counts", 40, -2.0, 2.0);
653      fListHistCascade->Add(fHistEtaNegXi);
654  }
655  if(! fHistThetaXi ){
656      fHistThetaXi = new TH1F("fHistThetaXi", "#theta of #Xi candidates (around the mass peak); #theta (deg); Counts", 180, 0., 180.0);
657      fListHistCascade->Add(fHistThetaXi);
658  }
659  if(! fHistPhiXi ){
660      fHistPhiXi = new TH1F("fHistPhiXi", "#phi of #Xi candidates (around the mass peak); #phi (deg); Counts", 360, 0., 360.);
661      fListHistCascade->Add(fHistPhiXi);
662  }
663  if(! f2dHistArmenteros) {
664      f2dHistArmenteros = new TH2F("f2dHistArmenteros", "#alpha_{Arm}(casc. cand.) Vs Pt_{Arm}(casc. cand.); #alpha_{Arm}; Pt_{Arm} (GeV/c)", 140, -1.2, 1.2, 300, 0., 0.3);
665      fListHistCascade->Add(f2dHistArmenteros);
666  }
667     //TH2
668  if(! f2dHistEffMassLambdaVsEffMassXiMinus) {
669      f2dHistEffMassLambdaVsEffMassXiMinus = new TH2F("f2dHistEffMassLambdaVsEffMassXiMinus", "M_{#Lambda} Vs M_{#Xi^{-} candidates}; Inv. M_{#Lambda^{0}} (GeV/c^{2}); M( #Lambda , #pi^{-} ) (GeV/c^{2})", 300, 1.1, 1.13, 400, 1.2, 2.0);
670      fListHistCascade->Add(f2dHistEffMassLambdaVsEffMassXiMinus);
671  }
672  if(! f2dHistEffMassXiVsEffMassOmegaMinus) {
673      f2dHistEffMassXiVsEffMassOmegaMinus = new TH2F("f2dHistEffMassXiVsEffMassOmegaMinus", "M_{#Xi^{-} candidates} Vs M_{#Omega^{-} candidates}; M( #Lambda , #pi^{-} ) (GeV/c^{2}); M( #Lambda , K^{-} ) (GeV/c^{2})", 400, 1.2, 2.0, 500, 1.5, 2.5);
674      fListHistCascade->Add(f2dHistEffMassXiVsEffMassOmegaMinus);
675  }
676  if(! f2dHistEffMassLambdaVsEffMassXiPlus) {
677      f2dHistEffMassLambdaVsEffMassXiPlus = new TH2F("f2dHistEffMassLambdaVsEffMassXiPlus", "M_{#Lambda} Vs M_{#Xi^{+} candidates}; Inv. M_{#Lambda^{0}} (GeV/c^{2}); M( #Lambda , #pi^{+} ) (GeV/c^{2})", 300, 1.1, 1.13, 400, 1.2, 2.0);
678      fListHistCascade->Add(f2dHistEffMassLambdaVsEffMassXiPlus);
679  }
680  if(! f2dHistEffMassXiVsEffMassOmegaPlus) {
681      f2dHistEffMassXiVsEffMassOmegaPlus = new TH2F("f2dHistEffMassXiVsEffMassOmegaPlus", "M_{#Xi^{+} candidates} Vs M_{#Omega^{+} candidates}; M( #Lambda , #pi^{+} ) (GeV/c^{2}); M( #Lambda , K^{+} ) (GeV/c^{2})", 400, 1.2, 2.0, 500, 1.5, 2.5);
682      fListHistCascade->Add(f2dHistEffMassXiVsEffMassOmegaPlus);
683  }
684  if(! f2dHistXiRadiusVsEffMassXiMinus) {
685      f2dHistXiRadiusVsEffMassXiMinus = new TH2F("f2dHistXiRadiusVsEffMassXiMinus", "Transv. R_{Xi Decay} Vs M_{#Xi^{-} candidates}; r_{cascade} (cm); M( #Lambda , #pi^{-} ) (GeV/c^{2})", 450, 0., 45.0, 400, 1.2, 2.0);
686      fListHistCascade->Add(f2dHistXiRadiusVsEffMassXiMinus);
687  }
688  if(! f2dHistXiRadiusVsEffMassXiPlus) {
689      f2dHistXiRadiusVsEffMassXiPlus = new TH2F("f2dHistXiRadiusVsEffMassXiPlus", "Transv. R_{Xi Decay} Vs M_{#Xi^{+} candidates}; r_{cascade} (cm); M( #Lambda , #pi^{+} ) (GeV/c^{2})", 450, 0., 45.0, 400, 1.2, 2.0);
690      fListHistCascade->Add(f2dHistXiRadiusVsEffMassXiPlus);
691  }
692  if(! f2dHistXiRadiusVsEffMassOmegaMinus) {
693      f2dHistXiRadiusVsEffMassOmegaMinus = new TH2F("f2dHistXiRadiusVsEffMassOmegaMinus", "Transv. R_{Xi Decay} Vs M_{#Omega^{-} candidates}; r_{cascade} (cm); M( #Lambda , K^{-} ) (GeV/c^{2}) ", 450, 0., 45.0, 500, 1.5, 2.5);
694      fListHistCascade->Add(f2dHistXiRadiusVsEffMassOmegaMinus);
695  }
696  if(! f2dHistXiRadiusVsEffMassOmegaPlus) {
697      f2dHistXiRadiusVsEffMassOmegaPlus = new TH2F("f2dHistXiRadiusVsEffMassOmegaPlus", "Transv. R_{Xi Decay} Vs M_{#Omega^{+} candidates}; r_{cascade} (cm); M( #Lambda , K^{+} ) (GeV/c^{2}) ", 450, 0., 45.0, 500, 1.5, 2.5);
698      fListHistCascade->Add(f2dHistXiRadiusVsEffMassOmegaPlus);
699  }
700  if(! f2dHistTPCdEdxOfCascDghters){
701      f2dHistTPCdEdxOfCascDghters = new TH2F("f2dHistTPCdEdxOfCascDghters", "TPC dE/dx of the cascade daughters; charge x || #vec{p}_{TPC inner wall}(Casc. daughter) || (GeV/c); TPC signal (ADC)", 2000, -10.0, 10.0, 450, 0., 900.);
702      fListHistCascade->Add(f2dHistTPCdEdxOfCascDghters);
703  }
704  if(! f2dHistDcaXiDaughtersvsInvMass){
705      f2dHistDcaXiDaughtersvsInvMass = new TH2F("f2dHistDcaXiDaughtersvsInvMass", "DCA between Xi Daughters; DCA (cm); Number of Cascades", 100, 0., 0.5, 400, 1.2, 2.0);
706      fListHistCascade->Add(f2dHistDcaXiDaughtersvsInvMass);
707  }
708  if(! f2dHistDcaBachToPrimVertexvsInvMass) {
709      f2dHistDcaBachToPrimVertexvsInvMass = new TH2F("f2dHistDcaBachToPrimVertexvsInvMass", "DCA of Bach. to Prim. Vertex; DCA (cm); Number of Cascades", 250, 0., 0.25, 400, 1.2, 2.0);
710      fListHistCascade->Add(f2dHistDcaBachToPrimVertexvsInvMass);
711  }
712  if(! f2dHistXiCosineOfPointingAnglevsInvMass){
713      f2dHistXiCosineOfPointingAnglevsInvMass = new TH2F("f2dHistXiCosineOfPointingAnglevsInvMass", "Cosine of Xi Pointing Angle; Cos (Xi Point.Angl); Number of Xis", 200, 0.99, 1.0, 400, 1.2, 2.0);
714      fListHistCascade->Add(f2dHistXiCosineOfPointingAnglevsInvMass);
715  }
716  if(! f2dHistMassLambdaAsCascDghtervsInvMass){ 
717      f2dHistMassLambdaAsCascDghtervsInvMass = new TH2F("f2dHistMassLambdaAsCascDghtervsInvMass","#Lambda associated to Casc. candidates; Eff. Mass (GeV/c^{2}); Counts", 300, 1.00, 1.3, 400, 1.2, 2.0);
718      fListHistCascade->Add(f2dHistMassLambdaAsCascDghtervsInvMass);
719  }
720  if(! f2dHistDcaV0DaughtersXivsInvMass){
721      f2dHistDcaV0DaughtersXivsInvMass = new TH2F("f2dHistDcaV0DaughtersXivsInvMass", "DCA between V0 daughters, in cascade; DCA (cm); Number of V0s", 120, 0., 0.6, 400, 1.2, 2.0);
722      fListHistCascade->Add(f2dHistDcaV0DaughtersXivsInvMass);
723  }
724  if(! f2dHistDcaV0ToPrimVertexXivsInvMass){
725      f2dHistDcaV0ToPrimVertexXivsInvMass = new TH2F("f2dHistDcaV0ToPrimVertexXivsInvMass", "DCA of V0 to Prim. Vertex, in cascade; DCA (cm); Number of Cascades", 200, 0., 1., 400, 1.2, 2.0);
726      fListHistCascade->Add(f2dHistDcaV0ToPrimVertexXivsInvMass);
727  }
728  // - CFContainer PID study Xi minus
729  if(!fCFContCascadePIDXiMinus)  {
730    const Int_t  lNbSteps      =  7 ;
731    const Int_t  lNbVariables  =  3 ;
732      //Array for the number of bins in each dimension :
733    Int_t lNbBinsPerVar[3] = {0};
734    lNbBinsPerVar[0] = 100;
735    lNbBinsPerVar[1] = 800;
736    lNbBinsPerVar[2] = 22;
737    if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
738         if (fwithSDD) fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
739                                                                     fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
740                                                                     "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
741         else if (!fwithSDD) fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
742                                                                     fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
743                                                                     "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar ); 
744    } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
745         fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
746                                                       fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
747                                                       "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
748    } else if (fCollidingSystem == "pPb") {
749         fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
750                                                       fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
751                                                       "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
752    }
753      //Setting the bin limits 
754    fCFContCascadePIDXiMinus->SetBinLimits(0,   0.0  ,  10.0 );  // Pt(Cascade)
755    fCFContCascadePIDXiMinus->SetBinLimits(1,   1.2  ,   2.0 );  // Xi Effective mass
756    fCFContCascadePIDXiMinus->SetBinLimits(2,  -1.1  ,   1.1 );  // Rapidity
757      //Setting the step title : one per PID case
758    fCFContCascadePIDXiMinus->SetStepTitle(0, "No PID");
759    fCFContCascadePIDXiMinus->SetStepTitle(1, "TPC PID / 4-#sigma cut on Bachelor track");
760    fCFContCascadePIDXiMinus->SetStepTitle(2, "TPC PID / 4-#sigma cut on Bachelor+Baryon tracks");
761    fCFContCascadePIDXiMinus->SetStepTitle(3, "TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks");
762    fCFContCascadePIDXiMinus->SetStepTitle(4, "Comb. PID / Bachelor");
763    fCFContCascadePIDXiMinus->SetStepTitle(5, "Comb. PID / Bachelor+Baryon");
764    fCFContCascadePIDXiMinus->SetStepTitle(6, "Comb. PID / Bachelor+Baryon+Meson");  
765      //Setting the variable title, per axis
766    fCFContCascadePIDXiMinus->SetVarTitle(0, "Pt_{cascade} (GeV/c)");
767    fCFContCascadePIDXiMinus->SetVarTitle(1, "M( #Lambda , #pi^{-} ) (GeV/c^{2})");
768    fCFContCascadePIDXiMinus->SetVarTitle(2, "Y_{#Xi}");
769    fListHistCascade->Add(fCFContCascadePIDXiMinus);
770  }
771  // - CFContainer PID study Xi plus
772  if (!fCFContCascadePIDXiPlus) {
773    const Int_t  lNbSteps      =  7 ;
774    const Int_t  lNbVariables  =  3 ;
775      //Array for the number of bins in each dimension :
776    Int_t lNbBinsPerVar[3] = {0};
777    lNbBinsPerVar[0] = 100;
778    lNbBinsPerVar[1] = 800;
779    lNbBinsPerVar[2] = 22;
780    if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
781         if (fwithSDD) fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
782                                                                    fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
783                                                                    "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
784         else if (!fwithSDD) fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
785                                                                          fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
786                                                                          "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
787    } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) { 
788         fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
789                                                      fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
790                                                      "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
791    } else if (fCollidingSystem == "pPb") {
792         fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
793                                                      fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
794                                                      "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
795    }
796      //Setting the bin limits 
797    fCFContCascadePIDXiPlus->SetBinLimits(0,   0.0  ,  10.0 );   // Pt(Cascade)
798    fCFContCascadePIDXiPlus->SetBinLimits(1,   1.2  ,   2.0 );   // Xi Effective mass
799    fCFContCascadePIDXiPlus->SetBinLimits(2,  -1.1  ,   1.1 );   // Rapidity
800      //Setting the step title : one per PID case
801    fCFContCascadePIDXiPlus->SetStepTitle(0, "No PID");
802    fCFContCascadePIDXiPlus->SetStepTitle(1, "TPC PID / 4-#sigma cut on Bachelor track");
803    fCFContCascadePIDXiPlus->SetStepTitle(2, "TPC PID / 4-#sigma cut on Bachelor+Baryon tracks");
804    fCFContCascadePIDXiPlus->SetStepTitle(3, "TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks");
805    fCFContCascadePIDXiPlus->SetStepTitle(4, "Comb. PID / Bachelor");
806    fCFContCascadePIDXiPlus->SetStepTitle(5, "Comb. PID / Bachelor+Baryon");
807    fCFContCascadePIDXiPlus->SetStepTitle(6, "Comb. PID / Bachelor+Baryon+Meson");
808      //Setting the variable title, per axis
809    fCFContCascadePIDXiPlus->SetVarTitle(0, "Pt_{cascade} (GeV/c)");
810    fCFContCascadePIDXiPlus->SetVarTitle(1, "M( #Lambda , #pi^{+} ) (GeV/c^{2})");
811    fCFContCascadePIDXiPlus->SetVarTitle(2, "Y_{#Xi}");
812    fListHistCascade->Add(fCFContCascadePIDXiPlus);
813  }
814  // - CFContainer PID study Omega minus
815  if(!fCFContCascadePIDOmegaMinus)  {
816    const Int_t  lNbSteps      =  7 ;
817    const Int_t  lNbVariables  =  3 ;
818      //Array for the number of bins in each dimension :
819    Int_t lNbBinsPerVar[3] = {0};
820    lNbBinsPerVar[0] = 100;
821    lNbBinsPerVar[1] = 1000;
822    lNbBinsPerVar[2] = 22;
823    if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
824         if (fwithSDD) fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
825                                                                        fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
826                                                                        "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
827         else if (!fwithSDD) fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
828                                                                              fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
829                                                                              "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
830    } else if (!fkSDDSelectionOn) {
831         fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
832                                                          fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
833                                                          "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
834    } else if (fCollidingSystem == "pPb") {
835         fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
836                                                          fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
837                                                          "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
838    }
839      //Setting the bin limits 
840    fCFContCascadePIDOmegaMinus->SetBinLimits(0,   0.0  ,  10.0 );       // Pt(Cascade)
841    fCFContCascadePIDOmegaMinus->SetBinLimits(1,   1.5  ,   2.5 );       // Omega Effective mass
842    fCFContCascadePIDOmegaMinus->SetBinLimits(2,  -1.1  ,   1.1 );       // Rapidity
843      //Setting the step title : one per PID case
844    fCFContCascadePIDOmegaMinus->SetStepTitle(0, "No PID");
845    fCFContCascadePIDOmegaMinus->SetStepTitle(1, "TPC PID / 4-#sigma cut on Bachelor track");
846    fCFContCascadePIDOmegaMinus->SetStepTitle(2, "TPC PID / 4-#sigma cut on Bachelor+Baryon tracks");
847    fCFContCascadePIDOmegaMinus->SetStepTitle(3, "TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks");
848    fCFContCascadePIDOmegaMinus->SetStepTitle(4, "Comb. PID / Bachelor");
849    fCFContCascadePIDOmegaMinus->SetStepTitle(5, "Comb. PID / Bachelor+Baryon");
850    fCFContCascadePIDOmegaMinus->SetStepTitle(6, "Comb. PID / Bachelor+Baryon+Meson");
851      //Setting the variable title, per axis
852    fCFContCascadePIDOmegaMinus->SetVarTitle(0, "Pt_{cascade} (GeV/c)");
853    fCFContCascadePIDOmegaMinus->SetVarTitle(1, "M( #Lambda , K^{-} ) (GeV/c^{2})");
854    fCFContCascadePIDOmegaMinus->SetVarTitle(2, "Y_{#Omega}");
855    fListHistCascade->Add(fCFContCascadePIDOmegaMinus);
856  }
857  // - CFContainer PID study Omega plus
858  if(!fCFContCascadePIDOmegaPlus)  {
859    const Int_t  lNbSteps      =  7 ;
860    const Int_t  lNbVariables  =  3 ;
861      //Array for the number of bins in each dimension :
862    Int_t lNbBinsPerVar[3] = {0};
863    lNbBinsPerVar[0] = 100;
864    lNbBinsPerVar[1] = 1000;
865    lNbBinsPerVar[2] = 22; 
866    if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
867         if (fwithSDD) fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
868                                                                       fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
869                                                                       "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
870         else if (!fwithSDD) fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
871                                                                             fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
872                                                                             "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
873    } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
874         fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
875                                                         fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
876                                                         "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
877    } else if (fCollidingSystem == "pPb") {
878         fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
879                                                         fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
880                                                         "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
881    }
882      //Setting the bin limits 
883    fCFContCascadePIDOmegaPlus->SetBinLimits(0,   0.0  ,  10.0 );        // Pt(Cascade)
884    fCFContCascadePIDOmegaPlus->SetBinLimits(1,   1.5  ,   2.5 );        // Omega Effective mass
885    fCFContCascadePIDOmegaPlus->SetBinLimits(2,  -1.1  ,   1.1 );        // Rapidity 
886      //Setting the step title : one per PID case
887    fCFContCascadePIDOmegaPlus->SetStepTitle(0, "No PID");
888    fCFContCascadePIDOmegaPlus->SetStepTitle(1, "TPC PID / 4-#sigma cut on Bachelor track");
889    fCFContCascadePIDOmegaPlus->SetStepTitle(2, "TPC PID / 4-#sigma cut on Bachelor+Baryon tracks");
890    fCFContCascadePIDOmegaPlus->SetStepTitle(3, "TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks");
891    fCFContCascadePIDOmegaPlus->SetStepTitle(4, "Comb. PID / Bachelor");
892    fCFContCascadePIDOmegaPlus->SetStepTitle(5, "Comb. PID / Bachelor+Baryon");
893    fCFContCascadePIDOmegaPlus->SetStepTitle(6, "Comb. PID / Bachelor+Baryon+Meson");
894      //Setting the variable title, per axis
895    fCFContCascadePIDOmegaPlus->SetVarTitle(0, "Pt_{cascade} (GeV/c)");
896    fCFContCascadePIDOmegaPlus->SetVarTitle(1, "M( #Lambda , K^{+} ) (GeV/c^{2})");
897    fCFContCascadePIDOmegaPlus->SetVarTitle(2, "Y_{#Omega}");  
898    fListHistCascade->Add(fCFContCascadePIDOmegaPlus);
899  }
900  // - CFContainer: towards the optimisation of topological selections
901  if(! fCFContCascadeCuts) {
902         // Container meant to store all the relevant distributions corresponding to the cut variables.
903         // NB: overflow/underflow of variables on which we want to cut later should be 0!!! 
904    const Int_t  lNbSteps      =  4 ;
905    const Int_t  lNbVariables  =  19 ;
906      //Array for the number of bins in each dimension :
907    Int_t lNbBinsPerVar[lNbVariables] = {0};
908    lNbBinsPerVar[0]  = 25;     //DcaCascDaughters             :  [0.0,2.4,3.0]       -> Rec.Cut = 2.0;
909    lNbBinsPerVar[1]  = 25;     //DcaBachToPrimVertex          :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01; 
910    lNbBinsPerVar[2]  = 60;     //CascCosineOfPointingAngle    :  [0.94,1.0]          -> Rec.Cut = 0.95;
911    lNbBinsPerVar[3]  = 40;     //CascRadius                   :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
912    lNbBinsPerVar[4]  = 30;     //InvMassLambdaAsCascDghter    :  [1.1,1.3]           -> Rec.Cut = 0.008;
913    lNbBinsPerVar[5]  = 20;     //DcaV0Daughters               :  [0.0,2.0]           -> Rec.Cut = 1.5;
914    lNbBinsPerVar[6]  = 201;    //V0CosineOfPointingAngleToXi  :  [0.89,1.0]          -> No Rec.Cut;
915    lNbBinsPerVar[7]  = 40;     //V0Radius                     :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
916    lNbBinsPerVar[8]  = 40;     //DcaV0ToPrimVertex            :  [0.0,0.39,110.0]    -> Rec.Cut = 0.01;  
917    lNbBinsPerVar[9]  = 25;     //DcaPosToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01;
918    lNbBinsPerVar[10] = 25;     //DcaNegToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01;
919    lNbBinsPerVar[11] = 150;    //InvMassXi                    :   2-MeV/c2 bins
920    lNbBinsPerVar[12] = 120;    //InvMassOmega                 :   2-MeV/c2 bins
921    lNbBinsPerVar[13] = 100;    //XiTransvMom                  :  [0.0,10.0]
922    lNbBinsPerVar[14] = 110;    //Y(Xi)                        :   0.02 in rapidity units
923    lNbBinsPerVar[15] = 110;    //Y(Omega)                     :   0.02 in rapidity units
924    lNbBinsPerVar[16] = 112;    //Proper lenght of cascade       
925    lNbBinsPerVar[17] = 112;    //Proper lenght of V0
926    lNbBinsPerVar[18] = 112;    //Distance V0-Xi in transverse plane
927    if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
928         if (fwithSDD) fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
929                                                               fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
930                                                               "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
931         else if (!fwithSDD) fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
932                                                                     fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
933                                                                     "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
934    } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
935         fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
936                                                 fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
937                                                 "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
938    } else if (fCollidingSystem == "pPb") {
939         fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
940                                                 fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
941                                                 "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
942    }
943      //Setting the bin limits 
944      //0 -  DcaXiDaughters
945    Double_t *lBinLim0  = new Double_t[ lNbBinsPerVar[0] + 1 ];
946         for(Int_t i=0; i< lNbBinsPerVar[0]; i++) lBinLim0[i] = (Double_t)0.0 + (2.4 - 0.0)/(lNbBinsPerVar[0] - 1) * (Double_t)i;
947         lBinLim0[ lNbBinsPerVar[0] ] = 3.0;
948    fCFContCascadeCuts -> SetBinLimits(0, lBinLim0);  
949    delete [] lBinLim0;
950      //1 - DcaToPrimVertexXi
951    Double_t *lBinLim1  = new Double_t[ lNbBinsPerVar[1] + 1 ];
952         for(Int_t i=0; i<lNbBinsPerVar[1]; i++) lBinLim1[i] = (Double_t)0.0 + (0.24  - 0.0)/(lNbBinsPerVar[1] - 1) * (Double_t)i;
953         lBinLim1[ lNbBinsPerVar[1] ] = 100.0;
954    fCFContCascadeCuts -> SetBinLimits(1, lBinLim1);  
955    delete [] lBinLim1;    
956      //2 - CascCosineOfPointingAngle 
957    fCFContCascadeCuts->SetBinLimits(2, 0.94, 1.);
958      //3 - CascRadius
959    Double_t *lBinLim3  = new Double_t[ lNbBinsPerVar[3]+1 ];
960         for(Int_t i=0; i< lNbBinsPerVar[3]; i++)   lBinLim3[i]  = (Double_t)0.0   + (3.9  - 0.0 )/(lNbBinsPerVar[3] - 1)  * (Double_t)i ;
961         lBinLim3[ lNbBinsPerVar[3] ] = 1000.0;
962    fCFContCascadeCuts -> SetBinLimits(3,  lBinLim3 );        
963    delete [] lBinLim3;
964      //4 - InvMassLambdaAsCascDghter
965    fCFContCascadeCuts->SetBinLimits(4, 1.1, 1.13);
966      //5 - DcaV0Daughters
967    fCFContCascadeCuts -> SetBinLimits(5, 0., 2.);
968      //6 - V0CosineOfPointingAngle
969    fCFContCascadeCuts -> SetBinLimits(6, 0.8, 1.001);
970      //7 - V0Radius
971    Double_t *lBinLim7 = new Double_t[ lNbBinsPerVar[7] + 1];
972         for(Int_t i=0; i< lNbBinsPerVar[7];i++) lBinLim7[i] = (Double_t)0.0 + (3.9 - 0.0)/(lNbBinsPerVar[7] - 1) * (Double_t)i;
973         lBinLim7[ lNbBinsPerVar[7] ] = 1000.0;
974    fCFContCascadeCuts -> SetBinLimits(7, lBinLim7); 
975    delete [] lBinLim7;
976      //8 - DcaV0ToPrimVertex
977    Double_t *lBinLim8  = new Double_t[ lNbBinsPerVar[8]+1 ];
978         for(Int_t i=0; i< lNbBinsPerVar[8];i++)   lBinLim8[i]  = (Double_t)0.0   + (0.39  - 0.0 )/(lNbBinsPerVar[8]-1)  * (Double_t)i ;
979         lBinLim8[ lNbBinsPerVar[8]  ] = 100.0;
980    fCFContCascadeCuts -> SetBinLimits(8,  lBinLim8 );    
981    delete [] lBinLim8;
982      //9 - DcaPosToPrimVertex
983    Double_t *lBinLim9  = new Double_t[ lNbBinsPerVar[9]+1 ];
984         for(Int_t i=0; i< lNbBinsPerVar[9];i++)   lBinLim9[i]  = (Double_t)0.0   + (0.24  - 0.0 )/(lNbBinsPerVar[9]-1)  * (Double_t)i ;
985         lBinLim9[ lNbBinsPerVar[9]  ] = 100.0;
986    fCFContCascadeCuts -> SetBinLimits(9,  lBinLim9 );        
987    delete [] lBinLim9;
988      //10 - DcaNegToPrimVertex
989    Double_t *lBinLim10  = new Double_t[ lNbBinsPerVar[10]+1 ];
990         for(Int_t i=0; i< lNbBinsPerVar[10];i++)   lBinLim10[i]  = (Double_t)0.0   + (0.24  - 0.0 )/(lNbBinsPerVar[10]-1)  * (Double_t)i ;
991         lBinLim10[ lNbBinsPerVar[10]  ] = 100.0;
992    fCFContCascadeCuts -> SetBinLimits(10,  lBinLim10 );            // DcaPosToPrimVertexXi : 0.0 to 0.25 
993    delete [] lBinLim10;
994      //11 - InvMassXi
995    fCFContCascadeCuts->SetBinLimits(11, 1.25, 1.40);
996      //12 - InvMassOmega
997    fCFContCascadeCuts->SetBinLimits(12, 1.62, 1.74);
998      //13 - XiTransvMom
999    fCFContCascadeCuts->SetBinLimits(13, 0.0, 10.0); 
1000      //14 - Y(Xi)
1001    fCFContCascadeCuts->SetBinLimits(14, -1.1, 1.1);
1002      //15 - Y(Omega)
1003    fCFContCascadeCuts->SetBinLimits(15, -1.1, 1.1);
1004      //16 - Proper time of cascade
1005    Double_t *lBinLim16  = new Double_t[ lNbBinsPerVar[16]+1 ];
1006    for(Int_t i=0; i< lNbBinsPerVar[16];i++) lBinLim16[i] = (Double_t) -1. + (110. + 1.0 ) / (lNbBinsPerVar[16] - 1) * (Double_t) i;
1007    lBinLim16[ lNbBinsPerVar[16] ] = 2000.0;
1008    fCFContCascadeCuts->SetBinLimits(16, lBinLim16);
1009      //17 - Proper time of V0
1010    fCFContCascadeCuts->SetBinLimits(17, lBinLim16);
1011      //18 - Distance V0-Xi in transverse plane
1012    fCFContCascadeCuts->SetBinLimits(18, lBinLim16);
1013      // Setting the number of steps : one for each cascade species (Xi-, Xi+ and Omega-, Omega+)
1014    fCFContCascadeCuts->SetStepTitle(0, "#Xi^{-} candidates");
1015    fCFContCascadeCuts->SetStepTitle(1, "#bar{#Xi}^{+} candidates");
1016    fCFContCascadeCuts->SetStepTitle(2, "#Omega^{-} candidates");
1017    fCFContCascadeCuts->SetStepTitle(3, "#bar{#Omega}^{+} candidates");
1018      // Setting the variable title, per axis
1019    fCFContCascadeCuts->SetVarTitle(0,  "Dca(cascade daughters) (cm)");
1020    fCFContCascadeCuts->SetVarTitle(1,  "ImpactParamToPV(bachelor) (cm)");
1021    fCFContCascadeCuts->SetVarTitle(2,  "cos(cascade PA)");
1022    fCFContCascadeCuts->SetVarTitle(3,  "R_{2d}(cascade decay) (cm)");
1023    fCFContCascadeCuts->SetVarTitle(4,  "M_{#Lambda}(as casc dghter) (GeV/c^{2})");
1024    fCFContCascadeCuts->SetVarTitle(5,  "Dca(V0 daughters) in Xi (cm)");
1025    fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 PA) to cascade vtx");
1026    fCFContCascadeCuts->SetVarTitle(7,  "R_{2d}(V0 decay) (cm)");
1027    fCFContCascadeCuts->SetVarTitle(8,  "ImpactParamToPV(V0) (cm)");
1028    fCFContCascadeCuts->SetVarTitle(9,  "ImpactParamToPV(Pos) (cm)");
1029    fCFContCascadeCuts->SetVarTitle(10, "ImpactParamToPV(Neg) (cm)");
1030    fCFContCascadeCuts->SetVarTitle(11, "Inv. Mass(Xi) (GeV/c^{2})");
1031    fCFContCascadeCuts->SetVarTitle(12, "Inv. Mass(Omega) (GeV/c^{2})");
1032    fCFContCascadeCuts->SetVarTitle(13, "pt(cascade) (GeV/c)");
1033    fCFContCascadeCuts->SetVarTitle(14, "Y(Xi)");
1034    fCFContCascadeCuts->SetVarTitle(15, "Y(Omega)");
1035    fCFContCascadeCuts->SetVarTitle(16, "mL/p (cascade) (cm)");
1036    fCFContCascadeCuts->SetVarTitle(17, "mL/p (V0) (cm)");
1037    fCFContCascadeCuts->SetVarTitle(18, "Distance V0-Cascade in transverse plane (cm)");
1038    fListHistCascade->Add(fCFContCascadeCuts);
1039  }
1040
1041  PostData(1, fListHistCascade);
1042  PostData(2, fCFContCascadePIDXiMinus);
1043  PostData(3, fCFContCascadePIDXiPlus);
1044  PostData(4, fCFContCascadePIDOmegaMinus);
1045  PostData(5, fCFContCascadePIDOmegaPlus);
1046  PostData(6, fCFContCascadeCuts);
1047 } // end UserCreateOutputObjects
1048
1049
1050 //________________________________________________________________________
1051 void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
1052
1053   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1054   // Main loop (called for each event)
1055   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1056   
1057   //----------------
1058   //Define variables 
1059   AliESDEvent *lESDevent = 0x0;
1060   AliAODEvent *lAODevent = 0x0;
1061
1062   //----------------------
1063   // Check the PIDresponse
1064   //---------------------
1065   if(!fPIDResponse) {
1066        AliError("Cannot get pid response");
1067        return;
1068   }
1069   if(! fESDtrackCuts ){
1070        fESDtrackCuts = new AliESDtrackCuts();
1071   }
1072   if(! fUtils ){
1073        fUtils = new AliAnalysisUtils();
1074   }
1075
1076
1077   ///////////////////
1078   // EVENT SELECTIONS
1079   ///////////////////
1080   // In order:
1081   // 1) SDD selection
1082   // 2) Physics selection
1083   // 3) Select only looking at events with well-established PV
1084   // 4) Pileup selection
1085   // 5) |Z| < 10 cm
1086
1087   //----------------------
1088   // Before any selections
1089   //----------------------
1090   //- Define the variables
1091   Int_t ncascadesBeforeAnySel = 0;
1092   Int_t nTrackMultiplicityBeforeAnySel = 0;
1093   if (fAnalysisType == "ESD") {
1094       // - Load the InputEvent and check
1095       lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
1096       if (!lESDevent) {
1097          AliWarning("ERROR: lESDevent not available \n");
1098          return;
1099       }
1100       // - Take the number of cascades and tracks before any events selection
1101       ncascadesBeforeAnySel = lESDevent->GetNumberOfCascades();
1102       nTrackMultiplicityBeforeAnySel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
1103   } else if (fAnalysisType == "AOD") {
1104       // - Load the InputEvent and check
1105       lAODevent = dynamic_cast<AliAODEvent*>( InputEvent() );
1106       if (!lAODevent) {
1107           AliWarning("ERROR: lAODevent not available \n");
1108           return;
1109       }
1110       // - Take the number of cascades and tracks before any events selection
1111       ncascadesBeforeAnySel  = lAODevent->GetNumberOfCascades();
1112       nTrackMultiplicityBeforeAnySel = -100;  //FIXME: I can't find the equivalent method for the AOD  
1113   } else {
1114       Printf("Analysis type (ESD or AOD) not specified \n");
1115       return;
1116   }
1117   // - Fill the plots
1118   fHistCascadeMultiplicityBeforeAnySel->Fill(ncascadesBeforeAnySel);
1119   fHistTrackMultiplicityBeforeAnySel->Fill(nTrackMultiplicityBeforeAnySel);
1120
1121   //--------------
1122   // SDD selection
1123   //--------------
1124   // - Define the variables
1125   Int_t ncascadesAfterSDDSel = 0;
1126   Int_t nTrackMultiplicityAfterSDDSel = 0;
1127   // - Selection for ESD and AOD
1128   if (fAnalysisType == "ESD") {
1129      if (fkSDDSelectionOn && fCollidingSystem == "pp") {
1130         TString trcl = lESDevent->GetFiredTriggerClasses();
1131         //cout<<"Fired Trigger Classes: "<<trcl<<endl;
1132         if (fwithSDD){
1133           if(!(trcl.Contains("ALLNOTRD"))) {
1134                cout<<"We are selecting events with SDD turn ON. This event has the SDD turn OFF. =>  RETURN!! (Exclude it)..."<<endl;
1135                PostData(1, fListHistCascade);
1136                PostData(2, fCFContCascadePIDXiMinus);
1137                PostData(3, fCFContCascadePIDXiPlus);
1138                PostData(4, fCFContCascadePIDOmegaMinus);
1139                PostData(5, fCFContCascadePIDOmegaPlus);
1140                PostData(6, fCFContCascadeCuts);
1141                return;
1142           }
1143         } else if (!fwithSDD){
1144           if((trcl.Contains("ALLNOTRD"))) {
1145                cout<<"We are selecting events with SDD turn OFF. This event has the SDD turn ON. =>  RETURN!! (Exclude it)..."<<endl;
1146                PostData(1, fListHistCascade);
1147                PostData(2, fCFContCascadePIDXiMinus);
1148                PostData(3, fCFContCascadePIDXiPlus);
1149                PostData(4, fCFContCascadePIDOmegaMinus);
1150                PostData(5, fCFContCascadePIDOmegaPlus);
1151                PostData(6, fCFContCascadeCuts);
1152                return;
1153           }
1154         }
1155      }
1156      // - Take the number of cascades and tracks after the SDD selection
1157      ncascadesAfterSDDSel = lESDevent->GetNumberOfCascades();
1158      nTrackMultiplicityAfterSDDSel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
1159   } else if (fAnalysisType == "AOD") {
1160      if (fkSDDSelectionOn && fCollidingSystem == "pp") {
1161         TString trcl = lAODevent->GetFiredTriggerClasses();
1162         if (fwithSDD){
1163            if(!(trcl.Contains("ALLNOTRD"))) {
1164                 PostData(1, fListHistCascade);
1165                 PostData(2, fCFContCascadePIDXiMinus);
1166                 PostData(3, fCFContCascadePIDXiPlus);
1167                 PostData(4, fCFContCascadePIDOmegaMinus);
1168                 PostData(5, fCFContCascadePIDOmegaPlus);
1169                 PostData(6, fCFContCascadeCuts);
1170                 cout<<"We are selecting events with SDD turn ON. This event has the SDD turn OFF. =>  RETURN!! (Exclude it)..."<<endl;
1171                 return;
1172            }
1173         } else if (!fwithSDD) {
1174            if((trcl.Contains("ALLNOTRD"))) {
1175                 PostData(1, fListHistCascade);
1176                 PostData(2, fCFContCascadePIDXiMinus);
1177                 PostData(3, fCFContCascadePIDXiPlus);
1178                 PostData(4, fCFContCascadePIDOmegaMinus);
1179                 PostData(5, fCFContCascadePIDOmegaPlus);
1180                 PostData(6, fCFContCascadeCuts);
1181                 cout<<"We are selecting events with SDD turn OFF. This event has the SDD turn ON. =>  RETURN!! (Exclude it)..."<<endl;
1182                 return;
1183            }
1184         }
1185      }
1186      // - Take the number of cascades and tracks after the SDD selection
1187      ncascadesAfterSDDSel = lAODevent->GetNumberOfCascades();
1188      nTrackMultiplicityAfterSDDSel = -100; //FIXME: I can't find the equivalent method for the AOD
1189   }
1190   // - Fill the plots
1191   fHistCascadeMultiplicityAfterSDDSel->Fill(ncascadesAfterSDDSel);
1192   fHistTrackMultiplicityAfterSDDSel->Fill(nTrackMultiplicityAfterSDDSel);
1193
1194   //-------------------------------------------
1195   // Multiplicity estimators for pPb collisions  //FIXME
1196   //-------------------------------------------
1197   //AliCentrality* centrality = 0;
1198   //if      (fAnalysisType == "ESD" && (fCollidingSystem == "pPb")) centrality = lESDevent->GetCentrality();
1199   //else if (fAnalysisType == "AOD" && (fCollidingSystem == "pPb")) centrality = lAODevent->GetCentrality();
1200   //Float_t lcentrality = 0.;
1201   //if (fCollidingSystem == "pPb") {
1202   //     if (fkUseCleaning) lcentrality = centrality->GetCentralityPercentile(fCentrEstimator.Data());
1203   //     else {
1204   //         lcentrality = centrality->GetCentralityPercentileUnchecked(fCentrEstimator.Data());
1205   //         if (centrality->GetQuality()>1) {
1206   //             PostData(1, fCFContCascadeCuts);
1207   //            return;
1208   //         }
1209   //     }
1210   //     //if (lcentrality<fCentrLowLim||lcentrality>=fCentrUpLim) { 
1211   //     //    PostData(1, fCFContCascadeCuts);
1212   //     //    return;
1213   //     //}
1214   //} else if (fCollidingSystem == "pp") lcentrality = 0.;  
1215
1216   //------------------
1217   // Physics selection 
1218   //-----------------
1219   // - Define the variables
1220   Int_t ncascadesAfterPhysicsSel = 0;
1221   Int_t nTrackMultiplicityAfterPhysicsSel = 0;
1222   // - Selection for ESD and AOD
1223   UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1224   Bool_t isSelected = 0;
1225   if      (fCollidingSystem == "pp" ) isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
1226   else if (fCollidingSystem == "pPb") isSelected = (maskIsSelected & AliVEvent::kINT7) == AliVEvent::kINT7;
1227   if(! isSelected){
1228       PostData(1, fListHistCascade);
1229       PostData(2, fCFContCascadePIDXiMinus);
1230       PostData(3, fCFContCascadePIDXiPlus);
1231       PostData(4, fCFContCascadePIDOmegaMinus);
1232       PostData(5, fCFContCascadePIDOmegaPlus);
1233       PostData(6, fCFContCascadeCuts);
1234       cout<<"We are selecting the events that past tha Physics Selection. This event does not pass the Physics Selection. =>  RETURN!! (Exclude it)..."<<endl;
1235       return;
1236   }
1237   if (fAnalysisType == "ESD") {
1238       // - Take the number of cascades and tracks after physics selection
1239       ncascadesAfterPhysicsSel = lESDevent->GetNumberOfCascades();    
1240       nTrackMultiplicityAfterPhysicsSel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);  
1241   } else if (fAnalysisType == "AOD") {
1242       // - Take the number of cascades and tracks after the physics selection
1243       ncascadesAfterPhysicsSel = lAODevent->GetNumberOfCascades();
1244       nTrackMultiplicityAfterPhysicsSel = -100;  //FIXME: I can't find the equivalent method for the AOD    
1245   } 
1246   // - Fill the plots
1247   fHistCascadeMultiplicityAfterPhysicsSel->Fill(ncascadesAfterPhysicsSel);
1248   fHistTrackMultiplicityAfterPhysicsSel->Fill(nTrackMultiplicityAfterPhysicsSel);
1249
1250   //---------------------------------------
1251   // Re-run cascade vertexer (only for ESD)
1252   //---------------------------------------
1253   if (fAnalysisType == "ESD" && fkRerunV0CascVertexers) {
1254        lESDevent->ResetCascades();
1255        lESDevent->ResetV0s();
1256        AliV0vertexer *lV0vtxer = new AliV0vertexer();
1257        AliCascadeVertexer *lCascVtxer = new AliCascadeVertexer();
1258        //lV0vtxer->GetCuts(fV0Sels);
1259        //lCascVtxer->GetCuts(fCascSels);
1260        lV0vtxer->SetCuts(fV0Sels);      // NB don't use SetDefaultCuts!! because it acts on static variables 
1261        lCascVtxer->SetCuts(fCascSels);
1262        lV0vtxer->Tracks2V0vertices(lESDevent);
1263        lCascVtxer->V0sTracks2CascadeVertices(lESDevent);
1264        //delete lV0vtxer;
1265        //delete lCascVtxer;
1266   }
1267
1268   //------------------------------
1269   // Well-established PV selection
1270   //------------------------------
1271   // - Define variables
1272   Int_t ncascadesForSelEvtNoTPCOnly = 0;
1273   Int_t nTrackMultiplicityForSelEvtNoTPCOnly = 0;
1274   // - Selection for the two colliding systems
1275   if (fCollidingSystem == "pp") {
1276       // - Selection for ESD and AOD
1277       if (fAnalysisType == "ESD") {
1278           // - Vertex coordinates: get the PVs stored in the ESD found with tracks and SPD
1279           const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
1280           const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
1281           // - Select only looking at events with well-established PV
1282           if (fkQualityCutNoTPConlyPrimVtx) {
1283               if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
1284                   AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1285                   PostData(1, fListHistCascade);
1286                   PostData(2, fCFContCascadePIDXiMinus);
1287                   PostData(3, fCFContCascadePIDXiPlus);
1288                   PostData(4, fCFContCascadePIDOmegaMinus);
1289                   PostData(5, fCFContCascadePIDOmegaPlus);
1290                   PostData(6, fCFContCascadeCuts);
1291                   return;
1292               }
1293           }
1294           // - Take the number of cascades and tracks after TPConly selection
1295           ncascadesForSelEvtNoTPCOnly = lESDevent->GetNumberOfCascades();
1296           nTrackMultiplicityForSelEvtNoTPCOnly = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
1297       } else if (fAnalysisType == "AOD") {
1298           // - Vertex coordinates: get the PVs stored in the AOD found with tracks and SPD
1299           const AliAODVertex *lPrimarySPDVtx = lAODevent->GetPrimaryVertexSPD();
1300           const AliAODVertex *lPrimaryTrackingAODVtx = lAODevent->GetPrimaryVertex();
1301           // - Select only looking at events with well-established PV
1302           if (fkQualityCutNoTPConlyPrimVtx) {
1303               if (!lPrimarySPDVtx && !lPrimaryTrackingAODVtx) {
1304                   AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1305                   PostData(1, fListHistCascade);
1306                   PostData(2, fCFContCascadePIDXiMinus);
1307                   PostData(3, fCFContCascadePIDXiPlus);
1308                   PostData(4, fCFContCascadePIDOmegaMinus);
1309                   PostData(5, fCFContCascadePIDOmegaPlus);
1310                   PostData(6, fCFContCascadeCuts);
1311                   return;
1312               }
1313           }
1314           // - Take the number of cascades and tracks after TPConly selection
1315           ncascadesForSelEvtNoTPCOnly = lAODevent->GetNumberOfCascades();
1316           nTrackMultiplicityForSelEvtNoTPCOnly = -100;  //FIXME: I can't find the equivalent method for the AOD
1317       }
1318   } else if (fCollidingSystem == "pPb") {
1319       if (fAnalysisType == "ESD") {
1320           Bool_t fHasVertex = kFALSE;
1321           const AliESDVertex *vertex = lESDevent->GetPrimaryVertexTracks();
1322           if (vertex->GetNContributors() < 1) {
1323               vertex = lESDevent->GetPrimaryVertexSPD();
1324               if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
1325               else fHasVertex = kTRUE;
1326               TString vtxTyp = vertex->GetTitle();
1327               Double_t cov[6]={0};
1328               vertex->GetCovarianceMatrix(cov);
1329               Double_t zRes = TMath::Sqrt(cov[5]);
1330               if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
1331           }
1332           else fHasVertex = kTRUE;
1333           if (fUtils->IsFirstEventInChunk(lESDevent)) { //Is First event in chunk rejection: Still present!
1334               AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1335               PostData(1, fListHistCascade);
1336               PostData(2, fCFContCascadePIDXiMinus);
1337               PostData(3, fCFContCascadePIDXiPlus);
1338               PostData(4, fCFContCascadePIDOmegaMinus);
1339               PostData(5, fCFContCascadePIDOmegaPlus);
1340               PostData(6, fCFContCascadeCuts);
1341               return;
1342           }
1343           // - Take the number of cascades and tracks after TPConly selection
1344           ncascadesForSelEvtNoTPCOnly = lESDevent->GetNumberOfCascades();
1345           nTrackMultiplicityForSelEvtNoTPCOnly = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
1346       } else if (fAnalysisType == "AOD") {
1347           Bool_t fHasVertex = kFALSE;
1348           const AliAODVertex *vertex = lAODevent->GetPrimaryVertex();
1349           if (vertex->GetNContributors() < 1) {
1350               vertex = lAODevent->GetPrimaryVertexSPD();
1351               if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
1352               else fHasVertex = kTRUE;
1353               TString vtxTyp = vertex->GetTitle();
1354               Double_t cov[6]={0};
1355               vertex->GetCovarianceMatrix(cov);
1356               Double_t zRes = TMath::Sqrt(cov[5]);
1357               if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
1358           }  
1359           else fHasVertex = kTRUE;
1360           if (fHasVertex == kFALSE) { //Is First event in chunk rejection: Still present!  //FIXME
1361               AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
1362               PostData(1, fListHistCascade);
1363               PostData(2, fCFContCascadePIDXiMinus);
1364               PostData(3, fCFContCascadePIDXiPlus);
1365               PostData(4, fCFContCascadePIDOmegaMinus);
1366               PostData(5, fCFContCascadePIDOmegaPlus);
1367               PostData(6, fCFContCascadeCuts);
1368               return;
1369           }  
1370           // - Take the number of cascades and tracks after TPConly selection
1371           ncascadesForSelEvtNoTPCOnly = lAODevent->GetNumberOfCascades();
1372           nTrackMultiplicityForSelEvtNoTPCOnly = -100;  //FIXME: I can't find the equivalent method for the AOD
1373       }
1374   }
1375   // - Fill the plots
1376   fHistCascadeMultiplicityForSelEvtNoTPCOnly->Fill(ncascadesForSelEvtNoTPCOnly);
1377   fHistTrackMultiplicityForSelEvtNoTPCOnly->Fill(nTrackMultiplicityForSelEvtNoTPCOnly);
1378    
1379  
1380   //----------------
1381   // Pilup selection
1382   //----------------
1383   // - Define variables
1384   Int_t ncascadesForSelEvtNoTPCOnlyNoPileup = 0;
1385   Int_t nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = 0;
1386   // - Selection for ESD and AOD
1387   if (fAnalysisType == "ESD" && fCollidingSystem == "pp") {
1388       if (fkQualityCutPileup) {
1389           if(lESDevent->IsPileupFromSPD()){
1390               AliWarning("Pb / Pile-up event ... return!");
1391               PostData(1, fListHistCascade);
1392               PostData(2, fCFContCascadePIDXiMinus);
1393               PostData(3, fCFContCascadePIDXiPlus);
1394               PostData(4, fCFContCascadePIDOmegaMinus);
1395               PostData(5, fCFContCascadePIDOmegaPlus);
1396               PostData(6, fCFContCascadeCuts);
1397               return;
1398           }
1399       }
1400       // - Take the number of cascades and tracks after Pileup selection
1401       ncascadesForSelEvtNoTPCOnlyNoPileup = lESDevent->GetNumberOfCascades();
1402       nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
1403   } else if (fAnalysisType == "AOD" && fCollidingSystem == "pp") {
1404       if (fkQualityCutPileup) {
1405           if(lAODevent->IsPileupFromSPD()){
1406               AliWarning("Pb / Pile-up event ... return!");
1407               PostData(1, fListHistCascade);
1408               PostData(2, fCFContCascadePIDXiMinus);
1409               PostData(3, fCFContCascadePIDXiPlus);
1410               PostData(4, fCFContCascadePIDOmegaMinus);
1411               PostData(5, fCFContCascadePIDOmegaPlus);
1412               PostData(6, fCFContCascadeCuts);
1413               return;
1414           }
1415       }
1416       // - Take the number of cascades and tracks after Pileup selection
1417       ncascadesForSelEvtNoTPCOnlyNoPileup = lAODevent->GetNumberOfCascades();
1418       nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = -100;   //FIXME: I can't find the equivalent method for the AOD
1419   }
1420   fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(ncascadesForSelEvtNoTPCOnlyNoPileup);
1421   fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup);
1422     
1423   //----------------------------------------------------
1424   // Vertex Z position selection (+ magnetic field info)
1425   //----------------------------------------------------
1426   // - Define variables
1427   Double_t lBestPrimaryVtxPos[3]  = {-100.0, -100.0, -100.0};
1428   Double_t lMagneticField         = -10.;
1429   Double_t tPrimaryVtxPosition[3] = {-100.0, -100.0, -100.0};
1430   Int_t ncascadesAfterVertexSel          = 0;
1431   Int_t nTrackMultiplicityAfterVertexSel = 0; 
1432   // - Selection for ESD and AOD
1433   if (fAnalysisType == "ESD") {
1434       // - Vertex coordinates: get the best primary vertex available for the event 
1435       const AliESDVertex *lPrimaryBestESDVtx = lESDevent->GetPrimaryVertex(); 
1436       if (!lPrimaryBestESDVtx){
1437           AliWarning("No prim. vertex in ESD... return!");
1438           PostData(1, fListHistCascade);
1439           PostData(2, fCFContCascadePIDXiMinus);
1440           PostData(3, fCFContCascadePIDXiPlus);
1441           PostData(4, fCFContCascadePIDOmegaMinus);
1442           PostData(5, fCFContCascadePIDOmegaPlus);
1443           PostData(6, fCFContCascadeCuts);
1444           return;
1445       }
1446       lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
1447       // - Fill the vertex plots before any event selection on vertex position
1448       const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
1449       tPrimaryVtxPosition[0] = primaryVtx->GetX();
1450       tPrimaryVtxPosition[1] = primaryVtx->GetY();
1451       tPrimaryVtxPosition[2] = primaryVtx->GetZ();
1452           fHistPVx->Fill( tPrimaryVtxPosition[0] );
1453           fHistPVy->Fill( tPrimaryVtxPosition[1] );
1454           fHistPVz->Fill( tPrimaryVtxPosition[2] );       
1455       // - Get magnetic filed info
1456       lMagneticField = lESDevent->GetMagneticField();
1457       //if(TMath::Abs(lMagneticField ) < 10e-6) continue;
1458       // - Selection on the primary vertex Z position 
1459       if (fkQualityCutZprimVtxPos) {
1460           if (TMath::Abs(lBestPrimaryVtxPos[2]) > fVtxRange || TMath::Abs(lBestPrimaryVtxPos[2]) < fVtxRangeMin) {
1461                AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
1462                PostData(1, fListHistCascade);
1463                PostData(2, fCFContCascadePIDXiMinus);
1464                PostData(3, fCFContCascadePIDXiPlus);
1465                PostData(4, fCFContCascadePIDOmegaMinus);
1466                PostData(5, fCFContCascadePIDOmegaPlus);
1467                PostData(6, fCFContCascadeCuts);
1468                return;
1469           }
1470       }
1471       // - Take the number of cascades and tracks after vertex Z position selection
1472       ncascadesAfterVertexSel = lESDevent->GetNumberOfCascades();
1473       nTrackMultiplicityAfterVertexSel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5); 
1474   } else if (fAnalysisType == "AOD") {
1475       // - Vertex coordinates: get the best primary vertex available for the event
1476       const AliAODVertex *lPrimaryBestAODVtx = lAODevent->GetPrimaryVertex();
1477       if (!lPrimaryBestAODVtx){
1478           AliWarning("No prim. vertex in AOD... return!");
1479           PostData(1, fListHistCascade);
1480           PostData(2, fCFContCascadePIDXiMinus);
1481           PostData(3, fCFContCascadePIDXiPlus);
1482           PostData(4, fCFContCascadePIDOmegaMinus);
1483           PostData(5, fCFContCascadePIDOmegaPlus);
1484           PostData(6, fCFContCascadeCuts);
1485           return;
1486       }
1487       lPrimaryBestAODVtx->GetXYZ( lBestPrimaryVtxPos );
1488       // - Fill the vertex plots before any event selection on vertex position
1489       const AliVVertex *primaryVtx = lAODevent->GetPrimaryVertex();
1490       tPrimaryVtxPosition[0] = primaryVtx->GetX();
1491       tPrimaryVtxPosition[1] = primaryVtx->GetY();
1492       tPrimaryVtxPosition[2] = primaryVtx->GetZ();
1493           fHistPVx->Fill( tPrimaryVtxPosition[0] );
1494           fHistPVy->Fill( tPrimaryVtxPosition[1] );
1495           fHistPVz->Fill( tPrimaryVtxPosition[2] );
1496       // - Get magnetic filed info
1497       lMagneticField = lAODevent->GetMagneticField();
1498       //if(TMath::Abs(lMagneticField ) < 10e-6) continue;
1499       // - Selection on the primary vertex Z position 
1500       if (fkQualityCutZprimVtxPos) {
1501           if (TMath::Abs(lBestPrimaryVtxPos[2]) > fVtxRange || TMath::Abs(lBestPrimaryVtxPos[2]) < fVtxRangeMin) {
1502               AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
1503               PostData(1, fListHistCascade);
1504               PostData(2, fCFContCascadePIDXiMinus);
1505               PostData(3, fCFContCascadePIDXiPlus);
1506               PostData(4, fCFContCascadePIDOmegaMinus);
1507               PostData(5, fCFContCascadePIDOmegaPlus);
1508               PostData(6, fCFContCascadeCuts);
1509               return;
1510           }
1511       }
1512       // - Take the number of cascades and tracks after vertex Z position selection
1513       ncascadesAfterVertexSel = lAODevent->GetNumberOfCascades();
1514       nTrackMultiplicityAfterVertexSel = -100; //FIXME: I can't find the equivalent method for the AOD
1515   } 
1516   // - Fill the plots
1517   fHistCascadeMultiplicityAfterVertexCutSel->Fill(ncascadesAfterVertexSel);
1518   fHistTrackMultiplicityAfterVertexCutSel->Fill(nTrackMultiplicityAfterVertexSel);
1519
1520   // - Vertex position plots: after any event selections
1521   tPrimaryVtxPosition[0] = -100.0;
1522   tPrimaryVtxPosition[1] = -100.0;
1523   tPrimaryVtxPosition[2] = -100.0;
1524   if (fAnalysisType == "ESD") {
1525        const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
1526        tPrimaryVtxPosition[0] = primaryVtx->GetX();
1527        tPrimaryVtxPosition[1] = primaryVtx->GetY();
1528        tPrimaryVtxPosition[2] = primaryVtx->GetZ();
1529   } else if (fAnalysisType == "AOD") {
1530        const AliVVertex *primaryVtx = lAODevent->GetPrimaryVertex();
1531        tPrimaryVtxPosition[0] = primaryVtx->GetX();
1532        tPrimaryVtxPosition[1] = primaryVtx->GetY();
1533        tPrimaryVtxPosition[2] = primaryVtx->GetZ();
1534   }
1535   fHistPVxAnalysis->Fill( tPrimaryVtxPosition[0] );
1536   fHistPVyAnalysis->Fill( tPrimaryVtxPosition[1] );
1537   fHistPVzAnalysis->Fill( tPrimaryVtxPosition[2] );
1538   
1539
1540
1541   //////////////////////////////
1542   // CASCADE RECONSTRUCTION PART
1543   //////////////////////////////
1544   
1545   //%%%%%%%%%%%%%
1546   // Cascade loop
1547   Int_t ncascades = 0;
1548   if      (fAnalysisType == "ESD") ncascades = lESDevent->GetNumberOfCascades();
1549   else if (fAnalysisType == "AOD") ncascades = lAODevent->GetNumberOfCascades();
1550
1551   for (Int_t iXi = 0; iXi < ncascades; iXi++) {// This is the begining of the Cascade loop (ESD or AOD)
1552            
1553       // -----------------------------------------------------------------------
1554       // - Initialisation of the local variables that will be needed for ESD/AOD
1555
1556       // - 0th part of initialisation : around primary vertex ...
1557       //Double_t lBestPrimaryVtxRadius3D     = -500.0;
1558       // - 1st part of initialisation : variables needed to store AliESDCascade data members
1559       Double_t lEffMassXi                  = 0.;
1560       Double_t lDcaXiDaughters             = -1.;
1561       Double_t lXiCosineOfPointingAngle    = -1.;
1562       Double_t lPosXi[3]                   = { -1000.0, -1000.0, -1000.0 };
1563       Double_t lXiRadius                   = -1000. ;
1564       // - 2nd part of initialisation : Nbr of clusters within TPC for the 3 daughter cascade tracks
1565       UShort_t lPosTPCClusters             = -1; // For ESD only ...
1566       UShort_t lNegTPCClusters             = -1; // For ESD only ...
1567       UShort_t lBachTPCClusters            = -1; // For ESD only ...
1568       Double_t lInnerWallMomCascDghters[3] = {-100., -100., -100.};
1569       Double_t lTPCSignalCascDghters   [3] = {-100., -100., -100.};
1570       // - 3rd part of initialisation : about V0 part in cascades
1571       Double_t lInvMassLambdaAsCascDghter  = 0.;
1572       Double_t lDcaV0DaughtersXi           = -1.;
1573       Double_t lDcaBachToPrimVertexXi      = -1.;
1574       Double_t lDcaV0ToPrimVertexXi        = -1.;
1575       Double_t lDcaPosToPrimVertexXi       = -1.;
1576       Double_t lDcaNegToPrimVertexXi       = -1.;
1577       Double_t lV0CosineOfPointingAngleXi  = -1. ;
1578       Double_t lPosV0Xi[3]                 = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
1579       Double_t lV0RadiusXi                 = -1000.0;
1580       Double_t lV0quality                  = 0.;
1581       // - 4th part of initialisation : Effective masses
1582       Double_t lInvMassXiMinus             = 0.;
1583       Double_t lInvMassXiPlus              = 0.;
1584       Double_t lInvMassOmegaMinus          = 0.;
1585       Double_t lInvMassOmegaPlus           = 0.;
1586       // - 5th part of initialisation : PID treatment
1587       Bool_t   lIsPosInXiProton            = kFALSE;
1588       Bool_t   lIsPosInXiPion              = kFALSE;
1589       Bool_t   lIsPosInOmegaProton         = kFALSE;
1590       Bool_t   lIsPosInOmegaPion           = kFALSE;
1591       Bool_t   lIsNegInXiProton            = kFALSE;
1592       Bool_t   lIsNegInXiPion              = kFALSE;
1593       Bool_t   lIsNegInOmegaProton         = kFALSE;
1594       Bool_t   lIsNegInOmegaPion           = kFALSE;
1595       Bool_t   lIsBachelorKaon             = kFALSE;
1596       Bool_t   lIsBachelorPion             = kFALSE; 
1597       Bool_t   lIsBachelorKaonForTPC       = kFALSE; 
1598       Bool_t   lIsBachelorPionForTPC       = kFALSE; 
1599       Bool_t   lIsNegPionForTPC            = kFALSE; 
1600       Bool_t   lIsPosPionForTPC            = kFALSE; 
1601       Bool_t   lIsNegProtonForTPC          = kFALSE; 
1602       Bool_t   lIsPosProtonForTPC          = kFALSE; 
1603       // - 6th part of initialisation : extra info for QA
1604       Double_t lXiMomX         = 0.;
1605       Double_t lXiMomY         = 0.;
1606       Double_t lXiMomZ         = 0.;
1607       Double_t lXiTransvMom    = 0.;
1608       Double_t lXiTotMom       = 0.;
1609       Double_t lV0PMomX        = 0.;
1610       Double_t lV0PMomY        = 0.;
1611       Double_t lV0PMomZ        = 0.;
1612       Double_t lV0NMomX        = 0.;
1613       Double_t lV0NMomY        = 0.;
1614       Double_t lV0NMomZ        = 0.;
1615       Double_t lV0TotMom       = 0.;
1616       Double_t lBachMomX       = 0.;
1617       Double_t lBachMomY       = 0.;
1618       Double_t lBachMomZ       = 0.;
1619       Double_t lBachTransvMom  = 0.;
1620       Double_t lBachTotMom     = 0.;
1621       Double_t lpTrackTransvMom  = 0.;
1622       Double_t lnTrackTransvMom  = 0.;
1623       Short_t  lChargeXi       = -2;
1624       Double_t lV0toXiCosineOfPointingAngle = 0.;
1625       Double_t lRapXi   = -20.0, lRapOmega = -20.0, lEta = -20.0, lTheta = 360., lPhi = 720.;
1626       Double_t lAlphaXi = -200., lPtArmXi  = -200.0;
1627       Double_t etaPos = 0., etaNeg = 0., etaBach = 0.;
1628   
1629       if (fAnalysisType == "ESD") { 
1630   
1631           // -------------------------------------
1632           // - Load the cascades from the handler
1633           AliESDcascade *xi = lESDevent->GetCascade(iXi);
1634           if (!xi) continue;
1635
1636           //----------------------------------------------------------------------------        
1637           // - Assigning the necessary variables for specific AliESDcascade data members        
1638           lV0quality = 0.;
1639           xi->ChangeMassHypothesis(lV0quality , 3312); // default working hypothesis: cascade = Xi-decay
1640           lEffMassXi               = xi->GetEffMassXi();
1641           lDcaXiDaughters          = xi->GetDcaXiDaughters();
1642           lXiCosineOfPointingAngle = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lBestPrimaryVtxPos[2] );
1643                                                                        //Take care : the best available vertex should be used (like in AliCascadeVertexer)
1644           xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
1645           lXiRadius                = TMath::Sqrt( lPosXi[0]*lPosXi[0] + lPosXi[1]*lPosXi[1] );
1646                 
1647           //-------------------------------------------------------------------------------------------------------------------------------
1648           // - Around the tracks: Bach + V0 (ESD). Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
1649           UInt_t lIdxPosXi      = (UInt_t) TMath::Abs( xi->GetPindex() );
1650           UInt_t lIdxNegXi      = (UInt_t) TMath::Abs( xi->GetNindex() );
1651           UInt_t lBachIdx       = (UInt_t) TMath::Abs( xi->GetBindex() );
1652                                       //Care track label can be negative in MC production (linked with the track quality)
1653                                       //However = normally, not the case for track index ...
1654           // - Rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
1655           if (lBachIdx == lIdxNegXi) { AliWarning("Pb / Idx(Bach. track) = Idx(Neg. track) ... continue!"); continue; }
1656           if (lBachIdx == lIdxPosXi) { AliWarning("Pb / Idx(Bach. track) = Idx(Pos. track) ... continue!"); continue; }
1657           // - Get the track for the daughters
1658           AliESDtrack *pTrackXi    = lESDevent->GetTrack( lIdxPosXi );
1659           AliESDtrack *nTrackXi    = lESDevent->GetTrack( lIdxNegXi );
1660           AliESDtrack *bachTrackXi = lESDevent->GetTrack( lBachIdx );
1661           if (!pTrackXi || !nTrackXi || !bachTrackXi ) {
1662                AliWarning("ERROR: Could not retrieve one of the 3 ESD daughter tracks of the cascade ...");
1663                continue;
1664           }
1665           // - Get the TPCnumber of cluster for the daughters
1666           lPosTPCClusters   = pTrackXi->GetTPCNcls();
1667           lNegTPCClusters   = nTrackXi->GetTPCNcls();
1668           lBachTPCClusters  = bachTrackXi->GetTPCNcls();
1669
1670           //-------------------------------------
1671           // - Rejection of a poor quality tracks
1672           if (fkQualityCutTPCrefit) {
1673                 // - Poor quality related to TPCrefit
1674                 ULong_t pStatus    = pTrackXi->GetStatus();
1675                 ULong_t nStatus    = nTrackXi->GetStatus();
1676                 ULong_t bachStatus = bachTrackXi->GetStatus();
1677                 if ((pStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Pos. track has no TPCrefit ... continue!"); continue; }
1678                 if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
1679                 if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
1680           }
1681           if (fkQualityCutnTPCcls) {
1682                 // - Poor quality related to TPC clusters
1683                 if (lPosTPCClusters  < fMinnTPCcls) { AliWarning("Pb / V0 Pos. track has less than 80 TPC clusters ... continue!"); continue; }
1684                 if (lNegTPCClusters  < fMinnTPCcls) { AliWarning("Pb / V0 Neg. track has less than 80 TPC clusters ... continue!"); continue; }
1685                 if (lBachTPCClusters < fMinnTPCcls) { AliWarning("Pb / Bach.   track has less than 80 TPC clusters ... continue!"); continue; }
1686           }
1687
1688           //-----------------------------------
1689           const AliExternalTrackParam *pExtTrack    = pTrackXi->GetInnerParam();
1690           const AliExternalTrackParam *nExtTrack    = nTrackXi->GetInnerParam();
1691           const AliExternalTrackParam *bachExtTrack = bachTrackXi->GetInnerParam();
1692           if (pExtTrack) {
1693                 lInnerWallMomCascDghters[0] = pExtTrack->GetP() * pExtTrack->Charge();
1694                 lTPCSignalCascDghters   [0] = pTrackXi->GetTPCsignal();
1695           }
1696           if (nExtTrack) {
1697                 lInnerWallMomCascDghters[1] = nExtTrack->GetP() * nExtTrack->Charge();
1698                 lTPCSignalCascDghters   [1] = nTrackXi->GetTPCsignal();
1699            }
1700            if (bachExtTrack) {
1701                 lInnerWallMomCascDghters[2] = bachExtTrack->GetP() * bachExtTrack->Charge();
1702                 lTPCSignalCascDghters   [2] = bachTrackXi->GetTPCsignal();
1703            }
1704            etaPos  = pTrackXi->Eta();
1705            etaNeg  = nTrackXi->Eta();
1706            etaBach = bachTrackXi->Eta();
1707            lInvMassLambdaAsCascDghter = xi->GetEffMass(); //This value shouldn't change, whatever the working hyp. is : Xi-, Xi+, Omega-, Omega+
1708            lDcaV0DaughtersXi          = xi->GetDcaV0Daughters(); 
1709            lV0CosineOfPointingAngleXi = xi->GetV0CosineOfPointingAngle(lBestPrimaryVtxPos[0],
1710                                                                        lBestPrimaryVtxPos[1],
1711                                                                        lBestPrimaryVtxPos[2] );
1712            lDcaV0ToPrimVertexXi = xi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lBestPrimaryVtxPos[2] );
1713            lDcaBachToPrimVertexXi = TMath::Abs( bachTrackXi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lMagneticField ) ); //Note: AliExternalTrackParam::GetD returns an algebraic value ...
1714            xi->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] ); 
1715            lV0RadiusXi = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0] + lPosV0Xi[1]*lPosV0Xi[1] );      
1716            lDcaPosToPrimVertexXi = TMath::Abs( pTrackXi ->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lMagneticField ) ); 
1717            lDcaNegToPrimVertexXi = TMath::Abs( nTrackXi ->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lMagneticField ) ); 
1718
1719            //-----------------------------------------
1720            // - Extra-selection for cascade candidates
1721            if (fkExtraSelections) { //in AliCascadeVertexer
1722                if (lDcaXiDaughters > 0.3) continue;  
1723                if (lXiCosineOfPointingAngle < 0.999 ) continue; 
1724                if (lDcaV0ToPrimVertexXi < 0.05) continue; 
1725                if (lDcaBachToPrimVertexXi < 0.03) continue; 
1726                //if (TMath::Abs(lInvMassLambdaAsCascDghter-1.11568) > 0.006 ) continue;   
1727                if (lDcaV0DaughtersXi > 1.) continue;  
1728                if (lV0CosineOfPointingAngleXi < 0.998) continue; 
1729                if (lDcaPosToPrimVertexXi < 0.1) continue; 
1730                if (lDcaNegToPrimVertexXi < 0.1) continue; 
1731                if (lXiRadius < .9) continue; 
1732                //if (lXiRadius > 100) continue; 
1733                if (lV0RadiusXi < 0.9) continue;   
1734                //if (lV0RadiusXi > 100) continue; 
1735            }
1736
1737            //----------------------------------------------------------------------------------------------------       
1738            // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega -/+
1739            if ( bachTrackXi->Charge() < 0 )     {
1740                 //Calculate the effective mass of the Xi- candidate: Xi- hyp. (pdg code 3312)
1741                 lV0quality = 0.;
1742                 xi->ChangeMassHypothesis(lV0quality , 3312);    
1743                 lInvMassXiMinus = xi->GetEffMassXi();
1744                 //Calculate the effective mass of the Xi- candidate: Omega- hyp. (pdg code 3334)
1745                 lV0quality = 0.;
1746                 xi->ChangeMassHypothesis(lV0quality , 3334);    
1747                 lInvMassOmegaMinus = xi->GetEffMassXi();
1748                 //Back to "default" hyp. (Xi-)
1749                 lV0quality = 0.;
1750                 xi->ChangeMassHypothesis(lV0quality , 3312); 
1751            } // end if negative bachelor
1752            if ( bachTrackXi->Charge() >  0 ) {
1753                 //Calculate the effective mass of the Xi- candidate: Xi+ hyp. (pdg code -3312)
1754                 lV0quality = 0.;
1755                 xi->ChangeMassHypothesis(lV0quality , -3312);   
1756                 lInvMassXiPlus = xi->GetEffMassXi();
1757                 //Calculate the effective mass of the Xi- candidate: Omega+ hyp. (pdg code -3334)
1758                 lV0quality = 0.;
1759                 xi->ChangeMassHypothesis(lV0quality , -3334);   
1760                 lInvMassOmegaPlus = xi->GetEffMassXi();
1761                 //Back to "default" hyp. (Xi-)
1762                 lV0quality = 0.;
1763                 xi->ChangeMassHypothesis(lV0quality , -3312);   
1764            } // end if positive bachelor
1765
1766            //--------------------------------
1767            // - PID on the daughter tracks
1768            // - Combined PID ->  removed, add when will be used
1769
1770            // - TPC PID : 3-sigma bands on Bethe-Bloch curve
1771            //Bachelor
1772            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 4) lIsBachelorKaonForTPC = kTRUE;
1773            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 4) lIsBachelorPionForTPC = kTRUE;
1774            //Negative V0 daughter
1775            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kPion   )) < 4) lIsNegPionForTPC   = kTRUE;
1776            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kProton )) < 4) lIsNegProtonForTPC = kTRUE;
1777            //Positive V0 daughter
1778            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kPion   )) < 4) lIsPosPionForTPC   = kTRUE;
1779            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 4) lIsPosProtonForTPC = kTRUE;
1780            /*
1781            const AliExternalTrackParam *pInnerWallTrackXi    = pTrackXi    ->GetInnerParam();
1782            const AliExternalTrackParam *nInnerWallTrackXi    = nTrackXi    ->GetInnerParam();
1783            const AliExternalTrackParam *bachInnerWallTrackXi = bachTrackXi ->GetInnerParam();
1784            if (pInnerWallTrackXi && nInnerWallTrackXi && bachInnerWallTrackXi ) { 
1785                 Double_t pMomInnerWall    = pInnerWallTrackXi   ->GetP();
1786                 Double_t nMomInnerWall    = nInnerWallTrackXi   ->GetP();
1787                 Double_t bachMomInnerWall = bachInnerWallTrackXi->GetP();
1788                 //Bachelor
1789                 if (TMath::Abs(fESDpid->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 3)                              lIsBachelorPionForTPC = kTRUE;
1790                 if (bachMomInnerWall < 0.350  && TMath::Abs(fESDpid->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 5) lIsBachelorKaonForTPC = kTRUE;
1791                 if (bachMomInnerWall > 0.350  && TMath::Abs(fESDpid->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 3) lIsBachelorKaonForTPC = kTRUE;                
1792                 //Negative V0 daughter
1793                 if (TMath::Abs(fESDpid->NumberOfSigmasTPC( nTrackXi,AliPID::kPion   )) < 3  )                           lIsNegPionForTPC   = kTRUE;
1794                 if (nMomInnerWall < 0.6  && TMath::Abs(fESDpid->NumberOfSigmasTPC( nTrackXi,AliPID::kProton ) ) < 5 )   lIsNegProtonForTPC = kTRUE;
1795                 if (nMomInnerWall > 0.6  && TMath::Abs(fESDpid->NumberOfSigmasTPC( nTrackXi,AliPID::kProton ) ) < 3 )   lIsNegProtonForTPC = kTRUE;       
1796                 //Positive V0 daughter
1797                 if (TMath::Abs(fESDpid->NumberOfSigmasTPC( pTrackXi,AliPID::kPion   )) < 3 )                            lIsPosPionForTPC   = kTRUE;
1798                 if (pMomInnerWall < 0.6  && TMath::Abs(fESDpid->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 5)     lIsPosProtonForTPC = kTRUE;
1799                 if (pMomInnerWall > 0.6  && TMath::Abs(fESDpid->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 3)     lIsPosProtonForTPC = kTRUE;
1800            }*/
1801                 
1802            //---------------------------------
1803            // - Extra info for QA (ESD)
1804            // Miscellaneous pieces of info that may help regarding data quality assessment.
1805            // Cascade transverse and total momentum
1806            xi->GetPxPyPz( lXiMomX, lXiMomY, lXiMomZ );
1807            lXiTransvMom = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY );
1808            lXiTotMom    = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY + lXiMomZ*lXiMomZ );
1809            // V0 total momentum
1810            xi->GetNPxPyPz(lV0NMomX,lV0NMomY,lV0NMomZ);
1811            xi->GetPPxPyPz(lV0PMomX,lV0PMomY,lV0PMomZ);
1812            lV0TotMom = TMath::Sqrt(TMath::Power(lV0NMomX+lV0PMomX,2) + TMath::Power(lV0NMomY+lV0PMomY,2) + TMath::Power(lV0NMomZ+lV0PMomZ,2));
1813            // Bachelor total momentum
1814            xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
1815            lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY );
1816            lBachTotMom     = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ );
1817            lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX   + lV0NMomY*lV0NMomY );
1818            lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX   + lV0PMomY*lV0PMomY );
1819            lChargeXi       = xi->Charge();
1820            lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
1821            lRapXi    = xi->RapXi();
1822            lRapOmega = xi->RapOmega();
1823            lEta      = xi->Eta();
1824            lTheta    = xi->Theta()*180.0/TMath::Pi();
1825            lPhi      = xi->Phi()*180.0/TMath::Pi();
1826            lAlphaXi  = xi->AlphaXi();
1827            lPtArmXi  = xi->PtArmXi();
1828            // Extra-cut = Anti-splitting cut for lambda daughters
1829            Bool_t kAntiSplittingLambda = kFALSE;        
1830            if (kAntiSplittingLambda) { // not used
1831                Double_t lNMomX = 0., lNMomY = 0., lNMomZ = 0.;
1832                Double_t lPMomX = 0., lPMomY = 0., lPMomZ = 0.;
1833                xi->GetPPxPyPz(lPMomX, lPMomY, lPMomZ); 
1834                xi->GetNPxPyPz(lNMomX, lNMomY, lNMomZ); 
1835                if ( xi->Charge() < 0) {// Xi- or Omega-
1836                    if (TMath::Abs(lBachTransvMom - TMath::Sqrt( lNMomX*lNMomX + lNMomY*lNMomY )  ) < 0.075) continue;
1837                } else {                //Xi+ or Omega+
1838                    if(TMath::Abs(lBachTransvMom - TMath::Sqrt( lPMomX*lPMomX + lPMomY*lPMomY ) ) < 0.075) continue;
1839                }
1840            }
1841
1842     } // end of ESD treatment
1843  
1844     else if (fAnalysisType == "AOD") {
1845
1846            // -------------------------------------
1847            // - Load the cascades from the handler
1848            const AliAODcascade *xi = lAODevent->GetCascade(iXi);
1849            if (!xi) continue;
1850                 
1851            //----------------------------------------------------------------------------        
1852            // - Assigning the necessary variables for specific AliESDcascade data members               
1853            lEffMassXi              = xi->MassXi(); // default working hypothesis : cascade = Xi- decay
1854            lDcaXiDaughters         = xi->DcaXiDaughters();
1855            lXiCosineOfPointingAngle = xi->CosPointingAngleXi( lBestPrimaryVtxPos[0], 
1856                                                               lBestPrimaryVtxPos[1], 
1857                                                               lBestPrimaryVtxPos[2] );
1858            lPosXi[0] = xi->DecayVertexXiX();
1859            lPosXi[1] = xi->DecayVertexXiY();
1860            lPosXi[2] = xi->DecayVertexXiZ();
1861            lXiRadius = TMath::Sqrt( lPosXi[0]*lPosXi[0] + lPosXi[1]*lPosXi[1] );
1862
1863            //-------------------------------------------------------------------------------------------------------------------------------
1864            // - Around the tracks: Bach + V0 (ESD). Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
1865            AliAODTrack *pTrackXi    = dynamic_cast<AliAODTrack*>( xi->GetDaughter(0) );
1866            AliAODTrack *nTrackXi    = dynamic_cast<AliAODTrack*>( xi->GetDaughter(1) );
1867            AliAODTrack *bachTrackXi = dynamic_cast<AliAODTrack*>( xi->GetDecayVertexXi()->GetDaughter(0) );
1868            if (!pTrackXi || !nTrackXi || !bachTrackXi ) {
1869                 AliWarning("ERROR: Could not retrieve one of the 3 AOD daughter tracks of the cascade ...");
1870                 continue;
1871            }
1872            UInt_t lIdxPosXi  = (UInt_t) TMath::Abs( pTrackXi->GetID() );  
1873            UInt_t lIdxNegXi  = (UInt_t) TMath::Abs( nTrackXi->GetID() );
1874            UInt_t lBachIdx   = (UInt_t) TMath::Abs( bachTrackXi->GetID() );
1875                                                 // Care track label can be negative in MC production (linked with the track quality)
1876                                                 // However = normally, not the case for track index ...
1877            // - Rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
1878            if (lBachIdx == lIdxNegXi) { AliWarning("Pb / Idx(Bach. track) = Idx(Neg. track) ... continue!"); continue; }
1879            if (lBachIdx == lIdxPosXi) { AliWarning("Pb / Idx(Bach. track) = Idx(Pos. track) ... continue!"); continue; }
1880            // - Get the TPCnumber of cluster for the daughters
1881            lPosTPCClusters   = pTrackXi->GetTPCNcls(); // FIXME: Is this ok? or something like in LambdaK0PbPb task AOD?
1882            lNegTPCClusters   = nTrackXi->GetTPCNcls();
1883            lBachTPCClusters  = bachTrackXi->GetTPCNcls();
1884
1885            //-------------------------------------
1886            // - Rejection of a poor quality tracks
1887            if (fkQualityCutTPCrefit) {
1888                 // - Poor quality related to TPCrefit
1889                 if (!(pTrackXi->IsOn(AliAODTrack::kTPCrefit))) { AliWarning("Pb / V0 Pos. track has no TPCrefit ... continue!"); continue; }
1890                 if (!(nTrackXi->IsOn(AliAODTrack::kTPCrefit))) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
1891                 if (!(bachTrackXi->IsOn(AliAODTrack::kTPCrefit))) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
1892            }
1893            if (fkQualityCutnTPCcls) {
1894                 // - Poor quality related to TPC clusters
1895                 if (lPosTPCClusters  < fMinnTPCcls) { //AliWarning("Pb / V0 Pos. track has less than 80 TPC clusters ... continue!");
1896                     continue; }
1897                 if (lNegTPCClusters  < fMinnTPCcls) { //AliWarning("Pb / V0 Neg. track has less than 80 TPC clusters ... continue!");
1898                     continue; }
1899                 if (lBachTPCClusters < fMinnTPCcls) { //AliWarning("Pb / Bach.   track has less than 80 TPC clusters ... continue!");
1900                     continue; }
1901            }
1902
1903            //---------------------------------------
1904            // - Around the tracks: Bach + V0 (AOD). Necessary variables for AODcascade data members coming from the AODv0 part (inheritance)
1905            etaPos  = pTrackXi->Eta();
1906            etaNeg  = nTrackXi->Eta();
1907            etaBach = bachTrackXi->Eta();
1908            lChargeXi = xi->ChargeXi();
1909            if ( lChargeXi < 0) lInvMassLambdaAsCascDghter = xi->MassLambda();
1910            else                lInvMassLambdaAsCascDghter = xi->MassAntiLambda();
1911            lDcaV0DaughtersXi      = xi->DcaV0Daughters(); 
1912            lDcaV0ToPrimVertexXi   = xi->DcaV0ToPrimVertex();
1913            lDcaBachToPrimVertexXi = xi->DcaBachToPrimVertex(); 
1914            lPosV0Xi[0] = xi->DecayVertexV0X();
1915            lPosV0Xi[1] = xi->DecayVertexV0Y();
1916            lPosV0Xi[2] = xi->DecayVertexV0Z(); 
1917            lV0RadiusXi = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0] + lPosV0Xi[1]*lPosV0Xi[1] );
1918            lV0CosineOfPointingAngleXi = xi->CosPointingAngle( lBestPrimaryVtxPos ); 
1919            lDcaPosToPrimVertexXi      = xi->DcaPosToPrimVertex(); 
1920            lDcaNegToPrimVertexXi      = xi->DcaNegToPrimVertex(); 
1921
1922            //----------------------------------------------------------------------------------------------------       
1923            // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega -/+
1924            if ( lChargeXi < 0 ) lInvMassXiMinus    = xi->MassXi();
1925            if ( lChargeXi > 0 ) lInvMassXiPlus     = xi->MassXi();
1926            if ( lChargeXi < 0 ) lInvMassOmegaMinus = xi->MassOmega();
1927            if ( lChargeXi > 0 ) lInvMassOmegaPlus  = xi->MassOmega();
1928
1929            //--------------------------------
1930            // - PID on the daughter tracks
1931            // - Combined PID ->  removed, add when will be used
1932
1933            // - TPC PID : 3-sigma bands on Bethe-Bloch curve
1934            //Bachelor
1935            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 4) lIsBachelorKaonForTPC = kTRUE;
1936            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 4) lIsBachelorPionForTPC = kTRUE;
1937            //Negative V0 daughter
1938            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kPion   )) < 4) lIsNegPionForTPC   = kTRUE;
1939            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kProton )) < 4) lIsNegProtonForTPC = kTRUE;
1940            //Positive V0 daughter
1941            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kPion   )) < 4) lIsPosPionForTPC   = kTRUE;
1942            if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 4) lIsPosProtonForTPC = kTRUE;
1943
1944            //---------------------------------
1945            // - Extra info for QA (AOD)
1946            // Miscellaneous pieces of info that may help regarding data quality assessment.
1947            // Cascade transverse and total momentum     
1948            lXiMomX = xi->MomXiX();
1949            lXiMomY = xi->MomXiY();
1950            lXiMomZ = xi->MomXiZ();
1951            lXiTransvMom = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY );
1952            lXiTotMom    = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY + lXiMomZ*lXiMomZ );
1953            Double_t lV0MomX = xi->MomV0X();
1954            Double_t lV0MomY = xi->MomV0Y();
1955            Double_t lV0MomZ = xi->MomV0Z();
1956            lV0TotMom = TMath::Sqrt(TMath::Power(lV0MomX,2)+TMath::Power(lV0MomY,2)+TMath::Power(lV0MomZ,2));
1957            lBachMomX = xi->MomBachX();
1958            lBachMomY = xi->MomBachY();
1959            lBachMomZ = xi->MomBachZ();          
1960            lBachTransvMom = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY );
1961            lBachTotMom    = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ );
1962            lV0NMomX = xi->MomNegX();
1963            lV0NMomY = xi->MomNegY();
1964            lV0PMomX = xi->MomPosX();
1965            lV0PMomY = xi->MomPosY();
1966            lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX   + lV0NMomY*lV0NMomY );
1967            lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX   + lV0PMomY*lV0PMomY );
1968            lV0toXiCosineOfPointingAngle = xi->CosPointingAngle( xi->GetDecayVertexXi() );
1969            lRapXi    = xi->RapXi();
1970            lRapOmega = xi->RapOmega();
1971            lEta      = xi->Eta();                       // Will not work ! need a method Pz(), Py() Px() 
1972            lTheta    = xi->Theta() *180.0/TMath::Pi();  // in AODcascade.
1973            lPhi      = xi->Phi()   *180.0/TMath::Pi();  // Here, we will get eta, theta, phi for the V0 ...
1974            lAlphaXi  = xi->AlphaXi();
1975            lPtArmXi  = xi->PtArmXi();
1976
1977     } // end of AOD treatment
1978
1979     // Cut on pt of the three daughter tracks
1980     if (lBachTransvMom<fMinPtCutOnDaughterTracks) continue;
1981     if (lpTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
1982     if (lnTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
1983       
1984     // Cut on pseudorapidity of the three daughter tracks
1985     if (TMath::Abs(etaBach)>fEtaCutOnDaughterTracks) continue;
1986     if (TMath::Abs(etaPos)>fEtaCutOnDaughterTracks) continue;
1987     if (TMath::Abs(etaNeg)>fEtaCutOnDaughterTracks) continue;
1988       
1989       
1990     //----------------------------------
1991     // Calculate proper lenght for cascade
1992     Double_t cascadeMass = 0.;
1993     if ( ( (lChargeXi<0) && lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) ||
1994          ( (lChargeXi>0) && lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC )  ) cascadeMass = 1.321;
1995     if ( ( (lChargeXi<0) && lIsBachelorKaonForTPC   && lIsPosProtonForTPC    && lIsNegPionForTPC ) ||
1996          ( (lChargeXi>0) && lIsBachelorKaonForTPC   && lIsNegProtonForTPC    && lIsPosPionForTPC )  ) cascadeMass = 1.672;
1997     Double_t lctau =  TMath::Sqrt(TMath::Power((lPosXi[0]-lBestPrimaryVtxPos[0]),2)+TMath::Power((lPosXi[1]-lBestPrimaryVtxPos[1]),2)+TMath::Power(( lPosXi[2]-lBestPrimaryVtxPos[2]),2));
1998     if (lXiTotMom!=0) lctau = lctau*cascadeMass/lXiTotMom;
1999     else lctau = -1.;
2000
2001     //-------------------------------------------------
2002     // Calculate proper lenght for Lambda (reconstructed)
2003     Float_t lambdaMass = 1.115683; // PDG mass
2004     Float_t distV0Xi =  TMath::Sqrt(TMath::Power((lPosV0Xi[0]-lPosXi[0]),2)+TMath::Power((lPosV0Xi[1]-lPosXi[1]),2)+TMath::Power((lPosV0Xi[2]-lPosXi[2]),2));
2005     Float_t lctauV0 = -1.;
2006     if (lV0TotMom!=0) lctauV0 = distV0Xi*lambdaMass/lV0TotMom;
2007     Float_t distTV0Xi =  TMath::Sqrt(TMath::Power((lPosV0Xi[0]-lPosXi[0]),2)+TMath::Power((lPosV0Xi[1]-lPosXi[1]),2));
2008
2009     //--------------
2010     /*// For AliEVE      
2011          if(lChargeXi < 0&& lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) {
2012              if (lXiTransvMom>2.&&lXiTransvMom<4.&&(lInvMassXiMinus<1.322&&lInvMassXiMinus>1.320)&&(lXiRadius<8.&&lXiRadius>3.)) {
2013                          // FIXME : Just to know which file is currently open : locate the file containing Xi
2014                   cout << "Name of the file containing Xi candidate(s) :" 
2015                        << CurrentFileName() 
2016                        << " / entry: "     << Entry()
2017                        << " / in file: "   << lESDevent->GetEventNumberInFile()   // <- Cvetan / From Mihaela: AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetReadEntry();
2018                        << " AliESDcascade number " << iXi 
2019                        << " : mass(Xi-) = " << lInvMassXiMinus
2020                        << " / charge = "   << lChargeXi
2021                        << " / pt(Casc) = " << lXiTransvMom
2022                        << " / Decay 2d R(Xi) = " << lXiRadius 
2023                        << endl;
2024              }
2025          }
2026          if(lChargeXi < 0&& lIsBachelorKaonForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) {
2027              if (lXiTransvMom>2&&lXiTransvMom<4&&(lInvMassOmegaMinus<1.674&&lInvMassOmegaMinus>1.670)&&(lXiRadius<8.&&lXiRadius>3.)) {
2028                   cout << "Name of the file containing Omega candidate(s) :"
2029                        << CurrentFileName()
2030                        << " / entry: "     << Entry()
2031                        << " / in file: "   << lESDevent->GetEventNumberInFile()   // <- Cvetan / From Mihaela: AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetReadEntry();
2032                        << " AliESDcascade number " << iXi 
2033                        << " : mass(Omega-) = " << lInvMassOmegaMinus
2034                        << " / charge = "   << lChargeXi
2035                        << " / pt(Casc) = " << lXiTransvMom
2036                        << " / Decay 2d R(Xi) = " << lXiRadius
2037                        << endl;
2038
2039              }
2040          }*/
2041           
2042
2043     // - 
2044     fHistPosV0TPCClusters->Fill( lPosTPCClusters );
2045     fHistNegV0TPCClusters->Fill( lNegTPCClusters );
2046     fHistBachTPCClusters->Fill( lBachTPCClusters );
2047     f2dHistTPCdEdxOfCascDghters->Fill( lInnerWallMomCascDghters[0] , lTPCSignalCascDghters[0] );
2048     f2dHistTPCdEdxOfCascDghters->Fill( lInnerWallMomCascDghters[1] , lTPCSignalCascDghters[1] );
2049     f2dHistTPCdEdxOfCascDghters->Fill( lInnerWallMomCascDghters[2] , lTPCSignalCascDghters[2] );
2050
2051     //----------------
2052     //Plot with PID on  
2053     if ( ( (lChargeXi<0) && lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) ||
2054          ( (lChargeXi>0) && lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC )  ) {
2055                                        // NOTE : 
2056                                        // with this condition, it could happen that a cascade candidate satisfies the wrong requirement,
2057                                        // e.g. one looks at a Xi- candidate for which lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC = kFALSE
2058                                        // Expectation: it should be excluded, but lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC = kTRUE
2059                                        // then this bad Xi-candidate will contribute anyway (OR condition).
2060                                        // Hence: the extra condition on the sign of the Cascade
2061            //if (TMath::Abs( lInvMassXiMinus-1.3217 ) < 0.010 || TMath::Abs( lInvMassXiPlus-1.3217 ) < 0.010)
2062            fHistEffMassXi->Fill( lEffMassXi );
2063            fHistDcaXiDaughters->Fill( lDcaXiDaughters );                    // Flag CascadeVtxer: Cut Variable e 
2064            fHistDcaBachToPrimVertex->Fill( lDcaBachToPrimVertexXi   );      // Flag CascadeVtxer: Cut Variable d
2065            fHistXiCosineOfPointingAngle->Fill( lXiCosineOfPointingAngle );  // Flag CascadeVtxer: Cut Variable f
2066            fHistXiRadius->Fill( lXiRadius );                                // Flag CascadeVtxer: Cut Variable g+h
2067            fHistMassLambdaAsCascDghter->Fill( lInvMassLambdaAsCascDghter ); // Flag CascadeVtxer: Cut Variable c
2068            fHistDcaV0DaughtersXi->Fill( lDcaV0DaughtersXi );
2069            fHistV0CosineOfPointingAngleXi->Fill( lV0CosineOfPointingAngleXi ); 
2070            fHistV0RadiusXi->Fill( lV0RadiusXi );
2071            fHistDcaV0ToPrimVertexXi->Fill( lDcaV0ToPrimVertexXi );          // Flag CascadeVtxer: Cut Variable b
2072            fHistDcaPosToPrimVertexXi->Fill( lDcaPosToPrimVertexXi );
2073            fHistDcaNegToPrimVertexXi->Fill( lDcaNegToPrimVertexXi );
2074            fHistChargeXi->Fill( lChargeXi );
2075            fHistV0toXiCosineOfPointingAngle->Fill( lV0toXiCosineOfPointingAngle );
2076            if ( TMath::Abs( lInvMassXiMinus-1.3217 ) < 0.012 || TMath::Abs( lInvMassXiPlus-1.3217 ) < 0.012) { // One InvMass should be different from 0
2077                 fHistXiTransvMom->Fill( lXiTransvMom );
2078                 fHistXiTotMom->Fill( lXiTotMom );
2079                 fHistBachTransvMomXi->Fill( lBachTransvMom );
2080                 fHistBachTotMomXi->Fill( lBachTotMom );
2081                 fHistRapXi->Fill( lRapXi );
2082                 fHistEtaXi->Fill( lEta );
2083                 if (lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC) {
2084                       fHistEtaBachXi->Fill( etaBach );
2085                       fHistEtaPosXi->Fill( etaPos );
2086                       fHistEtaNegXi->Fill( etaNeg );
2087                 }
2088                 fHistThetaXi->Fill( lTheta );
2089                 fHistPhiXi->Fill( lPhi );
2090            }
2091            if ( TMath::Abs( lInvMassOmegaMinus-1.672 ) < 0.012 || TMath::Abs( lInvMassOmegaPlus-1.672 ) < 0.012 ) { // One InvMass should be different from 0
2092                 fHistRapOmega->Fill( lRapOmega ); 
2093            }
2094            f2dHistArmenteros->Fill( lAlphaXi, lPtArmXi );
2095     } // end with PID ...
2096
2097     //-----------------------
2098     // - Invariant mass plots
2099     //Plots 1D
2100     if ( lChargeXi < 0 ) {
2101          fHistMassXiMinus->Fill( lInvMassXiMinus );
2102          fHistMassOmegaMinus->Fill( lInvMassOmegaMinus );
2103          f2dHistDcaXiDaughtersvsInvMass->Fill(lDcaXiDaughters,lInvMassXiMinus);
2104          f2dHistDcaBachToPrimVertexvsInvMass->Fill(lDcaBachToPrimVertexXi,lInvMassXiMinus); 
2105          f2dHistXiCosineOfPointingAnglevsInvMass->Fill(lXiCosineOfPointingAngle,lInvMassXiMinus);
2106          f2dHistMassLambdaAsCascDghtervsInvMass->Fill(lInvMassLambdaAsCascDghter,lInvMassXiMinus);
2107          f2dHistDcaV0DaughtersXivsInvMass->Fill(lDcaV0DaughtersXi,lInvMassXiMinus);
2108          f2dHistDcaV0ToPrimVertexXivsInvMass->Fill(lDcaV0ToPrimVertexXi,lInvMassXiMinus);
2109     }
2110     if ( lChargeXi > 0 ) {
2111       fHistMassXiPlus->Fill( lInvMassXiPlus );
2112       fHistMassOmegaPlus->Fill( lInvMassOmegaPlus );
2113     }
2114     //Plots 2D, 3D
2115     if ( lChargeXi < 0 ) {
2116       f2dHistEffMassLambdaVsEffMassXiMinus->Fill( lInvMassLambdaAsCascDghter, lInvMassXiMinus ); 
2117       f2dHistEffMassXiVsEffMassOmegaMinus ->Fill( lInvMassXiMinus, lInvMassOmegaMinus );
2118       f2dHistXiRadiusVsEffMassXiMinus     ->Fill( lXiRadius, lInvMassXiMinus );
2119       f2dHistXiRadiusVsEffMassOmegaMinus  ->Fill( lXiRadius, lInvMassOmegaMinus );
2120     } else {
2121       f2dHistEffMassLambdaVsEffMassXiPlus ->Fill( lInvMassLambdaAsCascDghter, lInvMassXiPlus );
2122       f2dHistEffMassXiVsEffMassOmegaPlus  ->Fill( lInvMassXiPlus, lInvMassOmegaPlus );
2123       f2dHistXiRadiusVsEffMassXiPlus      ->Fill( lXiRadius, lInvMassXiPlus);
2124       f2dHistXiRadiusVsEffMassOmegaPlus   ->Fill( lXiRadius, lInvMassOmegaPlus );
2125     }
2126
2127     //---------------------------------------------     
2128     // - Filling the AliCFContainers related to PID
2129     Double_t lContainerPIDVars[3] = {0.0};
2130     // Xi Minus         
2131     if ( lChargeXi < 0 ) {
2132           lContainerPIDVars[0] = lXiTransvMom;
2133           lContainerPIDVars[1] = lInvMassXiMinus;
2134           lContainerPIDVars[2] = lRapXi;
2135           //No PID
2136           fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 0); // No PID
2137           //TPC PID
2138           if ( lIsBachelorPionForTPC )                                           fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 1); // TPC PID / 4-#sigma cut on Bachelor track              
2139           if ( lIsBachelorPionForTPC && lIsPosProtonForTPC )                     fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 2); // TPC PID / 4-#sigma cut on Bachelor+Baryon tracks
2140           if ( lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 3); // TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks
2141           //Combined PID
2142           if ( lIsBachelorPion )                                      fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 4); // Comb. PID / Bachelor     
2143           if ( lIsBachelorPion && lIsPosInXiProton )                  fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 5); // Comb. PID / Bachelor+Baryon
2144           if (lIsBachelorPion && lIsPosInXiProton && lIsNegInXiPion ) fCFContCascadePIDXiMinus->Fill(lContainerPIDVars, 6); // Comb. PID / Bachelor+Baryon+Meson
2145     }
2146     lContainerPIDVars[0] = 0.; lContainerPIDVars[1] = 0.; lContainerPIDVars[2] = 0.;    
2147     // Xi Plus          
2148     if ( lChargeXi > 0 ) {
2149           lContainerPIDVars[0] = lXiTransvMom;
2150           lContainerPIDVars[1] = lInvMassXiPlus;
2151           lContainerPIDVars[2] = lRapXi;
2152           //No PID
2153           fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 0); // No PID
2154           //TPC PID
2155           if ( lIsBachelorPionForTPC )                                           fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 1); // TPC PID / 4-#sigma cut on Bachelor track
2156           if ( lIsBachelorPionForTPC && lIsNegProtonForTPC )                     fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 2); // TPC PID / 4-#sigma cut on Bachelor+Baryon tracks
2157           if ( lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC ) fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 3); // TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks
2158           //Combined PID
2159           if ( lIsBachelorPion )                                      fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 4); // Comb. PID / Bachelor
2160           if ( lIsBachelorPion && lIsNegInXiProton )                  fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 5); // Comb. PID / Bachelor+Baryon
2161           if (lIsBachelorPion && lIsNegInXiProton && lIsPosInXiPion ) fCFContCascadePIDXiPlus->Fill(lContainerPIDVars, 6); // Comb. PID / Bachelor+Baryon+Meson
2162     }
2163     lContainerPIDVars[0] = 0.; lContainerPIDVars[1] = 0.; lContainerPIDVars[2] = 0.; 
2164     // Omega Minus              
2165     if ( lChargeXi < 0 ) {
2166           lContainerPIDVars[0] = lXiTransvMom;
2167           lContainerPIDVars[1] = lInvMassOmegaMinus;
2168           lContainerPIDVars[2] = lRapOmega;
2169           //No PID
2170           fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 0); // No PID
2171           //TPC PID
2172           if ( lIsBachelorKaonForTPC )                                           fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 1); // TPC PID / 4-#sigma cut on Bachelor track
2173           if ( lIsBachelorKaonForTPC && lIsPosProtonForTPC )                     fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 2); // TPC PID / 4-#sigma cut on Bachelor+Baryon tracks
2174           if ( lIsBachelorKaonForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 3); // TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks
2175           //Combined PID
2176           if ( lIsBachelorKaon )                                            fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 4); // Comb. PID / Bachelor
2177           if ( lIsBachelorKaon && lIsPosInOmegaProton )                     fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 5); // Comb. PID / Bachelor+Baryon
2178           if (lIsBachelorKaon && lIsPosInOmegaProton && lIsNegInOmegaPion ) fCFContCascadePIDOmegaMinus->Fill(lContainerPIDVars, 6); // Comb. PID / Bachelor+Baryon+Meson
2179     }
2180     lContainerPIDVars[0] = 0.; lContainerPIDVars[1] = 0.; lContainerPIDVars[2] = 0.;
2181     // Omega Plus               
2182     if ( lChargeXi > 0 ) {
2183       lContainerPIDVars[0] = lXiTransvMom;
2184       lContainerPIDVars[1] = lInvMassOmegaPlus;
2185       lContainerPIDVars[2] = lRapOmega;
2186         // No PID
2187       fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 0); // No PID
2188         // TPC PID
2189       if ( lIsBachelorKaonForTPC  )
2190         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 1); // TPC PID / 4-#sigma cut on Bachelor track
2191       if( lIsBachelorKaonForTPC && 
2192           lIsNegProtonForTPC     )
2193         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 2); // TPC PID / 4-#sigma cut on Bachelor+Baryon tracks
2194       if ( lIsBachelorKaonForTPC && 
2195            lIsNegProtonForTPC    && 
2196            lIsPosPionForTPC       )
2197         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 3); // TPC PID / 4-#sigma cut on Bachelor+Baryon+Meson tracks
2198         // Combined PID
2199       if ( lIsBachelorKaon        )
2200         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 4); // Comb. PID / Bachelor
2201       if ( lIsBachelorKaon       && 
2202            lIsNegInOmegaProton    )
2203         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 5); // Comb. PID / Bachelor+Baryon
2204       if (lIsBachelorKaon     && 
2205           lIsNegInOmegaProton && 
2206           lIsPosInOmegaPion    )
2207         fCFContCascadePIDOmegaPlus->Fill(lContainerPIDVars, 6); // Comb. PID / Bachelor+Baryon+Meson
2208     }
2209                 
2210     //--------------------------------------------------------------------
2211     // Filling the AliCFContainer (optimisation of topological selections)
2212     Double_t lContainerCutVars[19] = {0.0};
2213                         
2214     lContainerCutVars[0]  = lDcaXiDaughters;
2215     lContainerCutVars[1]  = lDcaBachToPrimVertexXi;
2216     lContainerCutVars[2]  = lXiCosineOfPointingAngle;
2217     lContainerCutVars[3]  = lXiRadius;
2218     lContainerCutVars[4]  = lInvMassLambdaAsCascDghter;
2219     lContainerCutVars[5]  = lDcaV0DaughtersXi;
2220     lContainerCutVars[6]  = lV0toXiCosineOfPointingAngle;
2221     lContainerCutVars[7]  = lV0RadiusXi;
2222     lContainerCutVars[8]  = lDcaV0ToPrimVertexXi;       
2223     lContainerCutVars[9]  = lDcaPosToPrimVertexXi;
2224     lContainerCutVars[10] = lDcaNegToPrimVertexXi;
2225     lContainerCutVars[13] = lXiTransvMom;
2226     lContainerCutVars[16] = lctau;
2227     lContainerCutVars[17] = lctauV0;
2228     lContainerCutVars[18] = distTV0Xi;
2229  
2230     if ( lChargeXi < 0 ) {
2231          lContainerCutVars[11] = lInvMassXiMinus;
2232          lContainerCutVars[12] = lInvMassOmegaMinus;
2233          lContainerCutVars[14] = lRapXi;
2234          lContainerCutVars[15] = -1.;
2235          if (lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,0); // for Xi-
2236          lContainerCutVars[11] = lInvMassXiMinus;
2237          lContainerCutVars[12] = lInvMassOmegaMinus;
2238          lContainerCutVars[14] = -1.;
2239          lContainerCutVars[15] = lRapOmega;
2240          if (lIsBachelorKaonForTPC && lIsPosProtonForTPC && lIsNegPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,2); // for Omega-
2241     } else {
2242          lContainerCutVars[11] = lInvMassXiPlus;
2243          lContainerCutVars[12] = lInvMassOmegaPlus; 
2244          lContainerCutVars[14] = lRapXi;
2245          lContainerCutVars[15] = -1.; 
2246          if (lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,1); // for Xi+
2247          lContainerCutVars[11] = lInvMassXiPlus;
2248          lContainerCutVars[12] = lInvMassOmegaPlus;
2249          lContainerCutVars[14] = -1.;
2250          lContainerCutVars[15] = lRapOmega;
2251          if (lIsBachelorKaonForTPC && lIsNegProtonForTPC && lIsPosPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,3); // for Omega+ 
2252     }                 
2253   } //end of the Cascade loop (ESD or AOD)
2254     
2255   // Post output data.
2256  PostData(1, fListHistCascade);
2257  PostData(2, fCFContCascadePIDXiMinus);
2258  PostData(3, fCFContCascadePIDXiPlus);
2259  PostData(4, fCFContCascadePIDOmegaMinus);
2260  PostData(5, fCFContCascadePIDOmegaPlus);
2261  PostData(6, fCFContCascadeCuts);
2262 }
2263
2264 //________________________________________________________________________
2265 Int_t AliAnalysisTaskCheckCascadepp276::DoESDTrackWithTPCrefitMultiplicity(const AliESDEvent *lESDevent) {
2266     // Checking the number of tracks with TPCrefit for each event
2267     // Needed for a rough assessment of the event multiplicity
2268         
2269     Int_t nTrackWithTPCrefitMultiplicity = 0;
2270     for (Int_t iTrackIdx = 0; iTrackIdx < (InputEvent())->GetNumberOfTracks(); iTrackIdx++) {
2271       AliESDtrack *esdTrack     = 0x0;
2272       esdTrack  = lESDevent->GetTrack( iTrackIdx );
2273       if (!esdTrack) { AliWarning("Pb / Could not retrieve one track within the track loop for TPCrefit check ..."); continue; }
2274
2275       ULong_t lTrackStatus    = esdTrack->GetStatus();
2276       if ((lTrackStatus&AliESDtrack::kTPCrefit)    == 0) continue;
2277       else nTrackWithTPCrefitMultiplicity++;
2278         // FIXME :
2279         // The goal here is to get a better assessment of the event multiplicity.
2280         // (InputEvent())->GetNumberOfTracks() takes into account ITS std alone tracks + global tracks
2281         // This may introduce a bias. Hence the number of TPC refit tracks.
2282         // Note : the event multiplicity = analysis on its own... See Jacek's or Jan Fiete's analysis on dN/d(eta)
2283
2284     } // end loop over all event tracks
2285     return  nTrackWithTPCrefitMultiplicity;
2286 }
2287
2288
2289 //________________________________________________________________________
2290 void AliAnalysisTaskCheckCascadepp276::Terminate(Option_t *) 
2291 {
2292   // Draw result to the screen
2293   // Called once at the end of the query
2294
2295 /*  TList *cRetrievedList = 0x0;
2296          cRetrievedList = (TList*)GetOutputData(1);
2297         if(!cRetrievedList){
2298                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: ouput data container list not available\n"); return;
2299         }
2300   fHistTrackMultiplicity = dynamic_cast<TH1F*> (   cRetrievedList->FindObject("fHistTrackMultiplicity") );
2301   if (!fHistTrackMultiplicity) {
2302                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: fHistTrackMultiplicity not available\n"); return;
2303         }
2304   fHistMassXiMinus    = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistMassXiMinus") ); 
2305         if (!fHistMassXiMinus) {
2306                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: fHistMassXiMinus not available\n"); return;
2307         }
2308   fHistMassXiPlus     = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistMassXiPlus") );
2309         if (!fHistMassXiPlus) {
2310                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: fHistMassXiPlus not available\n"); return;
2311         }       
2312   fHistMassOmegaMinus = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistMassOmegaMinus") );
2313         if (!fHistMassOmegaMinus) {
2314                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: fHistMassOmegaMinus not available\n"); return;
2315         }
2316   fHistMassOmegaPlus  = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistMassOmegaPlus") );       
2317         if (!fHistMassOmegaPlus) {
2318                 AliWarning("ERROR - AliAnalysisTaskCheckCascadepp276: fHistMassOmegaPlus not available\n"); return;
2319         }
2320   
2321   TCanvas *canCheckCascade = new TCanvas("AliAnalysisTaskCheckCascadep276","CheckCascade overview",10,10,1010,660);
2322   canCheckCascade->Divide(2,2);
2323   
2324   canCheckCascade->cd(1);
2325   canCheckCascade->cd(1)->SetLogy();
2326   fHistTrackMultiplicity->SetMarkerStyle(kFullStar);  
2327   fHistTrackMultiplicity->GetXaxis()->SetLabelFont(42);
2328   fHistTrackMultiplicity->GetYaxis()->SetLabelFont(42);
2329   fHistTrackMultiplicity->SetTitleFont(42, "xy");
2330   fHistTrackMultiplicity->GetXaxis()->SetTitleOffset(1.1);
2331   fHistTrackMultiplicity->DrawCopy("H");
2332   
2333   canCheckCascade->cd(2);  
2334   fHistMassXiMinus ->SetMarkerStyle(kFullCircle);
2335   fHistMassXiMinus ->SetMarkerSize(0.5);
2336   fHistMassXiMinus ->GetXaxis()->SetLabelFont(42);
2337   fHistMassXiMinus ->GetYaxis()->SetLabelFont(42);
2338   fHistMassXiMinus ->SetTitleFont(42, "xy");
2339   fHistMassXiMinus ->GetXaxis()->SetTitleOffset(1.1);
2340   fHistMassXiMinus ->GetYaxis()->SetTitleOffset(1.3);
2341   //fHistMassXiMinus->Rebin(2);
2342   fHistMassXiMinus ->GetXaxis()->SetRangeUser(1.24, 1.42);
2343   fHistMassXiMinus ->DrawCopy("E");
2344   
2345   fHistMassXiPlus ->SetMarkerStyle(kOpenCircle);
2346   fHistMassXiPlus ->SetMarkerColor(kRed+2);
2347   fHistMassXiPlus ->SetLineColor(kRed+2);
2348   fHistMassXiPlus ->SetMarkerSize(0.5);
2349   //fHistMassXiPlus ->Rebin(2);
2350   fHistMassXiPlus ->DrawCopy("ESAME");
2351   
2352   
2353   TLegend *legendXi =new TLegend(0.67,0.34,0.97,0.54);
2354                 legendXi->SetTextFont(42);
2355                 legendXi->SetTextSize(0.05);
2356                 legendXi->SetFillColor(kWhite);
2357                 legendXi->AddEntry( fHistMassXiMinus,"#Xi^{-} candidates","lp");
2358                 legendXi->AddEntry( fHistMassXiPlus,"#Xi^{+} candidates","lp");
2359                 legendXi->Draw();
2360   
2361   
2362   canCheckCascade->cd(3);  
2363   fHistMassOmegaPlus ->SetMarkerStyle(kOpenCircle);
2364   fHistMassOmegaPlus ->SetMarkerColor(kRed+2);
2365   fHistMassOmegaPlus ->SetLineColor(kRed+2);
2366   fHistMassOmegaPlus ->SetMarkerSize(0.5);
2367   fHistMassOmegaPlus ->GetXaxis()->SetLabelFont(42);
2368   fHistMassOmegaPlus ->GetYaxis()->SetLabelFont(42);
2369   fHistMassOmegaPlus ->SetTitleFont(42, "xy");
2370   fHistMassOmegaPlus ->GetXaxis()->SetTitleOffset(1.1);
2371   fHistMassOmegaPlus ->GetYaxis()->SetTitleOffset(1.25);
2372   //fHistMassOmegaPlus ->Rebin(2);
2373   fHistMassOmegaPlus ->GetXaxis()->SetRangeUser(1.6, 1.84);
2374   fHistMassOmegaPlus ->DrawCopy("E");
2375   
2376   fHistMassOmegaMinus->SetMarkerStyle(kFullCircle);
2377   fHistMassOmegaMinus->SetMarkerSize(0.5);
2378   //fHistMassOmegaMinus->Rebin(2);
2379   fHistMassOmegaMinus->DrawCopy("ESAME");
2380
2381   
2382    TLegend *legendOmega = new TLegend(0.67,0.34,0.97,0.54);
2383                 legendOmega->SetTextFont(42);
2384                 legendOmega->SetTextSize(0.05);
2385                 legendOmega->SetFillColor(kWhite);
2386                 legendOmega->AddEntry( fHistMassOmegaMinus,"#Omega^{-} candidates","lp");
2387                 legendOmega->AddEntry( fHistMassOmegaPlus,"#Omega^{+} candidates","lp");
2388                 legendOmega->Draw();
2389      */
2390 }