]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/SPECTRA/AliProtonQAAnalysis.cxx
Adding the QA plot for the pid efficiency/contamination vs the number of TPC points...
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliProtonQAAnalysis.cxx
index a4d7b45d1f30257d4716c3a2301cbb6c9aa2c5a7..33e60cd0668a52c9998b7b40a53c65639ce0641c 100644 (file)
 //-----------------------------------------------------------------
 //                 AliProtonQAAnalysis class
 //   This is the class to deal with the proton analysis
-//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//   Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch
 //-----------------------------------------------------------------
 #include <Riostream.h>
-#include <TFile.h>
 #include <TSystem.h>
 #include <TF1.h>
 #include <TH2D.h>
 #include <TH3F.h>
 #include <TH1D.h>
+#include <TArrayI.h>
 #include <TParticle.h>
 
 #include "AliProtonQAAnalysis.h"
+#include "AliProtonAnalysisBase.h"
 
 #include <AliExternalTrackParam.h>
 #include <AliESDEvent.h>
 #include <AliLog.h>
 #include <AliPID.h>
 #include <AliStack.h>
+#include <AliESDVertex.h>
+#include <AliGenEventHeader.h>
+#include <AliMCEvent.h>
 
 ClassImp(AliProtonQAAnalysis)
 
 //____________________________________________________________________//
 AliProtonQAAnalysis::AliProtonQAAnalysis() : 
-  TObject(), 
+  TObject(), fProtonAnalysisBase(0),
   fNBinsY(0), fMinY(0), fMaxY(0),
   fNBinsPt(0), fMinPt(0), fMaxPt(0),
-  fMinTPCClusters(0), fMinITSClusters(0),
-  fMaxChi2PerTPCCluster(0), fMaxChi2PerITSCluster(0),
-  fMaxCov11(0), fMaxCov22(0), fMaxCov33(0), fMaxCov44(0), fMaxCov55(0),
-  fMaxSigmaToVertex(0), fMaxSigmaToVertexTPC(0),
-  fMaxDCAXY(0), fMaxDCAXYTPC(0),
-  fMaxDCAZ(0), fMaxDCAZTPC(0),
-  fMaxConstrainChi2(0),
-  fMinTPCClustersFlag(kFALSE), fMinITSClustersFlag(kFALSE),
-  fMaxChi2PerTPCClusterFlag(kFALSE), fMaxChi2PerITSClusterFlag(kFALSE),
-  fMaxCov11Flag(kFALSE), fMaxCov22Flag(kFALSE), 
-  fMaxCov33Flag(kFALSE), fMaxCov44Flag(kFALSE), fMaxCov55Flag(kFALSE),
-  fMaxSigmaToVertexFlag(kFALSE), fMaxSigmaToVertexTPCFlag(kFALSE),
-  fMaxDCAXYFlag(kFALSE), fMaxDCAXYTPCFlag(kFALSE),
-  fMaxDCAZFlag(kFALSE), fMaxDCAZTPCFlag(kFALSE),
-  fMaxConstrainChi2Flag(kFALSE),
-  fITSRefitFlag(kFALSE), fTPCRefitFlag(kFALSE),
-  fESDpidFlag(kFALSE), fTPCpidFlag(kFALSE),
-  fPointOnITSLayer1Flag(0), fPointOnITSLayer2Flag(0),
-  fPointOnITSLayer3Flag(0), fPointOnITSLayer4Flag(0),
-  fPointOnITSLayer5Flag(0), fPointOnITSLayer6Flag(0),
-  fGlobalQAList(0), fQA2DList(0),
+  fGlobalQAList(0), fQAVertexList(0), fQA2DList(0),
   fQAPrimaryProtonsAcceptedList(0),
   fQAPrimaryProtonsRejectedList(0),
   fQASecondaryProtonsAcceptedList(0),
@@ -71,20 +55,24 @@ AliProtonQAAnalysis::AliProtonQAAnalysis() :
   fQAPrimaryAntiProtonsRejectedList(0),
   fQASecondaryAntiProtonsAcceptedList(0),
   fQASecondaryAntiProtonsRejectedList(0),
-  fFunctionProbabilityFlag(kFALSE), 
-  fElectronFunction(0), fMuonFunction(0),
-  fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
-  fUseTPCOnly(kFALSE),
   fPDGList(0), fMCProcessesList(0),
-  fRunMCAnalysis(kFALSE) {
+  fRunMCAnalysis(kFALSE),
+  fMCProcessIdFlag(kFALSE), fMCProcessId(0),
+  fMotherParticlePDGCodeFlag(kFALSE), fMotherParticlePDGCode(0),
+  fAcceptedCutList(0), fRejectedCutList(0),
+  fAcceptedDCAList(0), fRejectedDCAList(0),
+  fRunEfficiencyAnalysis(kFALSE),
+  fUseCutsInEfficiency(kFALSE),
+  fEfficiencyList(0) {
   //Default constructor
-  for(Int_t i = 0; i < 5; i++) fPartFrac[i] = 0.0;
 }
 
 //____________________________________________________________________//
 AliProtonQAAnalysis::~AliProtonQAAnalysis() {
   //Default destructor
+  if(fProtonAnalysisBase) delete fProtonAnalysisBase;
   if(fGlobalQAList) delete fGlobalQAList;
+  if(fQAVertexList) delete fQAVertexList;
   if(fQA2DList) delete fQA2DList;
   if(fQAPrimaryProtonsAcceptedList) delete fQAPrimaryProtonsAcceptedList;
   if(fQAPrimaryProtonsRejectedList) delete fQAPrimaryProtonsRejectedList;
@@ -101,140 +89,54 @@ AliProtonQAAnalysis::~AliProtonQAAnalysis() {
 
   if(fPDGList) delete fPDGList;
   if(fMCProcessesList) delete fMCProcessesList;
+  
+  if(fAcceptedCutList) delete fAcceptedCutList;
+  if(fRejectedCutList) delete fRejectedCutList;
+  if(fAcceptedDCAList) delete fAcceptedDCAList;
+  if(fRejectedDCAList) delete fRejectedDCAList;
+  if(fEfficiencyList) delete fEfficiencyList;
 }
 
 //____________________________________________________________________//
-Double_t AliProtonQAAnalysis::GetParticleFraction(Int_t i, Double_t p) {
-  Double_t partFrac=0;
-  if(fFunctionProbabilityFlag) {
-    if(i == 0) partFrac = fElectronFunction->Eval(p);
-    if(i == 1) partFrac = fMuonFunction->Eval(p);
-    if(i == 2) partFrac = fPionFunction->Eval(p);
-    if(i == 3) partFrac = fKaonFunction->Eval(p);
-    if(i == 4) partFrac = fProtonFunction->Eval(p);
-  }
-  else partFrac = fPartFrac[i];
-
-  return partFrac;
-}
-
-//____________________________________________________________________//
-Bool_t AliProtonQAAnalysis::IsAccepted(AliESDtrack* track) {
-  // Checks if the track is excluded from the cuts
-  Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
-  if(fUseTPCOnly) {
-    AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
-    if(!tpcTrack) {
-      Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
-    }
-    else {
-      Pt = tpcTrack->Pt();
-      Px = tpcTrack->Px();
-      Py = tpcTrack->Py();
-      Pz = tpcTrack->Pz();
-    }
-  }
-  else{
-    Pt = track->Pt();
-    Px = track->Px();
-    Py = track->Py();
-    Pz = track->Pz();
-  }
-     
-  Int_t  fIdxInt[200];
-  Int_t nClustersITS = track->GetITSclusters(fIdxInt);
-  Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
-
-  Float_t chi2PerClusterITS = -1;
-  if (nClustersITS!=0)
-    chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
-  Float_t chi2PerClusterTPC = -1;
-  if (nClustersTPC!=0)
-    chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
-
-  Double_t extCov[15];
-  track->GetExternalCovariance(extCov);
-
-  if(fPointOnITSLayer1Flag)
-    if(!track->HasPointOnITSLayer(0)) return kFALSE;
-  if(fPointOnITSLayer2Flag)
-    if(!track->HasPointOnITSLayer(1)) return kFALSE;
-  if(fPointOnITSLayer3Flag)
-    if(!track->HasPointOnITSLayer(2)) return kFALSE;
-  if(fPointOnITSLayer4Flag)
-    if(!track->HasPointOnITSLayer(3)) return kFALSE;
-  if(fPointOnITSLayer5Flag)
-    if(!track->HasPointOnITSLayer(4)) return kFALSE;
-  if(fPointOnITSLayer6Flag)
-    if(!track->HasPointOnITSLayer(5)) return kFALSE;
-  if(fMinITSClustersFlag)
-    if(nClustersITS < fMinITSClusters) return kFALSE;
-  if(fMaxChi2PerITSClusterFlag)
-    if(chi2PerClusterITS > fMaxChi2PerITSCluster) return kFALSE; 
-  if(fMinTPCClustersFlag)
-    if(nClustersTPC < fMinTPCClusters) return kFALSE;
-  if(fMaxChi2PerTPCClusterFlag)
-    if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) return kFALSE; 
-  if(fMaxCov11Flag)
-    if(extCov[0] > fMaxCov11) return kFALSE;
-  if(fMaxCov22Flag)
-    if(extCov[2] > fMaxCov22) return kFALSE;
-  if(fMaxCov33Flag)
-    if(extCov[5] > fMaxCov33) return kFALSE;
-  if(fMaxCov44Flag)
-    if(extCov[9] > fMaxCov44) return kFALSE;
-  if(fMaxCov55Flag)
-    if(extCov[14] > fMaxCov55) return kFALSE;
-  if(fMaxSigmaToVertexFlag)
-    if(GetSigmaToVertex(track) > fMaxSigmaToVertex) return kFALSE;
-  if(fMaxSigmaToVertexTPCFlag)
-    if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) return kFALSE;
-  if(fITSRefitFlag)
-    if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
-  if(fTPCRefitFlag)
-    if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
-  if(fESDpidFlag)
-    if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) return kFALSE;
-  if(fTPCpidFlag)
-    if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) return kFALSE;
-
-  if((Pt < fMinPt) || (Pt > fMaxPt)) return kFALSE;
-  if((Rapidity(Px,Py,Pz) < fMinY) || (Rapidity(Px,Py,Pz) > fMaxY)) 
-    return kFALSE;
-
-  return kTRUE;
-}
-
-//____________________________________________________________________//
-void AliProtonQAAnalysis::FillQA(AliESDtrack* track, AliStack *stack) {
+void AliProtonQAAnalysis::FillQA(AliStack *const stack,
+                                AliESDEvent *esd,
+                                const AliESDVertex *vertex, 
+                                AliESDtrack* track) {
   // Checks if the track is excluded from the cuts
   Int_t nPrimaries = stack->GetNprimary();
   Int_t label = TMath::Abs(track->GetLabel());
 
-  Double_t Pt = 0.0, Px = 0.0, Py = 0.0, Pz = 0.0;
-  Float_t dcaXY = 0.0, dcaZ = 0.0;
-  if(fUseTPCOnly) {
+  Double_t gPt = 0.0, gPx = 0.0, gPy = 0.0, gPz = 0.0;
+  Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0};  //The impact parameters and their covariance.
+
+  if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
     AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
     if(!tpcTrack) {
-      Pt = 0.0; Px = 0.0; Py = 0.0; Pz = 0.0;
-      dcaXY = -100.0, dcaZ = -100.0;
+      gPt = 0.0; gPx = 0.0; gPy = 0.0; gPz = 0.0;
+      dca[0] = -100.; dca[1] = -100.;
+      cov[0] = -100.; cov[1] = -100.; cov[2] = -100.;
     }
     else {
-      Pt = tpcTrack->Pt();
-      Px = tpcTrack->Px();
-      Py = tpcTrack->Py();
-      Pz = tpcTrack->Pz();
-      track->GetImpactParametersTPC(dcaXY,dcaZ);
+      gPt = tpcTrack->Pt();
+      gPx = tpcTrack->Px();
+      gPy = tpcTrack->Py();
+      gPz = tpcTrack->Pz();
+      tpcTrack->PropagateToDCA(vertex,
+                              esd->GetMagneticField(),
+                              100.,dca,cov);
     }
   }
   else{
-    Pt = track->Pt();
-    Px = track->Px();
-    Py = track->Py();
-    Pz = track->Pz();
-    track->GetImpactParameters(dcaXY,dcaZ);
+    gPt = track->Pt();
+    gPx = track->Px();
+    gPy = track->Py();
+    gPz = track->Pz();
+    track->PropagateToDCA(vertex,
+                         esd->GetMagneticField(),
+                         100.,dca,cov);
   }
-     
+
   Int_t  fIdxInt[200];
   Int_t nClustersITS = track->GetITSclusters(fIdxInt);
   Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
@@ -249,430 +151,399 @@ void AliProtonQAAnalysis::FillQA(AliESDtrack* track, AliStack *stack) {
   Double_t extCov[15];
   track->GetExternalCovariance(extCov);
   
-  //cout<<"Charge: "<<track->Charge()<<
-  //" - Label/Primaries: "<<label<<"/"<<nPrimaries<<
-  //" - TPC clusters: "<<nClustersTPC<<endl;
   //protons
   if(track->Charge() > 0) {
     //Primaries
     if(label <= nPrimaries) {
-      if(fMinITSClustersFlag) {
-       if(nClustersITS < fMinITSClusters) {
+      if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
+       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
-         //status = kFALSE;
        }
-       else if(nClustersITS >= fMinITSClusters
+       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
       }//ITS clusters
-      if(fMaxChi2PerITSClusterFlag) {
-       if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
+       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
+       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
       }//chi2 per ITS cluster
-      if(fMinTPCClustersFlag) {
-       if(nClustersTPC < fMinTPCClusters) {
-         //cout<<"Primary proton rejected"<<endl;
+      if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
+       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
-         //status = kFALSE;
        }
-       else if(nClustersTPC >= fMinTPCClusters) {
-         //cout<<"Primary proton accepted"<<endl;
+       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
        }
       }//TPC clusters
-      if(fMaxChi2PerTPCClusterFlag) {
-       if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
+       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
+       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
       }//chi2 per TPC cluster
-      if(fMaxCov11Flag) {
-       if(extCov[0] > fMaxCov11) {
+      if(fProtonAnalysisBase->IsUsedMaxCov11()) {
+       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
-         //status = kFALSE;
        }
-       else if(extCov[0] <= fMaxCov11)
+       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
       }//cov11
-      if(fMaxCov22Flag) {
-       if(extCov[2] > fMaxCov22) {
+      if(fProtonAnalysisBase->IsUsedMaxCov22()) {
+       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
-         //status = kFALSE;
        }
-       else if(extCov[2] <= fMaxCov22)
+       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
       }//cov11
-      if(fMaxCov33Flag) {
-       if(extCov[5] > fMaxCov33) {
+      if(fProtonAnalysisBase->IsUsedMaxCov33()) {
+       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
-         //status = kFALSE;
        }
-       else if(extCov[5] <= fMaxCov33)
+       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
       }//cov11
-      if(fMaxCov44Flag) {
-       if(extCov[9] > fMaxCov44) {
+      if(fProtonAnalysisBase->IsUsedMaxCov44()) {
+       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
-         //status = kFALSE;
        }
-       else if(extCov[9] <= fMaxCov44)
+       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
       }//cov11
-      if(fMaxCov55Flag) {
-       if(extCov[14] > fMaxCov55) {
+      if(fProtonAnalysisBase->IsUsedMaxCov55()) {
+       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
-         //status = kFALSE;
        }
-       else if(extCov[14] <= fMaxCov55)
+       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
       }//cov55
-      if(fMaxSigmaToVertexFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex
-      if(fMaxSigmaToVertexTPCFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex TPC
-      if(fMaxDCAXYFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy global tracking
-      if(fMaxDCAXYTPCFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy TPC tracking
-      if(fMaxDCAZFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
       }//DCA z global tracking
-      if(fMaxDCAZTPCFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(14)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(14)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
       }//DCA z TPC tracking
-      if(fMaxConstrainChi2Flag) {
+      if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
        if(track->GetConstrainedChi2() > 0) {
-         if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
+         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
            ((TH1F *)(fQAPrimaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
-           //status = kFALSE;
          }
-         else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
+         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
            ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
        }
       }//constrain chi2 - vertex
-      if(fITSRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedITSRefit()) {
        if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(16)))->Fill(0);
-       //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(16)))->Fill(0);
       }//ITS refit
-      if(fTPCRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCRefit()) {
        if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(17)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(17)))->Fill(0);
       }//TPC refit
-      if(fESDpidFlag) {
+      if(fProtonAnalysisBase->IsUsedESDpid()) {
        if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(18)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(18)))->Fill(0);
       }//ESD pid
-      if(fTPCpidFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCpid()) {
        if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
          ((TH1F *)(fQAPrimaryProtonsRejectedList->At(19)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
          ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(19)))->Fill(0);
       }//TPC pid
-      if(fPointOnITSLayer1Flag) {
+      if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
+       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(20)))->Fill(track->GetTPCsignalN());
+       }
+       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(20)))->Fill(track->GetTPCsignalN());
+      }//number of TPC points for the dE/dx
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
        if(!track->HasPointOnITSLayer(0)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(20)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(21)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(0))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(20)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(21)))->Fill(0);
       }//point on SPD1
-      if(fPointOnITSLayer2Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
        if(!track->HasPointOnITSLayer(1)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(21)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(22)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(1))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(21)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(22)))->Fill(0);
       }//point on SPD2
-      if(fPointOnITSLayer3Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
        if(!track->HasPointOnITSLayer(2)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(22)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(23)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(2))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(22)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(23)))->Fill(0);
       }//point on SDD1
-      if(fPointOnITSLayer4Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
        if(!track->HasPointOnITSLayer(3)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(23)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(24)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(3))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(23)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(24)))->Fill(0);
       }//point on SDD2
-      if(fPointOnITSLayer5Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
        if(!track->HasPointOnITSLayer(4)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(24)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(25)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(4))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(24)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(25)))->Fill(0);
       }//point on SSD1
