]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/STRANGENESS/Cascades/AliAnalysisTaskCheckCascadepp276.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Cascades / AliAnalysisTaskCheckCascadepp276.cxx
index 799189a0740178059debe7b016140b6df965885b..f65912302586ccb2531ac937a144471fcccc8fb0 100644 (file)
 //                - AOD analysis part completed 
 //
 //
-//              Adapted to pp 2.76 analysis: D. Colella, domenico.colella@ba.infn.it
+//              Adapted to pp 2.76 TeV analysis: D. Colella, domenico.colella@ba.infn.it
 //               Gen-now 2012
 //                - Physics selection re-moved here (mainly for normalization in the efficiency calcuation)
 //                - Centrality selection deleted
-//                - 
+//
+//
+//             Adapted to pPb 5.02 TeV analysis: D. Colella, domenico.colella@ba.infn.it
+//               Aug-Sep 2014
+//               - Added the parameter fCollidingSystem, to distingish between pp and pPb procedures
+//
+//
 //
 //-----------------------------------------------------------------
 
@@ -92,6 +98,7 @@ class AliAODv0;
 #include "AliESDcascade.h"
 #include "AliAODcascade.h"
 #include "AliAODTrack.h"
+#include "AliAnalysisUtils.h"
 
 #include "AliAnalysisTaskCheckCascadepp276.h"
 
@@ -108,6 +115,8 @@ AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276()
   : AliAnalysisTaskSE(), 
     fAnalysisType               ("ESD"),
     fESDtrackCuts               (0),
+    fUtils                      (0),
+    fCollidingSystem            ("pp"),
     fPIDResponse                (0),
     fkRerunV0CascVertexers      (0),
     fkSDDSelectionOn            (kTRUE),
@@ -130,16 +139,16 @@ AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276()
       fHistCascadeMultiplicityBeforeAnySel(0),
       fHistCascadeMultiplicityAfterSDDSel(0),
       fHistCascadeMultiplicityAfterPhysicsSel(0),
-      fHistCascadeMultiplicityAfterVertexCutSel(0),
       fHistCascadeMultiplicityForSelEvtNoTPCOnly(0),
       fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
+      fHistCascadeMultiplicityAfterVertexCutSel(0),
       // Tracks multiplicity plots
       fHistTrackMultiplicityBeforeAnySel(0),
       fHistTrackMultiplicityAfterSDDSel(0),
       fHistTrackMultiplicityAfterPhysicsSel(0),
-      fHistTrackMultiplicityAfterVertexCutSel(0),
       fHistTrackMultiplicityForSelEvtNoTPCOnly(0),
       fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
+      fHistTrackMultiplicityAfterVertexCutSel(0),
       // Vertex position plots (BestVertex)
       fHistPVx(0), fHistPVy(0), fHistPVz(0),
       fHistPVxAnalysis(0), fHistPVyAnalysis(0), fHistPVzAnalysis(0),    
