]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/QATasks/AliAnalysisTaskQAMultistrange.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGLF / QATasks / AliAnalysisTaskQAMultistrange.cxx
1 /**************************************************************************
2  *  Authors : Domenico Colella                                            *
3  *                                                                        *
4  *                                                                        *
5  * Derived from the:                                                      *
6  *  - Original AliAnalysisTaskCheckCascade (A. Maire, G. Hippolyte)       *
7  *  - Adapted to PbPb analysis (M. Nicassio)                              *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 class TTree;
19 class TParticle;
20 class TVector3;
21
22 class AliESDVertex;
23 class AliAODVertex;
24 class AliESDv0;
25 class AliAODv0;
26
27 #include <Riostream.h>
28 #include "THnSparse.h"
29 #include "TVector3.h"
30 #include "TMath.h"
31
32 #include "AliLog.h"
33 #include "AliCentrality.h"
34 #include "AliESDEvent.h"
35 #include "AliAODEvent.h"
36 #include "AliESDtrackCuts.h"
37 #include "AliPIDResponse.h"
38
39 #include "AliInputEventHandler.h"
40 #include "AliAnalysisManager.h"
41 #include "AliESDInputHandler.h" 
42 #include "AliAODInputHandler.h"
43 #include "AliCFContainer.h"
44 #include "AliMultiplicity.h"
45
46 #include "AliESDcascade.h"
47 #include "AliAODcascade.h"
48 #include "AliAODTrack.h"
49
50 #include "AliAnalysisTaskQAMultistrange.h"
51
52 ClassImp(AliAnalysisTaskQAMultistrange)
53
54
55
56 //________________________________________________________________________
57 AliAnalysisTaskQAMultistrange::AliAnalysisTaskQAMultistrange() 
58   : AliAnalysisTaskSE(), 
59     fAnalysisType               ("ESD"), 
60     fESDtrackCuts               (0),
61     fCollidingSystem            ("PbPb"),
62     fPIDResponse                (0),
63     fkSDDSelectionOn            (kTRUE),
64     fkQualityCutZprimVtxPos     (kTRUE),
65     fkQualityCutNoTPConlyPrimVtx(kTRUE),
66     fkQualityCutTPCrefit        (kTRUE),
67     fkQualityCutnTPCcls         (kTRUE),
68     fkQualityCutPileup          (kTRUE),
69     fwithSDD                    (kTRUE),
70     fMinnTPCcls                 (0),  
71     fCentrLowLim                (0),
72     fCentrUpLim                 (0),
73     fCentrEstimator             (0),
74     fkUseCleaning               (0),
75     fVtxRange                   (0),
76     fMinPtCutOnDaughterTracks   (0),
77     fEtaCutOnDaughterTracks     (0),
78
79     
80     fCFContCascadeCuts(0)
81     
82
83 {
84   // Dummy Constructor
85 }
86
87
88 //________________________________________________________________________
89 AliAnalysisTaskQAMultistrange::AliAnalysisTaskQAMultistrange(const char *name) 
90   : AliAnalysisTaskSE(name),
91     fAnalysisType               ("ESD"), 
92     fESDtrackCuts               (0),
93     fCollidingSystem            ("PbPb"),
94     fPIDResponse                (0),
95     fkSDDSelectionOn            (kTRUE),
96     fkQualityCutZprimVtxPos     (kTRUE),
97     fkQualityCutNoTPConlyPrimVtx(kTRUE),
98     fkQualityCutTPCrefit        (kTRUE),
99     fkQualityCutnTPCcls         (kTRUE),
100     fkQualityCutPileup          (kTRUE),
101     fwithSDD                    (kTRUE),
102     fMinnTPCcls                 (0),
103     fCentrLowLim                (0),
104     fCentrUpLim                 (0),
105     fCentrEstimator             (0),
106     fkUseCleaning               (0),
107     fVtxRange                   (0),
108     fMinPtCutOnDaughterTracks   (0),
109     fEtaCutOnDaughterTracks     (0),
110
111
112     fCFContCascadeCuts(0)
113     
114
115 {
116   // Constructor
117   // Output slot #0 writes into a TList container (Cascade)
118   DefineOutput(1, AliCFContainer::Class());
119
120   AliLog::SetClassDebugLevel("AliAnalysisTaskQAMultistrange",1);
121 }
122
123
124 AliAnalysisTaskQAMultistrange::~AliAnalysisTaskQAMultistrange() {
125   //
126   // Destructor
127   //
128   // For all TH1, 2, 3 HnSparse and CFContainer are in the fListCascade TList.
129   // They will be deleted when fListCascade is deleted by the TSelector dtor
130   // Because of TList::SetOwner() ...
131   if (fCFContCascadeCuts && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { delete fCFContCascadeCuts;     fCFContCascadeCuts = 0x0;  }
132   if (fESDtrackCuts)         { delete fESDtrackCuts;        fESDtrackCuts = 0x0; }
133 }
134
135
136
137 //________________________________________________________________________
138 void AliAnalysisTaskQAMultistrange::UserCreateOutputObjects() {
139   // Create histograms
140   // Called once
141
142  //-----------------------------------------------
143  // Particle Identification Setup (new PID object)
144  //-----------------------------------------------
145  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
146  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
147  fPIDResponse = inputHandler->GetPIDResponse();
148
149
150  // Only used to get the number of primary reconstructed tracks
151  if (fAnalysisType == "ESD" && (! fESDtrackCuts )){
152    fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
153    //Printf("CheckCascade - ESDtrackCuts set up to 2010 std ITS-TPC cuts...");
154  }
155
156
157  //---------------------------------------------------
158  // Define the container for the topological variables
159  //---------------------------------------------------
160   if(! fCFContCascadeCuts) {
161       // Container meant to store all the relevant distributions corresponding to the cut variables.
162       // NB: overflow/underflow of variables on which we want to cut later should be 0!!! 
163       const Int_t  lNbSteps      =  4 ;
164       const Int_t  lNbVariables  =  21 ;
165       //Array for the number of bins in each dimension :
166       Int_t lNbBinsPerVar[lNbVariables] = {0};
167       lNbBinsPerVar[0]  = 25;     //DcaCascDaughters             :  [0.0,2.4,3.0]       -> Rec.Cut = 2.0;
168       lNbBinsPerVar[1]  = 25;     //DcaBachToPrimVertex          :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01; 
169       lNbBinsPerVar[2]  = 30;     //CascCosineOfPointingAngle    :  [0.97,1.0]          -> Rec.Cut = 0.98;
170       lNbBinsPerVar[3]  = 40;     //CascRadius                   :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
171       lNbBinsPerVar[4]  = 30;     //InvMassLambdaAsCascDghter    :  [1.1,1.3]           -> Rec.Cut = 0.008;
172       lNbBinsPerVar[5]  = 20;     //DcaV0Daughters               :  [0.0,2.0]           -> Rec.Cut = 1.5;
173       lNbBinsPerVar[6]  = 201;    //V0CosineOfPointingAngleToPV  :  [0.89,1.0]          -> Rec.Cut = 0.9;
174       lNbBinsPerVar[7]  = 40;     //V0Radius                     :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
175       lNbBinsPerVar[8]  = 40;     //DcaV0ToPrimVertex            :  [0.0,0.39,110.0]    -> Rec.Cut = 0.01;  
176       lNbBinsPerVar[9]  = 25;     //DcaPosToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.05;
177       lNbBinsPerVar[10] = 25;     //DcaNegToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.05
178       lNbBinsPerVar[11] = 150;    //InvMassXi                    :   2-MeV/c2 bins
179       lNbBinsPerVar[12] = 120;    //InvMassOmega                 :   2-MeV/c2 bins
180       lNbBinsPerVar[13] = 100;    //XiTransvMom                  :  [0.0,10.0]
181       lNbBinsPerVar[14] = 110;    //Y(Xi)                        :   0.02 in rapidity units
182       lNbBinsPerVar[15] = 110;    //Y(Omega)                     :   0.02 in rapidity units
183       lNbBinsPerVar[16] = 112;    //Proper lenght of cascade       
184       lNbBinsPerVar[17] = 112;    //Proper lenght of V0
185       lNbBinsPerVar[18] = 201;    //V0CosineOfPointingAngleToXiV
186       lNbBinsPerVar[19] = 11;     //Centrality
187       lNbBinsPerVar[20] = 100;    //ESD track multiplicity
188       //define the container
189       fCFContCascadeCuts = new AliCFContainer("fCFContCascadeCuts","Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar );
190       //Setting the bin limits 
191       //0 -  DcaXiDaughters
192       Double_t *lBinLim0  = new Double_t[ lNbBinsPerVar[0] + 1 ];
193          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;
194          lBinLim0[ lNbBinsPerVar[0] ] = 3.0;
195       fCFContCascadeCuts -> SetBinLimits(0, lBinLim0);
196       delete [] lBinLim0;
197       //1 - DcaToPrimVertexXi
198       Double_t *lBinLim1  = new Double_t[ lNbBinsPerVar[1] + 1 ];
199          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;
200          lBinLim1[ lNbBinsPerVar[1] ] = 100.0;
201       fCFContCascadeCuts -> SetBinLimits(1, lBinLim1);
202       delete [] lBinLim1;
203       //2 - CascCosineOfPointingAngle 
204       fCFContCascadeCuts->SetBinLimits(2, 0.97, 1.);
205       //3 - CascRadius
206       Double_t *lBinLim3  = new Double_t[ lNbBinsPerVar[3]+1 ];
207          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 ;
208          lBinLim3[ lNbBinsPerVar[3] ] = 1000.0;
209       fCFContCascadeCuts -> SetBinLimits(3,  lBinLim3 );
210       delete [] lBinLim3;
211       //4 - InvMassLambdaAsCascDghter
212       fCFContCascadeCuts->SetBinLimits(4, 1.1, 1.13);
213       //5 - DcaV0Daughters
214       fCFContCascadeCuts -> SetBinLimits(5, 0., 2.);
215       //6 - V0CosineOfPointingAngleToPV
216       fCFContCascadeCuts -> SetBinLimits(6, 0.8, 1.001);
217       //7 - V0Radius
218       Double_t *lBinLim7 = new Double_t[ lNbBinsPerVar[7] + 1];
219          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;
220          lBinLim7[ lNbBinsPerVar[7] ] = 1000.0;
221       fCFContCascadeCuts -> SetBinLimits(7, lBinLim7);
222       delete [] lBinLim7;
223       //8 - DcaV0ToPrimVertex
224       Double_t *lBinLim8  = new Double_t[ lNbBinsPerVar[8]+1 ];
225          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 ;
226          lBinLim8[ lNbBinsPerVar[8]  ] = 100.0;
227       fCFContCascadeCuts -> SetBinLimits(8,  lBinLim8 );
228       delete [] lBinLim8;
229       //9 - DcaPosToPrimVertex
230       Double_t *lBinLim9  = new Double_t[ lNbBinsPerVar[9]+1 ];
231          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 ;
232          lBinLim9[ lNbBinsPerVar[9]  ] = 100.0;
233       fCFContCascadeCuts -> SetBinLimits(9,  lBinLim9 );
234       delete [] lBinLim9;
235       //10 - DcaNegToPrimVertex
236       Double_t *lBinLim10  = new Double_t[ lNbBinsPerVar[10]+1 ];
237          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 ;
238          lBinLim10[ lNbBinsPerVar[10]  ] = 100.0;
239       fCFContCascadeCuts -> SetBinLimits(10,  lBinLim10 );     
240       delete [] lBinLim10;
241       //11 - InvMassXi
242       fCFContCascadeCuts->SetBinLimits(11, 1.25, 1.40);
243       //12 - InvMassOmega
244       fCFContCascadeCuts->SetBinLimits(12, 1.62, 1.74);
245       //13 - XiTransvMom
246       fCFContCascadeCuts->SetBinLimits(13, 0.0, 10.0);
247       //14 - Y(Xi)
248       fCFContCascadeCuts->SetBinLimits(14, -1.1, 1.1);
249       //15 - Y(Omega)
250       fCFContCascadeCuts->SetBinLimits(15, -1.1, 1.1);
251       //16 - Proper time of cascade
252       Double_t *lBinLim16  = new Double_t[ lNbBinsPerVar[16]+1 ];
253          for(Int_t i=0; i< lNbBinsPerVar[16];i++) lBinLim16[i] = (Double_t) -1. + (110. + 1.0 ) / (lNbBinsPerVar[16] - 1) * (Double_t) i;
254          lBinLim16[ lNbBinsPerVar[16] ] = 2000.0;
255       fCFContCascadeCuts->SetBinLimits(16, lBinLim16);
256       //17 - Proper time of V0
257       fCFContCascadeCuts->SetBinLimits(17, lBinLim16);
258       //18 - V0CosineOfPointingAngleToXiV
259       fCFContCascadeCuts -> SetBinLimits(18, 0.8, 1.001);
260       //19
261       Double_t *lBinLim19  = new Double_t[ lNbBinsPerVar[19]+1 ];
262          for(Int_t i=3; i< lNbBinsPerVar[19]+1;i++)   lBinLim19[i]  = (Double_t)(i-1)*10.;
263          lBinLim19[0] = 0.0; 
264          lBinLim19[1] = 5.0; 
265          lBinLim19[2] = 10.0;
266       fCFContCascadeCuts->SetBinLimits(19,  lBinLim19 );     
267       delete [] lBinLim19;
268       //20
269       fCFContCascadeCuts->SetBinLimits(20, 0.0, 6000.0);
270       // Setting the number of steps : one for each cascade species (Xi-, Xi+ and Omega-, Omega+)
271       fCFContCascadeCuts->SetStepTitle(0, "#Xi^{-} candidates");
272       fCFContCascadeCuts->SetStepTitle(1, "#bar{#Xi}^{+} candidates");
273       fCFContCascadeCuts->SetStepTitle(2, "#Omega^{-} candidates");
274       fCFContCascadeCuts->SetStepTitle(3, "#bar{#Omega}^{+} candidates");
275       // Setting the variable title, per axis
276       fCFContCascadeCuts->SetVarTitle(0,  "Dca(cascade daughters) (cm)");
277       fCFContCascadeCuts->SetVarTitle(1,  "ImpactParamToPV(bachelor) (cm)");
278       fCFContCascadeCuts->SetVarTitle(2,  "cos(cascade PA)");
279       fCFContCascadeCuts->SetVarTitle(3,  "R_{2d}(cascade decay) (cm)");
280       fCFContCascadeCuts->SetVarTitle(4,  "M_{#Lambda}(as casc dghter) (GeV/c^{2})");
281       fCFContCascadeCuts->SetVarTitle(5,  "Dca(V0 daughters) in Xi (cm)");
282       fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 PA) in cascade to PV");
283       fCFContCascadeCuts->SetVarTitle(7,  "R_{2d}(V0 decay) (cm)");
284       fCFContCascadeCuts->SetVarTitle(8,  "ImpactParamToPV(V0) (cm)");
285       fCFContCascadeCuts->SetVarTitle(9,  "ImpactParamToPV(Pos) (cm)");
286       fCFContCascadeCuts->SetVarTitle(10, "ImpactParamToPV(Neg) (cm)");
287       fCFContCascadeCuts->SetVarTitle(11, "Inv. Mass(Xi) (GeV/c^{2})");
288       fCFContCascadeCuts->SetVarTitle(12, "Inv. Mass(Omega) (GeV/c^{2})");
289       fCFContCascadeCuts->SetVarTitle(13, "pt(cascade) (GeV/c)");
290       fCFContCascadeCuts->SetVarTitle(14, "Y(Xi)");
291       fCFContCascadeCuts->SetVarTitle(15, "Y(Omega)");
292       fCFContCascadeCuts->SetVarTitle(16, "mL/p (cascade) (cm)");
293       fCFContCascadeCuts->SetVarTitle(17, "mL/p (V0) (cm)");
294       fCFContCascadeCuts->SetVarTitle(18,  "cos(V0 PA) in cascade to XiV");
295       fCFContCascadeCuts->SetVarTitle(19, "Centrality");
296       fCFContCascadeCuts->SetVarTitle(20, "ESD track multiplicity");
297   }
298
299 PostData(1, fCFContCascadeCuts);
300
301 }// end UserCreateOutputObjects
302
303
304 //________________________________________________________________________
305 void AliAnalysisTaskQAMultistrange::UserExec(Option_t *) {
306
307   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308   // Main loop (called for each event)
309   //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310
311   //-----------------------
312   //Define ESD/AOD handlers 
313   AliESDEvent *lESDevent = 0x0;
314   AliAODEvent *lAODevent = 0x0;
315
316   //---------------------
317   //Check the PIDresponse
318   if(!fPIDResponse) {
319        AliError("Cannot get pid response");
320        return;
321   }
322
323   //__________________________________________________
324   // After these lines we should have an ESD/AOD event
325
326   //---------------------------------------------------------
327   //Load the InputEvent and check, before any event selection   
328   //---------------------------------------------------------
329   Float_t  lPrimaryTrackMultiplicity = -1.;
330   AliCentrality* centrality = 0;
331   if (fAnalysisType == "ESD") {
332       lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
333       if (!lESDevent) {
334           AliWarning("ERROR: lESDevent not available \n");
335           return;
336       }
337       if (fCollidingSystem == "PbPb") lPrimaryTrackMultiplicity = fESDtrackCuts->CountAcceptedTracks(lESDevent);
338       if (fCollidingSystem == "PbPb") centrality = lESDevent->GetCentrality();
339       
340   } else if (fAnalysisType == "AOD") {
341       lAODevent = dynamic_cast<AliAODEvent*>( InputEvent() );
342       if (!lAODevent) {
343           AliWarning("ERROR: lAODevent not available \n");
344           return;
345       }
346       if (fCollidingSystem == "PbPb") {
347           lPrimaryTrackMultiplicity = 0;
348           Int_t    nTrackMultiplicity = (InputEvent())->GetNumberOfTracks();
349           for (Int_t itrack = 0; itrack < nTrackMultiplicity; itrack++) {
350                AliAODTrack* track = lAODevent->GetTrack(itrack);
351                if (track->TestFilterBit(AliAODTrack::kTrkGlobalNoDCA)) lPrimaryTrackMultiplicity++; 
352           }
353       }
354       if (fCollidingSystem == "PbPb") centrality = lAODevent->GetCentrality();
355   } else {
356     Printf("Analysis type (ESD or AOD) not specified \n");
357     return;
358   }
359
360   //-----------------------------------------
361   // Centrality selection for PbPb collisions
362   //-----------------------------------------
363   Float_t lcentrality = 0.;
364   if (fCollidingSystem == "PbPb") { 
365        if (fkUseCleaning) lcentrality = centrality->GetCentralityPercentile(fCentrEstimator.Data());
366        else {
367            lcentrality = centrality->GetCentralityPercentileUnchecked(fCentrEstimator.Data());
368            if (centrality->GetQuality()>1) {
369                PostData(1, fCFContCascadeCuts);
370                return;
371            }
372        }
373        if (lcentrality<fCentrLowLim||lcentrality>=fCentrUpLim) { 
374            PostData(1, fCFContCascadeCuts);
375            return;
376        }
377   } else if (fCollidingSystem == "pp") lcentrality = 0.;
378
379
380   //----------------------------------------
381   // SDD selection for pp@2.76TeV collisions
382   //----------------------------------------
383   if (fCollidingSystem == "pp") {
384       if (fAnalysisType == "ESD") {
385           if (fkSDDSelectionOn) {
386               TString trcl = lESDevent->GetFiredTriggerClasses();
387               if      (fwithSDD) { if(!(trcl.Contains("ALLNOTRD"))) { PostData(1, fCFContCascadeCuts); return; } }
388               else if (!fwithSDD){ if((trcl.Contains("ALLNOTRD")))  { PostData(1, fCFContCascadeCuts); return; } }
389           }
390       } else if (fAnalysisType == "AOD") {
391           if (fkSDDSelectionOn) {
392               TString trcl = lAODevent->GetFiredTriggerClasses();
393               if      (fwithSDD)  { if(!(trcl.Contains("ALLNOTRD"))) { PostData(1, fCFContCascadeCuts); return; } }
394               else if (!fwithSDD) { if((trcl.Contains("ALLNOTRD")))  { PostData(1, fCFContCascadeCuts); return; } }
395           }
396       }
397   }
398
399   //--------------------------------------------
400   // Physics selection for pp@2.76TeV collisions
401   //--------------------------------------------
402   // - moved to the runGrid for the PbPb collisions
403   if (fCollidingSystem == "pp") {
404       if (fAnalysisType == "ESD") {
405           UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
406           Bool_t isSelected = 0;
407           isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
408           if(! isSelected){ PostData(1, fCFContCascadeCuts); return; }
409       } else if (fAnalysisType == "AOD") {
410           UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
411           Bool_t isSelected = 0;
412           isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
413           if(! isSelected){ PostData(1, fCFContCascadeCuts); return; }
414       }
415   }
416
417   //------------------------------
418   // Well-established PV selection
419   //------------------------------
420   Double_t lBestPrimaryVtxPos[3] = {-100.0, -100.0, -100.0}; 
421   Double_t lMagneticField        = -10.;
422   if (fAnalysisType == "ESD") {
423        const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();   
424        const AliESDVertex *lPrimaryBestESDVtx = lESDevent->GetPrimaryVertex();  
425        if (fkQualityCutNoTPConlyPrimVtx) {
426            const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
427            if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
428                AliWarning(" No SPD prim. vertex nor prim. Tracking vertex ... return !");
429                PostData(1, fCFContCascadeCuts);
430                return;
431            }
432        }
433        lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
434        lMagneticField = lESDevent->GetMagneticField( );
435   } else if (fAnalysisType == "AOD") {
436        const AliAODVertex *lPrimaryBestAODVtx = lAODevent->GetPrimaryVertex();
437        if (!lPrimaryBestAODVtx){
438            AliWarning("No prim. vertex in AOD... return!");
439            PostData(1, fCFContCascadeCuts);
440            return;
441        }
442        lPrimaryBestAODVtx->GetXYZ( lBestPrimaryVtxPos );
443        lMagneticField = lAODevent->GetMagneticField();  
444   }
445
446   //------------------------------------------
447   // Pilup selection for pp@2.76TeV collisions
448   //------------------------------------------
449   if (fCollidingSystem == "pp") { 
450       if (fAnalysisType == "ESD") {
451           if (fkQualityCutPileup) { if(lESDevent->IsPileupFromSPD()){ PostData(1, fCFContCascadeCuts); return; } }
452       } else if (fAnalysisType == "AOD") {
453           if (fkQualityCutPileup) { if(lAODevent->IsPileupFromSPD()){ PostData(1, fCFContCascadeCuts); return; } }
454       }
455   }
456
457   //----------------------------
458   // Vertex Z position selection
459   //----------------------------
460   if (fkQualityCutZprimVtxPos) {
461       if (TMath::Abs(lBestPrimaryVtxPos[2]) > fVtxRange ) {
462           PostData(1, fCFContCascadeCuts);
463           return;
464       }
465   }
466
467
468
469   //////////////////////////////
470   // CASCADE RECONSTRUCTION PART
471   //////////////////////////////
472
473   //%%%%%%%%%%%%%
474   // Cascade loop
475   Int_t ncascades = 0;
476   if      (fAnalysisType == "ESD") ncascades = lESDevent->GetNumberOfCascades();
477   else if (fAnalysisType == "AOD") ncascades = lAODevent->GetNumberOfCascades();
478
479   for (Int_t iXi = 0; iXi < ncascades; iXi++) {// This is the begining of the Cascade loop (ESD or AOD)
480            
481     // -------------------------------------
482     // - Initialisation of the local variables that will be needed for ESD/AOD
483     // -- Container variables (1st round)
484     Double_t lDcaXiDaughters              = -1. ;                   //[Container]
485     Double_t lXiCosineOfPointingAngle     = -1. ;                   //[Container]
486     Double_t lPosXi[3] = { -1000.0, -1000.0, -1000.0 };             //Useful to define other variables: radius fid. vol., ctau, etc. for cascade
487     Double_t lXiRadius                    = -1000. ;                //[Container]
488     UShort_t lPosTPCClusters              = -1;                     //To check the quality of the tracks. For ESD only ...
489     UShort_t lNegTPCClusters              = -1;                     //To check the quality of the tracks. For ESD only ...
490     UShort_t lBachTPCClusters             = -1;                     //To check the quality of the tracks. For ESD only ...
491     Double_t lInvMassLambdaAsCascDghter   = 0.;                     //[Container]
492     Double_t lDcaV0DaughtersXi            = -1.;                    //[Container]
493     Double_t lDcaBachToPrimVertexXi       = -1.;                    //[Container]
494     Double_t lDcaV0ToPrimVertexXi         = -1.;                    //[Container]
495     Double_t lDcaPosToPrimVertexXi        = -1.;                    //[Container]
496     Double_t lDcaNegToPrimVertexXi        = -1.;                    //[Container]
497     Double_t lV0CosineOfPointingAngle     = -1.;                    //[Container]
498     Double_t lV0toXiCosineOfPointingAngle = -1.;                    //[Container] 
499     Double_t lPosV0Xi[3] = { -1000. , -1000., -1000. };             //Useful to define other variables: radius fid. vol., ctau, etc. for VO 
500     Double_t lV0RadiusXi                  = -1000.0;                //[Container]
501     Double_t lV0quality                   = 0.;                     //  ??
502     Double_t lInvMassXiMinus              = 0.;                     //[Container]
503     Double_t lInvMassXiPlus               = 0.;                     //[Container]
504     Double_t lInvMassOmegaMinus           = 0.;                     //[Container]
505     Double_t lInvMassOmegaPlus            = 0.;                     //[Container]
506     // -- PID treatment
507     Bool_t   lIsBachelorKaonForTPC = kFALSE; 
508     Bool_t   lIsBachelorPionForTPC = kFALSE; 
509     Bool_t   lIsNegPionForTPC      = kFALSE; 
510     Bool_t   lIsPosPionForTPC      = kFALSE; 
511     Bool_t   lIsNegProtonForTPC    = kFALSE; 
512     Bool_t   lIsPosProtonForTPC    = kFALSE; 
513     // -- More container variables and quality checks
514     Double_t lXiMomX           = 0.;                               //Useful to define other variables: lXiTransvMom, lXiTotMom
515     Double_t lXiMomY           = 0.;                               //Useful to define other variables: lXiTransvMom, lXiTotMom
516     Double_t lXiMomZ           = 0.;                               //Useful to define other variables: lXiTransvMom, lXiTotMom
517     Double_t lXiTransvMom      = 0.;                               //[Container]
518     Double_t lXiTotMom         = 0.;                               //Useful to define other variables: cTau
519     Double_t lV0PMomX          = 0.;                               //Useful to define other variables: lV0TotMom, lpTrackTransvMom
520     Double_t lV0PMomY          = 0.;                               //Useful to define other variables: lV0TotMom, lpTrackTransvMom
521     Double_t lV0PMomZ          = 0.;                               //Useful to define other variables: lV0TotMom, lpTrackTransvMom
522     Double_t lV0NMomX          = 0.;                               //Useful to define other variables: lV0TotMom, lnTrackTransvMom
523     Double_t lV0NMomY          = 0.;                               //Useful to define other variables: lV0TotMom, lnTrackTransvMom
524     Double_t lV0NMomZ          = 0.;                               //Useful to define other variables: lV0TotMom, lnTrackTransvMom
525     Double_t lV0TotMom         = 0.;                               //Useful to define other variables: lctauV0
526     Double_t lBachMomX         = 0.;                               //Useful to define other variables: lBachTransvMom
527     Double_t lBachMomY         = 0.;                               //Useful to define other variables: lBachTransvMom
528     Double_t lBachMomZ         = 0.;                               //Useful to define other variables: lBachTransvMom
529     Double_t lBachTransvMom    = 0.;                               //Selection on the min bachelor pT
530     Double_t lpTrackTransvMom  = 0.;                               //Selection on the min bachelor pT
531     Double_t lnTrackTransvMom  = 0.;                               //Selection on the min bachelor pT
532     Short_t  lChargeXi         = -2;                               //Useful to select the particles based on the charge
533     Double_t lRapXi            = -20.0;                            //[Container]
534     Double_t lRapOmega         = -20.0;                            //[Container]
535     Float_t  etaBach           = 0.;                               //Selection on the eta range
536     Float_t  etaPos            = 0.;                               //Selection on the eta range
537     Float_t  etaNeg            = 0.;                               //Selection on the eta range
538     // --  variables for the AliCFContainer dedicated to cascade cut optmisiation: ESD and AOD 
539     if (fAnalysisType == "ESD") { 
540   
541           // -------------------------------------
542           // - Load the cascades from the handler 
543           AliESDcascade *xi = lESDevent->GetCascade(iXi);
544           if (!xi) continue;
545         
546           // ---------------------------------------------------------------------------
547           // - Assigning the necessary variables for specific AliESDcascade data members        
548           lV0quality = 0.;
549           xi->ChangeMassHypothesis(lV0quality , 3312); // default working hypothesis : cascade = Xi- decay
550           lDcaXiDaughters          = xi->GetDcaXiDaughters();
551           lXiCosineOfPointingAngle = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lBestPrimaryVtxPos[2] );
552                                        // Take care : the best available vertex should be used (like in AliCascadeVertexer)
553           xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
554           lXiRadius             = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );
555                 
556           // -------------------------------------------------------------------------------------------------------------------------------
557           // - Around the tracks : Bach + V0 (ESD). Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
558           UInt_t lIdxPosXi      = (UInt_t) TMath::Abs( xi->GetPindex() );
559           UInt_t lIdxNegXi      = (UInt_t) TMath::Abs( xi->GetNindex() );
560           UInt_t lBachIdx       = (UInt_t) TMath::Abs( xi->GetBindex() );
561                                     // Care track label can be negative in MC production (linked with the track quality)
562                                     // However = normally, not the case for track index ...
563           // - Rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
564           if (lBachIdx == lIdxNegXi) continue;    
565           if (lBachIdx == lIdxPosXi) continue; 
566           // - Get the track for the daughters
567           AliESDtrack *pTrackXi         = lESDevent->GetTrack( lIdxPosXi );
568           AliESDtrack *nTrackXi         = lESDevent->GetTrack( lIdxNegXi );
569           AliESDtrack *bachTrackXi      = lESDevent->GetTrack( lBachIdx );
570           if (!pTrackXi || !nTrackXi || !bachTrackXi )  continue;
571           // - Get the TPCnumber of cluster for the daughters
572           lPosTPCClusters   = pTrackXi->GetTPCNcls();
573           lNegTPCClusters   = nTrackXi->GetTPCNcls();
574           lBachTPCClusters  = bachTrackXi->GetTPCNcls();
575       
576           // ------------------------------------
577           // - Rejection of a poor quality tracks
578           if (fkQualityCutTPCrefit) {
579                 // 1 - Poor quality related to TPCrefit
580                 ULong_t pStatus    = pTrackXi->GetStatus();
581                 ULong_t nStatus    = nTrackXi->GetStatus();
582                 ULong_t bachStatus = bachTrackXi->GetStatus();
583                 if ((pStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning(" V0 Pos. track has no TPCrefit ... continue!"); continue; }
584                 if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning(" V0 Neg. track has no TPCrefit ... continue!"); continue; }
585                 if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning(" Bach.   track has no TPCrefit ... continue!"); continue; }
586           }
587           if (fkQualityCutnTPCcls) {
588                 // 2 - Poor quality related to TPC clusters
589                 if (lPosTPCClusters  < fMinnTPCcls) { AliWarning(" V0 Pos. track has less than minn TPC clusters ... continue!"); continue; }
590                 if (lNegTPCClusters  < fMinnTPCcls) { AliWarning(" V0 Neg. track has less than minn TPC clusters ... continue!"); continue; }
591                 if (lBachTPCClusters < fMinnTPCcls) { AliWarning(" Bach.   track has less than minn TPC clusters ... continue!"); continue; }
592           }
593
594           // ------------------------------
595           etaPos  = pTrackXi->Eta();             
596           etaNeg  = nTrackXi->Eta();
597           etaBach = bachTrackXi->Eta();
598           lInvMassLambdaAsCascDghter = xi->GetEffMass();
599           lDcaV0DaughtersXi          = xi->GetDcaV0Daughters(); 
600           lV0CosineOfPointingAngle   = xi->GetV0CosineOfPointingAngle( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lBestPrimaryVtxPos[2] );
601           lDcaV0ToPrimVertexXi       = xi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lBestPrimaryVtxPos[2] ); 
602           lDcaBachToPrimVertexXi     = TMath::Abs( bachTrackXi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1],     lMagneticField) ); 
603           xi->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] ); 
604           lV0RadiusXi                = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0] + lPosV0Xi[1]*lPosV0Xi[1] );
605           lDcaPosToPrimVertexXi      = TMath::Abs( pTrackXi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lMagneticField ) ); 
606           lDcaNegToPrimVertexXi      = TMath::Abs( nTrackXi->GetD( lBestPrimaryVtxPos[0], lBestPrimaryVtxPos[1], lMagneticField ) ); 
607         
608            //----------------------------------------------------------------------------------------------------       
609            // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega -/+
610            if (bachTrackXi->Charge() < 0) {
611                 // Calculate the effective mass of the Xi- candidate. pdg code 3312 = Xi-
612                 lV0quality = 0.;
613                 xi->ChangeMassHypothesis(lV0quality , 3312);    
614                 lInvMassXiMinus = xi->GetEffMassXi();
615                 // Calculate the effective mass of the Xi- candidate. pdg code 3334 = Omega-
616                 lV0quality = 0.;
617                 xi->ChangeMassHypothesis(lV0quality , 3334);    
618                 lInvMassOmegaMinus = xi->GetEffMassXi();
619                 // Back to default hyp.                 
620                 lV0quality = 0.;
621                 xi->ChangeMassHypothesis(lV0quality , 3312);
622            }// end if negative bachelor
623            if ( bachTrackXi->Charge() >  0 ) {
624                 // Calculate the effective mass of the Xi+ candidate. pdg code -3312 = Xi+
625                 lV0quality = 0.;
626                 xi->ChangeMassHypothesis(lV0quality , -3312);   
627                 lInvMassXiPlus = xi->GetEffMassXi();
628                 // Calculate the effective mass of the Xi+ candidate. pdg code -3334  = Omega+
629                 lV0quality = 0.;
630                 xi->ChangeMassHypothesis(lV0quality , -3334);   
631                 lInvMassOmegaPlus = xi->GetEffMassXi();
632                 // Back to "default" hyp.
633                 lV0quality = 0.;
634                 xi->ChangeMassHypothesis(lV0quality , -3312); 
635            }// end if positive bachelor
636
637            // ----------------------------------------------    
638            // - TPC PID : 3-sigma bands on Bethe-Bloch curve
639            // Bachelor
640            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 4) lIsBachelorKaonForTPC = kTRUE;
641            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 4) lIsBachelorPionForTPC = kTRUE;
642            // Negative V0 daughter
643            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kPion   )) < 4) lIsNegPionForTPC   = kTRUE;
644            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kProton )) < 4) lIsNegProtonForTPC = kTRUE;
645            // Positive V0 daughter
646            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kPion   )) < 4) lIsPosPionForTPC   = kTRUE;
647            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 4) lIsPosProtonForTPC = kTRUE;
648         
649            // ------------------------------
650            // - Miscellaneous pieces of info that may help regarding data quality assessment.
651            xi->GetPxPyPz( lXiMomX, lXiMomY, lXiMomZ );
652            lXiTransvMom = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY );
653            lXiTotMom    = TMath::Sqrt( lXiMomX*lXiMomX + lXiMomY*lXiMomY + lXiMomZ*lXiMomZ );
654            xi->GetNPxPyPz(lV0NMomX,lV0NMomY,lV0NMomZ);
655            xi->GetPPxPyPz(lV0PMomX,lV0PMomY,lV0PMomZ);
656            lV0TotMom = TMath::Sqrt(TMath::Power(lV0NMomX+lV0PMomX,2)+TMath::Power(lV0NMomY+lV0PMomY,2)+TMath::Power(lV0NMomZ+lV0PMomZ,2));      
657            xi->GetBPxPyPz( lBachMomX, lBachMomY, lBachMomZ );
658            lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY );
659            lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX + lV0NMomY*lV0NMomY );
660            lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX + lV0PMomY*lV0PMomY );
661            lChargeXi = xi->Charge();
662            lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
663            lRapXi    = xi->RapXi();
664            lRapOmega = xi->RapOmega();
665         
666     } else if (fAnalysisType == "AOD") {
667
668            // -------------------------------------
669            // - Load the cascades from the handler      
670            const AliAODcascade *xi = lAODevent->GetCascade(iXi);
671            if (!xi) continue;
672                 
673            //----------------------------------------------------------------------------        
674            // - Assigning the necessary variables for specific AliESDcascade data members  
675            lDcaXiDaughters              = xi->DcaXiDaughters();
676            lXiCosineOfPointingAngle     = xi->CosPointingAngleXi( lBestPrimaryVtxPos[0], 
677                                                           lBestPrimaryVtxPos[1], 
678                                                           lBestPrimaryVtxPos[2] );
679            lPosXi[0] = xi->DecayVertexXiX();
680            lPosXi[1] = xi->DecayVertexXiY();
681            lPosXi[2] = xi->DecayVertexXiZ();
682            lXiRadius = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );      
683
684            //-------------------------------------------------------------------------------------------------------------------------------
685            // - Around the tracks: Bach + V0 (ESD). Necessary variables for ESDcascade data members coming from the ESDv0 part (inheritance)
686            AliAODTrack *pTrackXi    = dynamic_cast<AliAODTrack*>( xi->GetDaughter(0) );
687            AliAODTrack *nTrackXi    = dynamic_cast<AliAODTrack*>( xi->GetDaughter(1) );
688            AliAODTrack *bachTrackXi = dynamic_cast<AliAODTrack*>( xi->GetDecayVertexXi()->GetDaughter(0) );
689            if (!pTrackXi || !nTrackXi || !bachTrackXi ) continue;
690            UInt_t lIdxPosXi  = (UInt_t) TMath::Abs( pTrackXi->GetID() );  
691            UInt_t lIdxNegXi  = (UInt_t) TMath::Abs( nTrackXi->GetID() );
692            UInt_t lBachIdx   = (UInt_t) TMath::Abs( bachTrackXi->GetID() );
693                                 // Care track label can be negative in MC production (linked with the track quality)
694                                 // However = normally, not the case for track index ...
695
696            // - Rejection of a double use of a daughter track (nothing but just a crosscheck of what is done in the cascade vertexer)
697            if (lBachIdx == lIdxNegXi) continue; 
698            if (lBachIdx == lIdxPosXi) continue;
699            // - Get the TPCnumber of cluster for the daughters
700            lPosTPCClusters   = pTrackXi->GetTPCNcls(); // FIXME: Is this ok? or something like in LambdaK0PbPb task AOD?
701            lNegTPCClusters   = nTrackXi->GetTPCNcls();
702            lBachTPCClusters  = bachTrackXi->GetTPCNcls();
703
704            // ------------------------------------
705            // - Rejection of a poor quality tracks
706            if (fkQualityCutTPCrefit) {
707                 // - Poor quality related to TPCrefit
708                 if (!(pTrackXi->IsOn(AliAODTrack::kTPCrefit)))    { AliWarning(" V0 Pos. track has no TPCrefit ... continue!"); continue; }
709                 if (!(nTrackXi->IsOn(AliAODTrack::kTPCrefit)))    { AliWarning(" V0 Neg. track has no TPCrefit ... continue!"); continue; }
710                 if (!(bachTrackXi->IsOn(AliAODTrack::kTPCrefit))) { AliWarning(" Bach.   track has no TPCrefit ... continue!"); continue; }
711            }
712            if (fkQualityCutnTPCcls) {
713                 // - Poor quality related to TPC clusters
714                 if (lPosTPCClusters  < fMinnTPCcls) continue; 
715                 if (lNegTPCClusters  < fMinnTPCcls) continue; 
716                 if (lBachTPCClusters < fMinnTPCcls) continue; 
717            }
718   
719            // ------------------------------------------------------------------------------------------------------------------------------
720            // - Around the tracks: Bach + V0 (AOD). Necessary variables for AODcascade data members coming from the AODv0 part (inheritance)
721            etaPos  = pTrackXi->Eta();
722            etaNeg  = nTrackXi->Eta();
723            etaBach = bachTrackXi->Eta();
724            lChargeXi                    = xi->ChargeXi();
725            if ( lChargeXi < 0)  lInvMassLambdaAsCascDghter      = xi->MassLambda();
726            else                 lInvMassLambdaAsCascDghter      = xi->MassAntiLambda();
727            lDcaV0DaughtersXi            = xi->DcaV0Daughters(); 
728            lDcaV0ToPrimVertexXi                 = xi->DcaV0ToPrimVertex();
729            lDcaBachToPrimVertexXi               = xi->DcaBachToPrimVertex(); 
730            lPosV0Xi[0] = xi->DecayVertexV0X();
731            lPosV0Xi[1] = xi->DecayVertexV0Y();
732            lPosV0Xi[2] = xi->DecayVertexV0Z(); 
733            lV0RadiusXi  = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0]  +  lPosV0Xi[1]*lPosV0Xi[1] );
734            lV0CosineOfPointingAngle     = xi->CosPointingAngle( lBestPrimaryVtxPos ); 
735            lDcaPosToPrimVertexXi        = xi->DcaPosToPrimVertex(); 
736            lDcaNegToPrimVertexXi        = xi->DcaNegToPrimVertex(); 
737
738            // ---------------------------------------------------------------------------------------------------       
739            // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega -/+
740            if ( lChargeXi < 0 )         lInvMassXiMinus         = xi->MassXi();
741            if ( lChargeXi > 0 )         lInvMassXiPlus          = xi->MassXi();
742            if ( lChargeXi < 0 )         lInvMassOmegaMinus      = xi->MassOmega();
743            if ( lChargeXi > 0 )         lInvMassOmegaPlus       = xi->MassOmega();
744
745            // ----------------------------------------------
746            // - TPC PID : 3-sigma bands on Bethe-Bloch curve
747            // Bachelor
748            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 4) lIsBachelorKaonForTPC = kTRUE;
749            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 4) lIsBachelorPionForTPC = kTRUE;
750            // Negative V0 daughter
751            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kPion   )) < 4) lIsNegPionForTPC   = kTRUE;
752            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( nTrackXi,AliPID::kProton )) < 4) lIsNegProtonForTPC = kTRUE;
753            // Positive V0 daughter
754            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kPion   )) < 4) lIsPosPionForTPC   = kTRUE;
755            if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC( pTrackXi,AliPID::kProton )) < 4) lIsPosProtonForTPC = kTRUE;
756
757            //---------------------------------
758            // - Extra info for QA (AOD)
759            // Miscellaneous pieces of info that may help regarding data quality assessment.
760            // Cascade transverse and total momentum     
761            lXiMomX = xi->MomXiX();
762            lXiMomY = xi->MomXiY();
763            lXiMomZ = xi->MomXiZ();
764            lXiTransvMom         = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY );
765            lXiTotMom    = TMath::Sqrt( lXiMomX*lXiMomX   + lXiMomY*lXiMomY   + lXiMomZ*lXiMomZ );
766            Double_t lV0MomX = xi->MomV0X();
767            Double_t lV0MomY = xi->MomV0Y();
768            Double_t lV0MomZ = xi->MomV0Z();
769            lV0TotMom = TMath::Sqrt(TMath::Power(lV0MomX,2)+TMath::Power(lV0MomY,2)+TMath::Power(lV0MomZ,2));
770            lBachMomX = xi->MomBachX();
771            lBachMomY = xi->MomBachY();
772            lBachMomZ = xi->MomBachZ();          
773            lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX   + lBachMomY*lBachMomY );
774            lV0NMomX = xi->MomNegX();
775            lV0NMomY = xi->MomNegY();
776            lV0PMomX = xi->MomPosX();
777            lV0PMomY = xi->MomPosY(); 
778            lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX   + lV0NMomY*lV0NMomY );
779            lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX   + lV0PMomY*lV0PMomY );
780            lV0toXiCosineOfPointingAngle = xi->CosPointingAngle( xi->GetDecayVertexXi() );
781            lRapXi    = xi->RapXi();
782            lRapOmega = xi->RapOmega();
783
784     }// end of AOD treatment
785
786     //---------------------------------------
787     // Cut on pt of the three daughter tracks
788     if (lBachTransvMom<fMinPtCutOnDaughterTracks) continue;
789     if (lpTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
790     if (lnTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
791  
792     //---------------------------------------------------
793     // Cut on pseudorapidity of the three daughter tracks
794     if (TMath::Abs(etaBach)>fEtaCutOnDaughterTracks) continue;
795     if (TMath::Abs(etaPos)>fEtaCutOnDaughterTracks) continue;
796     if (TMath::Abs(etaNeg)>fEtaCutOnDaughterTracks) continue;
797
798     //----------------------------------
799     // Calculate proper time for cascade
800     Double_t cascadeMass = 0.;
801     if ( ( (lChargeXi<0) && lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC ) ||
802          ( (lChargeXi>0) && lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC )  ) cascadeMass = 1.321;
803     if ( ( (lChargeXi<0) && lIsBachelorKaonForTPC   && lIsPosProtonForTPC    && lIsNegPionForTPC ) ||
804          ( (lChargeXi>0) && lIsBachelorKaonForTPC   && lIsNegProtonForTPC    && lIsPosPionForTPC )  ) cascadeMass = 1.672; 
805     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));
806     if (lXiTotMom!=0)         lctau = lctau*cascadeMass/lXiTotMom;
807     else lctau = -1.;
808     // Calculate proper time for Lambda (reconstructed)
809     Float_t lambdaMass = 1.115683; // PDG mass
810     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));
811     Float_t lctauV0 = -1.;
812     if (lV0TotMom!=0) lctauV0 = distV0Xi*lambdaMass/lV0TotMom;
813
814                 
815     // Fill the AliCFContainer (optimisation of topological selections)
816     Double_t lContainerCutVars[21] = {0.0};
817     lContainerCutVars[0]  = lDcaXiDaughters;
818     lContainerCutVars[1]  = lDcaBachToPrimVertexXi;
819     lContainerCutVars[2]  = lXiCosineOfPointingAngle;
820     lContainerCutVars[3]  = lXiRadius;
821     lContainerCutVars[4]  = lInvMassLambdaAsCascDghter;
822     lContainerCutVars[5]  = lDcaV0DaughtersXi;
823     lContainerCutVars[6]  = lV0CosineOfPointingAngle;
824     lContainerCutVars[7]  = lV0RadiusXi;
825     lContainerCutVars[8]  = lDcaV0ToPrimVertexXi;
826     lContainerCutVars[9]  = lDcaPosToPrimVertexXi;
827     lContainerCutVars[10] = lDcaNegToPrimVertexXi;
828     lContainerCutVars[13] = lXiTransvMom;
829     lContainerCutVars[16] = lctau;
830     lContainerCutVars[17] = lctauV0;
831     lContainerCutVars[18] = lV0toXiCosineOfPointingAngle;
832     lContainerCutVars[19] = lcentrality;
833     lContainerCutVars[20] = lPrimaryTrackMultiplicity;
834     if ( lChargeXi < 0 ) {
835          lContainerCutVars[11] = lInvMassXiMinus;
836          lContainerCutVars[12] = lInvMassOmegaMinus;
837          lContainerCutVars[14] = lRapXi;
838          lContainerCutVars[15] = -1.;
839          if (lIsBachelorPionForTPC && lIsPosProtonForTPC && lIsNegPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,0); // for Xi-
840          lContainerCutVars[11] = lInvMassXiMinus;
841          lContainerCutVars[12] = lInvMassOmegaMinus;
842          lContainerCutVars[14] = -1.;
843          lContainerCutVars[15] = lRapOmega;
844          if (lIsBachelorKaonForTPC && lIsPosProtonForTPC && lIsNegPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,2); // for Omega-
845     } else {
846          lContainerCutVars[11] = lInvMassXiPlus;
847          lContainerCutVars[12] = lInvMassOmegaPlus;
848          lContainerCutVars[14] = lRapXi;
849          lContainerCutVars[15] = -1.;
850          if (lIsBachelorPionForTPC && lIsNegProtonForTPC && lIsPosPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,1); // for Xi+
851          lContainerCutVars[11] = lInvMassXiPlus;
852          lContainerCutVars[12] = lInvMassOmegaPlus;
853          lContainerCutVars[14] = -1.;
854          lContainerCutVars[15] = lRapOmega;
855          if (lIsBachelorKaonForTPC && lIsNegProtonForTPC && lIsPosPionForTPC) fCFContCascadeCuts->Fill(lContainerCutVars,3); // for Omega+ 
856     }
857
858
859   }// end of the Cascade loop (ESD or AOD)
860     
861   
862   // Post output data.
863   PostData(1, fCFContCascadeCuts); 
864 }
865
866 //________________________________________________________________________
867 void AliAnalysisTaskQAMultistrange::Terminate(Option_t *) 
868 {
869
870 }
871