-      if(fPointOnITSLayer6Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
        if(!track->HasPointOnITSLayer(5)) {
-         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(25)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsRejectedList->At(26)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(5))
-         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(25)))->Fill(0);
+         ((TH1F *)(fQAPrimaryProtonsAcceptedList->At(26)))->Fill(0);
       }//point on SSD2
     }//primary particle cut
 
     //Secondaries
     if(label > nPrimaries) {
-      if(fMinITSClustersFlag) {
-       if(nClustersITS < fMinITSClusters) {
+      if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
+       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(0)))->Fill(nClustersITS);
-         //status = kFALSE;
        }
-       else if(nClustersITS >= fMinITSClusters
+       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(0)))->Fill(nClustersITS);
       }//ITS clusters
-      if(fMaxChi2PerITSClusterFlag) {
-       if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
+       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
+       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
       }//chi2 per ITS cluster
-      if(fMinTPCClustersFlag) {
-       if(nClustersTPC < fMinTPCClusters) {
+      if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
+       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
          //cout<<"Secondary proton rejected"<<endl;
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(2)))->Fill(nClustersTPC);
-         //status = kFALSE;
        }
-       else if(nClustersTPC >= fMinTPCClusters) {
+       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
          //cout<<"Secondary proton accepted"<<endl;
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
        }
       }//TPC clusters
-      if(fMaxChi2PerTPCClusterFlag) {
-       if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
+       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
+       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
       }//chi2 per TPC cluster
-      if(fMaxCov11Flag) {
-       if(extCov[0] > fMaxCov11) {
+      if(fProtonAnalysisBase->IsUsedMaxCov11()) {
+       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(4)))->Fill(extCov[0]);
-         //status = kFALSE;
        }
-       else if(extCov[0] <= fMaxCov11)
+       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(4)))->Fill(extCov[0]);
       }//cov11
-      if(fMaxCov22Flag) {
-       if(extCov[2] > fMaxCov22) {
+      if(fProtonAnalysisBase->IsUsedMaxCov22()) {
+       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(5)))->Fill(extCov[2]);
-         //status = kFALSE;
        }
-       else if(extCov[2] <= fMaxCov22)
+       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(5)))->Fill(extCov[2]);
       }//cov11
-      if(fMaxCov33Flag) {
-       if(extCov[5] > fMaxCov33) {
+      if(fProtonAnalysisBase->IsUsedMaxCov33()) {
+       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(6)))->Fill(extCov[5]);
-         //status = kFALSE;
        }
-       else if(extCov[5] <= fMaxCov33)
+       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(6)))->Fill(extCov[5]);
       }//cov11
-      if(fMaxCov44Flag) {
-       if(extCov[9] > fMaxCov44) {
+      if(fProtonAnalysisBase->IsUsedMaxCov44()) {
+       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(7)))->Fill(extCov[9]);
-         //status = kFALSE;
        }
-       else if(extCov[9] <= fMaxCov44)
+       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(7)))->Fill(extCov[9]);
       }//cov11
-      if(fMaxCov55Flag) {
-       if(extCov[14] > fMaxCov55) {
+      if(fProtonAnalysisBase->IsUsedMaxCov55()) {
+       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(8)))->Fill(extCov[14]);
-         //status = kFALSE;
        }
-       else if(extCov[14] <= fMaxCov55)
+       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(8)))->Fill(extCov[14]);
       }//cov55
-      if(fMaxSigmaToVertexFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex
-      if(fMaxSigmaToVertexTPCFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex TPC
-      if(fMaxDCAXYFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy global tracking
-      if(fMaxDCAXYTPCFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy TPC tracking
-      if(fMaxDCAZFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
       }//DCA z global tracking
-      if(fMaxDCAZTPCFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(14)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(14)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
       }//DCA z TPC tracking
-      if(fMaxConstrainChi2Flag) {
+      if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
        if(track->GetConstrainedChi2() > 0) {
-         if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
+         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
            ((TH1F *)(fQASecondaryProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
-           //status = kFALSE;
          }
-         else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
+         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
            ((TH1F *)(fQASecondaryProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
        }
       }//constrain chi2 - vertex
-      if(fITSRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedITSRefit()) {
        if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(16)))->Fill(0);
-       //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(16)))->Fill(0);
       }//ITS refit
-      if(fTPCRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCRefit()) {
        if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(17)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(17)))->Fill(0);
       }//TPC refit
-      if(fESDpidFlag) {
+      if(fProtonAnalysisBase->IsUsedESDpid()) {
        if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(18)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(18)))->Fill(0);
       }//ESD pid
-      if(fTPCpidFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCpid()) {
        if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
          ((TH1F *)(fQASecondaryProtonsRejectedList->At(19)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
          ((TH1F *)(fQASecondaryProtonsAcceptedList->At(19)))->Fill(0);
       }//TPC pid
-      if(fPointOnITSLayer1Flag) {
+      if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
+       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(20)))->Fill(track->GetTPCsignalN());
+       }
+       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(20)))->Fill(track->GetTPCsignalN());
+      }//number of TPC points for the dE/dx
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
        if(!track->HasPointOnITSLayer(0)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(20)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(21)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(0))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(20)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(21)))->Fill(0);
       }//point on SPD1
-      if(fPointOnITSLayer2Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
        if(!track->HasPointOnITSLayer(1)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(21)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(22)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(1))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(21)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(22)))->Fill(0);
       }//point on SPD2
-      if(fPointOnITSLayer3Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
        if(!track->HasPointOnITSLayer(2)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(22)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(23)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(2))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(22)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(23)))->Fill(0);
       }//point on SDD1
-      if(fPointOnITSLayer4Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
        if(!track->HasPointOnITSLayer(3)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(23)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(24)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(3))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(23)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(24)))->Fill(0);
       }//point on SDD2
-      if(fPointOnITSLayer5Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
        if(!track->HasPointOnITSLayer(4)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(24)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(25)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(4))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(24)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(25)))->Fill(0);
       }//point on SSD1
-      if(fPointOnITSLayer6Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
        if(!track->HasPointOnITSLayer(5)) {
-         ((TH1F *)(fQASecondaryProtonsRejectedList->At(25)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsRejectedList->At(26)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(5))
-         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(25)))->Fill(0);
+         ((TH1F *)(fQASecondaryProtonsAcceptedList->At(26)))->Fill(0);
       }//point on SSD2
     }//secondary particle cut
   }//protons
@@ -681,479 +552,405 @@ void AliProtonQAAnalysis::FillQA(AliESDtrack* track, AliStack *stack) {
   if(track->Charge() < 0) {
     //Primaries
     if(label <= nPrimaries) {
-      if(fMinITSClustersFlag) {
-       if(nClustersITS < fMinITSClusters) {
+      if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
+       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
-         //status = kFALSE;
        }
-       else if(nClustersITS >= fMinITSClusters
+       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
       }//ITS clusters
-      if(fMaxChi2PerITSClusterFlag) {
-       if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
+       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
+       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
       }//chi2 per ITS cluster
-      if(fMinTPCClustersFlag) {
-       if(nClustersTPC < fMinTPCClusters) {
+      if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
+       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
          //cout<<"Primary antiproton rejected"<<endl;
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
-         //status = kFALSE;
        }
-       else if(nClustersTPC >= fMinTPCClusters) {
-         //cout<<"Primary antiproton accepted"<<endl;
+       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
        }
       }//TPC clusters
-      if(fMaxChi2PerTPCClusterFlag) {
-       if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
+       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
+       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
       }//chi2 per TPC cluster
-      if(fMaxCov11Flag) {
-       if(extCov[0] > fMaxCov11) {
+      if(fProtonAnalysisBase->IsUsedMaxCov11()) {
+       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
-         //status = kFALSE;
        }
-       else if(extCov[0] <= fMaxCov11)
+       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
       }//cov11
-      if(fMaxCov22Flag) {
-       if(extCov[2] > fMaxCov22) {
+      if(fProtonAnalysisBase->IsUsedMaxCov22()) {
+       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
-         //status = kFALSE;
        }
-       else if(extCov[2] <= fMaxCov22)
+       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
       }//cov11
-      if(fMaxCov33Flag) {
-       if(extCov[5] > fMaxCov33) {
+      if(fProtonAnalysisBase->IsUsedMaxCov33()) {
+       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
-         //status = kFALSE;
        }
-       else if(extCov[5] <= fMaxCov33)
+       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
       }//cov11
-      if(fMaxCov44Flag) {
-       if(extCov[9] > fMaxCov44) {
+      if(fProtonAnalysisBase->IsUsedMaxCov44()) {
+       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
-         //status = kFALSE;
        }
-       else if(extCov[9] <= fMaxCov44)
+       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
       }//cov11
-      if(fMaxCov55Flag) {
-       if(extCov[14] > fMaxCov55) {
+      if(fProtonAnalysisBase->IsUsedMaxCov55()) {
+       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
-         //status = kFALSE;
        }
-       else if(extCov[14] <= fMaxCov55)
+       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
       }//cov55
-      if(fMaxSigmaToVertexFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex
-      if(fMaxSigmaToVertexTPCFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex TPC
-      if(fMaxDCAXYFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy global tracking
-      if(fMaxDCAXYTPCFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy TPC tracking
-      if(fMaxDCAZFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
       }//DCA z global tracking
-      if(fMaxDCAZTPCFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(14)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(14)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
       }//DCA z TPC tracking
-      if(fMaxConstrainChi2Flag) {
+      if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
        if(track->GetConstrainedChi2() > 0) {
-         if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
+         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
            ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
-           //status = kFALSE;
          }
-         else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
+         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
            ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
        }
       }//constrain chi2 - vertex
-      if(fITSRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedITSRefit()) {
        if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(16)))->Fill(0);
-       //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(16)))->Fill(0);
       }//ITS refit
-      if(fTPCRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCRefit()) {
        if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(17)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(17)))->Fill(0);
       }//TPC refit
-      if(fESDpidFlag) {
+      if(fProtonAnalysisBase->IsUsedESDpid()) {
        if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(18)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(18)))->Fill(0);
       }//ESD pid
-      if(fTPCpidFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCpid()) {
        if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
          ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(19)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
          ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(19)))->Fill(0);
       }//TPC pid
-      if(fPointOnITSLayer1Flag) {
+      if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
+       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(20)))->Fill(track->GetTPCsignalN());
+       }
+       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(20)))->Fill(track->GetTPCsignalN());
+      }//number of TPC points for the dE/dx
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
        if(!track->HasPointOnITSLayer(0)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(20)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(21)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(0))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(20)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(21)))->Fill(0);
       }//point on SPD1
-      if(fPointOnITSLayer2Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
        if(!track->HasPointOnITSLayer(1)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(21)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(22)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(1))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(21)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(22)))->Fill(0);
       }//point on SPD2
-      if(fPointOnITSLayer3Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
        if(!track->HasPointOnITSLayer(2)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(22)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(23)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(2))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(22)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(23)))->Fill(0);
       }//point on SDD1
-      if(fPointOnITSLayer4Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
        if(!track->HasPointOnITSLayer(3)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(23)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(24)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(3))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(23)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(24)))->Fill(0);
       }//point on SDD2
-      if(fPointOnITSLayer5Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
        if(!track->HasPointOnITSLayer(4)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(24)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(25)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(4))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(24)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(25)))->Fill(0);
       }//point on SSD1
-      if(fPointOnITSLayer6Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
        if(!track->HasPointOnITSLayer(5)) {
-         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(25)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsRejectedList->At(26)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(5))
-         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(25)))->Fill(0);
+         ((TH1F *)(fQAPrimaryAntiProtonsAcceptedList->At(26)))->Fill(0);
       }//point on SSD2
     }//primary particle cut
 
     //Secondaries
     if(label > nPrimaries) {
-      if(fMinITSClustersFlag) {
-       if(nClustersITS < fMinITSClusters) {
+      if(fProtonAnalysisBase->IsUsedMinITSClusters()) {
+       if(nClustersITS < fProtonAnalysisBase->GetMinITSClusters()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(0)))->Fill(nClustersITS);
-         //status = kFALSE;
        }
-       else if(nClustersITS >= fMinITSClusters
+       else if(nClustersITS >= fProtonAnalysisBase->GetMinITSClusters()
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(0)))->Fill(nClustersITS);
       }//ITS clusters
-      if(fMaxChi2PerITSClusterFlag) {
-       if(chi2PerClusterITS > fMaxChi2PerITSCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerITSCluster()) {
+       if(chi2PerClusterITS > fProtonAnalysisBase->GetMaxChi2PerITSCluster()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(1)))->Fill(chi2PerClusterITS);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterITS <= fMaxChi2PerITSCluster)
+       else if(chi2PerClusterITS <= fProtonAnalysisBase->GetMaxChi2PerITSCluster())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(1)))->Fill(chi2PerClusterITS);
       }//chi2 per ITS cluster
-      if(fMinTPCClustersFlag) {
-       if(nClustersTPC < fMinTPCClusters) {
-         //cout<<"Secondary antiproton rejected"<<endl;
+      if(fProtonAnalysisBase->IsUsedMinTPCClusters()) {
+       if(nClustersTPC < fProtonAnalysisBase->GetMinTPCClusters()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(2)))->Fill(nClustersTPC);
-         //status = kFALSE;
        }
-       else if(nClustersTPC >= fMinTPCClusters) {
-         //cout<<"Secondary antiproton accepted"<<endl;
+       else if(nClustersTPC >= fProtonAnalysisBase->GetMinTPCClusters()) {
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(2)))->Fill(nClustersTPC);
        }
       }//TPC clusters
-      if(fMaxChi2PerTPCClusterFlag) {
-       if(chi2PerClusterTPC > fMaxChi2PerTPCCluster) {
+      if(fProtonAnalysisBase->IsUsedMaxChi2PerTPCCluster()) {
+       if(chi2PerClusterTPC > fProtonAnalysisBase->GetMaxChi2PerTPCCluster()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(3)))->Fill(chi2PerClusterTPC);
-         //status = kFALSE;
        }
-       else if(chi2PerClusterTPC <= fMaxChi2PerTPCCluster)
+       else if(chi2PerClusterTPC <= fProtonAnalysisBase->GetMaxChi2PerTPCCluster())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(3)))->Fill(chi2PerClusterTPC);
       }//chi2 per TPC cluster
-      if(fMaxCov11Flag) {
-       if(extCov[0] > fMaxCov11) {
+      if(fProtonAnalysisBase->IsUsedMaxCov11()) {
+       if(extCov[0] > fProtonAnalysisBase->GetMaxCov11()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(4)))->Fill(extCov[0]);
-         //status = kFALSE;
        }
-       else if(extCov[0] <= fMaxCov11)
+       else if(extCov[0] <= fProtonAnalysisBase->GetMaxCov11())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(4)))->Fill(extCov[0]);
       }//cov11
-      if(fMaxCov22Flag) {
-       if(extCov[2] > fMaxCov22) {
+      if(fProtonAnalysisBase->IsUsedMaxCov22()) {
+       if(extCov[2] > fProtonAnalysisBase->GetMaxCov22()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(5)))->Fill(extCov[2]);
-         //status = kFALSE;
        }
-       else if(extCov[2] <= fMaxCov22)
+       else if(extCov[2] <= fProtonAnalysisBase->GetMaxCov22())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(5)))->Fill(extCov[2]);
       }//cov11
-      if(fMaxCov33Flag) {
-       if(extCov[5] > fMaxCov33) {
+      if(fProtonAnalysisBase->IsUsedMaxCov33()) {
+       if(extCov[5] > fProtonAnalysisBase->GetMaxCov33()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(6)))->Fill(extCov[5]);
-         //status = kFALSE;
        }
-       else if(extCov[5] <= fMaxCov33)
+       else if(extCov[5] <= fProtonAnalysisBase->GetMaxCov33())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(6)))->Fill(extCov[5]);
       }//cov11
-      if(fMaxCov44Flag) {
-       if(extCov[9] > fMaxCov44) {
+      if(fProtonAnalysisBase->IsUsedMaxCov44()) {
+       if(extCov[9] > fProtonAnalysisBase->GetMaxCov44()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(7)))->Fill(extCov[9]);
-         //status = kFALSE;
        }
-       else if(extCov[9] <= fMaxCov44)
+       else if(extCov[9] <= fProtonAnalysisBase->GetMaxCov44())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(7)))->Fill(extCov[9]);
       }//cov11
-      if(fMaxCov55Flag) {
-       if(extCov[14] > fMaxCov55) {
+      if(fProtonAnalysisBase->IsUsedMaxCov55()) {
+       if(extCov[14] > fProtonAnalysisBase->GetMaxCov55()) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(8)))->Fill(extCov[14]);
-         //status = kFALSE;
        }
-       else if(extCov[14] <= fMaxCov55)
+       else if(extCov[14] <= fProtonAnalysisBase->GetMaxCov55())
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(8)))->Fill(extCov[14]);
       }//cov55
-      if(fMaxSigmaToVertexFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertex) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertex()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertex()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertex)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertex())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(9)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex
-      if(fMaxSigmaToVertexTPCFlag) {
-       if(GetSigmaToVertex(track) > fMaxSigmaToVertexTPC) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(GetSigmaToVertex(track));
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxSigmaToVertexTPC()) {
+       if(fProtonAnalysisBase->GetSigmaToVertex(track) > fProtonAnalysisBase->GetMaxSigmaToVertexTPC()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
        }
-       else if(GetSigmaToVertex(track) <= fMaxSigmaToVertexTPC)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(GetSigmaToVertex(track));
+       else if(fProtonAnalysisBase->GetSigmaToVertex(track) <= fProtonAnalysisBase->GetMaxSigmaToVertexTPC())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(10)))->Fill(fProtonAnalysisBase->GetSigmaToVertex(track));
       }//sigma to vertex TPC
-      if(fMaxDCAXYFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXY()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXY()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(11)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXY())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(11)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy global tracking
-      if(fMaxDCAXYTPCFlag) {
-       if(dcaXY > fMaxDCAXY) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(dcaXY);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAXYTPC()) {
+       if(TMath::Abs(dca[0]) > fProtonAnalysisBase->GetMaxDCAXYTPC()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(12)))->Fill(TMath::Abs(dca[0]));
        }
