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