@@ -202,6 +211,8 @@ AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276(const char *n
   : AliAnalysisTaskSE(name), 
     fAnalysisType               ("ESD"), 
     fESDtrackCuts               (0), 
+    fUtils                      (0),
+    fCollidingSystem            ("pp"),
     fPIDResponse                (0),
     fkRerunV0CascVertexers      (0),
     fkSDDSelectionOn            (kTRUE),
@@ -225,16 +236,16 @@ AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276(const char *n
       fHistCascadeMultiplicityBeforeAnySel(0),
       fHistCascadeMultiplicityAfterSDDSel(0),
       fHistCascadeMultiplicityAfterPhysicsSel(0),
-      fHistCascadeMultiplicityAfterVertexCutSel(0),
       fHistCascadeMultiplicityForSelEvtNoTPCOnly(0),
       fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
+      fHistCascadeMultiplicityAfterVertexCutSel(0),
       // Tracks multiplicity plots
       fHistTrackMultiplicityBeforeAnySel(0),
       fHistTrackMultiplicityAfterSDDSel(0),
       fHistTrackMultiplicityAfterPhysicsSel(0),
-      fHistTrackMultiplicityAfterVertexCutSel(0),
       fHistTrackMultiplicityForSelEvtNoTPCOnly(0),
       fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup(0),
+      fHistTrackMultiplicityAfterVertexCutSel(0),
       // Vertex position plots (BestVertex)
       fHistPVx(0), fHistPVy(0), fHistPVz(0),
       fHistPVxAnalysis(0), fHistPVyAnalysis(0), fHistPVzAnalysis(0),
@@ -289,24 +300,39 @@ AliAnalysisTaskCheckCascadepp276::AliAnalysisTaskCheckCascadepp276(const char *n
      // Input slot #0 works with a TChain
      // DefineInput(0, TChain::Class());
      // Output slot #1 writes into a TList container (cascade)
-        // default p-p values
-        fV0Sels[0] =  33.  ;     // max allowed chi2
-        fV0Sels[1] =   0.073;    // min allowed impact parameter for the 1st daughter 
-        fV0Sels[2] =   0.073;    // min allowed impact parameter for the 2nd daughter 
-        fV0Sels[3] =   1.18;     // max allowed DCA between the daughter tracks       
-        fV0Sels[4] =    .983;    // min allowed cosine of V0's pointing angle         
-        fV0Sels[5] =   2.67;     // min radius of the fiducial volume                 
-        fV0Sels[6] = 100.;       // max radius of the fiducial volume                 
-
-        fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
-        fCascSels[1] =   0.03;   // min allowed V0 impact parameter                    
-        fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
-        fCascSels[3] =   0.0204; // min allowed bachelor's impact parameter          
-        fCascSels[4] =   1.68;   // max allowed DCA between the V0 and the bachelor    
-        fCascSels[5] =   0.9826; // min allowed cosine of the cascade pointing angle   
-        fCascSels[6] =   0.38;   // min radius of the fiducial volume                  
-        fCascSels[7] = 100.;     // max radius of the fiducial volume                  
-
+     if (fCollidingSystem == "pp") {
+         fV0Sels[0] =  33.  ;     // max allowed chi2
+         fV0Sels[1] =   0.01;     // min allowed impact parameter for the 1st daughter 
+         fV0Sels[2] =   0.01;     // min allowed impact parameter for the 2nd daughter 
+         fV0Sels[3] =   1.5;      // max allowed DCA between the daughter tracks       
+         fV0Sels[4] =   0.9;      // min allowed cosine of V0's pointing angle - This is pT dependent        
+         fV0Sels[5] =   0.2;      // min radius of the fiducial volume                 
+         fV0Sels[6] = 200.;       // max radius of the fiducial volume                 
+         fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
+         fCascSels[1] =   0.01;   // min allowed V0 impact parameter                    
+         fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
+         fCascSels[3] =   0.01;   // min allowed bachelor's impact parameter          
+         fCascSels[4] =   2.0;    // max allowed DCA between the V0 and the bachelor    
+         fCascSels[5] =   0.95;   // min allowed cosine of the cascade pointing angle   
+         fCascSels[6] =   0.2;    // min radius of the fiducial volume                  
+         fCascSels[7] = 100.;     // max radius of the fiducial volume 
+     } else if (fCollidingSystem == "pPb") {
+         fV0Sels[0] =  33.  ;     // max allowed chi2
+         fV0Sels[1] =   0.02;     // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
+         fV0Sels[2] =   0.02;     // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
+         fV0Sels[3] =   2.0 ;     // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
+         fV0Sels[4] =   0.95;     // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
+         fV0Sels[5] =   1.0 ;     // min radius of the fiducial volume                 (LHC09a4 : 0.2)
+         fV0Sels[6] = 200.  ;     // max radius of the fiducial volume                 (LHC09a4 : 100.0)
+         fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
+         fCascSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
+         fCascSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
+         fCascSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
+         fCascSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
+         fCascSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
+         fCascSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
+         fCascSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
+     }
      // Output slot #0 writes into a TList container (Cascade)
      DefineOutput(1, TList::Class());
      DefineOutput(2, AliCFContainer::Class());
@@ -348,7 +374,6 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
  fPIDResponse = inputHandler->GetPIDResponse();
-
  // Only used to get the number of primary reconstructed tracks
  if (fAnalysisType == "ESD" && (! fESDtrackCuts )){
    fESDtrackCuts = new AliESDtrackCuts();
@@ -358,22 +383,39 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
  // Initialize cuts to re-run V0 and cascade vertexers
  //---------------------------------------------------
  // Not validated; to be checked
- fV0Sels[0] =  33.  ;     // max allowed chi2
- fV0Sels[1] =   0.073;    // min allowed impact parameter for the 1st daughter 
- fV0Sels[2] =   0.073;    // min allowed impact parameter for the 2nd daughter 
- fV0Sels[3] =   1.18;     // max allowed DCA between the daughter tracks       
- fV0Sels[4] =    .983;    // min allowed cosine of V0's pointing angle         
- fV0Sels[5] =   2.67;     // min radius of the fiducial volume                 
- fV0Sels[6] = 100.;       // max radius of the fiducial volume                 
-
- fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
- fCascSels[1] =   0.03;   // min allowed V0 impact parameter                    
- fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
- fCascSels[3] =   0.0204; // min allowed bachelor's impact parameter           //check cuts 
- fCascSels[4] =   1.68;   // max allowed DCA between the V0 and the bachelor    
- fCascSels[5] =   0.9826; // min allowed cosine of the cascade pointing angle   
- fCascSels[6] =   0.38;   // min radius of the fiducial volume                  
- fCascSels[7] = 100.;     // max radius of the fiducial volume 
+ if (fCollidingSystem == "pp") {
+      fV0Sels[0] =  33.  ;     // max allowed chi2
+      fV0Sels[1] =   0.01;     // min allowed impact parameter for the 1st daughter 
+      fV0Sels[2] =   0.01;     // min allowed impact parameter for the 2nd daughter 
+      fV0Sels[3] =   1.5;      // max allowed DCA between the daughter tracks       
+      fV0Sels[4] =   0.9;      // min allowed cosine of V0's pointing angle         
+      fV0Sels[5] =   0.2;      // min radius of the fiducial volume                 
+      fV0Sels[6] = 200.;       // max radius of the fiducial volume                 
+      fCascSels[0] =  33.;     // max allowed chi2 (same as PDC07)
+      fCascSels[1] =   0.01;   // min allowed V0 impact parameter                    
+      fCascSels[2] =   0.008;  // "window" around the Lambda mass                    
+      fCascSels[3] =   0.01;   // min allowed bachelor's impact parameter          
+      fCascSels[4] =   2.0;    // max allowed DCA between the V0 and the bachelor    
+      fCascSels[5] =   0.95;   // min allowed cosine of the cascade pointing angle   
+      fCascSels[6] =   0.2;    // min radius of the fiducial volume                  
+      fCascSels[7] = 100.;     // max radius of the fiducial volume 
+ } else if (fCollidingSystem == "pPb") {
+      fV0Sels[0] =  33.  ;     // max allowed chi2
+      fV0Sels[1] =   0.02;     // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
+      fV0Sels[2] =   0.02;     // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
+      fV0Sels[3] =   2.0 ;     // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
+      fV0Sels[4] =   0.95;     // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
+      fV0Sels[5] =   1.0 ;     // min radius of the fiducial volume                 (LHC09a4 : 0.2)
+      fV0Sels[6] = 200.  ;     // max radius of the fiducial volume                 (LHC09a4 : 100.0)
+      fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
+      fCascSels[1] =   0.05 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
+      fCascSels[2] =   0.010;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
+      fCascSels[3] =   0.03 ;  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
+      fCascSels[4] =   2.0  ;  // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
+      fCascSels[5] =   0.95 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
+      fCascSels[6] =   0.4  ;  // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
+      fCascSels[7] = 100.   ;  // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
+ }
 
  //----------------------
  // Initialize the histos
@@ -383,76 +425,76 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
  if(! fHistCascadeMultiplicityBeforeAnySel) {
         fHistCascadeMultiplicityBeforeAnySel = new TH1F("fHistCascadeMultiplicityBeforeAnySel",
                         "Cascades per event (before any selections);Nbr of Cascades/Evt;Events",                
-                        50, 0, 50);
+                        20, 0, 20);
         fListHistCascade->Add(fHistCascadeMultiplicityBeforeAnySel);
  }
  if(! fHistCascadeMultiplicityAfterSDDSel) {
         fHistCascadeMultiplicityAfterSDDSel = new TH1F("fHistCascadeMultiplicityAfterSDDSel", 
                        "Cascades per event (after the SDD selection);Nbr of Cascades/Evt;Events", 
-                       50, 0, 50);             
+                       20, 0, 20);             
        fListHistCascade->Add(fHistCascadeMultiplicityAfterSDDSel);
  }
  if(! fHistCascadeMultiplicityAfterPhysicsSel) {
         fHistCascadeMultiplicityAfterPhysicsSel = new TH1F("fHistCascadeMultiplicityAfterPhysicsSel",
                         "Cascades per event (after physics selection);Nbr of Cascades/Evt;Events",
-                        50, 0, 50);
+                        20, 0, 20);
         fListHistCascade->Add(fHistCascadeMultiplicityAfterPhysicsSel);
  }
- if(! fHistCascadeMultiplicityAfterVertexCutSel) {
-        fHistCascadeMultiplicityAfterVertexCutSel = new TH1F("fHistCascadeMultiplicityAfterVertexCutSel",
-                        "Cascades per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
-                        50, 0, 50);
-        fListHistCascade->Add(fHistCascadeMultiplicityAfterVertexCutSel);
- }
  if(! fHistCascadeMultiplicityForSelEvtNoTPCOnly) {
         fHistCascadeMultiplicityForSelEvtNoTPCOnly = new TH1F("fHistCascadeMultiplicityForSelEvtNoTPCOnly",
                         "Cascades per event (for selected events with well-established PV);Nbr of Cascades/Evt;Events",
-                        50, 0, 50);
+                        20, 0, 20);
         fListHistCascade->Add(fHistCascadeMultiplicityForSelEvtNoTPCOnly);
  }
  if(! fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup) {
         fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup",
                         "Cascades per event (for selected events with well-establisched PV and no pile-up);Nbr of Cascades/Evt;Events",
-                        50, 0, 50);
+                        20, 0, 20);
         fListHistCascade->Add(fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup);
  }
