SUMMARY = CFContainer improvement + step towards bookkeeping
authorbhippoly <bhippoly@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Mar 2010 17:16:57 +0000 (17:16 +0000)
committerbhippoly <bhippoly@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 19 Mar 2010 17:16:57 +0000 (17:16 +0000)
-------
1. CheckCascade :
* Andrei's advice : 1. implementation of a destructor /2. TList::SetOwner /3. PostData in UserCreateOutputObjects /4. PostData in accordance with return wihtin UserExec;
* Settings related to (quality) analysis cuts now as data members (needed for bookkeeping);
* Step towards bookkeeping with a TPaveText (commented ! not supported by the framework);
* Introduction of new TH1F or change of name :
    - fHistCascadeMultiplicityBeforeTrigSel,
    - fHistCascadeMultiplicity       becomes fHistCascadeMultiplicityForTrigEvt,
    - fHistTrackMultiplicity         becomes fHistTrackMultiplicityForTrigEvt,
    - fHistTPCrefitTrackMultiplicity becomes fHistTPCrefitTrackMultiplicityForTrigEvt,
    - fHistCascadeMultiplicityForSelEvt,          - fHistPosBestPrimaryVtx(X,Y,Z)ForSelEvt,
    - fHistPosTrkgPrimaryVtx(X,Y,Z)  become fHistPosTrkgPrimaryVtx(X,Y,Z)ForCascadeEvt,
    - fHistPosBestPrimaryVtx(X,Y,Z)  become  fHistPosBestPrimaryVtx(X,Y,Z)ForCascadeEvt;
* fCFContCascadeCuts reshuffled : 1. 20 dimensions [+Y(Xi) +Y(Omega)] / 2. 1 step = 1 species.

2. CheckPerformanceCascade :
* Andrei's advice : 1. implementation of a destructor /2. TList::SetOwner /3. PostData in UserCreateOutputObjects /4. PostData in accordance with return wihtin UserExec;
* Settings related to (quality) analysis cuts now as data members (needed for bookkeeping);
* Step towards bookkeeping with a TPaveText (commented ! not supported by the framework);
* AliCFContainer: Introduction of fCFCont*As*CascadeCuts = like fCFContCascadeCuts but for associated-to-MC particles
3. AddTaskCheckCascade + AddTaskCheckPerformanceCascade
* Settings corresponding to the new features above (choices hard-coded into each macro, != arguments)
(A.Maire)

PWG2/SPECTRA/AliAnalysisTaskCheckCascade.cxx
PWG2/SPECTRA/AliAnalysisTaskCheckCascade.h
PWG2/SPECTRA/AliAnalysisTaskCheckPerformanceCascade.cxx
PWG2/SPECTRA/AliAnalysisTaskCheckPerformanceCascade.h
PWG2/SPECTRA/macros/AddTaskCheckCascade.C
PWG2/SPECTRA/macros/AddTaskCheckPerformanceCascade.C

index c37c673..d8ee931 100644 (file)
@@ -22,7 +22,7 @@
 //              3. Supply an AliCFContainer meant to define the optimised topological selections
 //              4. Rough azimuthal correlation study (Eta, Phi)
 //            Adapted to Cascade : A.Maire Mar2008, antonin.maire@ires.in2p3.fr
-//            Modified :           A.Maire Jan2010, antonin.maire@ires.in2p3.fr
+//            Modified :           A.Maire Mar2010, antonin.maire@ires.in2p3.fr
 //-----------------------------------------------------------------
 
 
@@ -41,7 +41,6 @@ class AliESDv0;
 class AliAODv0;
 
 #include <Riostream.h>
-
 #include "TList.h"
 #include "TH1.h"
 #include "TH2.h"
@@ -57,8 +56,8 @@ class AliAODv0;
 
 #include "AliESDEvent.h"
 #include "AliAODEvent.h"
-// #include "AliV0vertexer.h"
-// #include "AliCascadeVertexer.h"
+//       #include "AliV0vertexer.h"
+//       #include "AliCascadeVertexer.h"
 #include "AliESDpid.h"
 
 #include "AliInputEventHandler.h"
@@ -79,16 +78,26 @@ ClassImp(AliAnalysisTaskCheckCascade)
 
 //________________________________________________________________________
 AliAnalysisTaskCheckCascade::AliAnalysisTaskCheckCascade() 
-  : AliAnalysisTaskSE(), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0),
+  : AliAnalysisTaskSE(), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0), /*fPaveTextBookKeeping(0),*/
+    fkRerunV0CascVertexers      (0),
+    fkQualityCutZprimVtxPos     (kTRUE),
+    fkQualityCutNoTPConlyPrimVtx(kTRUE),
+    fkQualityCutTPCrefit        (kTRUE),
+    fkQualityCut80TPCcls        (kTRUE),
+    fkExtraSelections           (0),
 
        // - Cascade part initialisation
     fListHistCascade(0),
-    fHistTrackMultiplicity(0), fHistTPCrefitTrackMultiplicity(0), fHistCascadeMultiplicity(0), fHistTPCrefitTrackMultiplicityForCascadeEvt(0),
+    fHistCascadeMultiplicityBeforeTrigSel(0),
+    fHistCascadeMultiplicityForTrigEvt(0), fHistTrackMultiplicityForTrigEvt(0), fHistTPCrefitTrackMultiplicityForTrigEvt(0),
+    fHistCascadeMultiplicityForSelEvt(0),
+    fHistPosBestPrimaryVtxXForSelEvt(0), fHistPosBestPrimaryVtxYForSelEvt(0), fHistPosBestPrimaryVtxZForSelEvt(0),
+    fHistTPCrefitTrackMultiplicityForCascadeEvt(0),
     fHistPosV0TPCClusters(0), fHistNegV0TPCClusters(0), fHistBachTPCClusters(0),
     fHistVtxStatus(0),
 
-    fHistPosTrkgPrimaryVtxX(0), fHistPosTrkgPrimaryVtxY(0), fHistPosTrkgPrimaryVtxZ(0), fHistTrkgPrimaryVtxRadius(0),
-    fHistPosBestPrimaryVtxX(0), fHistPosBestPrimaryVtxY(0), fHistPosBestPrimaryVtxZ(0), fHistBestPrimaryVtxRadius(0),
+    fHistPosTrkgPrimaryVtxXForCascadeEvt(0), fHistPosTrkgPrimaryVtxYForCascadeEvt(0), fHistPosTrkgPrimaryVtxZForCascadeEvt(0), fHistTrkgPrimaryVtxRadius(0),
+    fHistPosBestPrimaryVtxXForCascadeEvt(0), fHistPosBestPrimaryVtxYForCascadeEvt(0), fHistPosBestPrimaryVtxZForCascadeEvt(0), fHistBestPrimaryVtxRadius(0),
     f2dHistTrkgPrimVtxVsBestPrimVtx(0),
 
     fHistEffMassXi(0),  fHistChi2Xi(0),  
@@ -141,6 +150,9 @@ AliAnalysisTaskCheckCascade::AliAnalysisTaskCheckCascade()
 
 {
   // Dummy Constructor
+        for(Int_t iAlephIdx   = 0; iAlephIdx   < 5; iAlephIdx++   ) { fAlephParameters [iAlephIdx]    = -1.; }
+        for(Int_t iV0selIdx   = 0; iV0selIdx   < 7; iV0selIdx++   ) { fV0Sels          [iV0selIdx   ] = -1.; }
+        for(Int_t iCascSelIdx = 0; iCascSelIdx < 8; iCascSelIdx++ ) { fCascSels        [iCascSelIdx ] = -1.; }
 }
 
 
@@ -152,16 +164,26 @@ AliAnalysisTaskCheckCascade::AliAnalysisTaskCheckCascade()
 
 //________________________________________________________________________
 AliAnalysisTaskCheckCascade::AliAnalysisTaskCheckCascade(const char *name) 
-  : AliAnalysisTaskSE(name), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0),
+  : AliAnalysisTaskSE(name), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0), /*fPaveTextBookKeeping(0),*/
+    fkRerunV0CascVertexers      (0),
+    fkQualityCutZprimVtxPos     (kTRUE),
+    fkQualityCutNoTPConlyPrimVtx(kTRUE),
+    fkQualityCutTPCrefit        (kTRUE),
+    fkQualityCut80TPCcls        (kTRUE),
+    fkExtraSelections           (0),
      
        // - Cascade part initialisation
     fListHistCascade(0),
-    fHistTrackMultiplicity(0), fHistTPCrefitTrackMultiplicity(0), fHistCascadeMultiplicity(0), fHistTPCrefitTrackMultiplicityForCascadeEvt(0),
+    fHistCascadeMultiplicityBeforeTrigSel(0),
+    fHistCascadeMultiplicityForTrigEvt(0), fHistTrackMultiplicityForTrigEvt(0), fHistTPCrefitTrackMultiplicityForTrigEvt(0),
+    fHistCascadeMultiplicityForSelEvt(0),
+    fHistPosBestPrimaryVtxXForSelEvt(0), fHistPosBestPrimaryVtxYForSelEvt(0), fHistPosBestPrimaryVtxZForSelEvt(0),
+    fHistTPCrefitTrackMultiplicityForCascadeEvt(0),
     fHistPosV0TPCClusters(0), fHistNegV0TPCClusters(0), fHistBachTPCClusters(0),
     fHistVtxStatus(0),
 
-    fHistPosTrkgPrimaryVtxX(0), fHistPosTrkgPrimaryVtxY(0), fHistPosTrkgPrimaryVtxZ(0), fHistTrkgPrimaryVtxRadius(0),
-    fHistPosBestPrimaryVtxX(0), fHistPosBestPrimaryVtxY(0), fHistPosBestPrimaryVtxZ(0), fHistBestPrimaryVtxRadius(0),
+    fHistPosTrkgPrimaryVtxXForCascadeEvt(0), fHistPosTrkgPrimaryVtxYForCascadeEvt(0), fHistPosTrkgPrimaryVtxZForCascadeEvt(0), fHistTrkgPrimaryVtxRadius(0),
+    fHistPosBestPrimaryVtxXForCascadeEvt(0), fHistPosBestPrimaryVtxYForCascadeEvt(0), fHistPosBestPrimaryVtxZForCascadeEvt(0), fHistBestPrimaryVtxRadius(0),
     f2dHistTrkgPrimVtxVsBestPrimVtx(0),
 
     fHistEffMassXi(0),  fHistChi2Xi(0),  
@@ -217,13 +239,48 @@ AliAnalysisTaskCheckCascade::AliAnalysisTaskCheckCascade(const char *name)
 
   // Define input and output slots here
   // Input slot #0 works with a TChain
-  
+  // DefineInput(0, TChain::Class());
+  // Output slot #1 writes into a TList container (cascade)
+        
+        for(Int_t iAlephIdx   = 0; iAlephIdx   < 5; iAlephIdx++   ) { fAlephParameters [iAlephIdx]    = -1.; }
+        
+        fV0Sels[0] =  33.  ;  // max allowed chi2
+        fV0Sels[1] =   0.01;  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
+        fV0Sels[2] =   0.01;  // 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.0 ;  // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
+        fV0Sels[5] =   0.2 ;  // min radius of the fiducial volume                 (LHC09a4 : 0.2)
+        fV0Sels[6] = 100.  ;  // max radius of the fiducial volume                 (LHC09a4 : 100.0)
+        
+        fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
+        fCascSels[1] =   0.01 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
+        fCascSels[2] =   0.008;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
+        fCascSels[3] =   0.01 ;  // 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.98 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
+        fCascSels[6] =   0.2  ;  // 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, TPaveText::Class());*/
 }
 
 
+AliAnalysisTaskCheckCascade::~AliAnalysisTaskCheckCascade()
+{
+  //
+  // Destructor
+  //
 
+  // For all TH1, 2, 3 HnSparse and CFContainer are in the fListCascade TList.
+  // They will be deleted when fListCascade is deleted by the TSelector dtor
+  // Because of TList::SetOwner() ...
+        
+  if (fListHistCascade)         { delete fListHistCascade;     fListHistCascade = 0x0;    }
+  if (fESDpid)                  { delete fESDpid;              fESDpid = 0x0;} // fESDpid is not stored into the TList
+  //if (fPaveTextBookKeeping)     { delete fPaveTextBookKeeping; fPaveTextBookKeeping = 0x0;} // fPaveTextBookKeeping is not strored in the TList
+}
 
 
 
@@ -236,48 +293,207 @@ void AliAnalysisTaskCheckCascade::UserCreateOutputObjects()
 
 
  fListHistCascade = new TList();
