]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - CORRFW/AliCFTrackIsPrimaryCuts.cxx
Infinite loop is fixed
[u/mrichter/AliRoot.git] / CORRFW / AliCFTrackIsPrimaryCuts.cxx
index f0e8970d069d99334d576281f8a92ecf6e5f0924..b60599ad9424df6ed123c8b30c39475ea3fb9a23 100644 (file)
 // ESD and AOD data.
 // It mainly consists of a IsSelected function that returns a boolean.
 // This function checks whether the considered track passes a set of cuts:
-// - distance to main vertex in units of sigma (resolution)
+// - min. and max. distance to main vertex in transverse plane (xy)
+// - min. and max. longitudinal distance to main vertex (z)
+// - min. and max. distance to main vertex as ellpise in xy - z plane
+// - all above cuts on absolute values or in units of sigma (resolution)
+// - min. and max. distance to main vertex in units of sigma (resolution)
+// - max. transverse (xy) and longitudinal (z) impact parameter resolution
 // - require that the dca calculation doesn't fail
 // - accept or not accept daughter tracks of kink decays
 //
+// By default, the distance to 'vertex calculated from tracks' is used.
+// Optionally the SPD (tracklet based) or TPC (TPC only tracks based) vertex
+// can be used.
+// Note: the distance to the TPC-vertex is already stored in the ESD,
+// the distance to the SPD-vertex has to be re-calculated by propagating each
+// track while executing this cut.
+//
 // The cut values for these cuts are set with the corresponding set functions.
 // All cut classes provided by the correction framework are supposed to be
 // added in the Analysis Framwork's class AliAnalysisFilter and applied by
@@ -42,6 +54,7 @@
 #include <TBits.h>
 
 #include <AliESDtrack.h>
+#include <AliESDEvent.h>
 #include <AliLog.h>
 #include "AliCFTrackIsPrimaryCuts.h"
 
@@ -50,8 +63,19 @@ ClassImp(AliCFTrackIsPrimaryCuts)
 //__________________________________________________________________________________
 AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts() :
   AliCFCutBase(),
-  fNSigmaToVertex(0),
+  fESD(0x0),
+  fUseSPDvertex(0),
+  fUseTPCvertex(0),
+  fMinDCAToVertexXY(0),
+  fMinDCAToVertexZ(0),
+  fMaxDCAToVertexXY(0),
+  fMaxDCAToVertexZ(0),
+  fDCAToVertex2D(0),
+  fAbsDCAToVertex(0),
+  fNSigmaToVertexMin(0),
   fNSigmaToVertexMax(0),
+  fSigmaDCAxy(0),
+  fSigmaDCAz(0),
   fRequireSigmaToVertex(0),
   fAODType(AliAODTrack::kUndef),
   fAcceptKinkDaughters(0),
@@ -65,13 +89,17 @@ AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts() :
   fhNBinsDcaZ(0),
   fhNBinsDcaXYnorm(0),
   fhNBinsDcaZnorm(0),
+  fhNBinsSigmaDcaXY(0),
+  fhNBinsSigmaDcaZ(0),
   fhBinLimNSigma(0x0),
   fhBinLimRequireSigma(0x0),
   fhBinLimAcceptKink(0x0),
   fhBinLimDcaXY(0x0),
   fhBinLimDcaZ(0x0),
   fhBinLimDcaXYnorm(0x0),