+ if(! fHistCascadeMultiplicityAfterVertexCutSel) {
+        fHistCascadeMultiplicityAfterVertexCutSel = new TH1F("fHistCascadeMultiplicityAfterVertexCutSel",
+                                                             "Cascades per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
+                                                             20, 0, 20);
+        fListHistCascade->Add(fHistCascadeMultiplicityAfterVertexCutSel);
+ }
  // - Tracks multiplicity plots 
  if(! fHistTrackMultiplicityBeforeAnySel) {
        fHistTrackMultiplicityBeforeAnySel = new TH1F("fHistTrackMultiplicityBeforeAnySel", 
                        "Tracks per event (before any selections);Nbr of Cascades/Evt;Events", 
-                       200, 0, 200);           
+                       100, 0, 100);           
        fListHistCascade->Add(fHistTrackMultiplicityBeforeAnySel);
  } 
  if(! fHistTrackMultiplicityAfterSDDSel) {
         fHistTrackMultiplicityAfterSDDSel = new TH1F("fHistTrackMultiplicityAfterSDDSel",                  
                         "Tracks per event (after the SDD selection);Nbr of Cascades/Evt;Events",
-                        200, 0, 200);
+                        100, 0, 100);
         fListHistCascade->Add(fHistTrackMultiplicityAfterSDDSel);
  }
  if(! fHistTrackMultiplicityAfterPhysicsSel) {
         fHistTrackMultiplicityAfterPhysicsSel = new TH1F("fHistTrackMultiplicityAfterPhysicsSel",
                         "Tracks per event (after physics selection);Nbr of Cascades/Evt;Events",
-                        200, 0, 200);
+                        100, 0, 100);
         fListHistCascade->Add(fHistTrackMultiplicityAfterPhysicsSel);
  }
- if(! fHistTrackMultiplicityAfterVertexCutSel) {
-        fHistTrackMultiplicityAfterVertexCutSel = new TH1F("fHistTrackMultiplicityAfterVertexCutSel",
-                        "Tracks per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
-                        200, 0, 200);
-        fListHistCascade->Add(fHistTrackMultiplicityAfterVertexCutSel);
- }
  if(! fHistTrackMultiplicityForSelEvtNoTPCOnly) {
         fHistTrackMultiplicityForSelEvtNoTPCOnly = new TH1F("fHistTrackMultiplicityForSelEvtNoTPCOnly",
                         "Tracks per event (for selected events with well-established PV);Nbr of Cascades/Evt;Events",
-                        200, 0, 200);
+                        100, 0, 100);
         fListHistCascade->Add(fHistTrackMultiplicityForSelEvtNoTPCOnly);
  }
  if(! fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup) {
         fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup",
                         "Tracks per event (for selected events with well-establisched PV and no pile-up);Nbr of Cascades/Evt;Events",
-                        200, 0, 200);
+                        100, 0, 100);
         fListHistCascade->Add(fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup);
  }