+ fListHistCascade->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
  
  
-       // - General histos
+if(! fESDpid){
+
+  AliMCEventHandler *lmcEvtHandler  = dynamic_cast<AliMCEventHandler*>( (AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler() );
   
-if(! fHistTrackMultiplicity) { 
+  if( !lmcEvtHandler ){ // !0x0 = real data or !1 = there is an MC handler available (useMC = kTRUE in AnalysisTrainNew), so = data from MC
+        
+        // Reasonable parameters extracted for real p-p event (Dec 2009 - GSI Pass5) - A.Kalweit
+        fAlephParameters[0] = 0.0283086;        // No extra-division to apply in SetBlochParam
+        fAlephParameters[1] = 2.63394e+01;
+        fAlephParameters[2] = 5.04114e-11;
+        fAlephParameters[3] = 2.12543e+00;
+        fAlephParameters[4] = 4.88663e+00; 
+        Printf("CheckCascade - Check Aleph Param in case of REAL Data (fAlephParameters[1] = %f)\n",  fAlephParameters[1]);
+  }
+  else {
+        // Reasonable parameters extracted for p-p simulation (LHC09a4) - A.Kalweit
+         // fAlephParameters[0] = 4.23232575531564326e+00;//50*0.76176e-1; // do not forget to divide this value by 50 in SetBlochParam !
+         // fAlephParameters[1] = 8.68482806165147636e+00;//10.632; 
+         // fAlephParameters[2] = 1.34000000000000005e-05;//0.13279e-4;
+         // fAlephParameters[3] = 2.30445734159456084e+00;//1.8631;
+         // fAlephParameters[4] = 2.25624744086878559e+00;//1.9479;  
+          
+        // Reasonable parameters extracted for MC LHC09d10 event (Jan 2010) - A.Kalweit
+        fAlephParameters[0] = 2.15898e+00/50.;
+        fAlephParameters[1] = 1.75295e+01;
+        fAlephParameters[2] = 3.40030e-09;
+        fAlephParameters[3] = 1.96178e+00;
+        fAlephParameters[4] = 3.91720e+00;
+        Printf("CheckCascade - Check Aleph Param win case MC data (fAlephParameters[1] = %f)\n",  fAlephParameters[1]);
+  }
+
+  fESDpid = new AliESDpid();
+  fESDpid->GetTPCResponse().SetBetheBlochParameters( fAlephParameters[0],
+                                                     fAlephParameters[1],
+                                                     fAlephParameters[2],
+                                                     fAlephParameters[3],
+                                                     fAlephParameters[4] );
+}
+/* 
+if( !fPaveTextBookKeeping){
+        fPaveTextBookKeeping = new TPaveText(0.1, 0.1, 0.9, 0.9,"NDC");
+        fPaveTextBookKeeping->SetName("fPaveTextBookKeeping");
+        fPaveTextBookKeeping->SetBorderSize(0);
+        fPaveTextBookKeeping->SetTextAlign(12);
+        fPaveTextBookKeeping->SetFillColor(kWhite);
+        fPaveTextBookKeeping->SetTextFont(42);        // regular Arial or Helvetica,
+        fPaveTextBookKeeping->SetTextColor(kBlue+4);
+        
+        fPaveTextBookKeeping->AddText( "Task CHECK CASCADE analysis" );
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+        fPaveTextBookKeeping->AddText( Form("AnalysisType : %s ", fAnalysisType.Data() ));
+        if(!fCollidingSystems)  fPaveTextBookKeeping->AddText("Colliding system : p-p collisions ");
+        else                    fPaveTextBookKeeping->AddText("Colliding system : A-A collisions ");
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+    
+        if(fkRerunV0CascVertexers){
+                fPaveTextBookKeeping->AddText("A.1. With V0 vertexer : ");
+                fPaveTextBookKeeping->AddText( Form("  - V0 #chi^{2} _________________ <  %.3f ",               fV0Sels[0] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ 1^{st} daughter) ___ >  %.3f     cm ",  fV0Sels[1] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ 2^{nd} daughter) __  >  %.3f     cm",   fV0Sels[2] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA between V0 daughters ___ <  %.3f      cm",         fV0Sels[3] ));
+                fPaveTextBookKeeping->AddText( Form("  - cos(V0 pointing angle) _______ >  %.3f ",              fV0Sels[4] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(V0 decay) ________ >  %.3f             cm", fV0Sels[5] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(V0 decay) ________ <  %.3f         cm",     fV0Sels[6] ));
+                
+                fPaveTextBookKeeping->AddText(" "); 
+                
+                fPaveTextBookKeeping->AddText("A.2. With Casc. vertexer : ");
+                fPaveTextBookKeeping->AddText( Form("  - Casc. #chi^{2} ______________  <  %.3f ",                               fCascSels[0] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ V0) _________ >  %.3f    cm",                            fCascSels[1] ));
+                fPaveTextBookKeeping->AddText( Form("  - | M_{#Lambda}(reco) - M_{#Lambda}(pdg) | _______ <  %.3f    GeV/c^{2}", fCascSels[2] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ Bach) _______ >  %.3f    cm",                            fCascSels[3] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA between Bach/ #Lambda ______ <  %.3f    cm",                        fCascSels[4] ));
+                fPaveTextBookKeeping->AddText( Form("  - cos(Casc. pointing angle) ____ >  %.3f ",                               fCascSels[5] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(Casc. decay) ______ >  %.3f         cm",                     fCascSels[6] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(Casc. decay) ______ <  %.3f     cm",                         fCascSels[7] ));
+        }
+        else{   fPaveTextBookKeeping->AddText("A. No rerunning of the V0/Casc. vertexers ... See std cuts in (AliRoot+Rec.C) used for this prod. cycle");}
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+        
+        if(fkQualityCutZprimVtxPos)      fPaveTextBookKeeping->AddText("B. Quality Cut(prim. Vtx z-Pos)    = ON  ");
+        else                             fPaveTextBookKeeping->AddText("B. Quality Cut(prim. Vtx z-Pos)    = Off ");
+        if(fkQualityCutNoTPConlyPrimVtx) fPaveTextBookKeeping->AddText("C. Quality Cut(No TPC prim. vtx) = ON  ");
+        else                             fPaveTextBookKeeping->AddText("C. Quality Cut(No TPC prim. vtx) = Off ");
+        if(fkQualityCutTPCrefit)         fPaveTextBookKeeping->AddText("D. Quality Cut(TPCrefit)               = ON  ");
+        else                             fPaveTextBookKeeping->AddText("D. Quality Cut(TPCrefit)               = Off ");
+        if(fkQualityCut80TPCcls)         fPaveTextBookKeeping->AddText("E. Quality Cut(80 TPC clusters)   = ON  ");
+        else                             fPaveTextBookKeeping->AddText("E. Quality Cut(80 TPC clusters)   = Off ");
+        if(fkExtraSelections)            fPaveTextBookKeeping->AddText("F. Extra Analysis Selections         = ON  ");
+        else                             fPaveTextBookKeeping->AddText("F. Extra Analysis Selections         = Off ");
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+
+        fPaveTextBookKeeping->AddText("G. TPC Aleph Param : ");
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [0] =  %.5g", fAlephParameters[0] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [1] =  %.5g", fAlephParameters[1] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [2] =  %.5g", fAlephParameters[2] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [3] =  %.5g", fAlephParameters[3] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [4] =  %.5g", fAlephParameters[4] ));
+}       
+*/ 
+       // - General histos
+       //--------------
+if(! fHistCascadeMultiplicityBeforeTrigSel) {
+       if(fCollidingSystems)// AA collisions
+               fHistCascadeMultiplicityBeforeTrigSel = new TH1F("fHistCascadeMultiplicityBeforeTrigSel", 
+                       "Cascades per event (before Trig. Sel.);Nbr of Cascades/Evt;Events", 
+                       100, 0, 100);           
+       else // pp collisions
+               fHistCascadeMultiplicityBeforeTrigSel = new TH1F("fHistCascadeMultiplicityBeforeTrigSel", 
+                       "Cascades per event (before Trig. Sel.);Nbr of Cascades/Evt;Events", 
+                       25, 0, 25);
+       fListHistCascade->Add(fHistCascadeMultiplicityBeforeTrigSel);
+}
+
+        // - Histos for events passing the trigger selection
+        //--------------
+        
+if(! fHistCascadeMultiplicityForTrigEvt) {
+       if(fCollidingSystems)// AA collisions
+               fHistCascadeMultiplicityForTrigEvt = new TH1F("fHistCascadeMultiplicityForTrigEvt", 
+                       "Cascades per event (for triggered evt);Nbr of Cascades/Evt;Events", 
+                       100, 0, 100);           
+       else // pp collisions
+               fHistCascadeMultiplicityForTrigEvt = new TH1F("fHistCascadeMultiplicityForTrigEvt", 
+                       "Cascades per event (for triggered evt);Nbr of Cascades/Evt;Events", 
+                       25, 0, 25);
+       fListHistCascade->Add(fHistCascadeMultiplicityForTrigEvt);
+}
+
+if(! fHistTrackMultiplicityForTrigEvt) {       
        if(fCollidingSystems)// AA collisions   
-               fHistTrackMultiplicity = new TH1F("fHistTrackMultiplicity", 
-                       "Track Multiplicity;Nbr of tracks/Evt;Events", 
+               fHistTrackMultiplicityForTrigEvt = new TH1F("fHistTrackMultiplicityForTrigEvt", 
+                       "Track Multiplicity (for triggered evt);Nbr of tracks/Evt;Events", 
                        200, 0, 20000);                 
        else // pp collisions
-               fHistTrackMultiplicity = new TH1F("fHistTrackMultiplicity", 
-                       "Track Multiplicity;Nbr of tracks/Evt;Events", 
+               fHistTrackMultiplicityForTrigEvt = new TH1F("fHistTrackMultiplicityForTrigEvt", 
+                       "Track Multiplicity (for triggered evt);Nbr of tracks/Evt;Events", 
                        250, 0, 250);
-       fListHistCascade->Add(fHistTrackMultiplicity);
+       fListHistCascade->Add(fHistTrackMultiplicityForTrigEvt);
 }
 
-if(! fHistTPCrefitTrackMultiplicity) { 
+if(! fHistTPCrefitTrackMultiplicityForTrigEvt) {       
        if(fCollidingSystems)// AA collisions   
-               fHistTPCrefitTrackMultiplicity = new TH1F("fHistTPCrefitTrackMultiplicity", 
-                       "TPCrefit track Multiplicity;Nbr of TPCrefit tracks/Evt;Events", 
+               fHistTPCrefitTrackMultiplicityForTrigEvt = new TH1F("fHistTPCrefitTrackMultiplicityForTrigEvt", 
+                       "TPCrefit track Multiplicity (for triggered evt);Nbr of TPCrefit tracks/Evt;Events", 
                        200, 0, 20000);                 
        else // pp collisions
-               fHistTPCrefitTrackMultiplicity = new TH1F("fHistTPCrefitTrackMultiplicity", 
-                       "TPCrefit track Multiplicity;Nbr of TPCrefit tracks/Evt;Events", 
+               fHistTPCrefitTrackMultiplicityForTrigEvt = new TH1F("fHistTPCrefitTrackMultiplicityForTrigEvt", 
+                       "TPCrefit track Multiplicity (for triggered evt);Nbr of TPCrefit tracks/Evt;Events", 
                        250, 0, 250);
-       fListHistCascade->Add(fHistTPCrefitTrackMultiplicity);
+       fListHistCascade->Add(fHistTPCrefitTrackMultiplicityForTrigEvt);
 }
 
-if(! fHistCascadeMultiplicity) {
+
+        // - Histos for events passing the event selection at the analysis level
+        //--------------
+        
+if(! fHistCascadeMultiplicityForSelEvt) {
        if(fCollidingSystems)// AA collisions
-               fHistCascadeMultiplicity = new TH1F("fHistCascadeMultiplicity", 
+               fHistCascadeMultiplicityForSelEvt = new TH1F("fHistCascadeMultiplicityForSelEvt", 
                        "Cascades per event;Nbr of Cascades/Evt;Events", 
                        100, 0, 100);           
        else // pp collisions
-               fHistCascadeMultiplicity = new TH1F("fHistCascadeMultiplicity", 
+               fHistCascadeMultiplicityForSelEvt = new TH1F("fHistCascadeMultiplicityForSelEvt", 
                        "Cascades per event;Nbr of Cascades/Evt;Events", 
                        25, 0, 25);
-       fListHistCascade->Add(fHistCascadeMultiplicity);
+       fListHistCascade->Add(fHistCascadeMultiplicityForSelEvt);
+}
+
+if(! fHistPosBestPrimaryVtxXForSelEvt ){
+       fHistPosBestPrimaryVtxXForSelEvt   = new TH1F( "fHistPosBestPrimaryVtxXForSelEvt" , "Best Prim. Vertex Position in x; x (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxXForSelEvt);
+}
+
+if(! fHistPosBestPrimaryVtxYForSelEvt){
+       fHistPosBestPrimaryVtxYForSelEvt   = new TH1F( "fHistPosBestPrimaryVtxYForSelEvt" , "Best Prim. Vertex Position in y; y (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxYForSelEvt);
 }
 
+if(! fHistPosBestPrimaryVtxZForSelEvt ){
+       fHistPosBestPrimaryVtxZForSelEvt   = new TH1F( "fHistPosBestPrimaryVtxZForSelEvt" , "Best Prim. Vertex Position in z; z (cm); Events" , 100, -15.0, 15.0 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxZForSelEvt);
+}
+
+
 
 
+        // - Histos for events containing at least ONE CASCADE
+        //--------------
+        
 if(! fHistTPCrefitTrackMultiplicityForCascadeEvt) {
        if(fCollidingSystems)// AA collisions   
                fHistTPCrefitTrackMultiplicityForCascadeEvt = new TH1F("fHistTPCrefitTrackMultiplicityForCascadeEvt", 
@@ -319,20 +535,20 @@ if(! fHistVtxStatus ){
 
        // - Vertex Positions
   
-if(! fHistPosTrkgPrimaryVtxX ){
-       fHistPosTrkgPrimaryVtxX   = new TH1F( "fHistPosTrkgPrimaryVtxX" , "Trkg Prim. Vertex Position in x; x (cm); Events" , 200, -0.5, 0.5 );
-       fListHistCascade->Add(fHistPosTrkgPrimaryVtxX);
+if(! fHistPosTrkgPrimaryVtxXForCascadeEvt ){
+       fHistPosTrkgPrimaryVtxXForCascadeEvt   = new TH1F( "fHistPosTrkgPrimaryVtxXForCascadeEvt" , "Trkg Prim. Vertex Position in x; x (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosTrkgPrimaryVtxXForCascadeEvt);
 }
 
 
-if(! fHistPosTrkgPrimaryVtxY){
-       fHistPosTrkgPrimaryVtxY   = new TH1F( "fHistPosTrkgPrimaryVtxY" , "Trkg Prim. Vertex Position in y; y (cm); Events" , 200, -0.5, 0.5 );
-       fListHistCascade->Add(fHistPosTrkgPrimaryVtxY);
+if(! fHistPosTrkgPrimaryVtxYForCascadeEvt){
+       fHistPosTrkgPrimaryVtxYForCascadeEvt   = new TH1F( "fHistPosTrkgPrimaryVtxYForCascadeEvt" , "Trkg Prim. Vertex Position in y; y (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosTrkgPrimaryVtxYForCascadeEvt);
 }
 
-if(! fHistPosTrkgPrimaryVtxZ ){
-       fHistPosTrkgPrimaryVtxZ   = new TH1F( "fHistPosTrkgPrimaryVtxZ" , "Trkg Prim. Vertex Position in z; z (cm); Events" , 100, -15.0, 15.0 );
-       fListHistCascade->Add(fHistPosTrkgPrimaryVtxZ);
+if(! fHistPosTrkgPrimaryVtxZForCascadeEvt ){
+       fHistPosTrkgPrimaryVtxZForCascadeEvt   = new TH1F( "fHistPosTrkgPrimaryVtxZForCascadeEvt" , "Trkg Prim. Vertex Position in z; z (cm); Events" , 100, -15.0, 15.0 );
+       fListHistCascade->Add(fHistPosTrkgPrimaryVtxZForCascadeEvt);
 }
 
 if(! fHistTrkgPrimaryVtxRadius ){
@@ -343,19 +559,19 @@ if(! fHistTrkgPrimaryVtxRadius ){
 
 
 
-if(! fHistPosBestPrimaryVtxX ){
-       fHistPosBestPrimaryVtxX   = new TH1F( "fHistPosBestPrimaryVtxX" , "Best Prim. Vertex Position in x; x (cm); Events" , 200, -0.5, 0.5 );
-       fListHistCascade->Add(fHistPosBestPrimaryVtxX);
+if(! fHistPosBestPrimaryVtxXForCascadeEvt ){
+       fHistPosBestPrimaryVtxXForCascadeEvt   = new TH1F( "fHistPosBestPrimaryVtxXForCascadeEvt" , "Best Prim. Vertex Position in x; x (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxXForCascadeEvt);
 }
 
-if(! fHistPosBestPrimaryVtxY){
-       fHistPosBestPrimaryVtxY   = new TH1F( "fHistPosBestPrimaryVtxY" , "Best Prim. Vertex Position in y; y (cm); Events" , 200, -0.5, 0.5 );
-       fListHistCascade->Add(fHistPosBestPrimaryVtxY);
+if(! fHistPosBestPrimaryVtxYForCascadeEvt){
+       fHistPosBestPrimaryVtxYForCascadeEvt   = new TH1F( "fHistPosBestPrimaryVtxYForCascadeEvt" , "Best Prim. Vertex Position in y; y (cm); Events" , 200, -0.5, 0.5 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxYForCascadeEvt);
 }
 
-if(! fHistPosBestPrimaryVtxZ ){
-       fHistPosBestPrimaryVtxZ   = new TH1F( "fHistPosBestPrimaryVtxZ" , "Best Prim. Vertex Position in z; z (cm); Events" , 100, -15.0, 15.0 );
-       fListHistCascade->Add(fHistPosBestPrimaryVtxZ);
+if(! fHistPosBestPrimaryVtxZForCascadeEvt ){
+       fHistPosBestPrimaryVtxZForCascadeEvt   = new TH1F( "fHistPosBestPrimaryVtxZForCascadeEvt" , "Best Prim. Vertex Position in z; z (cm); Events" , 100, -15.0, 15.0 );
+       fListHistCascade->Add(fHistPosBestPrimaryVtxZForCascadeEvt);
 }
 
 if(! fHistBestPrimaryVtxRadius ){
@@ -664,46 +880,7 @@ if(! f3dHistXiPtVsEffMassVsYWith2CombPIDOmegaPlus) {
 }
 
 
-if(! fESDpid){
-               
-  Double_t lAlephParameters[5] = {0.};
-  AliMCEventHandler *lmcEvtHandler  = dynamic_cast<AliMCEventHandler*>( (AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler() );
-  
-  if( !lmcEvtHandler ){ // !0x0 = real data or !1 = there is an MC handler available (useMC = kTRUE in AnalysisTrainNew), so = data from MC
-        
-        // Reasonable parameters extracted for real p-p event (Dec 2009 - GSI Pass5) - A.Kalweit
-        lAlephParameters[0] = 0.0283086;        // No extra-division to apply in SetBlochParam
-        lAlephParameters[1] = 2.63394e+01;
-        lAlephParameters[2] = 5.04114e-11;
-        lAlephParameters[3] = 2.12543e+00;
-        lAlephParameters[4] = 4.88663e+00; 
-        Printf("CheckCascade - Check Aleph Param in case of REAL Data (lAlephParameters[1] = %f)\n",  lAlephParameters[1]);
-  }
-  else {
-        // Reasonable parameters extracted for p-p simulation (LHC09a4) - A.Kalweit
-         // lAlephParameters[0] = 4.23232575531564326e+00;//50*0.76176e-1; // do not forget to divide this value by 50 in SetBlochParam !
-         // lAlephParameters[1] = 8.68482806165147636e+00;//10.632; 
-         // lAlephParameters[2] = 1.34000000000000005e-05;//0.13279e-4;
-         // lAlephParameters[3] = 2.30445734159456084e+00;//1.8631;
-         // lAlephParameters[4] = 2.25624744086878559e+00;//1.9479;  
-          
-        // Reasonable parameters extracted for MC LHC09d10 event (Jan 2010) - A.Kalweit
-        lAlephParameters[0] = 2.15898e+00/50.;
-        lAlephParameters[1] = 1.75295e+01;
-        lAlephParameters[2] = 3.40030e-09;
-        lAlephParameters[3] = 1.96178e+00;
-        lAlephParameters[4] = 3.91720e+00;
-        Printf("CheckCascade - Check Aleph Param win case MC data (lAlephParameters[1] = %f)\n",  lAlephParameters[1]);
-  }
-
 
-  fESDpid = new AliESDpid();
-  fESDpid->GetTPCResponse().SetBetheBlochParameters(lAlephParameters[0],
-                                                lAlephParameters[1],
-                                                lAlephParameters[2],
-                                                lAlephParameters[3],
-                                                lAlephParameters[4]);
-}
 
 
 if(! f3dHistXiPtVsEffMassVsYWithTpcPIDOmegaMinus) {
@@ -889,24 +1066,20 @@ if(! fCFContCascadePIDOmegaPlus)  {
 
 
 
-
-
-
-
-
-
 // Part 3 : Towards the optimisation of topological selections -------
 if(! fCFContCascadeCuts){
    
        // Container meant to store all the relevant distributions corresponding to the cut variables.
-       // So far, 19 variables have been identified.
-       // The following will be done in quite an inelegant way.
-       // Improvement expected later.
-  const        Int_t  lNbSteps      =  2 ;
-  const Int_t  lNbVariables  =  18 ;
+       // So far, 20 variables have been identified.
+       // The following will be done in quite a brut force way ... 
+       // FIXME Improvement expected later (before Pb-Pb data at least)
+        //          - Define a user binning to have less bins in each dimension
+        //          - boolean for enabling/disbaling this CFContainer
+  const        Int_t  lNbSteps      =  4 ;
+  const Int_t  lNbVariables  =  20 ;
   
   //array for the number of bins in each dimension :
-  Int_t lNbBinsPerVar[18];
+  Int_t lNbBinsPerVar[20];
   lNbBinsPerVar[0]  = 25;
   lNbBinsPerVar[1]  = 25;
   lNbBinsPerVar[2]  = 20;
@@ -920,15 +1093,19 @@ if(! fCFContCascadeCuts){
   lNbBinsPerVar[9]  = 25;
   lNbBinsPerVar[10] = 25;
   
-  lNbBinsPerVar[11] = 60;
-  lNbBinsPerVar[12] = 50;
+  lNbBinsPerVar[11] = 100; // 2-MeV/c2 bins
+  lNbBinsPerVar[12] = 100; // 2-MeV/c2 bins
   
   lNbBinsPerVar[13] = 20;
-  lNbBinsPerVar[14] = 20;
+  
+  lNbBinsPerVar[14] = 44; // 0.05 in rapidity units
+  lNbBinsPerVar[15] = 44; // 0.05 in rapidity units
+  
+  lNbBinsPerVar[16] = 20;
  
-  lNbBinsPerVar[15] = 50;
-  lNbBinsPerVar[16] = 50;
-  lNbBinsPerVar[17] = 35;
+  lNbBinsPerVar[17] = 50;
+  lNbBinsPerVar[18] = 50;
+  lNbBinsPerVar[19] = 35;
     
  fCFContCascadeCuts = new AliCFContainer("fCFContCascadeCuts","Container for Cascade cuts", lNbSteps, lNbVariables, lNbBinsPerVar );
   
@@ -938,59 +1115,67 @@ if(! fCFContCascadeCuts){
   fCFContCascadeCuts->SetBinLimits(1,    0.0  ,  0.25 );       // DcaBachToPrimVertexXi
   fCFContCascadeCuts->SetBinLimits(2,    0.995,  1.0  );       // XiCosineOfPointingAngle
   fCFContCascadeCuts->SetBinLimits(3,    0.0  ,  4.0  );       // XiRadius
-  fCFContCascadeCuts->SetBinLimits(4,    1.1  ,  1.15  );      // InvMassLambdaAsCascDghter
+  fCFContCascadeCuts->SetBinLimits(4,    1.1  ,  1.15 );       // InvMassLambdaAsCascDghter
   fCFContCascadeCuts->SetBinLimits(5,    0.0  ,  0.6  );       // DcaV0DaughtersXi
   fCFContCascadeCuts->SetBinLimits(6,    0.98 ,  1.0  );       // V0CosineOfPointingAngleXi
   fCFContCascadeCuts->SetBinLimits(7,    0.0  , 20.0  );       // V0RadiusXi
   fCFContCascadeCuts->SetBinLimits(8,    0.0  ,  1.0  );       // DcaV0ToPrimVertexXi
   fCFContCascadeCuts->SetBinLimits(9,    0.0  ,  2.5  );       // DcaPosToPrimVertexXi
   fCFContCascadeCuts->SetBinLimits(10,   0.0  ,  2.5  );       // DcaNegToPrimVertexXi
-  fCFContCascadeCuts->SetBinLimits(11,   1.25 ,  1.45  );      // InvMassXi
+  fCFContCascadeCuts->SetBinLimits(11,   1.25 ,  1.45 );       // InvMassXi
   fCFContCascadeCuts->SetBinLimits(12,   1.6  ,  1.8  );       // InvMassOmega
-  fCFContCascadeCuts->SetBinLimits(13,   0.0  , 10.0  );       // XiTransvMom
-  fCFContCascadeCuts->SetBinLimits(14, -10.0  , 10.0  );       // BestPrimaryVtxPosZ
+  fCFContCascadeCuts->SetBinLimits(13,   0.0  , 10.0  );       // XiTransvMom 
+  fCFContCascadeCuts->SetBinLimits(14,  -1.1  ,  1.1  );       // Y(Xi)
+  fCFContCascadeCuts->SetBinLimits(15,  -1.1  ,  1.1  );       // Y(Omega)
+  fCFContCascadeCuts->SetBinLimits(16, -10.0  , 10.0  );       // BestPrimaryVtxPosZ
   if(fCollidingSystems){
-       fCFContCascadeCuts->SetBinLimits(15,   0.0, 10000.0  );    // TPCrefitTrackMultiplicity
-       fCFContCascadeCuts->SetBinLimits(16,   0.0, 10000.0  );    // SPDTrackletsMultiplicity
+       fCFContCascadeCuts->SetBinLimits(17,   0.0, 10000.0  );    // TPCrefitTrackMultiplicity
+       fCFContCascadeCuts->SetBinLimits(18,   0.0, 10000.0  );    // SPDTrackletsMultiplicity
   }
   else{  
-       fCFContCascadeCuts->SetBinLimits(15,   0.0, 250.0  );     // TPCrefitTrackMultiplicity
-       fCFContCascadeCuts->SetBinLimits(16,   0.0, 250.0  );     // SPDTrackletsMultiplicity
+       fCFContCascadeCuts->SetBinLimits(17,   0.0, 250.0  );     // TPCrefitTrackMultiplicity
+       fCFContCascadeCuts->SetBinLimits(18,   0.0, 250.0  );     // SPDTrackletsMultiplicity
   }
-  fCFContCascadeCuts->SetBinLimits(17,  25.0  ,165.0  );       // BachTPCClusters
+  fCFContCascadeCuts->SetBinLimits(19,  25.0  ,165.0  );       // BachTPCClusters
   
   
   
-  // Setting the number of steps : one for negative cascades (Xi- and Omega-), another for the positve cascades(Xi+ and Omega+)
-  fCFContCascadeCuts->SetStepTitle(0, "Negative Cascades");
-  fCFContCascadeCuts->SetStepTitle(1, "Positive Cascades");
+  // Setting the number of steps : one for each cascade species (Xi-, Xi+ and Omega-, Omega+)
+  fCFContCascadeCuts->SetStepTitle(0, "#Xi^{-} candidates");
+  fCFContCascadeCuts->SetStepTitle(1, "#bar{#Xi}^{+} candidates");
+  fCFContCascadeCuts->SetStepTitle(2, "#Omega^{-} candidates");
+  fCFContCascadeCuts->SetStepTitle(3, "#bar{#Omega}^{+} candidates");
   
   // Setting the variable title, per axis
-  // fCFContCascadeCuts->SetVarTitle(0,  "Chi2Xi");
-  fCFContCascadeCuts->SetVarTitle(0,  "DcaXiDaughters");
-  fCFContCascadeCuts->SetVarTitle(1,  "DcaBachToPrimVertexXi");
-  fCFContCascadeCuts->SetVarTitle(2,  "XiCosineOfPointingAngle");
-  fCFContCascadeCuts->SetVarTitle(3,  "XiRadius");
-  fCFContCascadeCuts->SetVarTitle(4,  "InvMassLambdaAsCascDghter");
-   // fCFContCascadeCuts->SetVarTitle(0,  "V0Chi2Xi");
-  fCFContCascadeCuts->SetVarTitle(5,  "DcaV0DaughtersXi");
-  
-  fCFContCascadeCuts->SetVarTitle(6,  "V0CosineOfPointingAngleXi");
-  fCFContCascadeCuts->SetVarTitle(7,  "V0RadiusXi");
-  fCFContCascadeCuts->SetVarTitle(8,  "DcaV0ToPrimVertexXi");
-  fCFContCascadeCuts->SetVarTitle(9,  "DcaPosToPrimVertexXi");
-  fCFContCascadeCuts->SetVarTitle(10, "DcaNegToPrimVertexXi");
-  
-  fCFContCascadeCuts->SetVarTitle(11, "InvMassXi");
-  fCFContCascadeCuts->SetVarTitle(12, "InvMassOmega");
-  
-  fCFContCascadeCuts->SetVarTitle(13, "XiTransvMom");
-  //fCFContCascadeCuts->SetVarTitle(14, "V0toXiCosineOfPointingAngle");
-  fCFContCascadeCuts->SetVarTitle(14, "BestPrimaryVtxPosZ");
-  
-  fCFContCascadeCuts->SetVarTitle(15, "TPCrefit track Multiplicity");
-  fCFContCascadeCuts->SetVarTitle(16, "SPDTrackletsMultiplicity");
-  fCFContCascadeCuts->SetVarTitle(17, "BachTPCClusters");
+  // fCFContCascadeCuts->SetVarTitle(40,  "Chi2Xi");
+  fCFContCascadeCuts->SetVarTitle(0,  "Dca(XiDaughters) (cm)");
+  fCFContCascadeCuts->SetVarTitle(1,  "Dca(Bach/PrimVertex) (cm)");
+  fCFContCascadeCuts->SetVarTitle(2,  "cos(Xi pointing angle)");
+  fCFContCascadeCuts->SetVarTitle(3,  "R_{2d}(Xi decay) (cm)");
+  fCFContCascadeCuts->SetVarTitle(4,  "M_{#Lambda}(As Casc Dghter) (GeV/c^{2})");
+   // fCFContCascadeCuts->SetVarTitle(40,  "V0Chi2Xi");
+  fCFContCascadeCuts->SetVarTitle(5,  "Dca(V0 Daughters Xi) (cm)");
+  
+  fCFContCascadeCuts->SetVarTitle(6,  "cos(V0 pointing Angle) in Casc");
+  fCFContCascadeCuts->SetVarTitle(7,  "R_{2d}(V0 decay) (cm)");
+  fCFContCascadeCuts->SetVarTitle(8,  "Dca(V0/PrimVertex) (cm)");
+  fCFContCascadeCuts->SetVarTitle(9,  "Dca(Pos/PrimVertex) (cm)");
+  fCFContCascadeCuts->SetVarTitle(10, "Dca(Neg/PrimVertex) (cm)");
+  
+  fCFContCascadeCuts->SetVarTitle(11, "Inv. Mass(Xi) (GeV/c^{2})");
+  fCFContCascadeCuts->SetVarTitle(12, "Inv. Mass(Omega) (GeV/c^{2})");
+  
+  fCFContCascadeCuts->SetVarTitle(13, "pt(Casc.) (GeV/c)");
+  //fCFContCascadeCuts->SetVarTitle(40, "V0toXiCosineOfPointingAngle");
+  
+  fCFContCascadeCuts->SetVarTitle(14, "Y(Xi)");
+  fCFContCascadeCuts->SetVarTitle(15, "Y(Omega)");
+  
+  fCFContCascadeCuts->SetVarTitle(16, "Z-position(BestPrimVtx) (cm)");
+  
+  fCFContCascadeCuts->SetVarTitle(17, "TPCrefit track Multiplicity");
+  fCFContCascadeCuts->SetVarTitle(18, "SPD tracklets Multiplicity");
+  fCFContCascadeCuts->SetVarTitle(19, "Bach.TPC Clusters");
   
   fListHistCascade->Add(fCFContCascadeCuts);
 }
@@ -1078,6 +1263,8 @@ if(! fHnSpAngularCorrOmegaPlus){
 }
 
 
+PostData(1, fListHistCascade);
+/* PostData(2, fPaveTextBookKeeping);*/
 }// end UserCreateOutputObjects
 
 
@@ -1093,9 +1280,15 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
 
         AliESDEvent *lESDevent = 0x0;
         AliAODEvent *lAODevent = 0x0;
-        Int_t ncascades                      = -1;
-        Int_t nTrackMultiplicity             = -1;
-        Int_t nTrackWithTPCrefitMultiplicity =  0;
+        Int_t    ncascades                      = -1;
+        Int_t    nTrackMultiplicity             = -1;
+        Int_t    nTrackWithTPCrefitMultiplicity =  0;
+
+        Short_t  lStatusTrackingPrimVtx         = -2;
+        Double_t lTrkgPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
+        Double_t lBestPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
+        Double_t lMagneticField                 = -10.;
+
        
        
   // Connect to the InputEvent 
@@ -1107,86 +1300,156 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
                AliWarning("ERROR: lESDevent not available \n");
                return;
        }
+        
+        fHistCascadeMultiplicityBeforeTrigSel->Fill ( lESDevent->GetNumberOfCascades() );
+        
         //-------------------------------------------------
         // 0 - Trigger managment
-       // FIXME : Check the availability of the proper trigger 
+       // NOTE : Check the availability of the proper trigger 
        
         // 1st option
                 //if( !MCEvent() ){ // 0x0 = real data or 1 = there is MC truth available, so = data from MC
                 //             if ( !( lESDevent->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) ) return;
                 //}
 
-        // 2nd option - Presuppose the presence of AliPhysicsSelectionTask
+        // 2nd option - Presuppose the presence of AliPhysicsSelectionTask FIXME FIXME FIXME FIXME FIXME
+        
         Bool_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
-        if ( ! isSelected ) return;
+        if ( ! isSelected ) { 
+                PostData(1, fListHistCascade); 
+                return;
+        }
+        
         //else Printf("Event selected ... \n");
        
         
         
         //-------------------------------------------------
         // 1 - Cascade vertexer (ESD)
-
-        // if(fAnalysisType == "ESD" ){
-        //         lESDevent->ResetCascades();
-        //         lESDevent->ResetV0s();
-        // 
-        //         AliV0vertexer V0vtxer;
-        //         AliCascadeVertexer CascVtxer;
-        // 
-        //         Double_t v0sels[]={33,    // max allowed chi2
-        //                         0.01,  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
-        //                         0.01,  // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
-        //                         2.0,   // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
-        //                         0.0,   // max allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
-        //                         0.2,   // min radius of the fiducial volume                 (LHC09a4 : 0.2)
-        //                         100    // max radius of the fiducial volume                 (LHC09a4 : 100.0)
-        //         };
-        //         V0vtxer.SetDefaultCuts(v0sels);
-        // 
-        //         Double_t xisels[]={33.,   // max allowed chi2 (same as PDC07)
-        //                         0.02,   // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
-        //                         0.008,  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
-        //                         0.01 ,  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
-        //                         0.5,    // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
-        //                         0.98,   // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
-        //                         0.2,    // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
-        //                         100     // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
-        //         };
-        //         CascVtxer.SetDefaultCuts(xisels);
-        // 
-        //         V0vtxer.Tracks2V0vertices(lESDevent);
-        //         CascVtxer.V0sTracks2CascadeVertices(lESDevent);
-        // }
-
-
+        
+        if(fkRerunV0CascVertexers){ // FIXME : relaunch V0 and Cascade vertexers
+//                 if(fAnalysisType == "ESD" ){
+//                         lESDevent->ResetCascades();
+//                         lESDevent->ResetV0s();
+//                 
+//                         AliV0vertexer lV0vtxer;
+//                         AliCascadeVertexer lCascVtxer;
+//                 
+//                         lV0vtxer.SetDefaultCuts(fV0Sels);
+//                         lCascVtxer.SetDefaultCuts(fCascSels);
+//                 
+//                         lV0vtxer.Tracks2V0vertices(lESDevent);
+//                         lCascVtxer.V0sTracks2CascadeVertices(lESDevent);
+//                 }
+        }// end if(RelaunchV0CascVertexers)
+        
         //-------------------------------------------------
        ncascades                      = lESDevent->GetNumberOfCascades();
         nTrackWithTPCrefitMultiplicity = DoESDTrackWithTPCrefitMultiplicity(lESDevent);
 
-
   }//if (fAnalysisType == "ESD")
   
+  
   if(fAnalysisType == "AOD"){  
          lAODevent = dynamic_cast<AliAODEvent*>( InputEvent() ); 
-       if (!lAODevent) {
+       if (!lAODevent) {
                AliWarning("ERROR: lAODevent not available \n");
                return;
        }
-       ncascades = lAODevent->GetNumberOfCascades();
-       // Printf("Number of cascade(s) = %d \n", ncascades);
+       ncascades                      = lAODevent->GetNumberOfCascades();
+        nTrackWithTPCrefitMultiplicity = -1;
+        
+        fHistCascadeMultiplicityBeforeTrigSel->Fill ( ncascades );
   }
-  
+
+  // For AOD or ESD ...
         nTrackMultiplicity = (InputEvent())->GetNumberOfTracks();
-       
-  
-  
-       
+
+
+        //-------------------------------------------------
+        fHistTrackMultiplicityForTrigEvt         ->Fill( nTrackMultiplicity             );
+        fHistTPCrefitTrackMultiplicityForTrigEvt ->Fill( nTrackWithTPCrefitMultiplicity );
+        fHistCascadeMultiplicityForTrigEvt       ->Fill( ncascades                      );
+
+
+
+
   // ---------------------------------------------------------------
-  // I - General histos (filled for any event)
+  // I - Global characteristics of the events + general histos (filled for any selected events and/or for the analysed events)
+
+                // - I.Step 1 : Characteristics of the event : prim. Vtx + magnetic field (ESD)
+                //-------------
+
+   if(fAnalysisType == "ESD"){
+        const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
+                // get the vtx stored in ESD found with tracks
+                lPrimaryTrackingESDVtx->GetXYZ( lTrkgPrimaryVtxPos );
+        
+        
+        const AliESDVertex *lPrimaryBestESDVtx = lESDevent->GetPrimaryVertex();        
+                // get the best primary vertex available for the event
+                // As done in AliCascadeVertexer, we keep the one which is the best one available.
+                // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
+                // This one will be used for next calculations (DCA essentially)
+                lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
+                lStatusTrackingPrimVtx  = lPrimaryTrackingESDVtx->GetStatus();
+
+        // FIXME : quality cut on the z-position of the prim vertex.
+        if(fkQualityCutZprimVtxPos) {
+                if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) { 
+                        AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !"); 
+                        PostData(1, fListHistCascade); 
+                        return; 
+                }
+        }
+        // FIXME : remove TPC-only primary vertex : retain only events with tracking + SPD vertex
+        if(fkQualityCutNoTPConlyPrimVtx) {
+                const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
+                if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingESDVtx->GetStatus() ){
+                        AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+                        PostData(1, fListHistCascade); 
+                        return;
+                }
+        }
+        
+        // NOTE : For older evts
+        
+        // As previously done in AliCascadeVertexer, we keep, between both retrieved vertices (SPD or Tracking) 
+        // the one which is the best one available.
+        // This one will be used for next calculations (DCA essentially)
+        // At that time, the TPC-only primary vertex was not considered
+        
+        
+        lMagneticField = lESDevent->GetMagneticField( );
+        // FIXME if(TMath::Abs(lMagneticField ) < 10e-6) continue;
+        
+   }// end if(ESD)
+        
+   if(fAnalysisType == "AOD"){
+        // To be developed
+        const AliAODVertex *lPrimaryBestAODVtx = lAODevent->GetPrimaryVertex();        
+       // get the best primary vertex available for the event
+       // We may keep the one which is the best one available = GetVertex(0)
+       // Pb with pile-up to expect
+       // This one will be used for next calculations (DCA essentially)
+       lPrimaryBestAODVtx->GetXYZ( lBestPrimaryVtxPos );
+        
+       lStatusTrackingPrimVtx  = -1;
+        lTrkgPrimaryVtxPos[0]   = -100.0;
+       lTrkgPrimaryVtxPos[1]   = -100.0;
+       lTrkgPrimaryVtxPos[2]   = -100.0;
+        lMagneticField = 0.;
+   }
 
-        fHistTrackMultiplicity         ->Fill( nTrackMultiplicity             );
-        fHistTPCrefitTrackMultiplicity ->Fill( nTrackWithTPCrefitMultiplicity );
-        fHistCascadeMultiplicity       ->Fill( ncascades                      );
+
+                // - I.Step 2 : Filling histos that characterize the selected event : x,y,z prim. Vtx distrib. (ESD)
+                //-------------
+
+        fHistCascadeMultiplicityForSelEvt ->Fill( ncascades );
+        fHistPosBestPrimaryVtxXForSelEvt  ->Fill( lBestPrimaryVtxPos[0] );
+        fHistPosBestPrimaryVtxYForSelEvt  ->Fill( lBestPrimaryVtxPos[1] );
+        fHistPosBestPrimaryVtxZForSelEvt  ->Fill( lBestPrimaryVtxPos[2] );
+       
 
   
   // ---------------------------------------------------------------
@@ -1200,20 +1463,17 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
 
   
         // - 0th part of initialisation : around primary vertex ...
-       Short_t  lStatusTrackingPrimVtx  = -2;
-       Double_t lTrkgPrimaryVtxPos[3]   = {-100.0, -100.0, -100.0};
-       Double_t lTrkgPrimaryVtxRadius3D = -500.0;
        
-       Double_t lBestPrimaryVtxPos[3]   = {-100.0, -100.0, -100.0};
+       Double_t lTrkgPrimaryVtxRadius3D = -500.0;
        Double_t lBestPrimaryVtxRadius3D = -500.0;
 
         // - 1st part of initialisation : variables needed to store AliESDCascade data members
        Double_t lEffMassXi      = 0. ;
-       Double_t lChi2Xi         = 0. ;
-       Double_t lDcaXiDaughters = 0. ;
-       Double_t lXiCosineOfPointingAngle = 0. ;
+       Double_t lChi2Xi         = -1. ;
+       Double_t lDcaXiDaughters = -1. ;
+       Double_t lXiCosineOfPointingAngle = -1. ;
        Double_t lPosXi[3] = { -1000.0, -1000.0, -1000.0 };
-       Double_t lXiRadius = 0. ;
+       Double_t lXiRadius = -1000. ;
         
         // - 2nd part of initialisation : Nbr of clusters within TPC for the 3 daughter cascade tracks
         Int_t    lPosTPCClusters    = -1; // For ESD only ...//FIXME : wait for availability in AOD
@@ -1222,13 +1482,13 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
                        
         // - 3rd part of initialisation : about V0 part in cascades
        Double_t lInvMassLambdaAsCascDghter = 0.;
-       Double_t lV0Chi2Xi         = 0. ;
-       Double_t lDcaV0DaughtersXi = 0.;
+       Double_t lV0Chi2Xi         = -1. ;
+       Double_t lDcaV0DaughtersXi = -1.;
                
-       Double_t lDcaBachToPrimVertexXi = 0., lDcaV0ToPrimVertexXi = 0.;
-       Double_t lDcaPosToPrimVertexXi  = 0.;
-       Double_t lDcaNegToPrimVertexXi  = 0.;
-       Double_t lV0CosineOfPointingAngleXi = 0. ;
+       Double_t lDcaBachToPrimVertexXi = -1., lDcaV0ToPrimVertexXi = -1.;
+       Double_t lDcaPosToPrimVertexXi  = -1.;
+       Double_t lDcaNegToPrimVertexXi  = -1.;
+       Double_t lV0CosineOfPointingAngleXi = -1. ;
        Double_t lPosV0Xi[3] = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
        Double_t lV0RadiusXi = -1000.0;
        Double_t lV0quality  = 0.;
@@ -1292,89 +1552,18 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        AliESDcascade *xi = lESDevent->GetCascade(iXi);
        if (!xi) continue;
        
-               // - II.Step 1 : Characteristics of the event : prim. Vtx + magnetic field (ESD)
-               //-------------
-       
-       const AliESDVertex *lPrimaryTrackingVtx = lESDevent->GetPrimaryVertexTracks();  
-               // get the vtx stored in ESD found with tracks
-       
-               lPrimaryTrackingVtx->GetXYZ( lTrkgPrimaryVtxPos );
-               lTrkgPrimaryVtxRadius3D = TMath::Sqrt(  lTrkgPrimaryVtxPos[0] * lTrkgPrimaryVtxPos[0] +
-                                                       lTrkgPrimaryVtxPos[1] * lTrkgPrimaryVtxPos[1] +
-                                                       lTrkgPrimaryVtxPos[2] * lTrkgPrimaryVtxPos[2] );
+        
+                // - II.Step 1 : around primary vertex
+                //-------------
+        lTrkgPrimaryVtxRadius3D = TMath::Sqrt(  lTrkgPrimaryVtxPos[0] * lTrkgPrimaryVtxPos[0] +
+                                                lTrkgPrimaryVtxPos[1] * lTrkgPrimaryVtxPos[1] +
+                                                lTrkgPrimaryVtxPos[2] * lTrkgPrimaryVtxPos[2] );
 
-               lStatusTrackingPrimVtx = lPrimaryTrackingVtx->GetStatus();
+        lBestPrimaryVtxRadius3D = TMath::Sqrt(  lBestPrimaryVtxPos[0] * lBestPrimaryVtxPos[0] +
+                                                lBestPrimaryVtxPos[1] * lBestPrimaryVtxPos[1] +
+                                                lBestPrimaryVtxPos[2] * lBestPrimaryVtxPos[2] );
 
 
-       const AliESDVertex *lPrimaryBestVtx = lESDevent->GetPrimaryVertex();    
-               // get the best primary vertex available for the event
-               // As done in AliCascadeVertexer, we keep the one which is the best one available.
-               // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
-               // This one will be used for next calculations (DCA essentially)
-       
-               lPrimaryBestVtx->GetXYZ( lBestPrimaryVtxPos );
-               lBestPrimaryVtxRadius3D = TMath::Sqrt(  lBestPrimaryVtxPos[0] * lBestPrimaryVtxPos[0] +
-                                                       lBestPrimaryVtxPos[1] * lBestPrimaryVtxPos[1] +
-                                                       lBestPrimaryVtxPos[2] * lBestPrimaryVtxPos[2] );
-                
-        // FIXME : quality cut on the z-position of the prim vertex.
-        Bool_t kQualityCutZprimVtxPos = kTRUE;
-        if(kQualityCutZprimVtxPos) {
-                if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) { AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !"); return; }
-        }
-        // FIXME : remove TPC-only primary vertex : retain only events with tracking + SPD vertex
-        Bool_t kQualityCutNoTPConlyPrimVtx = kTRUE;
-        if(kQualityCutNoTPConlyPrimVtx) {
-                const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();
-                if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingVtx->GetStatus() ){
-                        AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
-                        return;
-                }
-        }
-        
-                
-       
-       // For older evts
-       
-       //      const AliESDVertex *lPrimaryTrackingVtx = lESDevent->GetPrimaryVertexTracks();  
-       //              get the vtx stored in ESD found with tracks
-       //      Double_t lTrkgPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
-       //              lPrimaryTrackingVtx->GetXYZ( lTrkgPrimaryVtxPos );
-       //              Double_t lTrkgPrimaryVtxRadius3D = TMath::Sqrt( lTrkgPrimaryVtxPos[0]*lTrkgPrimaryVtxPos[0] +
-       //                                              lTrkgPrimaryVtxPos[1] * lTrkgPrimaryVtxPos[1] +
-       //                                              lTrkgPrimaryVtxPos[2] * lTrkgPrimaryVtxPos[2] );
-       // 
-       //      const AliESDVertex *lPrimarySPDVtx = lESDevent->GetPrimaryVertexSPD();  
-       //              get the vtx found by exclusive use of SPD
-       //      Double_t lSPDPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
-       //              lPrimarySPDVtx->GetXYZ( lSPDPrimaryVtxPos );
-       //              
-       //      // As done in AliCascadeVertexer, we keep, between both retrieved vertices, 
-       //      // the one which is the best one available.
-       //      // This one will be used for next calculations (DCA essentially)
-       //              
-       //              Double_t lBestPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
-       //              if( lPrimaryTrackingVtx->GetStatus() ) { // if tracking vtx = ok
-       //                      lBestPrimaryVtxPos[0] = lTrkgPrimaryVtxPos[0];
-       //                      lBestPrimaryVtxPos[1] = lTrkgPrimaryVtxPos[1];
-       //                      lBestPrimaryVtxPos[2] = lTrkgPrimaryVtxPos[2];
-       //              }
-       //              else{
-       //                      lBestPrimaryVtxPos[0] = lSPDPrimaryVtxPos[0];
-       //                      lBestPrimaryVtxPos[1] = lSPDPrimaryVtxPos[1];
-       //                      lBestPrimaryVtxPos[2] = lSPDPrimaryVtxPos[2];
-       //              }
-       //
-       //      Double_t lBestPrimaryVtxRadius3D = TMath::Sqrt( lBestPrimaryVtxPos[0]*lBestPrimaryVtxPos[0] +
-       //                                              lBestPrimaryVtxPos[1] * lBestPrimaryVtxPos[1] +
-       //                                              lBestPrimaryVtxPos[2] * lBestPrimaryVtxPos[2] );
-       
-       // Back to normal
-                       
-       Double_t lMagneticField = lESDevent->GetMagneticField( );
-        // FIXME if(TMath::Abs(lMagneticField ) < 10e-6) continue;
-       
-       
        
                // - II.Step 2 : Assigning the necessary variables for specific AliESDcascade data members (ESD)        
                //-------------
@@ -1385,8 +1574,8 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        lChi2Xi                         = xi->GetChi2Xi();
        lDcaXiDaughters                 = xi->GetDcaXiDaughters();
        lXiCosineOfPointingAngle        = xi->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0],
-                                                                               lBestPrimaryVtxPos[1],
-                                                                               lBestPrimaryVtxPos[2] );
+                                                                               lBestPrimaryVtxPos[1],
+                                                                               lBestPrimaryVtxPos[2] );
                // Take care : the best available vertex should be used (like in AliCascadeVertexer)
        
        xi->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
@@ -1425,10 +1614,7 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
         lBachTPCClusters  = bachTrackXi->GetTPCNcls(); 
 
                 // FIXME : rejection of a poor quality tracks
-        Bool_t kQualityCutTPCrefit = kTRUE;
-        Bool_t kQualityCut80TPCcls = kTRUE;
-        
-        if(kQualityCutTPCrefit){
+        if(fkQualityCutTPCrefit){
                 // 1 - Poor quality related to TPCrefit
                 ULong_t pStatus    = pTrackXi->GetStatus();
                 ULong_t nStatus    = nTrackXi->GetStatus();
@@ -1437,7 +1623,7 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
                 if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
                 if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
         }
-        if(kQualityCut80TPCcls){
+        if(fkQualityCut80TPCcls){
                 // 2 - Poor quality related to TPC clusters
                 if(lPosTPCClusters  < 80) { AliWarning("Pb / V0 Pos. track has less than 80 TPC clusters ... continue!"); continue; }
                 if(lNegTPCClusters  < 80) { AliWarning("Pb / V0 Neg. track has less than 80 TPC clusters ... continue!"); continue; }
@@ -1477,9 +1663,7 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
                // - II.Step 3' : extra-selection for cascade candidates
                // Towards optimisation of AA selection
         // FIXME
-       Bool_t kExtraSelections = kFALSE;
-       
-       if(kExtraSelections){
+       if(fkExtraSelections){
                // if(lChi2Xi > 2000) continue;
                // if(lV0Chi2Xi > 2000) continue;
                
@@ -1719,14 +1903,15 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        }
        
         // FIXME : Just to know which file is currently open : locate the file containing Xi
-        // cout << "Name of the file containing Xi candidate(s) after anti-splitting cut :" 
-        //         << CurrentFileName() 
-        //         << " / entry: "     << Entry()
-        //         << " / in file: "   << lESDevent->GetEventNumberInFile()   // <- Cvetan / From Mihaela: AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetReadEntry();
-        //         << " : mass(Xi) = " << xi->GetEffMassXi() 
-        //         << " / pt(Casc) = " << lXiTransvMom
-        //         << " / Decay 2d R(Xi) = " << lXiRadius 
-        //         << endl;
+//         cout << "Name of the file containing Xi candidate(s) :" 
+//                 << CurrentFileName() 
+//                 << " / entry: "     << Entry()
+//                 << " / in file: "   << lESDevent->GetEventNumberInFile()   // <- Cvetan / From Mihaela: AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->GetTree()->GetReadEntry();
+//                 << " : mass(Xi) = " << xi->GetEffMassXi() 
+//                 << " / charge = "   << lChargeXi
+//                 << " / pt(Casc) = " << lXiTransvMom
+//                 << " / Decay 2d R(Xi) = " << lXiRadius 
+//                 << endl;
 
        
                // II.Step 7 - Complementary info for monitoring the cascade cut variables
@@ -1761,19 +1946,10 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
                // - II.Step 1 : Characteristics of the event : prim. Vtx + magnetic field (AOD)
                //-------------
        
-       lTrkgPrimaryVtxPos[0]   = -100.0;
-       lTrkgPrimaryVtxPos[1]   = -100.0;
-       lTrkgPrimaryVtxPos[2]   = -100.0;
-       lTrkgPrimaryVtxRadius3D = -500. ;
-       // We don't have the different prim. vertex at the AOD level -> nothing to do.
 
-       const AliAODVertex *lPrimaryBestVtx = lAODevent->GetPrimaryVertex();    
-       // get the best primary vertex available for the event
-       // We may keep the one which is the best one available = GetVertex(0)
-       // Pb with pile-up to expect
-       // This one will be used for next calculations (DCA essentially)
+       lTrkgPrimaryVtxRadius3D = -500. ;
+       // FIXME : We don't have the different prim. vertex at the AOD level -> nothing to do.
 
-       lPrimaryBestVtx->GetXYZ( lBestPrimaryVtxPos );
        lBestPrimaryVtxRadius3D = TMath::Sqrt(  lBestPrimaryVtxPos[0] * lBestPrimaryVtxPos[0] +
                                                lBestPrimaryVtxPos[1] * lBestPrimaryVtxPos[1] +
                                                lBestPrimaryVtxPos[2] * lBestPrimaryVtxPos[2] );
@@ -1923,7 +2099,7 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
 
 
     // -------------------------------------
-    // II.Fill - Filling the TH1,2,3Fs
+    // II.Fill - Filling the TH1,2,3Fs, HnSparses, CFContainers, FOR events with CASCADES !
   
 
        // - II.Fill.Step 1      : primary vertex
@@ -1937,16 +2113,16 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        fHistVtxStatus                  ->Fill( lStatusTrackingPrimVtx   );  // 1 if tracking vtx = ok
 
        if( lStatusTrackingPrimVtx ){
-               fHistPosTrkgPrimaryVtxX ->Fill( lTrkgPrimaryVtxPos[0]    );
-               fHistPosTrkgPrimaryVtxY ->Fill( lTrkgPrimaryVtxPos[1]    );     
-               fHistPosTrkgPrimaryVtxZ ->Fill( lTrkgPrimaryVtxPos[2]    ); 
-               fHistTrkgPrimaryVtxRadius->Fill( lTrkgPrimaryVtxRadius3D );
+               fHistPosTrkgPrimaryVtxXForCascadeEvt  ->Fill( lTrkgPrimaryVtxPos[0]    );
+               fHistPosTrkgPrimaryVtxYForCascadeEvt  ->Fill( lTrkgPrimaryVtxPos[1]    );
+               fHistPosTrkgPrimaryVtxZForCascadeEvt  ->Fill( lTrkgPrimaryVtxPos[2]    );
+               fHistTrkgPrimaryVtxRadius             ->Fill( lTrkgPrimaryVtxRadius3D );
        }
 
-       fHistPosBestPrimaryVtxX         ->Fill( lBestPrimaryVtxPos[0]    );
-       fHistPosBestPrimaryVtxY         ->Fill( lBestPrimaryVtxPos[1]    );
-       fHistPosBestPrimaryVtxZ         ->Fill( lBestPrimaryVtxPos[2]    );
-       fHistBestPrimaryVtxRadius       ->Fill( lBestPrimaryVtxRadius3D  );
+       fHistPosBestPrimaryVtxXForCascadeEvt   ->Fill( lBestPrimaryVtxPos[0]    );
+       fHistPosBestPrimaryVtxYForCascadeEvt   ->Fill( lBestPrimaryVtxPos[1]    );
+       fHistPosBestPrimaryVtxZForCascadeEvt   ->Fill( lBestPrimaryVtxPos[2]    );
+       fHistBestPrimaryVtxRadius              ->Fill( lBestPrimaryVtxRadius3D  );
        
        f2dHistTrkgPrimVtxVsBestPrimVtx->Fill( lTrkgPrimaryVtxRadius3D, lBestPrimaryVtxRadius3D );
 
@@ -2197,7 +2373,7 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        
        
        // II.Fill.Step 7 : filling the AliCFContainer (optimisation of topological selections)
-       Double_t lContainerCutVars[18] = {0.0};
+       Double_t lContainerCutVars[20] = {0.0};
                        
        lContainerCutVars[0]  = lDcaXiDaughters;
        lContainerCutVars[1]  = lDcaBachToPrimVertexXi;
@@ -2210,24 +2386,40 @@ void AliAnalysisTaskCheckCascade::UserExec(Option_t *)
        lContainerCutVars[8]  = lDcaV0ToPrimVertexXi;   
        lContainerCutVars[9]  = lDcaPosToPrimVertexXi;
        lContainerCutVars[10] = lDcaNegToPrimVertexXi;
+        
+       lContainerCutVars[13] = lXiTransvMom;
+        
+       lContainerCutVars[16] = lBestPrimaryVtxPos[2];
+       lContainerCutVars[17] = nTrackWithTPCrefitMultiplicity;  // FIXME : nTrackWithTPCrefitMultiplicity not checked for AOD ... = 0
+       lContainerCutVars[18] = lSPDTrackletsMultiplicity;       // FIXME : SPDTrackletsMultiplicity is not available for AOD ... = -1
+       lContainerCutVars[19] = lBachTPCClusters;                // FIXME : BachTPCClusters          is not available for AOD ... = -1
        
-       if( lChargeXi < 0 ) { 
-               lContainerCutVars[11] = lInvMassXiMinus;
-               lContainerCutVars[12] = lInvMassOmegaMinus;
-       }
-       else {
-               lContainerCutVars[11] = lInvMassXiPlus;
-               lContainerCutVars[12] = lInvMassOmegaPlus;
-       }
-       
-       lContainerCutVars[13] = lXiTransvMom;   
-       lContainerCutVars[14] = lBestPrimaryVtxPos[2];
-       lContainerCutVars[15] = nTrackWithTPCrefitMultiplicity;  // FIXME : nTrackWithTPCrefitMultiplicity not checked for AOD ... = 0
-       lContainerCutVars[16] = lSPDTrackletsMultiplicity; // FIXME : SPDTrackletsMultiplicity is not available for AOD ... = -1
-       lContainerCutVars[17] = lBachTPCClusters;          // FIXME : BachTPCClusters          is not available for AOD ... = -1
-       
-       if( lChargeXi < 0 ) fCFContCascadeCuts->Fill(lContainerCutVars,0); // for negative cascades = Xi- and Omega-
-       else                fCFContCascadeCuts->Fill(lContainerCutVars,1); // for negative cascades = Xi+ and Omega+
+       if( lChargeXi < 0 ) {
+                lContainerCutVars[11] = lInvMassXiMinus;
+                lContainerCutVars[12] = 1.75;
+                lContainerCutVars[14] = lRapXi;
+                lContainerCutVars[15] = -1.;
+                        fCFContCascadeCuts->Fill(lContainerCutVars,0); // for Xi-
+
+                lContainerCutVars[11] = 1.4;
+                lContainerCutVars[12] = lInvMassOmegaMinus;
+                lContainerCutVars[14] = -1.;
+                lContainerCutVars[15] = lRapOmega;
+                        fCFContCascadeCuts->Fill(lContainerCutVars,2); // for Omega-
+        }
+       else{
+                lContainerCutVars[11] = lInvMassXiPlus;
+                lContainerCutVars[12] = 1.75;
+                lContainerCutVars[14] = lRapXi;
+                lContainerCutVars[15] = -1.; 
+                        fCFContCascadeCuts->Fill(lContainerCutVars,1); // for Xi+
+
+                lContainerCutVars[11] = 1.4;
+                lContainerCutVars[12] = lInvMassOmegaPlus;
+                lContainerCutVars[14] = -1.;
+                lContainerCutVars[15] = lRapOmega;
+                        fCFContCascadeCuts->Fill(lContainerCutVars,3); // for Omega+
+        }
   
                        
        // II.Fill.Step 8 :  angular correlations
@@ -2372,14 +2564,14 @@ void AliAnalysisTaskCheckCascade::Terminate(Option_t *)
                AliWarning("ERROR - AliAnalysisTaskCheckCascade: ouput data container list not available\n"); return;
        }
 
-  fHistTrackMultiplicity = dynamic_cast<TH1F*> (   cRetrievedList->FindObject("fHistTrackMultiplicity") );
-  if (!fHistTrackMultiplicity) {
-               AliWarning("ERROR - AliAnalysisTaskCheckCascade: fHistTrackMultiplicity not available\n"); return;
+  fHistTrackMultiplicityForTrigEvt = dynamic_cast<TH1F*> (   cRetrievedList->FindObject("fHistTrackMultiplicityForTrigEvt") );
+  if (!fHistTrackMultiplicityForTrigEvt) {
+               AliWarning("ERROR - AliAnalysisTaskCheckCascade: fHistTrackMultiplicityForTrigEvt not available\n"); return;
        }
  
-  fHistCascadeMultiplicity = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistCascadeMultiplicity") );
-       if (!fHistCascadeMultiplicity) {
-               AliWarning("ERROR - AliAnalysisTaskCheckCascade: fHistCascadeMultiplicity not available\n"); return;
+  fHistCascadeMultiplicityForTrigEvt = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistCascadeMultiplicityForTrigEvt") );
+       if (!fHistCascadeMultiplicityForTrigEvt) {
+               AliWarning("ERROR - AliAnalysisTaskCheckCascade: fHistCascadeMultiplicityForTrigEvt not available\n"); return;
        }
        
   fHistMassXiMinus    = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistMassXiMinus") );        
@@ -2404,21 +2596,21 @@ void AliAnalysisTaskCheckCascade::Terminate(Option_t *)
   
   canCheckCascade->cd(1);
   canCheckCascade->cd(1)->SetLogy();
-  fHistTrackMultiplicity->SetMarkerStyle(kFullStar);  
-  fHistTrackMultiplicity->GetXaxis()->SetLabelFont(42);
-  fHistTrackMultiplicity->GetYaxis()->SetLabelFont(42);
-  fHistTrackMultiplicity->SetTitleFont(42, "xy");
-  fHistTrackMultiplicity->GetXaxis()->SetTitleOffset(1.1);
-  fHistTrackMultiplicity->DrawCopy("H");
+  fHistTrackMultiplicityForTrigEvt->SetMarkerStyle(kFullStar);  
+  fHistTrackMultiplicityForTrigEvt->GetXaxis()->SetLabelFont(42);
+  fHistTrackMultiplicityForTrigEvt->GetYaxis()->SetLabelFont(42);
+  fHistTrackMultiplicityForTrigEvt->SetTitleFont(42, "xy");
+  fHistTrackMultiplicityForTrigEvt->GetXaxis()->SetTitleOffset(1.1);
+  fHistTrackMultiplicityForTrigEvt->DrawCopy("H");
   
   canCheckCascade->cd(2);  
   canCheckCascade->cd(2)->SetLogy();
-  fHistCascadeMultiplicity->SetMarkerStyle(kOpenSquare);
-  fHistCascadeMultiplicity->GetXaxis()->SetLabelFont(42);
-  fHistCascadeMultiplicity->GetYaxis()->SetLabelFont(42);
-  fHistCascadeMultiplicity->SetTitleFont(42, "xy");
-  fHistCascadeMultiplicity->GetXaxis()->SetTitleOffset(1.1);
-  fHistCascadeMultiplicity->DrawCopy("E");
+  fHistCascadeMultiplicityForTrigEvt->SetMarkerStyle(kOpenSquare);
+  fHistCascadeMultiplicityForTrigEvt->GetXaxis()->SetLabelFont(42);
+  fHistCascadeMultiplicityForTrigEvt->GetYaxis()->SetLabelFont(42);
+  fHistCascadeMultiplicityForTrigEvt->SetTitleFont(42, "xy");
+  fHistCascadeMultiplicityForTrigEvt->GetXaxis()->SetTitleOffset(1.1);
+  fHistCascadeMultiplicityForTrigEvt->DrawCopy("E");
   
   canCheckCascade->cd(3);  
   fHistMassXiMinus ->SetMarkerStyle(kFullCircle);
index 47fd73c..342a548 100644 (file)
@@ -13,7 +13,7 @@
 //              3. Supply an AliCFContainer meant to define the optimised topological selections
 //              4. Rough azimuthal correlation study (Eta, Phi)
 //            Adapted to Cascade : A.Maire Mar2008, antonin.maire@ires.in2p3.fr
-//            Modified :           A.Maire Jan2010, antonin.maire@ires.in2p3.fr
+//            Modified :           A.Maire Mar2010, antonin.maire@ires.in2p3.fr
 //-----------------------------------------------------------------
 
 class TList;
@@ -37,7 +37,7 @@ class AliAnalysisTaskCheckCascade : public AliAnalysisTaskSE {
  public:
   AliAnalysisTaskCheckCascade();
   AliAnalysisTaskCheckCascade(const char *name);
-  virtual ~AliAnalysisTaskCheckCascade() {}
+  virtual ~AliAnalysisTaskCheckCascade();
   
   virtual void   UserCreateOutputObjects();
   virtual void   UserExec(Option_t *option);
@@ -50,30 +50,59 @@ class AliAnalysisTaskCheckCascade : public AliAnalysisTaskSE {
   
   virtual void   Terminate(Option_t *);
   
-  void SetCollidingSystems(Short_t collidingSystems = 0)     {fCollidingSystems = collidingSystems;}
-  void SetAnalysisType    (const char* analysisType = "ESD") {fAnalysisType = analysisType;}
-  
-  
+  void SetCollidingSystems           (Short_t collidingSystems          = 0    ) { fCollidingSystems = collidingSystems;}
+  void SetAnalysisType               (const char* analysisType          = "ESD") { fAnalysisType     = analysisType;}
+  void SetRelaunchV0CascVertexers    (Bool_t rerunV0CascVertexers       = 0    ) { fkRerunV0CascVertexers       =  rerunV0CascVertexers;   }
+  void SetQualityCutZprimVtxPos      (Bool_t qualityCutZprimVtxPos      = kTRUE) { fkQualityCutZprimVtxPos      =  qualityCutZprimVtxPos;     }
+  void SetQualityCutNoTPConlyPrimVtx (Bool_t qualityCutNoTPConlyPrimVtx = kTRUE) { fkQualityCutNoTPConlyPrimVtx =  qualityCutNoTPConlyPrimVtx;}
+  void SetQualityCutTPCrefit         (Bool_t qualityCutTPCrefit         = kTRUE) { fkQualityCutTPCrefit         =  qualityCutTPCrefit;        }
+  void SetQualityCut80TPCcls         (Bool_t qualityCut80TPCcls         = kTRUE) { fkQualityCut80TPCcls         =  qualityCut80TPCcls;        }
+  void SetExtraSelections            (Bool_t extraSelections            = 0    ) { fkExtraSelections            =  extraSelections;           }
+
+
  private:
         // Note : In ROOT, "//!" means "do not stream the data from Master node to Worker node" ...
         // your data member object is created on the worker nodes and streaming is not needed.
         // http://root.cern.ch/download/doc/11InputOutput.pdf, page 14
 
 
-        TString         fAnalysisType;         // "ESD" or "AOD" analysis type 
-        Short_t         fCollidingSystems;     // 0 = pp collisions or 1 = AA collisions
+        TString         fAnalysisType;                  // "ESD" or "AOD" analysis type        
+        Short_t         fCollidingSystems;              // 0 = pp collisions or 1 = AA collisions
 
-        AliESDpid       *fESDpid;               // Tool data member to manage the TPC Bethe-Bloch info
+        AliESDpid       *fESDpid;                       // Tool data member to manage the TPC Bethe-Bloch info
+        //TPaveText       *fPaveTextBookKeeping;          // TString to store all the relevant info necessary for book keeping (v0 cuts, cascade cuts, quality cuts, ...)
 
+        Bool_t          fkRerunV0CascVertexers;         // Boolean : kTRUE = relaunch both V0 + Cascade vertexers
+        Bool_t          fkQualityCutZprimVtxPos;        // Boolean : kTRUE = cut on the prim.vtx  z-position
+        Bool_t          fkQualityCutNoTPConlyPrimVtx;   // Boolean : kTRUE = prim vtx should be SPD or Tracking vertex
+        Bool_t          fkQualityCutTPCrefit;           // Boolean : kTRUE = ask for TPCrefit for the 3 daughter tracks
+        Bool_t          fkQualityCut80TPCcls;           // Boolean : kTRUE = ask for 80 TPC clusters for each daughter track
+        Bool_t          fkExtraSelections;              // Boolean : kTRUE = apply tighter selections, before starting the analysis
+        
+        Double_t        fAlephParameters[5];            // Array to store the 5 param values for the TPC Bethe-Bloch parametrisation
+        Double_t        fV0Sels[7];                     // Array to store the 7 values for the different selections V0 related (if fkRerunV0CascVertexers)
+        Double_t        fCascSels[8];                   // Array to store the 8 values for the different selections Casc. related (if fkRerunV0CascVertexers)
 
 
              TList      *fListHistCascade;              //! List of Cascade histograms
-
-        // - General histos (filled for any event)
-        TH1F   *fHistTrackMultiplicity;                //! Track multiplicity distribution (without any cut = include ITS stand-alone + global tracks)
-        TH1F   *fHistTPCrefitTrackMultiplicity;        //! Track multiplicity distribution for tracks with TPCrefit
-        TH1F   *fHistCascadeMultiplicity;              //! Cascade multiplicity distribution
-
+        
+        // - General histos (filled before the trigger selection)
+        TH1F    *fHistCascadeMultiplicityBeforeTrigSel; //! Cascade multiplicity distribution
+         
+        // - General histos (filled for any triggered event)
+        TH1F    *fHistCascadeMultiplicityForTrigEvt;              //! Cascade multiplicity distribution
+        TH1F    *fHistTrackMultiplicityForTrigEvt;                //! Track multiplicity distribution (without any cut = include ITS stand-alone + global tracks)
+        TH1F    *fHistTPCrefitTrackMultiplicityForTrigEvt;        //! Track multiplicity distribution for tracks with TPCrefit
+        
+
+        // - General histos (filled for events selected in this analysis (|z(prim. vtx)| < 10 cm + prim vtx = SPD or Tracking) )
+        TH1F    *fHistCascadeMultiplicityForSelEvt;     //! Cascade multiplicity distribution
+        TH1F    *fHistPosBestPrimaryVtxXForSelEvt;      //! (best) primary vertex position distribution in x 
+        TH1F    *fHistPosBestPrimaryVtxYForSelEvt;      //! (best) primary vertex position distribution in y
+        TH1F    *fHistPosBestPrimaryVtxZForSelEvt;      //! (best) primary vertex position distribution in z
+        
+        
+        
 
         // - Characteristics for event with >1 cascade : Track Multiplicity, TPC clusters + Prim. vertex positions
         TH1F   *fHistTPCrefitTrackMultiplicityForCascadeEvt;   //! TPCrefit Track multiplicity distribution for event with >1 cascade candidate (NB: after quality sel. within the task)
@@ -84,16 +113,16 @@ class AliAnalysisTaskCheckCascade : public AliAnalysisTaskSE {
 
         TH1F    *fHistVtxStatus;                        //! Is there a tracking vertex in the cascade event ?
 
-                // Vtx coming from the full tracking
-        TH1F    *fHistPosTrkgPrimaryVtxX;               //! primary vertex position distribution in x 
-        TH1F    *fHistPosTrkgPrimaryVtxY;               //! primary vertex position distribution in y
-        TH1F    *fHistPosTrkgPrimaryVtxZ;               //! primary vertex position distribution in z
+                // Vtx coming from the full tracking, for events containing at least a cascade
+        TH1F    *fHistPosTrkgPrimaryVtxXForCascadeEvt;  //! primary vertex position distribution in x 
+        TH1F    *fHistPosTrkgPrimaryVtxYForCascadeEvt;  //! primary vertex position distribution in y
+        TH1F    *fHistPosTrkgPrimaryVtxZForCascadeEvt;  //! primary vertex position distribution in z
         TH1F    *fHistTrkgPrimaryVtxRadius;             //! primary vertex (3D) radius distribution 
 
-                // Best primary Vtx available for the event
-        TH1F    *fHistPosBestPrimaryVtxX;               //! (best) primary vertex position distribution in x 
-        TH1F    *fHistPosBestPrimaryVtxY;               //! (best) primary vertex position distribution in y
-        TH1F    *fHistPosBestPrimaryVtxZ;               //! (best) primary vertex position distribution in z
+                // Best primary Vtx available, for events containing at least a cascade
+        TH1F    *fHistPosBestPrimaryVtxXForCascadeEvt;  //! (best) primary vertex position distribution in x 
+        TH1F    *fHistPosBestPrimaryVtxYForCascadeEvt;  //! (best) primary vertex position distribution in y
+        TH1F    *fHistPosBestPrimaryVtxZForCascadeEvt;  //! (best) primary vertex position distribution in z
         TH1F    *fHistBestPrimaryVtxRadius;             //! (best) primary vertex radius distribution 
 
                 // Correlation Best Vtx / Full Tracking Vtx
@@ -192,8 +221,8 @@ class AliAnalysisTaskCheckCascade : public AliAnalysisTaskSE {
        
        
        
-       // PART 3 : Towards the optimisation of topological selections
-       AliCFContainer  *fCFContCascadeCuts;            //! Container meant to store all the relevant distributions corresponding to the cut variables
+       // PART 3 : Towards the optimisation of topological selections / systematics
+       AliCFContainer  *fCFContCascadeCuts;            //! Container meant to store all the relevant distributions corresponding to the cut variables
        
        
        // PART 4 :  Azimuthal correlation study
@@ -206,7 +235,7 @@ class AliAnalysisTaskCheckCascade : public AliAnalysisTaskSE {
   AliAnalysisTaskCheckCascade(const AliAnalysisTaskCheckCascade&);            // not implemented
   AliAnalysisTaskCheckCascade& operator=(const AliAnalysisTaskCheckCascade&); // not implemented
   
-  ClassDef(AliAnalysisTaskCheckCascade, 10);
+  ClassDef(AliAnalysisTaskCheckCascade, 11);
 };
 
 #endif
index c3b4d34..d76e163 100644 (file)
 #include "AliHeader.h"
 #include "AliMCEvent.h"
 #include "AliStack.h"
+#include "AliMultiplicity.h"
 #include "AliInputEventHandler.h"
 #include "AliAnalysisManager.h"
 
 #include "AliCFContainer.h"
 #include "AliESDpid.h"
-// #include "AliV0vertexer.h"
-// #include "AliCascadeVertexer.h"
+//      #include "AliV0vertexer.h"
+//      #include "AliCascadeVertexer.h"
 #include "AliESDEvent.h"
 #include "AliESDcascade.h"
 
@@ -56,7 +57,13 @@ ClassImp(AliAnalysisTaskCheckPerformanceCascade)
      //_____Dummy constructor________________________________________________________________
 AliAnalysisTaskCheckPerformanceCascade::AliAnalysisTaskCheckPerformanceCascade() 
 : AliAnalysisTaskSE(), // <- take care to AliAnalysisTask( empty )
-  fDebugCascade(0), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0),
+  fDebugCascade(0), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0), /*fPaveTextBookKeeping(0),*/
+    fkRerunV0CascVertexers      (0),
+    fkQualityCutZprimVtxPos     (kTRUE),
+    fkQualityCutNoTPConlyPrimVtx(kTRUE),
+    fkQualityCutTPCrefit        (kTRUE),
+    fkQualityCut80TPCcls        (kTRUE),
+    fkExtraSelections           (0),
     
        // - Cascade part initialisation
 fListHistCascade(0),
@@ -193,10 +200,15 @@ fListHistCascade(0),
     fCFContCascadePIDAsXiMinus(0),
     fCFContCascadePIDAsXiPlus(0),
     fCFContCascadePIDAsOmegaMinus(0),
-    fCFContCascadePIDAsOmegaPlus(0)
+    fCFContCascadePIDAsOmegaPlus(0),
+
+    fCFContAsCascadeCuts(0)
 
 {
 // Dummy constructor
+        for(Int_t iAlephIdx   = 0; iAlephIdx   < 5; iAlephIdx++   ) { fAlephParameters [iAlephIdx]    = -1.; }
+        for(Int_t iV0selIdx   = 0; iV0selIdx   < 7; iV0selIdx++   ) { fV0Sels          [iV0selIdx   ] = -1.; }
+        for(Int_t iCascSelIdx = 0; iCascSelIdx < 8; iCascSelIdx++ ) { fCascSels        [iCascSelIdx ] = -1.; }
 }
      
        
@@ -205,7 +217,13 @@ fListHistCascade(0),
 //_____Non-default Constructor________________________________________________________________
 AliAnalysisTaskCheckPerformanceCascade::AliAnalysisTaskCheckPerformanceCascade(const char *name) 
   : AliAnalysisTaskSE(name),
-    fDebugCascade(0), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0),
+    fDebugCascade(0), fAnalysisType("ESD"), fCollidingSystems(0), fESDpid(0),  /*fPaveTextBookKeeping(0),*/
+    fkRerunV0CascVertexers      (0),
+    fkQualityCutZprimVtxPos     (kTRUE),
+    fkQualityCutNoTPConlyPrimVtx(kTRUE),
+    fkQualityCutTPCrefit        (kTRUE),
+    fkQualityCut80TPCcls        (kTRUE),
+    fkExtraSelections           (0),
       
        // - Cascade part initialisation
 fListHistCascade(0),
@@ -342,21 +360,56 @@ fListHistCascade(0),
     fCFContCascadePIDAsXiMinus(0),
     fCFContCascadePIDAsXiPlus(0),
     fCFContCascadePIDAsOmegaMinus(0),
-    fCFContCascadePIDAsOmegaPlus(0)    
+    fCFContCascadePIDAsOmegaPlus(0),
+
+    fCFContAsCascadeCuts(0)
 
 {
   // Constructor
 
   // Define input and output slots here
-       // Input slot #0 works with a TChain
-       //DefineInput(0, TChain::Class());
-  // Output slot #0 writes into a TList container (cascade)
+  // Input slot #0 works with a TChain
+  // Output slot #1 writes into a TList container (cascade)
+        
+        for(Int_t iAlephIdx   = 0; iAlephIdx   < 5; iAlephIdx++   ) { fAlephParameters [iAlephIdx]    = -1.; }
+        
+        fV0Sels[0] =  33.  ;  // max allowed chi2
+        fV0Sels[1] =   0.01;  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
+        fV0Sels[2] =   0.01;  // 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.0 ;  // min allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
+        fV0Sels[5] =   0.2 ;  // min radius of the fiducial volume                 (LHC09a4 : 0.2)
+        fV0Sels[6] = 100.  ;  // max radius of the fiducial volume                 (LHC09a4 : 100.0)
+        
+        fCascSels[0] =  33.   ;  // max allowed chi2 (same as PDC07)
+        fCascSels[1] =   0.01 ;  // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
+        fCascSels[2] =   0.008;  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
+        fCascSels[3] =   0.01 ;  // 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.98 ;  // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
+        fCascSels[6] =   0.2  ;  // 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   )
+        
+
   DefineOutput(1, TList::Class());
  
 }
 
 
+AliAnalysisTaskCheckPerformanceCascade::~AliAnalysisTaskCheckPerformanceCascade()
+{
+  //
+  // Destructor
+  //
 
+  // For all TH1, 2, 3 HnSparse and CFContainer are in the fListCascade TList.
+  // They will be deleted when fListCascade is deleted by the TSelector dtor
+  // Because of TList::SetOwner()
+
+  if (fListHistCascade)      { delete fListHistCascade;     fListHistCascade = 0x0;  }  
+  if (fESDpid)               { delete fESDpid;              fESDpid = 0x0;} // fESDpid is not stored into the TList
+  /*if (fPaveTextBookKeeping)  { delete fPaveTextBookKeeping; fPaveTextBookKeeping = 0x0; } // fPaveTextBookKeeping is not stored into the TList*/
+}
 
 
 //________________________________________________________________________
@@ -370,36 +423,103 @@ void AliAnalysisTaskCheckPerformanceCascade::UserCreateOutputObjects()
        AliLog::SetGlobalLogLevel(AliLog::kError); 
        // to suppress the extensive info prompted by a run with MC                     
 
+   // Definition of the output datamembers     
+   fListHistCascade = new TList();
+   fListHistCascade->SetOwner(); // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
+        
 if(! fESDpid){
-               
-  Double_t lAlephParameters[5] = {0.};
-       // Reasonable parameters extracted for p-p simulation (LHC09a4) - A.Kalweit
-       // lAlephParameters[0] = 4.23232575531564326e+00/50;//50*0.76176e-1;
-       // lAlephParameters[1] = 8.68482806165147636e+00;//10.632; 
-       // lAlephParameters[2] = 1.34000000000000005e-05;//0.13279e-4;
-       // lAlephParameters[3] = 2.30445734159456084e+00;//1.8631;
-       // lAlephParameters[4] = 2.25624744086878559e+00;//1.9479;
+
+       // Reasonable parameters extracted for p-p simulation (LHC09a4) - A.Kalweit
+       // fAlephParameters[0] = 4.23232575531564326e+00/50;//50*0.76176e-1;
+       // fAlephParameters[1] = 8.68482806165147636e+00;//10.632; 
+       // fAlephParameters[2] = 1.34000000000000005e-05;//0.13279e-4;
+       // fAlephParameters[3] = 2.30445734159456084e+00;//1.8631;
+       // fAlephParameters[4] = 2.25624744086878559e+00;//1.9479;
         
         // Param for LHC09d10 prod - A.Kalweit
-        lAlephParameters[0] = 2.15898e+00/50.;
-        lAlephParameters[1] = 1.75295e+01;
-        lAlephParameters[2] = 3.40030e-09;
-        lAlephParameters[3] = 1.96178e+00;
-        lAlephParameters[4] = 3.91720e+00; 
+        fAlephParameters[0] = 2.15898e+00/50.;
+        fAlephParameters[1] = 1.75295e+01;
+        fAlephParameters[2] = 3.40030e-09;
+        fAlephParameters[3] = 1.96178e+00;
+        fAlephParameters[4] = 3.91720e+00; 
         
   fESDpid = new AliESDpid();
-  fESDpid->GetTPCResponse().SetBetheBlochParameters(lAlephParameters[0],
-                                         lAlephParameters[1],
-                                         lAlephParameters[2],
-                                         lAlephParameters[3],
-                                         lAlephParameters[4]);
+  fESDpid->GetTPCResponse().SetBetheBlochParameters( fAlephParameters[0],
+                                                     fAlephParameters[1],
+                                                     fAlephParameters[2],
+                                                     fAlephParameters[3],
+                                                     fAlephParameters[4] );
 }
-       
-       
-  // Definition of the datamembers     
-  fListHistCascade = new TList();
 
-  
+/*
+if( !fPaveTextBookKeeping){
+        fPaveTextBookKeeping = new TPaveText(0.1, 0.1, 0.9, 0.9,"NDC");
+        fPaveTextBookKeeping->SetName("fPaveTextBookKeeping");
+        fPaveTextBookKeeping->SetBorderSize(0);
+        fPaveTextBookKeeping->SetTextAlign(12);
+        fPaveTextBookKeeping->SetFillColor(kWhite);
+        fPaveTextBookKeeping->SetTextFont(42);        // regular Arial or Helvetica,
+        fPaveTextBookKeeping->SetTextColor(kGray+3);
+        
+        
+        fPaveTextBookKeeping->AddText( "Task CHECK PERFORMANCE CASCADE analysis" );
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+        fPaveTextBookKeeping->AddText( Form("AnalysisType : %s ", fAnalysisType.Data() ));
+        if(!fCollidingSystems)  fPaveTextBookKeeping->AddText("Colliding system : p-p collisions ");
+        else                    fPaveTextBookKeeping->AddText("Colliding system : A-A collisions ");
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+    
+        if(fkRerunV0CascVertexers){
+                fPaveTextBookKeeping->AddText("A.1. With V0 vertexer : ");
+                fPaveTextBookKeeping->AddText( Form("  - V0 #chi^{2} _________________ <  %.3f ",               fV0Sels[0] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ 1^{st} daughter) ___ >  %.3f     cm ",  fV0Sels[1] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ 2^{nd} daughter) __  >  %.3f     cm",   fV0Sels[2] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA between V0 daughters ___ <  %.3f      cm",         fV0Sels[3] ));
+                fPaveTextBookKeeping->AddText( Form("  - cos(V0 pointing angle) _______ >  %.3f ",              fV0Sels[4] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(V0 decay) ________ >  %.3f             cm", fV0Sels[5] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(V0 decay) ________ <  %.3f         cm",     fV0Sels[6] ));
+                
+                fPaveTextBookKeeping->AddText(" "); 
+                
+                fPaveTextBookKeeping->AddText("A.2. With Casc. vertexer : ");
+                fPaveTextBookKeeping->AddText( Form("  - Casc. #chi^{2} ______________  <  %.3f ",                               fCascSels[0] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ V0) _________ >  %.3f    cm",                            fCascSels[1] ));
+                fPaveTextBookKeeping->AddText( Form("  - | M_{#Lambda}(reco) - M_{#Lambda}(pdg) | _______ <  %.3f    GeV/c^{2}", fCascSels[2] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA(prim. Vtx/ Bach) _______ >  %.3f    cm",                            fCascSels[3] ));
+                fPaveTextBookKeeping->AddText( Form("  - DCA between Bach/ #Lambda ______ <  %.3f    cm",                        fCascSels[4] ));
+                fPaveTextBookKeeping->AddText( Form("  - cos(Casc. pointing angle) ____ >  %.3f ",                               fCascSels[5] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(Casc. decay) ______ >  %.3f         cm",                     fCascSels[6] ));
+                fPaveTextBookKeeping->AddText( Form("  - R_{transv}(Casc. decay) ______ <  %.3f     cm",                         fCascSels[7] ));
+        }
+        else{   fPaveTextBookKeeping->AddText("A. No rerunning of the V0/Casc. vertexers ... See std cuts in (AliRoot+Rec.C) used for this prod. cycle");}
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+        
+        if(fkQualityCutZprimVtxPos)      fPaveTextBookKeeping->AddText("B. Quality Cut(prim. Vtx z-Pos)    = ON  ");
+        else                             fPaveTextBookKeeping->AddText("B. Quality Cut(prim. Vtx z-Pos)    = Off ");
+        if(fkQualityCutNoTPConlyPrimVtx) fPaveTextBookKeeping->AddText("C. Quality Cut(No TPC prim. vtx) = ON  ");
+        else                             fPaveTextBookKeeping->AddText("C. Quality Cut(No TPC prim. vtx) = Off ");
+        if(fkQualityCutTPCrefit)         fPaveTextBookKeeping->AddText("D. Quality Cut(TPCrefit)               = ON  ");
+        else                             fPaveTextBookKeeping->AddText("D. Quality Cut(TPCrefit)               = Off ");
+        if(fkQualityCut80TPCcls)         fPaveTextBookKeeping->AddText("E. Quality Cut(80 TPC clusters)   = ON  ");
+        else                             fPaveTextBookKeeping->AddText("E. Quality Cut(80 TPC clusters)   = Off ");
+        if(fkExtraSelections)            fPaveTextBookKeeping->AddText("F. Extra Analysis Selections         = ON  ");
+        else                             fPaveTextBookKeeping->AddText("F. Extra Analysis Selections         = Off ");
+
+        fPaveTextBookKeeping->AddText("- - - - - - - - - - - ");
+
+        fPaveTextBookKeeping->AddText("G. TPC Aleph Param : ");
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [0] =  %.5g", fAlephParameters[0] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [1] =  %.5g", fAlephParameters[1] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [2] =  %.5g", fAlephParameters[2] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [3] =  %.5g", fAlephParameters[3] ));
+        fPaveTextBookKeeping->AddText( Form("   - fAlephParam [4] =  %.5g", fAlephParameters[4] ));
+        
+        fListHistCascade->Add(fPaveTextBookKeeping);
+}       
+*/
+                
   // - General
   
   if (!fHistMCTrackMultiplicity) {
@@ -1088,7 +1208,122 @@ if(! fCFContCascadePIDAsOmegaPlus)  {
   
 }
 
+// Part 3 : Towards the optimisation of topological selections -------
+if(! fCFContAsCascadeCuts){
+   
+       // Container meant to store all the relevant distributions corresponding to the cut variables.
+       // So far, 20 variables have been identified.
+       // The following will be done in quite a brut force way ... 
+       // FIXME Improvement expected later (before Pb-Pb data at least)
+        //          - Define a user binning to have less bins in each dimension
+        //          - boolean for enabling/disbaling this CFContainer
+  const        Int_t  lNbSteps      =  4 ;
+  const Int_t  lNbVariables  =  20 ;
+  
+  //array for the number of bins in each dimension :
+  Int_t lNbBinsPerVar[20];
+  lNbBinsPerVar[0]  = 25;
+  lNbBinsPerVar[1]  = 25;
+  lNbBinsPerVar[2]  = 20;
+  lNbBinsPerVar[3]  = 40;
+  lNbBinsPerVar[4]  = 50;
+  lNbBinsPerVar[5]  = 12;
+  
+  lNbBinsPerVar[6]  = 20;
+  lNbBinsPerVar[7]  = 40;
+  lNbBinsPerVar[8]  = 40;
+  lNbBinsPerVar[9]  = 25;
+  lNbBinsPerVar[10] = 25;
+  
+  lNbBinsPerVar[11] = 100; // 2-MeV/c2 bins
+  lNbBinsPerVar[12] = 100; // 2-MeV/c2 bins
+  
+  lNbBinsPerVar[13] = 20;
+  
+  lNbBinsPerVar[14] = 44; // 0.05 in rapidity units
+  lNbBinsPerVar[15] = 44; // 0.05 in rapidity units
+  
+  lNbBinsPerVar[16] = 20;
+  lNbBinsPerVar[17] = 50;
+  lNbBinsPerVar[18] = 50;
+  lNbBinsPerVar[19] = 35;
+    
+ fCFContAsCascadeCuts = new AliCFContainer("fCFContAsCascadeCuts","Cut Container for Asso. Cascades", lNbSteps, lNbVariables, lNbBinsPerVar );
+  
+  
+  //setting the bin limits (valid for v4-18-10-AN on)
+  fCFContAsCascadeCuts->SetBinLimits(0,    0.0  ,  0.25 );     // DcaXiDaughters
+  fCFContAsCascadeCuts->SetBinLimits(1,    0.0  ,  0.25 );     // DcaBachToPrimVertexXi
+  fCFContAsCascadeCuts->SetBinLimits(2,    0.995,  1.0  );     // XiCosineOfPointingAngle
+  fCFContAsCascadeCuts->SetBinLimits(3,    0.0  ,  4.0  );     // XiRadius
+  fCFContAsCascadeCuts->SetBinLimits(4,    1.1  ,  1.15 );     // InvMassLambdaAsCascDghter
+  fCFContAsCascadeCuts->SetBinLimits(5,    0.0  ,  0.6  );     // DcaV0DaughtersXi
+  fCFContAsCascadeCuts->SetBinLimits(6,    0.98 ,  1.0  );     // V0CosineOfPointingAngleXi
+  fCFContAsCascadeCuts->SetBinLimits(7,    0.0  , 20.0  );     // V0RadiusXi
+  fCFContAsCascadeCuts->SetBinLimits(8,    0.0  ,  1.0  );     // DcaV0ToPrimVertexXi
+  fCFContAsCascadeCuts->SetBinLimits(9,    0.0  ,  2.5  );     // DcaPosToPrimVertexXi
+  fCFContAsCascadeCuts->SetBinLimits(10,   0.0  ,  2.5  );     // DcaNegToPrimVertexXi
+  fCFContAsCascadeCuts->SetBinLimits(11,   1.25 ,  1.45 );     // InvMassXi
+  fCFContAsCascadeCuts->SetBinLimits(12,   1.6  ,  1.8  );     // InvMassOmega
+  fCFContAsCascadeCuts->SetBinLimits(13,   0.0  , 10.0  );     // pt_MC(Xi)
+  fCFContAsCascadeCuts->SetBinLimits(14,  -1.1  ,  1.1  );     // Y_MC(Xi)
+  fCFContAsCascadeCuts->SetBinLimits(15,  -1.1  ,  1.1  );     // Y_MC(Omega)
+  fCFContAsCascadeCuts->SetBinLimits(16, -10.0  , 10.0  );     // BestPrimaryVtxPosZ
+  if(fCollidingSystems){
+       fCFContAsCascadeCuts->SetBinLimits(17,   0.0, 10000.0  );    // TPCrefitTrackMultiplicity
+       fCFContAsCascadeCuts->SetBinLimits(18,   0.0, 10000.0  );    // SPDTrackletsMultiplicity
+  }
+  else{  
+       fCFContAsCascadeCuts->SetBinLimits(17,   0.0, 250.0  );     // TPCrefitTrackMultiplicity
+       fCFContAsCascadeCuts->SetBinLimits(18,   0.0, 250.0  );     // SPDTrackletsMultiplicity
+  }
+  fCFContAsCascadeCuts->SetBinLimits(19,  25.0  ,165.0  );     // BachTPCClusters
+  
+  
+  
+  // Setting the number of steps : one for each cascade species (Xi-, Xi+ and Omega-, Omega+)
+  fCFContAsCascadeCuts->SetStepTitle(0, "#Xi^{-} candidates associated to MC");
+  fCFContAsCascadeCuts->SetStepTitle(1, "#bar{#Xi}^{+} candidates associated to MC");
+  fCFContAsCascadeCuts->SetStepTitle(2, "#Omega^{-} candidates associated to MC");
+  fCFContAsCascadeCuts->SetStepTitle(3, "#bar{#Omega}^{+} candidates associated to MC");
+  
+  // Setting the variable title, per axis
+  // fCFContAsCascadeCuts->SetVarTitle(40,  "Chi2Xi");
+  fCFContAsCascadeCuts->SetVarTitle(0,  "Dca(XiDaughters) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(1,  "Dca(Bach/PrimVertex) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(2,  "cos(Xi pointing angle)");
+  fCFContAsCascadeCuts->SetVarTitle(3,  "R_{2d}(Xi decay) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(4,  "M_{#Lambda}(As Casc Dghter) (GeV/c^{2})");
+   // fCFContAsCascadeCuts->SetVarTitle(40,  "V0Chi2Xi");
+  fCFContAsCascadeCuts->SetVarTitle(5,  "Dca(V0 Daughters Xi) (cm)");
+  
+  fCFContAsCascadeCuts->SetVarTitle(6,  "cos(V0 pointing Angle) in Casc");
+  fCFContAsCascadeCuts->SetVarTitle(7,  "R_{2d}(V0 decay) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(8,  "Dca(V0/PrimVertex) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(9,  "Dca(Pos/PrimVertex) (cm)");
+  fCFContAsCascadeCuts->SetVarTitle(10, "Dca(Neg/PrimVertex) (cm)");
+  
+  fCFContAsCascadeCuts->SetVarTitle(11, "Inv. Mass(Xi) (GeV/c^{2})");
+  fCFContAsCascadeCuts->SetVarTitle(12, "Inv. Mass(Omega) (GeV/c^{2})");
+  
+  fCFContAsCascadeCuts->SetVarTitle(13, "Pt_{MC}(Casc.) (GeV/c)");
+  //fCFContAsCascadeCuts->SetVarTitle(40, "V0toXiCosineOfPointingAngle");
+  
+  fCFContAsCascadeCuts->SetVarTitle(14, "Y_{MC}(Xi)");
+  fCFContAsCascadeCuts->SetVarTitle(15, "Y_{MC}(Omega)");
+  
+  fCFContAsCascadeCuts->SetVarTitle(16, "Z-position(BestPrimVtx) (cm)");
   
+  fCFContAsCascadeCuts->SetVarTitle(17, "TPCrefit track Multiplicity");
+  fCFContAsCascadeCuts->SetVarTitle(18, "SPD tracklets Multiplicity");
+  fCFContAsCascadeCuts->SetVarTitle(19, "Bach.TPC Clusters");
+  
+  fListHistCascade->Add(fCFContAsCascadeCuts);
+}
+
+
+PostData(1, fListHistCascade); 
 }// end CreateOutputObjects
 
 
@@ -1117,10 +1352,9 @@ void AliAnalysisTaskCheckPerformanceCascade::UserExec(Option_t *)
                lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
                if (!lESDevent) {
                        Printf("ERROR: lESDevent not available \n");
-                       cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
+                       cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;  // or AliAnalysisTaskSE::CurrentFileName()
                        return;
                }
-               ncascades = lESDevent->GetNumberOfCascades();
        }
   
        else if(fAnalysisType == "AOD"){  
@@ -1130,7 +1364,6 @@ void AliAnalysisTaskCheckPerformanceCascade::UserExec(Option_t *)
                        cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
                        return;
                }
-               ncascades = lAODevent->GetNumberOfCascades();
        }
        
 
@@ -1149,14 +1382,83 @@ void AliAnalysisTaskCheckPerformanceCascade::UserExec(Option_t *)
                
        }
        
+        
+   // Temporary way : AOD awareness of the code to be developed  FIXME
+   if(fAnalysisType == "AOD") return;
+   
+   
+   
+   
   //-------------------------------------------------
-  // 0 - Trigger managment
-  // FIXME : Check the availability of the proper trigger 
+  // 0 - Trigger managment + global event selection
+  // NOTE : Check the availability of the proper trigger 
 
    // Note : Presuppose the presence of AliPhysicsSelectionTask
+   
         Bool_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
-        if ( ! isSelected ) return;
+        if ( ! isSelected ) { 
+                PostData(1, fListHistCascade); 
+                return; 
+        }
         //else Printf("Event selected ... \n");
+   
+
+  //-------------------------------------------------
+  // 1 - Cascade vertexer (ESD)
+        if(fkRerunV0CascVertexers){
+//                 if(fAnalysisType == "ESD" ){
+//                         lESDevent->ResetCascades();
+//                         lESDevent->ResetV0s();
+// 
+//                         AliV0vertexer lV0vtxer;
+//                         AliCascadeVertexer lCascVtxer;
+// 
+//                         lV0vtxer.SetDefaultCuts(fV0Sels);
+//                         lCascVtxer.SetDefaultCuts(fCascSels);
+// 
+//                         lV0vtxer.Tracks2V0vertices(lESDevent);
+//                         lCascVtxer.V0sTracks2CascadeVertices(lESDevent);
+//                 }
+        }
+
+
+  //------------------------------------------------
+  // 2 - Preparing the general info about of the event = prim. Vtx + magnetic field (ESD)
+  
+
+//      if(fAnalysisType == "ESD" ){
+
+        // Magnetic field
+                const Double_t lMagneticField = lESDevent->GetMagneticField( );
+
+        // Prim vertex
+                const AliESDVertex *lPrimaryTrackingVtx = lESDevent->GetPrimaryVertexTracks();  // get the vtx stored in ESD found with tracks
+                const AliESDVertex *lPrimarySPDVtx      = lESDevent->GetPrimaryVertexSPD();     // get the vtx stored in ESD found with SPD tracklets
+
+                const AliESDVertex *lPrimaryBestVtx     = lESDevent->GetPrimaryVertex();
+                        // get the best primary vertex available for the event
+                        // As done in AliCascadeVertexer, we keep the one which is the best one available.
+                        // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
+                        Double_t lBestPrimaryVtxPos[3]   = {-100.0, -100.0, -100.0};
+                lPrimaryBestVtx->GetXYZ( lBestPrimaryVtxPos );
+
+                // FIXME : quality cut on the z-position of the prim vertex.
+                if(fkQualityCutZprimVtxPos) {
+                        if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) { 
+                                AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !"); 
+                                PostData(1, fListHistCascade); 
+                                return;
+                        }
+                }
+                // FIXME : remove TPC-only primary vertex : retain only events with tracking + SPD vertex
+                if(fkQualityCutNoTPConlyPrimVtx) {
+                        if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingVtx->GetStatus() ){
+                                AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
+                                PostData(1, fListHistCascade); 
+                                return;
+                        }
+                }
+//      }// if ESD
         
         
   //   cout << "Name of the accessed file :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
@@ -1165,49 +1467,15 @@ void AliAnalysisTaskCheckPerformanceCascade::UserExec(Option_t *)
   //   fInputHandler->GetTree()->Print("toponly");
   //   fInputHandler->GetTree()->GetBranch("PrimaryVertex")->Print();
   //   fInputHandler->GetTree()->GetBranch("SPDVertex")->Print();
-        
-        
-   //-------------------------------------------------
-   // 1 - Cascade vertexer (ESD)
-
-        // if(fAnalysisType == "ESD" ){
-        //         lESDevent->ResetCascades();
-        //         lESDevent->ResetV0s();
-        // 
-        //         AliV0vertexer V0vtxer;
-        //         AliCascadeVertexer CascVtxer;
-        // 
-        //         Double_t v0sels[]={33,    // max allowed chi2
-        //                         0.02,  // min allowed impact parameter for the 1st daughter (LHC09a4 : 0.05)
-        //                         0.02,  // min allowed impact parameter for the 2nd daughter (LHC09a4 : 0.05)
-        //                         1.0,   // max allowed DCA between the daughter tracks       (LHC09a4 : 0.5)
-        //                         0.98,  // max allowed cosine of V0's pointing angle         (LHC09a4 : 0.99)
-        //                         0.2,   // min radius of the fiducial volume                 (LHC09a4 : 0.2)
-        //                         100    // max radius of the fiducial volume                 (LHC09a4 : 100.0)
-        //         };
-        //         V0vtxer.SetDefaultCuts(v0sels);
-        // 
-        //         Double_t xisels[]={33.,   // max allowed chi2 (same as PDC07)
-        //                         0.02,   // min allowed V0 impact parameter                    (PDC07 : 0.05   / LHC09a4 : 0.025 )
-        //                         0.020,  // "window" around the Lambda mass                    (PDC07 : 0.008  / LHC09a4 : 0.010 )
-        //                         0.01 ,  // min allowed bachelor's impact parameter            (PDC07 : 0.035  / LHC09a4 : 0.025 )
-        //                         0.5,    // max allowed DCA between the V0 and the bachelor    (PDC07 : 0.1    / LHC09a4 : 0.2   )
-        //                         0.99,   // min allowed cosine of the cascade pointing angle   (PDC07 : 0.9985 / LHC09a4 : 0.998 )
-        //                         0.2,    // min radius of the fiducial volume                  (PDC07 : 0.9    / LHC09a4 : 0.2   )
-        //                         100     // max radius of the fiducial volume                  (PDC07 : 100    / LHC09a4 : 100   )
-        //         };
-        //         CascVtxer.SetDefaultCuts(xisels);
-        // 
-        //         V0vtxer.Tracks2V0vertices(lESDevent);
-        //         CascVtxer.V0sTracks2CascadeVertices(lESDevent);
-        // }
 
 
 
   // ---------------------------------------------------------------
   // - Initialisation of the part dedicated to cascade vertices
+
+  if(fAnalysisType == "ESD")            ncascades = lESDevent->GetNumberOfCascades();
+  else if(fAnalysisType == "AOD")       ncascades = lAODevent->GetNumberOfCascades();
+       
   
   Int_t iNumberOfPrimaries = -1;
   iNumberOfPrimaries = lMCstack->GetNprimary();
@@ -1239,7 +1507,7 @@ void AliAnalysisTaskCheckPerformanceCascade::UserExec(Option_t *)
       
        
 //__________________________________________________________________________   
-// Part 1 - Loop over the different types of generated cascades (Xi-+, Omega-+)        
+// Part 1 - Loop over the different types of GENERATED cascades (Xi-+, Omega-+)        
 
        // - Initialisation of useful local variables
                
@@ -1523,10 +1791,6 @@ lHistPtMesDghter        = 0x0;
 //__________________________________________________________________________   
 // Part 2 - Loop over the reconstructed candidates
   
-  
-// Temporary way : AOD awareness of the code to be developed  
-if(fAnalysisType == "AOD") return;
-
 
 for (Int_t iXi = 0; iXi < ncascades; iXi++) 
 {// This is the begining of the Cascade loop
@@ -1534,37 +1798,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        AliESDcascade *xiESD = lESDevent->GetCascade(iXi);
        if (!xiESD) continue;
        
-       // -  Step 1 : Preparing the general info about of the event = prim. Vtx + magnetic field (ESD)
-       //-------------
-               
-       // Double_t lMagneticField = lESDevent->GetMagneticField( );
-
-        const AliESDVertex *lPrimaryTrackingVtx = lESDevent->GetPrimaryVertexTracks();  // get the vtx stored in ESD found with tracks
-        const AliESDVertex *lPrimarySPDVtx      = lESDevent->GetPrimaryVertexSPD();     // get the vtx stored in ESD found with SPD tracklets
-
-        const AliESDVertex *lPrimaryBestVtx     = lESDevent->GetPrimaryVertex();
-                // get the best primary vertex available for the event
-                // As done in AliCascadeVertexer, we keep the one which is the best one available.
-                // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
-                Double_t lBestPrimaryVtxPos[3]   = {-100.0, -100.0, -100.0};
-        lPrimaryBestVtx->GetXYZ( lBestPrimaryVtxPos );
-
-        // FIXME : quality cut on the z-position of the prim vertex.
-        Bool_t kQualityCutZprimVtxPos = kTRUE;
-        if(kQualityCutZprimVtxPos) {
-                if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) { AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !"); return; }
-        }
-        // FIXME : remove TPC-only primary vertex : retain only events with tracking + SPD vertex
-        Bool_t kQualityCutNoTPConlyPrimVtx = kTRUE;
-        if(kQualityCutNoTPConlyPrimVtx) {
-                if (!lPrimarySPDVtx->GetStatus() && !lPrimaryTrackingVtx->GetStatus() ){
-                        AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
-                        return;
-                }
-        }
-       
-       
-       // - Step 2 : Connection to daughter tracks of the current cascade
+       // - Step II.1 : Connection to daughter tracks of the current cascade
        //-------------
                        
                UInt_t lIdxPosXi        = (UInt_t) TMath::Abs( xiESD->GetPindex() );
@@ -1594,10 +1828,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
         Int_t lBachTPCClusters  = bachTrackXi->GetTPCNcls(); 
 
                 // FIXME : rejection of a poor quality tracks
-        Bool_t kQualityCutTPCrefit = kFALSE;
-        Bool_t kQualityCut80TPCcls = kFALSE;
-        
-        if(kQualityCutTPCrefit){
+        if(fkQualityCutTPCrefit){
                 // 1 - Poor quality related to TPCrefit
                 ULong_t pStatus    = pTrackXi->GetStatus();
                 ULong_t nStatus    = nTrackXi->GetStatus();
@@ -1606,14 +1837,14 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
                 if ((nStatus&AliESDtrack::kTPCrefit)    == 0) { AliWarning("Pb / V0 Neg. track has no TPCrefit ... continue!"); continue; }
                 if ((bachStatus&AliESDtrack::kTPCrefit) == 0) { AliWarning("Pb / Bach.   track has no TPCrefit ... continue!"); continue; }
         }
-        if(kQualityCut80TPCcls){
+        if(fkQualityCut80TPCcls){
                 // 2 - Poor quality related to TPC clusters
                 if(lPosTPCClusters  < 80) { AliWarning("Pb / V0 Pos. track has less than 80 TPC clusters ... continue!"); continue; }
                 if(lNegTPCClusters  < 80) { AliWarning("Pb / V0 Neg. track has less than 80 TPC clusters ... continue!"); continue; }
                 if(lBachTPCClusters < 80) { AliWarning("Pb / Bach.   track has less than 80 TPC clusters ... continue!"); continue; }
         }
        
-       // - Step 3 : Info over reconstructed cascades
+       // - Step II.2 : Info over reconstructed cascades
        //------------- 
        
        Double_t lInvMassXiMinus    = 0.;
@@ -1666,11 +1897,11 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if( lChargeXi > 0 )     fHistMassOmegaPlus      ->Fill( lInvMassOmegaPlus );
        
        
-       // - Step 4 : PID info
+       // - Step II.3 : PID info
        //-------------
        
        
-       // 4.1 - PID Information
+       // 3.1 - PID Information
 
        Bool_t   lIsPosInXiProton      = kFALSE;
        Bool_t   lIsPosInXiPion        = kFALSE;
@@ -1692,7 +1923,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        Bool_t   lIsNegProtonForTPC    = kFALSE; // For ESD only ...
        Bool_t   lIsPosProtonForTPC    = kFALSE; // For ESD only ...
 
-        // 4.1.A - Combined PID
+        // 3.1.A - Combined PID
        // Reasonable guess for the priors for the cascade track sample (e-, mu, pi, K, p)
        Double_t lPriorsGuessXi[5]    = {0, 0, 2, 0, 1};
        Double_t lPriorsGuessOmega[5] = {0, 0, 1, 1, 1};
@@ -1807,7 +2038,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        }// end if bachelor track with existing combined PID
        
        
-       // 4.1.B - TPC PID : 3-sigma bands on Bethe-Bloch curve
+       // 3.1.B - TPC PID : 3-sigma bands on Bethe-Bloch curve
        // Bachelor
        if (TMath::Abs(fESDpid->NumberOfSigmasTPC( bachTrackXi,AliPID::kKaon)) < 3) lIsBachelorKaonForTPC = kTRUE;
        if (TMath::Abs(fESDpid->NumberOfSigmasTPC( bachTrackXi,AliPID::kPion)) < 3) lIsBachelorPionForTPC = kTRUE;
@@ -1828,7 +2059,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if( lChargeXi > 0 && lIsBachelorKaon )    fHistMassWithCombPIDOmegaPlus   ->Fill( lInvMassOmegaPlus  );
          
        
-       // 4.2 - PID proba Vs Pt(Bach)
+       // 3.2 - PID proba Vs Pt(Bach)
        Int_t      lblBachForPID  = (Int_t) TMath::Abs( bachTrackXi->GetLabel() );
        TParticle* mcBachForPID   = lMCstack->Particle( lblBachForPID );
        Double_t   lmcPtBach      = mcBachForPID->Pt();
@@ -1837,7 +2068,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if(lIsBachelorKaon)   f2dHistPIDprobaKaonVsMCPtBach->Fill( lmcPtBach, pkaonBach );
        
                        
-       // 4.3 - MC perfect PID
+       // 3.3 - MC perfect PID
        Bool_t   lIsBachelorMCPiMinus  = kFALSE;
        Bool_t   lIsBachelorMCPiPlus   = kFALSE;
        Bool_t   lIsBachelorMCKMinus   = kFALSE;
@@ -1856,7 +2087,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
         
        
        
-       // - Step 5 : MC association (care : lots of "continue;" below this line)
+       // - Step II.4 : MC association (care : lots of "continue;" below this line)
        //------------- 
        
        Bool_t lAssoXiMinus    = kFALSE;
@@ -1869,7 +2100,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
                cout    << "MC EventNumber : " << lMCevent->Header()->GetEvent() 
                        << " / MC event Number in Run : " << lMCevent->Header()->GetEventNrInRun() << endl;
        
-       // - Step 5.1 : level of the V0 daughters
+       // - Step 4.1 : level of the V0 daughters
                
        Int_t lblPosV0Dghter = (Int_t) TMath::Abs( pTrackXi->GetLabel() );  
                // Abs value = needed ! question of quality track association ...
@@ -1879,7 +2110,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        TParticle* mcNegV0Dghter = lMCstack->Particle( lblNegV0Dghter );
        
 
-       // - Step 5.2 : level of the Xi daughters
+       // - Step 4.2 : level of the Xi daughters
                
        Int_t lblMotherPosV0Dghter = mcPosV0Dghter->GetFirstMother() ; 
        Int_t lblMotherNegV0Dghter = mcNegV0Dghter->GetFirstMother();
@@ -1898,7 +2129,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        TParticle* mcBach   = lMCstack->Particle( lblBach );    
                                
 
-       // - Step 5.3 : level of Xi candidate
+       // - Step 4.3 : level of Xi candidate
        
        Int_t lblGdMotherPosV0Dghter =   mcMotherPosV0Dghter->GetFirstMother() ;
        Int_t lblGdMotherNegV0Dghter =   mcMotherNegV0Dghter->GetFirstMother() ;
@@ -1920,7 +2151,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        TParticle* mcMotherBach = lMCstack->Particle( lblMotherBach );
        
                
-       // - Step 5.4 : Manage boolean for association
+       // - Step 4.4 : Manage boolean for association
        
        if( mcMotherBach                ->GetPdgCode() ==   3312 &&
            mcGdMotherPosV0Dghter       ->GetPdgCode() ==   3312 &&
@@ -1940,8 +2171,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        
        
        
-       if(!lAssoXiMinus && !lAssoXiPlus && !lAssoOmegaMinus && !lAssoOmegaPlus) continue; // no association
-       
+       if(!lAssoXiMinus && !lAssoXiPlus && !lAssoOmegaMinus && !lAssoOmegaPlus) continue; // no association, skip the rest of the code 
        // If a proper association  exists ...
                
        if(fDebug > 4){
@@ -1951,8 +2181,8 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
                cout << "OmegaPlus  = " << lAssoOmegaPlus  << endl 
                     << "----"          << endl;        
        }
-       
-               
+
+
        if(fDebug > 5){
                cout << endl;
                cout << "- V0 daughters - " << endl;
@@ -1982,24 +2212,25 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        }
 
        
-       // - Step 6 : Plots around the cascade candidates associated with MC
+       // - Step 5 : Plots around the cascade candidates associated with MC
        //------------- 
        
         Double_t lmcPt             = mcMotherBach->Pt();
-        Double_t lmcRapXi          = 0.5*TMath::Log( (mcMotherBach->Energy() + mcMotherBach->Pz()) / 
+        Double_t lmcRapCasc        = 0.5*TMath::Log( (mcMotherBach->Energy() + mcMotherBach->Pz()) / 
                                                      (mcMotherBach->Energy() - mcMotherBach->Pz() +1.e-13) );
         Double_t lmcEta            = mcMotherBach->Eta();
         Double_t lmcTransvRadius   = mcBach->R(); // to get the decay point of Xi, = the production vertex of Bachelor ...
 
         Double_t lrecoPt           = xiESD->Pt();
         Double_t lrecoTransvRadius = TMath::Sqrt( xiESD->Xv() * xiESD->Xv() + xiESD->Yv() * xiESD->Yv() );
-       
+
+
        // - Histos for the cascade candidates associated with MC
        
        if( lChargeXi < 0 && lAssoXiMinus){     
                fHistAsMCMassXiMinus          ->Fill( lInvMassXiMinus  );
-               if(lIsBachelorPion)     f2dHistAsMCandCombPIDGenPtVsGenYXiMinus->Fill( lmcPt, lmcRapXi );
-               f2dHistAsMCGenPtVsGenYXiMinus ->Fill( lmcPt, lmcRapXi  );
+               if(lIsBachelorPion)     f2dHistAsMCandCombPIDGenPtVsGenYXiMinus->Fill( lmcPt, lmcRapCasc );
+               f2dHistAsMCGenPtVsGenYXiMinus ->Fill( lmcPt, lmcRapCasc);
                fHistAsMCGenEtaXiMinus        ->Fill( lmcEta           );
                f2dHistAsMCResPtXiMinus       ->Fill( lmcPt,           (lrecoPt - lmcPt)/ lmcPt );
                f2dHistAsMCResRXiMinus        ->Fill( lmcTransvRadius, (lrecoTransvRadius - lmcTransvRadius)/ lmcTransvRadius    );
@@ -2007,8 +2238,8 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        
        else if( lChargeXi > 0 && lAssoXiPlus){ 
                fHistAsMCMassXiPlus           ->Fill( lInvMassXiPlus   );
-               if(lIsBachelorPion)     f2dHistAsMCandCombPIDGenPtVsGenYXiPlus->Fill( lmcPt, lmcRapXi );
-               f2dHistAsMCGenPtVsGenYXiPlus  ->Fill( lmcPt, lmcRapXi  );
+               if(lIsBachelorPion)     f2dHistAsMCandCombPIDGenPtVsGenYXiPlus->Fill( lmcPt, lmcRapCasc );
+               f2dHistAsMCGenPtVsGenYXiPlus  ->Fill( lmcPt, lmcRapCasc);
                fHistAsMCGenEtaXiPlus         ->Fill( lmcEta           );
                f2dHistAsMCResPtXiPlus        ->Fill( lmcPt,           (lrecoPt - lmcPt)/ lmcPt );
                f2dHistAsMCResRXiPlus         ->Fill( lmcTransvRadius, (lrecoTransvRadius - lmcTransvRadius)/ lmcTransvRadius    );
@@ -2016,8 +2247,8 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        
        else if( lChargeXi < 0 && lAssoOmegaMinus){     
                fHistAsMCMassOmegaMinus          ->Fill( lInvMassOmegaMinus );
-               if(lIsBachelorKaon)     f2dHistAsMCandCombPIDGenPtVsGenYOmegaMinus->Fill( lmcPt, lmcRapXi );
-               f2dHistAsMCGenPtVsGenYOmegaMinus ->Fill( lmcPt, lmcRapXi    );
+               if(lIsBachelorKaon)     f2dHistAsMCandCombPIDGenPtVsGenYOmegaMinus->Fill( lmcPt, lmcRapCasc );
+               f2dHistAsMCGenPtVsGenYOmegaMinus ->Fill( lmcPt, lmcRapCasc  );
                fHistAsMCGenEtaOmegaMinus        ->Fill( lmcEta             );
                f2dHistAsMCResPtOmegaMinus       ->Fill( lmcPt,           (lrecoPt - lmcPt)/ lmcPt );
                f2dHistAsMCResROmegaMinus        ->Fill( lmcTransvRadius, (lrecoTransvRadius - lmcTransvRadius)/ lmcTransvRadius    );
@@ -2025,35 +2256,146 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        
        else if( lChargeXi > 0 && lAssoOmegaPlus){      
                fHistAsMCMassOmegaPlus           ->Fill( lInvMassOmegaPlus );
-               if(lIsBachelorKaon)     f2dHistAsMCandCombPIDGenPtVsGenYOmegaPlus->Fill( lmcPt, lmcRapXi );
-               f2dHistAsMCGenPtVsGenYOmegaPlus  ->Fill( lmcPt, lmcRapXi   );
+               if(lIsBachelorKaon)     f2dHistAsMCandCombPIDGenPtVsGenYOmegaPlus->Fill( lmcPt, lmcRapCasc );
+               f2dHistAsMCGenPtVsGenYOmegaPlus  ->Fill( lmcPt, lmcRapCasc   );
                fHistAsMCGenEtaOmegaPlus         ->Fill( lmcEta            );
                f2dHistAsMCResPtOmegaPlus        ->Fill( lmcPt,           (lrecoPt - lmcPt)/ lmcPt );
                f2dHistAsMCResROmegaPlus         ->Fill( lmcTransvRadius, (lrecoTransvRadius - lmcTransvRadius)/ lmcTransvRadius    );
        }
         
         
+        // - Step 6 : Containers = Cascade cuts + PID
+       //------------- 
+
+       // Double_t lChi2Xi         = -1. ;
+        Double_t lDcaXiDaughters            = -1. ;
+        Double_t lDcaBachToPrimVertexXi     = -1. ;
+        Double_t lXiCosineOfPointingAngle   = -1. ;
+        Double_t lPosXi[3]                  = { -1000.0, -1000.0, -1000.0 };
+        Double_t lXiRadius                  = -1000. ;
         
+        Double_t lInvMassLambdaAsCascDghter = 0.;
+        Double_t lDcaV0DaughtersXi          = -1.;
+        // Double_t lV0Chi2Xi               = -1. ;
+        Double_t lV0CosineOfPointingAngleXi = -1.;
+        Double_t lPosV0Xi[3]                = { -1000. , -1000., -1000. }; // Position of VO coming from cascade
+        Double_t lV0RadiusXi                = -1000.;
+        Double_t lDcaV0ToPrimVertexXi       = -1.;
+        Double_t lDcaPosToPrimVertexXi      = -1.;
+        Double_t lDcaNegToPrimVertexXi      = -1.;
+
+        Int_t    nTrackWithTPCrefitMultiplicity  =  0;
+        Int_t    lSPDTrackletsMultiplicity       = -1;
+
         
+        // 6.2 - Definition of the needed variables
         
-        //FIXME
+        //lChi2Xi                       = xiESD->GetChi2Xi();
+        lDcaXiDaughters                 = xiESD->GetDcaXiDaughters();
+        lDcaBachToPrimVertexXi          = TMath::Abs( bachTrackXi->GetD( lBestPrimaryVtxPos[0], 
+                                                                         lBestPrimaryVtxPos[1], 
+                                                                         lMagneticField  ) ); 
+                                        // NOTE : AliExternalTrackParam::GetD returns an algebraic value
+        lXiCosineOfPointingAngle        = xiESD->GetCascadeCosineOfPointingAngle( lBestPrimaryVtxPos[0],
+                                                                                  lBestPrimaryVtxPos[1],
+                                                                                  lBestPrimaryVtxPos[2] );
+                                        // Take care : the best available vertex should be used (like in AliCascadeVertexer)
+                xiESD->GetXYZcascade( lPosXi[0],  lPosXi[1], lPosXi[2] ); 
+        lXiRadius                       = TMath::Sqrt( lPosXi[0]*lPosXi[0]  +  lPosXi[1]*lPosXi[1] );
+        lInvMassLambdaAsCascDghter      = xiESD->GetEffMass(); 
+                                        // This value shouldn't change, whatever the working hyp. is : Xi-, Xi+, Omega-, Omega+
+        lDcaV0DaughtersXi               = xiESD->GetDcaV0Daughters();
+        // lV0Chi2Xi                    = xiESD->GetChi2V0();
+        lV0CosineOfPointingAngleXi      = xiESD->GetV0CosineOfPointingAngle( lBestPrimaryVtxPos[0],
+                                                                             lBestPrimaryVtxPos[1],
+                                                                             lBestPrimaryVtxPos[2] );
+                xiESD->GetXYZ( lPosV0Xi[0],  lPosV0Xi[1], lPosV0Xi[2] ); 
+        lV0RadiusXi                     = TMath::Sqrt( lPosV0Xi[0]*lPosV0Xi[0]  +  lPosV0Xi[1]*lPosV0Xi[1] );
+        
+        lDcaV0ToPrimVertexXi            = xiESD->GetD( lBestPrimaryVtxPos[0], 
+                                                lBestPrimaryVtxPos[1], 
+                                                lBestPrimaryVtxPos[2] );
+        
+        lDcaPosToPrimVertexXi           = TMath::Abs( pTrackXi   ->GetD( lBestPrimaryVtxPos[0],
+                                                                         lBestPrimaryVtxPos[1],
+                                                                         lMagneticField  )     );
+        
+        lDcaNegToPrimVertexXi           = TMath::Abs( nTrackXi   ->GetD( lBestPrimaryVtxPos[0], 
+                                                                         lBestPrimaryVtxPos[1], 
+                                                                         lMagneticField  )     );
         
-       // - Filling the AliCFContainers related to PID
-       
-       Double_t lContainerPIDVars[4] = {0.0};
-        Int_t nTrackWithTPCrefitMultiplicity =  0;
         
-        nTrackWithTPCrefitMultiplicity = DoESDTrackWithTPCrefitMultiplicity(lESDevent);
         
+        nTrackWithTPCrefitMultiplicity  = DoESDTrackWithTPCrefitMultiplicity(lESDevent);
         
         
+        const AliMultiplicity *lAliMult = lESDevent->GetMultiplicity();
+        lSPDTrackletsMultiplicity       = lAliMult->GetNumberOfTracklets();
+        
+
+        // 6.3 - Filling the AliCFContainer (optimisation of topological selections + systematics)
+        Double_t lContainerCutVars[20] = {0.0};
+
+        lContainerCutVars[0]  = lDcaXiDaughters;
+        lContainerCutVars[1]  = lDcaBachToPrimVertexXi;
+        lContainerCutVars[2]  = lXiCosineOfPointingAngle;
+        lContainerCutVars[3]  = lXiRadius;
+        lContainerCutVars[4]  = lInvMassLambdaAsCascDghter;
+        lContainerCutVars[5]  = lDcaV0DaughtersXi;
+        lContainerCutVars[6]  = lV0CosineOfPointingAngleXi;
+        lContainerCutVars[7]  = lV0RadiusXi;
+        lContainerCutVars[8]  = lDcaV0ToPrimVertexXi;  
+        lContainerCutVars[9]  = lDcaPosToPrimVertexXi;
+        lContainerCutVars[10] = lDcaNegToPrimVertexXi;
+
+        lContainerCutVars[13] = lmcPt;
+
+        lContainerCutVars[16] = lBestPrimaryVtxPos[2];
+        lContainerCutVars[17] = nTrackWithTPCrefitMultiplicity;  // FIXME : nTrackWithTPCrefitMultiplicity not checked for AOD ...
+        lContainerCutVars[18] = lSPDTrackletsMultiplicity;       // FIXME : SPDTrackletsMultiplicity is not available for AOD ... 
+        lContainerCutVars[19] = lBachTPCClusters;                // FIXME : BachTPCClusters          is not available for AOD ... 
+
+        // All cases should be covered below
+        if( lChargeXi < 0 && lAssoXiMinus    ) {
+                lContainerCutVars[11] = lInvMassXiMinus;
+                lContainerCutVars[12] = 1.75;
+                lContainerCutVars[14] = lmcRapCasc;
+                lContainerCutVars[15] = -1.;
+                        fCFContAsCascadeCuts->Fill(lContainerCutVars,0); // for Xi-
+        }
+        if( lChargeXi > 0 && lAssoXiPlus     ){
+                lContainerCutVars[11] = lInvMassXiPlus;
+                lContainerCutVars[12] = 1.75;
+                lContainerCutVars[14] = lmcRapCasc;
+                lContainerCutVars[15] = -1.; 
+                        fCFContAsCascadeCuts->Fill(lContainerCutVars,1); // for Xi+
+        }
+        if( lChargeXi < 0 && lAssoOmegaMinus )  {
+                lContainerCutVars[11] = 1.4;
+                lContainerCutVars[12] = lInvMassOmegaMinus;
+                lContainerCutVars[14] = -1.;
+                lContainerCutVars[15] = lmcRapCasc;
+                        fCFContAsCascadeCuts->Fill(lContainerCutVars,2); // for Omega-
+        }
+       if( lChargeXi > 0 && lAssoOmegaPlus  ){
+                lContainerCutVars[11] = 1.4;
+                lContainerCutVars[12] = lInvMassOmegaPlus;
+                lContainerCutVars[14] = -1.;
+                lContainerCutVars[15] = lmcRapCasc;
+                        fCFContAsCascadeCuts->Fill(lContainerCutVars,3); // for Omega+
+        }
+        
         
+       // 6.4 - Filling the AliCFContainers related to PID
+
+       Double_t lContainerPIDVars[4] = {0.0};
+
        
        // Xi Minus             
        if( lChargeXi < 0 && lAssoXiMinus ) {
                lContainerPIDVars[0] = lmcPt              ;
                lContainerPIDVars[1] = lInvMassXiMinus    ;
-               lContainerPIDVars[2] = lmcRapXi           ;
+               lContainerPIDVars[2] = lmcRapCasc         ;
                lContainerPIDVars[3] = nTrackWithTPCrefitMultiplicity ;
                        
                // No PID
@@ -2091,7 +2433,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if( lChargeXi > 0 && lAssoXiPlus ) {
                lContainerPIDVars[0] = lmcPt              ;
                lContainerPIDVars[1] = lInvMassXiPlus     ;
-               lContainerPIDVars[2] = lmcRapXi           ;
+               lContainerPIDVars[2] = lmcRapCasc           ;
                lContainerPIDVars[3] = nTrackWithTPCrefitMultiplicity ;
                        
                // No PID
@@ -2129,7 +2471,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if( lChargeXi < 0 && lAssoOmegaMinus ) {
                lContainerPIDVars[0] = lmcPt              ;
                lContainerPIDVars[1] = lInvMassOmegaMinus ;
-               lContainerPIDVars[2] = lmcRapXi           ;
+               lContainerPIDVars[2] = lmcRapCasc         ;
                lContainerPIDVars[3] = nTrackWithTPCrefitMultiplicity ;
                        
                // No PID
@@ -2167,7 +2509,7 @@ for (Int_t iXi = 0; iXi < ncascades; iXi++)
        if( lChargeXi > 0 && lAssoOmegaPlus) {
                lContainerPIDVars[0] = lmcPt              ;
                lContainerPIDVars[1] = lInvMassOmegaPlus  ;
-               lContainerPIDVars[2] = lmcRapXi           ;
+               lContainerPIDVars[2] = lmcRapCasc         ;
                lContainerPIDVars[3] = nTrackWithTPCrefitMultiplicity ;
                        
                // No PID
@@ -2230,7 +2572,7 @@ Int_t AliAnalysisTaskCheckPerformanceCascade::DoESDTrackWithTPCrefitMultiplicity
                     // The goal here is to get a better assessment of the event multiplicity.
                     // (InputEvent())->GetNumberOfTracks() takes into account ITS std alone tracks + global tracks
                     // This may introduce a bias. Hence the number of TPC refit tracks.
-                    // Note : the event multiplicity = analysis on its own... See Jacek's or Jan Fiete's analysis on dN/d(eta)
+                    // Note : the event multiplicity = analysis on its own... See Jacek's or Jan Fiete's analysis on dN/d(pt) and dN/d(eta)
 
         }// end loop over all event tracks
         return  nTrackWithTPCrefitMultiplicity;
index 63eb0f7..0e13760 100644 (file)
@@ -26,7 +26,7 @@ class AliAnalysisTaskCheckPerformanceCascade : public AliAnalysisTaskSE {
  
   AliAnalysisTaskCheckPerformanceCascade();
   AliAnalysisTaskCheckPerformanceCascade(const char *name );
-  virtual ~AliAnalysisTaskCheckPerformanceCascade() {}
+  virtual ~AliAnalysisTaskCheckPerformanceCascade();
   
   //virtual void   ConnectInputData(Option_t *);
   virtual void   UserCreateOutputObjects();
@@ -38,12 +38,36 @@ class AliAnalysisTaskCheckPerformanceCascade : public AliAnalysisTaskSE {
   void SetCollidingSystems (Short_t collidingSystems = 0)     {fCollidingSystems = collidingSystems;}
   void SetAnalysisType     (const char* analysisType = "ESD") {fAnalysisType = analysisType;}
   
+  void SetRelaunchV0CascVertexers    (Bool_t rerunV0CascVertexers       = 0    ) { fkRerunV0CascVertexers       =  rerunV0CascVertexers;   }
+  void SetQualityCutZprimVtxPos      (Bool_t qualityCutZprimVtxPos      = kTRUE) { fkQualityCutZprimVtxPos      =  qualityCutZprimVtxPos;     }
+  void SetQualityCutNoTPConlyPrimVtx (Bool_t qualityCutNoTPConlyPrimVtx = kTRUE) { fkQualityCutNoTPConlyPrimVtx =  qualityCutNoTPConlyPrimVtx;}
+  void SetQualityCutTPCrefit         (Bool_t qualityCutTPCrefit         = kTRUE) { fkQualityCutTPCrefit         =  qualityCutTPCrefit;        }
+  void SetQualityCut80TPCcls         (Bool_t qualityCut80TPCcls         = kTRUE) { fkQualityCut80TPCcls         =  qualityCut80TPCcls;        }
+  void SetExtraSelections            (Bool_t extraSelections            = 0    ) { fkExtraSelections            =  extraSelections;           }
+
  private:
+        // Note : In ROOT, "//!" means "do not stream the data from Master node to Worker node" ...
+        // your data member object is created on the worker nodes and streaming is not needed.
+        // http://root.cern.ch/download/doc/11InputOutput.pdf, page 14
+
         Int_t           fDebugCascade;          // Denug Flag for this task devoted to cascade
         TString         fAnalysisType;          // "ESD" or "AOD" analysis type        
         Short_t         fCollidingSystems;      // 0 = pp collisions or 1 = AA collisions
 
         AliESDpid       *fESDpid;        // Tool data member to manage the TPC Bethe-Bloch info
+        //TPaveText       *fPaveTextBookKeeping;          // TString to store all the relevant info necessary for book keeping (v0 cuts, cascade cuts, quality cuts, ...)
+
+        Bool_t          fkRerunV0CascVertexers;         // Boolean : kTRUE = relaunch both V0 + Cascade vertexers
+        Bool_t          fkQualityCutZprimVtxPos;        // Boolean : kTRUE = cut on the prim.vtx  z-position
+        Bool_t          fkQualityCutNoTPConlyPrimVtx;   // Boolean : kTRUE = prim vtx should be SPD or Tracking vertex
+        Bool_t          fkQualityCutTPCrefit;           // Boolean : kTRUE = ask for TPCrefit for the 3 daughter tracks
+        Bool_t          fkQualityCut80TPCcls;           // Boolean : kTRUE = ask for 80 TPC clusters for each daughter track
+        Bool_t          fkExtraSelections;              // Boolean : kTRUE = apply tighter selections, before starting the analysis
+        
+        Double_t        fAlephParameters[5];            // Array to store the 5 param values for the TPC Bethe-Bloch parametrisation
+        Double_t        fV0Sels[7];                     // Array to store the 7 values for the different selections V0 related (if fkRerunV0CascVertexers)
+        Double_t        fCascSels[8];                   // Array to store the 8 values for the different selections Casc. related (if fkRerunV0CascVertexers)
+
        
        TList   *fListHistCascade;              //! List of Cascade histograms
                // - Histos 
@@ -210,12 +234,13 @@ class AliAnalysisTaskCheckPerformanceCascade : public AliAnalysisTaskSE {
        AliCFContainer  *fCFContCascadePIDAsOmegaMinus;   //! for Omega-: Container to store any 3D histos with the different PID flavours
        AliCFContainer  *fCFContCascadePIDAsOmegaPlus;    //! for Omega+: Container to store any 3D histos with the different PID flavours
        
-       
+       // - Towards the optimisation of topological selections/ systematics (on associated candidates)
+       AliCFContainer  *fCFContAsCascadeCuts;            //! Container meant to store all the relevant distributions corresponding to the cut variables
        
   AliAnalysisTaskCheckPerformanceCascade(const AliAnalysisTaskCheckPerformanceCascade&);            // not implemented
   AliAnalysisTaskCheckPerformanceCascade& operator=(const AliAnalysisTaskCheckPerformanceCascade&); // not implemented
   
-  ClassDef(AliAnalysisTaskCheckPerformanceCascade, 3);
+  ClassDef(AliAnalysisTaskCheckPerformanceCascade, 4);
 };
 
 #endif
index c96f84f..91a91d8 100644 (file)
@@ -20,8 +20,16 @@ AliAnalysisTaskCheckCascade *AddTaskCheckCascade(Short_t       lCollidingSystems
 
    // Create and configure the task
        AliAnalysisTaskCheckCascade *taskcheckcascade = new AliAnalysisTaskCheckCascade("TaskCheckCascade");
-   taskcheckcascade->SetCollidingSystems(lCollidingSystems);
-   taskcheckcascade->SetAnalysisType(type);
+   taskcheckcascade-> SetCollidingSystems           (lCollidingSystems);
+   taskcheckcascade-> SetAnalysisType               (type);
+   
+   taskcheckcascade-> SetRelaunchV0CascVertexers    (0);     //NOTE
+   taskcheckcascade-> SetQualityCutZprimVtxPos      (kTRUE);
+   taskcheckcascade-> SetQualityCutNoTPConlyPrimVtx (kTRUE);
+   taskcheckcascade-> SetQualityCutTPCrefit         (kTRUE);
+   taskcheckcascade-> SetQualityCut80TPCcls         (kTRUE);
+        // taskcheckcascade-> SetExtraSelections            (0);
+   
    
    mgr->AddTask(taskcheckcascade);
 
@@ -48,11 +56,12 @@ AliAnalysisTaskCheckCascade *AddTaskCheckCascade(Short_t       lCollidingSystems
    */
    
    TString outputFileName = AliAnalysisManager::GetCommonFileName();
+   
    outputFileName += ":PWG2CheckCascade";
    if (lCollidingSystems) outputFileName += "_AA_";
-   else outputFileName += "_PP_";
-   if (mgr->GetMCtruthEventHandler()) outputFileName += "MC_";
-   if(lMasterJobSessionFlag.Length()) outputFileName += lMasterJobSessionFlag.Data();
+   else outputFileName += "_PP";
+   if (mgr->GetMCtruthEventHandler()) outputFileName += "_MC";
+   //if(lMasterJobSessionFlag.Length()) outputFileName += lMasterJobSessionFlag.Data();
    
    Printf("AddTaskCheckCascade - Set OutputFileName : \n %s\n", outputFileName.Data() );
 
@@ -61,8 +70,15 @@ AliAnalysisTaskCheckCascade *AddTaskCheckCascade(Short_t       lCollidingSystems
                                                             AliAnalysisManager::kOutputContainer,
                                                             outputFileName );
    
+//    AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("cPaveTextBookKeeping",
+//                                                          TPaveText::Class(),
+//                                                          AliAnalysisManager::kOutputContainer,
+//                                                          outputFileName );
+   
+   
    mgr->ConnectInput( taskcheckcascade, 0, mgr->GetCommonInputContainer());
    mgr->ConnectOutput(taskcheckcascade, 1, coutput1);
+   //mgr->ConnectOutput(taskcheckcascade, 2, coutput2);
    
    return taskcheckcascade;
 }   
index a304669..4dd5d4c 100644 (file)
@@ -20,8 +20,16 @@ AliAnalysisTaskCheckPerformanceCascade *AddTaskCheckPerformanceCascade(Short_t
 
    // Create and configure the task
         AliAnalysisTaskCheckPerformanceCascade *taskCheckPerfCascade = new AliAnalysisTaskCheckPerformanceCascade("TaskCheckPerfCascade");
-   taskCheckPerfCascade->SetCollidingSystems(lCollidingSystems);
-   taskCheckPerfCascade->SetAnalysisType(type);
+   taskCheckPerfCascade->SetCollidingSystems            (lCollidingSystems);
+   taskCheckPerfCascade->SetAnalysisType                (type);
+   
+   taskCheckPerfCascade-> SetRelaunchV0CascVertexers    (0);     //NOTE
+   taskCheckPerfCascade-> SetQualityCutZprimVtxPos      (kTRUE);
+   taskCheckPerfCascade-> SetQualityCutNoTPConlyPrimVtx (kTRUE);
+   taskCheckPerfCascade-> SetQualityCutTPCrefit         (kTRUE);
+   taskCheckPerfCascade-> SetQualityCut80TPCcls         (kTRUE);
+        // taskCheckPerfCascade-> SetExtraSelections            (0);
+   
    
    mgr->AddTask(taskCheckPerfCascade);
 
@@ -41,17 +49,18 @@ AliAnalysisTaskCheckPerformanceCascade *AddTaskCheckPerformanceCascade(Short_t
                 lCommonFileName += "-";
                 lCommonFileName += lMasterJobSessionFlag.Data();
         }
-                lCommonFileName += ".root"; 
+                lCommonFileName += ".root";
+
         mgr->SetCommonFileName( lCommonFileName.Data() );
    }
    */
-   
+
    TString outputFileName = AliAnalysisManager::GetCommonFileName();
    outputFileName += ":PWG2CheckPerformanceCascade";
    if (lCollidingSystems) outputFileName += "_AA_";
-   else outputFileName += "_PP_";
-   if (mgr->GetMCtruthEventHandler()) outputFileName += "MC_";
-   if(lMasterJobSessionFlag.Length()) outputFileName += lMasterJobSessionFlag.Data();
+   else outputFileName += "_PP";
+   if (mgr->GetMCtruthEventHandler()) outputFileName += "_MC";
+   //if(lMasterJobSessionFlag.Length()) outputFileName += lMasterJobSessionFlag.Data();
    
    Printf("AddTaskCheckPerfCascade - Set OutputFileName : \n %s\n", outputFileName.Data() );