-       else if(dcaXY <= fMaxDCAXY)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(dcaXY);
+       else if(TMath::Abs(dca[0]) <= fProtonAnalysisBase->GetMaxDCAXYTPC())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(12)))->Fill(TMath::Abs(dca[0]));
       }//DCA xy TPC tracking
-      if(fMaxDCAZFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZ()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZ()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(13)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZ())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(13)))->Fill(TMath::Abs(dca[1]));
       }//DCA z global tracking
-      if(fMaxDCAZTPCFlag) {
-       if(dcaZ > fMaxDCAZ) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(14)))->Fill(dcaZ);
-         //status = kFALSE;
+      if(fProtonAnalysisBase->IsUsedMaxDCAZTPC()) {
+       if(TMath::Abs(dca[1]) > fProtonAnalysisBase->GetMaxDCAZTPC()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(14)))->Fill(TMath::Abs(dca[1]));
        }
-       else if(dcaZ <= fMaxDCAZ)
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(14)))->Fill(dcaZ);
+       else if(TMath::Abs(dca[1]) <= fProtonAnalysisBase->GetMaxDCAZTPC())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(14)))->Fill(TMath::Abs(dca[1]));
       }//DCA z TPC tracking
-      if(fMaxConstrainChi2Flag) {
+      if(fProtonAnalysisBase->IsUsedMaxConstrainChi2()) {
        if(track->GetConstrainedChi2() > 0) {
-         if(TMath::Log(track->GetConstrainedChi2()) > fMaxConstrainChi2) {
+         if(TMath::Log(track->GetConstrainedChi2()) > fProtonAnalysisBase->GetMaxConstrainChi2()) {
            ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
-           //status = kFALSE;
          }
-         else if(TMath::Log(track->GetConstrainedChi2()) <= fMaxConstrainChi2)
+         else if(TMath::Log(track->GetConstrainedChi2()) <= fProtonAnalysisBase->GetMaxConstrainChi2())
            ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(15)))->Fill(TMath::Log(track->GetConstrainedChi2()));
        }
       }//constrain chi2 - vertex
-      if(fITSRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedITSRefit()) {
        if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(16)))->Fill(0);
-       //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kITSrefit) != 0)
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(16)))->Fill(0);
       }//ITS refit
-      if(fTPCRefitFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCRefit()) {
        if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(17)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCrefit) != 0)
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(17)))->Fill(0);
       }//TPC refit
-      if(fESDpidFlag) {
+      if(fProtonAnalysisBase->IsUsedESDpid()) {
        if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(18)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kESDpid) != 0)
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(18)))->Fill(0);
       }//ESD pid
-      if(fTPCpidFlag) {
+      if(fProtonAnalysisBase->IsUsedTPCpid()) {
        if ((track->GetStatus() & AliESDtrack::kTPCpid) == 0) {
          ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(19)))->Fill(0);
-         //status = kFALSE;
        }
        else if((track->GetStatus() & AliESDtrack::kTPCpid) != 0)
          ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(19)))->Fill(0);
       }//TPC pid
-      if(fPointOnITSLayer1Flag) {
+      if(fProtonAnalysisBase->IsUsedMinTPCdEdxPoints()) {
+       if(track->GetTPCsignalN() < fProtonAnalysisBase->GetMinTPCdEdxPoints()) {
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(20)))->Fill(track->GetTPCsignalN());
+       }
+       if(track->GetTPCsignalN() >= fProtonAnalysisBase->GetMinTPCdEdxPoints())
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(20)))->Fill(track->GetTPCsignalN());
+      }//number of TPC points for the dE/dx
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer1()) {
        if(!track->HasPointOnITSLayer(0)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(20)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(21)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(0))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(20)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(21)))->Fill(0);
       }//point on SPD1
-      if(fPointOnITSLayer2Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer2()) {
        if(!track->HasPointOnITSLayer(1)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(21)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(22)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(1))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(21)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(22)))->Fill(0);
       }//point on SPD2
-      if(fPointOnITSLayer3Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer3()) {
        if(!track->HasPointOnITSLayer(2)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(22)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(23)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(2))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(22)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(23)))->Fill(0);
       }//point on SDD1
-      if(fPointOnITSLayer4Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer4()) {
        if(!track->HasPointOnITSLayer(3)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(23)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(24)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(3))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(23)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(24)))->Fill(0);
       }//point on SDD2
-      if(fPointOnITSLayer5Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer5()) {
        if(!track->HasPointOnITSLayer(4)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(24)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(25)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(4))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(24)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(25)))->Fill(0);
       }//point on SSD1
-      if(fPointOnITSLayer6Flag) {
+      if(fProtonAnalysisBase->IsUsedPointOnITSLayer6()) {
        if(!track->HasPointOnITSLayer(5)) {
-         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(25)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsRejectedList->At(26)))->Fill(0);
        }
        else if(track->HasPointOnITSLayer(5))
-         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(25)))->Fill(0);
+         ((TH1F *)(fQASecondaryAntiProtonsAcceptedList->At(26)))->Fill(0);
       }//point on SSD2
     }//secondary particle cut
   }//antiprotons
 }
 
 //____________________________________________________________________//