+ if(! fHistTrackMultiplicityAfterVertexCutSel) {
+        fHistTrackMultiplicityAfterVertexCutSel = new TH1F("fHistTrackMultiplicityAfterVertexCutSel",
+                                                           "Tracks per event (after vertex cut selection);Nbr of Cascades/Evt;Events",
+                                                           100, 0, 100);
+        fListHistCascade->Add(fHistTrackMultiplicityAfterVertexCutSel);
+ }
  // - Vertex position plots
  if(! fHistPVx ){
        fHistPVx = new TH1F("fHistPVx", "Best PV position in x; x (cm); Events", 2000, -0.5, 0.5);
@@ -505,11 +547,11 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
      fListHistCascade->Add(fHistDcaBachToPrimVertex);
  }
  if(! fHistXiCosineOfPointingAngle) {
-     fHistXiCosineOfPointingAngle = new TH1F("fHistXiCosineOfPointingAngle", "Cosine of Xi Pointing Angle; Cos (Xi Point.Angl); Counts", 301, 0.97, 1.0001);
+     fHistXiCosineOfPointingAngle = new TH1F("fHistXiCosineOfPointingAngle", "Cosine of Xi Pointing Angle; Cos (Xi Point.Angl); Counts", 601, 0.94, 1.0001);
      fListHistCascade->Add(fHistXiCosineOfPointingAngle);
  }
  if(! fHistXiRadius ){
-     fHistXiRadius = new TH1F("fHistXiRadius", "Cascade decay transv. radius; r (cm); Counts" , 1050, 0., 105.0);
+     fHistXiRadius = new TH1F("fHistXiRadius", "Cascade decay transv. radius; r (cm); Counts" , 2050, 0., 205.0);
      fListHistCascade->Add(fHistXiRadius);
  }
  if(! fHistMassLambdaAsCascDghter) {
@@ -529,7 +571,7 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
      fListHistCascade->Add(fHistV0CosineOfPointingAngleXi);
  }
  if(! fHistV0RadiusXi) {
-     fHistV0RadiusXi = new TH1F("fHistV0RadiusXi", "V0 decay radius, in cascade; radius (cm); Counts", 1050, 0., 105.0);
+     fHistV0RadiusXi = new TH1F("fHistV0RadiusXi", "V0 decay radius, in cascade; radius (cm); Counts", 2050, 0., 205.0);
      fListHistCascade->Add(fHistV0RadiusXi);
  }
  if(! fHistDcaPosToPrimVertexXi) {
@@ -691,7 +733,22 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    lNbBinsPerVar[0] = 100;
    lNbBinsPerVar[1] = 800;
    lNbBinsPerVar[2] = 22;
-   fCFContCascadePIDXiMinus = new AliCFContainer("fCFContCascadePIDXiMinus","Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
+        if (fwithSDD) fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
+                                                                    fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                    "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
+        else if (!fwithSDD) fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
+                                                                    fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                    "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar ); 
+   } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
+        fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
+                                                      fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                      "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   } else if (fCollidingSystem == "pPb") {
+        fCFContCascadePIDXiMinus = new AliCFContainer(Form("fCFContCascadePIDXiMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
+                                                      fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                      "Pt_{cascade} Vs M_{#Xi^{-} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   }
      //Setting the bin limits 
    fCFContCascadePIDXiMinus->SetBinLimits(0,   0.0  ,  10.0 ); // Pt(Cascade)
    fCFContCascadePIDXiMinus->SetBinLimits(1,   1.2  ,   2.0 ); // Xi Effective mass
@@ -719,7 +776,22 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    lNbBinsPerVar[0] = 100;
    lNbBinsPerVar[1] = 800;
    lNbBinsPerVar[2] = 22;
-   fCFContCascadePIDXiPlus = new AliCFContainer("fCFContCascadePIDXiPlus","Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
+        if (fwithSDD) fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
+                                                                   fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                   "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
+        else if (!fwithSDD) fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
+                                                                         fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                         "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
+   } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) { 
+        fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
+                                                     fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                     "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
+   } else if (fCollidingSystem == "pPb") {
+        fCFContCascadePIDXiPlus = new AliCFContainer(Form("fCFContCascadePIDXiPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
+                                                     fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                     "Pt_{cascade} Vs M_{#Xi^{+} candidates} Vs Y_{#Xi}", lNbSteps, lNbVariables, lNbBinsPerVar);
+   }
      //Setting the bin limits 
    fCFContCascadePIDXiPlus->SetBinLimits(0,   0.0  ,  10.0 );  // Pt(Cascade)
    fCFContCascadePIDXiPlus->SetBinLimits(1,   1.2  ,   2.0 );  // Xi Effective mass
@@ -747,7 +819,22 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    lNbBinsPerVar[0] = 100;
    lNbBinsPerVar[1] = 1000;
    lNbBinsPerVar[2] = 22;
-   fCFContCascadePIDOmegaMinus = new AliCFContainer("fCFContCascadePIDOmegaMinus","Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
+        if (fwithSDD) fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
+                                                                       fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                       "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+        else if (!fwithSDD) fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
+                                                                             fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                             "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   } else if (!fkSDDSelectionOn) {
+        fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
+                                                         fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                         "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   } else if (fCollidingSystem == "pPb") {
+        fCFContCascadePIDOmegaMinus = new AliCFContainer(Form("fCFContCascadePIDOmegaMinus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
+                                                         fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                         "Pt_{cascade} Vs M_{#Omega^{-} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   }
      //Setting the bin limits 
    fCFContCascadePIDOmegaMinus->SetBinLimits(0,   0.0  ,  10.0 );      // Pt(Cascade)
    fCFContCascadePIDOmegaMinus->SetBinLimits(1,   1.5  ,   2.5 );      // Omega Effective mass
@@ -775,7 +862,22 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    lNbBinsPerVar[0] = 100;
    lNbBinsPerVar[1] = 1000;
    lNbBinsPerVar[2] = 22; 
-   fCFContCascadePIDOmegaPlus = new AliCFContainer("fCFContCascadePIDOmegaPlus","Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
+        if (fwithSDD) fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
+                                                                      fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                      "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+        else if (!fwithSDD) fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
+                                                                            fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                            "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
+        fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
+                                                        fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                        "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   } else if (fCollidingSystem == "pPb") {
+        fCFContCascadePIDOmegaPlus = new AliCFContainer(Form("fCFContCascadePIDOmegaPlus_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
+                                                        fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                        "Pt_{cascade} Vs M_{#Omega^{+} candidates} Vs Y_{#Omega}", lNbSteps, lNbVariables, lNbBinsPerVar );
+   }
      //Setting the bin limits 
    fCFContCascadePIDOmegaPlus->SetBinLimits(0,   0.0  ,  10.0 );       // Pt(Cascade)
    fCFContCascadePIDOmegaPlus->SetBinLimits(1,   1.5  ,   2.5 );       // Omega Effective mass
@@ -802,17 +904,17 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    const Int_t  lNbVariables  =  19 ;
      //Array for the number of bins in each dimension :
    Int_t lNbBinsPerVar[lNbVariables] = {0};
-   lNbBinsPerVar[0]  = 25;     //DcaCascDaughters             :  [0.0,2.4,3.0]       -> Rec.Cut = 2.0;
+   lNbBinsPerVar[0]  = 25;     //DcaCascDaughters             :  [0.0,2.5]           -> Rec.Cut = 2.0;
    lNbBinsPerVar[1]  = 25;     //DcaBachToPrimVertex          :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01; 
-   lNbBinsPerVar[2]  = 30;     //CascCosineOfPointingAngle    :  [0.97,1.0]          -> Rec.Cut = 0.98;
+   lNbBinsPerVar[2]  = 61;     //CascCosineOfPointingAngle    :  [0.94,1.001]        -> Rec.Cut = 0.95;
    lNbBinsPerVar[3]  = 40;     //CascRadius                   :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
    lNbBinsPerVar[4]  = 30;     //InvMassLambdaAsCascDghter    :  [1.1,1.3]           -> Rec.Cut = 0.008;
-   lNbBinsPerVar[5]  = 20;     //DcaV0Daughters               :  [0.0,2.0]           -> Rec.Cut = 1.5;
-   lNbBinsPerVar[6]  = 201;    //V0CosineOfPointingAngle      :  [0.89,1.0]          -> Rec.Cut = 0.9;
+   lNbBinsPerVar[5]  = 21;     //DcaV0Daughters               :  [0.0,2.0]           -> Rec.Cut = 1.5;
+   lNbBinsPerVar[6]  = 201;    //V0CosineOfPointingAngleToXi  :  [0.89,1.0]          -> No Rec.Cut;
    lNbBinsPerVar[7]  = 40;     //V0Radius                     :  [0.0,3.9,1000.0]    -> Rec.Cut = 0.2;
    lNbBinsPerVar[8]  = 40;     //DcaV0ToPrimVertex            :  [0.0,0.39,110.0]    -> Rec.Cut = 0.01;  
-   lNbBinsPerVar[9]  = 25;     //DcaPosToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.05;
-   lNbBinsPerVar[10] = 25;     //DcaNegToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.05
+   lNbBinsPerVar[9]  = 25;     //DcaPosToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01;
+   lNbBinsPerVar[10] = 25;     //DcaNegToPrimVertex           :  [0.0,0.24,100.0]    -> Rec.Cut = 0.01;
    lNbBinsPerVar[11] = 150;    //InvMassXi                    :   2-MeV/c2 bins
    lNbBinsPerVar[12] = 120;    //InvMassOmega                 :   2-MeV/c2 bins
    lNbBinsPerVar[13] = 100;    //XiTransvMom                  :  [0.0,10.0]
@@ -821,14 +923,30 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    lNbBinsPerVar[16] = 112;    //Proper lenght of cascade       
    lNbBinsPerVar[17] = 112;    //Proper lenght of V0
    lNbBinsPerVar[18] = 112;    //Distance V0-Xi in transverse plane
-   fCFContCascadeCuts = new AliCFContainer("fCFContCascadeCuts","Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
+   if (fCollidingSystem == "pp" && fkSDDSelectionOn) {
+        if (fwithSDD) fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDon",
+                                                              fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                              "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
+        else if (!fwithSDD) fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_wSDDoff",
+                                                                    fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                                    "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
+   } else if (fCollidingSystem == "pp" && !fkSDDSelectionOn) {
+        fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f_woSDD",
+                                                fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
+   } else if (fCollidingSystem == "pPb") {
+        fCFContCascadeCuts = new AliCFContainer(Form("fCFContCascadeCuts_minnTPCcls%i_vtxlim%.1f-%.1f_minptdghtrk%.1f_etacutdghtrk%.1f",
+                                                fMinnTPCcls,fVtxRange,fVtxRangeMin,fMinPtCutOnDaughterTracks,fEtaCutOnDaughterTracks),
+                                                "Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar);
+   }
      //Setting the bin limits 
      //0 -  DcaXiDaughters
-   Double_t *lBinLim0  = new Double_t[ lNbBinsPerVar[0] + 1 ];
-        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;
-        lBinLim0[ lNbBinsPerVar[0] ] = 3.0;
-   fCFContCascadeCuts -> SetBinLimits(0, lBinLim0);  
-   delete [] lBinLim0;
+   //Double_t *lBinLim0  = new Double_t[ lNbBinsPerVar[0] + 1 ];
+   //     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;
+   //     lBinLim0[ lNbBinsPerVar[0] ] = 3.0;
+   //fCFContCascadeCuts -> SetBinLimits(0, lBinLim0);  
+   //delete [] lBinLim0;
+   fCFContCascadeCuts->SetBinLimits(0,0.0,2.5);
      //1 - DcaToPrimVertexXi
    Double_t *lBinLim1  = new Double_t[ lNbBinsPerVar[1] + 1 ];
         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;
@@ -836,7 +954,7 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    fCFContCascadeCuts -> SetBinLimits(1, lBinLim1);  
    delete [] lBinLim1;    
      //2 - CascCosineOfPointingAngle 
-   fCFContCascadeCuts->SetBinLimits(2, 0.97, 1.);
+   fCFContCascadeCuts->SetBinLimits(2, 0.94, 1.001);
      //3 - CascRadius
    Double_t *lBinLim3  = new Double_t[ lNbBinsPerVar[3]+1 ];
         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 ;
@@ -846,7 +964,7 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
      //4 - InvMassLambdaAsCascDghter
    fCFContCascadeCuts->SetBinLimits(4, 1.1, 1.13);
      //5 - DcaV0Daughters
-   fCFContCascadeCuts -> SetBinLimits(5, 0., 2.);
+   fCFContCascadeCuts -> SetBinLimits(5, 0., 2.1);
      //6 - V0CosineOfPointingAngle
    fCFContCascadeCuts -> SetBinLimits(6, 0.8, 1.001);
      //7 - V0Radius
@@ -904,7 +1022,8 @@ void AliAnalysisTaskCheckCascadepp276::UserCreateOutputObjects() {
    fCFContCascadeCuts->SetVarTitle(3,  "R_{2d}(cascade decay) (cm)");
    fCFContCascadeCuts->SetVarTitle(4,  "M_{#Lambda}(as casc dghter) (GeV/c^{2})");
    fCFContCascadeCuts->SetVarTitle(5,  "Dca(V0 daughters) in Xi (cm)");
-   fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 PA) in cascade");
+   if (fCollidingSystem == "pp")       fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 PA) to cascade vtx");
+   else if (fCollidingSystem == "pPb") fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 PA) to primary vtx");
    fCFContCascadeCuts->SetVarTitle(7,  "R_{2d}(V0 decay) (cm)");
    fCFContCascadeCuts->SetVarTitle(8,  "ImpactParamToPV(V0) (cm)");
    fCFContCascadeCuts->SetVarTitle(9,  "ImpactParamToPV(Pos) (cm)");
@@ -941,17 +1060,31 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   AliESDEvent *lESDevent = 0x0;
   AliAODEvent *lAODevent = 0x0;
 
+  //----------------------
+  // Check the PIDresponse
   //---------------------
-  //Check the PIDresponse
   if(!fPIDResponse) {
        AliError("Cannot get pid response");
        return;
   }
+  if(! fESDtrackCuts ){
+       fESDtrackCuts = new AliESDtrackCuts();
+  }
+  if(! fUtils ){
+       fUtils = new AliAnalysisUtils();
+  }
+
 
   ///////////////////
   // EVENT SELECTIONS
-  ///////////////////  
-               
+  ///////////////////
+  // In order:
+  // 1) SDD selection
+  // 2) Physics selection
+  // 3) Select only looking at events with well-established PV
+  // 4) Pileup selection
+  // 5) |Z| < 10 cm
+
   //----------------------
   // Before any selections
   //----------------------
@@ -985,7 +1118,7 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   // - Fill the plots
   fHistCascadeMultiplicityBeforeAnySel->Fill(ncascadesBeforeAnySel);
   fHistTrackMultiplicityBeforeAnySel->Fill(nTrackMultiplicityBeforeAnySel);
+
   //--------------
   // SDD selection
   //--------------
@@ -994,7 +1127,7 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   Int_t nTrackMultiplicityAfterSDDSel = 0;
   // - Selection for ESD and AOD
   if (fAnalysisType == "ESD") {
-     if (fkSDDSelectionOn) {
+     if (fkSDDSelectionOn && fCollidingSystem == "pp") {
         TString trcl = lESDevent->GetFiredTriggerClasses();
         //cout<<"Fired Trigger Classes: "<<trcl<<endl;
         if (fwithSDD){
@@ -1025,7 +1158,7 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
      ncascadesAfterSDDSel = lESDevent->GetNumberOfCascades();
      nTrackMultiplicityAfterSDDSel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
   } else if (fAnalysisType == "AOD") {
-     if (fkSDDSelectionOn) {
+     if (fkSDDSelectionOn && fCollidingSystem == "pp") {
         TString trcl = lAODevent->GetFiredTriggerClasses();
         if (fwithSDD){
            if(!(trcl.Contains("ALLNOTRD"))) {
@@ -1059,60 +1192,54 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   fHistCascadeMultiplicityAfterSDDSel->Fill(ncascadesAfterSDDSel);
   fHistTrackMultiplicityAfterSDDSel->Fill(nTrackMultiplicityAfterSDDSel);
 
-  //----------------------------------------------
-  // Physics selection (+ re-vertexer for the ESD)
-  //----------------------------------------------
+  //-------------------------------------------
+  // Multiplicity estimators for pPb collisions  //FIXME
+  //-------------------------------------------
+  //AliCentrality* centrality = 0;
+  //if      (fAnalysisType == "ESD" && (fCollidingSystem == "pPb")) centrality = lESDevent->GetCentrality();
+  //else if (fAnalysisType == "AOD" && (fCollidingSystem == "pPb")) centrality = lAODevent->GetCentrality();
+  //Float_t lcentrality = 0.;
+  //if (fCollidingSystem == "pPb") {
+  //     if (fkUseCleaning) lcentrality = centrality->GetCentralityPercentile(fCentrEstimator.Data());
+  //     else {
+  //         lcentrality = centrality->GetCentralityPercentileUnchecked(fCentrEstimator.Data());
+  //         if (centrality->GetQuality()>1) {
+  //             PostData(1, fCFContCascadeCuts);
+  //            return;
+  //         }
+  //     }
+  //     //if (lcentrality<fCentrLowLim||lcentrality>=fCentrUpLim) { 
+  //     //    PostData(1, fCFContCascadeCuts);
+  //     //    return;
+  //     //}
+  //} else if (fCollidingSystem == "pp") lcentrality = 0.;  
+
+  //------------------
+  // Physics selection 
+  //-----------------
   // - Define the variables
   Int_t ncascadesAfterPhysicsSel = 0;
   Int_t nTrackMultiplicityAfterPhysicsSel = 0;
   // - Selection for ESD and AOD
+  UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+  Bool_t isSelected = 0;
+  if      (fCollidingSystem == "pp" ) isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
+  else if (fCollidingSystem == "pPb") isSelected = (maskIsSelected & AliVEvent::kINT7) == AliVEvent::kINT7;
+  if(! isSelected){
+      PostData(1, fListHistCascade);
+      PostData(2, fCFContCascadePIDXiMinus);
+      PostData(3, fCFContCascadePIDXiPlus);
+      PostData(4, fCFContCascadePIDOmegaMinus);
+      PostData(5, fCFContCascadePIDOmegaPlus);
+      PostData(6, fCFContCascadeCuts);
+      cout<<"We are selecting the events that past tha Physics Selection. This event does not pass the Physics Selection. =>  RETURN!! (Exclude it)..."<<endl;
+      return;
+  }
   if (fAnalysisType == "ESD") {
-      UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
-      Bool_t isSelected = 0;
-      isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
-      if(! isSelected){
-          PostData(1, fListHistCascade);
-          PostData(2, fCFContCascadePIDXiMinus);
-          PostData(3, fCFContCascadePIDXiPlus);
-          PostData(4, fCFContCascadePIDOmegaMinus);
-          PostData(5, fCFContCascadePIDOmegaPlus);
-          PostData(6, fCFContCascadeCuts);
-          cout<<"We are selecting the events that past tha Physics Selection. This event does not pass the Physics Selection. =>  RETURN!! (Exclude it)..."<<endl;
-          return;
-      }
       // - Take the number of cascades and tracks after physics selection
       ncascadesAfterPhysicsSel = lESDevent->GetNumberOfCascades();    
       nTrackMultiplicityAfterPhysicsSel = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);  
-      // - Cascade vertexer (ESD)
-      // Relaunch V0 and Cascade vertexers
-      if (fkRerunV0CascVertexers) { 
-            lESDevent->ResetCascades();
-            lESDevent->ResetV0s();
-            //AliV0vertexer *lV0vtxer = new AliV0vertexer();
-            //AliCascadeVertexer *lCascVtxer = new AliCascadeVertexer();
-            //lV0vtxer->GetCuts(fV0Sels);
-            //lCascVtxer->GetCuts(fCascSels);
-            //lV0vtxer->SetCuts(fV0Sels);      // NB don't use SetDefaultCuts!! because it acts on static variables 
-            //lCascVtxer->SetCuts(fCascSels);
-            //lV0vtxer->Tracks2V0vertices(lESDevent);
-            //lCascVtxer->V0sTracks2CascadeVertices(lESDevent);
-            //delete lV0vtxer;
-            //delete lCascVtxer;
-      }         
   } else if (fAnalysisType == "AOD") {
-      UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
-      Bool_t isSelected = 0;
-      isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
-      if(! isSelected){
-          PostData(1, fListHistCascade);
-          PostData(2, fCFContCascadePIDXiMinus);
-          PostData(3, fCFContCascadePIDXiPlus);
-          PostData(4, fCFContCascadePIDOmegaMinus);
-          PostData(5, fCFContCascadePIDOmegaPlus);
-          PostData(6, fCFContCascadeCuts);
-          cout<<"We are selecting the events that past tha Physics Selection. This event does not pass the Physics Selection. =>  RETURN!! (Exclude it)..."<<endl;
-          return;
-      }    
       // - Take the number of cascades and tracks after the physics selection
       ncascadesAfterPhysicsSel = lAODevent->GetNumberOfCascades();
       nTrackMultiplicityAfterPhysicsSel = -100;  //FIXME: I can't find the equivalent method for the AOD    
@@ -1120,7 +1247,198 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   // - Fill the plots
   fHistCascadeMultiplicityAfterPhysicsSel->Fill(ncascadesAfterPhysicsSel);
   fHistTrackMultiplicityAfterPhysicsSel->Fill(nTrackMultiplicityAfterPhysicsSel);
-  
+
+  //---------------------------------------
+  // Re-run cascade vertexer (only for ESD)
+  //---------------------------------------
+  if (fAnalysisType == "ESD" && fkRerunV0CascVertexers) {
+       lESDevent->ResetCascades();
+       lESDevent->ResetV0s();
+       AliV0vertexer *lV0vtxer = new AliV0vertexer();
+       AliCascadeVertexer *lCascVtxer = new AliCascadeVertexer();
+       //lV0vtxer->GetCuts(fV0Sels);
+       //lCascVtxer->GetCuts(fCascSels);
+       lV0vtxer->SetCuts(fV0Sels);      // NB don't use SetDefaultCuts!! because it acts on static variables 
+       lCascVtxer->SetCuts(fCascSels);
+       lV0vtxer->Tracks2V0vertices(lESDevent);
+       lCascVtxer->V0sTracks2CascadeVertices(lESDevent);
+       //delete lV0vtxer;
+       //delete lCascVtxer;
+  }
+
+  //------------------------------
+  // Well-established PV selection
+  //------------------------------
+  // - Define variables
+  Int_t ncascadesForSelEvtNoTPCOnly = 0;
+  Int_t nTrackMultiplicityForSelEvtNoTPCOnly = 0;
+  // - Selection for the two colliding systems
+  if (fCollidingSystem == "pp") {
+      // - Selection for ESD and AOD
+      if (fAnalysisType == "ESD") {
+          // - Vertex coordinates: get the PVs stored in the ESD found with tracks and SPD
+          const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
+          const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
+          // - Select only looking at events with well-established PV
+          if (fkQualityCutNoTPConlyPrimVtx) {
+              if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
+                  AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+                  PostData(1, fListHistCascade);
+                  PostData(2, fCFContCascadePIDXiMinus);
+                  PostData(3, fCFContCascadePIDXiPlus);
+                  PostData(4, fCFContCascadePIDOmegaMinus);
+                  PostData(5, fCFContCascadePIDOmegaPlus);
+                  PostData(6, fCFContCascadeCuts);
+                  return;
+              }
+          }
+          // - Take the number of cascades and tracks after TPConly selection
+          ncascadesForSelEvtNoTPCOnly = lESDevent->GetNumberOfCascades();
+          nTrackMultiplicityForSelEvtNoTPCOnly = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
+      } else if (fAnalysisType == "AOD") {
+          // - Vertex coordinates: get the PVs stored in the AOD found with tracks and SPD
+          const AliAODVertex *lPrimarySPDVtx = lAODevent->GetPrimaryVertexSPD();
+          const AliAODVertex *lPrimaryTrackingAODVtx = lAODevent->GetPrimaryVertex();
+          // - Select only looking at events with well-established PV
+          if (fkQualityCutNoTPConlyPrimVtx) {
+              if (!lPrimarySPDVtx && !lPrimaryTrackingAODVtx) {
+                  AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+                  PostData(1, fListHistCascade);
+                  PostData(2, fCFContCascadePIDXiMinus);
+                  PostData(3, fCFContCascadePIDXiPlus);
+                  PostData(4, fCFContCascadePIDOmegaMinus);
+                  PostData(5, fCFContCascadePIDOmegaPlus);
+                  PostData(6, fCFContCascadeCuts);
+                  return;
+              }
+          }
+          // - Take the number of cascades and tracks after TPConly selection
+          ncascadesForSelEvtNoTPCOnly = lAODevent->GetNumberOfCascades();
+          nTrackMultiplicityForSelEvtNoTPCOnly = -100;  //FIXME: I can't find the equivalent method for the AOD
+      }
+  } else if (fCollidingSystem == "pPb") {
+      if (fAnalysisType == "ESD") {
+          Bool_t fHasVertex = kFALSE;
+          const AliESDVertex *vertex = lESDevent->GetPrimaryVertexTracks();
+          if (vertex->GetNContributors() < 1) {
+              vertex = lESDevent->GetPrimaryVertexSPD();
+              if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
+              else                                fHasVertex = kTRUE;
+              TString vtxTyp = vertex->GetTitle();
+              Double_t cov[6]={0};
+              vertex->GetCovarianceMatrix(cov);
+              Double_t zRes = TMath::Sqrt(cov[5]);
+              if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
+          } else fHasVertex = kTRUE;
+          if (fHasVertex == kFALSE) {
+              AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }
+          if (fUtils->IsFirstEventInChunk(lESDevent)) { //Is First event in chunk rejection: Still present!
+              AliWarning("Pb / This is the first event in the chunk! ... return !");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }
+          // - Take the number of cascades and tracks after TPConly selection
+          ncascadesForSelEvtNoTPCOnly = lESDevent->GetNumberOfCascades();
+          nTrackMultiplicityForSelEvtNoTPCOnly = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
+      } else if (fAnalysisType == "AOD") {
+          Bool_t fHasVertex = kFALSE;
+          const AliAODVertex *vertex = lAODevent->GetPrimaryVertex();
+          if (vertex->GetNContributors() < 1) {
+              vertex = lAODevent->GetPrimaryVertexSPD();
+              if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
+              else                                fHasVertex = kTRUE;
+              TString vtxTyp = vertex->GetTitle();
+              Double_t cov[6]={0};
+              vertex->GetCovarianceMatrix(cov);
+              Double_t zRes = TMath::Sqrt(cov[5]);
+              if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
+          } else fHasVertex = kTRUE;
+          if (fHasVertex == kFALSE) {
+              AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }
+          if (fHasVertex == kFALSE) { //Is First event in chunk rejection: Still present!  //FIXME
+              AliWarning("Pb / This is the first event in the chunk! ... return !");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }  
+          // - Take the number of cascades and tracks after TPConly selection
+          ncascadesForSelEvtNoTPCOnly = lAODevent->GetNumberOfCascades();
+          nTrackMultiplicityForSelEvtNoTPCOnly = -100;  //FIXME: I can't find the equivalent method for the AOD
+      }
+  }
+  // - Fill the plots
+  fHistCascadeMultiplicityForSelEvtNoTPCOnly->Fill(ncascadesForSelEvtNoTPCOnly);
+  fHistTrackMultiplicityForSelEvtNoTPCOnly->Fill(nTrackMultiplicityForSelEvtNoTPCOnly);
+   
+  //----------------
+  // Pilup selection
+  //----------------
+  // - Define variables
+  Int_t ncascadesForSelEvtNoTPCOnlyNoPileup = 0;
+  Int_t nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = 0;
+  // - Selection for ESD and AOD
+  if (fAnalysisType == "ESD" && fCollidingSystem == "pp") {
+      if (fkQualityCutPileup) {
+          if(lESDevent->IsPileupFromSPD()){
+              AliWarning("Pb / Pile-up event ... return!");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }
+      }
+      // - Take the number of cascades and tracks after Pileup selection
+      ncascadesForSelEvtNoTPCOnlyNoPileup = lESDevent->GetNumberOfCascades();
+      nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
+  } else if (fAnalysisType == "AOD" && fCollidingSystem == "pp") {
+      if (fkQualityCutPileup) {
+          if(lAODevent->IsPileupFromSPD()){
+              AliWarning("Pb / Pile-up event ... return!");
+              PostData(1, fListHistCascade);
+              PostData(2, fCFContCascadePIDXiMinus);
+              PostData(3, fCFContCascadePIDXiPlus);
+              PostData(4, fCFContCascadePIDOmegaMinus);
+              PostData(5, fCFContCascadePIDOmegaPlus);
+              PostData(6, fCFContCascadeCuts);
+              return;
+          }
+      }
+      // - Take the number of cascades and tracks after Pileup selection
+      ncascadesForSelEvtNoTPCOnlyNoPileup = lAODevent->GetNumberOfCascades();
+      nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = -100;   //FIXME: I can't find the equivalent method for the AOD
+  }
+  fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(ncascadesForSelEvtNoTPCOnlyNoPileup);
+  fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup);
+    
   //----------------------------------------------------
   // Vertex Z position selection (+ magnetic field info)
   //----------------------------------------------------
@@ -1218,117 +1536,25 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
   fHistCascadeMultiplicityAfterVertexCutSel->Fill(ncascadesAfterVertexSel);
   fHistTrackMultiplicityAfterVertexCutSel->Fill(nTrackMultiplicityAfterVertexSel);
 
-  //------------------------------
-  // Well-established PV selection
-  //------------------------------
-  // - Define variables
-  Int_t ncascadesForSelEvtNoTPCOnly = 0;
-  Int_t nTrackMultiplicityForSelEvtNoTPCOnly = 0;
-  // - Selection for ESD and AOD
-  if (fAnalysisType == "ESD") {
-      // - Vertex coordinates: get the PVs stored in the ESD found with tracks and SPD
-      const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
-      const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
-      // - Select only looking at events with well-established PV
-      if (fkQualityCutNoTPConlyPrimVtx) {
-          if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
-              AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
-              PostData(1, fListHistCascade);
-              PostData(2, fCFContCascadePIDXiMinus);
-              PostData(3, fCFContCascadePIDXiPlus);
-              PostData(4, fCFContCascadePIDOmegaMinus);
-              PostData(5, fCFContCascadePIDOmegaPlus);
-              PostData(6, fCFContCascadeCuts);
-              return;
-          }
-      }
-      // - Take the number of cascades and tracks after TPConly selection
-      ncascadesForSelEvtNoTPCOnly = lESDevent->GetNumberOfCascades();
-      nTrackMultiplicityForSelEvtNoTPCOnly = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
-  } else if (fAnalysisType == "AOD") {
-      // - Vertex coordinates: get the PVs stored in the AOD found with tracks and SPD
-      const AliAODVertex *lPrimarySPDVtx = lAODevent->GetPrimaryVertexSPD();
-      const AliAODVertex *lPrimaryTrackingAODVtx = lAODevent->GetPrimaryVertex();
-      // - Select only looking at events with well-established PV
-      if (fkQualityCutNoTPConlyPrimVtx) {
-          if (!lPrimarySPDVtx && !lPrimaryTrackingAODVtx) {
-              AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
-              PostData(1, fListHistCascade);
-              PostData(2, fCFContCascadePIDXiMinus);
-              PostData(3, fCFContCascadePIDXiPlus);
-              PostData(4, fCFContCascadePIDOmegaMinus);
-              PostData(5, fCFContCascadePIDOmegaPlus);
-              PostData(6, fCFContCascadeCuts);
-              return;
-          }
-      }
-      // - Take the number of cascades and tracks after TPConly selection
-      ncascadesForSelEvtNoTPCOnly = lAODevent->GetNumberOfCascades();
-      nTrackMultiplicityForSelEvtNoTPCOnly = -100;  //FIXME: I can't find the equivalent method for the AOD
-  }
-  // - Fill the plots
-  fHistCascadeMultiplicityForSelEvtNoTPCOnly->Fill(ncascadesForSelEvtNoTPCOnly);
-  fHistTrackMultiplicityForSelEvtNoTPCOnly->Fill(nTrackMultiplicityForSelEvtNoTPCOnly);
-
-  //----------------
-  // Pilup selection
-  //----------------
-  // - Define variables
-  Int_t ncascadesForSelEvtNoTPCOnlyNoPileup = 0;
-  Int_t nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = 0;
+  // - Vertex position plots: after any event selections
   tPrimaryVtxPosition[0] = -100.0;
   tPrimaryVtxPosition[1] = -100.0;
   tPrimaryVtxPosition[2] = -100.0;
-  // - Selection for ESD and AOD
   if (fAnalysisType == "ESD") {
-      if (fkQualityCutPileup) {
-          if(lESDevent->IsPileupFromSPD()){
-              AliWarning("Pb / Pile-up event ... return!");
-              PostData(1, fListHistCascade);
-              PostData(2, fCFContCascadePIDXiMinus);
-              PostData(3, fCFContCascadePIDXiPlus);
-              PostData(4, fCFContCascadePIDOmegaMinus);
-              PostData(5, fCFContCascadePIDOmegaPlus);
-              PostData(6, fCFContCascadeCuts);
-              return;
-           }
-      }
-      // - Take the number of cascades and tracks after Pileup selection
-      ncascadesForSelEvtNoTPCOnlyNoPileup = lESDevent->GetNumberOfCascades();
-      nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = fESDtrackCuts->GetReferenceMultiplicity(lESDevent,AliESDtrackCuts::kTrackletsITSTPC,0.5);
-      // - Take the vertex position after all selections
-      const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
-      tPrimaryVtxPosition[0] = primaryVtx->GetX();  
-      tPrimaryVtxPosition[1] = primaryVtx->GetY();
-      tPrimaryVtxPosition[2] = primaryVtx->GetZ();
+       const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
+       tPrimaryVtxPosition[0] = primaryVtx->GetX();
+       tPrimaryVtxPosition[1] = primaryVtx->GetY();
+       tPrimaryVtxPosition[2] = primaryVtx->GetZ();
   } else if (fAnalysisType == "AOD") {
-      if (fkQualityCutPileup) {
-          if(lAODevent->IsPileupFromSPD()){
-              AliWarning("Pb / Pile-up event ... return!");
-              PostData(1, fListHistCascade);
-              PostData(2, fCFContCascadePIDXiMinus);
-              PostData(3, fCFContCascadePIDXiPlus);
-              PostData(4, fCFContCascadePIDOmegaMinus);
-              PostData(5, fCFContCascadePIDOmegaPlus);
-              PostData(6, fCFContCascadeCuts);
-              return;
-           }
-      }
-      // - Take the number of cascades and tracks after Pileup selection
-      ncascadesForSelEvtNoTPCOnlyNoPileup = lAODevent->GetNumberOfCascades();
-      nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup = -100;   //FIXME: I can't find the equivalent method for the AOD
-      // - Take the vertex position after all selections
-      const AliVVertex *primaryVtx = lAODevent->GetPrimaryVertex();
-      tPrimaryVtxPosition[0] = primaryVtx->GetX();
-      tPrimaryVtxPosition[1] = primaryVtx->GetY();
-      tPrimaryVtxPosition[2] = primaryVtx->GetZ();
+       const AliVVertex *primaryVtx = lAODevent->GetPrimaryVertex();
+       tPrimaryVtxPosition[0] = primaryVtx->GetX();
+       tPrimaryVtxPosition[1] = primaryVtx->GetY();
+       tPrimaryVtxPosition[2] = primaryVtx->GetZ();
   }
-  // - Fill the plots
   fHistPVxAnalysis->Fill( tPrimaryVtxPosition[0] );
   fHistPVyAnalysis->Fill( tPrimaryVtxPosition[1] );
   fHistPVzAnalysis->Fill( tPrimaryVtxPosition[2] );
-  fHistCascadeMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(ncascadesForSelEvtNoTPCOnlyNoPileup);
-  fHistTrackMultiplicityForSelEvtNoTPCOnlyNoPileup->Fill(nTrackMultiplicityForSelEvtNoTPCOnlyNoPileup);  
+  
 
 
   //////////////////////////////
@@ -1411,6 +1637,8 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
       Double_t lBachMomZ       = 0.;
       Double_t lBachTransvMom  = 0.;
       Double_t lBachTotMom     = 0.;
+      Double_t lpTrackTransvMom  = 0.;
+      Double_t lnTrackTransvMom  = 0.;
       Short_t  lChargeXi       = -2;
       Double_t lV0toXiCosineOfPointingAngle = 0.;
       Double_t lRapXi   = -20.0, lRapOmega = -20.0, lEta = -20.0, lTheta = 360., lPhi = 720.;
@@ -1510,23 +1738,21 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
            //-----------------------------------------
           // - Extra-selection for cascade candidates
            if (fkExtraSelections) { //in AliCascadeVertexer
-               if (lDcaXiDaughters > 0.3) continue;  
-               if (lXiCosineOfPointingAngle < 0.999 ) continue; 
-               if (lDcaV0ToPrimVertexXi < 0.05) continue; 
-               if (lDcaBachToPrimVertexXi < 0.03) continue; 
-               //if (TMath::Abs(lInvMassLambdaAsCascDghter-1.11568) > 0.006 ) continue;   
-               if (lDcaV0DaughtersXi > 1.) continue;  
-               if (lV0CosineOfPointingAngleXi < 0.998) continue; 
-               if (lDcaPosToPrimVertexXi < 0.1) continue; 
-               if (lDcaNegToPrimVertexXi < 0.1) continue; 
-              if (lXiRadius < .9) continue; 
-               //if (lXiRadius > 100) continue; 
-              if (lV0RadiusXi < 0.9) continue;   
-               //if (lV0RadiusXi > 100) continue; 
+                if (lDcaXiDaughters > 0.3) continue;                                              // in AliCascadeVertexer
+                if (lXiCosineOfPointingAngle < 0.999 ) continue;                                  // in AliCascadeVertexer
+                if (lDcaV0ToPrimVertexXi < 0.05) continue;                                        // in AliCascadeVertexer
+                if (lDcaBachToPrimVertexXi < 0.03) continue;                                      // in AliCascadeVertexer
+                if (lDcaV0DaughtersXi > 1.) continue;                                             // in AliV0vertexer
+                if ((fCollidingSystem == "pp") && (lV0toXiCosineOfPointingAngle < 0.998)) continue; // in AliV0vertexer
+                if ((fCollidingSystem == "pPb") && (lV0CosineOfPointingAngleXi < 0.998)) continue;  // in AliV0vertexer
+                if (lDcaPosToPrimVertexXi < 0.1) continue;                                        // in AliV0vertexer
+                if (lDcaNegToPrimVertexXi < 0.1) continue;                                        // in AliV0vertexer
+                if (lXiRadius < .9) continue;                                                     // in AliCascadeVertexer
+                if (lV0RadiusXi < 0.9) continue;                                                  // in AliV0vertexer
            }
 
-           //----------------------------------------------------------------------------------------------------      
-           // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega -/+
+           //---------------------------------------------------------------------------------------------------       
+           // - Around effective masses. Change mass hypotheses to cover all the possibilities:  Xi-/+, Omega-/+
            if ( bachTrackXi->Charge() < 0 )    {
                 //Calculate the effective mass of the Xi- candidate: Xi- hyp. (pdg code 3312)
                 lV0quality = 0.;
@@ -1605,6 +1831,8 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
            xi->GetBPxPyPz(  lBachMomX,  lBachMomY,  lBachMomZ );
            lBachTransvMom  = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY );
            lBachTotMom     = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ );
+           lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX   + lV0NMomY*lV0NMomY );
+           lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX   + lV0PMomY*lV0PMomY );
            lChargeXi       = xi->Charge();
            lV0toXiCosineOfPointingAngle = xi->GetV0CosineOfPointingAngle( lPosXi[0], lPosXi[1], lPosXi[2] );
            lRapXi    = xi->RapXi();
@@ -1748,6 +1976,12 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
            lBachMomZ = xi->MomBachZ();         
            lBachTransvMom = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY );
            lBachTotMom    = TMath::Sqrt( lBachMomX*lBachMomX + lBachMomY*lBachMomY + lBachMomZ*lBachMomZ );
+           lV0NMomX = xi->MomNegX();
+           lV0NMomY = xi->MomNegY();
+           lV0PMomX = xi->MomPosX();
+           lV0PMomY = xi->MomPosY();
+           lnTrackTransvMom = TMath::Sqrt( lV0NMomX*lV0NMomX   + lV0NMomY*lV0NMomY );
+           lpTrackTransvMom = TMath::Sqrt( lV0PMomX*lV0PMomX   + lV0PMomY*lV0PMomY );
            lV0toXiCosineOfPointingAngle = xi->CosPointingAngle( xi->GetDecayVertexXi() );
            lRapXi    = xi->RapXi();
            lRapOmega = xi->RapOmega();
@@ -1759,6 +1993,17 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
 
     } // end of AOD treatment
 
+    // Cut on pt of the three daughter tracks
+    if (lBachTransvMom<fMinPtCutOnDaughterTracks) continue;
+    if (lpTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
+    if (lnTrackTransvMom<fMinPtCutOnDaughterTracks) continue;
+      
+    // Cut on pseudorapidity of the three daughter tracks
+    if (TMath::Abs(etaBach)>fEtaCutOnDaughterTracks) continue;
+    if (TMath::Abs(etaPos)>fEtaCutOnDaughterTracks) continue;
+    if (TMath::Abs(etaNeg)>fEtaCutOnDaughterTracks) continue;
+      
+      
     //----------------------------------
     // Calculate proper lenght for cascade
     Double_t cascadeMass = 0.;
@@ -1989,7 +2234,8 @@ void AliAnalysisTaskCheckCascadepp276::UserExec(Option_t *) {
     lContainerCutVars[3]  = lXiRadius;
     lContainerCutVars[4]  = lInvMassLambdaAsCascDghter;
     lContainerCutVars[5]  = lDcaV0DaughtersXi;
-    lContainerCutVars[6]  = lV0toXiCosineOfPointingAngle;
+    if (fCollidingSystem == "pp")       lContainerCutVars[6]  = lV0toXiCosineOfPointingAngle;
+    else if (fCollidingSystem == "pPb") lContainerCutVars[6]  = lV0CosineOfPointingAngleXi;
     lContainerCutVars[7]  = lV0RadiusXi;
     lContainerCutVars[8]  = lDcaV0ToPrimVertexXi;      
     lContainerCutVars[9]  = lDcaPosToPrimVertexXi;