-  fhBinLimDcaZnorm(0x0)
+  fhBinLimDcaZnorm(0x0),
+  fhBinLimSigmaDcaXY(0x0),
+  fhBinLimSigmaDcaZ(0x0)
 {
   //
   // Default constructor
@@ -81,8 +109,19 @@ AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts() :
 //__________________________________________________________________________________
 AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts(Char_t* name, Char_t* title) :
   AliCFCutBase(name,title),
-  fNSigmaToVertex(0),
+  fESD(0x0),
+  fUseSPDvertex(0),
+  fUseTPCvertex(0),
+  fMinDCAToVertexXY(0),
+  fMinDCAToVertexZ(0),
+  fMaxDCAToVertexXY(0),
+  fMaxDCAToVertexZ(0),
+  fDCAToVertex2D(0),
+  fAbsDCAToVertex(0),
+  fNSigmaToVertexMin(0),
   fNSigmaToVertexMax(0),
+  fSigmaDCAxy(0),
+  fSigmaDCAz(0),
   fRequireSigmaToVertex(0),
   fAODType(AliAODTrack::kUndef),
   fAcceptKinkDaughters(0),
@@ -96,13 +135,17 @@ AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts(Char_t* name, Char_t* title) :
   fhNBinsDcaZ(0),
   fhNBinsDcaXYnorm(0),
   fhNBinsDcaZnorm(0),
+  fhNBinsSigmaDcaXY(0),
+  fhNBinsSigmaDcaZ(0),
   fhBinLimNSigma(0x0),
   fhBinLimRequireSigma(0x0),
   fhBinLimAcceptKink(0x0),
   fhBinLimDcaXY(0x0),
   fhBinLimDcaZ(0x0),
   fhBinLimDcaXYnorm(0x0),
-  fhBinLimDcaZnorm(0x0)
+  fhBinLimDcaZnorm(0x0),
+  fhBinLimSigmaDcaXY(0x0),
+  fhBinLimSigmaDcaZ(0x0)
 {
   //
   // Constructor
@@ -112,8 +155,19 @@ AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts(Char_t* name, Char_t* title) :
 //__________________________________________________________________________________
 AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts(const AliCFTrackIsPrimaryCuts& c) :
   AliCFCutBase(c),
-  fNSigmaToVertex(c.fNSigmaToVertex),
+  fESD(c.fESD),
+  fUseSPDvertex(c.fUseSPDvertex),
+  fUseTPCvertex(c.fUseTPCvertex),
+  fMinDCAToVertexXY(c.fMinDCAToVertexXY),
+  fMinDCAToVertexZ(c.fMinDCAToVertexZ),
+  fMaxDCAToVertexXY(c.fMaxDCAToVertexXY),
+  fMaxDCAToVertexZ(c.fMaxDCAToVertexZ),
+  fDCAToVertex2D(c.fDCAToVertex2D),
+  fAbsDCAToVertex(c.fAbsDCAToVertex),
+  fNSigmaToVertexMin(c.fNSigmaToVertexMin),
   fNSigmaToVertexMax(c.fNSigmaToVertexMax),
+  fSigmaDCAxy(c.fSigmaDCAxy),
+  fSigmaDCAz(c.fSigmaDCAz),
   fRequireSigmaToVertex(c.fRequireSigmaToVertex),
   fAODType(c.fAODType),
   fAcceptKinkDaughters(c.fAcceptKinkDaughters),
@@ -127,13 +181,17 @@ AliCFTrackIsPrimaryCuts::AliCFTrackIsPrimaryCuts(const AliCFTrackIsPrimaryCuts&
   fhNBinsDcaZ(c.fhNBinsDcaZ),
   fhNBinsDcaXYnorm(c.fhNBinsDcaXYnorm),
   fhNBinsDcaZnorm(c.fhNBinsDcaZnorm),
+  fhNBinsSigmaDcaXY(c.fhNBinsSigmaDcaXY),
+  fhNBinsSigmaDcaZ(c.fhNBinsSigmaDcaZ),
   fhBinLimNSigma(c.fhBinLimNSigma),
   fhBinLimRequireSigma(c.fhBinLimRequireSigma),
   fhBinLimAcceptKink(c.fhBinLimAcceptKink),
   fhBinLimDcaXY(c.fhBinLimDcaXY),
   fhBinLimDcaZ(c.fhBinLimDcaZ),
   fhBinLimDcaXYnorm(c.fhBinLimDcaXYnorm),
-  fhBinLimDcaZnorm(c.fhBinLimDcaZnorm)
+  fhBinLimDcaZnorm(c.fhBinLimDcaZnorm),
+  fhBinLimSigmaDcaXY(c.fhBinLimSigmaDcaXY),
+  fhBinLimSigmaDcaZ(c.fhBinLimSigmaDcaZ)
 {
   //
   // copy constructor
@@ -148,8 +206,19 @@ AliCFTrackIsPrimaryCuts& AliCFTrackIsPrimaryCuts::operator=(const AliCFTrackIsPr
   //
   if (this != &c) {
     AliCFCutBase::operator=(c) ;
-    fNSigmaToVertex = c.fNSigmaToVertex ;
+    fESD = c.fESD;
+    fUseSPDvertex = c.fUseSPDvertex;
+    fUseTPCvertex = c.fUseTPCvertex;
+    fMinDCAToVertexXY = c.fMinDCAToVertexXY;
+    fMinDCAToVertexZ = c.fMinDCAToVertexZ;
+    fMaxDCAToVertexXY = c.fMaxDCAToVertexXY;
+    fMaxDCAToVertexZ = c.fMaxDCAToVertexZ;
+    fDCAToVertex2D = c.fDCAToVertex2D;
+    fAbsDCAToVertex = c.fAbsDCAToVertex;
+    fNSigmaToVertexMin = c.fNSigmaToVertexMin ;
     fNSigmaToVertexMax = c.fNSigmaToVertexMax ;
+    fSigmaDCAxy = c.fSigmaDCAxy ;
+    fSigmaDCAz = c.fSigmaDCAz ;
     fRequireSigmaToVertex = c.fRequireSigmaToVertex ;
     fAODType = c.fAODType ;
     fAcceptKinkDaughters = c.fAcceptKinkDaughters ;
@@ -163,6 +232,8 @@ AliCFTrackIsPrimaryCuts& AliCFTrackIsPrimaryCuts::operator=(const AliCFTrackIsPr
     fhNBinsDcaZ = c.fhNBinsDcaZ;
     fhNBinsDcaXYnorm = c.fhNBinsDcaXYnorm;
     fhNBinsDcaZnorm = c.fhNBinsDcaZnorm;
+    fhNBinsSigmaDcaXY = c.fhNBinsSigmaDcaXY;
+    fhNBinsSigmaDcaZ = c.fhNBinsSigmaDcaZ;
     fhBinLimNSigma = c.fhBinLimNSigma;
     fhBinLimRequireSigma = c.fhBinLimRequireSigma;
     fhBinLimAcceptKink = c.fhBinLimAcceptKink;
@@ -170,10 +241,12 @@ AliCFTrackIsPrimaryCuts& AliCFTrackIsPrimaryCuts::operator=(const AliCFTrackIsPr
     fhBinLimDcaZ = c.fhBinLimDcaZ;
     fhBinLimDcaXYnorm = c.fhBinLimDcaXYnorm;
     fhBinLimDcaZnorm = c.fhBinLimDcaZnorm;
+    fhBinLimSigmaDcaXY = c.fhBinLimSigmaDcaXY;
+    fhBinLimSigmaDcaZ = c.fhBinLimSigmaDcaZ;
 
+    for (Int_t j=0; j<6; j++) fDCA[j] = c.fDCA[j];
     for (Int_t j=0; j<c.kNStepQA; j++){
       if(c.fhDcaXYvsDcaZ[j]) fhDcaXYvsDcaZ[j] = (TH2F*)c.fhDcaXYvsDcaZ[j]->Clone();
-      if(c.fhDcaXYvsDcaZnorm[j]) fhDcaXYvsDcaZnorm[j] = (TH2F*)c.fhDcaXYvsDcaZnorm[j]->Clone();
       for (Int_t i=0; i<c.kNHist; i++){
        if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
       }
@@ -193,10 +266,10 @@ AliCFTrackIsPrimaryCuts::~AliCFTrackIsPrimaryCuts()
 
   for (Int_t j=0; j<kNStepQA; j++){
     if(fhDcaXYvsDcaZ[j])       delete fhDcaXYvsDcaZ[j];
-    if(fhDcaXYvsDcaZnorm[j])   delete fhDcaXYvsDcaZnorm[j];
     for (Int_t i=0; i<kNHist; i++)
       if(fhQA[i][j])           delete fhQA[i][j];
   }
+  if(fESD)                     delete fESD;
   if(fBitmap)                  delete fBitmap;
   if(fhBinLimNSigma)           delete fhBinLimNSigma;
   if(fhBinLimRequireSigma)     delete fhBinLimRequireSigma;
@@ -205,6 +278,8 @@ AliCFTrackIsPrimaryCuts::~AliCFTrackIsPrimaryCuts()
   if(fhBinLimDcaZ)             delete fhBinLimDcaZ;
   if(fhBinLimDcaXYnorm)        delete fhBinLimDcaXYnorm;
   if(fhBinLimDcaZnorm)                 delete fhBinLimDcaZnorm;
+  if(fhBinLimSigmaDcaXY)       delete fhBinLimSigmaDcaXY;
+  if(fhBinLimSigmaDcaZ)        delete fhBinLimSigmaDcaZ;
 }
 //__________________________________________________________________________________
 void AliCFTrackIsPrimaryCuts::Initialise()
@@ -212,20 +287,39 @@ void AliCFTrackIsPrimaryCuts::Initialise()
   //
   // sets everything to zero
   //
-  fNSigmaToVertex = 0;
+  fUseSPDvertex = 0;
+  fUseTPCvertex = 0;
+  fMinDCAToVertexXY = 0;
+  fMinDCAToVertexZ = 0;
+  fMaxDCAToVertexXY = 0;
+  fMaxDCAToVertexZ = 0;
+  fDCAToVertex2D = 0;
+  fAbsDCAToVertex = 0;
+  fNSigmaToVertexMin = 0;
   fNSigmaToVertexMax = 0;
+  fSigmaDCAxy = 0;
+  fSigmaDCAz = 0;
   fRequireSigmaToVertex = 0;
   fAcceptKinkDaughters = 0;
   fAODType = AliAODTrack::kUndef;
 
+  SetMinDCAToVertexXY();
+  SetMinDCAToVertexZ();
+  SetMaxDCAToVertexXY();
+  SetMaxDCAToVertexZ();
+  SetDCAToVertex2D();
+  SetAbsDCAToVertex();
+  SetMinNSigmaToVertex();
   SetMaxNSigmaToVertex();
+  SetMaxSigmaDCAxy();
+  SetMaxSigmaDCAz();
   SetRequireSigmaToVertex();
   SetAcceptKinkDaughters();
   SetAODType();
 
+  for (Int_t j=0; j<6; j++) fDCA[j] = 0.;
   for (Int_t j=0; j<kNStepQA; j++)  {
     fhDcaXYvsDcaZ[j] = 0x0;
-    fhDcaXYvsDcaZnorm[j] = 0x0;
     for (Int_t i=0; i<kNHist; i++)
       fhQA[i][j] = 0x0;
   }
@@ -234,13 +328,15 @@ void AliCFTrackIsPrimaryCuts::Initialise()
   fBitmap=new TBits(0);
 
   //set default bining for QA histograms
-  SetHistogramBins(kCutNSigmaToVertex,500,0.,50.);
+  SetHistogramBins(kCutNSigmaToVertex,100,0.,10.);
   SetHistogramBins(kCutRequireSigmaToVertex,5,-0.75,1.75);
   SetHistogramBins(kCutAcceptKinkDaughters,5,-0.75,1.75);
   SetHistogramBins(kDcaXY,500,-10.,10.);
   SetHistogramBins(kDcaZ,500,-10.,10.);
   SetHistogramBins(kDcaXYnorm,500,-10.,10.);
   SetHistogramBins(kDcaZnorm,500,-10.,10.);
+  SetHistogramBins(kSigmaDcaXY,500,-0.1,0.9);
+  SetHistogramBins(kSigmaDcaZ,500,-0.1,0.9);
 }
 //__________________________________________________________________________________
 void AliCFTrackIsPrimaryCuts::Copy(TObject &c) const
@@ -255,59 +351,89 @@ void AliCFTrackIsPrimaryCuts::Copy(TObject &c) const
   if (fhCutStatistics)  target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
   if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
 
+  for (Int_t j=0; j<6; j++) target.fDCA[j] = fDCA[j];
   for (Int_t j=0; j<kNStepQA; j++){
     if(fhDcaXYvsDcaZ[j]) target.fhDcaXYvsDcaZ[j] = (TH2F*)fhDcaXYvsDcaZ[j]->Clone();
-    if(fhDcaXYvsDcaZnorm[j]) target.fhDcaXYvsDcaZnorm[j] = (TH2F*)fhDcaXYvsDcaZnorm[j]->Clone();
     for (Int_t i=0; i<kNHist; i++)
       if(fhQA[i][j]) target.fhQA[i][j] = (TH1F*)fhQA[i][j]->Clone();
   }
   TNamed::Copy(c);
 }
-//____________________________________________________________________
-void AliCFTrackIsPrimaryCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
-{
-  //
-  // Calculates the number of sigma to the vertex.
-  // Currently applicable for ESD tracks only
-  //
-  Float_t b[2];
-  Float_t bRes[2];
-  Float_t bCov[3];
-  esdTrack->GetImpactParameters(b,bCov);
-  if (bCov[0]<=0 || bCov[2]<=0) {
-    AliDebug(1, "Estimated b resolution lower or equal zero!");
-    bCov[0]=0; bCov[2]=0;
-  }
-  bRes[0] = TMath::Sqrt(bCov[0]);
-  bRes[1] = TMath::Sqrt(bCov[2]);
-
-  // -----------------------------------
-  // How to get to a n-sigma cut?
-  //
-  // The accumulated statistics from 0 to d is
+//__________________________________________________________________________________
+void AliCFTrackIsPrimaryCuts::SetEvtInfo(TObject* esd) {
   //
-  // ->  Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
-  // ->  1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
+  // Sets pointer to esd event information (AliESDEvent)
   //
-  // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
-  // Can this be expressed in a different way?
-
-  if (bRes[0] == 0 || bRes[1] ==0) {
-    fNSigmaToVertex = -1;
+  if (!esd) {
+    AliError("Pointer to AliESDEvent !");
     return;
   }
+  TString className(esd->ClassName());
+  if (className.CompareTo("AliESDEvent") != 0) {
+    AliError("argument must point to an AliESDEvent !");
+    return ;
+  }
+  fESD = (AliESDEvent*) esd;
+}
+//__________________________________________________________________________________
+void AliCFTrackIsPrimaryCuts::UseSPDvertex(Bool_t b) {
+  fUseSPDvertex = b;
+  if(fUseTPCvertex && fUseSPDvertex) {
+       fUseSPDvertex = kFALSE;
+       AliError("SPD and TPC vertex chosen. TPC vertex is preferred.");
+  }
+}
+//__________________________________________________________________________________
+void AliCFTrackIsPrimaryCuts::UseTPCvertex(Bool_t b) {
+  fUseTPCvertex = b;
+  if(fUseTPCvertex) fUseSPDvertex = kFALSE;
+}
+//__________________________________________________________________________________
+void AliCFTrackIsPrimaryCuts::GetDCA(AliESDtrack* esdTrack)
+{
+  if (!esdTrack) return;
+
+  Float_t b[2] = {0.,0.};
+  Float_t bCov[3] = {0.,0.,0.};
+  if(!fUseSPDvertex && !fUseTPCvertex) esdTrack->GetImpactParameters(b,bCov);
+  if( fUseTPCvertex)                   esdTrack->GetImpactParametersTPC(b,bCov);
+
+  if( fUseSPDvertex) {
+       if (!fESD) return;
+       const AliESDVertex *vtx = fESD->GetVertex();
+       const Double_t Bz = fESD->GetMagneticField();
+       AliExternalTrackParam *cParam = 0;
+       Bool_t success = esdTrack->RelateToVertex(vtx, Bz, kVeryBig, cParam);
+       if (success) esdTrack->GetImpactParameters(b,bCov);
+  }
 
-  Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
-
-  // stupid rounding problem screws up everything:
-  // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
-  if (TMath::Exp(-d * d / 2) < 1e-10) {
-    fNSigmaToVertex = 1000;
-    return;
+  if (bCov[0]<=0 || bCov[2]<=0) {
+      bCov[0]=0; bCov[2]=0;
+  }
+  fDCA[0] = b[0]; // impact parameter xy
+  fDCA[1] = b[1]; // impact parameter z
+  fDCA[2] = TMath::Sqrt(bCov[0]); // resolution xy
+  fDCA[3] = TMath::Sqrt(bCov[2]); // resolution z
+
+  if (!fAbsDCAToVertex) {
+       if (fDCA[2] > 0) fDCA[0] = fDCA[0]/fDCA[2]; // normalised impact parameter xy
+       if (fDCA[3] > 0) fDCA[1] = fDCA[1]/fDCA[3]; // normalised impact parameter z
   }
 
-  d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
-  fNSigmaToVertex = d;
+  // get n_sigma
+  if(!fUseSPDvertex && !fUseTPCvertex)
+       fDCA[5] = AliESDtrackCuts::GetSigmaToVertex(esdTrack);
+
+  if(fUseTPCvertex) {
+       fDCA[5] = -1;
+       if (fDCA[2]==0 || fDCA[3]==0)
+         return;
+       fDCA[5] = 1000.;
+       Float_t d = TMath::Sqrt(TMath::Power(b[0]/fDCA[2],2) + TMath::Power(b[1]/fDCA[3],2));
+       if (TMath::Exp(-d * d / 2) < 1e-15)
+         return;
+       fDCA[5] = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
+  }
   return;
 }
 //__________________________________________________________________________________
@@ -337,13 +463,62 @@ void AliCFTrackIsPrimaryCuts::SelectionBitMap(TObject* obj)
   if (isAODTrack) aodTrack = dynamic_cast<AliAODTrack*>(obj);
 
   // get the track to vertex parameter for ESD track
-  if (isESDTrack) GetSigmaToVertex(esdTrack);
+  if (isESDTrack) GetDCA(esdTrack);
+
+  Float_t bxy = 0, bz = 0;
+  if (isESDTrack) {
+       bxy = TMath::Abs(fDCA[0]);
+       bz  = TMath::Abs(fDCA[1]);
+ }
+  Float_t b2Dmin = 0, b2Dmax = 0;
+  if (isESDTrack) {
+    if (fMinDCAToVertexXY>0 && fMinDCAToVertexZ>0)
+       b2Dmin = fDCA[0]*fDCA[0]/fMinDCAToVertexXY/fMinDCAToVertexXY + fDCA[1]*fDCA[1]/fMinDCAToVertexZ/fMinDCAToVertexZ;
+    if (fMaxDCAToVertexXY>0 && fMaxDCAToVertexZ>0) 
+       b2Dmax = fDCA[0]*fDCA[0]/fMaxDCAToVertexXY/fMaxDCAToVertexXY + fDCA[1]*fDCA[1]/fMaxDCAToVertexZ/fMaxDCAToVertexZ;
+  }
 
   // fill the bitmap
   Int_t iCutBit = 0;
 
   if (isESDTrack) {
-    if (fNSigmaToVertex <= fNSigmaToVertexMax) {
+    if (fDCAToVertex2D || (!fDCAToVertex2D && bxy >= fMinDCAToVertexXY && bxy <= fMaxDCAToVertexXY)) {
+      fBitmap->SetBitNumber(iCutBit,kTRUE);
+    }
+  }
+  else fBitmap->SetBitNumber(iCutBit,kTRUE);
+
+  iCutBit++;
+
+  if (isESDTrack) {
+    if (fDCAToVertex2D || (!fDCAToVertex2D && bz  >= fMinDCAToVertexZ && bz  <= fMaxDCAToVertexZ)) {
+      fBitmap->SetBitNumber(iCutBit,kTRUE);
+    }
+  }
+  else fBitmap->SetBitNumber(iCutBit,kTRUE);
+
+  iCutBit++;
+
+  if (isESDTrack) {
+    if (!fDCAToVertex2D || (fDCAToVertex2D && b2Dmin > 1  && b2Dmax < 1)) {
+      fBitmap->SetBitNumber(iCutBit,kTRUE);
+    }
+  }
+  else fBitmap->SetBitNumber(iCutBit,kTRUE);
+
+  iCutBit++;
+
+  if (isESDTrack) {
+    if (fDCA[5] >= fNSigmaToVertexMin && fDCA[5] <= fNSigmaToVertexMax) {
+      fBitmap->SetBitNumber(iCutBit,kTRUE);
+    }
+  }
+  else fBitmap->SetBitNumber(iCutBit,kTRUE);
+
+  iCutBit++;
+
+  if (isESDTrack) {
+    if (fDCA[2] < fSigmaDCAxy) {
       fBitmap->SetBitNumber(iCutBit,kTRUE);
     }
   }
@@ -352,7 +527,16 @@ void AliCFTrackIsPrimaryCuts::SelectionBitMap(TObject* obj)
   iCutBit++;
 
   if (isESDTrack) {
-    if (!fRequireSigmaToVertex || (fNSigmaToVertex>=0 && fRequireSigmaToVertex)) {
+    if (fDCA[3] < fSigmaDCAz) {
+      fBitmap->SetBitNumber(iCutBit,kTRUE);
+    }
+  }
+  else fBitmap->SetBitNumber(iCutBit,kTRUE);
+
+  iCutBit++;
+
+  if (isESDTrack) {
+    if (!fRequireSigmaToVertex || (fDCA[5]>=0 && fRequireSigmaToVertex)) {
       fBitmap->SetBitNumber(iCutBit,kTRUE);
     }
   }
@@ -448,6 +632,18 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
     fhBinLimDcaZnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZnorm[i]=bins[i];
     break;
+
+  case kSigmaDcaXY:
+    fhNBinsSigmaDcaXY=nbins+1;
+    fhBinLimSigmaDcaXY=new Double_t[nbins+1];
+    for(Int_t i=0;i<nbins+1;i++)fhBinLimSigmaDcaXY[i]=bins[i];
+    break;
+
+  case kSigmaDcaZ:
+    fhNBinsSigmaDcaZ=nbins+1;
+    fhBinLimSigmaDcaZ=new Double_t[nbins+1];
+    for(Int_t i=0;i<nbins+1;i++)fhBinLimSigmaDcaZ[i]=bins[i];
+    break;
   }
 }
 //__________________________________________________________________________________
@@ -498,6 +694,18 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
     fhBinLimDcaZnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZnorm[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
+
+  case kSigmaDcaXY:
+    fhNBinsSigmaDcaXY=nbins+1;
+    fhBinLimSigmaDcaXY=new Double_t[nbins+1];
+    for(Int_t i=0;i<nbins+1;i++)fhBinLimSigmaDcaXY[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
+    break;
+
+  case kSigmaDcaZ:
+    fhNBinsSigmaDcaZ=nbins+1;
+    fhBinLimSigmaDcaZ=new Double_t[nbins+1];
+    for(Int_t i=0;i<nbins+1;i++)fhBinLimSigmaDcaZ[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
+    break;
   }
 }
 //__________________________________________________________________________________
@@ -510,22 +718,37 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
   // book cut statistics and cut correlation histograms
   fhCutStatistics = new TH1F(Form("%s_cut_statistics",GetName()), Form("%s cut statistics",GetName()), kNCuts,0.5,kNCuts+0.5);
   fhCutStatistics->SetLineWidth(2);
-  fhCutStatistics->GetXaxis()->SetBinLabel(1,"n dca");
-  fhCutStatistics->GetXaxis()->SetBinLabel(2,"require dca");
-  fhCutStatistics->GetXaxis()->SetBinLabel(3,"kink daughter");
-  fhCutStatistics->GetXaxis()->SetBinLabel(4,"AOD type");
+  fhCutStatistics->GetXaxis()->SetBinLabel(1,"dca xy");
+  fhCutStatistics->GetXaxis()->SetBinLabel(2,"dca z");
+  fhCutStatistics->GetXaxis()->SetBinLabel(3,"dca ellipse");
+  fhCutStatistics->GetXaxis()->SetBinLabel(4,"n dca");
+  fhCutStatistics->GetXaxis()->SetBinLabel(5,"sigma dca xy");
+  fhCutStatistics->GetXaxis()->SetBinLabel(6,"sigma dca z");
+  fhCutStatistics->GetXaxis()->SetBinLabel(7,"require dca");
+  fhCutStatistics->GetXaxis()->SetBinLabel(8,"kink daughter");
+  fhCutStatistics->GetXaxis()->SetBinLabel(9,"AOD type");
 
   fhCutCorrelation = new TH2F(Form("%s_cut_correlation",GetName()), Form("%s cut  correlation",GetName()), kNCuts,0.5,kNCuts+0.5,kNCuts,0.5,kNCuts+0.5);
   fhCutCorrelation->SetLineWidth(2);
-  fhCutCorrelation->GetXaxis()->SetBinLabel(1,"n dca");
-  fhCutCorrelation->GetXaxis()->SetBinLabel(2,"require dca");
-  fhCutCorrelation->GetXaxis()->SetBinLabel(3,"kink daughter");
-  fhCutCorrelation->GetXaxis()->SetBinLabel(4,"AOD type");
-
-  fhCutCorrelation->GetYaxis()->SetBinLabel(1,"n dca");
-  fhCutCorrelation->GetYaxis()->SetBinLabel(2,"require dca");
-  fhCutCorrelation->GetYaxis()->SetBinLabel(3,"kink daughter");
-  fhCutCorrelation->GetYaxis()->SetBinLabel(4,"AOD type");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(1,"dca xy");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(2,"dca z");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(3,"dca ellipse");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(4,"n dca");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(5,"sigma dca xy");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(6,"sigma dca z");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(7,"require dca");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(8,"kink daughter");
+  fhCutCorrelation->GetXaxis()->SetBinLabel(9,"AOD type");
+
+  fhCutCorrelation->GetYaxis()->SetBinLabel(1,"dca xy");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(2,"dca z");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(3,"dca ellipse");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(4,"n dca");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(5,"sigma dca xy");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(6,"sigma dca z");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(7,"require dca");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(8,"kink daughter");
+  fhCutCorrelation->GetYaxis()->SetBinLabel(9,"AOD type");
 
   // book QA histograms
   Char_t str[256];
@@ -534,7 +757,6 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
     else sprintf(str,"_cut");
 
     fhDcaXYvsDcaZ[i]            = new  TH2F(Form("%s_dcaXYvsDcaZ%s",GetName(),str),"",200,-10,10,200,-10,10);
-    fhDcaXYvsDcaZnorm[i]        = new  TH2F(Form("%s_dcaXYvsDcaZnorm%s",GetName(),str),"",200,-10,10,200,-10,10);
     fhQA[kCutNSigmaToVertex][i]        = new TH1F(Form("%s_nSigmaToVertex%s",GetName(),str),"",fhNBinsNSigma-1,fhBinLimNSigma);
     fhQA[kCutRequireSigmaToVertex][i] = new TH1F(Form("%s_requireSigmaToVertex%s",GetName(),str),"",fhNBinsRequireSigma-1,fhBinLimRequireSigma);
     fhQA[kCutAcceptKinkDaughters][i] = new TH1F(Form("%s_acceptKinkDaughters%s",GetName(),str),"",fhNBinsAcceptKink-1,fhBinLimAcceptKink);
@@ -542,11 +764,11 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
     fhQA[kDcaZ][i]             = new TH1F(Form("%s_dcaZ%s",GetName(),str),"",fhNBinsDcaZ-1,fhBinLimDcaZ);
     fhQA[kDcaXYnorm][i]                = new TH1F(Form("%s_dcaXYnorm%s",GetName(),str),"",fhNBinsDcaXYnorm-1,fhBinLimDcaXYnorm);
     fhQA[kDcaZnorm][i]         = new TH1F(Form("%s_dcaZnorm%s",GetName(),str),"",fhNBinsDcaZnorm-1,fhBinLimDcaZnorm);
+    fhQA[kSigmaDcaXY][i]       = new TH1F(Form("%s_sigmaDcaXY%s",GetName(),str),"",fhNBinsSigmaDcaXY-1,fhBinLimSigmaDcaXY);
+    fhQA[kSigmaDcaZ][i]                = new TH1F(Form("%s_sigmaDcaZ%s",GetName(),str),"",fhNBinsSigmaDcaZ-1,fhBinLimSigmaDcaZ);
 
     fhDcaXYvsDcaZ[i]->SetXTitle("impact par. d_{z}");
     fhDcaXYvsDcaZ[i]->SetYTitle("impact par. d_{xy}");
-    fhDcaXYvsDcaZnorm[i]->SetXTitle("norm. impact par. d_{z} / #sigma_{z}");
-    fhDcaXYvsDcaZnorm[i]->SetYTitle("norm. impact par. d_{xy} / #sigma_{xy}");
 
     fhQA[kCutNSigmaToVertex][i]->SetXTitle("n #sigma to vertex");
     fhQA[kCutRequireSigmaToVertex][i]->SetXTitle("require #sigma to vertex");
@@ -555,6 +777,8 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
     fhQA[kDcaZ][i]->SetXTitle("impact par. d_{z}");
     fhQA[kDcaXYnorm][i]->SetXTitle("norm. impact par. d_{xy} / #sigma_{xy}");
     fhQA[kDcaZnorm][i]->SetXTitle("norm. impact par. d_{z} / #sigma_{z}");
+    fhQA[kSigmaDcaXY][i]->SetXTitle("impact par. resolution #sigma_{xy}");
+    fhQA[kSigmaDcaZ][i]->SetXTitle("impact par. resolution #sigma_{z}");
   }
   for(Int_t i=0; i<kNHist; i++) fhQA[i][1]->SetLineColor(color);
 }
@@ -578,36 +802,26 @@ void AliCFTrackIsPrimaryCuts::FillHistograms(TObject* obj, Bool_t f)
   // f = 0: fill histograms before cuts
   // f = 1: fill histograms after cuts
 
+  // get the track to vertex parameter for ESD track
   if (esdTrack) {
-    Float_t b[2];
-    Float_t bRes[2];
-    Float_t bCov[3];
-    esdTrack->GetImpactParameters(b,bCov);
-    if (bCov[0]<=0 || bCov[2]<=0) {
-      AliDebug(1, "Estimated b resolution lower or equal zero!");
-      bCov[0]=0; bCov[2]=0;
-    }
-    bRes[0] = TMath::Sqrt(bCov[0]);
-    bRes[1] = TMath::Sqrt(bCov[2]);
-  
-    fhQA[kDcaZ][f]->Fill(b[1]);
-    fhQA[kDcaXY][f]->Fill(b[0]);
-    fhDcaXYvsDcaZ[f]->Fill(b[1],b[0]);
-    
-    if (bRes[0]!=0 && bRes[1]!=0) {
-      fhQA[kDcaZnorm][f]->Fill(b[1]/bRes[1]);
-      fhQA[kDcaXYnorm][f]->Fill(b[0]/bRes[0]);
-      fhDcaXYvsDcaZnorm[f]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
-    }
 
-    fhQA[kCutNSigmaToVertex][f]->Fill(fNSigmaToVertex);
-    if (fNSigmaToVertex<0 && fRequireSigmaToVertex) fhQA[kCutRequireSigmaToVertex][f]->Fill(0.);
-    if (!(fNSigmaToVertex<0 && fRequireSigmaToVertex)) fhQA[kCutRequireSigmaToVertex][f]->Fill(1.);
-    
+    fhQA[kDcaZ][f]->Fill(fDCA[1]);
+    fhQA[kDcaXY][f]->Fill(fDCA[0]);
+    fhDcaXYvsDcaZ[f]->Fill(fDCA[1],fDCA[0]);
+    fhQA[kSigmaDcaXY][f]->Fill(fDCA[2]);
+    fhQA[kSigmaDcaZ][f]->Fill(fDCA[3]);
+// // // // // // //  delete histograms
+      fhQA[kDcaZnorm][f]->Fill(fDCA[1]);
+      fhQA[kDcaXYnorm][f]->Fill(fDCA[0]);
+
+    fhQA[kCutNSigmaToVertex][f]->Fill(fDCA[5]);
+    if (fDCA[5]<0 && fRequireSigmaToVertex) fhQA[kCutRequireSigmaToVertex][f]->Fill(0.);
+    if (!(fDCA[5]<0 && fRequireSigmaToVertex)) fhQA[kCutRequireSigmaToVertex][f]->Fill(1.);
+
     if (!fAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0) fhQA[kCutAcceptKinkDaughters][f]->Fill(0.);
     if (!(!fAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)) fhQA[kCutAcceptKinkDaughters][f]->Fill(0.);
   }
-    
+
   // fill cut statistics and cut correlation histograms with information from the bitmap
   if (f) return;
 
@@ -653,7 +867,6 @@ void AliCFTrackIsPrimaryCuts::SaveHistograms(const Char_t* dir) {
       gDirectory->cd("after_cuts");
 
     fhDcaXYvsDcaZ[j]    ->Write();
-    fhDcaXYvsDcaZnorm[j]->Write();
 
     for(Int_t i=0; i<kNHist; i++) fhQA[i][j]->Write();
 
@@ -745,8 +958,8 @@ void AliCFTrackIsPrimaryCuts::DrawHistograms()
 
   // -----
 
-  TCanvas* canvas3 = new TCanvas("Track_QA_Primary_3", "Track QA Primary 3", 800, 800);
-  canvas3->Divide(2, 2);
+  TCanvas* canvas3 = new TCanvas("Track_QA_Primary_3", "Track QA Primary 3", 800, 400);
+  canvas3->Divide(2, 1);
 
   canvas3->cd(1);
   gPad->SetRightMargin(right);
@@ -766,42 +979,42 @@ void AliCFTrackIsPrimaryCuts::DrawHistograms()
   fhQA[kDcaZnorm][0]->Draw();
   fhQA[kDcaZnorm][1]->Draw("same");
 
-  canvas3->cd(3);
-//   fhDXYvsDZ[0]->SetStats(kFALSE);
-  gPad->SetLogz();
-  gPad->SetLeftMargin(bottom);
-  gPad->SetTopMargin(0.1);
-  gPad->SetBottomMargin(bottom);
-  gPad->SetRightMargin(0.2);
-  fhDcaXYvsDcaZnorm[0]->Draw("COLZ");
-
-  canvas3->cd(4);
-//   fhDXYvsDZ[1]->SetStats(kFALSE);
-  gPad->SetLogz();
-  gPad->SetLeftMargin(bottom);
-  gPad->SetTopMargin(0.1);
-  gPad->SetBottomMargin(bottom);
-  gPad->SetRightMargin(0.2);
-  fhDcaXYvsDcaZnorm[1]->Draw("COLZ");
-
   canvas3->SaveAs(Form("%s.eps", canvas3->GetName()));
   canvas3->SaveAs(Form("%s.ps", canvas3->GetName()));
 
   // -----
 
-  TCanvas* canvas4 = new TCanvas("Track_QA_Primary_4", "Track QA Primary 4", 1200, 500);
-  canvas4->Divide(3, 1);
+  TCanvas* canvas4 = new TCanvas("Track_QA_Primary_4", "Track QA Primary 4", 1200, 800);
+  canvas4->Divide(3, 2);
 
   canvas4->cd(1);
   gPad->SetRightMargin(right);
   gPad->SetLeftMargin(left);
   gPad->SetTopMargin(top);
   gPad->SetBottomMargin(bottom);
+  fhQA[kSigmaDcaXY][0]->SetStats(kFALSE);
+  fhQA[kSigmaDcaXY][0]->Draw();
+  fhQA[kSigmaDcaXY][1]->Draw("same");
+
+  canvas4->cd(2);
+  gPad->SetRightMargin(right);
+  gPad->SetLeftMargin(left);
+  gPad->SetTopMargin(top);
+  gPad->SetBottomMargin(bottom);
+  fhQA[kSigmaDcaZ][0]->SetStats(kFALSE);
+  fhQA[kSigmaDcaZ][0]->Draw();
+  fhQA[kSigmaDcaZ][1]->Draw("same");
+
+  canvas4->cd(4);
+  gPad->SetRightMargin(right);
+  gPad->SetLeftMargin(left);
+  gPad->SetTopMargin(top);
+  gPad->SetBottomMargin(bottom);
   fhQA[kCutNSigmaToVertex][0]->SetStats(kFALSE);
   fhQA[kCutNSigmaToVertex][0]->Draw();
   fhQA[kCutNSigmaToVertex][1]->Draw("same");
 
-  canvas4->cd(2);
+  canvas4->cd(5);
   gPad->SetRightMargin(right);
   gPad->SetLeftMargin(left);
   gPad->SetTopMargin(top);
@@ -810,7 +1023,7 @@ void AliCFTrackIsPrimaryCuts::DrawHistograms()
   fhQA[kCutRequireSigmaToVertex][0]->Draw();
   fhQA[kCutRequireSigmaToVertex][1]->Draw("same");
 
-  canvas4->cd(3);
+  canvas4->cd(6);
   gPad->SetRightMargin(right);
   gPad->SetLeftMargin(left);
   gPad->SetTopMargin(top);
@@ -834,7 +1047,6 @@ void AliCFTrackIsPrimaryCuts::AddQAHistograms(TList *qaList) {
 
   for (Int_t j=0; j<kNStepQA; j++) {
     qaList->Add(fhDcaXYvsDcaZ[j]);
-    qaList->Add(fhDcaXYvsDcaZnorm[j]);
     for(Int_t i=0; i<kNHist; i++)
        qaList->Add(fhQA[i][j]);
   }