-Float_t AliProtonQAAnalysis::GetSigmaToVertex(AliESDtrack* esdTrack) {
-  // Calculates the number of sigma to the vertex.
-  
-  Float_t b[2];
-  Float_t bRes[2];
-  Float_t bCov[3];
-  if(fUseTPCOnly) 
-    esdTrack->GetImpactParametersTPC(b,bCov);
-  else
-    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]);
-  
-  if (bRes[0] == 0 || bRes[1] ==0) return -1;
-  
-  Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
-  
-  if (TMath::Exp(-d * d / 2) < 1e-10) return 1000;
-  
-  d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
-  
-  return d;
-}
-
-//____________________________________________________________________//
-Double_t AliProtonQAAnalysis::Rapidity(Double_t Px, Double_t Py, Double_t Pz) {
-  //returns the rapidity of the proton - to be removed
-  Double_t fMass = 9.38270000000000048e-01;
-  
-  Double_t P = TMath::Sqrt(TMath::Power(Px,2) + 
-                           TMath::Power(Py,2) + 
-                          TMath::Power(Pz,2));
-  Double_t energy = TMath::Sqrt(P*P + fMass*fMass);
-  Double_t y = -999;
-  if(energy != Pz) 
-    y = 0.5*TMath::Log((energy + Pz)/(energy - Pz));
-
-  return y;
-}
-
-//____________________________________________________________________//
-void AliProtonQAAnalysis::SetQAOn() {
+void AliProtonQAAnalysis::SetRunQAAnalysis() {
   //initializes the QA lists
   //fQAHistograms = kTRUE;
   fGlobalQAList = new TList();
+
   fQA2DList = new TList();
   fQA2DList->SetName("fQA2DList");
   fGlobalQAList->Add(fQA2DList);
@@ -1192,85 +989,987 @@ void AliProtonQAAnalysis::SetQAOn() {
 }
 
 //____________________________________________________________________//
-void AliProtonQAAnalysis::SetQAYPtBins(Int_t nbinsY, Double_t minY, Double_t maxY,
-                                     Int_t nbinsPt, Double_t minPt, Double_t maxPt) {
+void AliProtonQAAnalysis::SetQAYPtBins(Int_t nbinsY, 
+                                      Double_t minY, Double_t maxY,
+                                      Int_t nbinsPt, 
+                                      Double_t minPt, Double_t maxPt) {
   //Initializes the QA binning
   fNBinsY = nbinsY;
   fMinY = minY; fMaxY = maxY;
   fNBinsPt = nbinsPt;
   fMinPt = minPt; fMaxPt = maxPt;
   InitQA();
+  InitCutLists();
+  InitVertexQA();
   if(fRunMCAnalysis) InitMCAnalysis();
+  if(fRunEfficiencyAnalysis) InitEfficiencyAnalysis();
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::InitEfficiencyAnalysis() {
+  //Initialization of the efficiency list - reconstruction & PID efficiency
+  //Adding each monitored object in the list
+  fEfficiencyList = new TList();
+
+  //MC primary protons and antiprotons for the reconstruction efficiency
+  TH2D *gHistMCYPtProtons = new TH2D("gHistMCYPtProtons",
+                                    ";;P_{T} [GeV/c]",
+                                    fNBinsY,fMinY,fMaxY,
+                                    fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtProtons->GetXaxis()->SetTitle("y");
+  gHistMCYPtProtons->SetStats(kTRUE);
+  gHistMCYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtProtons);
+  TH2D *gHistMCYPtAntiProtons = new TH2D("gHistMCYPtAntiProtons",
+                                        ";y;P_{T} [GeV/c]",
+                                        fNBinsY,fMinY,fMaxY,
+                                        fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtAntiProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtAntiProtons->GetXaxis()->SetTitle("y");
+  gHistMCYPtAntiProtons->SetStats(kTRUE);
+  gHistMCYPtAntiProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtAntiProtons);
+
+  //MC secondary protons and antiprotons that come from weak decay for the reconstruction efficiency
+  TH2D *gHistMCYPtProtonsFromWeak = new TH2D("gHistMCYPtProtonsFromWeak",
+                                            ";;P_{T} [GeV/c]",
+                                            fNBinsY,fMinY,fMaxY,
+                                            fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitle("y");
+  gHistMCYPtProtonsFromWeak->SetStats(kTRUE);
+  gHistMCYPtProtonsFromWeak->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtProtonsFromWeak);
+  TH2D *gHistMCYPtAntiProtonsFromWeak = new TH2D("gHistMCYPtAntiProtonsFromWeak",
+                                                ";y;P_{T} [GeV/c]",
+                                                fNBinsY,fMinY,fMaxY,
+                                                fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("y");
+  gHistMCYPtAntiProtonsFromWeak->SetStats(kTRUE);
+  gHistMCYPtAntiProtonsFromWeak->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtAntiProtonsFromWeak);
+
+  //MC secondary protons and antiprotons that come from hadronic interactions for the reconstruction efficiency
+  TH2D *gHistMCYPtProtonsFromHadronic = new TH2D("gHistMCYPtProtonsFromHadronic",
+                                                ";;P_{T} [GeV/c]",
+                                                fNBinsY,fMinY,fMaxY,
+                                                fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitle("y");
+  gHistMCYPtProtonsFromHadronic->SetStats(kTRUE);
+  gHistMCYPtProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtProtonsFromHadronic);
+  TH2D *gHistMCYPtAntiProtonsFromHadronic = new TH2D("gHistMCYPtAntiProtonsFromHadronic",
+                                                    ";y;P_{T} [GeV/c]",
+                                                    fNBinsY,fMinY,fMaxY,
+                                                    fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("y");
+  gHistMCYPtAntiProtonsFromHadronic->SetStats(kTRUE);
+  gHistMCYPtAntiProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistMCYPtAntiProtonsFromHadronic);
+  
+  //ESD primary protons and antiprotons for the reconstruction efficiency
+  TH2D *gHistESDYPtProtons = new TH2D("gHistESDYPtProtons",
+                                     ";;P_{T} [GeV/c]",
+                                     fNBinsY,fMinY,fMaxY,
+                                     fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtProtons->GetXaxis()->SetTitle("y");
+  gHistESDYPtProtons->SetStats(kTRUE);
+  gHistESDYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtProtons);
+  TH2D *gHistESDYPtAntiProtons = new TH2D("gHistESDYPtAntiProtons",
+                                         ";;P_{T} [GeV/c]",
+                                         fNBinsY,fMinY,fMaxY,
+                                         fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtAntiProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtAntiProtons->GetXaxis()->SetTitle("y");
+  gHistESDYPtAntiProtons->SetStats(kTRUE);
+  gHistESDYPtAntiProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtAntiProtons);
+
+  //ESD (anti)protons from weak decays for the reconstruction efficiency
+  TH2D *gHistESDYPtProtonsFromWeak = new TH2D("gHistESDYPtProtonsFromWeak",
+                                             ";;P_{T} [GeV/c]",
+                                             fNBinsY,fMinY,fMaxY,
+                                             fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitle("y");
+  gHistESDYPtProtonsFromWeak->SetStats(kTRUE);
+  gHistESDYPtProtonsFromWeak->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtProtonsFromWeak);
+  TH2D *gHistESDYPtAntiProtonsFromWeak = new TH2D("gHistESDYPtAntiProtonsFromWeak",
+                                                 ";;P_{T} [GeV/c]",
+                                                 fNBinsY,fMinY,fMaxY,
+                                                 fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitle("y");
+  gHistESDYPtAntiProtonsFromWeak->SetStats(kTRUE);
+  gHistESDYPtAntiProtonsFromWeak->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtAntiProtonsFromWeak);
+
+  //ESD (anti)protons from hadronic interactions for the reconstruction efficiency
+  TH2D *gHistESDYPtProtonsFromHadronic = new TH2D("gHistESDYPtProtonsFromHadronic",
+                                                 ";;P_{T} [GeV/c]",
+                                                 fNBinsY,fMinY,fMaxY,
+                                                 fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitle("y");
+  gHistESDYPtProtonsFromHadronic->SetStats(kTRUE);
+  gHistESDYPtProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtProtonsFromHadronic);
+  TH2D *gHistESDYPtAntiProtonsFromHadronic = new TH2D("gHistESDYPtAntiProtonsFromHadronic",
+                                                     ";;P_{T} [GeV/c]",
+                                                     fNBinsY,fMinY,fMaxY,
+                                                     fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitle("y");
+  gHistESDYPtAntiProtonsFromHadronic->SetStats(kTRUE);
+  gHistESDYPtAntiProtonsFromHadronic->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDYPtAntiProtonsFromHadronic);
+  
+  
+  //ESD reconstructed tracks that were initially protons for the PID efficiency
+  TH3D *gHistESDInitYPtProtons = new TH3D("gHistESDInitYPtProtons",
+                                         ";;P_{T} [GeV/c];N_{points}",
+                                         fNBinsY,fMinY,fMaxY,
+                                         fNBinsPt,fMinPt,fMaxPt,
+                                         100,0,200);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDInitYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDInitYPtProtons->GetXaxis()->SetTitle("y");
+  gHistESDInitYPtProtons->SetStats(kTRUE);
+  gHistESDInitYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDInitYPtProtons);
+  
+  //ESD reconstructed tracks that were initially protons and were identified as protons for the PID efficiency
+  TH3D *gHistESDIdYPtProtons = new TH3D("gHistESDIdYPtProtons",
+                                       ";;P_{T} [GeV/c];N_{points}",
+                                       fNBinsY,fMinY,fMaxY,
+                                       fNBinsPt,fMinPt,fMaxPt,
+                                       100,0,200);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDIdYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDIdYPtProtons->GetXaxis()->SetTitle("y");
+  gHistESDIdYPtProtons->SetStats(kTRUE);
+  gHistESDIdYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDIdYPtProtons);
+  //ESD reconstructed tracks that were identified as protons for the PID contamination
+  TH3D *gHistESDRecIdYPtProtons = new TH3D("gHistESDRecIdYPtProtons",
+                                          ";;P_{T} [GeV/c];N_{points}",
+                                          fNBinsY,fMinY,fMaxY,
+                                          fNBinsPt,fMinPt,fMaxPt,
+                                          100,0,200);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDRecIdYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDRecIdYPtProtons->GetXaxis()->SetTitle("y");
+  gHistESDRecIdYPtProtons->SetStats(kTRUE);
+  gHistESDRecIdYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDRecIdYPtProtons);
+
+  //ESD reconstructed tracks that were identified as protons but were initially not protons for the PID contamination
+  TH3D *gHistESDContamYPtProtons = new TH3D("gHistESDContamYPtProtons",
+                                           ";;P_{T} [GeV/c];N_{points}",
+                                           fNBinsY,fMinY,fMaxY,
+                                           fNBinsPt,fMinPt,fMaxPt,
+                                           100,0,200);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistESDContamYPtProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistESDContamYPtProtons->GetXaxis()->SetTitle("y");
+  gHistESDContamYPtProtons->SetStats(kTRUE);
+  gHistESDContamYPtProtons->GetXaxis()->SetTitleColor(1);
+  fEfficiencyList->Add(gHistESDContamYPtProtons);
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::InitCutLists() {
+  //Initialization of the cut lists
+  //Adding each monitored object in each list
+
+  //Accepted cut list
+  fAcceptedCutList = new TList();
+  TH1F *gPrimaryProtonsClustersOnITSLayers = new TH1F("gPrimaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gPrimaryProtonsClustersOnITSLayers);
+  TH1F *gPrimaryAntiProtonsClustersOnITSLayers = new TH1F("gPrimaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsClustersOnITSLayers);
+  TH1F *gSecondaryProtonsClustersOnITSLayers = new TH1F("gSecondaryProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gSecondaryProtonsClustersOnITSLayers);
+  TH1F *gSecondaryAntiProtonsClustersOnITSLayers = new TH1F("gSecondaryAntiProtonsClustersOnITSLayers",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsClustersOnITSLayers);
+
+  TH1F *gPrimaryProtonsNClustersITS = new TH1F("gPrimaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gPrimaryProtonsNClustersITS);
+  TH1F *gPrimaryAntiProtonsNClustersITS = new TH1F("gPrimaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsNClustersITS);
+  TH1F *gSecondaryProtonsNClustersITS = new TH1F("gSecondaryProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gSecondaryProtonsNClustersITS);
+  TH1F *gSecondaryAntiProtonsNClustersITS = new TH1F("gSecondaryAntiProtonsNClustersITS",";ITS Layer;Entries",6,0.5,6.5);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsNClustersITS);
+
+  TH1F *gPrimaryProtonsChi2PerClusterITS = new TH1F("gPrimaryProtonsChi2PerClusterITS",
+                                                   ";x^{2}/N_{clusters} (ITS);Entries",
+                                                   100,0,20);
+  fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterITS);
+  TH1F *gPrimaryAntiProtonsChi2PerClusterITS = new TH1F("gPrimaryAntiProtonsChi2PerClusterITS",
+                                                       ";x^{2}/N_{clusters} (ITS);Entries",
+                                                       100,0,20);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterITS);
+  TH1F *gSecondaryProtonsChi2PerClusterITS = new TH1F("gSecondaryProtonsChi2PerClusterITS",
+                                                     ";x^{2}/N_{clusters} (ITS);Entries",
+                                                     100,0,20);
+  fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterITS);
+  TH1F *gSecondaryAntiProtonsChi2PerClusterITS = new TH1F("gSecondaryAntiProtonsChi2PerClusterITS",
+                                                         ";x^{2}/N_{clusters} (ITS);Entries",
+                                                         100,0,20);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterITS);
+
+  TH1F *gPrimaryProtonsConstrainChi2 = new TH1F("gPrimaryProtonsConstrainChi2",
+                                               ";Log_{10}(#chi^{2});Entries",
+                                               100,-10,10);
+  fAcceptedCutList->Add(gPrimaryProtonsConstrainChi2);
+  TH1F *gPrimaryAntiProtonsConstrainChi2 = new TH1F("gPrimaryAntiProtonsConstrainChi2",
+                                                   ";Log_{10}(#chi^{2});Entries",
+                                                   100,-10,10);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsConstrainChi2);
+  TH1F *gSecondaryProtonsConstrainChi2 = new TH1F("gSecondaryProtonsConstrainChi2",
+                                                 ";Log_{10}(#chi^{2});Entries",
+                                                 100,-10,10);
+  fAcceptedCutList->Add(gSecondaryProtonsConstrainChi2);
+  TH1F *gSecondaryAntiProtonsConstrainChi2 = new TH1F("gSecondaryAntiProtonsConstrainChi2",
+                                                     ";Log_{10}(#chi^{2});Entries",
+                                                     100,-10,10);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsConstrainChi2);
+
+  TH1F *gPrimaryProtonsTPCClusters = new TH1F("gPrimaryProtonsTPCClusters",
+                                             ";N_{clusters} (TPC);Entries",
+                                             100,0,200);
+  fAcceptedCutList->Add(gPrimaryProtonsTPCClusters);
+  TH1F *gPrimaryAntiProtonsTPCClusters = new TH1F("gPrimaryAntiProtonsTPCClusters",
+                                                 ";N_{clusters} (TPC);Entries",
+                                                 100,0,200);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsTPCClusters);
+  TH1F *gSecondaryProtonsTPCClusters = new TH1F("gSecondaryProtonsTPCClusters",
+                                               ";N_{clusters} (TPC);Entries",
+                                               100,0,200);
+  fAcceptedCutList->Add(gSecondaryProtonsTPCClusters);
+  TH1F *gSecondaryAntiProtonsTPCClusters = new TH1F("gSecondaryAntiProtonsTPCClusters",
+                                                   ";N_{clusters} (TPC);Entries",
+                                                   100,0,200);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsTPCClusters);
+
+  TH1F *gPrimaryProtonsChi2PerClusterTPC = new TH1F("gPrimaryProtonsChi2PerClusterTPC",
+                                                   ";x^{2}/N_{clusters} (TPC);Entries",
+                                                   100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsChi2PerClusterTPC);
+  TH1F *gPrimaryAntiProtonsChi2PerClusterTPC = new TH1F("gPrimaryAntiProtonsChi2PerClusterTPC",
+                                                       ";x^{2}/N_{clusters} (TPC);Entries",
+                                                       100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsChi2PerClusterTPC);
+  TH1F *gSecondaryProtonsChi2PerClusterTPC = new TH1F("gSecondaryProtonsChi2PerClusterTPC",
+                                                     ";x^{2}/N_{clusters} (TPC);Entries",
+                                                     100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsChi2PerClusterTPC);
+  TH1F *gSecondaryAntiProtonsChi2PerClusterTPC = new TH1F("gSecondaryAntiProtonsChi2PerClusterTPC",
+                                                         ";x^{2}/N_{clusters} (TPC);Entries",
+                                                         100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsChi2PerClusterTPC);
+
+  TH1F *gPrimaryProtonsExtCov11 = new TH1F("gPrimaryProtonsExtCov11",
+                                          ";#sigma_{y} [cm];Entries",
+                                          100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsExtCov11);
+  TH1F *gPrimaryAntiProtonsExtCov11 = new TH1F("gPrimaryAntiProtonsExtCov11",
+                                              ";#sigma_{y} [cm];Entries",
+                                              100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov11);
+  TH1F *gSecondaryProtonsExtCov11 = new TH1F("gSecondaryProtonsExtCov11",
+                                            ";#sigma_{y} [cm];Entries",
+                                            100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsExtCov11);
+  TH1F *gSecondaryAntiProtonsExtCov11 = new TH1F("gSecondaryAntiProtonsExtCov11",
+                                                ";#sigma_{y} [cm];Entries",
+                                                100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov11);
+
+
+  TH1F *gPrimaryProtonsExtCov22 = new TH1F("gPrimaryProtonsExtCov22",
+                                          ";#sigma_{z} [cm];Entries",
+                                          100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsExtCov22);
+  TH1F *gPrimaryAntiProtonsExtCov22 = new TH1F("gPrimaryAntiProtonsExtCov22",
+                                              ";#sigma_{z} [cm];Entries",
+                                              100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov22);
+  TH1F *gSecondaryProtonsExtCov22 = new TH1F("gSecondaryProtonsExtCov22",
+                                            ";#sigma_{z} [cm];Entries",
+                                            100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsExtCov22);
+  TH1F *gSecondaryAntiProtonsExtCov22 = new TH1F("gSecondaryAntiProtonsExtCov22",
+                                                ";#sigma_{z} [cm];Entries",
+                                                100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov22);
+
+
+  TH1F *gPrimaryProtonsExtCov33 = new TH1F("gPrimaryProtonsExtCov33",
+                                          ";#sigma_{sin(#phi)};Entries",
+                                          100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsExtCov33);
+  TH1F *gPrimaryAntiProtonsExtCov33 = new TH1F("gPrimaryAntiProtonsExtCov33",
+                                              ";#sigma_{sin(#phi)};Entries",
+                                              100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov33);
+  TH1F *gSecondaryProtonsExtCov33 = new TH1F("gSecondaryProtonsExtCov33",
+                                            ";#sigma_{sin(#phi)};Entries",
+                                            100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsExtCov33);
+  TH1F *gSecondaryAntiProtonsExtCov33 = new TH1F("gSecondaryAntiProtonsExtCov33",
+                                                ";#sigma_{sin(#phi)};Entries",
+                                                100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov33);
+
+
+  TH1F *gPrimaryProtonsExtCov44 = new TH1F("gPrimaryProtonsExtCov44",
+                                          ";#sigma_{tan(#lambda)};Entries",
+                                          100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsExtCov44);
+  TH1F *gPrimaryAntiProtonsExtCov44 = new TH1F("gPrimaryAntiProtonsExtCov44",
+                                              ";#sigma_{tan(#lambda)};Entries",
+                                              100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov44);
+  TH1F *gSecondaryProtonsExtCov44 = new TH1F("gSecondaryProtonsExtCov44",
+                                            ";#sigma_{tan(#lambda)};Entries",
+                                            100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsExtCov44);
+  TH1F *gSecondaryAntiProtonsExtCov44 = new TH1F("gSecondaryAntiProtonsExtCov44",
+                                                ";#sigma_{tan(#lambda)};Entries",
+                                                100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov44);
+
+
+  TH1F *gPrimaryProtonsExtCov55 = new TH1F("gPrimaryProtonsExtCov55",
+                                          ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
+                                          100,0,4);
+  fAcceptedCutList->Add(gPrimaryProtonsExtCov55);
+  TH1F *gPrimaryAntiProtonsExtCov55 = new TH1F("gPrimaryAntiProtonsExtCov55",
+                                              ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
+                                              100,0,4);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsExtCov55);
+  TH1F *gSecondaryProtonsExtCov55 = new TH1F("gSecondaryProtonsExtCov55",
+                                            ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
+                                            100,0,4);
+  fAcceptedCutList->Add(gSecondaryProtonsExtCov55);
+  TH1F *gSecondaryAntiProtonsExtCov55 = new TH1F("gSecondaryAntiProtonsExtCov55",
+                                                ";#sigma_{1/P_{T}} [GeV/c]^{-1};Entries",
+                                                100,0,4);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsExtCov55);
+  //eta-phi-Nclusters
+  TH3D *gHistEtaPhiNClustersPrimaryProtonsPass = new TH3D("gHistEtaPhiNClustersPrimaryProtonsPass",
+                                                         "Accepted primary protons;#eta;#phi;N_{clusters}(TPC)",
+                                                         fNBinsY,fMinY,fMaxY,
+                                                         100,0,360,
+                                                         100,0,200);
+  gHistEtaPhiNClustersPrimaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiNClustersPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiNClustersPrimaryProtonsPass);//eta-phi of primary accepted ESD protons
+  TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsPass = new TH3D("gHistEtaPhiNClustersPrimaryAntiProtonsPass",
+                                                             "Accepted primary antiprotons;#eta;#phi;N_{clusters}(TPC)",
+                                                             fNBinsY,fMinY,fMaxY,
+                                                             100,0,360,
+                                                             100,0,200);
+  gHistEtaPhiNClustersPrimaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiNClustersPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiNClustersPrimaryAntiProtonsPass);//eta-phi of primary accepted ESD antiprotons
+  TH3D *gHistEtaPhiNClustersSecondaryProtonsPass = new TH3D("gHistEtaPhiNClustersSecondaryProtonsPass",
+                                                           "Accepted secondary protons;#eta;#phi;N_{clusters}(TPC)",
+                                                           fNBinsY,fMinY,fMaxY,
+                                                           100,0,360,
+                                                           100,0,200);
+  gHistEtaPhiNClustersSecondaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiNClustersSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiNClustersSecondaryProtonsPass);//eta-phi of secondary accepted ESD protons
+  TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsPass = new TH3D("gHistEtaPhiNClustersSecondaryAntiProtonsPass",
+                                                               "Accepted secondary antiprotons;#eta;#phi;N_{clusters}(TPC)",
+                                                               fNBinsY,fMinY,fMaxY,
+                                                               100,0,360,
+                                                               100,0,200);
+  gHistEtaPhiNClustersSecondaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiNClustersSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiNClustersSecondaryAntiProtonsPass);//eta-phi of secondary accepted ESD antiprotons
+  //eta-phi-chi^2 per TPC cluster
+  TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass = new TH3D("gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass",
+                                                                 "Accepted primary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                 fNBinsY,fMinY,fMaxY,
+                                                                 100,0,360,
+                                                                 100,0,4);
+  gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsPass);//eta-phi of primary accepted ESD protons
+  TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass = new TH3D("gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass",
+                                                                     "Accepted primary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                     fNBinsY,fMinY,fMaxY,
+                                                                     100,0,360,
+                                                                     100,0,4);
+  gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsPass);//eta-phi of primary accepted ESD antiprotons
+  TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass = new TH3D("gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass",
+                                                                   "Accepted secondary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                   fNBinsY,fMinY,fMaxY,
+                                                                   100,0,360,
+                                                                   100,0,4);
+  gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsPass);//eta-phi of secondary accepted ESD protons
+  TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass = new TH3D("gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass",
+                                                                       "Accepted secondary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                       fNBinsY,fMinY,fMaxY,
+                                                                       100,0,360,
+                                                                       100,0,4);
+  gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsPass);//eta-phi of secondary accepted ESD antiprotons
+  //eta-phi-number of TPC points for the dE/dx
+  TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass = new TH3D("gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass",
+                                                                 "Accepted primary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                 fNBinsY,fMinY,fMaxY,
+                                                                 100,0,360,
+                                                                 100,0,200);
+  gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsPass);//eta-phi of primary accepted ESD protons
+  TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass = new TH3D("gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass",
+                                                                     "Accepted primary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                     fNBinsY,fMinY,fMaxY,
+                                                                     100,0,360,
+                                                                     100,0,200);
+  gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsPass);//eta-phi of primary accepted ESD antiprotons
+  TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass = new TH3D("gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass",
+                                                                   "Accepted secondary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                   fNBinsY,fMinY,fMaxY,
+                                                                   100,0,360,
+                                                                   100,0,200);
+  gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsPass);//eta-phi of secondary accepted ESD protons
+  TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass = new TH3D("gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass",
+                                                                       "Accepted secondary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                       fNBinsY,fMinY,fMaxY,
+                                                                       100,0,360,
+                                                                       100,0,200);
+  gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
+  fAcceptedCutList->Add(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsPass);//eta-phi of secondary accepted ESD antiprotons
+
+  TH1F *gPrimaryProtonsNPointsTPCdEdx = new TH1F("gPrimaryProtonsNPointsTPCdEdx",
+                                             ";N_{points} (TPC-dE/dx);Entries",
+                                             100,0,200);
+  fAcceptedCutList->Add(gPrimaryProtonsNPointsTPCdEdx);
+  TH1F *gPrimaryAntiProtonsNPointsTPCdEdx = new TH1F("gPrimaryAntiProtonsNPointsTPCdEdx",
+                                                 ";N_{points} (TPC-dE/dx);Entries",
+                                                 100,0,200);
+  fAcceptedCutList->Add(gPrimaryAntiProtonsNPointsTPCdEdx);
+  TH1F *gSecondaryProtonsNPointsTPCdEdx = new TH1F("gSecondaryProtonsNPointsTPCdEdx",
+                                               ";N_{points} (TPC-dE/dx);Entries",
+                                               100,0,200);
+  fAcceptedCutList->Add(gSecondaryProtonsNPointsTPCdEdx);
+  TH1F *gSecondaryAntiProtonsNPointsTPCdEdx = new TH1F("gSecondaryAntiProtonsNPointsTPCdEdx",
+                                                   ";N_{points} (TPC-dE/dx);Entries",
+                                                   100,0,200);
+  fAcceptedCutList->Add(gSecondaryAntiProtonsNPointsTPCdEdx);
+  
+  //Rejected cut list
+  fRejectedCutList = new TList();
+  //eta-phi-Nclusters
+  TH3D *gHistEtaPhiNClustersPrimaryProtonsReject = new TH3D("gHistEtaPhiNClustersPrimaryProtonsReject",
+                                                         "Rejected primary protons;#eta;#phi;N_{clusters}(TPC)",
+                                                         fNBinsY,fMinY,fMaxY,
+                                                         100,0,360,
+                                                         100,0,200);
+  gHistEtaPhiNClustersPrimaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiNClustersPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiNClustersPrimaryProtonsReject);//eta-phi of primary rejected ESD protons
+  TH3D *gHistEtaPhiNClustersPrimaryAntiProtonsReject = new TH3D("gHistEtaPhiNClustersPrimaryAntiProtonsReject",
+                                                             "Rejected primary antiprotons;#eta;#phi;N_{clusters}(TPC)",
+                                                             fNBinsY,fMinY,fMaxY,
+                                                             100,0,360,
+                                                             100,0,200);
+  gHistEtaPhiNClustersPrimaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiNClustersPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiNClustersPrimaryAntiProtonsReject);//eta-phi of primary rejected ESD antiprotons
+  TH3D *gHistEtaPhiNClustersSecondaryProtonsReject = new TH3D("gHistEtaPhiNClustersSecondaryProtonsReject",
+                                                           "Rejected secondary protons;#eta;#phi;N_{clusters}(TPC)",
+                                                           fNBinsY,fMinY,fMaxY,
+                                                           100,0,360,
+                                                           100,0,200);
+  gHistEtaPhiNClustersSecondaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiNClustersSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiNClustersSecondaryProtonsReject);//eta-phi of secondary rejected ESD protons
+  TH3D *gHistEtaPhiNClustersSecondaryAntiProtonsReject = new TH3D("gHistEtaPhiNClustersSecondaryAntiProtonsReject",
+                                                               "Rejected secondary antiprotons;#eta;#phi;N_{clusters}(TPC)",
+                                                               fNBinsY,fMinY,fMaxY,
+                                                               100,0,360,
+                                                               100,0,200);
+  gHistEtaPhiNClustersSecondaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiNClustersSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiNClustersSecondaryAntiProtonsReject);//eta-phi of secondary rejected ESD antiprotons
+  //eta-phi-chi^2 per TPC cluster
+  TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject = new TH3D("gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject",
+                                                                 "Rejected primary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                 fNBinsY,fMinY,fMaxY,
+                                                                 100,0,360,
+                                                                 100,0,4);
+  gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiChi2PerTPCClusterPrimaryProtonsReject);//eta-phi of primary rejected ESD protons
+  TH3D *gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject = new TH3D("gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject",
+                                                                     "Rejected primary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                     fNBinsY,fMinY,fMaxY,
+                                                                     100,0,360,
+                                                                     100,0,4);
+  gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiChi2PerTPCClusterPrimaryAntiProtonsReject);//eta-phi of primary rejected ESD antiprotons
+  TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject = new TH3D("gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject",
+                                                                   "Rejected secondary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                   fNBinsY,fMinY,fMaxY,
+                                                                   100,0,360,
+                                                                   100,0,4);
+  gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiChi2PerTPCClusterSecondaryProtonsReject);//eta-phi of secondary rejected ESD protons
+  TH3D *gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject = new TH3D("gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject",
+                                                                       "Rejected secondary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                       fNBinsY,fMinY,fMaxY,
+                                                                       100,0,360,
+                                                                       100,0,4);
+  gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiChi2PerTPCClusterSecondaryAntiProtonsReject);//eta-phi of secondary rejected ESD antiprotons
+  //eta-phi-number of TPC points for the dE/dx
+  TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject = new TH3D("gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject",
+                                                                 "Rejected primary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                 fNBinsY,fMinY,fMaxY,
+                                                                 100,0,360,
+                                                                 100,0,200);
+  gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiTPCdEdxNPointsPrimaryProtonsReject);//eta-phi of primary rejected ESD protons
+  TH3D *gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject = new TH3D("gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject",
+                                                                     "Rejected primary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                     fNBinsY,fMinY,fMaxY,
+                                                                     100,0,360,
+                                                                     100,0,200);
+  gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiTPCdEdxNPointsPrimaryAntiProtonsReject);//eta-phi of primary rejected ESD antiprotons
+  TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject = new TH3D("gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject",
+                                                                   "Rejected secondary protons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                   fNBinsY,fMinY,fMaxY,
+                                                                   100,0,360,
+                                                                   100,0,200);
+  gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiTPCdEdxNPointsSecondaryProtonsReject);//eta-phi of secondary rejected ESD protons
+  TH3D *gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject = new TH3D("gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject",
+                                                                       "Rejected secondary antiprotons;#eta;#phi;#chi^{2}/N_{clusters}(TPC)",
+                                                                       fNBinsY,fMinY,fMaxY,
+                                                                       100,0,360,
+                                                                       100,0,200);
+  gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject->SetStats(kTRUE);
+  gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
+  fRejectedCutList->Add(gHistEtaPhiTPCdEdxNPointsSecondaryAntiProtonsReject);//eta-phi of secondary rejected ESD antiprotons
+
+  //DCA list
+  fAcceptedDCAList = new TList();
+  TH1F *gPrimaryProtonsDCAXY = new TH1F("gPrimaryProtonsDCAXY",
+                                       ";DCA_{xy} [cm];Entries",
+                                       100,0,20);
+  fAcceptedDCAList->Add(gPrimaryProtonsDCAXY);
+  TH1F *gPrimaryAntiProtonsDCAXY = new TH1F("gPrimaryAntiProtonsDCAXY",
+                                           ";DCA_{xy} [cm];Entries",
+                                           100,0,20);
+  fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAXY);
+  TH1F *gSecondaryProtonsDCAXY = new TH1F("gSecondaryProtonsDCAXY",
+                                         ";DCA_{xy} [cm];Entries",
+                                         100,0,20);
+  fAcceptedDCAList->Add(gSecondaryProtonsDCAXY);
+  TH1F *gSecondaryAntiProtonsDCAXY = new TH1F("gSecondaryAntiProtonsDCAXY",
+                                             ";DCA_{xy} [cm];Entries",
+                                             100,0,20);
+
+  fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAXY);
+  TH1F *gPrimaryProtonsDCAZ = new TH1F("gPrimaryProtonsDCAZ",
+                                      ";DCA_{z} [cm];Entries",
+                                      100,0,20);
+  fAcceptedDCAList->Add(gPrimaryProtonsDCAZ);
+  TH1F *gPrimaryAntiProtonsDCAZ = new TH1F("gPrimaryAntiProtonsDCAZ",
+                                          ";DCA_{z} [cm];Entries",
+                                          100,0,20);
+  fAcceptedDCAList->Add(gPrimaryAntiProtonsDCAZ);
+  TH1F *gSecondaryProtonsDCAZ = new TH1F("gSecondaryProtonsDCAZ",
+                                        ";DCA_{z} [cm];Entries",
+                                        100,0,20);
+  fAcceptedDCAList->Add(gSecondaryProtonsDCAZ);
+  TH1F *gSecondaryAntiProtonsDCAZ = new TH1F("gSecondaryAntiProtonsDCAZ",
+                                            ";DCA_{z} [cm];Entries",
+                                            100,0,20);
+  fAcceptedDCAList->Add(gSecondaryAntiProtonsDCAZ);
+
+  TH1F *gPrimaryProtonsSigmaToVertex = new TH1F("gPrimaryProtonsSigmaToVertex",
+                                               ";#sigma_{Vertex};Entries",
+                                               100,0,10);
+  fAcceptedDCAList->Add(gPrimaryProtonsSigmaToVertex);
+  TH1F *gPrimaryAntiProtonsSigmaToVertex = new TH1F("gPrimaryAntiProtonsSigmaToVertex",
+                                                   ";#sigma_{Vertex};Entries",
+                                                   100,0,10);
+  fAcceptedDCAList->Add(gPrimaryAntiProtonsSigmaToVertex);
+  TH1F *gSecondaryProtonsSigmaToVertex = new TH1F("gSecondaryProtonsSigmaToVertex",
+                                                 ";#sigma_{Vertex};Entries",
+                                                 100,0,10);
+  fAcceptedDCAList->Add(gSecondaryProtonsSigmaToVertex);
+  TH1F *gSecondaryAntiProtonsSigmaToVertex = new TH1F("gSecondaryAntiProtonsSigmaToVertex",
+                                                     ";#sigma_{Vertex};Entries",
+                                                     100,0,10);
+  fAcceptedDCAList->Add(gSecondaryAntiProtonsSigmaToVertex);
+
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::InitVertexQA() {
+  //Initializes the Vertex QA histograms
+  fQAVertexList = new TList();
+  fQAVertexList->SetName("fQAVertexList");
+
+  //Gen. multiplicity bins
+  //Float_t xBins[24] = {0,1,2,4,6,8,10,15,20,30,40,50,75,100,
+  //200,300,400,500,750,1000,1500,2000,2500,3000};
+  //MC primary multiplicity (vertex efficiency calculation)
+  TH1F *gHistMCPrimaryVz = new TH1F("gHistMCPrimaryVz",
+                                   ";V_{z} (gen.) [cm];Entries",
+                                   40,-20.,20.);
+  fQAVertexList->Add(gHistMCPrimaryVz);
+  //TH1F *gHistMCPrimaryMultiplicity = new TH1F("gHistMCPrimaryMultiplicity",
+  //";N_{prim. gen.};Entries",
+  //23,xBins);
+  //fQAVertexList->Add(gHistMCPrimaryMultiplicity);
+  
+  //TPC
+  TH1F *gHistTPCVz = new TH1F("gHistTPCVz",
+                             ";V_{z} (gen.) [cm];Entries",
+                             40,-20.,20.);
+  fQAVertexList->Add(gHistTPCVz);
+  //TH1F *gHistMCPrimaryMultiplicityTPC = new TH1F("gHistMCPrimaryMultiplicityTPC",
+  //"Vertex TPC;N_{prim. gen.};Entries",
+  //23,xBins);
+  //fQAVertexList->Add(gHistMCPrimaryMultiplicityTPC);
+  TH2F *gHistTPCESDVxN = new TH2F("gHistTPCESDVxN",
+                                "Primary vertex TPC;V_{x} [cm];N_{contributors}",
+                                100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistTPCESDVxN);
+  TH2F *gHistTPCESDVyN = new TH2F("gHistTPCESDVyN",
+                                "Primary vertex TPC;V_{y} [cm];N_{contributors}",
+                                100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistTPCESDVyN);
+  TH2F *gHistTPCESDVzN = new TH2F("gHistTPCESDVzN",
+                                "Primary vertex TPC;V_{z} [cm];N_{contributors}",
+                                100,-20.,20.,1000,0,5000);
+  fQAVertexList->Add(gHistTPCESDVzN);
+  TH1F *gHistTPCDiffVx = new TH1F("gHistTPCDiffVx",
+                                 ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistTPCDiffVx);
+  TH1F *gHistTPCDiffVy = new TH1F("gHistTPCDiffVy",
+                                 ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistTPCDiffVy);
+  TH1F *gHistTPCDiffVz = new TH1F("gHistTPCDiffVz",
+                                 ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistTPCDiffVz);
+  TH1F *gHistTPCResolutionVx = new TH1F("gHistTPCResolutionVx",
+                                       ";#sigma_{x} [#mu m];Entries",
+                                       100,0.,1000000.);
+  fQAVertexList->Add(gHistTPCResolutionVx);
+  TH1F *gHistTPCResolutionVy = new TH1F("gHistTPCResolutionVy",
+                                       ";#sigma_{y} [#mu m];Entries",
+                                       100,0.,1000000.);
+  fQAVertexList->Add(gHistTPCResolutionVy);
+  TH1F *gHistTPCResolutionVz = new TH1F("gHistTPCResolutionVz",
+                                       ";#sigma_{z} [#mu m];Entries",
+                                       100,0.,6000.);
+  fQAVertexList->Add(gHistTPCResolutionVz);
+  
+  //SPD
+  TH1F *gHistSPDVz = new TH1F("gHistSPDVz",
+                             ";V_{z} (gen.) [cm];Entries",
+                             40,-20.,20.);
+  fQAVertexList->Add(gHistSPDVz);
+  //TH1F *gHistMCPrimaryMultiplicitySPD = new TH1F("gHistMCPrimaryMultiplicitySPD",
+  //"Vertex SPD;N_{prim. gen.};Entries",
+  //23,xBins);
+  //fQAVertexList->Add(gHistMCPrimaryMultiplicitySPD);
+  TH2F *gHistSPDESDVxN = new TH2F("gHistSPDESDVxN",
+                                "Primary vertex SPD;V_{x} [cm];N_{contributors}",
+                                100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistSPDESDVxN);
+  TH2F *gHistSPDESDVyN = new TH2F("gHistSPDESDVyN",
+                                "Primary vertex SPD;V_{y} [cm];N_{contributors}",
+                                100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistSPDESDVyN);
+  TH2F *gHistSPDESDVzN = new TH2F("gHistSPDESDVzN",
+                                "Primary vertex SPD;V_{z} [cm];N_{contributors}",
+                                100,-20.,20.,1000,0,5000);
+  fQAVertexList->Add(gHistSPDESDVzN);
+  TH1F *gHistSPDDiffVx = new TH1F("gHistSPDDiffVx",
+                                 ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistSPDDiffVx);
+  TH1F *gHistSPDDiffVy = new TH1F("gHistSPDDiffVy",
+                                 ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistSPDDiffVy);
+  TH1F *gHistSPDDiffVz = new TH1F("gHistSPDDiffVz",
+                                 ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
+                                 100,-10000.,10000.);
+  fQAVertexList->Add(gHistSPDDiffVz);
+  TH1F *gHistSPDResolutionVx = new TH1F("gHistSPDResolutionVx",
+                                       ";#sigma_{x} [#mu m];Entries",
+                                       100,0.,1000.);
+  fQAVertexList->Add(gHistSPDResolutionVx);
+  TH1F *gHistSPDResolutionVy = new TH1F("gHistSPDResolutionVy",
+                                       ";#sigma_{y} [#mu m];Entries",
+                                       100,0.,1000.);
+  fQAVertexList->Add(gHistSPDResolutionVy);
+  TH1F *gHistSPDResolutionVz = new TH1F("gHistSPDResolutionVz",
+                                       ";#sigma_{z} [#mu m];Entries",
+                                       100,0.,500.);
+  fQAVertexList->Add(gHistSPDResolutionVz);
+  
+  //Tracks
+  TH1F *gHistTracksVz = new TH1F("gHistTracksVz",
+                                ";V_{z} (gen.) [cm];Entries",
+                                40,-20.,20.);
+  fQAVertexList->Add(gHistTracksVz);
+  //TH1F *gHistMCPrimaryMultiplicityTracks = new TH1F("gHistMCPrimaryMultiplicityTracks",
+  //"Vertex Tracks;N_{prim. gen.};Entries",
+  //23,xBins);
+  //fQAVertexList->Add(gHistMCPrimaryMultiplicityTracks);
+  TH2F *gHistTracksESDVxN = new TH2F("gHistTracksESDVxN",
+                                    "Primary vertex Tracks;V_{x} [cm];N_{contributors}",
+                                    100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistTracksESDVxN);
+  TH2F *gHistTracksESDVyN = new TH2F("gHistTracksESDVyN",
+                                   "Primary vertex Tracks;V_{y} [cm];N_{contributors}",
+                                   100,-10.,10.,1000,0,5000);
+  fQAVertexList->Add(gHistTracksESDVyN);
+  TH2F *gHistTracksESDVzN = new TH2F("gHistTracksESDVzN",
+                                   "Primary vertex Tracks;V_{z} [cm];N_{contributors}",
+                                   100,-20.,20.,1000,0,5000);
+  fQAVertexList->Add(gHistTracksESDVzN);
+  TH1F *gHistTracksDiffVx = new TH1F("gHistTracksDiffVx",
+                                    ";V_{x}(rec.) - V_{x}(true) [#mu m];Entries",
+                                    100,-10000.,10000.);
+  fQAVertexList->Add(gHistTracksDiffVx);
+  TH1F *gHistTracksDiffVy = new TH1F("gHistTracksDiffVy",
+                                    ";V_{y}(rec.) - V_{y}(true) [#mu m];Entries",
+                                    100,-10000.,10000.);
+  fQAVertexList->Add(gHistTracksDiffVy);
+  TH1F *gHistTracksDiffVz = new TH1F("gHistTracksDiffVz",
+                                    ";V_{z}(rec.) - V_{z}(true) [#mu m];Entries",
+                                    100,-10000.,10000.);
+  fQAVertexList->Add(gHistTracksDiffVz);
+  TH1F *gHistTracksResolutionVx = new TH1F("gHistTracksResolutionVx",
+                                          ";#sigma_{x} [#mu m];Entries",
+                                          100,0.,5000.);
+  fQAVertexList->Add(gHistTracksResolutionVx);
+  TH1F *gHistTracksResolutionVy = new TH1F("gHistTracksResolutionVy",
+                                          ";#sigma_{y} [#mu m];Entries",
+                                          100,0.,5000.);
+  fQAVertexList->Add(gHistTracksResolutionVy);
+  TH1F *gHistTracksResolutionVz = new TH1F("gHistTracksResolutionVz",
+                                          ";#sigma_{z} [#mu m];Entries",
+                                          100,0.,1000.);
+  fQAVertexList->Add(gHistTracksResolutionVz);
 }
 
 //____________________________________________________________________//
 void AliProtonQAAnalysis::InitQA() {
-  //Initializes the QA histograms and builds the directory structure
+  //Initializes the QA histograms
   //if(!fQAHistograms) 
-  SetQAOn();
+  SetRunQAAnalysis();
 
   //2D histograms
   //TDirectory *dir2D = gDirectory->mkdir("2D");
   //fGlobalQAList->Add(dir2D); dir2D->cd();
   TH2D *gHistYPtPrimaryProtonsPass = new TH2D("gHistYPtPrimaryProtonsPass",
-                                             ";y;P_{T} [GeV/c]",
+                                             ";;P_{T} [GeV/c]",
                                              fNBinsY,fMinY,fMaxY,
                                              fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitle("y");
   gHistYPtPrimaryProtonsPass->SetStats(kTRUE);
   gHistYPtPrimaryProtonsPass->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtPrimaryProtonsPass);
+  fQA2DList->Add(gHistYPtPrimaryProtonsPass);//y-pT of primary accepted ESD protons
   TH2D *gHistYPtPrimaryProtonsReject = new TH2D("gHistYPtPrimaryProtonsReject",
-                                               ";y;P_{T} [GeV/c]",
+                                               ";;P_{T} [GeV/c]",
                                                fNBinsY,fMinY,fMaxY,
                                                fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitle("y");
   gHistYPtPrimaryProtonsReject->SetStats(kTRUE);
   gHistYPtPrimaryProtonsReject->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtPrimaryProtonsReject);
+  fQA2DList->Add(gHistYPtPrimaryProtonsReject);//y-pT of primary rejected ESD protons
 
   TH2D *gHistYPtSecondaryProtonsPass = new TH2D("gHistYPtSecondaryProtonsPass",
-                                               ";y;P_{T} [GeV/c]",
+                                               ";;P_{T} [GeV/c]",
                                                fNBinsY,fMinY,fMaxY,
                                                fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitle("y");
   gHistYPtSecondaryProtonsPass->SetStats(kTRUE);
   gHistYPtSecondaryProtonsPass->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtSecondaryProtonsPass);
+  fQA2DList->Add(gHistYPtSecondaryProtonsPass);//y-pT of secondary accepted ESD protons
   TH2D *gHistYPtSecondaryProtonsReject = new TH2D("gHistYPtSecondaryProtonsReject",
-                                                 ";y;P_{T} [GeV/c]",
+                                                 ";;P_{T} [GeV/c]",
                                                  fNBinsY,fMinY,fMaxY,
                                                  fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitle("y");
   gHistYPtSecondaryProtonsReject->SetStats(kTRUE);
   gHistYPtSecondaryProtonsReject->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtSecondaryProtonsReject);
+  fQA2DList->Add(gHistYPtSecondaryProtonsReject);//y-pT of secondary rejected ESD protons
 
   TH2D *gHistYPtPrimaryAntiProtonsPass = new TH2D("gHistYPtPrimaryAntiProtonsPass",
-                                                 ";y;P_{T} [GeV/c]",
+                                                 ";;P_{T} [GeV/c]",
                                                  fNBinsY,fMinY,fMaxY,
                                                  fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitle("y");
   gHistYPtPrimaryAntiProtonsPass->SetStats(kTRUE);
   gHistYPtPrimaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);
+  fQA2DList->Add(gHistYPtPrimaryAntiProtonsPass);//y-pT of primary accepted ESD antiprotons
   TH2D *gHistYPtPrimaryAntiProtonsReject = new TH2D("gHistYPtPrimaryAntiProtonsReject",
-                                                 ";y;P_{T} [GeV/c]",
-                                                 fNBinsY,fMinY,fMaxY,
-                                                 fNBinsPt,fMinPt,fMaxPt);
+                                                   ";;P_{T} [GeV/c]",
+                                                   fNBinsY,fMinY,fMaxY,
+                                                   fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitle("y");
   gHistYPtPrimaryAntiProtonsReject->SetStats(kTRUE);
   gHistYPtPrimaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtPrimaryAntiProtonsReject);
+  fQA2DList->Add(gHistYPtPrimaryAntiProtonsReject);//y-pT of primary rejected ESD antiprotons
 
   TH2D *gHistYPtSecondaryAntiProtonsPass = new TH2D("gHistYPtSecondaryAntiProtonsPass",
-                                                 ";y;P_{T} [GeV/c]",
-                                                 fNBinsY,fMinY,fMaxY,
-                                                 fNBinsPt,fMinPt,fMaxPt);
+                                                   ";;P_{T} [GeV/c]",
+                                                   fNBinsY,fMinY,fMaxY,
+                                                   fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitle("y");
   gHistYPtSecondaryAntiProtonsPass->SetStats(kTRUE);
   gHistYPtSecondaryAntiProtonsPass->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtSecondaryAntiProtonsPass);
+  fQA2DList->Add(gHistYPtSecondaryAntiProtonsPass);//y-pT of secondary accepted ESD antiprotons
   TH2D *gHistYPtSecondaryAntiProtonsReject = new TH2D("gHistYPtSecondaryAntiProtonsReject",
-                                                 ";y;P_{T} [GeV/c]",
-                                                 fNBinsY,fMinY,fMaxY,
-                                                 fNBinsPt,fMinPt,fMaxPt);
+                                                     ";;P_{T} [GeV/c]",
+                                                     fNBinsY,fMinY,fMaxY,
+                                                     fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitle("y");
   gHistYPtSecondaryAntiProtonsReject->SetStats(kTRUE);
   gHistYPtSecondaryAntiProtonsReject->GetXaxis()->SetTitleColor(1);
