First version of the Lc to K0sP and Xic to XiPiPi classes from AOD tracks ( Y. Watanabe )
authorzconesa <zaida.conesa.del.valle@cern.ch>
Mon, 12 Jan 2015 11:32:05 +0000 (12:32 +0100)
committerzconesa <zaida.conesa.del.valle@cern.ch>
Mon, 12 Jan 2015 11:32:31 +0000 (12:32 +0100)
14 files changed:
PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.cxx [new file with mode: 0644]
PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.h [new file with mode: 0644]
PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.cxx [new file with mode: 0644]
PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.h [new file with mode: 0644]
PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.cxx [new file with mode: 0644]
PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.h [new file with mode: 0644]
PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.cxx [new file with mode: 0644]
PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.h [new file with mode: 0644]
PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.cxx [new file with mode: 0644]
PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.h [new file with mode: 0644]
PWGHF/vertexingHF/CMakeLists.txt
PWGHF/vertexingHF/PWGHFvertexingHFLinkDef.h
PWGHF/vertexingHF/macros/AddTaskLc2pK0sfromAODtracks.C [new file with mode: 0644]
PWGHF/vertexingHF/macros/AddTaskXicPlus2XiPiPifromAODtracks.C [new file with mode: 0644]

diff --git a/PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.cxx b/PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.cxx
new file mode 100644 (file)
index 0000000..3c54494
--- /dev/null
@@ -0,0 +1,381 @@
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/////////////////////////////////////////////////////////////
+//
+// Class for AOD reconstructed heavy-flavour cascades 3prong
+// Used for Xic->pi Xi pi analysis
+//
+// Author: Y.S. Watanabe, wyosuke@cns.s.u-tokyo.ac.jp
+/////////////////////////////////////////////////////////////
+
+#include <TVector3.h>
+#include <TDatabasePDG.h>
+#include <TClonesArray.h>
+#include "AliAODMCParticle.h"
+#include "AliAODRecoDecay.h"
+#include "AliAODVertex.h"
+#include "AliAODRecoDecayHF3Prong.h"
+#include "AliAODRecoCascadeHF3Prong.h"
+
+ClassImp(AliAODRecoCascadeHF3Prong)
+
+//-----------------------------------------------------------------------------
+
+AliAODRecoCascadeHF3Prong::AliAODRecoCascadeHF3Prong() :
+AliAODRecoDecayHF3Prong()
+{
+  //
+  // Default Constructor
+  //
+}
+
+//-----------------------------------------------------------------------------
+AliAODRecoCascadeHF3Prong::AliAODRecoCascadeHF3Prong(AliAODVertex *vtx2, Short_t charge,
+                                                    Double_t *px, Double_t *py, Double_t *pz,
+                                                    Double_t *d0, Double_t *d0err, 
+                                                    Double_t *dca, Double_t sigvert,
+                                                    Double_t dist12,Double_t dist23):
+  AliAODRecoDecayHF3Prong(vtx2, px, py, pz, d0, d0err, dca,sigvert,dist12,dist23,charge)
+{
+  //
+  //  Constructor with AliAODVertex for decay vertex
+  //
+}
+
+//-----------------------------------------------------------------------------
+AliAODRecoCascadeHF3Prong::AliAODRecoCascadeHF3Prong(const AliAODRecoCascadeHF3Prong &source) :
+  AliAODRecoDecayHF3Prong(source)
+{
+  //
+  // Copy constructor
+  //
+}
+
+//-----------------------------------------------------------------------------
+AliAODRecoCascadeHF3Prong &AliAODRecoCascadeHF3Prong::operator=(const AliAODRecoCascadeHF3Prong &source)
+{
+  //
+  // assignment operator
+  //
+  if(&source == this) return *this;
+
+  AliAODRecoDecayHF3Prong::operator=(source);
+
+  return *this;
+}
+
+//-----------------------------------------------------------------------------
+AliAODRecoCascadeHF3Prong::~AliAODRecoCascadeHF3Prong()
+{
+  //
+  // Default Destructor
+  //
+}
+
+//----------------------------------------------------------------------------
+//Int_t AliAODRecoCascadeHF3Prong::MatchToMC(Int_t pdgabs,Int_t pdgabs3prong,
+//                                     Int_t *pdgDg,Int_t *pdgDg3prong,
+//                                  TClonesArray *mcArray, Bool_t isV0) const
+//{
+//  //
+//  // Check if this candidate is matched to a MC signal
+//  // If no, return -1
+//  // If yes, return label (>=0) of the AliAODMCParticle
+//  // 
+//
+//  Int_t ndg=GetNDaughters();
+//  if(ndg==0) {
+//    AliError("No daughters available");
+//    return -1;
+//  }
+//
+//  if ( isV0 &&
+//       ( (pdgDg[1]==2212 && pdgDg[0]==310) ||
+//      (pdgDg[1]==211 && pdgDg[0]==3122) ) ) {
+//    AliWarning(Form("Please, pay attention: first element in AliAODRecoCascadeHF3Prong object must be the bachelor and second one V0. Skipping! (pdgDg[0] = %d, (pdgDg[1] = %d)", pdgDg[0], pdgDg[1]));
+//    return -1;
+//  }
+//
+//  Int_t lab3Prong = -1;
+//
+//  if (!isV0) {
+//    AliAODRecoDecayHF2Prong *the2Prong = Get2Prong();
+//    lab2Prong = the2Prong->MatchToMC(pdgabs2prong,mcArray,2,pdgDg2prong);
+//  } else {
+//    AliAODv0 *theV0 = dynamic_cast<AliAODv0*>(Getv0());
+//    lab2Prong = theV0->MatchToMC(pdgabs2prong,mcArray,2,pdgDg2prong); // the V0
+//  }
+//
+//  if(lab2Prong<0) return -1;
+//
+//  Int_t dgLabels[10]={0,0,0,0,0,0,0,0,0,0};
+//
+//  if (!isV0) {
+//    // loop on daughters and write labels
+//    for(Int_t i=0; i<ndg; i++) {
+//      AliVTrack *trk = dynamic_cast<AliVTrack*>(GetDaughter(i));
+//      if(!trk) continue;
+//      Int_t lab = trk->GetLabel();
+//      if(lab==-1) { // this daughter is the 2prong
+//     lab=lab2Prong;
+//      } else if(lab<-1) continue;
+//      dgLabels[i] = lab;
+//    }
+//  } else {
+//    AliVTrack *trk = dynamic_cast<AliVTrack*>(GetBachelor()); // the bachelor
+//    if (!trk) return -1;
+//    dgLabels[0] = trk->GetLabel();//TMath::Abs(trk->GetLabel());
+//    dgLabels[1] = lab2Prong;
+//  }
+//
+//  Int_t finalLabel = AliAODRecoDecay::MatchToMC(pdgabs,mcArray,dgLabels,2,2,pdgDg);
+//
+//  if (finalLabel>=0){
+//    // debug printouts for Lc->V0 bachelor case
+//
+//    if ( isV0 && (dgLabels[0]!=-1 && dgLabels[1]!=-1) ) {
+//      AliAODv0 *theV0 = dynamic_cast<AliAODv0*>(Getv0());
+//      Bool_t onTheFly = theV0->GetOnFlyStatus();
+//      if (pdgDg[0]==2212 && pdgDg[1]==310) {
+//     AliAODMCParticle*k0s = dynamic_cast<AliAODMCParticle*>(mcArray->At(lab2Prong));
+//     if(k0s){
+//       Int_t labK0 = k0s->GetMother();       
+//       AliAODMCParticle*k0bar = dynamic_cast<AliAODMCParticle*>(mcArray->At(labK0));
+//       if(k0bar){
+//         AliDebug(1,Form(" (onTheFly=%1d) LabelV0=%d (%d) -> LabelK0S=%d (%d -> %d %d)",onTheFly,labK0,k0bar->GetPdgCode(),lab2Prong,pdgabs2prong,pdgDg2prong[0],pdgDg2prong[1]));
+//         AliDebug(1,Form(" LabelLc=%d (%d) -> LabelBachelor=%d (%d) LabelV0=%d (%d)",
+//                         finalLabel,pdgabs,
+//                         dgLabels[0],pdgDg[0],dgLabels[1],pdgDg[1]));
+//       }
+//     }
+//      } else if (pdgDg[0]==211 && pdgDg[1]==3122) {
+//     AliDebug(1,Form(" (onTheFly=%1d) LabelV0=%d (%d -> %d %d)",onTheFly,lab2Prong,pdgabs2prong,pdgDg2prong[0],pdgDg2prong[1]));
+//     AliDebug(1,Form(" LabelLc=%d (%d) -> LabelBachelor=%d (%d) LabelV0=%d (%d)",
+//                     finalLabel,pdgabs,
+//                   dgLabels[0],pdgDg[0],dgLabels[1],pdgDg[1]));
+//      }
+//
+//    }
+//  }
+//
+//  return finalLabel;
+//
+//}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaXiDaughters() const
+{
+  //
+  // DCA between Xi daughters
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaXiDaughters();
+
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaV0Daughters() const
+{
+  //
+  // DCA between Cascade-V0 daughters
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaV0Daughters();
+
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDecayLength() const
+{
+  //
+  // Decay length of Xi
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+
+  if (!casc) 
+    return -1.;
+  AliAODVertex *vtxPrimary = GetPrimaryVtx();
+  Double_t posVtx[3] = {0.,0.,0.};
+  vtxPrimary->GetXYZ(posVtx);
+  return casc->DecayLengthXi(posVtx[0],posVtx[1],posVtx[2]);
+
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDecayLengthV0() const
+{
+  //
+  // Decay length of V0 from Xi
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DecayLengthV0();
+
+}
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascCosPointingAngle() const 
+{
+  //
+  // Xi pointing angle to primary vertex
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -999.;
+
+  AliAODVertex *vtxPrimary = GetPrimaryVtx();
+  Double_t posVtx[3] = {0.,0.,0.};
+  vtxPrimary->GetXYZ(posVtx);
+  return casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
+}
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascCosPointingAngleV0() const 
+{
+  //
+  // Cos pointing angle of V0 to Xi decay vertex
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -999.;
+  return casc->CosPointingAngle(casc->GetDecayVertexXi());
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaV0ToPrimVertex() const
+{
+  //
+  // DCA to primary vertex of Cascade-V0 
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaV0ToPrimVertex();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaPosToPrimVertex() const
+{
+  //
+  // DCA to primary vertex of Cascade-positive track
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaPosToPrimVertex();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaNegToPrimVertex() const
+{
+  //
+  // DCA to primary vertex of Cascade-negative track
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaNegToPrimVertex();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascDcaBachToPrimVertex() const
+{
+  //
+  // DCA to primary vertex of Cascade-Bachelor track
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->DcaBachToPrimVertex();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascMassXi() const
+{
+  //
+  // Xi mass
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->MassXi();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascMassLambda() const
+{
+  //
+  // Lambda mass of cascade-v0
+  //
+
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->MassLambda();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::CascMassAntiLambda() const
+{
+  //
+  // Anti-Lambda mass of cascade-v0
+  //
+       
+  AliAODcascade *casc = (AliAODcascade*)GetCascade();
+  if (!casc) 
+    return -1.;
+  return casc->MassAntiLambda();
+}
+
+//________________________________________________________________________
+Double_t AliAODRecoCascadeHF3Prong::XicCosPointingAngle() const
+{
+  //
+  // Xic pointing angle to primary vertex
+  //
+
+  AliAODVertex *vtxPrimary = GetPrimaryVtx();
+  AliAODVertex *vtxSecondary = GetSecondaryVtx();
+
+  Double_t dx = vtxSecondary->GetX()-vtxPrimary->GetX();
+  Double_t dy = vtxSecondary->GetY()-vtxPrimary->GetY();
+  Double_t dl = sqrt(dx*dx+dy*dy);
+
+  Double_t px = Px();
+  Double_t py = Py();
+  Double_t pt = Pt();
+
+  if(dl>0&&pt>0)
+    return (px*dx+py*dy)/pt/dl; 
+  else
+    return -9999.;
+}
diff --git a/PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.h b/PWGHF/vertexingHF/AliAODRecoCascadeHF3Prong.h
new file mode 100644 (file)
index 0000000..11dbaf6
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef ALIAODRECOCASCADEHF3PRONG_H
+#define ALIAODRECOCASCADEHF3PRONG_H
+/* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */ 
+
+//***********************************************************
+// Class AliAODRecoCascadeHF3Prong
+// base class for AOD reconstructed heavy-flavour cascade 3Prong decays
+// (Xic+->pi Xi pi, ...)
+// The convention is: prong 0 is bachelor, prong 1 is cascade
+// prong 2 is bachelor
+//
+// Author: Y.S. Watanabe, wyosuke@cns.s.u-tokyo.ac.jp
+//***********************************************************
+
+#include <TRef.h>
+#include <TRefArray.h>
+#include <TClonesArray.h>
+#include <TClass.h>
+#include "AliAODVertex.h"
+#include "AliAODcascade.h"
+#include "AliAODv0.h"
+#include "AliAODRecoDecayHF3Prong.h"
+
+class AliAODRecoCascadeHF3Prong : public AliAODRecoDecayHF3Prong {
+
+ public:
+
+  AliAODRecoCascadeHF3Prong();
+  AliAODRecoCascadeHF3Prong(AliAODVertex *vtx2, Short_t charge,
+                           Double_t *px, Double_t *py, Double_t *pz,
+                           Double_t *d0, Double_t *d0err, 
+                           Double_t *dca, Double_t sigvert,
+                           Double_t dist12,Double_t dist23);
+  virtual ~AliAODRecoCascadeHF3Prong();
+
+  AliAODRecoCascadeHF3Prong(const AliAODRecoCascadeHF3Prong& source);
+  AliAODRecoCascadeHF3Prong& operator=(const AliAODRecoCascadeHF3Prong& source);
+
+  AliAODTrack* GetBachelor1() const {return (AliAODTrack*)GetDaughter(0);}
+  AliAODTrack* GetBachelor2() const {return (AliAODTrack*)GetDaughter(2);}
+  AliAODcascade* GetCascade() const {
+    if ( ! ((AliAODRecoDecay*)GetDaughter(1))->IsA()->InheritsFrom("AliAODcascade") ){
+      AliWarning("Object is not of type cascade");
+      return 0;
+    }
+    return (AliAODcascade*)GetDaughter(1);
+  }
+
+  AliAODTrack* GetCascadePositiveTrack() const { return  (AliAODTrack*)GetCascade()->GetDaughter(0);  }
+  AliAODTrack* GetCascadeNegativeTrack() const { return  (AliAODTrack*)GetCascade()->GetDaughter(1);  }
+  AliAODTrack* GetCascadeBachelorTrack() const { return  (AliAODTrack*)GetCascade()->GetDecayVertexXi()->GetDaughter(0);  }
+
+  // Xic invariant mass
+  Double_t InvMassPiXiPi() const {
+    UInt_t pdg[3]={211,3312,211}; return InvMass(3,pdg);
+  }
+
+  //  Int_t MatchToMC(Int_t pdgabs,Int_t pdgabs3prong,
+  //                  Int_t *pdgDg,Int_t *pdgDg3prong,
+  //                  TClonesArray *mcArray, Bool_t isV0=kFALSE) const;
+
+  Double_t CascDcaXiDaughters() const;
+  Double_t CascDcaV0Daughters() const;
+  Double_t CascDecayLength() const;
+  Double_t CascDecayLengthV0() const;
+  Double_t CascCosPointingAngle() const;
+  Double_t CascCosPointingAngleV0() const;
+  Double_t CascDcaV0ToPrimVertex() const;
+  Double_t CascDcaPosToPrimVertex() const;
+  Double_t CascDcaNegToPrimVertex() const;
+  Double_t CascDcaBachToPrimVertex() const;
+  Double_t CascMassXi() const;
+  Double_t CascMassLambda() const;
+  Double_t CascMassAntiLambda() const;
+
+  Double_t XicCosPointingAngle() const;
+
+ protected:
+
+  ClassDef(AliAODRecoCascadeHF3Prong, 1); // heavy-flavour cascade 3prong class
+};
+
+#endif
diff --git a/PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.cxx b/PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.cxx
new file mode 100644 (file)
index 0000000..7bb2144
--- /dev/null
@@ -0,0 +1,1051 @@
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appeuear in the supporting documentation. The authors make no claims   *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//
+//
+//               Lc->pK0s analysis code
+//
+//  Input: AOD
+//  Output: TTree or THnSparse (mass vs pT vs Centrality)
+//
+//  Cuts:
+//  TTree: very loose cut
+//  THnSparse: One THnSparse is created per cut. One cut is specified by
+//  an array of bits, each bit corresponds to a cut in "Cut" function.
+//  Use "AddCutStream" function to add a cut. 
+//
+//-------------------------------------------------------------------------
+//
+//                 Authors: Y.S Watanabe(a)
+//  (a) CNS, the University of Tokyo
+//  Contatcs: wyosuke@cns.s.u-tokyo.ac.jp
+//-------------------------------------------------------------------------
+
+#include <TSystem.h>
+#include <TParticle.h>
+#include <TParticlePDG.h>
+#include <TH1F.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <THnSparse.h>
+#include <TLorentzVector.h>
+#include <TTree.h>
+#include "TROOT.h"
+#include <TDatabasePDG.h>
+#include <AliAnalysisDataSlot.h>
+#include <AliAnalysisDataContainer.h>
+#include "AliStack.h"
+#include "AliMCEvent.h"
+#include "AliAnalysisManager.h"
+#include "AliAODMCHeader.h"
+#include "AliAODHandler.h"
+#include "AliLog.h"
+#include "AliExternalTrackParam.h"
+#include "AliAODVertex.h"
+#include "AliESDVertex.h"
+#include "AliAODRecoDecay.h"
+#include "AliAODRecoDecayHF.h"
+#include "AliAODRecoCascadeHF.h"
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliAODv0.h"
+#include "AliAODcascade.h"
+#include "AliAODMCParticle.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisTaskSELc2pK0sfromAODtracks.h"
+#include "AliPIDResponse.h"
+#include "AliPIDCombined.h"
+#include "AliTOFPIDResponse.h"
+#include "AliAODPidHF.h"
+#include "AliInputEventHandler.h"
+#include "AliESDtrackCuts.h"
+#include "AliNeutralTrackParam.h"
+#include "AliKFParticle.h"
+#include "AliKFVertex.h"
+#include "AliExternalTrackParam.h"
+#include "AliESDtrack.h"
+#include "AliCentrality.h"
+#include "AliVertexerTracks.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliAnalysisTaskSELc2pK0sfromAODtracks)
+
+//__________________________________________________________________________
+AliAnalysisTaskSELc2pK0sfromAODtracks::AliAnalysisTaskSELc2pK0sfromAODtracks() : 
+  AliAnalysisTaskSE(),
+  fUseMCInfo(kFALSE),
+  fOutput(0),
+  fOutputAll(0),
+  fListCuts(0),
+  fCEvents(0),
+  fHTrigger(0),
+  fHCentrality(0),
+  fProdCuts(0),
+  fAnalCuts(0),
+  fIsEventSelected(kFALSE),
+  fWriteVariableTree(kFALSE),
+  fVariablesTree(0),
+  fIspp(kFALSE),
+  fIspA(kFALSE),
+  fIsAA(kFALSE),
+  fIsMB(kFALSE),
+  fIsSemi(kFALSE),
+  fIsCent(kFALSE),
+  fIsINT7(kFALSE),
+  fIsEMC7(kFALSE),
+  fCandidateVariables(),
+  fVtx1(0),
+  fV1(0),
+  fBzkG(0),
+  fCentrality(0),
+  fTriggerCheck(0),
+  fHistoLcK0SpMass(),
+  fHistoBachPt(0),
+  fHistod0Bach(0),
+  fHistod0V0(0),
+  fHistod0d0(0),
+  fHistoV0CosPA(0),
+  fHistoProbProton(0),
+  fHistoDecayLength(0),
+  fHistoK0SMass(0)
+{
+  //
+  // Default Constructor. 
+  //
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskSELc2pK0sfromAODtracks::AliAnalysisTaskSELc2pK0sfromAODtracks(const Char_t* name,
+                                                                            AliRDHFCutsLctopK0sfromAODtracks* prodCuts, 
+                                                                            AliRDHFCutsLctopK0sfromAODtracks* analCuts, 
+                                                                            Bool_t writeVariableTree) :
+  AliAnalysisTaskSE(name),
+  fUseMCInfo(kFALSE),
+  fOutput(0),
+  fOutputAll(0),
+  fListCuts(0),
+  fCEvents(0),
+  fHTrigger(0),
+  fHCentrality(0),
+  fProdCuts(prodCuts),
+  fAnalCuts(analCuts),
+  fIsEventSelected(kFALSE),
+  fWriteVariableTree(writeVariableTree),
+  fVariablesTree(0),
+  fIspp(kFALSE),
+  fIspA(kFALSE),
+  fIsAA(kFALSE),
+  fIsMB(kFALSE),
+  fIsSemi(kFALSE),
+  fIsCent(kFALSE),
+  fIsINT7(kFALSE),
+  fIsEMC7(kFALSE),
+  fCandidateVariables(),
+  fVtx1(0),
+  fV1(0),
+  fBzkG(0),
+  fCentrality(0),
+  fTriggerCheck(0),
+  fHistoLcK0SpMass(),
+  fHistoBachPt(0),
+  fHistod0Bach(0),
+  fHistod0V0(0),
+  fHistod0d0(0),
+  fHistoV0CosPA(0),
+  fHistoProbProton(0),
+  fHistoDecayLength(0),
+  fHistoK0SMass(0)
+{
+  //
+  // Constructor. Initialization of Inputs and Outputs
+  //
+  Info("AliAnalysisTaskSELc2pK0sfromAODtracks","Calling Constructor");
+
+  DefineOutput(1,TList::Class());  //conters
+  DefineOutput(2,TList::Class());
+  if(writeVariableTree){
+    DefineOutput(3,TTree::Class());  //My private output
+  }else{
+    DefineOutput(3,TList::Class());  //conters
+  }
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskSELc2pK0sfromAODtracks::~AliAnalysisTaskSELc2pK0sfromAODtracks() {
+  //
+  // destructor
+  //
+  Info("~AliAnalysisTaskSELc2pK0sfromAODtracks","Calling Destructor");
+
+  if (fOutput) {
+    delete fOutput;
+    fOutput = 0;
+  }
+
+  if (fOutputAll) {
+    delete fOutputAll;
+    fOutputAll = 0;
+  }
+
+  if (fListCuts) {
+    delete fListCuts;
+    fListCuts = 0;
+  }
+
+
+  if (fProdCuts) {
+    delete fProdCuts;
+    fProdCuts = 0;
+  }
+
+  if (fAnalCuts) {
+    delete fAnalCuts;
+    fAnalCuts = 0;
+  }
+
+  if (fVariablesTree) {
+    delete fVariablesTree;
+    fVariablesTree = 0;
+  }
+
+}
+
+//_________________________________________________
+void AliAnalysisTaskSELc2pK0sfromAODtracks::Init() {
+  //
+  // Initialization
+  //
+  //
+
+  fIsEventSelected=kFALSE;
+
+  if (fDebug > 1) AliInfo("Init");
+
+  fListCuts = new TList();
+  fListCuts->SetOwner();
+  fListCuts->SetName("ListCuts");
+  fListCuts->Add(new AliRDHFCutsLctopK0sfromAODtracks(*fProdCuts));
+  fListCuts->Add(new AliRDHFCutsLctopK0sfromAODtracks(*fAnalCuts));
+  PostData(2,fListCuts);
+
+  return;
+}
+
+//_________________________________________________
+void AliAnalysisTaskSELc2pK0sfromAODtracks::UserExec(Option_t *)
+{
+  //
+  // UserExec
+  //
+
+  if (!fInputEvent) {
+    AliError("NO EVENT FOUND!");
+    return;
+  }
+  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
+
+  fCEvents->Fill(1);
+
+  //------------------------------------------------
+  // First check if the event has proper vertex and B
+  //------------------------------------------------
+       
+  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
+  if (!fVtx1) return;
+
+  Double_t pos[3],cov[6];
+  fVtx1->GetXYZ(pos);
+  fVtx1->GetCovarianceMatrix(cov);
+  fV1 = new AliESDVertex(pos,cov,100.,100,fVtx1->GetName());
+
+  fBzkG = (Double_t)aodEvent->GetMagneticField(); 
+  AliKFParticle::SetField(fBzkG);
+  if (TMath::Abs(fBzkG)<0.001) {
+    delete fV1;
+    return;
+  }
+  fCEvents->Fill(2);
+
+  //------------------------------------------------
+  // Event selection setting
+  //------------------------------------------------
+  if (fUseMCInfo)
+    fAnalCuts->SetTriggerClass("");
+
+  if ( !fUseMCInfo && fIspp) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kMB);
+  }
+
+  if ( !fUseMCInfo && fIspA) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kINT7);
+  }
+  if ( !fUseMCInfo && fIsAA) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kMB | AliVEvent::kSemiCentral | AliVEvent::kCentral);
+  }
+
+  //------------------------------------------------
+  // Event selection 
+  //------------------------------------------------
+  Bool_t fIsTriggerNotOK = fAnalCuts->IsEventRejectedDueToTrigger();
+  if(!fIsTriggerNotOK) fCEvents->Fill(3);
+  fIsEventSelected = fAnalCuts->IsEventSelected(aodEvent); // better to initialize before CheckEventSelection call
+  if(!fIsEventSelected) {
+    delete fV1;
+    return;
+  }
+  fCEvents->Fill(4);
+
+  fIsMB=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kMB)==(AliVEvent::kMB);
+  fIsSemi=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kSemiCentral)==(AliVEvent::kSemiCentral);
+  fIsCent=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kCentral)==(AliVEvent::kCentral); 
+  fIsINT7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kINT7)==(AliVEvent::kINT7);  
+  fIsEMC7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kEMC7)==(AliVEvent::kEMC7);   
+  fTriggerCheck = fIsMB+2*fIsSemi+4*fIsCent+8*fIsINT7+16*fIsEMC7;
+  if(fIsMB) fHTrigger->Fill(1);
+  if(fIsSemi) fHTrigger->Fill(2);
+  if(fIsCent) fHTrigger->Fill(3);
+  if(fIsINT7) fHTrigger->Fill(4);
+  if(fIsEMC7) fHTrigger->Fill(5);
+  if(fIsMB|fIsSemi|fIsCent) fHTrigger->Fill(7);
+  if(fIsINT7|fIsEMC7) fHTrigger->Fill(8);
+  if(fIsMB&fIsSemi) fHTrigger->Fill(10);
+  if(fIsMB&fIsCent) fHTrigger->Fill(11);
+  if(fIsINT7&fIsEMC7) fHTrigger->Fill(12);
+
+  if ( !fUseMCInfo && (fIsAA || fIspA)) {
+    AliCentrality *cent = aodEvent->GetCentrality();
+    fCentrality = cent->GetCentralityPercentile("V0M");
+  }
+  fHCentrality->Fill(fCentrality);
+
+  //------------------------------------------------
+  // Check if the event has v0 candidate
+  //------------------------------------------------
+  //Int_t nv0 = aodEvent->GetNumberOfV0s();
+  fCEvents->Fill(5);
+
+  //------------------------------------------------
+  // MC analysis setting
+  //------------------------------------------------
+  //  TClonesArray *mcArray = 0;
+  //  AliAODMCHeader *mcHeader=0;
+  //  if (fUseMCInfo) {
+  //    // MC array need for maching
+  //    mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+  //    if (!mcArray) {
+  //      AliError("Could not find Monte-Carlo in AOD");
+  //      return;
+  //    }
+  //    fCEvents->Fill(6); // in case of MC events
+  //
+  //    // load MC header
+  //    mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+  //    if (!mcHeader) {
+  //      AliError("AliAnalysisTaskSELc2pK0sfromAODtracks::UserExec: MC header branch not found!\n");
+  //      return;
+  //    }
+  //    fCEvents->Fill(7); // in case of MC events
+  //
+  //    Double_t zMCVertex = mcHeader->GetVtxZ();
+  //    if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
+  //      AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
+  //      return;
+  //    } else {
+  //      fCEvents->Fill(17); // in case of MC events
+  //    }
+  //   }
+
+  //------------------------------------------------
+  // Main analysis done in this function
+  //------------------------------------------------
+  MakeAnalysis(aodEvent);
+
+
+  PostData(1,fOutput);
+  if(fWriteVariableTree){
+    PostData(3,fVariablesTree);
+  }else{
+    PostData(3,fOutputAll);
+  }
+
+  fIsEventSelected=kFALSE;
+
+  delete fV1;
+  return;
+}
+
+//________________________________________ terminate ___________________________
+void AliAnalysisTaskSELc2pK0sfromAODtracks::Terminate(Option_t*)
+{    
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+  
+  //AliInfo("Terminate","");
+  AliAnalysisTaskSE::Terminate();
+  
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));
+  if (!fOutput) {     
+    AliError("fOutput not available");
+    return;
+  }
+
+  if(!fWriteVariableTree){
+    fOutputAll = dynamic_cast<TList*> (GetOutputData(3));
+    if (!fOutputAll) {     
+      AliError("fOutputAll not available");
+      return;
+    }
+  }
+
+  return;
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskSELc2pK0sfromAODtracks::UserCreateOutputObjects() 
+{ 
+  //
+  // UserCreateOutputObject
+  //
+  //AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
+
+  //------------------------------------------------
+  // output object setting
+  //------------------------------------------------
+  fOutput = new TList();
+  fOutput->SetOwner();
+  fOutput->SetName("chist0");
+  DefineGeneralHistograms(); // define general histograms
+  PostData(1,fOutput);
+
+  DefineTreeVariables();
+  if (fWriteVariableTree) {
+    PostData(3,fVariablesTree);
+  }else{
+    fOutputAll = new TList();
+    fOutputAll->SetOwner();
+    fOutputAll->SetName("anahisto");
+    DefineAnalysisHistograms(); // define general histograms
+    PostData(3,fOutputAll);
+  }
+
+
+  return;
+}
+
+//-------------------------------------------------------------------------------
+void AliAnalysisTaskSELc2pK0sfromAODtracks::MakeAnalysis
+(
+ AliAODEvent *aodEvent
+ )
+{
+  //
+  // Main Analysis part
+  //
+
+  Int_t nV0s= aodEvent->GetNumberOfV0s();
+  if (nV0s==0) {
+    return;
+  }
+  Int_t nTracks= aodEvent->GetNumberOfTracks();
+  if (nTracks==0) {
+    return;
+  }
+
+  //------------------------------------------------
+  // V0 loop 
+  //------------------------------------------------
+  for (Int_t iv0 = 0; iv0<nV0s; iv0++) {
+    AliAODv0 *v0 = aodEvent->GetV0(iv0);
+    if(!v0) continue;
+    if(!fProdCuts->SingleV0Cuts(v0,fVtx1)) continue;
+
+    AliAODTrack *cptrack =  (AliAODTrack*)(v0->GetDaughter(0));
+    AliAODTrack *cntrack =  (AliAODTrack*)(v0->GetDaughter(1));
+
+    //------------------------------------------------
+    // track loop 
+    //------------------------------------------------
+    for (Int_t itrk = 0; itrk<nTracks; itrk++) {
+      AliAODTrack *trk = (AliAODTrack*)aodEvent->GetTrack(itrk);
+      if(trk->GetID()<0) continue;
+      if(!fProdCuts->SingleTrkCuts(trk)) continue;
+
+      Int_t cpid = cptrack->GetID();
+      Int_t cnid = cntrack->GetID();
+      Int_t lpid = trk->GetID();
+      if((cpid==lpid)||(cnid==lpid)) continue;
+
+      if(!fProdCuts->SelectWithRoughCuts(v0,trk)) continue;
+
+      AliAODVertex *secVert = ReconstructSecondaryVertex(v0,trk,aodEvent);
+      if(!secVert) continue;
+
+      AliAODRecoCascadeHF *lcobj = MakeCascadeHF(v0,trk,aodEvent,secVert);
+      if(!lcobj) {
+       continue;
+      }
+
+      FillROOTObjects(lcobj);
+
+      lcobj->GetSecondaryVtx()->RemoveDaughters();
+      lcobj->UnsetOwnPrimaryVtx();
+      delete lcobj;lcobj=NULL;
+      delete secVert;
+    }
+  }
+
+}
+
+////-------------------------------------------------------------------------------
+void AliAnalysisTaskSELc2pK0sfromAODtracks::FillROOTObjects(AliAODRecoCascadeHF *lcobj) 
+{
+  //
+  // Fill histograms or tree depending on fWriteVariableTree 
+  //
+
+  AliAODTrack *trk = lcobj->GetBachelor();
+  AliAODv0 *v0 = lcobj->Getv0();
+
+  fCandidateVariables[ 0] = lcobj->InvMassLctoK0sP();
+  fCandidateVariables[ 1] = lcobj->Px();
+  fCandidateVariables[ 2] = lcobj->Py();
+  fCandidateVariables[ 3] = lcobj->Pz();
+  fCandidateVariables[ 4] = v0->MassK0Short();
+  fCandidateVariables[ 5] = lcobj->PxProng(0);
+  fCandidateVariables[ 6] = lcobj->PyProng(0);
+  fCandidateVariables[ 7] = lcobj->PzProng(0);
+  fCandidateVariables[ 8] = lcobj->PxProng(1);
+  fCandidateVariables[ 9] = lcobj->PyProng(1);
+  fCandidateVariables[10] = lcobj->PzProng(1);
+  fCandidateVariables[11] = fVtx1->GetX();
+  fCandidateVariables[12] = fVtx1->GetY();
+  fCandidateVariables[13] = fVtx1->GetZ();
+  fCandidateVariables[14] = fCentrality;
+  fCandidateVariables[15] = lcobj->DecayLengthXY();
+
+  Double_t nSigmaTPCpr=-9999.;
+  Double_t nSigmaTOFpr=-9999.;
+  Double_t probProton=-9999.;
+  if(fAnalCuts->GetIsUsePID())
+    {
+      fAnalCuts->GetPidHF()->GetnSigmaTPC(trk,4,nSigmaTPCpr);
+      fAnalCuts->GetPidHF()->GetnSigmaTOF(trk,4,nSigmaTOFpr);
+      probProton = fAnalCuts->GetProtonProbabilityTPCTOF(trk);
+      fCandidateVariables[16] = nSigmaTPCpr;
+      fCandidateVariables[17] = nSigmaTOFpr;
+      fCandidateVariables[18] = probProton;
+    }
+
+  if(fWriteVariableTree)
+    fVariablesTree->Fill();
+  else{
+    for(Int_t ic=0;ic < fAnalCuts->GetNCutsArray(); ic++)
+      {
+       fAnalCuts->SetCutsFromArray(ic);
+       if(fAnalCuts->IsSelected(lcobj,AliRDHFCuts::kCandidate))
+         {
+           Double_t cont[3];
+           cont[0] = lcobj->InvMassLctoK0sP();
+           cont[1] = lcobj->Pt();
+           cont[2] = fCentrality;
+           fHistoLcK0SpMass[ic]->Fill(cont);
+         }
+      }
+    fHistoBachPt->Fill(trk->Pt());
+    fHistod0Bach->Fill(lcobj->Getd0Prong(0));
+    fHistod0V0->Fill(lcobj->Getd0Prong(1));
+    fHistod0d0->Fill(lcobj->Getd0Prong(0)*lcobj->Getd0Prong(1));
+    fHistoV0CosPA->Fill(lcobj->CosV0PointingAngle());
+    fHistoProbProton->Fill(probProton);
+    fHistoDecayLength->Fill(lcobj->DecayLengthXY());
+    fHistoK0SMass->Fill(v0->MassK0Short());
+  }
+  return;
+}
+
+////-------------------------------------------------------------------------------
+void AliAnalysisTaskSELc2pK0sfromAODtracks::DefineTreeVariables() 
+{
+  //
+  // Define tree variables
+  //
+
+  const char* nameoutput = GetOutputSlot(3)->GetContainer()->GetName();
+  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
+  Int_t nVar = 19;
+  fCandidateVariables = new Float_t [nVar];
+  TString * fCandidateVariableNames = new TString[nVar];
+
+  fCandidateVariableNames[ 0]="InvMassLc2pK0s";
+  fCandidateVariableNames[ 1]="LcPx";
+  fCandidateVariableNames[ 2]="LcPy";
+  fCandidateVariableNames[ 3]="LcPz";
+  fCandidateVariableNames[ 4]="massK0Short";
+  fCandidateVariableNames[ 5]="V0Px";
+  fCandidateVariableNames[ 6]="V0Py";
+  fCandidateVariableNames[ 7]="V0Pz";
+  fCandidateVariableNames[ 8]="BachPx";
+  fCandidateVariableNames[ 9]="BachPy";
+  fCandidateVariableNames[10]="BachPz";
+  fCandidateVariableNames[11]="PrimVertx";
+  fCandidateVariableNames[12]="PrimVerty";
+  fCandidateVariableNames[13]="PrimVertz";
+  fCandidateVariableNames[14]="Centrality";
+  fCandidateVariableNames[15]="DecayLengthXY";
+  fCandidateVariableNames[16]="nSigmaTPCpr";
+  fCandidateVariableNames[17]="nSigmaTOFpr";
+  fCandidateVariableNames[18]="probProton";
+
+  for (Int_t ivar=0; ivar<nVar; ivar++) {
+    fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
+  }
+
+  return;
+}
+
+////__________________________________________________________________________
+void  AliAnalysisTaskSELc2pK0sfromAODtracks::DefineGeneralHistograms() {
+  //
+  // This is to define general histograms
+  //
+
+  fCEvents = new TH1F("fCEvents","conter",18,-0.5,17.5);
+  fCEvents->SetStats(kTRUE);
+  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
+  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
+  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
+  fCEvents->GetXaxis()->SetBinLabel(4,"TriggerOK");
+  fCEvents->GetXaxis()->SetBinLabel(5,"IsEventSelected");
+  fCEvents->GetXaxis()->SetBinLabel(6,"CascadesHF exists");
+  fCEvents->GetXaxis()->SetBinLabel(7,"MCarray exists");
+  fCEvents->GetXaxis()->SetBinLabel(8,"MCheader exists");
+  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
+  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
+  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
+  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
+  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
+  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
+  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
+  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
+  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
+  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
+  //fCEvents->GetXaxis()->SetTitle("");
+  fCEvents->GetYaxis()->SetTitle("counts");
+
+  fHTrigger = new TH1F("fHTrigger","counter",18,-0.5,17.5);
+  fHTrigger->SetStats(kTRUE);
+  fHTrigger->GetXaxis()->SetBinLabel(1,"X1");
+  fHTrigger->GetXaxis()->SetBinLabel(2,"kMB");
+  fHTrigger->GetXaxis()->SetBinLabel(3,"kSemiCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(4,"kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(5,"kINT7");
+  fHTrigger->GetXaxis()->SetBinLabel(6,"kEMC7");
+  //fHTrigger->GetXaxis()->SetBinLabel(7,"Space");
+  fHTrigger->GetXaxis()->SetBinLabel(8,"kMB|kSemiCentral|kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(9,"kINT7|kEMC7");
+  fHTrigger->GetXaxis()->SetBinLabel(11,"kMB&kSemiCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(12,"kMB&kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(13,"kINT7&kEMC7");
+
+  fHCentrality = new TH1F("fHCentrality","conter",100,0.,100.);
+
+  fOutput->Add(fCEvents);
+  fOutput->Add(fHTrigger);
+  fOutput->Add(fHCentrality);
+
+  return;
+}
+//__________________________________________________________________________
+void  AliAnalysisTaskSELc2pK0sfromAODtracks::DefineAnalysisHistograms() 
+{
+  //
+  // Define analyis histograms
+  //
+       
+  //------------------------------------------------
+  // Basic histogram
+  //------------------------------------------------
+  Int_t bins_base[3]=          {80                             ,20             ,10};
+  Double_t xmin_base[3]={2.286-0.2,0           ,0.00};
+  Double_t xmax_base[3]={2.286+0.2,20. ,100};
+
+  for(Int_t i=0;i<fAnalCuts->GetNCutsArray();i++)
+    {
+      fHistoLcK0SpMass.push_back(new THnSparseF(Form("fHistoLcK0SpMass_Cut%d",i),Form("Cut%d",i),3,bins_base,xmin_base,xmax_base));
+      fOutputAll->Add(fHistoLcK0SpMass[i]);
+    }
+
+  //------------------------------------------------
+  // checking histograms
+  //------------------------------------------------
+  fHistoBachPt = new TH1F("fHistoBachPt","Bachelor p_{T}",100,0.0,5.0);
+  fOutputAll->Add(fHistoBachPt);
+  fHistod0Bach = new TH1F("fHistod0Bach","Bachelor d_{0}",100,-0.5,0.5);
+  fOutputAll->Add(fHistod0Bach);
+  fHistod0V0 = new TH1F("fHistod0V0","V_{0} d_{0}",100,-0.5,0.5);
+  fOutputAll->Add(fHistod0V0);
+  fHistod0d0 = new TH1F("fHistod0d0","d_{0} d_{0}",100,-0.5,0.5);
+  fOutputAll->Add(fHistod0d0);
+  fHistoV0CosPA=new TH1F("fHistoV0CosPA","V0->Second vertex cospa",100,-1.,1.0);
+  fOutputAll->Add(fHistoV0CosPA);
+  fHistoProbProton=new TH1F("fHistoProbProton","ProbProton",100,0.,1.0);
+  fOutputAll->Add(fHistoProbProton);
+  fHistoDecayLength=new TH1F("fHistoDecayLength","Decay Length",100,-0.1,0.1);
+  fOutputAll->Add(fHistoDecayLength);
+  fHistoK0SMass=new TH1F("fHistoK0SMass","K0S mass",100,0.497-0.05,0.497+0.05);
+  fOutputAll->Add(fHistoK0SMass);
+
+  return;
+}
+
+//________________________________________________________________________
+AliAODRecoCascadeHF* AliAnalysisTaskSELc2pK0sfromAODtracks::MakeCascadeHF(AliAODv0 *v0, AliAODTrack *part, AliAODEvent * aod, AliAODVertex *secVert) 
+{
+  //
+  // Create AliAODRecoCascadeHF object from the argument
+  //
+
+  if(!v0) return 0x0;
+  if(!part) return 0x0;
+  if(!aod) return 0x0;
+
+  //------------------------------------------------
+  // PrimaryVertex
+  //------------------------------------------------
+  AliAODVertex *primVertexAOD;
+  Bool_t unsetvtx = kFALSE;
+  if(fIspp){
+    primVertexAOD = CallPrimaryVertex(v0,part,aod);
+    if(!primVertexAOD){
+      primVertexAOD = fVtx1;
+    }else{
+      unsetvtx = kTRUE;
+    }
+  }else{
+    primVertexAOD = fVtx1;
+  }
+  if(!primVertexAOD) return 0x0;
+  Double_t posprim[3]; primVertexAOD->GetXYZ(posprim);
+
+  //------------------------------------------------
+  // DCA between tracks
+  //------------------------------------------------
+  AliESDtrack *esdtrack = new AliESDtrack((AliVTrack*)part);
+
+  AliNeutralTrackParam *trackV0=NULL;
+  const AliVTrack *trackVV0 = dynamic_cast<const AliVTrack*>(v0);
+  if(trackVV0)  trackV0 = new AliNeutralTrackParam(trackVV0);
+
+  Double_t xdummy, ydummy;
+  Double_t dca = esdtrack->GetDCA(trackV0,fBzkG,xdummy,ydummy);
+
+
+  //------------------------------------------------
+  // Propagate all tracks to the secondary vertex and calculate momentum there
+  //------------------------------------------------
+       
+  Double_t d0z0bach[2],covd0z0bach[3];
+  if(sqrt(pow(secVert->GetX(),2)+pow(secVert->GetY(),2))<1.){
+    part->PropagateToDCA(secVert,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
+    trackV0->PropagateToDCA(secVert,fBzkG,kVeryBig);
+  }else{
+    part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
+    trackV0->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig);
+  }
+  Double_t momv0_new[3]={-9999,-9999,-9999.};
+  trackV0->GetPxPyPz(momv0_new);
+
+  Double_t px[2],py[2],pz[2];
+  px[0] = part->Px(); py[0] = part->Py(); pz[0] = part->Pz(); 
+  px[1] = momv0_new[0]; py[1] = momv0_new[1]; pz[1] = momv0_new[2]; 
+
+  //------------------------------------------------
+  // d0
+  //------------------------------------------------
+  Double_t d0[3],d0err[3];
+
+  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
+  d0[0]= d0z0bach[0];
+  d0err[0] = TMath::Sqrt(covd0z0bach[0]);
+
+  Double_t d0z0v0[2],covd0z0v0[3];
+  trackV0->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0v0,covd0z0v0);
+  d0[1]= d0z0v0[0];
+  d0err[1] = TMath::Sqrt(covd0z0v0[0]);
+
+  //------------------------------------------------
+  // Create AliAODRecoCascadeHF
+  //------------------------------------------------
+  Short_t charge = part->Charge();
+  AliAODRecoCascadeHF *theCascade = new AliAODRecoCascadeHF(secVert,charge,px,py,pz,d0,d0err,dca);
+  if(!theCascade)  
+    {
+      if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+      if(esdtrack) delete esdtrack;
+      if(trackV0) delete trackV0;
+      return 0x0;
+    }
+  theCascade->SetOwnPrimaryVtx(primVertexAOD);
+  UShort_t id[2]={(UShort_t)part->GetID(),(UShort_t)trackV0->GetID()};
+  theCascade->SetProngIDs(2,id);
+
+  theCascade->GetSecondaryVtx()->AddDaughter(part);
+  theCascade->GetSecondaryVtx()->AddDaughter(v0);
+
+  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+  if(esdtrack) delete esdtrack;
+  if(trackV0) delete trackV0;
+
+  return theCascade;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSELc2pK0sfromAODtracks::CallPrimaryVertex(AliAODv0 *v0, AliAODTrack *trk, AliAODEvent* aod)
+{
+  //
+  // Make an array of tracks which should not be used in primary vertex calculation and 
+  // Call PrimaryVertex function
+  //
+
+  TObjArray *TrackArray = new TObjArray(3);
+  
+  AliESDtrack *cptrk1 = new AliESDtrack((AliVTrack*)trk);
+  TrackArray->AddAt(cptrk1,0);
+  
+  AliESDtrack *cascptrack = new AliESDtrack((AliVTrack*)v0->GetDaughter(0));
+  TrackArray->AddAt(cascptrack,1);
+  AliESDtrack *cascntrack = new AliESDtrack((AliVTrack*)v0->GetDaughter(1));
+  TrackArray->AddAt(cascntrack,2);
+  
+  AliAODVertex *newvert  = PrimaryVertex(TrackArray,aod);
+  
+  for(Int_t i=0;i<3;i++)
+    {
+      AliESDtrack *tesd = (AliESDtrack*)TrackArray->UncheckedAt(i);
+      delete tesd;
+    }
+  TrackArray->Clear();
+  delete TrackArray;
+  
+  return newvert;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSELc2pK0sfromAODtracks::PrimaryVertex(const TObjArray *trkArray,
+                                                                  AliVEvent *event)
+{
+  //
+  //Used only for pp
+  //copied from AliAnalysisVertexingHF (except for the following 3 lines)
+  //
+
+  Bool_t fRecoPrimVtxSkippingTrks = kTRUE;
+  Bool_t fRmTrksFromPrimVtx = kFALSE;
+
+  AliESDVertex *vertexESD = 0;
+  AliAODVertex *vertexAOD = 0;
+  
+  //vertexESD = new AliESDVertex(*fV1);
+  
+
+  if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) { 
+    // primary vertex from the input event
+    
+    vertexESD = new AliESDVertex(*fV1);
+    
+  } else {
+    // primary vertex specific to this candidate
+    
+    Int_t nTrks = trkArray->GetEntriesFast();
+    AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
+    
+    if(fRecoPrimVtxSkippingTrks) { 
+      // recalculating the vertex
+      
+      if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
+       Float_t diamondcovxy[3];
+       event->GetDiamondCovXY(diamondcovxy);
+       Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
+       Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
+       AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
+       vertexer->SetVtxStart(diamond);
+       delete diamond; diamond=NULL;
+       if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter")) 
+         vertexer->SetOnlyFitter();
+      }
+      Int_t skipped[1000];
+      Int_t nTrksToSkip=0,id;
+      AliExternalTrackParam *t = 0;
+      for(Int_t i=0; i<nTrks; i++) {
+       t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
+       id = (Int_t)t->GetID();
+       if(id<0) continue;
+       skipped[nTrksToSkip++] = id;
+      }
+      // TEMPORARY FIX
+      // For AOD, skip also tracks without covariance matrix
+      Double_t covtest[21];
+      for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
+       AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
+       if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
+         id = (Int_t)vtrack->GetID();
+         if(id<0) continue;
+         skipped[nTrksToSkip++] = id;
+       }
+      }
+      for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
+      //
+      vertexer->SetSkipTracks(nTrksToSkip,skipped);
+      vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event); 
+      
+    } else if(fRmTrksFromPrimVtx && nTrks>0) { 
+      // removing the prongs tracks
+      
+      TObjArray rmArray(nTrks);
+      UShort_t *rmId = new UShort_t[nTrks];
+      AliESDtrack *esdTrack = 0;
+      AliESDtrack *t = 0;
+      for(Int_t i=0; i<nTrks; i++) {
+       t = (AliESDtrack*)trkArray->UncheckedAt(i);
+       esdTrack = new AliESDtrack(*t);
+       rmArray.AddLast(esdTrack);
+       if(esdTrack->GetID()>=0) {
+         rmId[i]=(UShort_t)esdTrack->GetID();
+       } else {
+         rmId[i]=9999;
+       }
+      }
+      Float_t diamondxy[2]={static_cast<Float_t>(event->GetDiamondX()),static_cast<Float_t>(event->GetDiamondY())};
+      vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
+      delete [] rmId; rmId=NULL;
+      rmArray.Delete();
+      
+    }
+    
+    delete vertexer; vertexer=NULL;
+    if(!vertexESD) return vertexAOD;
+    if(vertexESD->GetNContributors()<=0) { 
+      //AliDebug(2,"vertexing failed"); 
+      delete vertexESD; vertexESD=NULL;
+      return vertexAOD;
+    }
+    
+    
+  }
+  
+  // convert to AliAODVertex
+  Double_t pos[3],cov[6],chi2perNDF;
+  vertexESD->GetXYZ(pos); // position
+  vertexESD->GetCovMatrix(cov); //covariance matrix
+  chi2perNDF = vertexESD->GetChi2toNDF();
+  delete vertexESD; vertexESD=NULL;
+  
+  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
+  
+  return vertexAOD;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSELc2pK0sfromAODtracks::ReconstructSecondaryVertex(AliAODv0 *v0, AliAODTrack *part, AliAODEvent * aod) 
+{
+  //
+  // Reconstruct secondary vertex from trkArray (Copied from AliAnalysisVertexingHF)
+  //
+  //------------------------------------------------
+  // PrimaryVertex
+  //------------------------------------------------
+  AliAODVertex *primVertexAOD;
+  Bool_t unsetvtx = kFALSE;
+  if(fIspp){
+    primVertexAOD = CallPrimaryVertex(v0,part,aod);
+    if(!primVertexAOD){
+      primVertexAOD = fVtx1;
+    }else{
+      unsetvtx = kTRUE;
+    }
+  }else{
+    primVertexAOD = fVtx1;
+  }
+  if(!primVertexAOD) return 0x0;
+
+  //------------------------------------------------
+  // Secondary vertex
+  //------------------------------------------------
+
+  Double_t LcPx = part->Px()+v0->Px();
+  Double_t LcPy = part->Py()+v0->Py();
+  Double_t LcPt = TMath::Sqrt(LcPx*LcPx+LcPy*LcPy);
+
+  Double_t d0z0[2],covd0z0[3];
+  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+  Double_t x0 = primVertexAOD->GetX();
+  Double_t y0 = primVertexAOD->GetY();
+  Double_t px0 = LcPx/LcPt;
+  Double_t py0 = LcPy/LcPt;
+  Double_t tx[3];
+  part->GetXYZ(tx);
+  Double_t x1 = tx[0];
+  Double_t y1 = tx[1];
+  part->GetPxPyPz(tx);
+  Double_t px1 = tx[0];
+  Double_t py1 = tx[1];
+  Double_t pt1 = sqrt(px1*px1+py1*py1);
+  px1 = px1/pt1;
+  py1 = py1/pt1;
+
+  Double_t dx = x0 - x1;
+  Double_t dy = y0 - y1;
+
+  Double_t Delta = -px0*py1+py0*px1;
+  Double_t a0 = -9999.;
+  if(Delta!=0)
+    {
+      a0 = 1./Delta * (py1 * dx - px1 * dy);
+    }
+  Double_t neovertx = x0 + a0 * px0;
+  Double_t neoverty = y0 + a0 * py0;
+  Double_t z0 = primVertexAOD->GetZ();
+  Double_t neovertz = z0 + TMath::Abs(a0)*part->Pz()/part->Pt();
+
+  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+
+  Double_t pos[3],cov[6],chi2perNDF;
+  pos[0]=neovertx;
+  pos[1]=neoverty;
+  pos[2]=neovertz;
+  cov[0]=0.0;
+  cov[1]=0.0;
+  cov[2]=0.0;
+  cov[3]=0.0;
+  cov[4]=0.0;
+  cov[5]=0.0;
+  chi2perNDF=0.0;
+  AliAODVertex *secVert = new AliAODVertex(pos,cov,chi2perNDF);
+  if(!secVert){
+    return 0x0;
+  }
+  return secVert;
+}
diff --git a/PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.h b/PWGHF/vertexingHF/AliAnalysisTaskSELc2pK0sfromAODtracks.h
new file mode 100644 (file)
index 0000000..8e816de
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef ALIANALYSISTASKSELC2PK0SFROMAODTRACKS_H
+#define ALIANALYSISTASKSELC2PK0SFROMAODTRACKS_H
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */ 
+
+#include "TROOT.h"
+#include "TSystem.h"
+
+#include "AliAnalysisTaskSE.h"
+#include "AliAODEvent.h"
+#include "AliPID.h"
+#include "AliRDHFCutsLctopK0sfromAODtracks.h"
+
+class THnSparse;
+class TH1F;
+class TClonesArray;
+class AliAODRecoCascadeHF;
+class AliESDVertex;
+
+class AliAnalysisTaskSELc2pK0sfromAODtracks : public AliAnalysisTaskSE 
+{
+ public:
+  AliAnalysisTaskSELc2pK0sfromAODtracks();
+  AliAnalysisTaskSELc2pK0sfromAODtracks(const Char_t* name, AliRDHFCutsLctopK0sfromAODtracks* cuts, AliRDHFCutsLctopK0sfromAODtracks* cuts2, Bool_t writeVariableTree=kTRUE);
+  virtual ~AliAnalysisTaskSELc2pK0sfromAODtracks();
+
+  // Implementation of interface methods  
+  virtual void UserCreateOutputObjects();
+  virtual void Init();
+  virtual void LocalInit() {Init();}
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+
+  void FillROOTObjects(AliAODRecoCascadeHF *lcobj);
+  void MakeAnalysis(AliAODEvent *aod);
+
+
+  // set MC usage
+  void SetMC(Bool_t theMCon) {fUseMCInfo = theMCon;}
+  Bool_t GetMC() const {return fUseMCInfo;}
+
+  void SetIspp(Bool_t a) { fIspp=a; }
+  Bool_t GetIspp() { return fIspp; }
+  void SetIspA(Bool_t a) { fIspA=a; }
+  Bool_t GetIspA() { return fIspA; }
+  void SetIsAA(Bool_t a) { fIsAA=a; }
+  Bool_t GetIsAA() { return fIsAA; }
+
+  AliAODRecoCascadeHF* MakeCascadeHF(AliAODv0 *casc, AliAODTrack *trk, AliAODEvent *aod, AliAODVertex *vert);
+  AliAODVertex* ReconstructSecondaryVertex(AliAODv0 *casc, AliAODTrack *trk, AliAODEvent *aod);
+
+
+ private:
+
+  AliAnalysisTaskSELc2pK0sfromAODtracks(const AliAnalysisTaskSELc2pK0sfromAODtracks &source);
+  AliAnalysisTaskSELc2pK0sfromAODtracks& operator=(const AliAnalysisTaskSELc2pK0sfromAODtracks& source); 
+
+  void DefineTreeVariables();
+  void DefineGeneralHistograms();
+  void DefineAnalysisHistograms();
+
+  AliAODVertex *CallPrimaryVertex(AliAODv0 *v0, AliAODTrack *trk, AliAODEvent *evt);
+  AliAODVertex* PrimaryVertex(const TObjArray *trkArray,AliVEvent *event);
+
+  Bool_t fUseMCInfo;                 // Use MC info
+  TList *fOutput;                    //! User output slot 1 // general histos
+  TList *fOutputAll;                 //! User Output slot 3  //analysis histograms 
+  TList *fListCuts;                  //! User output slot 2 // Cuts 
+  TH1F *fCEvents;                    //! Histogram to check selected events
+  TH1F *fHTrigger;                   //! Histogram to check Trigger
+  TH1F *fHCentrality;                //! Histogram to check Centrality
+  AliRDHFCutsLctopK0sfromAODtracks *fProdCuts;// Cuts - sent to output slot 2
+  AliRDHFCutsLctopK0sfromAODtracks *fAnalCuts;// Cuts - sent to output slot 2
+  Bool_t fIsEventSelected;          // flag for event selected
+  Bool_t    fWriteVariableTree;     // flag to decide whether to write the candidate variables on a tree variables
+  TTree    *fVariablesTree;         //! tree of the candidate variables after track selection on output slot 4
+  Bool_t fIspp;       //ispp event 
+  Bool_t fIspA;       //ispA event 
+  Bool_t fIsAA;       //isAA event 
+  Bool_t fIsMB;       //MB trigger event
+  Bool_t fIsSemi;     //SemiCentral trigger event
+  Bool_t fIsCent;     //Central trigger event
+  Bool_t fIsINT7;     //INT7 trigger event
+  Bool_t fIsEMC7;     //EMC7 trigger event
+  Float_t *fCandidateVariables;   //! variables to be written to the tree
+  AliAODVertex *fVtx1;            // primary vertex
+  AliESDVertex *fV1;              // primary vertex
+  Double_t fBzkG;                 // magnetic field value [kG]
+  Float_t  fCentrality;           //Centrality
+  Float_t  fTriggerCheck;         //Stores trigger information
+
+  //--------------------- My histograms ------------------
+  std::vector<THnSparse*> fHistoLcK0SpMass;         //Lc mass spectra
+
+  TH1F* fHistoBachPt;      //! Bachelor pT histogram
+  TH1F* fHistod0Bach;      //! Bachelor d0 histogram
+  TH1F* fHistod0V0;        //! V0 d0 histogram
+  TH1F* fHistod0d0;        //! Bachelor d0 * V0 d0 histogram
+  TH1F* fHistoV0CosPA;     //! V0 cosine pointing angle to primary vertex
+  TH1F* fHistoProbProton;  //! Probability to be proton histogram
+  TH1F* fHistoDecayLength; //! Decay length histogram
+  TH1F* fHistoK0SMass;     //! K0s mass histogram
+
+
+  ClassDef(AliAnalysisTaskSELc2pK0sfromAODtracks,1); // class for Lc->p K0
+};
+#endif
+
diff --git a/PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.cxx b/PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.cxx
new file mode 100644 (file)
index 0000000..b107b23
--- /dev/null
@@ -0,0 +1,1359 @@
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appeuear in the supporting documentation. The authors make no claims   *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//
+//
+//               XicPlus2XiPiPi analysis code
+//
+//  Input: AOD
+//  Output: TTree or THnSparse (mass vs pT vs Centrality)
+//
+//  Cuts:
+//  TTree: very loose cut
+//  THnSparse: One THnSparse is created per cut. One cut is specified by
+//  an array of bits, each bit corresponds to a cut in "Cut" function.
+//
+//-------------------------------------------------------------------------
+//
+//                 Authors: Y.S Watanabe(a)
+//  (a) CNS, the University of Tokyo
+//  Contatcs: wyosuke@cns.s.u-tokyo.ac.jp
+//-------------------------------------------------------------------------
+
+#include <TSystem.h>
+#include <TParticle.h>
+#include <TParticlePDG.h>
+#include <THnSparse.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TLorentzVector.h>
+#include <TTree.h>
+#include "TROOT.h"
+#include <TDatabasePDG.h>
+#include <AliAnalysisDataSlot.h>
+#include <AliAnalysisDataContainer.h>
+#include "AliStack.h"
+#include "AliMCEvent.h"
+#include "AliAnalysisManager.h"
+#include "AliAODMCHeader.h"
+#include "AliAODHandler.h"
+#include "AliLog.h"
+#include "AliExternalTrackParam.h"
+#include "AliAODVertex.h"
+#include "AliESDVertex.h"
+#include "AliAODRecoDecay.h"
+#include "AliAODRecoDecayHF.h"
+#include "AliAODRecoCascadeHF3Prong.h"
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliAODv0.h"
+#include "AliAODcascade.h"
+#include "AliAODMCParticle.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.h"
+#include "AliPIDResponse.h"
+#include "AliPIDCombined.h"
+#include "AliAODPidHF.h"
+#include "AliInputEventHandler.h"
+#include "AliESDtrackCuts.h"
+#include "AliNeutralTrackParam.h"
+#include "AliKFParticle.h"
+#include "AliKFVertex.h"
+#include "AliExternalTrackParam.h"
+#include "AliCentrality.h"
+#include "AliVertexerTracks.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks)
+
+//__________________________________________________________________________
+AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks() : 
+  AliAnalysisTaskSE(),
+  fUseMCInfo(kFALSE),
+  fOutput(0),
+  fOutputAll(0),
+  fListCuts(0),
+  fCEvents(0),
+  fHTrigger(0),
+  fHCentrality(0),
+  fProdCuts(0),
+  fAnalCuts(0),
+  fIsEventSelected(kFALSE),
+  fWriteVariableTree(kFALSE),
+  fVariablesTree(0),
+  fIspp(kFALSE),
+  fIspA(kFALSE),
+  fIsAA(kFALSE),
+  fIsMB(kFALSE),
+  fIsSemi(kFALSE),
+  fIsCent(kFALSE),
+  fIsINT7(kFALSE),
+  fIsEMC7(kFALSE),
+  fCandidateVariables(),
+  fVtx1(0),
+  fV1(0),
+  fBzkG(0),
+  fCentrality(0),
+  fTriggerCheck(0),
+  fHistoXicMass(),
+  fHistoDcaPi1Pi2(0),
+  fHistoDcaPiCasc(0),
+  fHistoLikeDecayLength(0),
+  fHistoLikeDecayLengthXY(0),
+  fHistoXicCosPAXY(0),
+  fHistoXiMass(0),
+  fHistoCascDcaXiDaughters(0),
+  fHistoCascDcaV0Daughters(0),
+  fHistoCascDcaV0ToPrimVertex(0),
+  fHistoCascDcaPosToPrimVertex(0),
+  fHistoCascDcaNegToPrimVertex(0),
+  fHistoCascDcaBachToPrimVertex(0),
+  fHistoCascCosPAXiPrim(0),
+  fHistoXiPt(0),
+  fHistoPiPt(0),
+  fHistoPid0(0),
+  fHistonSigmaTPCpi(0),
+  fHistonSigmaTOFpi(0),
+  fHistoProbPion(0)
+{
+  //
+  // Default Constructor. 
+  //
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks(const Char_t* name,
+                                                                                          AliRDHFCutsXicPlustoXiPiPifromAODtracks* prodCuts,
+                                                                                          AliRDHFCutsXicPlustoXiPiPifromAODtracks* analCuts, 
+                                                                                          Bool_t writeVariableTree) :
+  AliAnalysisTaskSE(name),
+  fUseMCInfo(kFALSE),
+  fOutput(0),
+  fOutputAll(0),
+  fListCuts(0),
+  fCEvents(0),
+  fHTrigger(0),
+  fHCentrality(0),
+  fProdCuts(prodCuts),
+  fAnalCuts(analCuts),
+  fIsEventSelected(kFALSE),
+  fWriteVariableTree(writeVariableTree),
+  fVariablesTree(0),
+  fIspp(kFALSE),
+  fIspA(kFALSE),
+  fIsAA(kFALSE),
+  fIsMB(kFALSE),
+  fIsSemi(kFALSE),
+  fIsCent(kFALSE),
+  fIsINT7(kFALSE),
+  fIsEMC7(kFALSE),
+  fCandidateVariables(),
+  fVtx1(0),
+  fV1(0),
+  fBzkG(0),
+  fCentrality(0),
+  fTriggerCheck(0),
+  fHistoXicMass(),
+  fHistoDcaPi1Pi2(0),
+  fHistoDcaPiCasc(0),
+  fHistoLikeDecayLength(0),
+  fHistoLikeDecayLengthXY(0),
+  fHistoXicCosPAXY(0),
+  fHistoXiMass(0),
+  fHistoCascDcaXiDaughters(0),
+  fHistoCascDcaV0Daughters(0),
+  fHistoCascDcaV0ToPrimVertex(0),
+  fHistoCascDcaPosToPrimVertex(0),
+  fHistoCascDcaNegToPrimVertex(0),
+  fHistoCascDcaBachToPrimVertex(0),
+  fHistoCascCosPAXiPrim(0),
+  fHistoXiPt(0),
+  fHistoPiPt(0),
+  fHistoPid0(0),
+  fHistonSigmaTPCpi(0),
+  fHistonSigmaTOFpi(0),
+  fHistoProbPion(0)
+{
+  //
+  // Constructor. Initialization of Inputs and Outputs
+  //
+  Info("AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks","Calling Constructor");
+  
+  DefineOutput(1,TList::Class());
+  DefineOutput(2,TList::Class());
+  if(writeVariableTree){
+    DefineOutput(3,TTree::Class());
+  }else{
+    DefineOutput(3,TList::Class());
+  }
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::~AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks() {
+  //
+  // destructor
+  //
+  Info("~AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks","Calling Destructor");
+  
+  
+  if (fOutput) {
+    delete fOutput;
+    fOutput = 0;
+  }
+  
+  if (fOutputAll) {
+    delete fOutputAll;
+    fOutputAll = 0;
+  }
+
+  if (fListCuts) {
+    delete fListCuts;
+    fListCuts = 0;
+  }
+  
+  
+  if (fAnalCuts) {
+    delete fAnalCuts;
+    fAnalCuts = 0;
+  }
+
+  if (fProdCuts) {
+    delete fProdCuts;
+    fProdCuts = 0;
+  }
+  
+  if (fVariablesTree) {
+    delete fVariablesTree;
+    fVariablesTree = 0;
+  }
+  
+  if(fCandidateVariables){
+    delete fCandidateVariables;
+    fCandidateVariables = 0;
+  }
+  
+}
+
+//_________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::Init() {
+  //
+  // Initialization
+  //
+  //
+  
+  //Copied from $ALICE_ROOT/PWGHF/vertexingHF/ConfigVertexingHF.C
+  
+  fIsEventSelected=kFALSE;
+  
+  if (fDebug > 1) AliInfo("Init");
+  
+  fListCuts = new TList();
+  fListCuts->SetOwner();
+  fListCuts->SetName("ListCuts");
+  fListCuts->Add(new AliRDHFCutsXicPlustoXiPiPifromAODtracks(*fProdCuts));
+  fListCuts->Add(new AliRDHFCutsXicPlustoXiPiPifromAODtracks(*fAnalCuts));
+  PostData(2,fListCuts);
+
+  return;
+}
+
+//_________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::UserExec(Option_t *)
+{
+  //
+  // UserExec code
+  //
+
+  if (!fInputEvent) {
+    AliError("NO EVENT FOUND!");
+    return;
+  }
+  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
+  
+  
+  fCEvents->Fill(1);
+  //------------------------------------------------
+  // First check if the event has proper vertex and B
+  //------------------------------------------------
+  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
+  if (!fVtx1) return;
+  
+  Double_t pos[3],cov[6];
+  fVtx1->GetXYZ(pos);
+  fVtx1->GetCovarianceMatrix(cov);
+  fV1 = new AliESDVertex(pos,cov,100.,100,fVtx1->GetName());
+  
+  fBzkG = (Double_t)aodEvent->GetMagneticField(); 
+  AliKFParticle::SetField(fBzkG);
+  if (TMath::Abs(fBzkG)<0.001) {
+    delete fV1;
+    return;
+  }
+  fCEvents->Fill(2);
+  
+  //------------------------------------------------
+  // Event selection setting 
+  //------------------------------------------------
+  if (fUseMCInfo)
+    fAnalCuts->SetTriggerClass("");
+  
+  if ( !fUseMCInfo && fIspp) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kMB);
+  }
+  
+  if ( !fUseMCInfo && fIspA) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kINT7);
+  }
+  if ( !fUseMCInfo && fIsAA) {
+    fAnalCuts->SetUsePhysicsSelection(kTRUE);
+    fAnalCuts->SetTriggerClass("");
+    fAnalCuts->SetTriggerMask(AliVEvent::kMB | AliVEvent::kSemiCentral | AliVEvent::kCentral);
+  }
+  
+  //------------------------------------------------
+  // Event selection 
+  //------------------------------------------------
+  Bool_t fIsTriggerNotOK = fAnalCuts->IsEventRejectedDueToTrigger();
+  if(!fIsTriggerNotOK) fCEvents->Fill(3);
+  
+  
+  fIsEventSelected = fAnalCuts->IsEventSelected(aodEvent); 
+  if(!fIsEventSelected) {
+    //cout<<"Why: "<<fAnalCuts->GetWhyRejection()<<endl;
+    delete fV1;
+    return;
+  }
+  
+  //cout<<fabs(aodEvent->GetPrimaryVertex()->GetZ()-aodEvent->GetPrimaryVertexSPD()->GetZ())<<endl;
+  
+  fCEvents->Fill(4);
+  
+  fIsMB=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kMB)==(AliVEvent::kMB);
+  fIsSemi=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kSemiCentral)==(AliVEvent::kSemiCentral);
+  fIsCent=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kCentral)==(AliVEvent::kCentral); 
+  fIsINT7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kINT7)==(AliVEvent::kINT7);  
+  fIsEMC7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kEMC7)==(AliVEvent::kEMC7);   
+  fTriggerCheck = fIsMB+2*fIsSemi+4*fIsCent+8*fIsINT7+16*fIsEMC7;
+  if(fIsMB) fHTrigger->Fill(1);
+  if(fIsSemi) fHTrigger->Fill(2);
+  if(fIsCent) fHTrigger->Fill(3);
+  if(fIsINT7) fHTrigger->Fill(4);
+  if(fIsEMC7) fHTrigger->Fill(5);
+  if(fIsMB|fIsSemi|fIsCent) fHTrigger->Fill(7);
+  if(fIsINT7|fIsEMC7) fHTrigger->Fill(8);
+  if(fIsMB&fIsSemi) fHTrigger->Fill(10);
+  if(fIsMB&fIsCent) fHTrigger->Fill(11);
+  if(fIsINT7&fIsEMC7) fHTrigger->Fill(12);
+  
+  if ( !fUseMCInfo && (fIsAA || fIspA)) {
+    AliCentrality *cent = aodEvent->GetCentrality();
+    fCentrality = cent->GetCentralityPercentile("V0M");
+  }
+  fHCentrality->Fill(fCentrality);
+  
+  //------------------------------------------------
+  // Check if the event has cascade candidate
+  //------------------------------------------------
+  Int_t ncasc = aodEvent->GetNumberOfCascades();
+  Int_t nselecasc = 0.;
+  for(Int_t ic=0;ic<ncasc;ic++){
+    AliAODcascade *casc = aodEvent->GetCascade(ic);
+    if(!fProdCuts) continue;
+    if(fProdCuts->SingleCascadeCuts(casc)) nselecasc++;
+  }
+  
+  if(nselecasc==0){
+    delete fV1;
+    return;
+  }
+  
+  fCEvents->Fill(5);
+  
+  //------------------------------------------------
+  // MC analysis setting
+  //------------------------------------------------
+  //  TClonesArray *mcArray = 0;
+  //  AliAODMCHeader *mcHeader=0;
+  //  if (fUseMCInfo) {
+  //    // MC array need for maching
+  //    mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+  //    if (!mcArray) {
+  //      AliError("Could not find Monte-Carlo in AOD");
+  //      delete fV1;
+  //      return;
+  //    }
+  //    fCEvents->Fill(6); // in case of MC events
+  //    
+  //    // load MC header
+  //    mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+  //    if (!mcHeader) {
+  //      AliError("AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::UserExec: MC header branch not found!\n");
+  //      delete fV1;
+  //      return;
+  //    }
+  //    fCEvents->Fill(7); // in case of MC events
+  //    
+  //    Double_t zMCVertex = mcHeader->GetVtxZ();
+  //    if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
+  //      AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
+  //      delete fV1;
+  //      return;
+  //    } else {
+  //      fCEvents->Fill(17); // in case of MC events
+  //    }
+  //  }
+  
+  //------------------------------------------------
+  // Main analysis done in this function
+  //------------------------------------------------
+  MakeAnalysis(aodEvent);
+  
+  PostData(1,fOutput);
+  if(fWriteVariableTree){
+    PostData(3,fVariablesTree);
+  }else{
+    PostData(3,fOutputAll);
+  }
+  
+  fIsEventSelected=kFALSE;
+  
+  delete fV1;
+  return;
+}
+
+//________________________________________ terminate ___________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::Terminate(Option_t*)
+{    
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+  
+  //AliInfo("Terminate","");
+  AliAnalysisTaskSE::Terminate();
+  
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));
+  if (!fOutput) {     
+    AliError("fOutput not available");
+    return;
+  }
+  
+  if(!fWriteVariableTree){
+    fOutputAll = dynamic_cast<TList*> (GetOutputData(3));
+    if (!fOutputAll) {     
+      AliError("fOutputAll not available");
+      return;
+    }
+  }
+  
+  return;
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::UserCreateOutputObjects() 
+{ 
+  //
+  // UserCreateOutputObjects
+  //
+
+  AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
+  
+  //------------------------------------------------
+  // output object setting
+  //------------------------------------------------
+  fOutput = new TList();
+  fOutput->SetOwner();
+  fOutput->SetName("chist0");
+  DefineGeneralHistograms(); // define general histograms
+  PostData(1,fOutput);
+  
+  DefineTreeVariables();
+  if (fWriteVariableTree) {
+    PostData(3,fVariablesTree);
+  }else{
+    fOutputAll = new TList();
+    fOutputAll->SetOwner();
+    fOutputAll->SetName("anahisto");
+    DefineAnalysisHistograms(); // define general histograms
+    PostData(3,fOutputAll);
+  }
+
+
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::MakeAnalysis
+(
+ AliAODEvent *aodEvent
+ )
+{
+  //
+  // Main analysis part called from UserExec
+  //
+
+  Int_t nCascades= aodEvent->GetNumberOfCascades();
+  if (nCascades==0) {
+    return;
+  }
+  Int_t nTracks= aodEvent->GetNumberOfTracks();
+  if (nTracks==0) {
+    return;
+  }
+  
+  //------------------------------------------------
+  // Select good track before hand to save time
+  //------------------------------------------------
+  Bool_t  seleTrkFlags[nTracks];
+  Int_t nSeleTrks=0;
+  SelectTrack(aodEvent,nTracks,nSeleTrks,seleTrkFlags);
+  Bool_t  seleCascFlags[nCascades];
+  Int_t     nSeleCasc=0;
+  SelectCascade(aodEvent,nCascades,nSeleCasc,seleCascFlags);
+  
+  //------------------------------------------------
+  // Cascade loop 
+  //------------------------------------------------
+  for (Int_t icasc = 0; icasc<nCascades; icasc++) {
+    if(!seleCascFlags[icasc]) continue;
+    AliAODcascade *casc = aodEvent->GetCascade(icasc);
+    if(!casc) continue;
+    
+    AliAODTrack *cptrack =  (AliAODTrack*)(casc->GetDaughter(0));
+    AliAODTrack *cntrack =  (AliAODTrack*)(casc->GetDaughter(1));
+    AliAODTrack *cbtrack =  (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0));
+    if(!cptrack || !cntrack || !cbtrack) continue;
+    
+    Int_t cpid = cptrack->GetID();
+    Int_t cnid = cntrack->GetID();
+    Int_t cbid = cbtrack->GetID();
+
+    if(cptrack->Charge()==0) continue;
+    if(cntrack->Charge()==0) continue;
+    if(cbtrack->Charge()==0) continue;
+
+    Short_t charge_casc = cptrack->Charge() + cntrack->Charge() + cbtrack->Charge();
+    
+    //------------------------------------------------
+    // Track1 loop 
+    //------------------------------------------------
+    for (Int_t itrk1 = 0; itrk1<nTracks-1; itrk1++) {
+      if(!seleTrkFlags[itrk1]) continue;
+      AliAODTrack *trk1 = (AliAODTrack*)aodEvent->GetTrack(itrk1);
+      if(!trk1||trk1->GetID()<0) continue;
+      
+      //------------------------------------------------
+      // Track2 loop 
+      //------------------------------------------------
+      for (Int_t itrk2 = itrk1+1; itrk2<nTracks; itrk2++) {
+       if(!seleTrkFlags[itrk2]) continue;
+       AliAODTrack *trk2 = (AliAODTrack*)aodEvent->GetTrack(itrk2);
+       if(!trk2||trk2->GetID()<0) continue;
+       
+       if(!SelectLikeSign(trk1,trk2)) continue;
+       
+       Int_t lpid1 = trk1->GetID();
+       Int_t lpid2 = trk2->GetID();
+       if((cpid==lpid1)||(cpid==lpid2)||(cnid==lpid1)||(cnid==lpid2)||(cbid==lpid1)||(cbid==lpid2)) continue;
+       
+       
+       Short_t charge_like1 = trk1->Charge();
+       Short_t charge_like2 = trk2->Charge();
+       Bool_t ok_charge = kFALSE;
+       if((charge_casc==-1)&&(charge_like1==1)&&(charge_like2==1)) ok_charge = kTRUE;
+       if((charge_casc==1)&&(charge_like1==-1)&&(charge_like2==-1)) ok_charge = kTRUE;
+       if(!ok_charge) continue;
+
+       //------------------------------------------------
+       // Roughly select good candidates to speed up
+       //------------------------------------------------
+       if(!fProdCuts->SelectWithRoughCuts(casc,trk1,trk2)) continue;
+
+       //------------------------------------------------
+       // Secondary vertex calculation
+       //------------------------------------------------
+       Double_t dispersion;
+       AliAODVertex *secVert = CallReconstructSecondaryVertex(trk1,trk2,dispersion);
+       if(!secVert) continue;
+
+       AliAODRecoCascadeHF3Prong *xicobj = MakeCascadeHF3Prong(casc,trk1,trk2,aodEvent,secVert,dispersion);
+       if(!xicobj) {
+         delete secVert;
+         continue;
+       }
+
+       FillROOTObjects(xicobj);
+
+       xicobj->GetSecondaryVtx()->RemoveDaughters();
+       xicobj->UnsetOwnPrimaryVtx();
+       delete xicobj;xicobj=NULL;
+       delete secVert;
+       
+      }//trk2
+    }//trk1
+  }//casc
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::FillROOTObjects(AliAODRecoCascadeHF3Prong *xicobj) 
+{
+  //
+  // Fill histogram or Tree depending on fWriteVariableTree flag
+  //
+
+  AliAODTrack *part1 = xicobj->GetBachelor1();
+  AliAODTrack *part2 = xicobj->GetBachelor2();
+  AliAODcascade *casc = xicobj->GetCascade();
+
+  fCandidateVariables[ 0] = xicobj->InvMassPiXiPi();
+  fCandidateVariables[ 1] = xicobj->Px();
+  fCandidateVariables[ 2] = xicobj->Py();
+  fCandidateVariables[ 3] = xicobj->Pz();
+  fCandidateVariables[ 4] = part1->Px();
+  fCandidateVariables[ 5] = part1->Py();
+  fCandidateVariables[ 6] = part1->Pz();
+  fCandidateVariables[ 7] = part2->Px();
+  fCandidateVariables[ 8] = part2->Py();
+  fCandidateVariables[ 9] = part2->Pz();
+  fCandidateVariables[10] = casc->MassXi();
+  fCandidateVariables[11] = casc->MomXiX();
+  fCandidateVariables[12] = casc->MomXiY();
+  fCandidateVariables[13] = casc->MomXiZ();
+  fCandidateVariables[14] = casc->MassLambda();
+  fCandidateVariables[15] = casc->MassAntiLambda();
+
+  fCandidateVariables[16] = fCentrality;
+  fCandidateVariables[17] = fVtx1->GetX();
+  fCandidateVariables[18] = fVtx1->GetY();
+  fCandidateVariables[19] = fVtx1->GetZ();
+  fCandidateVariables[20] = xicobj->GetOwnPrimaryVtx()->GetX();
+  fCandidateVariables[21] = xicobj->GetOwnPrimaryVtx()->GetY();
+  fCandidateVariables[22] = xicobj->GetOwnPrimaryVtx()->GetZ();
+
+  fCandidateVariables[23] = xicobj->CascDcaXiDaughters();
+  fCandidateVariables[24] = xicobj->CascDcaV0Daughters();
+  fCandidateVariables[25] = xicobj->CascDecayLength();
+  fCandidateVariables[26] = xicobj->CascCosPointingAngle();
+  fCandidateVariables[27] = xicobj->CascDcaV0ToPrimVertex();
+  fCandidateVariables[28] = xicobj->CascDcaPosToPrimVertex();
+  fCandidateVariables[29] = xicobj->CascDcaNegToPrimVertex();
+  fCandidateVariables[30] = xicobj->CascDcaBachToPrimVertex();
+  fCandidateVariables[31] = xicobj->CascDecayLengthV0();
+  fCandidateVariables[32] = xicobj->CascCosPointingAngleV0();
+
+  Double_t dca[3];
+  xicobj->GetDCAs(dca);
+  fCandidateVariables[33] = dca[0];
+  fCandidateVariables[34] = dca[1];
+  fCandidateVariables[35] = dca[2];
+  fCandidateVariables[36] = xicobj->Getd0Prong(0);
+  fCandidateVariables[37] = xicobj->Getd0Prong(2);
+  fCandidateVariables[38] = xicobj->Getd0Prong(1);
+
+  fCandidateVariables[39] = xicobj->DecayLength();
+  fCandidateVariables[40] = xicobj->DecayLengthXY();
+  fCandidateVariables[41] = xicobj->XicCosPointingAngle();
+
+  Double_t nSigmaTPCpi1=-9999.;
+  Double_t nSigmaTPCpi2=-9999.;
+  Double_t nSigmaTOFpi1=-9999.;
+  Double_t nSigmaTOFpi2=-9999.;
+  Double_t probPion1=-9999.;
+  Double_t probPion2=-9999.;
+
+  if(fAnalCuts->GetIsUsePID())
+    {
+      fAnalCuts->GetPidHF()->GetnSigmaTPC(part1,2,nSigmaTPCpi1);
+      fCandidateVariables[42] = nSigmaTPCpi1;
+      fAnalCuts->GetPidHF()->GetnSigmaTPC(part2,2,nSigmaTPCpi2);
+      fCandidateVariables[43] = nSigmaTPCpi2;
+      fAnalCuts->GetPidHF()->GetnSigmaTOF(part1,2,nSigmaTOFpi1);
+      fCandidateVariables[44] = nSigmaTOFpi1;
+      fAnalCuts->GetPidHF()->GetnSigmaTOF(part2,2,nSigmaTOFpi2);
+      fCandidateVariables[45] = nSigmaTOFpi2;
+
+      probPion1 =  fAnalCuts->GetPionProbabilityTPCTOF(part1);
+      probPion2 =  fAnalCuts->GetPionProbabilityTPCTOF(part2);
+      fCandidateVariables[46] = probPion1;
+      fCandidateVariables[47] = probPion2;
+    }
+
+  if(fWriteVariableTree)
+    fVariablesTree->Fill();
+  else{
+    for(Int_t ic=0;ic < fAnalCuts->GetNCutsArray(); ic++)
+      {
+       fAnalCuts->SetCutsFromArray(ic);
+       if(fAnalCuts->IsSelected(xicobj,AliRDHFCuts::kCandidate))
+         {
+           Double_t cont[3];
+           cont[0] = xicobj->InvMassPiXiPi();
+           cont[1] = xicobj->Pt();
+           cont[2] = fCentrality;
+           fHistoXicMass[ic]->Fill(cont);
+         }
+      }
+    fHistoDcaPi1Pi2->Fill(dca[2]);
+    fHistoDcaPiCasc->Fill(dca[0]);
+    fHistoDcaPiCasc->Fill(dca[1]);
+    fHistoLikeDecayLength->Fill(xicobj->DecayLength());
+    fHistoLikeDecayLengthXY->Fill(xicobj->DecayLengthXY());
+    fHistoXicCosPAXY->Fill(xicobj->XicCosPointingAngle());
+    fHistoXiMass->Fill(xicobj->CascMassXi());
+    fHistoCascDcaXiDaughters->Fill(xicobj->CascDcaXiDaughters());
+    fHistoCascDcaV0Daughters->Fill(xicobj->CascDcaV0Daughters());
+    fHistoCascDcaV0ToPrimVertex->Fill(xicobj->CascDcaV0ToPrimVertex());
+    fHistoCascDcaPosToPrimVertex->Fill(xicobj->CascDcaPosToPrimVertex());
+    fHistoCascDcaNegToPrimVertex->Fill(xicobj->CascDcaNegToPrimVertex());
+    fHistoCascDcaBachToPrimVertex->Fill(xicobj->CascDcaBachToPrimVertex());
+    fHistoCascCosPAXiPrim->Fill(xicobj->CascCosPointingAngle());
+    fHistoXiPt->Fill(xicobj->PtProng(1));
+    fHistoPiPt->Fill(xicobj->PtProng(0));
+    fHistoPiPt->Fill(xicobj->PtProng(2));
+    fHistoPid0->Fill(xicobj->Getd0Prong(0));
+    fHistoPid0->Fill(xicobj->Getd0Prong(2));
+    fHistonSigmaTPCpi->Fill(nSigmaTPCpi1);
+    fHistonSigmaTPCpi->Fill(nSigmaTPCpi2);
+    fHistonSigmaTOFpi->Fill(nSigmaTOFpi1);
+    fHistonSigmaTOFpi->Fill(nSigmaTOFpi2);
+    fHistoProbPion->Fill(probPion1);
+    fHistoProbPion->Fill(probPion2);
+       
+  }
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::DefineTreeVariables() 
+{
+  //
+  // This is to define tree variables
+  //
+  const char* nameoutput = GetOutputSlot(3)->GetContainer()->GetName();
+  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
+  Int_t nVar = 48;
+  fCandidateVariables = new Float_t [nVar];
+  TString * fCandidateVariableNames = new TString[nVar];
+
+  fCandidateVariableNames[ 0]="InvMassXic";
+  fCandidateVariableNames[ 1]="XicPx";
+  fCandidateVariableNames[ 2]="XicPy";
+  fCandidateVariableNames[ 3]="XicPz";
+  fCandidateVariableNames[ 4]="Pi1Px";
+  fCandidateVariableNames[ 5]="Pi1Py";
+  fCandidateVariableNames[ 6]="Pi1Pz";
+  fCandidateVariableNames[ 7]="Pi2Px";
+  fCandidateVariableNames[ 8]="Pi2Py";
+  fCandidateVariableNames[ 9]="Pi2Pz";
+  fCandidateVariableNames[10]="MassXi";
+  fCandidateVariableNames[11]="XiPx";
+  fCandidateVariableNames[12]="XiPy";
+  fCandidateVariableNames[13]="XiPz";
+  fCandidateVariableNames[14]="MassLambda";
+  fCandidateVariableNames[15]="MassAntiLambda";
+
+  fCandidateVariableNames[16]="Centrality";
+  fCandidateVariableNames[17]="PrimVtxX";
+  fCandidateVariableNames[18]="PrimVtxY";
+  fCandidateVariableNames[19]="PrimVtxZ";
+  fCandidateVariableNames[20]="NewPrimVtxX";
+  fCandidateVariableNames[21]="NewPrimVtxY";
+  fCandidateVariableNames[22]="NewPrimVtxZ";
+
+  fCandidateVariableNames[23]="CascDcaXiDaughters";
+  fCandidateVariableNames[24]="CascDcaV0Daughters";
+  fCandidateVariableNames[25]="CascDecayLengthXi";
+  fCandidateVariableNames[26]="CascCosPointingAngleXi";
+  fCandidateVariableNames[27]="CascDcaV0ToPrimVertex";
+  fCandidateVariableNames[28]="CascDcaPosToPrimVertex";
+  fCandidateVariableNames[29]="CascDcaNegToPrimVertex";
+  fCandidateVariableNames[30]="CascDcaBachToPrimVertex";
+  fCandidateVariableNames[31]="CascDecayLengthV0";
+  fCandidateVariableNames[32]="CascCosPointingAngleV0";
+
+  fCandidateVariableNames[33]="DcaPi1Casc";
+  fCandidateVariableNames[34]="DcaPi2Casc";
+  fCandidateVariableNames[35]="DcaPi1Pi2";
+
+  fCandidateVariableNames[36]="Pi1d0";
+  fCandidateVariableNames[37]="Pi2d0";
+  fCandidateVariableNames[38]="Cascd0";
+
+  fCandidateVariableNames[39]="DecayLength";
+  fCandidateVariableNames[40]="DecayLengthXY";
+  fCandidateVariableNames[41]="XicCosPAXY";
+
+  fCandidateVariableNames[42]="nSigmaTPCpi1";
+  fCandidateVariableNames[43]="nSigmaTPCpi2";
+  fCandidateVariableNames[44]="nSigmaTOFpi1";
+  fCandidateVariableNames[45]="nSigmaTOFpi2";
+  fCandidateVariableNames[46]="probPion1";
+  fCandidateVariableNames[47]="probPion2";
+
+
+  for (Int_t ivar=0; ivar<nVar; ivar++) {
+    fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
+  }
+
+  return;
+}
+
+//__________________________________________________________________________
+void  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::DefineGeneralHistograms() {
+  //
+  // This is to define general histograms
+  //
+
+  fCEvents = new TH1F("fCEvents","conter",18,-0.5,17.5);
+  fCEvents->SetStats(kTRUE);
+  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
+  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
+  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
+  fCEvents->GetXaxis()->SetBinLabel(4,"TriggerOK");
+  fCEvents->GetXaxis()->SetBinLabel(5,"IsEventSelected");
+  fCEvents->GetXaxis()->SetBinLabel(6,"CascadesHF exists");
+  fCEvents->GetXaxis()->SetBinLabel(7,"MCarray exists");
+  fCEvents->GetXaxis()->SetBinLabel(8,"MCheader exists");
+  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
+  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
+  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
+  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
+  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
+  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
+  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
+  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
+  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
+  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
+  //fCEvents->GetXaxis()->SetTitle("");
+  fCEvents->GetYaxis()->SetTitle("counts");
+
+  fHTrigger = new TH1F("fHTrigger","counter",18,-0.5,17.5);
+  fHTrigger->SetStats(kTRUE);
+  fHTrigger->GetXaxis()->SetBinLabel(1,"X1");
+  fHTrigger->GetXaxis()->SetBinLabel(2,"kMB");
+  fHTrigger->GetXaxis()->SetBinLabel(3,"kSemiCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(4,"kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(5,"kINT7");
+  fHTrigger->GetXaxis()->SetBinLabel(6,"kEMC7");
+  //fHTrigger->GetXaxis()->SetBinLabel(7,"Space");
+  fHTrigger->GetXaxis()->SetBinLabel(8,"kMB|kSemiCentral|kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(9,"kINT7|kEMC7");
+  fHTrigger->GetXaxis()->SetBinLabel(11,"kMB&kSemiCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(12,"kMB&kCentral");
+  fHTrigger->GetXaxis()->SetBinLabel(13,"kINT7&kEMC7");
+
+  fHCentrality = new TH1F("fHCentrality","conter",100,0.,100.);
+
+  fOutput->Add(fCEvents);
+  fOutput->Add(fHTrigger);
+  fOutput->Add(fHCentrality);
+
+  return;
+}
+
+//__________________________________________________________________________
+void  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::DefineAnalysisHistograms() 
+{
+  //
+  // Define histograms
+  //
+  
+  //------------------------------------------------
+  // Basic histograms
+  //------------------------------------------------
+  Int_t bins_base[3]=          {80                             ,20             ,10};
+  Double_t xmin_base[3]={2.468-0.2,0           ,0.00};
+  Double_t xmax_base[3]={2.468+0.2,20. ,100};
+  
+  for(Int_t i=0;i<fAnalCuts->GetNCutsArray();i++)
+    {
+      fHistoXicMass.push_back(new THnSparseF(Form("fHistoXicMass_Cut%d",i),Form("Cut%d",i),3,bins_base,xmin_base,xmax_base));
+      fOutputAll->Add(fHistoXicMass[i]);
+      
+    }
+  
+  //------------------------------------------------
+  // Checking histograms
+  //------------------------------------------------
+  fHistoDcaPi1Pi2 = new TH1F("fHistoDcaPi1Pi2","DCA (#pi_{1}-#pi_{2})",100,0.0,1.0);
+  fOutputAll->Add(fHistoDcaPi1Pi2);
+  fHistoDcaPiCasc = new TH1F("fHistoDcaPiCasc","DCA (#pi-#Xi)",100,0.0,1.0);
+  fOutputAll->Add(fHistoDcaPiCasc);
+  fHistoLikeDecayLength = new TH1F("fHistoLikeDecayLength","Decay Length (#pi-#pi)",100,0.,0.2);
+  fOutputAll->Add(fHistoLikeDecayLength);
+  fHistoLikeDecayLengthXY = new TH1F("fHistoLikeDecayLengthXY","Decay Length (#pi-#pi)",100,0.,0.2);
+  fOutputAll->Add(fHistoLikeDecayLengthXY);
+  fHistoXicCosPAXY = new TH1F("fHistoXicCosPAXY","#Xi_{c} cos(pa) ",100,-1.0,1.0);
+  fOutputAll->Add(fHistoXicCosPAXY);
+  fHistoXiMass=new TH1F("fHistoXiMass","#Xi^{-} Mass",100,1.322-0.05,1.322+0.05);
+  fOutputAll->Add(fHistoXiMass);
+  fHistoCascDcaXiDaughters=new TH1F("fHistoCascDcaXiDaughters","DCA #Xi daughters ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaXiDaughters);
+  fHistoCascDcaV0Daughters=new TH1F("fHistoCascDcaV0Daughters","DCA #Xi daughters ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaV0Daughters);
+  fHistoCascDcaV0ToPrimVertex=new TH1F("fHistoCascDcaV0ToPrimVertex","DCA V0 daughters ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaV0ToPrimVertex);
+  fHistoCascDcaPosToPrimVertex=new TH1F("fHistoCascDcaPosToPrimVertex","DCA Pos-Prim ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaPosToPrimVertex);
+  fHistoCascDcaNegToPrimVertex=new TH1F("fHistoCascDcaNegToPrimVertex","DCA Neg-Prim ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaNegToPrimVertex);
+  fHistoCascDcaBachToPrimVertex=new TH1F("fHistoCascDcaBachToPrimVertex","DCA Bach-Prim ",100,0.0,1.0);
+  fOutputAll->Add(fHistoCascDcaBachToPrimVertex);
+  fHistoCascCosPAXiPrim=new TH1F("fHistoCascCosPAXiPrim","#Xi CosPA (prim)",100,0.8,1.0);
+  fOutputAll->Add(fHistoCascCosPAXiPrim);
+  fHistoXiPt=new TH1F("fHistoXiPt","#Xi^{-} p_{T}",100,0.,10.);
+  fOutputAll->Add(fHistoXiPt);
+  fHistoPiPt=new TH1F("fHistoPiPt","#pi p_{T}",100,0.,10);
+  fOutputAll->Add(fHistoPiPt);
+  fHistoPid0=new TH1F("fHistoPid0","#pi d_{0}",100,-0.1,0.1);
+  fOutputAll->Add(fHistoPid0);
+  fHistonSigmaTPCpi=new TH1F("fHistonSigmaTPCpi","n#sigma (TPC, pion)",100,-10.,10.);
+  fOutputAll->Add(fHistonSigmaTPCpi);
+  fHistonSigmaTOFpi=new TH1F("fHistonSigmaTOFpi","n#sigma (TOF, pion)",100,-10.,10.);
+  fOutputAll->Add(fHistonSigmaTOFpi);
+  fHistoProbPion=new TH1F("fHistoProbPion","Bayse Prob",100,0.0,1.);
+  fOutputAll->Add(fHistoProbPion);
+  
+  return;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::SelectTrack( const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks,Bool_t *seleFlags)
+{
+  //
+  // Select good tracks using fProdCuts (AliRDHFCuts object) and return the array of their ids
+  //
+  
+  //const Int_t entries = event->GetNumberOfTracks();
+  if(trkEntries==0) return;
+  
+  nSeleTrks=0;
+  for(Int_t i=0; i<trkEntries; i++) {
+    seleFlags[i] = kFALSE;
+    
+    AliVTrack *track;
+    track = (AliVTrack*)event->GetTrack(i);
+    
+    if(track->GetID()<0) continue;
+    Double_t covtest[21];
+    if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
+    
+    AliAODTrack *aodt = (AliAODTrack*)track;
+
+    if(!fProdCuts) continue;
+    if(fProdCuts->SingleTrkCuts(aodt)){
+      seleFlags[i]=kTRUE;
+      nSeleTrks++;
+    }
+  } // end loop on tracks
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::SelectCascade( const AliVEvent *event,Int_t nCascades,Int_t &nSeleCasc, Bool_t *seleCascFlags)
+{
+  //
+  // Select good cascade using fProdCuts (AliRDHFCuts object) and return the array of their ids
+  //
+
+  nSeleCasc = 0;
+  for(Int_t icasc=0;icasc<nCascades;icasc++)
+    {
+      seleCascFlags[icasc] = kFALSE;
+      AliAODcascade *casc = ((AliAODEvent*)event)->GetCascade(icasc);
+
+      if(!fProdCuts) continue;
+      if(fProdCuts->SingleCascadeCuts(casc)){
+       seleCascFlags[icasc] = kTRUE;
+       nSeleCasc++;
+      }
+    }
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::SelectLikeSign(AliAODTrack *trk1, AliAODTrack *trk2)
+{
+  //
+  // Select LikeSign tracks
+  //
+
+  if(trk1->Charge()!=trk2->Charge()) return kFALSE;
+  if(trk1->GetID()==trk2->GetID()) return kFALSE;
+  return kTRUE;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk1, AliAODTrack *trk2, AliAODEvent* aod)
+{
+  //
+  // Make an array of tracks which should not be used in primary vertex calculation and 
+  // Call PrimaryVertex function
+  //
+
+  TObjArray *twoTrackArrayPlusXi = new TObjArray(5);
+  
+  AliESDtrack *cptrk1 = new AliESDtrack((AliVTrack*)trk1);
+  twoTrackArrayPlusXi->AddAt(cptrk1,0);
+  AliESDtrack *cptrk2 = new AliESDtrack((AliVTrack*)trk2);
+  twoTrackArrayPlusXi->AddAt(cptrk2,1);
+  
+  AliESDtrack *cascptrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(0));
+  twoTrackArrayPlusXi->AddAt(cascptrack,2);
+  AliESDtrack *cascntrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(1));
+  twoTrackArrayPlusXi->AddAt(cascntrack,3);
+  AliESDtrack *cascbtrack = new AliESDtrack((AliVTrack*)casc->GetDecayVertexXi()->GetDaughter(0));
+  twoTrackArrayPlusXi->AddAt(cascbtrack,4);
+  
+  AliAODVertex *newvert  = PrimaryVertex(twoTrackArrayPlusXi,aod);
+  
+  for(Int_t i=0;i<5;i++)
+    {
+      AliESDtrack *tesd = (AliESDtrack*)twoTrackArrayPlusXi->UncheckedAt(i);
+      delete tesd;
+    }
+  twoTrackArrayPlusXi->Clear();
+  delete twoTrackArrayPlusXi;
+  
+  return newvert;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::CallReconstructSecondaryVertex(AliAODTrack *trk1, AliAODTrack *trk2, Double_t &dispersion)
+{
+  //
+  // Make an array of tracks which I want to use for vertex calculation and call ReconstructSecondaryVertex
+  //
+
+  TObjArray *trkArray;
+  trkArray= new TObjArray(2);
+  
+  AliESDtrack *cptrk1 = new AliESDtrack((AliVTrack*)trk1);
+  trkArray->AddAt(cptrk1,0);
+  AliESDtrack *cptrk2 = new AliESDtrack((AliVTrack*)trk2);
+  trkArray->AddAt(cptrk2,1);
+  
+  AliAODVertex *secvertex;
+  secvertex = ReconstructSecondaryVertex(trkArray,dispersion);
+  
+  for(Int_t i=0;i<2;i++)
+    {
+      AliESDtrack *tesd = (AliESDtrack*)trkArray->UncheckedAt(i);
+      delete tesd;
+    }
+  trkArray->Clear();
+  delete trkArray;
+  
+  return secvertex;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::PrimaryVertex(const TObjArray *trkArray,
+                                                                         AliVEvent *event)
+{
+  //
+  //Used only for pp
+  //copied from AliAnalysisVertexingHF (except for the following 3 lines)
+  //
+       
+  Bool_t fRecoPrimVtxSkippingTrks = kTRUE;
+  Bool_t fRmTrksFromPrimVtx = kFALSE;
+
+  AliESDVertex *vertexESD = 0;
+  AliAODVertex *vertexAOD = 0;
+  
+  //vertexESD = new AliESDVertex(*fV1);
+  
+
+  if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) { 
+    // primary vertex from the input event
+    
+    vertexESD = new AliESDVertex(*fV1);
+    
+  } else {
+    // primary vertex specific to this candidate
+    
+    Int_t nTrks = trkArray->GetEntriesFast();
+    AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
+    
+    if(fRecoPrimVtxSkippingTrks) { 
+      // recalculating the vertex
+      
+      if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
+       Float_t diamondcovxy[3];
+       event->GetDiamondCovXY(diamondcovxy);
+       Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
+       Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
+       AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
+       vertexer->SetVtxStart(diamond);
+       delete diamond; diamond=NULL;
+       if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter")) 
+         vertexer->SetOnlyFitter();
+      }
+      Int_t skipped[1000];
+      Int_t nTrksToSkip=0,id;
+      AliExternalTrackParam *t = 0;
+      for(Int_t i=0; i<nTrks; i++) {
+       t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
+       id = (Int_t)t->GetID();
+       if(id<0) continue;
+       skipped[nTrksToSkip++] = id;
+      }
+      // TEMPORARY FIX
+      // For AOD, skip also tracks without covariance matrix
+      Double_t covtest[21];
+      for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
+       AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
+       if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
+         id = (Int_t)vtrack->GetID();
+         if(id<0) continue;
+         skipped[nTrksToSkip++] = id;
+       }
+      }
+      for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
+      //
+      vertexer->SetSkipTracks(nTrksToSkip,skipped);
+      vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event); 
+      
+    } else if(fRmTrksFromPrimVtx && nTrks>0) { 
+      // removing the prongs tracks
+      
+      TObjArray rmArray(nTrks);
+      UShort_t *rmId = new UShort_t[nTrks];
+      AliESDtrack *esdTrack = 0;
+      AliESDtrack *t = 0;
+      for(Int_t i=0; i<nTrks; i++) {
+       t = (AliESDtrack*)trkArray->UncheckedAt(i);
+       esdTrack = new AliESDtrack(*t);
+       rmArray.AddLast(esdTrack);
+       if(esdTrack->GetID()>=0) {
+         rmId[i]=(UShort_t)esdTrack->GetID();
+       } else {
+         rmId[i]=9999;
+       }
+      }
+      Float_t diamondxy[2]={static_cast<Float_t>(event->GetDiamondX()),static_cast<Float_t>(event->GetDiamondY())};
+      vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
+      delete [] rmId; rmId=NULL;
+      rmArray.Delete();
+      
+    }
+    
+    delete vertexer; vertexer=NULL;
+    if(!vertexESD) return vertexAOD;
+    if(vertexESD->GetNContributors()<=0) { 
+      //AliDebug(2,"vertexing failed"); 
+      delete vertexESD; vertexESD=NULL;
+      return vertexAOD;
+    }
+    
+    
+  }
+  
+  // convert to AliAODVertex
+  Double_t pos[3],cov[6],chi2perNDF;
+  vertexESD->GetXYZ(pos); // position
+  vertexESD->GetCovMatrix(cov); //covariance matrix
+  chi2perNDF = vertexESD->GetChi2toNDF();
+  delete vertexESD; vertexESD=NULL;
+  
+  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
+  
+  return vertexAOD;
+}
+
+//________________________________________________________________________
+AliAODVertex* AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::ReconstructSecondaryVertex(TObjArray *trkArray, Double_t &dispersion,Bool_t useTRefArray)
+{
+  //
+  // Reconstruct secondary vertex from trkArray (Copied from AliAnalysisVertexingHF)
+  //
+  
+  AliESDVertex *vertexESD = 0;
+  AliAODVertex *vertexAOD = 0;
+  
+  AliVertexerTracks *fVertexerTracks = new AliVertexerTracks(fBzkG);
+  
+  fVertexerTracks->SetVtxStart(fV1);
+  vertexESD = (AliESDVertex*)fVertexerTracks->VertexForSelectedESDTracks(trkArray);
+  
+  delete fVertexerTracks; fVertexerTracks=NULL;
+
+  if(!vertexESD) return vertexAOD;
+
+  if(vertexESD->GetNContributors()!=trkArray->GetEntriesFast()) { 
+    //AliDebug(2,"vertexing failed"); 
+    delete vertexESD; vertexESD=NULL;
+    return vertexAOD;
+  }
+  
+  Double_t vertRadius2=vertexESD->GetX()*vertexESD->GetX()+vertexESD->GetY()*vertexESD->GetY();
+  if(vertRadius2>8.){
+    // vertex outside beam pipe, reject candidate to avoid propagation through material
+    delete vertexESD; vertexESD=NULL;
+    return vertexAOD;
+  }
+  
+  
+  // convert to AliAODVertex
+  Double_t pos[3],cov[6],chi2perNDF;
+  vertexESD->GetXYZ(pos); // position
+  vertexESD->GetCovMatrix(cov); //covariance matrix
+  chi2perNDF = vertexESD->GetChi2toNDF();
+  dispersion = vertexESD->GetDispersion();
+  delete vertexESD; vertexESD=NULL;
+  
+  Int_t nprongs= (useTRefArray ? 0 : trkArray->GetEntriesFast());
+  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
+  
+  return vertexAOD;
+}
+
+//________________________________________________________________________
+AliAODRecoCascadeHF3Prong* AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks::MakeCascadeHF3Prong(AliAODcascade *casc, AliAODTrack *part1, AliAODTrack *part2, AliAODEvent * aod, AliAODVertex *secVert, Double_t dispersion) 
+{
+  //
+  // Make AliAODRecoCascadeHF3Prong object from the arguments
+  //
+       
+  //------------------------------------------------
+  // PrimaryVertex
+  //------------------------------------------------
+  AliAODVertex *primVertexAOD;
+  Bool_t unsetvtx = kFALSE;
+  if(fIspp){
+    primVertexAOD = CallPrimaryVertex(casc,part1,part2,aod);
+    if(!primVertexAOD){
+      primVertexAOD = fVtx1;
+    }else{
+      unsetvtx = kTRUE;
+    }
+  }else{
+    primVertexAOD = fVtx1;
+  }
+  if(!primVertexAOD) return 0x0;
+  Double_t pos[3]; primVertexAOD->GetXYZ(pos);
+
+
+  //------------------------------------------------
+  // DCA between tracks
+  //------------------------------------------------
+  AliESDtrack *esdtrack1 = new AliESDtrack((AliVTrack*)part1);
+  AliESDtrack *esdtrack2 = new AliESDtrack((AliVTrack*)part2);
+  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
+  xyz[0]=casc->DecayVertexXiX();
+  xyz[1]=casc->DecayVertexXiY();
+  xyz[2]=casc->DecayVertexXiZ();
+  pxpypz[0]=casc->MomXiX();
+  pxpypz[1]=casc->MomXiY();
+  pxpypz[2]=casc->MomXiZ();
+  casc->GetCovarianceXYZPxPyPz(cv);
+  sign=casc->ChargeXi();
+  AliExternalTrackParam        *trackCasc = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
+
+  Double_t xdummy, ydummy;
+  Double_t dcap1p2 = esdtrack1->GetDCA(esdtrack2,fBzkG,xdummy,ydummy);
+  if(fabs(dcap1p2)>fProdCuts->GetProdLikeSignDcaMax())
+    {
+      if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+      if(esdtrack1) delete esdtrack1;
+      if(esdtrack2) delete esdtrack2;
+      if(trackCasc) delete trackCasc;
+      return 0x0;
+    }
+  Double_t dcap1casc = esdtrack1->GetDCA(trackCasc,fBzkG,xdummy,ydummy);
+  Double_t dcap2casc = esdtrack2->GetDCA(trackCasc,fBzkG,xdummy,ydummy);
+  Double_t dca[3]={dcap1casc,dcap2casc,dcap1p2};
+
+  //------------------------------------------------
+  // Propagate all tracks to the secondary vertex and calculate momentum there
+  //------------------------------------------------
+
+  Double_t d0z0[2],covd0z0[3];
+  Double_t secR = TMath::Sqrt(secVert->GetX()*secVert->GetX()+secVert->GetY()*secVert->GetY());
+  if(secR<1.0){
+    part1->PropagateToDCA(secVert,fBzkG,kVeryBig,d0z0,covd0z0);
+    part2->PropagateToDCA(secVert,fBzkG,kVeryBig,d0z0,covd0z0);
+    trackCasc->PropagateToDCA(secVert,fBzkG,kVeryBig);
+  }else{
+    part1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+    part2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+    trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig);
+  }
+
+  Double_t momxi_new[3]={-9999,-9999,-9999.};
+  trackCasc->GetPxPyPz(momxi_new);
+
+  Double_t px[3],py[3],pz[3];
+  px[0] = part1->Px(); py[0] = part1->Py(); pz[0] = part1->Pz(); 
+  px[1] = momxi_new[0]; py[1] = momxi_new[1]; pz[1] = momxi_new[2]; 
+  px[2] = part2->Px(); py[2] = part2->Py(); pz[2] = part2->Pz(); 
+
+  //------------------------------------------------
+  // d0
+  //------------------------------------------------
+  Double_t d0[3],d0err[3];
+  part1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+  d0[0]= d0z0[0];
+  d0err[0] = TMath::Sqrt(covd0z0[0]);
+
+  trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+  d0[1]= d0z0[0];
+  d0err[1] = TMath::Sqrt(covd0z0[0]);//Do not know what to use
+
+  part2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
+  d0[2]= d0z0[0];
+  d0err[2] = TMath::Sqrt(covd0z0[0]);
+
+
+  //------------------------------------------------
+  // Other stuff
+  //------------------------------------------------
+  Double_t dist12=0.0;//Vertex pi-casc not calculated
+  Double_t dist23=0.0;//Vertex pi-casc not calculated
+  Short_t charge=(Short_t)(part1->Charge()+trackCasc->Charge()+part2->Charge());
+
+  //------------------------------------------------
+  // Create AliAODRecoCascadeHF3Prong
+  //------------------------------------------------
+  AliAODRecoCascadeHF3Prong *theCascade = new AliAODRecoCascadeHF3Prong(secVert,charge,px,py,pz,d0,d0err,dca,dispersion,dist12,dist23);
+  if(!theCascade)  
+    {
+      if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+      if(esdtrack1) delete esdtrack1;
+      if(esdtrack2) delete esdtrack2;
+      if(trackCasc) delete trackCasc;
+      return 0x0;
+    }
+  theCascade->SetOwnPrimaryVtx(primVertexAOD);
+  UShort_t id[3]={(UShort_t)part1->GetID(),(UShort_t)trackCasc->GetID(),(UShort_t)part2->GetID()};
+  theCascade->SetProngIDs(3,id);
+
+  theCascade->GetSecondaryVtx()->AddDaughter(part1);
+  theCascade->GetSecondaryVtx()->AddDaughter(casc);
+  theCascade->GetSecondaryVtx()->AddDaughter(part2);
+
+  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
+  if(esdtrack1) delete esdtrack1;
+  if(esdtrack2) delete esdtrack2;
+  if(trackCasc) delete trackCasc;
+
+  return theCascade;
+}
diff --git a/PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.h b/PWGHF/vertexingHF/AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.h
new file mode 100644 (file)
index 0000000..f4c76f3
--- /dev/null
@@ -0,0 +1,140 @@
+#ifndef ALIANALYSISTASKSEXICPLUS2XIPIPIFROMAODTRACKS_H
+#define ALIANALYSISTASKSEXICPLUS2XIPIPIFROMAODTRACKS_H
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */ 
+
+#include "TROOT.h"
+#include "TSystem.h"
+
+#include "AliAnalysisTaskSE.h"
+#include "AliAODEvent.h"
+#include "AliPID.h"
+#include "AliRDHFCutsXicPlustoXiPiPifromAODtracks.h"
+
+class THnSparse;
+class TH1F;
+class TClonesArray;
+class AliAODRecoCascadeHF3Prong;
+class AliAODPidHF;
+class AliESDtrackCuts;
+class AliESDVertex;
+
+class AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks : public AliAnalysisTaskSE 
+{
+ public:
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks();
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks(const Char_t* name, AliRDHFCutsXicPlustoXiPiPifromAODtracks* cuts, AliRDHFCutsXicPlustoXiPiPifromAODtracks* cuts2, Bool_t writeVariableTree=kTRUE);
+  virtual ~AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks();
+
+  // Implementation of interface methods  
+  virtual void UserCreateOutputObjects();
+  virtual void Init();
+  virtual void LocalInit() {Init();}
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+
+  void FillROOTObjects(AliAODRecoCascadeHF3Prong *xicobj);
+  void MakeAnalysis(AliAODEvent *aod);
+
+  
+  // set MC usage
+  void SetMC(Bool_t theMCon) {fUseMCInfo = theMCon;}
+  Bool_t GetMC() const {return fUseMCInfo;}
+  
+  void   SetIspp(Bool_t a) { fIspp=a; }
+  Bool_t GetIspp() { return fIspp; }
+  void   SetIspA(Bool_t a) { fIspA=a; }
+  Bool_t GetIspA() { return fIspA; }
+  void   SetIsAA(Bool_t a) { fIsAA=a; }
+  Bool_t GetIsAA() { return fIsAA; }
+  
+  void SelectCascade( const AliVEvent *event,Int_t nCascades,Int_t &nSeleCasc, Bool_t *seleCascFlags);
+  void SelectTrack( const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks,Bool_t *seleFlags);
+  Bool_t SelectLikeSign(AliAODTrack *trk1, AliAODTrack *trk2);
+  AliAODRecoCascadeHF3Prong* MakeCascadeHF3Prong(AliAODcascade *casc, AliAODTrack *trk1, AliAODTrack *trk2, AliAODEvent *aod, AliAODVertex *secvert, Double_t dispersion);
+  
+ private:
+  
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks(const AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks &source);
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks& operator=(const AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks& source); 
+  
+  void DefineTreeVariables();
+  void DefineGeneralHistograms();
+  void DefineAnalysisHistograms();
+
+  AliAODVertex *CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk1, AliAODTrack *trk2, AliAODEvent *evt);
+  AliAODVertex* PrimaryVertex(const TObjArray *trkArray,AliVEvent *event);
+  AliAODVertex* CallReconstructSecondaryVertex(AliAODTrack *trk1, AliAODTrack *trk2,Double_t &disp);
+  AliAODVertex* ReconstructSecondaryVertex(TObjArray *trkArray, Double_t &dispersion,Bool_t useTRefArray=kTRUE);
+  
+  Bool_t fUseMCInfo;          // Use MC info
+  TList *fOutput;             //! User output slot 1 // general histos
+  TList *fOutputAll;          //! User output slot 3 // Analysis histos
+  TList *fListCuts;           //! User output slot 2 // Cuts 
+  TH1F *fCEvents;             // Histogram to check selected events
+  TH1F *fHTrigger;            //Histograms to check trigger
+  TH1F *fHCentrality;         //histogram to check centrality
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks *fProdCuts;      // Cuts - sent to output slot 2
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks *fAnalCuts;      // Cuts - sent to output slot 2
+  Bool_t fIsEventSelected;           // flag for event selected
+  Bool_t    fWriteVariableTree;       // flag to decide whether to write the candidate variables on a tree variables
+  TTree    *fVariablesTree;           //! tree of the candidate variables after track selection on output slot 4
+  Bool_t fIspp;            //is pp run
+  Bool_t fIspA;            //is pA run
+  Bool_t fIsAA;            //is AA run
+  Bool_t fIsMB;            //Is MB event
+  Bool_t fIsSemi;          //is semi-central trigger event
+  Bool_t fIsCent;          //is central trigger event
+  Bool_t fIsINT7;          // is int7 trigger event
+  Bool_t fIsEMC7;          //is emc7 trigger event
+  Float_t *fCandidateVariables;     //! variables to be written to the tree
+  AliAODVertex *fVtx1;              // primary vertex
+  AliESDVertex *fV1;                // primary vertex
+  Double_t fBzkG;                   // magnetic field value [kG]
+  Float_t  fCentrality;             //centrality
+  Float_t  fTriggerCheck;           // Trigger information
+  
+  //--------------------- My histograms ------------------
+  std::vector<THnSparse* > fHistoXicMass;        //! xic mass spectra
+  
+  TH1F*  fHistoDcaPi1Pi2;                    //!  DCA between pions
+  TH1F*  fHistoDcaPiCasc;                    //! DCA between pi and cascade
+  TH1F*  fHistoLikeDecayLength;              //! Decay length
+  TH1F*  fHistoLikeDecayLengthXY;            //! Decay length in XY
+  TH1F*  fHistoXicCosPAXY;                   //! Xic cosine pointing angle
+  
+  TH1F*  fHistoXiMass;                       //! mass of xi
+  TH1F*  fHistoCascDcaXiDaughters;           //! DCA of xi daughgers
+  TH1F*  fHistoCascDcaV0Daughters;           //! DCA of v0 daughters
+  TH1F*  fHistoCascDcaV0ToPrimVertex;        //! DCA of v0 to primary vertex 
+  TH1F*  fHistoCascDcaPosToPrimVertex;       //! DCA of positive track to primary vertex 
+  TH1F*  fHistoCascDcaNegToPrimVertex;       //! DCA of negative track to primary vertex 
+  TH1F*  fHistoCascDcaBachToPrimVertex;      //! DCA of bachelor track to primary vertex 
+  TH1F*  fHistoCascCosPAXiPrim;              //! Cosine pointing angle of Xi to primary vertex
+  TH1F*  fHistoXiPt;                         //! Xi pt
+  
+  TH1F*  fHistoPiPt;                         //! Pion pT
+  TH1F*  fHistoPid0;                         //! pion d0
+  TH1F*  fHistonSigmaTPCpi;                  //! nSigma of TPC pion
+  TH1F*  fHistonSigmaTOFpi;                  //! nSigma of TOF pion
+  TH1F*  fHistoProbPion;                     //! Probability to be pion
+  
+  ClassDef(AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks,1); // class for Xic->Xipipi
+};
+#endif
+
diff --git a/PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.cxx b/PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.cxx
new file mode 100644 (file)
index 0000000..ca28006
--- /dev/null
@@ -0,0 +1,593 @@
+/**************************************************************************
+ * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/////////////////////////////////////////////////////////////
+//
+// Class for cuts on AOD reconstructed Lc->p+K0s
+//
+// Modified by Y.S Watanabe - wyosuke@cns.s.u-tokyo.ac.jp
+//
+/////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+
+#include <TDatabasePDG.h>
+#include <TMath.h>
+
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "AliPIDResponse.h"
+#include "AliRDHFCutsLctopK0sfromAODtracks.h"
+#include "AliAODRecoCascadeHF.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliAODVertex.h"
+#include "AliAODv0.h"
+#include "AliAODcascade.h"
+#include "AliESDv0.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliRDHFCutsLctopK0sfromAODtracks)
+
+//--------------------------------------------------------------------------
+AliRDHFCutsLctopK0sfromAODtracks::AliRDHFCutsLctopK0sfromAODtracks(const char* name) :
+AliRDHFCuts(name),
+  fPIDStrategy(kNSigmaCuts),
+  fCombinedPIDThreshold(0.),
+  fUseOnTheFlyV0(kFALSE),
+  fProdTrackPtMin(0.3),
+  fProdTrackEtaRange(0.8),
+  fProdUseAODFilterBit(kTRUE),
+  fProdV0MassTolK0s(0.01),
+  fProdV0PtMin(0.5),
+  fProdV0CosPointingAngleToPrimVtxMin(0.99),
+  fProdV0DcaDaughtersMax(1.5),
+  fProdV0DaughterEtaRange(0.8),
+  fProdV0DaughterPtMin(0.0),
+  fProdV0DaughterTPCClusterMin(70),
+fProdRoughMassTol(0.25),
+fProdRoughPtMin(0.0),
+fnCuts(0),
+  fnTotalCutBins(1),
+  fCutsArray(0)
+{
+  //
+  // Default Constructor
+  //
+
+  const Int_t nvars=7;
+  SetNVars(nvars);
+  TString varNames[nvars]={"Lc inv. mass [GeV/c2]",                   //  0
+                          "Lc pT [GeV/c]", //1
+                          "Bachelor pT [GeV/c]", //2
+                          "Bachelor d0 [cm]", //3
+                          "V0 d0 [cm]", //4
+                          "K0s mass [GeV/c2]", //5
+                          "Decay Length XY [cm]" //6
+  };
+
+  Bool_t isUpperCut[nvars]={kTRUE,  //  0
+                           kFALSE, //1
+                           kFALSE, //2
+                           kTRUE, //3
+                           kTRUE, //4
+                           kTRUE, //5
+                           kFALSE //6
+  };
+  SetVarNames(nvars,varNames,isUpperCut);
+  Bool_t forOpt[nvars]={kFALSE, //  0
+                       kFALSE, //1
+                       kTRUE, //2
+                       kTRUE, //3
+                       kTRUE, //4
+                       kTRUE, //5
+                       kTRUE //6
+  };
+  SetVarsForOpt(nvars,forOpt);
+
+  Float_t limits[2]={0,999999999.};
+  SetPtBins(2,limits);
+}
+//--------------------------------------------------------------------------
+AliRDHFCutsLctopK0sfromAODtracks::AliRDHFCutsLctopK0sfromAODtracks(const AliRDHFCutsLctopK0sfromAODtracks &source) :
+  AliRDHFCuts(source),
+  fPIDStrategy(source.fPIDStrategy),
+  fCombinedPIDThreshold(source.fCombinedPIDThreshold),
+  fUseOnTheFlyV0(source.fUseOnTheFlyV0),
+  fProdTrackPtMin(source.fProdTrackPtMin),
+  fProdTrackEtaRange(source.fProdTrackEtaRange),
+  fProdUseAODFilterBit(source.fProdUseAODFilterBit),
+  fProdV0MassTolK0s(source.fProdV0MassTolK0s),
+  fProdV0PtMin(source.fProdV0PtMin),
+  fProdV0CosPointingAngleToPrimVtxMin(source.fProdV0CosPointingAngleToPrimVtxMin),
+  fProdV0DcaDaughtersMax(source.fProdV0DcaDaughtersMax),
+  fProdV0DaughterEtaRange(source.fProdV0DaughterEtaRange),
+  fProdV0DaughterPtMin(source.fProdV0DaughterPtMin),
+  fProdV0DaughterTPCClusterMin(source.fProdV0DaughterTPCClusterMin),
+  fProdRoughMassTol(source.fProdRoughMassTol),
+  fProdRoughPtMin(source.fProdRoughPtMin),
+  fnCuts(source.fnCuts),
+  fnTotalCutBins(source.fnTotalCutBins),
+  fCutsArray(0)
+{
+  //
+  // Copy constructor
+  //
+  if(source.fCutsArray) SetCutsArray(source.fnTotalCutBins,source.fCutsArray);
+}
+//--------------------------------------------------------------------------
+AliRDHFCutsLctopK0sfromAODtracks &AliRDHFCutsLctopK0sfromAODtracks::operator=(const AliRDHFCutsLctopK0sfromAODtracks &source)
+{
+  //
+  // assignment operator
+  //
+
+  if (this != &source) {
+    AliRDHFCuts::operator=(source);
+  }
+
+  fPIDStrategy = source.fPIDStrategy;
+  fCombinedPIDThreshold = source.fCombinedPIDThreshold;
+  fUseOnTheFlyV0 = source.fUseOnTheFlyV0;
+  fProdTrackPtMin = source.fProdTrackPtMin;
+  fProdTrackEtaRange = source.fProdTrackEtaRange;
+  fProdUseAODFilterBit = source.fProdUseAODFilterBit;
+  fProdV0MassTolK0s = source.fProdV0MassTolK0s;
+  fProdV0PtMin = source.fProdV0PtMin;
+  fProdV0CosPointingAngleToPrimVtxMin = source.fProdV0CosPointingAngleToPrimVtxMin;
+  fProdV0DcaDaughtersMax=source.fProdV0DcaDaughtersMax;
+  fProdV0DaughterEtaRange=source.fProdV0DaughterEtaRange;
+  fProdV0DaughterPtMin=source.fProdV0DaughterPtMin;
+  fProdV0DaughterTPCClusterMin=source.fProdV0DaughterTPCClusterMin;
+  fProdRoughMassTol = source.fProdRoughMassTol;
+  fProdRoughPtMin = source.fProdRoughPtMin;
+  
+  if(source.fnCuts) fnCuts = source.fnCuts;
+  if(source.fnTotalCutBins) fnTotalCutBins = source.fnCuts;
+  if(source.fCutsArray) SetCutsArray(source.fnTotalCutBins,source.fCutsArray);
+  
+  return *this;
+}
+
+//---------------------------------------------------------------------------
+AliRDHFCutsLctopK0sfromAODtracks::~AliRDHFCutsLctopK0sfromAODtracks() {
+  //
+  //  Default Destructor
+  //
+  
+  if(fCutsArray) delete[] fCutsArray;
+}
+
+//---------------------------------------------------------------------------
+void AliRDHFCutsLctopK0sfromAODtracks::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
+  //
+  // Fills in vars the values of the variables
+  //
+  
+  if (pdgdaughters[0]==-9999) return; // dummy
+
+  AliAODRecoCascadeHF* dd=(AliAODRecoCascadeHF*)d;
+  if(!dd){
+    AliError("No AliAODRecoCascadeHF object found\n");
+    return;
+  }
+  
+  if (nvars!=fnVarsForOpt) {
+    AliError("Cut object seems to have the wrong number of variables\n");
+    return;
+  }
+
+  //Double_t ptD=d->Pt();
+  //Int_t ptbin=PtBin(ptD);
+  Int_t iter=-1;
+
+  if(fVarsForOpt[0]){
+    iter++;
+    Double_t mlcPDG =  TDatabasePDG::Instance()->GetParticle(4122)->Mass();
+    vars[iter]= TMath::Abs(dd->InvMassLctoK0sP()-mlcPDG) ;
+  }
+  if(fVarsForOpt[1]){
+    iter++;
+    vars[iter]= dd->Pt();
+  }
+  if(fVarsForOpt[2]){
+    iter++;
+    AliAODTrack *part = dd->GetBachelor();
+    vars[iter]= part->Pt();
+  }
+  if(fVarsForOpt[3]){
+    iter++;
+    vars[iter]= dd->Getd0Prong(0);
+  }
+  if(fVarsForOpt[4]){
+    iter++;
+    vars[iter]= dd->Getd0Prong(1);
+  }
+  if(fVarsForOpt[5]){
+    iter++;
+    AliAODv0 *v0 = dd->Getv0();
+    vars[iter]= v0->MassK0Short();
+  }
+  if(fVarsForOpt[6]){
+    iter++;
+    vars[iter]= dd->DecayLengthXY();
+  }
+  
+  return;
+}
+
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsLctopK0sfromAODtracks::IsSelected(TObject* obj, Int_t selectionLevel) {
+  //
+  // Apply selection
+  //
+
+  if (!fCutsRD) {
+    AliFatal("Cut matrix not inizialized. Exit...");
+    return 0;
+  }
+
+  AliAODRecoCascadeHF* d=(AliAODRecoCascadeHF*)obj;
+  if(!d){
+    AliDebug(2,"AliAODRecoCascadeHF null");
+    return 0;
+  }
+
+  Double_t ptD=d->Pt();
+  if(ptD<fMinPtCand) return 0;
+  if(ptD>fMaxPtCand) return 0;
+
+  if (selectionLevel==AliRDHFCuts::kAll ||
+      selectionLevel==AliRDHFCuts::kTracks) {
+    //Performed in production stage
+  }
+
+  Int_t returnvalueCuts=1;
+  // selection on candidate
+  if (selectionLevel==AliRDHFCuts::kAll ||
+      selectionLevel==AliRDHFCuts::kCandidate) {
+    
+    Double_t pt=d->Pt();
+    Int_t ptbin=PtBin(pt);
+    if (ptbin==-1) {
+      return 0;
+    }
+    Bool_t okcand=kTRUE;
+    
+    Double_t mlcPDG =  TDatabasePDG::Instance()->GetParticle(4122)->Mass();
+    Double_t mk0sPDG =  TDatabasePDG::Instance()->GetParticle(310)->Mass();
+    AliAODTrack *part = d->GetBachelor();
+    AliAODv0 *v0 = d->Getv0();
+    
+    if(TMath::Abs(d->InvMassLctoK0sP()-mlcPDG) > fCutsRD[GetGlobalIndex(0,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(d->Pt() < fCutsRD[GetGlobalIndex(1,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(part->Pt() < fCutsRD[GetGlobalIndex(2,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(3,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(4,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(TMath::Abs(v0->MassK0Short()-mk0sPDG) > fCutsRD[GetGlobalIndex(5,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(d->DecayLengthXY() < fCutsRD[GetGlobalIndex(6,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    
+    if(!okcand)  return 0;
+    returnvalueCuts = 1;
+  }
+  
+  Int_t returnvaluePID=1;
+  if(selectionLevel==AliRDHFCuts::kAll ||
+     selectionLevel==AliRDHFCuts::kCandidate|| 
+     selectionLevel==AliRDHFCuts::kPID) {
+
+    switch(fPIDStrategy){
+    case kNSigmaCuts:
+      returnvaluePID = IsSelectedPID(d);
+      break;
+    case kCombinedCuts:
+      returnvaluePID = IsSelectedCombinedPID(d);
+      break;
+    }
+  }
+  
+  Int_t returnvalue = 0;
+  if(returnvalueCuts==1 && returnvaluePID==1) returnvalue=1;
+  
+  return returnvalue;
+}
+
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsLctopK0sfromAODtracks::IsSelectedPID(AliAODRecoDecayHF* obj) 
+{
+  //
+  // IsSelectedPID
+  //
+
+  if(!fUsePID || !obj) return 1;
+
+  AliAODRecoCascadeHF* dd=(AliAODRecoCascadeHF*)obj;
+  AliAODTrack *part = dd->GetBachelor();
+  
+  Int_t returnvalue=1;
+
+  if(fPidHF->GetPidResponse()==0x0){
+    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+    AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
+    AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
+    fPidHF->SetPidResponse(pidResp);
+  }
+
+  Int_t isProton=fPidHF->MakeRawPid(part,4); 
+  if(isProton<1) returnvalue = 0;
+  
+  return returnvalue;
+}
+
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsLctopK0sfromAODtracks::IsSelectedCombinedPID(AliAODRecoDecayHF* obj) {
+  //
+  // IsSelectedCombinedPID
+  //
+    
+  if(!fUsePID || !obj) {return 1;}
+
+  AliAODRecoCascadeHF* dd=(AliAODRecoCascadeHF*)obj;
+  AliAODTrack *part = dd->GetBachelor();
+  if(!part) return 0;
+
+  Int_t returnvalue=1;
+  Double_t probProton = GetProtonProbabilityTPCTOF(part);
+  if(probProton<fCombinedPIDThreshold) returnvalue = 0;
+
+  return returnvalue;
+}
+
+//________________________________________________________________________
+Double_t AliRDHFCutsLctopK0sfromAODtracks::GetProtonProbabilityTPCTOF(AliAODTrack* trk) 
+{
+  //
+  // Get Proton probability
+  //
+  fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
+  Double_t prob1[AliPID::kSPECIES];
+  UInt_t detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
+  if (detUsed1 != (UInt_t)fPidHF->GetPidCombined()->GetDetectorMask() ) 
+    { 
+      fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
+      detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
+    }
+  return prob1[AliPID::kProton];
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsLctopK0sfromAODtracks::SingleTrkCuts(AliAODTrack *trk)
+{
+  //
+  // Single Track Cut to be applied before object creation
+  //
+
+  if(trk->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
+  if(!(trk->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
+  if(fProdUseAODFilterBit && !trk->TestFilterMask(BIT(4))) return kFALSE;
+  if(fabs(trk->Eta())>fProdTrackEtaRange) return kFALSE;
+  if(trk->Pt()<fProdTrackPtMin) return kFALSE;
+
+  if(fUsePID)
+    {
+      if(fPidHF->GetPidResponse()==0x0){
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
+       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
+       fPidHF->SetPidResponse(pidResp);
+      }
+
+      Int_t isProton=fPidHF->MakeRawPid(trk,4); 
+      if(isProton<1) return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsLctopK0sfromAODtracks::SingleV0Cuts(AliAODv0 *v0, AliAODVertex *primVert)
+{
+  //
+  // Single V0 Cut to be applied before object creation
+  //
+
+  Bool_t onFlyV0 = v0->GetOnFlyStatus(); // on-the-flight V0s
+  if ( onFlyV0 && !fUseOnTheFlyV0 ) return kFALSE;
+
+  AliAODTrack *cptrack =  (AliAODTrack*)(v0->GetDaughter(0));
+  AliAODTrack *cntrack =  (AliAODTrack*)(v0->GetDaughter(1));
+  if(!cptrack || !cntrack) return kFALSE;
+  if ( cptrack->Charge() == cntrack->Charge() ) return kFALSE;
+  if(!(cptrack->GetStatus() & AliESDtrack::kTPCrefit) ||
+     !(cntrack->GetStatus() & AliESDtrack::kTPCrefit)) return kFALSE;
+  AliAODVertex *maybeKinkPos = (AliAODVertex*)cptrack->GetProdVertex();
+  AliAODVertex *maybeKinkNeg = (AliAODVertex*)cntrack->GetProdVertex();
+  if (maybeKinkPos->GetType()==AliAODVertex::kKink || maybeKinkNeg->GetType()==AliAODVertex::kKink) 
+    return kFALSE;
+
+  if ( ( ( cptrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin ) || 
+       ( ( cntrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin) ) return kFALSE;
+
+  Double_t massK0S = v0->MassK0Short();
+  Double_t mk0sPDG   = TDatabasePDG::Instance()->GetParticle(310)->Mass();
+  if(fabs(massK0S-mk0sPDG)>fProdV0MassTolK0s) return kFALSE;
+
+
+  if(TMath::Abs(v0->DcaV0Daughters())>fProdV0DcaDaughtersMax) return kFALSE;
+  Double_t posVtx[3] = {0.,0.,0.};
+  primVert->GetXYZ(posVtx);
+  Double_t cospav0 = v0->CosPointingAngle(posVtx); 
+  if(cospav0<fProdV0CosPointingAngleToPrimVtxMin) return kFALSE;
+  if(v0->Pt()<fProdV0PtMin) return kFALSE;
+  if(fabs(cptrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
+  if(fabs(cntrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
+  if(cptrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
+  if(cntrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsLctopK0sfromAODtracks::SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *part)
+{
+  //
+  // Mass and pT Cut to be applied before object creation
+  //
+
+  Double_t mprPDG =  TDatabasePDG::Instance()->GetParticle(2212)->Mass();
+  Double_t mLcPDG =  TDatabasePDG::Instance()->GetParticle(4122)->Mass();
+
+  Double_t pxpr_init = part->Px();
+  Double_t pypr_init = part->Py();
+  Double_t pzpr_init = part->Pz();
+  Double_t Epr_init = sqrt(pxpr_init*pxpr_init+pypr_init*pypr_init+pzpr_init*pzpr_init+mprPDG*mprPDG);
+
+  Double_t pxv0_init = v0->Px();
+  Double_t pyv0_init = v0->Py();
+  Double_t pzv0_init = v0->Pz();
+  Double_t massv0_init = v0->MassK0Short();
+  Double_t Ev0_init = sqrt(pxv0_init*pxv0_init+pyv0_init*pyv0_init+pzv0_init*pzv0_init+massv0_init*massv0_init);
+
+  Double_t pxlc_init = pxpr_init+pxv0_init;
+  Double_t pylc_init = pypr_init+pyv0_init;
+  Double_t pzlc_init = pzpr_init+pzv0_init;
+  Double_t Elc_init = Epr_init+Ev0_init;
+  Double_t lcmass_init = sqrt(Elc_init*Elc_init-pxlc_init*pxlc_init-pylc_init*pylc_init-pzlc_init*pzlc_init);
+
+  if(lcmass_init<mLcPDG-fProdRoughMassTol || lcmass_init>mLcPDG+fProdRoughMassTol) return kFALSE;
+  if(sqrt(pxlc_init*pxlc_init+pylc_init*pylc_init)<fProdRoughPtMin) return kFALSE;
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsLctopK0sfromAODtracks::SetCutsArray(Int_t nCuts, Int_t nVars, Int_t nPtBins, Float_t ***cutsArray) 
+{
+  //
+  // store the cuts
+  //
+  if (nVars!=fnVars) {
+    AliError(" wrong number of variables\n");
+    return;
+  }
+  if (nCuts!=fnCuts) {
+    AliError(" wrong number of cuts\n");
+    return;
+  }
+  if (nPtBins!=fnPtBins) {
+    AliError(" wrong number of pT bin\n");
+    return;
+  }
+
+  if(!fCutsArray)
+    {
+      fnTotalCutBins = nCuts * nVars * nPtBins;
+      fCutsArray = new Float_t[fnTotalCutBins];
+    }
+
+  for(Int_t icuts=0;icuts<nCuts;icuts++){
+    for(Int_t iv=0;iv<nVars;iv++){
+      for(Int_t ip=0;ip<nPtBins;ip++){
+       Int_t gid = GetCutArrayID(icuts,iv,ip);
+       fCutsArray[gid] = cutsArray[icuts][iv][ip];
+      }
+    }
+  }
+  return;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsLctopK0sfromAODtracks::SetCutsArray(Int_t nTotBins, Float_t *cutsArray) 
+{
+  //
+  // store the cuts
+  //
+
+  if (nTotBins!=fnVars*fnPtBins*fnCuts) {
+    AliError(" wrong number of variables\n");
+    return;
+  }
+
+  if(!fCutsArray)
+    {
+      fnTotalCutBins = fnCuts * fnVars * fnPtBins;
+      fCutsArray = new Float_t[fnTotalCutBins];
+    }
+
+  for(Int_t i=0;i<nTotBins;i++){
+    fCutsArray[i] = cutsArray[i];
+  }
+
+  return;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsLctopK0sfromAODtracks::SetCutsFromArray(Int_t iCuts) 
+{
+  //
+  // Read Cuts from fCutsArray and update fCutsRD
+  //
+  Float_t** cutsarray;
+  cutsarray=new Float_t*[fnVars];
+  for(Int_t ic=0;ic<fnVars;ic++){cutsarray[ic]=new Float_t[fnPtBins];}
+
+  for(Int_t i=0;i<fnVars;i++){
+    for(Int_t j=0;j<fnPtBins;j++){
+      Int_t gid = GetCutArrayID(iCuts,i,j);
+      cutsarray[i][j] = fCutsArray[gid];
+    }
+  }
+  SetCuts(fnVars,fnPtBins,cutsarray);
+
+  for(Int_t ic=0;ic<fnVars;ic++){
+    delete[] cutsarray[ic];
+  }
+  delete[] cutsarray;
+}
+
+//________________________________________________________________________
+Int_t AliRDHFCutsLctopK0sfromAODtracks::GetCutArrayID(Int_t ic, Int_t iv, Int_t ip) 
+{
+  //
+  // Global index of fCutsArray
+  //
+  return ic*fnVars*fnPtBins+iv*fnPtBins+ip;
+}
diff --git a/PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.h b/PWGHF/vertexingHF/AliRDHFCutsLctopK0sfromAODtracks.h
new file mode 100644 (file)
index 0000000..fe163ef
--- /dev/null
@@ -0,0 +1,114 @@
+#ifndef ALIRDHFCUTSLCTOPK0SFROMAODTRACKS_H
+#define ALIRDHFCUTSLCTOPK0SFROMAODTRACKS_H
+/* Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//***********************************************************
+// Class AliRDHFCutsXictoPLUSXiPiPifromAODtracks
+// class for cuts on AOD reconstructed Lc-> pK0s
+//***********************************************************
+
+#include "AliRDHFCuts.h"
+
+class AliRDHFCutsLctopK0sfromAODtracks : public AliRDHFCuts
+{
+ public:
+
+  enum EPIDStrategy{
+    kNSigmaCuts,
+    kCombinedCuts
+  };
+
+  AliRDHFCutsLctopK0sfromAODtracks(const char* name="CutsLctopK0s");
+  virtual ~AliRDHFCutsLctopK0sfromAODtracks();
+  AliRDHFCutsLctopK0sfromAODtracks(const AliRDHFCutsLctopK0sfromAODtracks& source);
+  AliRDHFCutsLctopK0sfromAODtracks& operator=(const AliRDHFCutsLctopK0sfromAODtracks& source);
+
+  using AliRDHFCuts::GetCutVarsForOpt;
+  virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters);
+
+  using AliRDHFCuts::IsSelected;
+  virtual Int_t IsSelected(TObject* obj,Int_t selectionLevel);
+  using AliRDHFCuts::IsSelectedPID;
+  virtual Int_t IsSelectedPID(AliAODRecoDecayHF* obj);
+  Int_t IsSelectedCombinedPID(AliAODRecoDecayHF* obj);
+  Double_t GetProtonProbabilityTPCTOF(AliAODTrack *trk);
+
+  void SetPIDStrategy(EPIDStrategy pidStrategy){fPIDStrategy=pidStrategy;}
+  EPIDStrategy GetPIDStrategy() const {return fPIDStrategy;}
+  void SetCombinedPIDThreshold(Double_t a){fCombinedPIDThreshold=a;}
+  Double_t GetCombinedPIDThreshold(){return fCombinedPIDThreshold;}
+
+  void SetUseOnTheFlyV0(Bool_t a) { fUseOnTheFlyV0=a; }
+  Bool_t GetUseOnTheFlyV0() { return fUseOnTheFlyV0; }
+
+  Bool_t SingleTrkCuts(AliAODTrack *trk);
+  Bool_t SingleV0Cuts(AliAODv0 *v0, AliAODVertex *vert);
+  Bool_t SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *trk1);
+
+  void SetProdTrackPtMin(Double_t a){fProdTrackPtMin=a;}
+  void SetProdTrackEtaRange(Double_t a){fProdTrackEtaRange=a;}
+  void SetProdUseAODFilterBit(Bool_t a){fProdUseAODFilterBit=a;}
+  void SetProdV0MassTolK0s(Double_t a){fProdV0MassTolK0s=a;}
+  void SetProdV0PtMin(Double_t a){fProdV0PtMin=a;}
+  void SetProdV0CosPointingAngleToPrimVtxMin(Double_t a){fProdV0CosPointingAngleToPrimVtxMin=a;}
+  void SetProdV0DcaDaughtersMax(Double_t a){fProdV0DcaDaughtersMax=a;}
+  void SetProdV0DaughterEtaRange(Double_t a){fProdV0DaughterEtaRange=a;}
+  void SetProdV0DaughterPtMin(Double_t a){fProdV0DaughterPtMin=a;}
+  void SetProdV0DaughterTPCClusterMin(Double_t a){fProdV0DaughterTPCClusterMin=a;}
+  
+  void SetProdRoughMassTol(Double_t a){fProdRoughMassTol=a;}
+  void SetProdRoughPtMin(Double_t a){fProdRoughPtMin=a;}
+  
+  Double_t GetProdTrackPtMin(){return fProdTrackPtMin;}
+  Double_t GetProdTrackEtaRange(){return fProdTrackEtaRange;}
+  Bool_t   GetProdUseAODFilterBit(){return fProdUseAODFilterBit;}
+  Double_t GetProdV0MassTolK0s(){return fProdV0MassTolK0s;}
+  Double_t GetProdV0PtMin(){return fProdV0PtMin;}
+  Double_t GetProdV0CosPointingAngleToPrimVtxMin(){return fProdV0CosPointingAngleToPrimVtxMin;}
+  Double_t GetProdV0DcaDaughtersMax(){return fProdV0DcaDaughtersMax;}
+  Double_t GetProdV0DaughterEtaRange(){return fProdV0DaughterEtaRange;}
+  Double_t GetProdV0DaughterPtMin(){return fProdV0DaughterPtMin;}
+  Double_t GetProdV0DaughterTPCClusterMin(){return fProdV0DaughterTPCClusterMin;}
+  
+  Double_t GetProdRoughMassTol(){return fProdRoughMassTol;}
+  Double_t GetProdRoughPtMin(){return fProdRoughPtMin;}
+  
+  void  SetNCuts(Int_t ncuts){fnCuts=ncuts;}
+  Int_t GetNCutsArray(){return fnCuts;}
+  void  SetCutsArray(Int_t nCuts, Int_t nVars,Int_t nPtBins,Float_t ***cutsRD);
+  void  SetCutsArray(Int_t nTotBins,Float_t *cutsRD);
+  void  SetCutsFromArray(Int_t nCuts);
+  Int_t GetCutArrayID(Int_t ic,Int_t iv,Int_t ip);
+
+ protected:
+       
+ private:
+
+  EPIDStrategy fPIDStrategy;        //PID strategy
+  Double_t fCombinedPIDThreshold;   //Threshold used in  IsSelectedCombinedPID 
+  Bool_t   fUseOnTheFlyV0;          //Flag to check if we use on-the-fly v0
+  
+  Double_t fProdTrackPtMin;         //Minimum Track pT used before object creation
+  Double_t fProdTrackEtaRange;      //eta range used before object creation
+  Bool_t   fProdUseAODFilterBit;    //Flag for AOD filter Bit used before object creation
+  Double_t fProdV0MassTolK0s;       //K0s mass selection  used before object creation
+  Double_t fProdV0PtMin;            //Minimum K0s pT used before object creation
+  Double_t fProdV0CosPointingAngleToPrimVtxMin;//V0 pointing angle used before object creation
+  Double_t fProdV0DcaDaughtersMax;  //Max DCA between V0 daughters used before object creation
+  Double_t fProdV0DaughterEtaRange; //V0Daughter eta range used before object creation
+  Double_t fProdV0DaughterPtMin;    //V0 Daughter pT min used before object creation
+  Double_t fProdV0DaughterTPCClusterMin;//V0 daughter Minimum TPC cluster pT used before object creation
+  Double_t fProdRoughMassTol;       //Mass cut for Lc used before object creation
+  Double_t fProdRoughPtMin;         //pT cut for Lc used before object creation
+  
+  Int_t fnCuts;               //Number of Cuts defined 
+  Int_t fnTotalCutBins;       // fnCuts *fnVars * fnPtBins
+  Float_t *fCutsArray;        //[fnTotalCutBins]
+
+  ClassDef(AliRDHFCutsLctopK0sfromAODtracks,1);
+};
+
+#endif
diff --git a/PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.cxx b/PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.cxx
new file mode 100644 (file)
index 0000000..3f64815
--- /dev/null
@@ -0,0 +1,658 @@
+/**************************************************************************
+ * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/////////////////////////////////////////////////////////////
+//
+// Class for cuts on AOD reconstructed Lc->p+K0s
+//
+// Modified by Y.S Watanabe - wyosuke@cns.s.u-tokyo.ac.jp
+//
+/////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+
+#include <TDatabasePDG.h>
+#include <TMath.h>
+
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "AliPIDResponse.h"
+#include "AliRDHFCutsXicPlustoXiPiPifromAODtracks.h"
+#include "AliAODRecoCascadeHF3Prong.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliAODVertex.h"
+#include "AliAODv0.h"
+#include "AliAODcascade.h"
+#include "AliESDv0.h"
+
+using std::cout;
+using std::endl;
+
+ClassImp(AliRDHFCutsXicPlustoXiPiPifromAODtracks)
+
+//--------------------------------------------------------------------------
+AliRDHFCutsXicPlustoXiPiPifromAODtracks::AliRDHFCutsXicPlustoXiPiPifromAODtracks(const char* name) :
+  AliRDHFCuts(name),
+  fPIDStrategy(kNSigmaCuts),
+  fCombinedPIDThreshold(0.),
+  fProdTrackPtMin(0.),
+  fProdTrackEtaRange(9999.),
+  fProdUseAODFilterBit(kTRUE),
+  fProdMassTolLambda(0.010),
+  fProdMassTolXi(0.008),
+  fProdRfidMinV0(0.6),
+  fProdRfidMaxV0(100.0),
+  fProdRfidMinXi(0.6),
+  fProdRfidMaxXi(100.0),
+  fProdLikeSignDcaMax(2.0),
+  fProdRoughMassTol(0.25),
+  fProdRoughPtMin(0.0),
+  fnCuts(0),
+  fnTotalCutBins(1),
+  fCutsArray(0)
+{
+  //
+  // Default Constructor
+  //
+
+  const Int_t nvars=13;
+  SetNVars(nvars);
+  TString varNames[nvars]={"Xic inv. mass [GeV/c2]",                   //  0
+                          "Xic Pt [GeV/c]", //1
+                          "Xi mass Tolrelance [GeV/c2]", //2
+                          "Lambda mass Tolrelance [GeV/c2]", //3
+                          "Max DCA pi-pi [cm]", //4
+                          "Max DCA pi-casc [cm]",//5
+                          "Max d0 pi [cm]",//6
+                          "Max d0 Xi [cm]",//7
+                          "Min d0 Xi-Bach [cm]",//8
+                          "Min d0 Xi-V0 [cm]",//9
+                          "Min Xic cosPA ",//10
+                          "Min DecayLengthXY ",//11
+                          "Min Bachelor pT"//12
+  };
+
+  Bool_t isUpperCut[nvars]={kTRUE,  //  0
+                           kFALSE, //1
+                           kTRUE, //2
+                           kTRUE, //3
+                           kTRUE, //4
+                           kTRUE, //5
+                           kTRUE, //6
+                           kTRUE, //7
+                           kFALSE, //8
+                           kFALSE, //9
+                           kFALSE, //10
+                           kFALSE,//11
+                           kFALSE //12
+  };
+  SetVarNames(nvars,varNames,isUpperCut);
+  Bool_t forOpt[nvars]={kFALSE, //  0
+                       kFALSE, //1
+                       kTRUE, //2
+                       kTRUE, //3
+                       kTRUE, //4
+                       kTRUE, //5
+                       kTRUE, //6
+                       kTRUE, //7
+                       kTRUE, //8
+                       kTRUE, //9
+                       kTRUE, //10
+                       kTRUE, //11
+                       kTRUE //12
+  };
+  SetVarsForOpt(nvars,forOpt);
+
+  Float_t limits[2]={0,999999999.};
+  SetPtBins(2,limits);
+}
+
+//--------------------------------------------------------------------------
+AliRDHFCutsXicPlustoXiPiPifromAODtracks::AliRDHFCutsXicPlustoXiPiPifromAODtracks(const AliRDHFCutsXicPlustoXiPiPifromAODtracks &source) :
+  AliRDHFCuts(source),
+  fPIDStrategy(source.fPIDStrategy),
+  fCombinedPIDThreshold(source.fCombinedPIDThreshold),
+  fProdTrackPtMin(source.fProdTrackPtMin),
+  fProdTrackEtaRange(source.fProdTrackEtaRange),
+  fProdUseAODFilterBit(source.fProdUseAODFilterBit),
+  fProdMassTolLambda(source.fProdMassTolLambda),
+  fProdMassTolXi(source.fProdMassTolXi),
+  fProdRfidMinV0(source.fProdRfidMinV0),
+  fProdRfidMaxV0(source.fProdRfidMaxV0),
+  fProdRfidMinXi(source.fProdRfidMinXi),
+  fProdRfidMaxXi(source.fProdRfidMaxXi),
+  fProdLikeSignDcaMax(source.fProdLikeSignDcaMax),
+  fProdRoughMassTol(source.fProdRoughMassTol),
+  fProdRoughPtMin(source.fProdRoughPtMin),
+  fnCuts(source.fnCuts),
+  fnTotalCutBins(source.fnTotalCutBins),
+  fCutsArray(0)
+{
+  //
+  // Copy constructor
+  //
+  if(source.fCutsArray) SetCutsArray(source.fnTotalCutBins,source.fCutsArray);
+}
+
+//--------------------------------------------------------------------------
+AliRDHFCutsXicPlustoXiPiPifromAODtracks &AliRDHFCutsXicPlustoXiPiPifromAODtracks::operator=(const AliRDHFCutsXicPlustoXiPiPifromAODtracks &source)
+{
+  //
+  // assignment operator
+  //
+
+  if (this != &source) {
+    AliRDHFCuts::operator=(source);
+  }
+
+  fPIDStrategy = source.fPIDStrategy;
+  fCombinedPIDThreshold = source.fCombinedPIDThreshold;
+  fProdUseAODFilterBit = source.fProdUseAODFilterBit;
+  fProdTrackPtMin = source.fProdTrackPtMin;
+  fProdTrackEtaRange = source.fProdTrackEtaRange;
+  fProdMassTolLambda = source.fProdMassTolLambda;
+  fProdMassTolXi = source.fProdMassTolXi;
+  fProdRfidMinV0 = source.fProdRfidMinV0;
+  fProdRfidMaxV0 = source.fProdRfidMaxV0;
+  fProdRfidMinXi = source.fProdRfidMinXi;
+  fProdRfidMaxXi = source.fProdRfidMaxXi;
+  fProdLikeSignDcaMax = source.fProdLikeSignDcaMax;
+  fProdRoughMassTol = source.fProdRoughMassTol;
+  fProdRoughPtMin = source.fProdRoughPtMin;
+  fnCuts = source.fnCuts;
+  fnTotalCutBins = source.fnCuts;
+  if(source.fCutsArray) SetCutsArray(source.fnTotalCutBins,source.fCutsArray);
+
+  return *this;
+}
+
+//---------------------------------------------------------------------------
+AliRDHFCutsXicPlustoXiPiPifromAODtracks::~AliRDHFCutsXicPlustoXiPiPifromAODtracks() {
+  //
+  //  Default Destructor
+  //
+  if(fCutsArray) delete[] fCutsArray;
+}
+
+//---------------------------------------------------------------------------
+void AliRDHFCutsXicPlustoXiPiPifromAODtracks::GetCutVarsForOpt(AliAODRecoDecayHF *d, Float_t *vars, Int_t nvars, Int_t *pdgdaughters) {
+  //
+  // Fills in vars the values of the variables
+  //
+
+  if (pdgdaughters[0]==-9999) return; // dummy
+
+  AliAODRecoCascadeHF3Prong* dd=(AliAODRecoCascadeHF3Prong*)d;
+  if(!dd){
+    AliDebug(2," No AliAODRecoCascadeHF3Prong object found\n");
+    return;
+  }
+
+  if (nvars!=fnVarsForOpt) {
+    AliError("AliRDHFCutsXicPlustoXiPiPifromAODtracks wrong number of variables\n");
+    return;
+  }
+
+  //Double_t ptD=d->Pt();
+  //Int_t ptbin=PtBin(ptD);
+  Int_t iter=-1;
+
+  if(fVarsForOpt[0]){
+    iter++;
+    Double_t mxicPDG =  TDatabasePDG::Instance()->GetParticle(4232)->Mass();
+    vars[iter]= TMath::Abs(dd->InvMassPiXiPi()-mxicPDG) ;
+  }
+  if(fVarsForOpt[1]){
+    iter++;
+    vars[iter]= dd->Pt();
+  }
+  if(fVarsForOpt[2]){
+    iter++;
+    Double_t mxiPDG =  TDatabasePDG::Instance()->GetParticle(3312)->Mass();
+    vars[iter]= TMath::Abs(dd->CascMassXi()-mxiPDG);
+  }
+  if(fVarsForOpt[3]){
+    iter++;
+    Double_t mLPDG =  TDatabasePDG::Instance()->GetParticle(3122)->Mass();
+    vars[iter]= TMath::Abs(dd->CascMassLambda()-mLPDG);
+  }
+  Double_t dca[3];
+  dd->GetDCAs(dca);
+  if(fVarsForOpt[4]){
+    iter++;
+    vars[iter]= dca[2];
+  }
+  if(fVarsForOpt[5]){
+    iter++;
+    vars[iter]= dca[0];
+  }
+  if(fVarsForOpt[6]){
+    iter++;
+    vars[iter]= dd->Getd0Prong(0);
+  }
+  if(fVarsForOpt[7]){
+    iter++;
+    vars[iter]= dd->Getd0Prong(1);
+  }
+  if(fVarsForOpt[8]){
+    iter++;
+    vars[iter]= dd->CascDcaBachToPrimVertex();
+  }
+  if(fVarsForOpt[9]){
+    iter++;
+    vars[iter]= dd->CascDcaV0ToPrimVertex();
+  }
+  if(fVarsForOpt[10]){
+    iter++;
+    vars[iter]= dd->XicCosPointingAngle();
+  }
+  if(fVarsForOpt[11]){
+    iter++;
+    vars[iter]= dd->DecayLengthXY();
+  }
+  if(fVarsForOpt[12]){
+    iter++;
+    vars[iter]= dd->PtProng(0);
+  }
+
+  return;
+}
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::IsSelected(TObject* obj,Int_t selectionLevel) 
+{
+  //
+  // Apply selection
+  //
+
+  if (!fCutsRD) {
+    AliFatal("Cut matrice not inizialized. Exit...");
+    return 0;
+  }
+
+  AliAODRecoCascadeHF3Prong* d=(AliAODRecoCascadeHF3Prong*)obj;
+  if(!d){
+    AliDebug(2," No AliAODRecoCascadeHF3Prong object found\n");
+    return 0;
+  }
+
+  Double_t ptD=d->Pt();
+  if(ptD<fMinPtCand) return 0;
+  if(ptD>fMaxPtCand) return 0;
+
+  if (selectionLevel==AliRDHFCuts::kAll ||
+      selectionLevel==AliRDHFCuts::kTracks) {
+    //Performed in production stage
+  }
+
+  Int_t returnvalueCuts=1;
+  // selection on candidate
+  if (selectionLevel==AliRDHFCuts::kAll ||
+      selectionLevel==AliRDHFCuts::kCandidate) {
+
+    Double_t pt=d->Pt();
+    Int_t ptbin=PtBin(pt);
+    if (ptbin==-1) {
+      return 0;
+    }
+    Bool_t okcand=kTRUE;
+
+    Double_t mLPDG =  TDatabasePDG::Instance()->GetParticle(3122)->Mass();
+    Double_t mxiPDG =  TDatabasePDG::Instance()->GetParticle(3312)->Mass();
+    Double_t mxicPDG =  TDatabasePDG::Instance()->GetParticle(4232)->Mass();
+    if(TMath::Abs(d->InvMassPiXiPi()-mxicPDG) > fCutsRD[GetGlobalIndex(0,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(d->Pt()< fCutsRD[GetGlobalIndex(1,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if(TMath::Abs(d->CascMassXi()-mxiPDG) > fCutsRD[GetGlobalIndex(2,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(d->CascMassLambda()-mLPDG) > fCutsRD[GetGlobalIndex(3,ptbin)]) &&(TMath::Abs(d->CascMassAntiLambda()-mLPDG) > fCutsRD[GetGlobalIndex(3,ptbin)]) )
+      {
+       okcand = kFALSE;
+      }
+    Double_t dca[3];
+    d->GetDCAs(dca);
+    if(TMath::Abs(dca[2]) > fCutsRD[GetGlobalIndex(4,ptbin)])
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(dca[0]) > fCutsRD[GetGlobalIndex(5,ptbin)]) && (TMath::Abs(dca[1]) > fCutsRD[GetGlobalIndex(5,ptbin)]) ) 
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)]) && (TMath::Abs(d->Getd0Prong(2)) > fCutsRD[GetGlobalIndex(6,ptbin)]) ) 
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(7,ptbin)])) 
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(d->CascDcaBachToPrimVertex()) < fCutsRD[GetGlobalIndex(8,ptbin)])) 
+      {
+       okcand = kFALSE;
+      }
+    if((TMath::Abs(d->CascDcaV0ToPrimVertex()) < fCutsRD[GetGlobalIndex(9,ptbin)])) 
+      {
+       okcand = kFALSE;
+      }
+    if( d->XicCosPointingAngle() < fCutsRD[GetGlobalIndex(10,ptbin)]) 
+      {
+       okcand = kFALSE;
+      }
+    if( d->DecayLengthXY() < fCutsRD[GetGlobalIndex(11,ptbin)]) 
+      {
+       okcand = kFALSE;
+      }
+    if( d->PtProng(0) < fCutsRD[GetGlobalIndex(12,ptbin)] || d->PtProng(2) < fCutsRD[GetGlobalIndex(12,ptbin)]  ) 
+      {
+       okcand = kFALSE;
+      }
+
+    if(!okcand)  return 0;
+    returnvalueCuts = 1;
+  }
+
+  Int_t returnvaluePID=1;
+  if(selectionLevel==AliRDHFCuts::kAll ||
+     selectionLevel==AliRDHFCuts::kCandidate|| 
+     selectionLevel==AliRDHFCuts::kPID) {
+
+    switch(fPIDStrategy){
+    case kNSigmaCuts:
+      returnvaluePID = IsSelectedPID(d);
+      break;
+    case kCombinedCuts:
+      returnvaluePID = IsSelectedCombinedPID(d);
+      break;
+    }
+  }
+
+  Int_t returnvalue = 0;
+  if(returnvalueCuts==1 && returnvaluePID==1) returnvalue=1;
+
+  return returnvalue;
+}
+
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::IsSelectedPID(AliAODRecoDecayHF* obj) 
+{
+  //
+  //  PID selection
+  //
+
+  if(!fUsePID || !obj) return 1;
+
+  AliAODRecoCascadeHF3Prong* dd=(AliAODRecoCascadeHF3Prong*)obj;
+  AliAODTrack *part1 = dd->GetBachelor1();
+  AliAODTrack *part2 = dd->GetBachelor2();
+
+  Int_t returnvalue=1;
+
+  if(fPidHF->GetPidResponse()==0x0){
+    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+    AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
+    AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
+    fPidHF->SetPidResponse(pidResp);
+  }
+
+  Int_t isPion1=fPidHF->MakeRawPid(part1,2); 
+  Int_t isPion2=fPidHF->MakeRawPid(part2,2); 
+
+  if(isPion1<1) returnvalue = 0;
+  if(isPion2<1) returnvalue = 0;
+
+  return returnvalue;
+}
+
+//---------------------------------------------------------------------------
+Int_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::IsSelectedCombinedPID(AliAODRecoDecayHF* obj) {
+  //
+  //  Combined PID selection
+  //
+    
+  if(!fUsePID || !obj) {return 1;}
+
+  AliAODRecoCascadeHF3Prong* dd=(AliAODRecoCascadeHF3Prong*)obj;
+  AliAODTrack *part1 = dd->GetBachelor1();
+  AliAODTrack *part2 = dd->GetBachelor2();
+  if(!part1||!part2) return 0;
+
+  Int_t returnvalue=1;
+  Double_t probPion1 = GetPionProbabilityTPCTOF(part1);
+  Double_t probPion2 = GetPionProbabilityTPCTOF(part2);
+  if(probPion1<fCombinedPIDThreshold) returnvalue = 0;
+  if(probPion2<fCombinedPIDThreshold) returnvalue = 0;
+  return returnvalue;
+}
+
+//________________________________________________________________________
+Double_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::GetPionProbabilityTPCTOF(AliAODTrack* trk) 
+{
+  //
+  //  Get Pion Probablility
+  //
+  //fPidHF->GetPidCombined()->SetDefaultTPCPriors();
+  fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
+  Double_t prob1[AliPID::kSPECIES];
+  UInt_t detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
+  if (detUsed1 != (UInt_t)fPidHF->GetPidCombined()->GetDetectorMask() ) 
+    { 
+      fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
+      detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
+    }
+  return prob1[AliPID::kPion];
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::SingleTrkCuts(AliAODTrack *trk)
+{
+  //
+  //  Single Track Cut
+  //
+  
+  if(trk->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
+  if(!(trk->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
+
+  if(fProdUseAODFilterBit && !trk->TestFilterMask(BIT(4))) return kFALSE;
+  //   if(!fAnalCuts->IsDaughterSelected(trk,fV1,esdTrackCuts)) return kFALSE;
+  if(fabs(trk->Eta())>fProdTrackEtaRange) return kFALSE;
+  if(trk->Pt()<fProdTrackPtMin) return kFALSE;
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::SingleCascadeCuts(AliAODcascade *casc)
+{
+  //
+  //  Single Cascade Cut
+  //
+       
+  if(!casc) return kFALSE;
+
+  AliAODTrack *ptrack = (AliAODTrack*) (casc->GetDaughter(0));
+  AliAODTrack *ntrack = (AliAODTrack*) (casc->GetDaughter(1));
+  AliAODTrack *btrack = (AliAODTrack*) (casc->GetDecayVertexXi()->GetDaughter(0));
+  
+  if(!ptrack||!ntrack||!btrack) return kFALSE;
+
+  Double_t mLPDG =  TDatabasePDG::Instance()->GetParticle(3122)->Mass();
+  Double_t mxiPDG =  TDatabasePDG::Instance()->GetParticle(3312)->Mass();
+  
+  Double_t massLambda = casc->MassLambda();
+  Double_t massAntiLambda = casc->MassAntiLambda();
+  if(TMath::Abs(massLambda-mLPDG)>fProdMassTolLambda && TMath::Abs(massAntiLambda-mLPDG)>fProdMassTolLambda) 
+    return kFALSE;
+  
+  Double_t massXi = casc->MassXi();
+  if(TMath::Abs(massXi-mxiPDG)>fProdMassTolXi)
+    return kFALSE;
+  
+  Double_t lPosXi[3];
+  lPosXi[0] = casc->DecayVertexXiX();
+  lPosXi[1] = casc->DecayVertexXiY();
+  lPosXi[2] = casc->DecayVertexXiZ();
+  Double_t decayvertXi = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]);
+  Double_t lPosV0[3];
+  lPosV0[0] = casc->DecayVertexV0X();
+  lPosV0[1] = casc->DecayVertexV0Y();
+  lPosV0[2] = casc->DecayVertexV0Z();
+  Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]);
+  
+  if(decayvertV0<fProdRfidMinV0 || decayvertV0>fProdRfidMaxV0) return kFALSE;
+  if(decayvertXi<fProdRfidMinXi || decayvertXi>fProdRfidMaxXi) return kFALSE;
+  
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::SelectWithRoughCuts(AliAODcascade *casc, AliAODTrack *part1, AliAODTrack *part2)
+{
+  //
+  //  Select With Rough mass and pT cut before object creation
+  //
+
+  //Constants
+  Double_t mpiPDG =  TDatabasePDG::Instance()->GetParticle(211)->Mass();
+  Double_t mxiPDG =  TDatabasePDG::Instance()->GetParticle(3312)->Mass();
+  Double_t mxicPDG =  TDatabasePDG::Instance()->GetParticle(4232)->Mass();
+
+  Double_t pxpi1_init = part1->Px();
+  Double_t pypi1_init = part1->Py();
+  Double_t pzpi1_init = part1->Pz();
+  Double_t Epi1_init = sqrt(pxpi1_init*pxpi1_init+pypi1_init*pypi1_init+pzpi1_init*pzpi1_init+mpiPDG*mpiPDG);
+  Double_t pxpi2_init = part2->Px();
+  Double_t pypi2_init = part2->Py();
+  Double_t pzpi2_init = part2->Pz();
+  Double_t Epi2_init = sqrt(pxpi2_init*pxpi2_init+pypi2_init*pypi2_init+pzpi2_init*pzpi2_init+mpiPDG*mpiPDG);
+  Double_t pxcasc_init = casc->MomXiX();
+  Double_t pycasc_init = casc->MomXiY();
+  Double_t pzcasc_init = casc->MomXiZ();
+  Double_t Ecasc_init = sqrt(pxcasc_init*pxcasc_init+pycasc_init*pycasc_init+pzcasc_init*pzcasc_init+mxiPDG*mxiPDG);
+  Double_t pxxic_init = pxpi1_init+pxpi2_init+pxcasc_init;
+  Double_t pyxic_init = pypi1_init+pypi2_init+pycasc_init;
+  Double_t pzxic_init = pzpi1_init+pzpi2_init+pzcasc_init;
+  Double_t Exic_init = Epi1_init+Epi2_init+Ecasc_init;
+  Double_t xicmass_init = sqrt(Exic_init*Exic_init-pxxic_init*pxxic_init-pyxic_init*pyxic_init-pzxic_init*pzxic_init);
+  
+  if(xicmass_init<mxicPDG-fProdRoughMassTol || xicmass_init>mxicPDG+fProdRoughMassTol) return kFALSE;
+  if(sqrt(pxxic_init*pxxic_init+pyxic_init*pyxic_init)<fProdRoughPtMin) return kFALSE;
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsXicPlustoXiPiPifromAODtracks::SetCutsArray(Int_t nCuts, Int_t nVars, Int_t nPtBins, Float_t ***cutsArray) 
+{
+  //
+  // store the cuts
+  //
+  if (nVars!=fnVars) {
+    AliError(" wrong number of variables\n");
+    return;
+  }
+  if (nCuts!=fnCuts) {
+    AliError(" wrong number of cuts\n");
+    return;
+  }
+  if (nPtBins!=fnPtBins) {
+    AliError(" wrong number of pT bins\n");
+    return;
+  }
+
+  if(!fCutsArray)
+    {
+      fnTotalCutBins = nCuts * nVars * nPtBins;
+      fCutsArray = new Float_t[fnTotalCutBins];
+    }
+
+  for(Int_t icuts=0;icuts<nCuts;icuts++){
+    for(Int_t iv=0;iv<nVars;iv++){
+      for(Int_t ip=0;ip<nPtBins;ip++){
+       Int_t gid = GetCutArrayID(icuts,iv,ip);
+       fCutsArray[gid] = cutsArray[icuts][iv][ip];
+      }
+    }
+  }
+  return;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsXicPlustoXiPiPifromAODtracks::SetCutsArray(Int_t nTotBins, Float_t *cutsArray) 
+{
+  //
+  // store the cuts
+  //
+  if (nTotBins!=fnVars*fnPtBins*fnCuts) {
+    AliError(" wrong number of variables\n");
+    return;
+  }
+
+  if(!fCutsArray)
+    {
+      fnTotalCutBins = fnCuts * fnVars * fnPtBins;
+      fCutsArray = new Float_t[fnTotalCutBins];
+    }
+
+  for(Int_t i=0;i<nTotBins;i++){
+    fCutsArray[i] = cutsArray[i];
+  }
+
+  return;
+}
+
+//________________________________________________________________________
+void AliRDHFCutsXicPlustoXiPiPifromAODtracks::SetCutsFromArray(Int_t iCuts) 
+{
+  //
+  //  Update fCutsRD
+  //
+
+  Float_t** cutsarray;
+  cutsarray=new Float_t*[fnVars];
+  for(Int_t ic=0;ic<fnVars;ic++){cutsarray[ic]=new Float_t[fnPtBins];}
+
+  for(Int_t i=0;i<fnVars;i++){
+    for(Int_t j=0;j<fnPtBins;j++){
+      Int_t gid = GetCutArrayID(iCuts,i,j);
+      cutsarray[i][j] = fCutsArray[gid];
+    }
+  }
+  SetCuts(fnVars,fnPtBins,cutsarray);
+
+  for(Int_t ic=0;ic<fnVars;ic++){
+    delete[] cutsarray[ic];
+  }
+  delete[] cutsarray;
+}
+
+//________________________________________________________________________
+Int_t AliRDHFCutsXicPlustoXiPiPifromAODtracks::GetCutArrayID(Int_t ic, Int_t iv, Int_t ip) 
+{
+  //
+  //  Get GlobalIndex of fCutsArray
+  //
+  return ic*fnVars*fnPtBins+iv*fnPtBins+ip;
+}
diff --git a/PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.h b/PWGHF/vertexingHF/AliRDHFCutsXicPlustoXiPiPifromAODtracks.h
new file mode 100644 (file)
index 0000000..b82edd3
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef ALIRDHFCUTSXICPLUSTOXIPIPIFROMAODTRACKS_H
+#define ALIRDHFCUTSXICPLUSTOXIPIPIFROMAODTRACKS_H
+/* Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//***********************************************************
+// Class AliRDHFCutsXictoPLUSXiPiPifromAODtracks
+// class for cuts on AOD reconstructed Xic-> pi Xi pi
+//***********************************************************
+
+#include "AliRDHFCuts.h"
+
+class AliRDHFCutsXicPlustoXiPiPifromAODtracks : public AliRDHFCuts
+{
+ public:
+
+  enum EPIDStrategy{
+    kNSigmaCuts,
+    kCombinedCuts
+  };
+
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks(const char* name="CutsXicPlustoXiPiPi");
+  virtual ~AliRDHFCutsXicPlustoXiPiPifromAODtracks();
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks(const AliRDHFCutsXicPlustoXiPiPifromAODtracks& source);
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks& operator=(const AliRDHFCutsXicPlustoXiPiPifromAODtracks& source);
+
+  using AliRDHFCuts::GetCutVarsForOpt;
+  virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters);
+
+  using AliRDHFCuts::IsSelected;
+  virtual Int_t IsSelected(TObject* obj,Int_t selectionLevel);
+  using AliRDHFCuts::IsSelectedPID;
+  virtual Int_t IsSelectedPID(AliAODRecoDecayHF* obj);
+  Int_t IsSelectedCombinedPID(AliAODRecoDecayHF* obj);
+  Double_t GetPionProbabilityTPCTOF(AliAODTrack *trk);
+
+  void SetPIDStrategy(EPIDStrategy pidStrategy){fPIDStrategy=pidStrategy;}
+  EPIDStrategy GetPIDStrategy() const {return fPIDStrategy;}
+  void SetCombinedPIDThreshold(Double_t a){fCombinedPIDThreshold=a;}
+  Double_t GetCombinedPIDThreshold(){return fCombinedPIDThreshold;}
+
+
+  Bool_t SingleTrkCuts(AliAODTrack *trk);
+  Bool_t SingleCascadeCuts(AliAODcascade *casc);
+  Bool_t SelectWithRoughCuts(AliAODcascade *casc, AliAODTrack *trk1, AliAODTrack *trk2);
+
+  void SetProdTrackPtMin(Double_t a){fProdTrackPtMin=a;}
+  void SetProdTrackEtaRange(Double_t a){fProdTrackEtaRange=a;}
+  void SetProdUseAODFilterBit(Bool_t a){fProdUseAODFilterBit=a;}
+  void SetProdMassTolLambda(Double_t a){fProdMassTolLambda=a;}
+  void SetProdMassTolXi(Double_t a){fProdMassTolXi=a;}
+  void SetProdRfidMinV0(Double_t a){fProdRfidMinV0=a;}
+  void SetProdRfidMaxV0(Double_t a){fProdRfidMaxV0=a;}
+  void SetProdRfidMinXi(Double_t a){fProdRfidMinXi=a;}
+  void SetProdRfidMaxXi(Double_t a){fProdRfidMaxXi=a;}
+  void SetProdRoughMassTol(Double_t a){fProdRoughMassTol=a;}
+  void SetProdRoughPtMin(Double_t a){fProdRoughPtMin=a;}
+  void SetProdLikeSignDcaMax(Double_t a){fProdLikeSignDcaMax=a;}
+
+  Double_t GetProdTrackPtMin(){return fProdTrackPtMin;}
+  Double_t GetProdTrackEtaRange(){return fProdTrackEtaRange;}
+  Bool_t   GetProdUseAODFilterBit(){return fProdUseAODFilterBit;}
+  Double_t GetProdMassTolLambda(){return fProdMassTolLambda;}
+  Double_t GetProdMassTolXi(){return fProdMassTolXi;}
+  Double_t GetProdRfidMinV0(){return fProdRfidMinV0;}
+  Double_t GetProdRfidMaxV0(){return fProdRfidMaxV0;}
+  Double_t GetProdRfidMinXi(){return fProdRfidMinXi;}
+  Double_t GetProdRfidMaxXi(){return fProdRfidMaxXi;}
+  Double_t GetProdRoughMassTol(){return fProdRoughMassTol;}
+  Double_t GetProdRoughPtMin(){return fProdRoughPtMin;}
+  Double_t GetProdLikeSignDcaMax(){return fProdLikeSignDcaMax;}
+
+  void  SetNCuts(Int_t ncuts){fnCuts=ncuts;}
+  Int_t GetNCutsArray(){return fnCuts;}
+  void  SetCutsArray(Int_t nCuts, Int_t nVars,Int_t nPtBins,Float_t ***cutsRD);
+  void  SetCutsArray(Int_t nTotBins,Float_t *cutsRD);
+  void  SetCutsFromArray(Int_t nCuts);
+  Int_t GetCutArrayID(Int_t ic,Int_t iv,Int_t ip);
+
+ protected:
+       
+ private:
+
+  EPIDStrategy fPIDStrategy;        //PID Strategy
+  Double_t fCombinedPIDThreshold;   //PID threshold used in IsSelectedCombinedPID
+
+  Double_t fProdTrackPtMin;         //Minimum Bachelor pT 
+  Double_t fProdTrackEtaRange;      //Bachelor Eta range
+  Bool_t   fProdUseAODFilterBit;    //Use AODfilterBit or not
+  Double_t fProdMassTolLambda;      //Tolerance of Lambda mass from PDG value
+  Double_t fProdMassTolXi;          //Tolerance of Xi mass from PDG value
+  Double_t fProdRfidMinV0;          //Minimum Decay vertex of V0
+  Double_t fProdRfidMaxV0;          //Max Decay vertex of V0
+  Double_t fProdRfidMinXi;          //Minimum Decay vertex of Xi
+  Double_t fProdRfidMaxXi;          //Max Decay vertex of Xi
+  Double_t fProdLikeSignDcaMax;     //Maximum DCA of pions
+  Double_t fProdRoughMassTol;       //Tolerance of Xic mass from PDG value 
+  Double_t fProdRoughPtMin;         //Minimum pT of Xic
+
+  Int_t fnCuts;                    //Number of Cuts
+  Int_t fnTotalCutBins;            //fnCuts * fnvars * fnPtBins
+  Float_t *fCutsArray;             //[fnTotalCutBins]
+
+  ClassDef(AliRDHFCutsXicPlustoXiPiPifromAODtracks,1); 
+};
+
+#endif
index cc721e4..ca27f2b 100644 (file)
@@ -42,6 +42,7 @@ set(SRCS
   AliAODRecoDecayHF3Prong.cxx 
   AliAODRecoDecayHF4Prong.cxx 
   AliAODRecoCascadeHF.cxx 
+  AliAODRecoCascadeHF3Prong.cxx
   AliAODPidHF.cxx 
   AliRDHFCuts.cxx 
   AliVertexingHFUtils.cxx 
@@ -54,6 +55,8 @@ set(SRCS
   AliRDHFCutsLctoV0.cxx 
   AliRDHFCutsD0toKpipipi.cxx 
   AliRDHFCutsDStartoKpipi.cxx 
+  AliRDHFCutsLctopK0sfromAODtracks.cxx
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks.cxx
   AliAnalysisVertexingHF.cxx 
   AliAnalysisTaskSEVertexingHF.cxx 
   AliAnalysisTaskMEVertexingHF.cxx 
@@ -67,6 +70,8 @@ set(SRCS
   AliAnalysisTaskSELc2V0bachelor.cxx 
   AliAnalysisTaskSEDvsMultiplicity.cxx
   AliAnalysisTaskCheckHFMCProd.cxx
+  AliAnalysisTaskSELc2pK0sfromAODtracks.cxx
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks.cxx
   AliCFVertexingHF.cxx 
   AliCFVertexingHF2Prong.cxx 
   AliCFVertexingHF3Prong.cxx 
@@ -142,4 +147,4 @@ install(DIRECTORY
             macros
         DESTINATION PWGHF/vertexingHF/)
 
-install(DIRECTORY charmFlow DESTINATION PWGHF/vertexingHF)
\ No newline at end of file
+install(DIRECTORY charmFlow DESTINATION PWGHF/vertexingHF)
index 0a968b8..fd9a1ba 100644 (file)
@@ -10,6 +10,7 @@
 #pragma link C++ class AliAODRecoDecayHF3Prong+;
 #pragma link C++ class AliAODRecoDecayHF4Prong+;
 #pragma link C++ class AliAODRecoCascadeHF+;
+#pragma link C++ class AliAODRecoCascadeHF3Prong+;
 #pragma link C++ class AliAODHFUtil+;
 #pragma link C++ class AliAODPidHF+;
 #pragma link C++ class AliRDHFCuts+;
@@ -23,6 +24,8 @@
 #pragma link C++ class AliRDHFCutsLctoV0+;
 #pragma link C++ class AliRDHFCutsD0toKpipipi+;
 #pragma link C++ class AliRDHFCutsDStartoKpipi+;
+#pragma link C++ class AliRDHFCutsLctopK0sfromAODtracks++;
+#pragma link C++ class AliRDHFCutsXicPlustoXiPiPifromAODtracks++;
 #pragma link C++ class AliAnalysisVertexingHF+;
 #pragma link C++ class AliAnalysisTaskSEVertexingHF+;
 #pragma link C++ class AliAnalysisTaskMEVertexingHF+;
@@ -36,6 +39,8 @@
 #pragma link C++ class AliAnalysisTaskSELc2V0bachelor+;
 #pragma link C++ class AliAnalysisTaskSEDvsMultiplicity+;
 #pragma link C++ class AliAnalysisTaskCheckHFMCProd+;
+#pragma link C++ class AliAnalysisTaskSELc2pK0sfromAODtracks++;
+#pragma link C++ class AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks++;
 #pragma link C++ class AliCFVertexingHF+;
 #pragma link C++ class AliCFVertexingHF2Prong+;
 #pragma link C++ class AliCFVertexingHF3Prong+;
diff --git a/PWGHF/vertexingHF/macros/AddTaskLc2pK0sfromAODtracks.C b/PWGHF/vertexingHF/macros/AddTaskLc2pK0sfromAODtracks.C
new file mode 100644 (file)
index 0000000..2ffbb90
--- /dev/null
@@ -0,0 +1,85 @@
+AliAnalysisTaskSELc2pK0sfromAODtracks *AddTaskLc2pK0sfromAODtracks(TString finname="",
+                                                                  Bool_t theMCon=kFALSE,
+                                                                  Bool_t writeVariableTree=kFALSE,
+                                                                  Int_t nTour=0
+                                                                  )
+
+{
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskLc2V0YW", "No analysis manager to connect to.");
+    return NULL;
+  }  
+
+  Bool_t stdcuts=kFALSE;
+  TFile* filecuts;
+  if( finname.EqualTo("") ) {
+    stdcuts=kTRUE; 
+  } else {
+    filecuts=TFile::Open(finname.Data());
+    if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
+      AliFatal("Input file not found : check your cut object");
+    }
+  }
+
+  AliRDHFCutsLctopK0sfromAODtracks* RDHFCutsLc2pK0sprod = new AliRDHFCutsLctopK0sfromAODtracks();
+  if (stdcuts) RDHFCutsLc2pK0sprod->SetStandardCutsPP2010();
+  else RDHFCutsLc2pK0sprod = (AliRDHFCutsLctopK0sfromAODtracks*)filecuts->Get("LcProductionCuts");
+  RDHFCutsLc2pK0sprod->SetName("LcProductionCuts");
+  RDHFCutsLc2pK0sprod->SetMinPtCandidate(-1.);
+  RDHFCutsLc2pK0sprod->SetMaxPtCandidate(10000.);
+  if (!RDHFCutsLc2pK0sprod) {
+    cout << "Specific AliRDHFCutsLc2pK0sprod not found\n";
+    return;
+  }
+  
+  AliRDHFCutsLctopK0sfromAODtracks* RDHFCutsLc2pK0sanal = new AliRDHFCutsLctopK0sfromAODtracks();
+  if (stdcuts) RDHFCutsLc2pK0sanal->SetStandardCutsPP2010();
+  else RDHFCutsLc2pK0sanal = (AliRDHFCutsLctopK0sfromAODtracks*)filecuts->Get("LcAnalysisCuts");
+  RDHFCutsLc2pK0sanal->SetName("LcAnalysisCuts");
+  RDHFCutsLc2pK0sanal->SetMinPtCandidate(-1.);
+  RDHFCutsLc2pK0sanal->SetMaxPtCandidate(10000.);
+  if (!RDHFCutsLc2pK0sanal) {
+    cout << "Specific AliRDHFCutsLc2pK0sanal not found\n";
+    return;
+  }
+
+
+  //CREATE THE TASK
+
+  printf("CREATE TASK\n");
+  AliAnalysisTaskSELc2pK0sfromAODtracks *task = new AliAnalysisTaskSELc2pK0sfromAODtracks("AliAnalysisTaskSELc2pK0sfromAODtracks",RDHFCutsLc2pK0sprod,RDHFCutsLc2pK0sanal,writeVariableTree);
+  task->SetIspp(kFALSE);
+  task->SetIspA(kFALSE);
+  task->SetIsAA(kTRUE);
+  task->SetMC(theMCon);
+  task->SetDebugLevel(1);
+
+
+  mgr->AddTask(task);
+
+  // Create and connect containers for input/output  
+  TString outputfile = AliAnalysisManager::GetCommonFileName();
+  outputfile += ":PWG3_D2H_Lc2pK0s_";
+  outputfile += nTour;
+
+  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
+
+  // ----- output data -----
+  AliAnalysisDataContainer *coutput1   = mgr->CreateContainer(Form("Lchist%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // general histos
+  mgr->ConnectOutput(task,1,coutput1);
+  AliAnalysisDataContainer *coutputLc2 = mgr->CreateContainer(Form("Lc2pK0sCuts%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // cuts
+  mgr->ConnectOutput(task,2,coutputLc2);
+
+  if (writeVariableTree) {
+    AliAnalysisDataContainer *coutputLc3 = mgr->CreateContainer(Form("Lc2pK0svariables%1d",nTour),TTree::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // variables tree
+    mgr->ConnectOutput(task,3,coutputLc3);
+  } else {
+    AliAnalysisDataContainer *coutputLc3 = mgr->CreateContainer(Form("LcAll%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // variables tree
+    mgr->ConnectOutput(task,3,coutputLc3);
+  }
+
+  return task;
+
+}
diff --git a/PWGHF/vertexingHF/macros/AddTaskXicPlus2XiPiPifromAODtracks.C b/PWGHF/vertexingHF/macros/AddTaskXicPlus2XiPiPifromAODtracks.C
new file mode 100644 (file)
index 0000000..5bea456
--- /dev/null
@@ -0,0 +1,86 @@
+AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks *AddTaskXicPlus2XiPiPifromAODtracks(TString finname="",
+                                                                                Bool_t theMCon=kFALSE,
+                                                                                Bool_t writeVariableTree=kFALSE,
+                                                                                Int_t nTour=0
+                                                                                )
+
+{
+  
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskLc2V0YW", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  Bool_t stdcuts=kFALSE;
+  TFile* filecuts;
+  if( finname.EqualTo("") ) {
+    stdcuts=kTRUE; 
+  } else {
+    filecuts=TFile::Open(finname.Data());
+    if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
+      AliFatal("Input file not found : check your cut object");
+    }
+  }
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks* RDHFCutsXic2PiPiprod = new AliRDHFCutsXicPlustoXiPiPifromAODtracks();
+  if (stdcuts) RDHFCutsXic2PiPiprod->SetStandardCutsPP2010();
+  else RDHFCutsXic2PiPiprod = (AliRDHFCutsXicPlustoXiPiPifromAODtracks*)filecuts->Get("XicPlusProductionCuts");
+  RDHFCutsXic2PiPiprod->SetName("XicPlusProductionCuts");
+  RDHFCutsXic2PiPiprod->SetMinPtCandidate(2.);
+  RDHFCutsXic2PiPiprod->SetMaxPtCandidate(10000.);
+
+  if (!RDHFCutsXic2PiPiprod) {
+    cout << "Specific AliRDHFCutsXic2PiPiprod not found\n";
+    return;
+  }
+  
+  AliRDHFCutsXicPlustoXiPiPifromAODtracks* RDHFCutsXic2PiPianal = new AliRDHFCutsXicPlustoXiPiPifromAODtracks();
+  if (stdcuts) RDHFCutsXic2PiPianal->SetStandardCutsPP2010();
+  else RDHFCutsXic2PiPianal = (AliRDHFCutsXicPlustoXiPiPifromAODtracks*)filecuts->Get("XicPlusAnalysisCuts");
+  RDHFCutsXic2PiPianal->SetName("XicPlusAnalysisCuts");
+  RDHFCutsXic2PiPianal->SetMinPtCandidate(2.);
+  RDHFCutsXic2PiPianal->SetMaxPtCandidate(10000.);
+
+    
+  // mm let's see if everything is ok
+  if (!RDHFCutsXic2PiPianal) {
+    cout << "Specific AliRDHFCutsXic2PiPianal not found\n";
+    return;
+  }
+
+
+  //CREATE THE TASK
+  
+  printf("CREATE TASK\n");
+  AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks *task = new AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks("AliAnalysisTaskSEXicPlus2XiPiPifromAODtracks",RDHFCutsXic2PiPiprod,RDHFCutsXic2PiPianal,writeVariableTree);
+  task->SetIspp(kFALSE);
+  task->SetIspA(kFALSE);
+  task->SetIsAA(kTRUE);
+  task->SetMC(theMCon);
+  task->SetDebugLevel(1);
+  
+  mgr->AddTask(task);
+  
+  // Create and connect containers for input/output  
+  TString outputfile = AliAnalysisManager::GetCommonFileName();
+  outputfile += ":PWG3_D2H_XicPlus2XiPiPi_";
+  outputfile += nTour;
+  
+  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
+  
+  // ----- output data -----
+  AliAnalysisDataContainer *coutput1   = mgr->CreateContainer(Form("chist%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // general histos
+  mgr->ConnectOutput(task,1,coutput1);
+  AliAnalysisDataContainer *coutputXic2 = mgr->CreateContainer(Form("XicPlus2XiPiPiCuts%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // cuts
+  mgr->ConnectOutput(task,2,coutputXic2);
+  if (writeVariableTree) {
+    AliAnalysisDataContainer *coutputXic3 = mgr->CreateContainer(Form("XicPlusvariables%1d",nTour),TTree::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); 
+    mgr->ConnectOutput(task,3,coutputXic3);
+  }else{
+    AliAnalysisDataContainer *coutputXic3 = mgr->CreateContainer(Form("XicPlusAll%1d",nTour),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data()); // general histos
+    mgr->ConnectOutput(task,3,coutputXic3);
+  }
+  
+  return task;
+
+}