-  fQA2DList->Add(gHistYPtSecondaryAntiProtonsReject);
+  fQA2DList->Add(gHistYPtSecondaryAntiProtonsReject);//y-pT of secondary rejected ESD antiprotons
+
+  TH2D *gHistYPtPrimaryProtonsMC = new TH2D("gHistYPtPrimaryProtonsMC",
+                                           ";;P_{T} [GeV/c]",
+                                           fNBinsY,fMinY,fMaxY,
+                                           fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitle("y");
+  gHistYPtPrimaryProtonsMC->SetStats(kTRUE);
+  gHistYPtPrimaryProtonsMC->GetXaxis()->SetTitleColor(1);
+  fQA2DList->Add(gHistYPtPrimaryProtonsMC);//y-pT of primary MC protons
+  TH2D *gHistYPtPrimaryAntiProtonsMC = new TH2D("gHistYPtPrimaryAntiProtonsMC",
+                                               ";;P_{T} [GeV/c]",
+                                               fNBinsY,fMinY,fMaxY,
+                                               fNBinsPt,fMinPt,fMaxPt);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitle("y");
+  gHistYPtPrimaryAntiProtonsMC->SetStats(kTRUE);
+  gHistYPtPrimaryAntiProtonsMC->GetXaxis()->SetTitleColor(1);
+  fQA2DList->Add(gHistYPtPrimaryAntiProtonsMC);//y-pT of primary MC antiprotons
+
+  TH3F *gHistYPtPDGProtonsPass = new TH3F("gHistYPtPDGProtonsPass",
+                                         ";;P_{T} [GeV/c];PDG",
+                                         fNBinsY,fMinY,fMaxY,
+                                         fNBinsPt,fMinPt,fMaxPt,
+                                         14,-0.5,13.5);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPDGProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPDGProtonsPass->GetXaxis()->SetTitle("y");
+  fQA2DList->Add(gHistYPtPDGProtonsPass);//composition of secondary protons
+  TH3F *gHistYPtPDGAntiProtonsPass = new TH3F("gHistYPtPDGAntiProtonsPass",
+                                             ";;P_{T} [GeV/c];PDG",
+                                             fNBinsY,fMinY,fMaxY,
+                                             fNBinsPt,fMinPt,fMaxPt,
+                                             14,-0.5,13.5);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPDGAntiProtonsPass->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPDGAntiProtonsPass->GetXaxis()->SetTitle("y");
+  fQA2DList->Add(gHistYPtPDGAntiProtonsPass);//composition of secondary antiprotons
 
   /*gDirectory->cd("../");
   //protons
@@ -1378,6 +2077,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gPrimaryProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryProtonsPointOnITSLayer6Pass",
                                             "",10,-1,1);
   fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsPointOnITSLayer6Pass);
+  TH1F *gPrimaryProtonsNumberOfTPCdEdxPointsPass = new TH1F("gPrimaryProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
+  fQAPrimaryProtonsAcceptedList->Add(gPrimaryProtonsNumberOfTPCdEdxPointsPass);
 
   //Rejected primary protons
   /*gDirectory->cd("../");
@@ -1478,6 +2179,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gPrimaryProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryProtonsPointOnITSLayer6Reject",
                                             "",10,-1,1);
   fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsPointOnITSLayer6Reject);
+  TH1F *gPrimaryProtonsNumberOfTPCdEdxPointsReject = new TH1F("gPrimaryProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
+  fQAPrimaryProtonsRejectedList->Add(gPrimaryProtonsNumberOfTPCdEdxPointsReject);
 
   //________________________________________________________________//
   /*gDirectory->cd("../../");
@@ -1582,6 +2285,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gSecondaryProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryProtonsPointOnITSLayer6Pass",
                                                         "",10,-1,1);
   fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsPointOnITSLayer6Pass);
+  TH1F *gSecondaryProtonsNumberOfTPCdEdxPointsPass = new TH1F("gSecondaryProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
+  fQASecondaryProtonsAcceptedList->Add(gSecondaryProtonsNumberOfTPCdEdxPointsPass);
 
   //Rejected secondary protons
   /*gDirectory->cd("../");
@@ -1682,7 +2387,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gSecondaryProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryProtonsPointOnITSLayer6Reject",
                                                           "",10,-1,1);
   fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsPointOnITSLayer6Reject);
-  
+  TH1F *gSecondaryProtonsNumberOfTPCdEdxPointsReject = new TH1F("gSecondaryProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
+  fQASecondaryProtonsRejectedList->Add(gSecondaryProtonsNumberOfTPCdEdxPointsReject);  
 
   /*gDirectory->cd("../../../");
 
@@ -1791,6 +2497,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Pass",
                                                           "",10,-1,1);
   fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Pass);
+  TH1F *gPrimaryAntiProtonsNumberOfTPCdEdxPointsPass = new TH1F("gPrimaryAntiProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
+  fQAPrimaryAntiProtonsAcceptedList->Add(gPrimaryAntiProtonsNumberOfTPCdEdxPointsPass);
   
   //Rejected primary antiprotons
   /*gDirectory->cd("../");
@@ -1891,6 +2599,8 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gPrimaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gPrimaryAntiProtonsPointOnITSLayer6Reject",
                                                             "",10,-1,1);
   fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsPointOnITSLayer6Reject);
+  TH1F *gPrimaryAntiProtonsNumberOfTPCdEdxPointsReject = new TH1F("gPrimaryAntiProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
+  fQAPrimaryAntiProtonsRejectedList->Add(gPrimaryAntiProtonsNumberOfTPCdEdxPointsReject);
   
   //________________________________________________________________//
   /*gDirectory->cd("../../");
@@ -1995,7 +2705,9 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Pass = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Pass",
                                                             "",10,-1,1);
   fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Pass);
-  
+  TH1F *gSecondaryAntiProtonsNumberOfTPCdEdxPointsPass = new TH1F("gSecondaryAntiProtonsNumberOfTPCdEdxPointsPass","",100,0,200);
+  fQASecondaryAntiProtonsAcceptedList->Add(gSecondaryAntiProtonsNumberOfTPCdEdxPointsPass);
+
   //Rejected secondary antiprotons
   /*gDirectory->cd("../");
   TDirectory *dirAntiProtonsSecondaryRejected = gDirectory->mkdir("Rejected");
@@ -2095,158 +2807,1620 @@ void AliProtonQAAnalysis::InitQA() {
   TH1F *gSecondaryAntiProtonsPointOnITSLayer6Reject = new TH1F("gSecondaryAntiProtonsPointOnITSLayer6Reject",
                                                             "",10,-1,1);
   fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsPointOnITSLayer6Reject);
+  TH1F *gSecondaryAntiProtonsNumberOfTPCdEdxPointsReject = new TH1F("gSecondaryAntiProtonsNumberOfTPCdEdxPointsReject","",100,0,200);
+  fQASecondaryAntiProtonsRejectedList->Add(gSecondaryAntiProtonsNumberOfTPCdEdxPointsReject);
 }
 
 //____________________________________________________________________//
-void AliProtonQAAnalysis::RunQA(AliStack *stack, AliESDEvent *fESD) {
+void AliProtonQAAnalysis::RunReconstructionEfficiencyAnalysis(AliMCEvent *const mcEvent, 
+                                                             AliESDEvent *esd,
+                                                             const AliESDVertex *vertex) {
+  //Run the reconstruction efficiency code (primaries & secondaries)
+  AliStack *stack = mcEvent->Stack();
+
+  Int_t nMCParticles = mcEvent->GetNumberOfTracks();
+  Int_t nMCLabelCounter = 0;
+  TArrayI labelMCArray(nMCParticles);
+
+  for (Int_t iTracks = 0; iTracks < mcEvent->GetNumberOfTracks(); iTracks++) {
+    AliMCParticle *mcTrack = mcEvent->GetTrack(iTracks);
+    if (!mcTrack) {
+      Printf("ERROR: Could not receive track %d (mc loop)", iTracks);
+      continue;
+    }
+    if(TMath::Abs(mcTrack->Eta()) > 1.0) continue;//acceptance
+    if((mcTrack->Pt() > fMaxPt)||(mcTrack->Pt() < fMinPt)) continue;
+    if(fProtonAnalysisBase->GetEtaMode()) {
+      if((mcTrack->Eta() > fMaxY)|| (mcTrack->Eta() < fMinY)) continue;
+    }
+    else 
+      if((fProtonAnalysisBase->Rapidity(mcTrack->Px(),mcTrack->Py(),mcTrack->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(mcTrack->Px(),mcTrack->Py(),mcTrack->Pz()) < fMinY)) continue;
+    
+    // Loop over Track References
+    Bool_t labelTPC = kFALSE;
+    AliTrackReference* trackRef = 0;
+    for (Int_t iTrackRef = 0; iTrackRef  < mcTrack->GetNumberOfTrackReferences(); iTrackRef++) {
+      trackRef = mcTrack->GetTrackReference(iTrackRef);
+      if(trackRef) {
+       Int_t detectorId = trackRef->DetectorId(); 
+       if (detectorId == AliTrackReference::kTPC) {        
+         labelTPC = kTRUE;
+         break;
+       }
+      }      
+    }
+
+    //findable tracks
+    if (labelTPC) {
+      TParticle* particle = mcTrack->Particle();
+      if(!particle) continue;
+      Int_t pdgcode = particle->GetPdgCode();
+      if(TMath::Abs(pdgcode) != 2212) continue;
+      
+      labelMCArray.AddAt(iTracks,nMCLabelCounter);
+      nMCLabelCounter += 1;
+
+      if(iTracks <= stack->GetNprimary()) {
+       if(pdgcode == 2212) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(0)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                                  particle->Py(),
+                                                                                  particle->Pz()),
+                                                    particle->Pt());
+       }//protons
+       if(pdgcode == -2212) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(1)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                                  particle->Py(),
+                                                                                  particle->Pz()),
+                                                    particle->Pt());
+       }//antiprotons
+      }//primaries
+      else {
+       //secondaries
+       Int_t lPartMother = -1;
+       Int_t motherPDGCode = -1;
+       lPartMother = particle->GetFirstMother();
+       AliMCParticle *mcMotherTrack = mcEvent->GetTrack(lPartMother);
+       TParticle *motherParticle = mcMotherTrack->Particle();
+       if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+       
+       if(pdgcode == 2212) {
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode()) 
+             ((TH2D *)(fEfficiencyList->At(2)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(2)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode()) 
+             ((TH2D *)(fEfficiencyList->At(4)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(4)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//hadronic interactions
+       }//protons
+       if(pdgcode == -2212) {
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode()) 
+             ((TH2D *)(fEfficiencyList->At(3)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(3)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode()) 
+             ((TH2D *)(fEfficiencyList->At(5)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(5)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//hadronic interactions
+       }//antiprotons
+      }//secondaries
+    }//findable tracks
+  }//MC track loop
+
+  //ESD track loop
+  Bool_t iFound = kFALSE;
+  Int_t mcGoods = nMCLabelCounter;
+  for (Int_t k = 0; k < mcGoods; k++) {
+    Int_t mcLabel = labelMCArray.At(k);
+    iFound = kFALSE;
+
+    Int_t nGoodTracks = esd->GetNumberOfTracks();
+    TArrayI labelArray(nGoodTracks);
+    Int_t labelCounter = 0;
+    for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
+      AliESDtrack* track = esd->GetTrack(iTracks);
+      if(!track) continue;
+            
+      //TPC only
+      if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
+       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
+       if(!tpcTrack) continue;
+       
+       Int_t label = TMath::Abs(track->GetTPCLabel());
+       if(IsLabelUsed(labelArray,label)) continue;
+       labelArray.AddAt(label,labelCounter);
+       labelCounter += 1;
+       
+       if (mcLabel != TMath::Abs(label)) continue;
+       if(mcLabel != label) continue;
+       
+       TParticle *particle = stack->Particle(label);
+       if(!particle) continue;
+       Int_t pdgcode = particle->GetPdgCode();
+       if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+       if(fProtonAnalysisBase->GetEtaMode()) {
+         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
+       }
+       else 
+         if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+       
+       //Double_t probability[5];
+       
+       if(fUseCutsInEfficiency) 
+         if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;
+       
+       //reconstructed primary (anti)protons
+       if(pdgcode == 2212) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+         if(label <= stack->GetNprimary()) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//primaries
+         if(label > stack->GetNprimary()) {
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           lPartMother = particle->GetFirstMother();
+           TParticle *motherParticle = stack->Particle(lPartMother);
+           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           
+           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
+                                                        particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(8)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                 particle->Py(),
+                                                                 particle->Pz()),
+                                                        particle->Pt());
+           }//weak decays
+           if((particle->GetUniqueID() == 13)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
+                                                         particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                  particle->Py(),
+                                                                  particle->Pz()),
+                                                         particle->Pt());
+           }//hadronic interactions
+         }//secondaries
+       }//initial protons
+       if(pdgcode == -2212) {  
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+         if(label <= stack->GetNprimary()) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//primaries
+         if(label > stack->GetNprimary()) {
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           lPartMother = particle->GetFirstMother();
+           TParticle *motherParticle = stack->Particle(lPartMother);
+           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           
+           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
+                                                        particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(9)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                 particle->Py(),
+                                                                 particle->Pz()),
+                                                        particle->Pt());
+           }//weak decays
+           if((particle->GetUniqueID() == 13)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
+                                                         particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                  particle->Py(),
+                                                                  particle->Pz()),
+                                                         particle->Pt());
+           }//hadronic interactions
+         }//secondaries
+       }//initial antiprotons  
+      }//TPC only tracks
+      else {
+       Int_t label = TMath::Abs(track->GetLabel());
+       if(IsLabelUsed(labelArray,label)) continue;
+       labelArray.AddAt(label,labelCounter);
+       labelCounter += 1;
+       
+       if (mcLabel != TMath::Abs(label)) continue;
+       if(mcLabel != label) continue;
+       
+       TParticle *particle = stack->Particle(label);
+       if(!particle) continue;
+       Int_t pdgcode = particle->GetPdgCode();
+       if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+       if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+       if(fProtonAnalysisBase->GetEtaMode()) {
+         if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
+       }
+       else 
+         if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+       
+       //Double_t probability[5];
+
+       if(fUseCutsInEfficiency) 
+         if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;
+       
+       //reconstructed primary (anti)protons
+       if(pdgcode == 2212) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+         if(label <= stack->GetNprimary()) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//primaries
+         if(label > stack->GetNprimary()) {
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           lPartMother = particle->GetFirstMother();
+           TParticle *motherParticle = stack->Particle(lPartMother);
+           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           
+           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
+                                                        particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(8)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                 particle->Py(),
+                                                                 particle->Pz()),
+                                                        particle->Pt());
+           }//weak decays
+           if((particle->GetUniqueID() == 13)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
+                                                         particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                  particle->Py(),
+                                                                  particle->Pz()),
+                                                         particle->Pt());
+           }//hadronic interactions
+         }//secondaries
+       }//initial protons
+       if(pdgcode == -2212) {  
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+         if(label <= stack->GetNprimary()) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//primaries
+         if(label > stack->GetNprimary()) {
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           lPartMother = particle->GetFirstMother();
+           TParticle *motherParticle = stack->Particle(lPartMother);
+           if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           
+           if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
+                                                        particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(9)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                 particle->Py(),
+                                                                 particle->Pz()),
+                                                        particle->Pt());
+           }//weak decays
+           if((particle->GetUniqueID() == 13)) {
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
+                                                         particle->Pt());
+             else
+               ((TH2D *)(fEfficiencyList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                  particle->Py(),
+                                                                  particle->Pz()),
+                                                         particle->Pt());
+           }//hadronic interactions
+         }//secondaries
+       }//initial antiprotons
+       
+      }//global tracking
+    }//track loop
+    labelArray.Reset();
+  }//loop over findable tracks
+
+  labelMCArray.Reset();
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::RunPIDEfficiencyAnalysis(AliStack *const stack, 
+                                                  AliESDEvent *esd) {
+  Int_t nGoodTracks = esd->GetNumberOfTracks();
+  TArrayI labelArray(nGoodTracks);
+  Int_t labelCounter = 0;
+  for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
+    AliESDtrack* track = esd->GetTrack(iTracks);
+    if(!track) continue;
+    
+    //TPC only
+    if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
+      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
+      if(!tpcTrack) continue;
+    }
+       
+    Int_t label = TMath::Abs(track->GetLabel());
+    if(IsLabelUsed(labelArray,label)) continue;
+    labelArray.AddAt(label,labelCounter);
+    labelCounter += 1;
+               
+    TParticle *particle = stack->Particle(label);
+    if(!particle) continue;
+    Int_t pdgcode = particle->GetPdgCode();
+    
+    Int_t nTPCpoints = track->GetTPCsignalN();
+
+    //pid
+    if(fProtonAnalysisBase->IsProton(track)) {
+      if(fProtonAnalysisBase->GetEtaMode())
+       ((TH3D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
+                                                 particle->Pt(),nTPCpoints);
+      else ((TH3D *)(fEfficiencyList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()),particle->Pt(),nTPCpoints);
+      if(TMath::Abs(pdgcode) == 2212) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
+                                                   particle->Pt(),nTPCpoints);
+       else
+         ((TH3D *)(fEfficiencyList->At(13)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()),particle->Pt(),nTPCpoints);
+      }//properly identified as proton
+      else {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
+                                                   particle->Pt(),nTPCpoints);
+       else
+         ((TH3D *)(fEfficiencyList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()),particle->Pt(),nTPCpoints);
+      }//contamination
+    }//identified as proton
+  }//ESD track loop
+  labelArray.Reset();
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::RunEfficiencyAnalysis(AliStack *const stack, 
+                                               AliESDEvent *esd,
+                                               const AliESDVertex *vertex) {
+  //Runs the efficiency code
+  //MC loop
+  Int_t nMCProtons = 0, nESDProtons = 0;
+  for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
+    TParticle *particle = stack->Particle(iParticle);
+    if(!particle) continue;
+
+    if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+    if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+    if(fProtonAnalysisBase->GetEtaMode()) {
+      if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
+    }
+    else 
+      if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+
+    Int_t pdgcode = particle->GetPdgCode();
+    if(TMath::Abs(pdgcode) != 2212) continue;
+
+    if(iParticle <= stack->GetNprimary()) {
+      if(pdgcode == 2212) {
+       nMCProtons += 1;
+       if(fProtonAnalysisBase->GetEtaMode()) 
+         ((TH2D *)(fEfficiencyList->At(0)))->Fill(particle->Eta(),
+                                                  particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                           particle->Py(),
+                                                           particle->Pz()),
+                                                  particle->Pt());
+      }//protons
+      if(pdgcode == -2212) {
+       if(fProtonAnalysisBase->GetEtaMode()) 
+         ((TH2D *)(fEfficiencyList->At(1)))->Fill(particle->Eta(),
+                                                  particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                           particle->Py(),
+                                                           particle->Pz()),
+                                                  particle->Pt());
+      }//antiprotons
+    }//primaries
+    else {
+      //secondaries
+      Int_t lPartMother = -1;
+      Int_t motherPDGCode = -1;
+      lPartMother = particle->GetFirstMother();
+      TParticle *motherParticle = stack->Particle(lPartMother);
+      if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+
+      if(pdgcode == 2212) {
+       if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(2)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(2)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//weak decays
+       if((particle->GetUniqueID() == 13)) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(4)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(4)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                                  particle->Py(),
+                                                                                  particle->Pz()),
+                                                    particle->Pt());
+       }//hadronic interactions
+      }//protons
+      if(pdgcode == -2212) {
+       if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(3)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(3)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//weak decays
+       if((particle->GetUniqueID() == 13)) {
+         if(fProtonAnalysisBase->GetEtaMode()) 
+           ((TH2D *)(fEfficiencyList->At(5)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(5)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//hadronic interactions
+      }//antiprotons
+    }//secondaries
+  
+  }//MC loop
+
+  //ESD track loop
+  Int_t nGoodTracks = esd->GetNumberOfTracks();
+  TArrayI labelArray(nGoodTracks);
+  Int_t labelCounter = 0;
+  for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
+    AliESDtrack* track = esd->GetTrack(iTracks);
+    if(!track) continue;
+    
+    Int_t label = TMath::Abs(track->GetLabel());
+    if(IsLabelUsed(labelArray,label)) continue;
+    labelArray.AddAt(label,labelCounter);
+    labelCounter += 1;
+    
+    TParticle *particle = stack->Particle(label);
+    if(!particle) continue;
+    Int_t pdgcode = particle->GetPdgCode();
+    if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+    
+    Double_t gPt = 0.0, gP = 0.0;
+    
+    //TPC only
+    if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
+      AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
+      if(!tpcTrack) continue;
+      gPt = tpcTrack->Pt();
+      gP = tpcTrack->P();
+      
+      if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+      if(fProtonAnalysisBase->GetEtaMode()) {
+       if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
+      }
+      else 
+       if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+      
+      if(fUseCutsInEfficiency) 
+       if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;
+      
+      //reconstructed primary (anti)protons
+      if(pdgcode == 2212) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                            particle->Py(),
+                                                            particle->Pz()),
+                                                   particle->Pt());
+       if(label <= stack->GetNprimary()) {
+         nESDProtons += 1;
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//primaries
+       if(label > stack->GetNprimary()) {
+         Int_t lPartMother = -1;
+         Int_t motherPDGCode = -1;
+         lPartMother = particle->GetFirstMother();
+         TParticle *motherParticle = stack->Particle(lPartMother);
+         if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+         
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(8)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
+                                                       particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                particle->Py(),
+                                                                particle->Pz()),
+                                                       particle->Pt());
+         }//hadronic interactions
+       }//secondaries
+      }//initial protons
+      if(pdgcode == -2212) {   
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                            particle->Py(),
+                                                            particle->Pz()),
+                                                   particle->Pt());
+       if(label <= stack->GetNprimary()) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//primaries
+       if(label > stack->GetNprimary()) {
+         Int_t lPartMother = -1;
+         Int_t motherPDGCode = -1;
+         lPartMother = particle->GetFirstMother();
+         TParticle *motherParticle = stack->Particle(lPartMother);
+         if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+         
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(9)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
+                                                       particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                particle->Py(),
+                                                                particle->Pz()),
+                                                       particle->Pt());
+         }//hadronic interactions
+       }//secondaries
+      }//initial antiprotons
+      
+      //pid
+      if(fProtonAnalysisBase->IsProton(track)) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                            particle->Py(),
+                                                            particle->Pz()),
+                                                   particle->Pt());
+       if(TMath::Abs(pdgcode) == 2212) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(13)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+       }//properly identified as proton
+       else {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+       }//contamination
+      }//identified as proton
+    }//TPC only tracks
+    else {
+      if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+      if(fProtonAnalysisBase->GetEtaMode()) {
+       if((particle->Eta() > fMaxY)|| (particle->Eta() < fMinY)) continue;
+      }
+      else {
+       if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+      }
+      
+      if(fUseCutsInEfficiency) 
+       if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) continue;
+      
+      //reconstructed primary (anti)protons
+      if(pdgcode == 2212) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                            particle->Py(),
+                                                            particle->Pz()),
+                                                   particle->Pt());
+       if(label <= stack->GetNprimary()) {
+         nESDProtons += 1;
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(6)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//primaries
+       if(label > stack->GetNprimary()) {
+         Int_t lPartMother = -1;
+         Int_t motherPDGCode = -1;
+         lPartMother = particle->GetFirstMother();
+         TParticle *motherParticle = stack->Particle(lPartMother);
+         if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+         
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(8)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(8)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(10)))->Fill(particle->Eta(),
+                                                       particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                particle->Py(),
+                                                                particle->Pz()),
+                                                       particle->Pt());
+         }//hadronic interactions
+       }//secondaries
+      }//initial protons
+      if(pdgcode == -2212) {   
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else
+         ((TH2D *)(fEfficiencyList->At(12)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                            particle->Py(),
+                                                            particle->Pz()),
+                                                   particle->Pt());
+       if(label <= stack->GetNprimary()) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(7)))->Fill(particle->Eta(),
+                                                    particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                             particle->Py(),
+                                                             particle->Pz()),
+                                                    particle->Pt());
+       }//primaries
+       if(label > stack->GetNprimary()) {
+         Int_t lPartMother = -1;
+         Int_t motherPDGCode = -1;
+         lPartMother = particle->GetFirstMother();
+         TParticle *motherParticle = stack->Particle(lPartMother);
+         if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+         
+         if((particle->GetUniqueID() == 4)&&(TMath::Abs(motherPDGCode) == 3122)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(9)))->Fill(particle->Eta(),
+                                                      particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(9)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+         }//weak decays
+         if((particle->GetUniqueID() == 13)) {
+           if(fProtonAnalysisBase->GetEtaMode())
+             ((TH2D *)(fEfficiencyList->At(11)))->Fill(particle->Eta(),
+                                                       particle->Pt());
+           else
+             ((TH2D *)(fEfficiencyList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                                particle->Py(),
+                                                                particle->Pz()),
+                                                       particle->Pt());
+         }//hadronic interactions
+       }//secondaries
+      }//initial antiprotons
+      
+      //pid
+      if(fProtonAnalysisBase->IsProton(track)) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH2D *)(fEfficiencyList->At(14)))->Fill(particle->Eta(),
+                                                   particle->Pt());
+       else ((TH2D *)(fEfficiencyList->At(14)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                               particle->Py(),
+                                                               particle->Pz()),
+                                                      particle->Pt());
+       if(TMath::Abs(pdgcode) == 2212) {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(13)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(13)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+       }//properly identified as proton
+       else {
+         if(fProtonAnalysisBase->GetEtaMode())
+           ((TH2D *)(fEfficiencyList->At(15)))->Fill(particle->Eta(),
+                                                     particle->Pt());
+         else
+           ((TH2D *)(fEfficiencyList->At(15)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                              particle->Py(),
+                                                              particle->Pz()),
+                                                     particle->Pt());
+       }//contamination
+      }//identified as proton
+    }//global tracking
+  }//track loop
+  
+  //Printf("MC protons: %d - ESD protons: %d",nMCProtons,nESDProtons);
+}
+
+//____________________________________________________________________//
+Bool_t AliProtonQAAnalysis::IsLabelUsed(TArrayI labelArray, 
+                                       Int_t label) {
+  //Checks if the label is used already
+  Bool_t status = kFALSE;
+  for(Int_t i = 0; i < labelArray.GetSize(); i++) {
+    if(labelArray.At(i) == label)
+      status = kTRUE;
+  }
+
+  return status;
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::RunVertexQA(AliGenEventHeader *header,
+                                     AliStack *const stack, 
+                                     AliESDEvent *const esd) {
+  //Runs the vertex QA
+  //MC vertex
+  TArrayF primaryVertex(3);
+  header->PrimaryVertex(primaryVertex);
+
+  //Int_t nPrimaries = stack->GetNprimary();
+  ((TH1F *)(fQAVertexList->At(0)))->Fill(primaryVertex[2]);
+
+  //TPC vertex
+  const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();
+  if(!vertexTPC) {
+    Printf("ERROR: Could not retrieve the TPC vertex");
+    return;
+  }
+  if(vertexTPC->GetNContributors() > 0) {
+    ((TH1F *)(fQAVertexList->At(1)))->Fill(primaryVertex[2]);
+    ((TH2F *)(fQAVertexList->At(2)))->Fill(vertexTPC->GetXv(),
+                                          vertexTPC->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(3)))->Fill(vertexTPC->GetYv(),
+                                          vertexTPC->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(4)))->Fill(vertexTPC->GetZv(),
+                                          vertexTPC->GetNContributors());
+    ((TH1F *)(fQAVertexList->At(5)))->Fill((vertexTPC->GetXv()-primaryVertex[0])*10000.);
+    ((TH1F *)(fQAVertexList->At(6)))->Fill((vertexTPC->GetYv()-primaryVertex[1])*10000.);
+    ((TH1F *)(fQAVertexList->At(7)))->Fill((vertexTPC->GetZv()-primaryVertex[2])*10000.);
+    ((TH1F *)(fQAVertexList->At(8)))->Fill(vertexTPC->GetXRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(9)))->Fill(vertexTPC->GetYRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(10)))->Fill(vertexTPC->GetZRes()*10000.);
+  }//TPC vertex
+
+  //SPD vertex
+  const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();
+  if(!vertexSPD) {
+    Printf("ERROR: Could not retrieve the SPD vertex");
+    return;
+  }
+  if(vertexSPD->GetNContributors() > 0) {
+    ((TH1F *)(fQAVertexList->At(11)))->Fill(primaryVertex[2]);
+    ((TH2F *)(fQAVertexList->At(12)))->Fill(vertexSPD->GetXv(),
+                                           vertexSPD->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(13)))->Fill(vertexSPD->GetYv(),
+                                           vertexSPD->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(14)))->Fill(vertexSPD->GetZv(),
+                                           vertexSPD->GetNContributors());
+    ((TH1F *)(fQAVertexList->At(15)))->Fill((vertexSPD->GetXv()-primaryVertex[0])*10000.);
+    ((TH1F *)(fQAVertexList->At(16)))->Fill((vertexSPD->GetYv()-primaryVertex[1])*10000.);
+    ((TH1F *)(fQAVertexList->At(17)))->Fill((vertexSPD->GetZv()-primaryVertex[2])*10000.);
+    ((TH1F *)(fQAVertexList->At(18)))->Fill(vertexSPD->GetXRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(19)))->Fill(vertexSPD->GetYRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(20)))->Fill(vertexSPD->GetZRes()*10000.);
+  }//SPD vertex
+  
+  //Tracks vertex
+  const AliESDVertex *vertexTracks = esd->GetPrimaryVertex();
+  if(!vertexTracks) {
+    Printf("ERROR: Could not retrieve the Tracks vertex");
+    return;
+  }
+  if(vertexTracks->GetNContributors() > 0) {
+    ((TH1F *)(fQAVertexList->At(21)))->Fill(primaryVertex[2]);
+    ((TH2F *)(fQAVertexList->At(22)))->Fill(vertexTracks->GetXv(),
+                                           vertexTracks->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(23)))->Fill(vertexTracks->GetYv(),
+                                           vertexTracks->GetNContributors());
+    ((TH2F *)(fQAVertexList->At(24)))->Fill(vertexTracks->GetZv(),
+                                           vertexTracks->GetNContributors());
+    ((TH1F *)(fQAVertexList->At(25)))->Fill((vertexTracks->GetXv()-primaryVertex[0])*10000.);
+    ((TH1F *)(fQAVertexList->At(26)))->Fill((vertexTracks->GetYv()-primaryVertex[1])*10000.);
+    ((TH1F *)(fQAVertexList->At(27)))->Fill((vertexTracks->GetZv()-primaryVertex[2])*10000.);
+    ((TH1F *)(fQAVertexList->At(28)))->Fill(vertexTracks->GetXRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(29)))->Fill(vertexTracks->GetYRes()*10000.);
+    ((TH1F *)(fQAVertexList->At(30)))->Fill(vertexTracks->GetZRes()*10000.);
+  }//Tracks vertex
+
+}
+
+//____________________________________________________________________//
+void AliProtonQAAnalysis::RunQAAnalysis(AliStack *stack, 
+                                       AliESDEvent *esd,
+                                       const AliESDVertex *vertex) {
   //Runs the QA code
-  Int_t nGoodTracks = fESD->GetNumberOfTracks();
+  //MC loop
+  for(Int_t iParticle = 0; iParticle < stack->GetNprimary(); iParticle++) {
+    TParticle *particle = stack->Particle(iParticle);
+    if(!particle) continue;
+
+    if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+    if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+    if(fProtonAnalysisBase->GetEtaMode()) {
+      if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
+    }
+    else {
+      if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+    }
+    Int_t pdgcode = particle->GetPdgCode();
+    if(pdgcode == 2212) {
+      if(fProtonAnalysisBase->GetEtaMode())
+       ((TH2D *)(fQA2DList->At(8)))->Fill(particle->Eta(),
+                                          particle->Pt());
+      else
+       ((TH2D *)(fQA2DList->At(8)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                   particle->Py(),
+                                                   particle->Pz()),
+                                          particle->Pt());
+    }
+    if(pdgcode == -2212) {
+      if(fProtonAnalysisBase->GetEtaMode())
+       ((TH2D *)(fQA2DList->At(9)))->Fill(particle->Eta(),
+                                          particle->Pt());
+      else
+       ((TH2D *)(fQA2DList->At(9)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                   particle->Py(),
+                                                   particle->Pz()),
+                                          particle->Pt());
+    }
+  }//MC loop
+  
+  //ESD track loop
+  Int_t nGoodTracks = esd->GetNumberOfTracks();
+  TArrayI labelArray(nGoodTracks);
+  Int_t labelCounter = 0;
   for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) {
-    AliESDtrack* track = fESD->GetTrack(iTracks);
+    AliESDtrack* track = esd->GetTrack(iTracks);
+    if(!track) continue;
+    
     Int_t label = TMath::Abs(track->GetLabel()); 
-    Double_t Pt = 0.0, P = 0.0;
-    Double_t probability[5];
+    if(IsLabelUsed(labelArray,label)) continue;
+    labelArray.AddAt(label,labelCounter);
+    labelCounter += 1;
+    
+    TParticle *particle = stack->Particle(label);
+    if(!particle) continue;
+    if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+    
+    AliESDtrack trackTPC;
+    
+    //in case it's a TPC only track relate it to the proper vertex
+    if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)&&(!fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
+      //if((fUseTPCOnly)&&(!fUseHybridTPC)) {
+      Float_t p[2],cov[3];
+      track->GetImpactParametersTPC(p,cov);
+      if (p[0]==0 && p[1]==0)  
+       track->RelateToVertexTPC(((AliESDEvent*)esd)->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
+      if (!track->FillTPCOnlyTrack(trackTPC)) {
+       continue;
+      }
+      track = &trackTPC ;
+    }
+    
+    Double_t gPt = 0.0, gP = 0.0;
+    //Double_t probability[5];
+    Float_t dcaXY = 0.0, dcaZ = 0.0;
+    Double_t nSigmaToVertex = fProtonAnalysisBase->GetSigmaToVertex(track);
+    Int_t  fIdxInt[200];
+    Int_t nClustersITS = track->GetITSclusters(fIdxInt);
+    Int_t nClustersTPC = track->GetTPCclusters(fIdxInt);
+    
+    Float_t chi2PerClusterITS = -1;
+    if (nClustersITS!=0)
+      chi2PerClusterITS = track->GetITSchi2()/Float_t(nClustersITS);
+    Float_t chi2PerClusterTPC = -1;
+    if (nClustersTPC!=0)
+      chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC);
+    Double_t chi2ConstrainVertex = TMath::Log(track->GetConstrainedChi2());    
+    Double_t extCov[15];
+    track->GetExternalCovariance(extCov);
+    Int_t npointsTPCdEdx = track->GetTPCsignalN();
 
-    if(fUseTPCOnly) {
+    //TPC only
+    if((fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kTPC)||(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)) {
       AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)track->GetTPCInnerParam();
       if(!tpcTrack) continue;
-      Pt = tpcTrack->Pt();
-      P = tpcTrack->P();
+      gPt = tpcTrack->Pt();
+      gP = tpcTrack->P();
+      if(fProtonAnalysisBase->GetAnalysisMode()==AliProtonAnalysisBase::kHybrid)
+       track->GetImpactParameters(dcaXY,dcaZ);
+      else track->GetImpactParametersTPC(dcaXY,dcaZ);
       
       //pid
-      track->GetTPCpid(probability);
-      Double_t rcc = 0.0;
-      for(Int_t i = 0; i < AliPID::kSPECIES; i++)
-       rcc += probability[i]*GetParticleFraction(i,P);
-      if(rcc == 0.0) continue;
-      Double_t w[5];
-      for(Int_t i = 0; i < AliPID::kSPECIES; i++)
-       w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
-      Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
-      if(fParticleType == 4) {
-       FillQA(track, stack);
-       if(IsAccepted(track)) {
+      if(fProtonAnalysisBase->IsProton(track)) {
+       if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
+
+       FillQA(stack,esd,vertex,track);
+       if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
          if(label <= stack->GetNprimary()) {
-            if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-         }//primary particles
+           if(track->Charge() > 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(44)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(48)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(52)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1D *)(fAcceptedCutList->At(56)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(0)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }//accepted primary protons
+           else if(track->Charge() < 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(45)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(49)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(53)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1D *)(fAcceptedCutList->At(57)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(4)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(4)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }//accepted primary antiprotons
+         }//accepted primary particles
          else if(label > stack->GetNprimary()) {
-           if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-         }//secondary particles
-       }//cuts
-       else if(!IsAccepted(track)) {
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           if(particle) {
+             lPartMother = particle->GetFirstMother();
+             TParticle *motherParticle = stack->Particle(lPartMother);
+             if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           }
+           
+           if(fMCProcessIdFlag)
+             if(particle->GetUniqueID() != fMCProcessId) continue;
+           if(fMotherParticlePDGCodeFlag)
+             if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
+           
+           if(track->Charge() > 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(46)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(50)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(54)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1D *)(fAcceptedCutList->At(58)))->Fill(npointsTPCdEdx);
+
+             ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(2)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(2)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+             if(fProtonAnalysisBase->GetEtaMode())
+             ((TH3F *)(fQA2DList->At(10)))->Fill(tpcTrack->Eta(),gPt,
+                                                 ConvertPDGToInt(motherPDGCode));
+             else
+               ((TH3F *)(fQA2DList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                            tpcTrack->Py(),
+                                                            tpcTrack->Pz()),
+                                                   gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+           }//accepted secondary protons
+           else if(track->Charge() < 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(47)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(51)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(55)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1F *)(fAcceptedCutList->At(59)))->Fill(npointsTPCdEdx);
+
+             ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(6)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH3F *)(fQA2DList->At(11)))->Fill(tpcTrack->Eta(),gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+             else
+               ((TH3F *)(fQA2DList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                            tpcTrack->Py(),
+                                                            tpcTrack->Pz()),
+                                                   gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+           }//accepted secondary antiprotons
+         }//accepted secondary particles
+       }//accepted - track cuts
+       else {
          if(label <= stack->GetNprimary()) {
-            if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-         }//primary particles
+           if(track->Charge() > 0) {
+             ((TH3D *)(fRejectedCutList->At(0)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(4)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(8)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(1)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }
+           else if(track->Charge() < 0) {
+             ((TH3D *)(fRejectedCutList->At(1)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(5)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(9)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(5)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(5)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }
+         }//rejected primary particles
          else if(label > stack->GetNprimary()) {
-           if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-         }//secondary particles
-       }//cuts
+           if(track->Charge() > 0) {
+             ((TH3D *)(fRejectedCutList->At(2)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(6)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(10)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(3)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(3)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }
+           else if(track->Charge() < 0) {
+             ((TH3D *)(fRejectedCutList->At(3)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(7)))->Fill(tpcTrack->Eta(),
+                                                       tpcTrack->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(11)))->Fill(tpcTrack->Eta(),
+                                                        tpcTrack->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(7)))->Fill(tpcTrack->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(tpcTrack->Px(),
+                                                           tpcTrack->Py(),
+                                                           tpcTrack->Pz()),
+                                                  gPt);
+           }
+         }//rejected secondary particles
+       }//rejected - track cuts
       }//proton check
     }//TPC only tracks
-    else if(!fUseTPCOnly) {
-      Pt = track->Pt();
-      P = track->P();
+    //combined tracking
+    else {
+      gPt = track->Pt();
+      gP = track->P();
+      track->GetImpactParameters(dcaXY,dcaZ);
       
       //pid
-      track->GetESDpid(probability);
-      Double_t rcc = 0.0;
-      for(Int_t i = 0; i < AliPID::kSPECIES; i++)
-       rcc += probability[i]*GetParticleFraction(i,P);
-      if(rcc == 0.0) continue;
-      Double_t w[5];
-      for(Int_t i = 0; i < AliPID::kSPECIES; i++)
-       w[i] = probability[i]*GetParticleFraction(i,P)/rcc;
-      Long64_t fParticleType = TMath::LocMax(AliPID::kSPECIES,w);
-      if(fParticleType == 4) {
-       FillQA(track, stack);
-       if(IsAccepted(track)) {
+      if(fProtonAnalysisBase->IsProton(track)) {
+       if(!fProtonAnalysisBase->IsInPhaseSpace(track)) continue; //track outside the analyzed y-Pt
+
+       FillQA(stack,esd,vertex,track);
+       if(fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
          if(label <= stack->GetNprimary()) {
-            if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(0)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(4)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
+           if(track->Charge() > 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(0)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(4)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(8)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(12)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(16)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(20)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(24)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(28)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(32)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(36)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(40)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(44)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(48)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(52)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1F *)(fAcceptedCutList->At(56)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(0)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(4)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(8)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(0)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
+           else if(track->Charge() < 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(1)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(5)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(9)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(13)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(17)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(21)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(25)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(29)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(33)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(37)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(41)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(45)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(49)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(53)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1F *)(fAcceptedCutList->At(57)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(1)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(5)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(9)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(4)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(4)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
          }//primary particles
          else if(label > stack->GetNprimary()) {
-           if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(2)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(6)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
+           Int_t lPartMother = -1;
+           Int_t motherPDGCode = -1;
+           if(particle) {
+             lPartMother = particle->GetFirstMother();
+             TParticle *motherParticle = stack->Particle(lPartMother);
+             if(motherParticle) motherPDGCode = motherParticle->GetPdgCode();
+           }
+           
+           if(fMCProcessIdFlag)
+             if(particle->GetUniqueID() != fMCProcessId) continue;
+           if(fMotherParticlePDGCodeFlag)
+             if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
+           
+           if(track->Charge() > 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(2)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(6)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(10)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(14)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(18)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(22)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(26)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(30)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(34)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(38)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(42)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(46)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(50)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(54)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1F *)(fAcceptedCutList->At(58)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(2)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(6)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(10)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(2)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(2)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH3F *)(fQA2DList->At(10)))->Fill(track->Eta(),gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+             else
+               ((TH3F *)(fQA2DList->At(10)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                            track->Py(),
+                                                            track->Pz()),
+                                                   gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+           }
+           else if(track->Charge() < 0) {
+             for(Int_t iLayer = 0; iLayer < 6; iLayer++) {
+               if(track->HasPointOnITSLayer(iLayer))
+                 ((TH1F *)(fAcceptedCutList->At(3)))->Fill(iLayer+1);
+             }
+             ((TH1F *)(fAcceptedCutList->At(7)))->Fill(nClustersITS);
+             ((TH1F *)(fAcceptedCutList->At(11)))->Fill(chi2PerClusterITS);
+             ((TH1F *)(fAcceptedCutList->At(15)))->Fill(chi2ConstrainVertex);
+             ((TH1F *)(fAcceptedCutList->At(19)))->Fill(nClustersTPC);
+             ((TH1F *)(fAcceptedCutList->At(23)))->Fill(chi2PerClusterTPC);
+             ((TH1F *)(fAcceptedCutList->At(27)))->Fill(extCov[0]);
+             ((TH1F *)(fAcceptedCutList->At(31)))->Fill(extCov[2]);
+             ((TH1F *)(fAcceptedCutList->At(35)))->Fill(extCov[5]);
+             ((TH1F *)(fAcceptedCutList->At(39)))->Fill(extCov[9]);
+             ((TH1F *)(fAcceptedCutList->At(43)))->Fill(extCov[14]);
+             ((TH3D *)(fAcceptedCutList->At(47)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        nClustersTPC);
+             ((TH3D *)(fAcceptedCutList->At(51)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        chi2PerClusterTPC);
+             ((TH3D *)(fAcceptedCutList->At(55)))->Fill(track->Eta(),
+                                                        track->Phi()*180./TMath::Pi(),
+                                                        npointsTPCdEdx);
+             ((TH1F *)(fAcceptedCutList->At(59)))->Fill(npointsTPCdEdx);
+             
+             ((TH1F *)(fAcceptedDCAList->At(3)))->Fill(TMath::Abs(dcaXY));
+             ((TH1F *)(fAcceptedDCAList->At(7)))->Fill(TMath::Abs(dcaZ));
+             ((TH1F *)(fAcceptedDCAList->At(11)))->Fill(nSigmaToVertex);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(6)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(6)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH3F *)(fQA2DList->At(11)))->Fill(track->Eta(),gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+             else
+               ((TH3F *)(fQA2DList->At(11)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                            track->Py(),
+                                                            track->Pz()),
+                                                   gPt,
+                                                   ConvertPDGToInt(motherPDGCode));
+           }
          }//secondary particles
-       }//cuts
-       else if(!IsAccepted(track)) {
+       }//accepted - track cuts
+       else if(!fProtonAnalysisBase->IsAccepted(esd,vertex,track)) {
          if(label <= stack->GetNprimary()) {
-            if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(1)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(5)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
+           if(track->Charge() > 0) {
+             ((TH3D *)(fRejectedCutList->At(0)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(4)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(8)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(1)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
+           else if(track->Charge() < 0) {
+             ((TH3D *)(fRejectedCutList->At(1)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(5)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(9)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+                                               
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(5)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(5)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
          }//primary particles
          else if(label > stack->GetNprimary()) {
-           if(track->Charge() > 0)
-              ((TH2D *)(fQA2DList->At(3)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
-            else if(track->Charge() < 0)
-              ((TH2D *)(fQA2DList->At(7)))->Fill(Rapidity(track->Px(),
-                                                         track->Py(),
-                                                         track->Pz()),
-                                                Pt);
+           if(track->Charge() > 0) {
+             ((TH3D *)(fRejectedCutList->At(2)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(6)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(10)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(3)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(3)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
+           else if(track->Charge() < 0) {
+             ((TH3D *)(fRejectedCutList->At(3)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       nClustersTPC);
+             ((TH3D *)(fRejectedCutList->At(7)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       chi2PerClusterTPC);
+             ((TH3D *)(fRejectedCutList->At(11)))->Fill(track->Eta(),
+                                                       track->Phi()*180./TMath::Pi(),
+                                                       npointsTPCdEdx);
+             if(fProtonAnalysisBase->GetEtaMode())
+               ((TH2D *)(fQA2DList->At(7)))->Fill(track->Eta(),gPt);
+             else
+               ((TH2D *)(fQA2DList->At(7)))->Fill(fProtonAnalysisBase->Rapidity(track->Px(),
+                                                           track->Py(),
+                                                           track->Pz()),
+                                                  gPt);
+           }
          }//secondary particles
-       }//cuts
+       }//rejected - track cuts
       }//proton check
     }//combined tracking
   }//track loop
@@ -2258,16 +4432,24 @@ void AliProtonQAAnalysis::InitMCAnalysis() {
   //MC analysis - 3D histograms: y-pT-pdg
   fPDGList = new TList();
   TH3F *gHistYPtPDGProtons = new TH3F("gHistYPtPDGProtons",
-                                     ";y;P_{T} [GeV/c];PDG",
+                                     ";;P_{T} [GeV/c];PDG",
                                      fNBinsY,fMinY,fMaxY,
                                      fNBinsPt,fMinPt,fMaxPt,
                                      14,-0.5,13.5);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPDGProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPDGProtons->GetXaxis()->SetTitle("y");
   fPDGList->Add(gHistYPtPDGProtons);
   TH3F *gHistYPtPDGAntiProtons = new TH3F("gHistYPtPDGAntiProtons",
-                                         ";y;P_{T} [GeV/c];PDG",
+                                         ";;P_{T} [GeV/c];PDG",
                                          fNBinsY,fMinY,fMaxY,
                                          fNBinsPt,fMinPt,fMaxPt,
                                          14,-0.5,13.5);
+  if(fProtonAnalysisBase->GetEtaMode()) 
+    gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("#eta");
+  else 
+    gHistYPtPDGAntiProtons->GetXaxis()->SetTitle("y");
   fPDGList->Add(gHistYPtPDGAntiProtons);
 
   //MC processes
@@ -2316,27 +4498,52 @@ void AliProtonQAAnalysis::InitMCAnalysis() {
 }
 
 //____________________________________________________________________//
-void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
+void AliProtonQAAnalysis::RunMCAnalysis(AliStack* const stack) {
   //Main analysis part - MC 
   for(Int_t iParticle = 0; iParticle < stack->GetNtrack(); iParticle++) {
     TParticle *particle = stack->Particle(iParticle);
+    if(!particle) continue;
+
     if(TMath::Abs(particle->Eta()) > 1.0) continue;//acceptance
+    if((particle->Pt() > fMaxPt)||(particle->Pt() < fMinPt)) continue;
+    if(fProtonAnalysisBase->GetEtaMode()) {
+      if((particle->Eta() > fMaxY)||(particle->Eta() < fMinY)) continue;
+    }
+    else {
+      if((fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) > fMaxY)||(fProtonAnalysisBase->Rapidity(particle->Px(),particle->Py(),particle->Pz()) < fMinY)) continue;
+    }
+
     Int_t pdgcode = particle->GetPdgCode();
     if(pdgcode == 2212) {
-      if(iParticle <= stack->GetNprimary()) 
-       ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
-                                                  particle->Py(),
-                                                  particle->Pz()),
-                                         particle->Pt(),0);
+      if(iParticle <= stack->GetNprimary()) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),particle->Pt(),0);
+       else
+         ((TH3F *)(fPDGList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                    particle->Py(),
+                                                    particle->Pz()),
+                                           particle->Pt(),0);
+      }
       else if(iParticle > stack->GetNprimary()) {
        Int_t lPartMother = particle->GetFirstMother();
        TParticle *motherParticle = stack->Particle(lPartMother);
        if(!motherParticle) continue;
-       ((TH3F *)(fPDGList->At(0)))->Fill(Rapidity(particle->Px(),
-                                                  particle->Py(),
-                                                  particle->Pz()),
-                                         particle->Pt(),
-                                         ConvertPDGToInt(motherParticle->GetPdgCode()));
+       Int_t motherPDGCode = motherParticle->GetPdgCode();
+       if(fMCProcessIdFlag)
+         if(particle->GetUniqueID() != fMCProcessId) continue;
+       if(fMotherParticlePDGCodeFlag)
+         if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
+
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3F *)(fPDGList->At(0)))->Fill(particle->Eta(),
+                                           particle->Pt(),
+                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
+       else
+         ((TH3F *)(fPDGList->At(0)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                    particle->Py(),
+                                                    particle->Pz()),
+                                           particle->Pt(),
+                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
        //processes
        if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
          ((TH1F *)(fMCProcessesList->At(0)))->Fill(particle->GetUniqueID());
@@ -2366,20 +4573,35 @@ void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
     }//pdgcode of proton
 
     if(pdgcode == -2212) {
-      if(iParticle <= stack->GetNprimary()) 
-       ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
-                                                  particle->Py(),
-                                                  particle->Pz()),
-                                         particle->Pt(),0);
+      if(iParticle <= stack->GetNprimary()) {
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),particle->Pt(),0);
+       else
+         ((TH3F *)(fPDGList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                    particle->Py(),
+                                                    particle->Pz()),
+                                           particle->Pt(),0);
+      }
       else if(iParticle > stack->GetNprimary()) {
        Int_t lPartMother = particle->GetFirstMother();
        TParticle *motherParticle = stack->Particle(lPartMother);
        if(!motherParticle) continue;
-       ((TH3F *)(fPDGList->At(1)))->Fill(Rapidity(particle->Px(),
-                                                  particle->Py(),
-                                                  particle->Pz()),
-                                         particle->Pt(),
-                                         ConvertPDGToInt(motherParticle->GetPdgCode()));
+       Int_t motherPDGCode = motherParticle->GetPdgCode();
+       if(fMCProcessIdFlag)
+         if(particle->GetUniqueID() != fMCProcessId) continue;
+       if(fMotherParticlePDGCodeFlag)
+         if(TMath::Abs(motherPDGCode) != fMotherParticlePDGCode) continue;
+
+       if(fProtonAnalysisBase->GetEtaMode())
+         ((TH3F *)(fPDGList->At(1)))->Fill(particle->Eta(),
+                                           particle->Pt(),
+                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
+       else
+         ((TH3F *)(fPDGList->At(1)))->Fill(fProtonAnalysisBase->Rapidity(particle->Px(),
+                                                    particle->Py(),
+                                                    particle->Pz()),
+                                           particle->Pt(),
+                                           ConvertPDGToInt(motherParticle->GetPdgCode()));
 
        //processes
        if(TMath::Abs(motherParticle->GetPdgCode()) == 130)
@@ -2405,7 +4627,7 @@ void AliProtonQAAnalysis::RunMCAnalysis(AliStack* stack) {
 }
 
 //____________________________________________________________________//
-Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) {
+Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) const {
   //Converts the pdg code to an int based on the following scheme:
   //1: PDG code: 130 - Name: K_L0
   //2: PDG code: 211 - Name: pi+
@@ -2483,5 +4705,3 @@ Int_t AliProtonQAAnalysis::ConvertPDGToInt(Int_t pdgCode) {
 
 
 
-
-