]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliAnalysisTaskSEHFQA.cxx
Fix in histogram binning
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSEHFQA.cxx
index 4dfc8c4e398b057a3a6f67c240faa76308cee7e9..5924880de3999d88d6340223d35e89a14d9b61bf 100644 (file)
 #include <TList.h>
 #include <TH1F.h>
 #include <TH2F.h>
+#include <TH3F.h>
+#include <TProfile2D.h>
 #include <TDatabasePDG.h>
 
 #include <AliAnalysisDataSlot.h>
 #include <AliAnalysisDataContainer.h>
 #include "AliAnalysisManager.h"
 #include "AliESDtrack.h"
+#include "AliESDVertex.h"
 #include "AliVertexerTracks.h"
 #include "AliPID.h"
+#include "AliPIDResponse.h"
 #include "AliTPCPIDResponse.h"
 #include "AliAODHandler.h"
 #include "AliAODEvent.h"
 #include "AliRDHFCutsDStartoKpipi.h"
 #include "AliRDHFCutsD0toKpi.h"
 #include "AliRDHFCutsLctopKpi.h"
+#include "AliRDHFCutsLctoV0.h"
 #include "AliInputEventHandler.h"
 
+#include "AliFlowEvent.h"
+#include "AliFlowTrackCuts.h"
+#include "AliFlowTrackSimple.h"
+#include "AliFlowVector.h"
+
 #include "AliAnalysisTaskSEHFQA.h"
 
+using std::cout;
+using std::endl;
+
 ClassImp(AliAnalysisTaskSEHFQA)
 
 //____________________________________________________________________________
@@ -70,18 +83,24 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA():AliAnalysisTaskSE(),
   fOutputCounters(0x0),
   fOutputCheckCentrality(0x0),
   fOutputEvSelection(0x0),
+  fOutputFlowObs(0x0),
   fDecayChannel(AliAnalysisTaskSEHFQA::kD0toKpi),
   fCuts(0x0),
+  fFlowEvent(0x0),
+  fRFPcuts(0x0),
   fEstimator(AliRDHFCuts::kCentTRK),
   fReadMC(kFALSE),
   fSimpleMode(kFALSE),
-  fOnOff()
+  fUseSelectionBit(kTRUE),
+  fOnOff(),
+  fFillDistrTrackEffChecks(kFALSE)
 {
   //default constructor
   fOnOff[0]=kTRUE;
   fOnOff[1]=kTRUE;
   fOnOff[2]=kTRUE;
   fOnOff[3]=kTRUE;
+  fOnOff[4]=kTRUE;
 }
 
 //____________________________________________________________________________
@@ -93,12 +112,17 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
   fOutputCounters(0x0),
   fOutputCheckCentrality(0x0),
   fOutputEvSelection(0x0),
+  fOutputFlowObs(0x0),
   fDecayChannel(ch),
   fCuts(0x0),
+  fFlowEvent(0x0),
+  fRFPcuts(0x0),
   fEstimator(AliRDHFCuts::kCentTRK),
   fReadMC(kFALSE),
   fSimpleMode(kFALSE),
-  fOnOff()
+  fUseSelectionBit(kTRUE),
+  fOnOff(),
+  fFillDistrTrackEffChecks(kFALSE)
 {
   //constructor
 
@@ -109,6 +133,7 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
   fOnOff[1]=kTRUE;
   fOnOff[2]=kTRUE;
   fOnOff[3]=kTRUE;
+  fOnOff[4]=kTRUE;
 
   // Output slot #1 writes into a TH1F container (number of events)
   DefineOutput(1,TH1F::Class());  //My private output
@@ -136,6 +161,9 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
   case 5:
     DefineOutput(4,AliRDHFCutsLctopKpi::Class());  //My private output
     break;
+  case kLambdactoV0:
+    DefineOutput(4,AliRDHFCutsLctoV0::Class());  //My private output
+    break;
   }
   if (fOnOff[2]) {
     // Output slot #5 writes into a TList container (AliCounterCollection)
@@ -145,6 +173,7 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
   }
 
   if(fOnOff[3]) DefineOutput(7,TList::Class());  //My private output
+  if(fOnOff[4]) DefineOutput(8,TList::Class());  //My private output
 
 }
 
@@ -164,6 +193,10 @@ AliAnalysisTaskSEHFQA::~AliAnalysisTaskSEHFQA()
 
   delete fOutputEvSelection;
 
+  if(fOnOff[4]) {
+    delete fOutputFlowObs;
+    delete fFlowEvent;
+  }
 }
 
 //___________________________________________________________________________
@@ -171,56 +204,60 @@ void AliAnalysisTaskSEHFQA::Init(){
 
   //initialization
   if(fDebug > 1) printf("AnalysisTaskSEHFQA::Init() \n");
+  AliRDHFCuts *copycut = 0x0;
 
   switch(fDecayChannel){
   case 0:
     {
-      AliRDHFCutsDplustoKpipi* copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
     }
     break;
   case 1:
     {
-      AliRDHFCutsD0toKpi* copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
     }
     break;
   case 2:
     {
-      AliRDHFCutsDStartoKpipi* copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
     }
     break;
   case 3:
     {
-      AliRDHFCutsDstoKKpi* copycut=new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
     }
     break;
   case 4:
     {
-      AliRDHFCutsD0toKpipipi* copycut=new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
     }
     break;
   case 5:
     {
-      AliRDHFCutsLctopKpi* copycut=new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
-      // Post the data
-      PostData(4,copycut);
+      copycut=new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
+    }
+    break;
+  case kLambdactoV0:
+    {
+      copycut=new AliRDHFCutsLctoV0(*(static_cast<AliRDHFCutsLctoV0*>(fCuts)));
     }
     break;
-
   default:
-    return;
-  }
+    AliFatal("Bad initialization for the decay channe - Exiting...");
+    break;
+  }  
 
+  const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
+  if (copycut){
+    copycut->SetName(nameoutput);
+    
+    // Post the data
+    PostData(4,copycut);
+  }else{
+    AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
+  }    
 
+  return;
 
 }
 
@@ -240,14 +277,12 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
   fNEntries->GetXaxis()->SetBinLabel(4,"nCandidates(AnCuts)");
   fNEntries->GetXaxis()->SetBinLabel(5,"EventsWithGoodVtx");
   //fNEntries->GetXaxis()->SetBinLabel(6,"N. of 0SMH");
-  fNEntries->GetXaxis()->SetBinLabel(6,"N. of CSH1");
+  fNEntries->GetXaxis()->SetBinLabel(6,"N candidates");
   if(fReadMC){
     fNEntries->GetXaxis()->SetBinLabel(7,"MC Cand from c");
     fNEntries->GetXaxis()->SetBinLabel(8,"MC Cand from b");
     fNEntries->GetXaxis()->SetBinLabel(9,"N fake Trks");
     fNEntries->GetXaxis()->SetBinLabel(10,"N true Trks");
-  } else{
-    fNEntries->GetXaxis()->SetBinLabel(7,"N candidates");
   }
 
   fNEntries->GetXaxis()->SetNdivisions(1,kFALSE);
@@ -259,7 +294,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputPID->SetName(GetOutputSlot(2)->GetContainer()->GetName());
 
     //TOF pid
-    TH1F* hTOFflags=new TH1F("hTOFflags","TOF flags",6,-0.5,5.5);
+    TH1F* hTOFflags=new TH1F("hTOFflags","TOF flags",7,-0.5,6.5);
     hTOFflags->SetMinimum(0.);
     hTOFflags->GetXaxis()->SetBinLabel(1,"All Tracks");
     hTOFflags->GetXaxis()->SetBinLabel(2,"kTPCout");
@@ -267,10 +302,28 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hTOFflags->GetXaxis()->SetBinLabel(4,"kTIME");
     hTOFflags->GetXaxis()->SetBinLabel(5,"kTOFpid");
     hTOFflags->GetXaxis()->SetBinLabel(6,"kTOFmismatch");
+    hTOFflags->GetXaxis()->SetBinLabel(7,"kDetPidOK");
 
     TString hname="hTOFsig";
     TH1F* hTOFsig=new TH1F(hname.Data(),"Distribution of TOF signal;TOF time [ps];Entries", 100, -2.e3,40.e3);
 
+    hname="hTOFstartTimeMask";
+    TH1F* hTOFstartTimeMask=new TH1F(hname.Data(),"TOF start time mask; Mask ;Entries", 8, -0.5,7.5);
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(1,"FILL");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(2,"TOF");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(3,"T0A");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(4,"TOF.and.T0A");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(5,"T0C");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(6,"TOF.and.T0C");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(7,"T0AC");
+    hTOFstartTimeMask->GetXaxis()->SetBinLabel(8,"TOF.and.T0AC");
+
+    hname="hTOFstartTimeRes";
+    TH1F* hTOFstartTimeRes=new TH1F(hname.Data(),"TOF start time resolution; Resolution (ps) ;Entries", 100, 0.,300.);
+
+    hname="hTOFstartTimeDistrib";
+    TH1F* hTOFstartTimeDistrib=new TH1F(hname.Data(),"TOF start time distribution; Start time ;Entries", 400, -1000.,1000.);
+
     hname="hTOFtime";
     TH1F* hTOFtime=new TH1F(hname.Data(),"Distribution of TOF time Kaon;TOF time(Kaon) [ps];Entries", 1000, 0.,50000.);
 
@@ -321,6 +374,9 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputPID->Add(hTOFflags);
     fOutputPID->Add(hTOFsig);
     fOutputPID->Add(hTPCsig);
+    fOutputPID->Add(hTOFstartTimeMask);
+    fOutputPID->Add(hTOFstartTimeRes);
+    fOutputPID->Add(hTOFstartTimeDistrib);
     fOutputPID->Add(hTOFtime);
     fOutputPID->Add(hTOFtimeKaonHyptime);
     fOutputPID->Add(hTOFtimeKaonHyptimeAC);
@@ -335,6 +391,36 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputPID->Add(hTPCsigmaK);
     fOutputPID->Add(hTPCsigmaPion);
     fOutputPID->Add(hTPCsigmaProton);
+
+    if(fReadMC){
+      //TOF
+      hname="hTOFsigmaMCKSigPid";
+      TH2F* hTOFsigmaMCKSigPid=new TH2F(hname.Data(),"(TOFsignal-timeK)/tofSigPid;p[GeV/c];(TOFsignal-timeK)/tofSigPid",500,0.,10.,400,-20,20);
+
+      hname="hTOFsigmaMCPionSigPid";
+      TH2F* hTOFsigmaMCPionSigPid=new TH2F(hname.Data(),"(TOFsignal-time#pi)/tofSigPid;p[GeV/c];(TOFsignal-time#pi)/tofSigPid",500,0.,10.,400,-20,20);
+
+      hname="hTOFsigmaMCProtonSigPid";
+      TH2F* hTOFsigmaMCProtonSigPid=new TH2F(hname.Data(),"(TOFsignal-timep)/tofSigPid;p[GeV/c];(TOFsignal-time p)/tofSigPid",500,0.,10.,400,-20,20);
+
+      //TPC
+      hname="hTPCsigmaMCK";
+      TH2F* hTPCsigmaMCK=new TH2F(hname.Data(),"TPC Sigma for K as a function of momentum;p[GeV/c];Sigma Kaon",500,0.,10.,400,-20,20);
+
+      hname="hTPCsigmaMCPion";
+      TH2F* hTPCsigmaMCPion=new TH2F(hname.Data(),"TPC Sigma for #pi as a function of momentum;p[GeV/c];Sigma #pi",500,0.,10.,400,-20,20);
+
+      hname="hTPCsigmaMCProton";
+      TH2F* hTPCsigmaMCProton=new TH2F(hname.Data(),"TPC Sigma for proton as a function of momentum;p[GeV/c];Sigma Proton",500,0.,10.,400,-20,20);
+
+      fOutputPID->Add(hTOFsigmaMCKSigPid);
+      fOutputPID->Add(hTOFsigmaMCPionSigPid);
+      fOutputPID->Add(hTOFsigmaMCProtonSigPid);
+      fOutputPID->Add(hTPCsigmaMCK);
+      fOutputPID->Add(hTPCsigmaMCPion);
+      fOutputPID->Add(hTPCsigmaMCProton);
+
+    }
   }
 
   //quality of the tracks
@@ -356,10 +442,22 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hname="hnLayerITS";
     TH1F* hnLayerITS=new TH1F(hname.Data(),"Number of tracks with point in layer;ITS layer;",7,-1.5,5.5);
     hnLayerITS->GetXaxis()->SetBinLabel(1,"n tracks");
+    hnLayerITS->GetXaxis()->SetBinLabel(2,"SPDin");
+    hnLayerITS->GetXaxis()->SetBinLabel(3,"SPDout");
+    hnLayerITS->GetXaxis()->SetBinLabel(4,"SDDin");
+    hnLayerITS->GetXaxis()->SetBinLabel(5,"SDDout");
+    hnLayerITS->GetXaxis()->SetBinLabel(6,"SSDin");
+    hnLayerITS->GetXaxis()->SetBinLabel(7,"SSDout");
 
     hname="hnLayerITSsa";
     TH1F* hnLayerITSsa=new TH1F(hname.Data(),"Number of tracks with point in layer;ITS layer;",7,-1.5,5.5);
     hnLayerITSsa->GetXaxis()->SetBinLabel(1,"n tracks");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(2,"SPDin");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(3,"SPDout");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(4,"SDDin");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(5,"SDDout");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(6,"SSDin");
+    hnLayerITSsa->GetXaxis()->SetBinLabel(7,"SSDout");
    
     hname="hnClsSPD";
     TH1F* hnClsSPD=new TH1F(hname.Data(),"Distribution of number of SPD clusters;nSPDcls;Entries",3,-0.5,2.5);
@@ -368,16 +466,188 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     TH1F* hptGoodTr=new TH1F(hname.Data(),"Pt distribution of 'good' tracks;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
     hptGoodTr->SetTitleOffset(1.3,"Y");
 
+    if(!fSimpleMode){
+      hname="hptGoodTrFromDaugh";
+      TH1F* hptGoodTrFromDaugh=new TH1F(hname.Data(),"Pt distribution of 'good' candidate's daughters;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
+      hptGoodTrFromDaugh->SetTitleOffset(1.3,"Y");
+      fOutputTrack->Add(hptGoodTrFromDaugh);
+    }
+
     hname="hdistrGoodTr";
-    TH1F* hdistrGoodTr=new TH1F(hname.Data(),"Distribution of number of 'good' tracks per event;no.good-tracks/ev;Entries",4000,-0.5,3999.5);
+    TH1F* hdistrGoodTr=new TH1F(hname.Data(),"Distribution of number of 'good' candidate's daughters per event;no.good-tracks/ev;Entries",4000,-0.5,3999.5);
     hdistrGoodTr->SetTitleOffset(1.3,"Y");
 
-    hname="hd0";
-    TH1F* hd0=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of 'good' tracks;d_{0rphi}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+    hname="hdistrSelTr";
+    TH1F* hdistrSelTr=new TH1F(hname.Data(),"Distribution of number of Selected tracks per event;no.good-tracks/ev;Entries",4000,-0.5,3999.5);
+    hdistrSelTr->SetTitleOffset(1.3,"Y");
 
-    hname="hd0z";
-    TH1F* hd0z=new TH1F(hname.Data(),"Impact parameter (z) distribution of 'good' tracks;d_{0z}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+    hname="hd0dau";
+    TH1F* hd0dau=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of D daughter tracks;d_{0rphi}[cm];Entries/10^{3} cm",200,-0.1,0.1);
 
+    hname="hd0zdau";
+    TH1F* hd0zdau=new TH1F(hname.Data(),"Impact parameter (z) distribution of D daughter tracks;d_{0z}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+
+    hname="hd0TracksSPDin";
+    TH1F* hd0TracksSPDin=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks kITSrefit, SPDinner; d_{0rphi}[cm];Entries",200,-0.5,0.5);
+
+    hname="hd0TracksSPDany";
+    TH1F* hd0TracksSPDany=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks kITSrefit, SPDany; d_{0rphi}[cm];Entries",200,-0.5,0.5);
+
+    hname="hd0TracksFilterBit4";
+    TH1F* hd0TracksFilterBit4=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks FilterBit4; d_{0rphi}[cm];Entries",200,-0.5,0.5);
+
+    hname="hd0TracksTPCITSSPDany";
+    TH1F* hd0TracksTPCITSSPDany=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks TPC+ITScuts+SPDany; d_{0rphi}[cm];Entries",200,-0.5,0.5);
+
+
+    if(fFillDistrTrackEffChecks){
+      hname="hPtDaughters";
+      TH1F *hPtDaughters=new TH1F(hname.Data(),"p_{T} distributions of the daughter tracks;p_{T} [GeV/c];Entries",200,0.,20.);
+    
+      hname="hPhiDaughters";
+      TH1F *hPhiDaughters=new TH1F(hname.Data(),"#phi distribution of the daughter tracks;#phi [rad];Entries",100,0.,2*(TMath::Pi()));
+    
+      hname="hEtaDaughters";
+      TH1F *hEtaDaughters=new TH1F(hname.Data(),"#eta distribution of the daughter tracks;#eta;Entries",80,-2.,2.);
+    
+      hname="hEtavsPhiDaughters";
+      TH2F *hEtavsPhiDaughters=new TH2F(hname.Data(),"#eta vs #phi distribution of the daughter tracks;#phi;#eta",100,0.,2*(TMath::Pi()),80,-2.,2.);
+    
+      hname="hNTPCclsvsPtDaughters";
+      TH2F *hNTPCclsvsPtDaughters=new TH2F(hname.Data(),"N TPC clusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N TPC cls",200,0.,20.,85,-0.5,169.5);
+    
+      hname="hNTPCclsvsPhiDaughters";
+      TH2F *hNTPCclsvsPhiDaughters=new TH2F(hname.Data(),"N TPC clusters vs #phi distribution of the daughter tracks;#phi [rad];N TPC cls",100,0.,2*(TMath::Pi()),85,-0.5,169.5);
+      
+      hname="hNTPCclsvsEtaDaughters";
+      TH2F *hNTPCclsvsEtaDaughters=new TH2F(hname.Data(),"N TPC clusters vs #eta distribution of the daughter tracks;#eta;N TPC cls",80,-2.,2.,85,-0.5,169.5);
+
+      hname="hNTPCCrossedRowsvsPtDaughters";
+      TH2F *hNTPCCrossedRowsvsPtDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N TPC cros. rows",200,0.,20.,100,-0.5,199.5);
+    
+      hname="hNTPCCrossedRowsvsPhiDaughters";
+      TH2F *hNTPCCrossedRowsvsPhiDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs #phi distribution of the daughter tracks;#phi [rad];N TPC cros. rows",100,0.,2*(TMath::Pi()),100,-0.5,199.5);
+      
+      hname="hNTPCCrossedRowsvsEtaDaughters";
+      TH2F *hNTPCCrossedRowsvsEtaDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs #eta distribution of the daughter tracks;#eta;N TPC cros. rows",80,-2.,2.,100,-0.5,199.5);
+      hname="hRatioCRowsOverFclsvsPtDaughters";
+      TH2F *hRatioCRowsOverFclsvsPtDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];CRows/FCls",200,0.,20,100,0.,1.);
+   
+      hname="hRatioCRowsOverFclsvsPhiDaughters";
+      TH2F *hRatioCRowsOverFclsvsPhiDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #phi distribution of the daughter tracks;#phi [rad];CRows/FCls",100,0.,2*(TMath::Pi()),100,0.,1.);
+    
+      hname="hRatioCRowsOverFclsvsEtaDaughters";
+      TH2F *hRatioCRowsOverFclsvsEtaDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #eta distribution of the daughter tracks;#eta;CRows/FCls",80,-2.,2.,100,0.,1.);
+    
+      hname="hNITSclsvsPtDaughters";
+      TH2F *hNITSclsvsPtDaughters=new TH2F(hname.Data(),"N ITS clusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N ITS cls",200,0.,20,7,-0.5,6.5);
+    
+      hname="hNITSclsvsPhiDaughters";
+      TH2F *hNITSclsvsPhiDaughters=new TH2F(hname.Data(),"N ITS clusters vs #phi distribution of the daughter tracks;#phi [rad];N ITS cls",100,0.,2*(TMath::Pi()),7,-0.5,6.5);
+    
+      hname="hNITSclsvsEtaDaughters";
+      TH2F *hNITSclsvsEtaDaughters=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the daughter tracks;#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
+    
+      hname="hSPDclsDaughters";
+      TH1I *hSPDclsDaughters = new TH1I(hname.Data(),"N SPD points distrubution; ;Entries",4,0,4);
+      hSPDclsDaughters->GetXaxis()->SetBinLabel(1, "no SPD");
+      hSPDclsDaughters->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
+      hSPDclsDaughters->GetXaxis()->SetBinLabel(3, "kOnlySecond");
+      hSPDclsDaughters->GetXaxis()->SetBinLabel(4, "kBoth");
+
+      hname="hPtAllTracks";
+      TH1F *hPtAllTracks=new TH1F(hname.Data(),"p_{T} distributions of the AOD tracks (ID>0);p_{T} [GeV/c];Entries",200,0.,20.);
+    
+      hname="hPhiAllTracks";
+      TH1F *hPhiAllTracks=new TH1F(hname.Data(),"#phi distribution of the AOD tracks (ID>0);#phi [rad];Entries",100,0.,2*(TMath::Pi()));
+    
+      hname="hEtaAllTracks";
+      TH1F *hEtaAllTracks=new TH1F(hname.Data(),"#eta distribution of the AOD tracks (ID>0);#eta;Entries",80,-2.,2.);
+    
+      hname="hEtavsPhiAllTracks";
+      TH2F *hEtavsPhiAllTracks=new TH2F(hname.Data(),"#eta vs #phi distribution of the AOD tracks (ID>0);#phi;#eta",100,0.,2*(TMath::Pi()),80,-2.,2.);
+    
+      hname="hNTPCclsvsPtAllTracks";
+      TH2F *hNTPCclsvsPtAllTracks=new TH2F(hname.Data(),"N TPC clusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];N TPC cls",200,0.,20,85,-0.5,169.5);
+    
+      hname="hNTPCclsvsPhiAllTracks";
+      TH2F *hNTPCclsvsPhiAllTracks=new TH2F(hname.Data(),"N TPC clusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];N TPC cls",100,0.,2*(TMath::Pi()),85,-0.5,169.5);
+      
+      hname="hNTPCclsvsEtaAllTracks";
+      TH2F *hNTPCclsvsEtaAllTracks=new TH2F(hname.Data(),"N TPC clusters vs #eta distribution of the AOD tracks (ID>0);#eta;N TPC cls",80,-2.,2.,85,-0.5,169.5);
+
+      hname="hNTPCCrossedRowsvsPtAllTracks";
+      TH2F *hNTPCCrossedRowsvsPtAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs p_{T} distribution of the AOD tracks;p_{T} [GeV/c];N TPC cros. rows",200,0.,20.,100,-0.5,199.5);
+    
+      hname="hNTPCCrossedRowsvsPhiAllTracks";
+      TH2F *hNTPCCrossedRowsvsPhiAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs #phi distribution of the AOD tracks;#phi [rad];N TPC cros. rows",100,0.,2*(TMath::Pi()),100,-0.5,199.5);
+      
+      hname="hNTPCCrossedRowsvsEtaAllTracks";
+      TH2F *hNTPCCrossedRowsvsEtaAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs #eta distribution of the AOD tracks;#eta;N TPC cros. rows",80,-2.,2.,100,-0.5,199.5);
+      hname="hRatioCRowsOverFclsvsPtAllTracks";
+      TH2F *hRatioCRowsOverFclsvsPtAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];CRows/FCls",200,0.,20,100,0.,1.);
+   
+      hname="hRatioCRowsOverFclsvsPhiAllTracks";
+      TH2F *hRatioCRowsOverFclsvsPhiAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];CRows/FCls",100,0.,2*(TMath::Pi()),100,0.,1.);
+    
+      hname="hRatioCRowsOverFclsvsEtaAllTracks";
+      TH2F *hRatioCRowsOverFclsvsEtaAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #eta distribution of the AOD tracks (ID>0);#eta;CRows/FCls",80,-2.,2.,100,0.,1.);
+    
+      hname="hNITSclsvsPtAllTracks";
+      TH2F *hNITSclsvsPtAllTracks=new TH2F(hname.Data(),"N ITS clusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];N ITS cls",200,0.,20,7,-0.5,6.5);
+    
+      hname="hNITSclsvsPhiAllTracks";
+      TH2F *hNITSclsvsPhiAllTracks=new TH2F(hname.Data(),"N ITS clusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];N ITS cls",100,0.,2*(TMath::Pi()),7,-0.5,6.5);
+    
+      hname="hNITSclsvsEtaAllTracks";
+      TH2F *hNITSclsvsEtaAllTracks=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the AOD tracks (ID>0);#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
+    
+      hname="hSPDclsAllTracks";
+      TH1I *hSPDclsAllTracks = new TH1I(hname.Data(),"N SPD points distrubution AOD tracks (ID>0); ;Entries",4,0,4);
+      hSPDclsAllTracks->GetXaxis()->SetBinLabel(1, "no SPD");
+      hSPDclsAllTracks->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
+      hSPDclsAllTracks->GetXaxis()->SetBinLabel(3, "kOnlySecond");
+      hSPDclsAllTracks->GetXaxis()->SetBinLabel(4, "kBoth");
+
+      fOutputTrack->Add(hPtDaughters);
+      fOutputTrack->Add(hPhiDaughters);
+      fOutputTrack->Add(hEtaDaughters);
+      fOutputTrack->Add(hEtavsPhiDaughters);
+      fOutputTrack->Add(hNTPCclsvsPtDaughters);
+      fOutputTrack->Add(hNTPCclsvsPhiDaughters);
+      fOutputTrack->Add(hNTPCclsvsEtaDaughters);
+      fOutputTrack->Add(hNTPCCrossedRowsvsPtDaughters);
+      fOutputTrack->Add(hNTPCCrossedRowsvsPhiDaughters);
+      fOutputTrack->Add(hNTPCCrossedRowsvsEtaDaughters);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsPtDaughters);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsPhiDaughters);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsEtaDaughters);
+      fOutputTrack->Add(hNITSclsvsPtDaughters);
+      fOutputTrack->Add(hNITSclsvsPhiDaughters);
+      fOutputTrack->Add(hNITSclsvsEtaDaughters);
+      fOutputTrack->Add(hSPDclsDaughters);
+      fOutputTrack->Add(hPtAllTracks);
+      fOutputTrack->Add(hPhiAllTracks);
+      fOutputTrack->Add(hEtaAllTracks);
+      fOutputTrack->Add(hEtavsPhiAllTracks);
+      fOutputTrack->Add(hNTPCclsvsPtAllTracks);
+      fOutputTrack->Add(hNTPCclsvsPhiAllTracks);
+      fOutputTrack->Add(hNTPCclsvsEtaAllTracks);
+      fOutputTrack->Add(hNTPCCrossedRowsvsPtAllTracks);
+      fOutputTrack->Add(hNTPCCrossedRowsvsPhiAllTracks);
+      fOutputTrack->Add(hNTPCCrossedRowsvsEtaAllTracks);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsPtAllTracks);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsPhiAllTracks);
+      fOutputTrack->Add(hRatioCRowsOverFclsvsEtaAllTracks);
+      fOutputTrack->Add(hNITSclsvsPtAllTracks);
+      fOutputTrack->Add(hNITSclsvsPhiAllTracks);
+      fOutputTrack->Add(hNITSclsvsEtaAllTracks);
+      fOutputTrack->Add(hSPDclsAllTracks);
+
+    }
+    
     fOutputTrack->Add(hnClsITS);
     fOutputTrack->Add(hnClsITSselTr);
     fOutputTrack->Add(hnClsITSSA);
@@ -386,13 +656,19 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputTrack->Add(hnClsSPD);
     fOutputTrack->Add(hptGoodTr);
     fOutputTrack->Add(hdistrGoodTr);
-    fOutputTrack->Add(hd0);
-    fOutputTrack->Add(hd0z);
+    fOutputTrack->Add(hdistrSelTr);
+    fOutputTrack->Add(hd0TracksSPDin);
+    fOutputTrack->Add(hd0TracksSPDany);
+    fOutputTrack->Add(hd0TracksFilterBit4);
+    fOutputTrack->Add(hd0TracksTPCITSSPDany);
+    fOutputTrack->Add(hd0dau);
+    fOutputTrack->Add(hd0zdau);
+    
 
     if(fReadMC){
       hname="hdistrFakeTr";
       TH1F* hdistrFakeTr=new TH1F(hname.Data(),"Distribution of number of fake tracks per event;no.fake-tracks/ev;Entries",4000,-0.5,3999.5);
-      hdistrGoodTr->SetTitleOffset(1.3,"Y");
+      hdistrFakeTr->SetTitleOffset(1.3,"Y");
 
       hname="hd0f";
       TH1F* hd0f=new TH1F(hname.Data(),"Impact parameter distribution of fake tracks;d_{0}[cm];Entries/10^{3} cm",200,-0.1,0.1);
@@ -400,6 +676,12 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       hname="hptFakeTr";
       TH1F* hptFakeTr=new TH1F(hname.Data(),"Pt distribution of fake tracks;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
       hptFakeTr->SetTitleOffset(1.3,"Y");
+      if(!fSimpleMode){
+       hname="hptFakeTrFromDaugh";
+       TH1F* hptFakeTrFromDaugh=new TH1F(hname.Data(),"Pt distribution of fake tracks from daughters;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
+       hptFakeTrFromDaugh->SetTitleOffset(1.3,"Y");
+       fOutputTrack->Add(hptFakeTrFromDaugh);
+      }
 
       fOutputTrack->Add(hptFakeTr);
       fOutputTrack->Add(hdistrFakeTr);
@@ -446,14 +728,41 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     TH1F* hMultOut=new TH1F(hname.Data(),"Multiplicity out of Centrality range;multiplicity;Entries",10000,-0.5,9999.5);
 
     hname="hMultvsPercentile";
-    TH2F* hMultvsPercentile=new TH2F(hname.Data(),"Multiplicity vs Percentile;multiplicity;percentile",10000,-0.5,9999.5,12,-10.,110);
+    TH2F* hMultvsPercentile=new TH2F(hname.Data(),"Multiplicity vs Percentile;multiplicity;percentile",10000,-0.5,9999.5,240,-10.,110);
+
+    hname="hntrklvsPercentile";
+    TH2F* hntrklvsPercentile=new TH2F(hname.Data(),"N tracklets vs Percentile;ntracklets;percentile",5000,-0.5,4999.5,240,-10.,110);
+
+    hname="hnTPCTracksvsPercentile";
+    TH2F* hnTPCTracksvsPercentile=new TH2F(hname.Data(),"N TPC tracks vs Percentile;nTPCTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
+
+    hname="hnTPCITSTracksvsPercentile";
+    TH2F* hnTPCITSTracksvsPercentile=new TH2F(hname.Data(),"N TPC+ITS tracks vs Percentile;nTPCITSTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
+
+    hname="hnTPCITS1SPDTracksvsPercentile";
+    TH2F* hnTPCITS1SPDTracksvsPercentile=new TH2F(hname.Data(),"N TPC+ITS+1SPD tracks vs Percentile;nTPCITS1SPDTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
+
+    hname="hV0MultiplicityPercentile";
+    TH2F*hV0MultiplicityPercentile = new TH2F(hname.Data(),"V0 Multiplicity vs Percentile;V0 multiplicity;percentile",1000,-0.5,9999.5,120,-10.,110);
 
+    hname="hV0MultiplicityNtrackletsIn";
+    TH2F*hV0MultiplicityNtrackletsIn = new TH2F(hname.Data(),"V0 Multiplicity vs Number of tracklets in the CC;V0 multiplicity;percentile",1000,-0.5,9999.5,5000,-0.5,4999.5);
+
+    hname="hStdPercentileSPDPercentile";
+    TH2F* hStdPercentileSPDPercentile = new TH2F(hname.Data(),"Std estimator Percentile Vs SPD Percentile;Std estimator percentile;SPD percentile",120,-10.,110,120,-10.,110);
 
     fOutputCheckCentrality->Add(hNtrackletsIn);
     fOutputCheckCentrality->Add(hNtrackletsOut);
     fOutputCheckCentrality->Add(hMultIn);
     fOutputCheckCentrality->Add(hMultOut);
     fOutputCheckCentrality->Add(hMultvsPercentile);
+    fOutputCheckCentrality->Add(hntrklvsPercentile);
+    fOutputCheckCentrality->Add(hnTPCTracksvsPercentile);
+    fOutputCheckCentrality->Add(hnTPCITSTracksvsPercentile);
+    fOutputCheckCentrality->Add(hnTPCITS1SPDTracksvsPercentile);
+    fOutputCheckCentrality->Add(hV0MultiplicityPercentile);
+    fOutputCheckCentrality->Add(hV0MultiplicityNtrackletsIn);
+    fOutputCheckCentrality->Add(hStdPercentileSPDPercentile);
 
     PostData(6,fOutputCheckCentrality);
   
@@ -479,10 +788,24 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     evselection->AddRubric("evnonsel","zvtx");
     evselection->Init();
 
-    TH1F* hzvtx=new TH1F("hzvtx", "Distribution of z_{VTX};z_{VTX} [cm];Entries",100,-20,20);
-
-
-    TH2F* hTrigCent=new TH2F("hTrigCent","Centrality vs. Trigger types",12,-1.5,10.5,12,-10,110);
+    TH1F* hxvtx=new TH1F("hxvtx", "Distribution of x_{VTX};x_{VTX} [cm];Entries",800,-1,1);
+    TH1F* hyvtx=new TH1F("hyvtx", "Distribution of y_{VTX};y_{VTX} [cm];Entries",800,-1,1);
+    TH1F* hzvtx=new TH1F("hzvtx", "Distribution of z_{VTX};z_{VTX} [cm];Entries",800,-30,30);
+    TH1F* hxvtxSelEv=new TH1F("hxvtxSelEv", "Distribution of x_{VTX} Selected Ev;x_{VTX} [cm];Entries",800,-1,1);
+    TH1F* hyvtxSelEv=new TH1F("hyvtxSelEv", "Distribution of y_{VTX} Selected Ev;y_{VTX} [cm];Entries",800,-1,1);
+    TH1F* hzvtxSelEv=new TH1F("hzvtxSelEv", "Distribution of z_{VTX} Selected Ev;z_{VTX} [cm];Entries",800,-30,30);
+    TH1F* hWhichVert=new TH1F("hWhichVert","Vertex Type",4,-1.5,2.5);
+    hWhichVert->GetXaxis()->SetBinLabel(1,"Not found");
+    hWhichVert->GetXaxis()->SetBinLabel(2,"Track");
+    hWhichVert->GetXaxis()->SetBinLabel(3,"SPD-3D");
+    hWhichVert->GetXaxis()->SetBinLabel(4,"SPD-z");
+    TH1F* hWhichVertSelEv=new TH1F("hWhichVertSelEv","Vertex Type",4,-1.5,2.5);
+    hWhichVertSelEv->GetXaxis()->SetBinLabel(1,"Not found");
+    hWhichVertSelEv->GetXaxis()->SetBinLabel(2,"Track");
+    hWhichVertSelEv->GetXaxis()->SetBinLabel(3,"SPD-3D");
+    hWhichVertSelEv->GetXaxis()->SetBinLabel(4,"SPD-z");
+
+    TH2F* hTrigCent=new TH2F("hTrigCent","Centrality vs. Trigger types",14,-1.5,12.5,12,-10,110);
     hTrigCent->GetXaxis()->SetBinLabel(1,"All");
     hTrigCent->GetXaxis()->SetBinLabel(2,"kAny");
     hTrigCent->GetXaxis()->SetBinLabel(3,"kMB");
@@ -494,9 +817,11 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hTrigCent->GetXaxis()->SetBinLabel(9,"kEMCJET+GAMMA");
     hTrigCent->GetXaxis()->SetBinLabel(10,"Muons");
     hTrigCent->GetXaxis()->SetBinLabel(11,"PHOS");
-    hTrigCent->GetXaxis()->SetBinLabel(12,"Others");
+    hTrigCent->GetXaxis()->SetBinLabel(12,"TRD");
+    hTrigCent->GetXaxis()->SetBinLabel(13,"HighMult");
+    hTrigCent->GetXaxis()->SetBinLabel(14,"Others");
 
-    TH2F* hTrigMul=new TH2F("hTrigMul","Multiplicity vs. Trigger types",12,-1.5,10.5,100,0.,10000.);
+    TH2F* hTrigMul=new TH2F("hTrigMul","Multiplicity vs. Trigger types",14,-1.5,12.5,100,0.,10000.);
     hTrigMul->GetXaxis()->SetBinLabel(1,"All");
     hTrigMul->GetXaxis()->SetBinLabel(2,"kAny");
     hTrigMul->GetXaxis()->SetBinLabel(3,"kMB");
@@ -508,9 +833,11 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hTrigMul->GetXaxis()->SetBinLabel(9,"kEMCJET+GAMMA");
     hTrigMul->GetXaxis()->SetBinLabel(10,"Muons");
     hTrigMul->GetXaxis()->SetBinLabel(11,"PHOS");
-    hTrigMul->GetXaxis()->SetBinLabel(12,"Others");
+    hTrigMul->GetXaxis()->SetBinLabel(12,"TRD");
+    hTrigMul->GetXaxis()->SetBinLabel(13,"HighMult");
+    hTrigMul->GetXaxis()->SetBinLabel(14,"Others");
 
-    TH2F* hTrigCentSel=new TH2F("hTrigCentSel","Trigger types",12,-1.5,10.5,12,-10,110);
+    TH2F* hTrigCentSel=new TH2F("hTrigCentSel","Trigger types",14,-1.5,12.5,12,-10,110);
     hTrigCentSel->GetXaxis()->SetBinLabel(1,"All");
     hTrigCentSel->GetXaxis()->SetBinLabel(2,"kAny");
     hTrigCentSel->GetXaxis()->SetBinLabel(3,"kMB");
@@ -522,31 +849,131 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hTrigCentSel->GetXaxis()->SetBinLabel(9,"kEMCJET+GAMMA");
     hTrigCentSel->GetXaxis()->SetBinLabel(10,"Muons");
     hTrigCentSel->GetXaxis()->SetBinLabel(11,"PHOS");
-    hTrigCentSel->GetXaxis()->SetBinLabel(12,"Others");
+    hTrigCentSel->GetXaxis()->SetBinLabel(12,"TRD");
+    hTrigCentSel->GetXaxis()->SetBinLabel(13,"HighMult");
+    hTrigCentSel->GetXaxis()->SetBinLabel(14,"Others");
 
     AliCounterCollection *trigCounter=new AliCounterCollection("trigCounter");
     trigCounter->AddRubric("run",500000);
-    trigCounter->AddRubric("triggerType","Any/MB/Cent/SemiCent/EMCAL");
+    trigCounter->AddRubric("triggerType","All/Any/MB/Cent/SemiCent/EMCAL/MUON/NoPhysSelMUON/NoPhysSelEvNot7/NoPhysSelCMUP1/NoPhysSelMB/NoPhysSelCent/NoPhysSelSemiCent/CINT7");
     trigCounter->Init();
 
+    TH1F* hWhyEvRejected=new TH1F("hWhyEvRejected", "Why Event rejected",7,-1.5,5.5);
+
+    hWhyEvRejected->GetXaxis()->SetBinLabel(1,"N events");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(2,"pileup");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(3,"centrality");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(4,"Vertex not found");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(5,"trigger");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(6,"z vertex out of 10 cm");
+    hWhyEvRejected->GetXaxis()->SetBinLabel(7,"physics sel");
+
+
     fOutputEvSelection->Add(evselection);
+    fOutputEvSelection->Add(hxvtx);
+    fOutputEvSelection->Add(hyvtx);
     fOutputEvSelection->Add(hzvtx);
+    fOutputEvSelection->Add(hxvtxSelEv);
+    fOutputEvSelection->Add(hyvtxSelEv);
+    fOutputEvSelection->Add(hzvtxSelEv);
+    fOutputEvSelection->Add(hWhichVert);
+    fOutputEvSelection->Add(hWhichVertSelEv);
     fOutputEvSelection->Add(hTrigCent);
     fOutputEvSelection->Add(hTrigMul);
     fOutputEvSelection->Add(hTrigCentSel);
     fOutputEvSelection->Add(trigCounter);
+    fOutputEvSelection->Add(hWhyEvRejected);
+
+  }
+  if(fOnOff[4]){ // FLOW OBSERVABLES
+    fOutputFlowObs=new TList();
+    fOutputFlowObs->SetOwner();
+    fOutputFlowObs->SetName(GetOutputSlot(8)->GetContainer()->GetName());
+
+    fFlowEvent = new AliFlowEvent(3000);
+    fRFPcuts = new AliFlowTrackCuts("rfpCuts");
+
+    TH2F *hFEvents = new TH2F("hFlowEvents","FlowEvent Selection",7,0,7,7,-10,60);
+    hFEvents->GetXaxis()->SetBinLabel(1,"REACHED");
+    hFEvents->GetXaxis()->SetBinLabel(2,"TRIGGERED");
+    hFEvents->GetXaxis()->SetBinLabel(3,"kMB");
+    hFEvents->GetXaxis()->SetBinLabel(4,"kCent");
+    hFEvents->GetXaxis()->SetBinLabel(5,"kSemiC");
+    hFEvents->GetXaxis()->SetBinLabel(6,"Triggered + vtx cut");
+    hFEvents->GetXaxis()->SetBinLabel(7,"UnexpectedBehaviour");
+    fOutputFlowObs->Add(hFEvents);
+
+    TProfile2D *hQ[3];
+    TH2F *hAngleQ[3];
+    TH3F *hPhiEta[3];
+    TString ref[3] = {"FB1","FB128","VZE"};
+    Int_t etabin[3] = {40,40,20};
+    Int_t etamax[3] = { 1, 1, 5};
+    for(Int_t i=0; i<3; ++i) {
+      hQ[i]= new TProfile2D( Form("h%s_Q",ref[i].Data()),
+                            Form("Q_{2} components for %s",ref[i].Data()),
+                            4,0,4,12,0,60,"s");
+      hQ[i]->GetXaxis()->SetBinLabel(1,"Qx^{-}");
+      hQ[i]->GetXaxis()->SetBinLabel(2,"Qy^{-}");
+      hQ[i]->GetXaxis()->SetBinLabel(3,"Qx^{+}");
+      hQ[i]->GetXaxis()->SetBinLabel(4,"Qy^{+}");
+      hQ[i]->GetYaxis()->SetTitle("Centrality");
+      fOutputFlowObs->Add(hQ[i]);
+
+      hAngleQ[i] = new TH2F( Form("h%s_AngleQ",ref[i].Data()),
+                            Form("#Psi_{2} for %s",ref[i].Data()),
+                            72,0,TMath::Pi(),12,0,60);
+      hAngleQ[i]->GetXaxis()->SetTitle( Form("#Psi_{2}^{%s}",ref[i].Data()) );
+      hAngleQ[i]->GetYaxis()->SetTitle("Centrality");
+      fOutputFlowObs->Add(hAngleQ[i]);
+
+      hPhiEta[i] = new TH3F( Form("h%s_PhiEta",ref[i].Data()),
+                            Form("Eta vs Phi for %s",ref[i].Data()),
+                            144,0,TMath::TwoPi(),etabin[i],-1.0*etamax[i],+1.0*etamax[i],12,0,60);
+      hPhiEta[i]->GetXaxis()->SetTitle("Phi");
+      hPhiEta[i]->GetYaxis()->SetTitle("Eta");
+      hPhiEta[i]->GetZaxis()->SetTitle("Centrality");
+      fOutputFlowObs->Add(hPhiEta[i]);
+
+    }
+    TH3F *hTPCVZE_AngleQ = new TH3F("hTPCVZE_AngleQ","#Psi_{2}^{VZERO} vs #Psi_{2}^{TPC}",   72,0,TMath::Pi(),72,0,TMath::Pi(),12,0,60);
+    hTPCVZE_AngleQ->GetXaxis()->SetTitle("#Psi_{2}^{TPC}");
+    hTPCVZE_AngleQ->GetYaxis()->SetTitle("#Psi_{2}^{VZE}");
+    hTPCVZE_AngleQ->GetZaxis()->SetTitle("Centrality");
+    fOutputFlowObs->Add(hTPCVZE_AngleQ);
+
+    TH2F *hCentVsMultRPS = new TH2F("hCentVsMultRPS", " Centrality Vs. Multiplicity RPs",5000, 0, 5000.,12,0,60 );
+    hCentVsMultRPS->GetXaxis()->SetTitle("Multiplicity RPs");
+    hCentVsMultRPS->GetYaxis()->SetTitle("Centrality");
+    fOutputFlowObs->Add(hCentVsMultRPS);
+  }
+
+  /*
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
+  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
+  if (fCuts->GetIsUsePID() && fDecayChannel==kLambdactoV0) {
+    fCuts->GetPidHF()->SetPidResponse(pidResp);
+    AliRDHFCutsLctoV0* lccuts=dynamic_cast<AliRDHFCutsLctoV0*>(fCuts);
+    if(lccuts){
+      lccuts->GetPidV0pos()->SetPidResponse(pidResp);
+      lccuts->GetPidV0neg()->SetPidResponse(pidResp);
+      fCuts->GetPidHF()->SetOldPid(kFALSE);
+      lccuts->GetPidV0pos()->SetOldPid(kFALSE);
+      lccuts->GetPidV0neg()->SetOldPid(kFALSE);
+    }
   }
-//  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-//  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
-//  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
-//  fCuts->GetPidHF()->SetPidResponse(pidResp);
+  */
+
   // Post the data
   PostData(1,fNEntries);
+
   if(fOnOff[1]) PostData(2,fOutputPID);
   if(fOnOff[0]) PostData(3,fOutputTrack);
   PostData(4,fCuts);
   if(fOnOff[2]) PostData(5,fOutputCounters);
   if(fOnOff[3]) PostData(7,fOutputEvSelection);
+  if(fOnOff[4]) PostData(8,fOutputFlowObs);
 
   if(!fOnOff[0] && !fOnOff[1] && !fOnOff[2]) AliError("Nothing will be filled!");
 }
@@ -648,6 +1075,16 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          pdgdaughters[2]=211;//pi
        }
        break; 
+      case kLambdactoV0:
+       arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
+       pdg=4122;
+       if(fReadMC){
+         pdgdaughters =new Int_t[3];
+         pdgdaughters[0]=2212;//p
+         pdgdaughters[1]=211;//pi
+         pdgdaughters[2]=211;//pi
+       }
+       break; 
       }
     }
   } else if(aod) {
@@ -712,11 +1149,21 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        pdgdaughters[2]=211;//pi
       }
       break; 
+      case kLambdactoV0:
+       arrayProng=(TClonesArray*)aod->GetList()->FindObject("CascadesHF");
+       pdg=4122;
+       if(fReadMC){
+         pdgdaughters =new Int_t[3];
+         pdgdaughters[0]=2212;//p
+         pdgdaughters[1]=211;//pi
+         pdgdaughters[2]=211;//pi
+       }
+       break; 
     }
   }
   Bool_t isSimpleMode=fSimpleMode;
   if(!arrayProng) {
-    AliInfo("Branch not found! The output will contain only trak related histograms\n");
+    AliInfo("Branch not found! The output will contain only track related histograms\n");
     isSimpleMode=kTRUE;
     fNEntries->Fill(2);
   }
@@ -753,6 +1200,35 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   Double_t centrality=fCuts->GetCentrality(aod);
   Double_t multiplicity=aod->GetHeader()->GetRefMultiplicity();
   Int_t runNumber = aod->GetRunNumber();
+  TString trigClass=aod->GetFiredTriggerClasses();
+  Int_t nAODtracks=aod->GetNTracks();
+  Int_t nSelTracksTPCOnly=0;
+  Int_t nSelTracksTPCITS=0;
+  Int_t nSelTracksTPCITS1SPD=0;
+
+  for (Int_t k=0;k<nAODtracks;k++){
+    AliAODTrack* track=aod->GetTrack(k);
+    if(track->GetID()<0) continue;
+    Int_t nclsTot=0,nclsSPD=0;
+    for(Int_t l=0;l<6;l++) {
+      if(TESTBIT(track->GetITSClusterMap(),l)) {
+       nclsTot++; if(l<2) nclsSPD++;
+      }
+    }
+    UShort_t nTPCClus=track->GetTPCClusterMap().CountBits();
+    if(TMath::Abs(track->Eta())<0.8 && nTPCClus>=70 && track->GetStatus()&AliESDtrack::kTPCrefit){
+      if(track->TestFilterBit(1))  nSelTracksTPCOnly++;
+      if(track->GetStatus()&AliESDtrack::kITSrefit){
+       nSelTracksTPCITS++;
+       if(nclsSPD>0) nSelTracksTPCITS1SPD++;      
+      }
+    }
+  }
+
+  if(fOnOff[4]) {
+    FillFlowObs(aod);
+    PostData(8,fOutputFlowObs);
+  }
   if(fOnOff[3]){
     TH2F* hTrigC=(TH2F*)fOutputEvSelection->FindObject("hTrigCent");
     TH2F* hTrigM=(TH2F*)fOutputEvSelection->FindObject("hTrigMul");
@@ -760,7 +1236,22 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
     hTrigC->Fill(-1.,centrality);
     hTrigM->Fill(-1.,multiplicity);
-    
+    trigCount->Count(Form("triggerType:All/Run:%d",runNumber));
+    if(evSelMask==0){
+      if(aod->GetEventType()!=7){
+       trigCount->Count(Form("triggerType:NoPhysSelEvNot7/Run:%d",runNumber));
+      }else if(trigClass.Contains("CMUP1")){
+       trigCount->Count(Form("triggerType:NoPhysSelCMUP1/Run:%d",runNumber));
+      }else if(trigClass.Contains("MUON")){
+       trigCount->Count(Form("triggerType:NoPhysSelMUON/Run:%d",runNumber));
+      }else if(trigClass.Contains("CPBI2_B1-B") || trigClass.Contains(" CPBI2WU_B1-B")){
+       trigCount->Count(Form("triggerType:NoPhysSelMB/Run:%d",runNumber));
+      }else if(trigClass.Contains("CCENT") || trigClass.Contains("CVHN")){
+       trigCount->Count(Form("triggerType:NoPhysSelCent/Run:%d",runNumber));
+      }else if(trigClass.Contains("CSEMI") || trigClass.Contains("CVLN")){
+       trigCount->Count(Form("triggerType:NoPhysSelSemiCent/Run:%d",runNumber));
+      }
+    }
     if(evSelMask & AliVEvent::kAny){
       hTrigC->Fill(0.,centrality);
       hTrigM->Fill(0.,multiplicity);
@@ -774,6 +1265,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     if(evSelMask & AliVEvent::kINT7){ 
       hTrigC->Fill(2.,centrality);
       hTrigM->Fill(2.,multiplicity);
+      trigCount->Count(Form("triggerType:CINT7/Run:%d",runNumber));
     }
     if(evSelMask & AliVEvent::kCINT5){ 
       hTrigC->Fill(3.,centrality);
@@ -801,15 +1293,24 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     if(evSelMask & (((AliVEvent::kCMUS5 | AliVEvent::kMUSH7) | (AliVEvent::kMUL7 | AliVEvent::kMUU7)) |  (AliVEvent::kMUS7 | AliVEvent::kMUON))){
       hTrigC->Fill(8.,centrality);
       hTrigM->Fill(8.,multiplicity);
+      trigCount->Count(Form("triggerType:MUON/Run:%d",runNumber));
     }
     if(evSelMask & (AliVEvent::kPHI1 | AliVEvent::kPHI7)){ 
       hTrigC->Fill(9.,centrality);
       hTrigM->Fill(9.,multiplicity);
     }
-    if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)){
+    if(evSelMask & (AliVEvent::kTRD)){
       hTrigC->Fill(10.,centrality);
       hTrigM->Fill(10.,multiplicity);
     }
+    if(evSelMask & (AliVEvent::kHighMult)){
+      hTrigC->Fill(11.,centrality);
+      hTrigM->Fill(11.,multiplicity);
+    }
+    if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)){
+      hTrigC->Fill(12.,centrality);
+      hTrigM->Fill(12.,multiplicity);
+    }
   }
   
 
@@ -826,6 +1327,12 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   //count events with good vertex
   // AOD primary vertex
   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
+
+  Double_t pos[3],cov[6];
+  vtx1->GetXYZ(pos);
+  vtx1->GetCovarianceMatrix(cov);
+  const AliESDVertex vESD(pos,cov,100.,100);
+
   TString primTitle = vtx1->GetTitle();
   if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) fNEntries->Fill(4);
 
@@ -837,17 +1344,43 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
 
   Bool_t evSelbyCentrality=kTRUE,evSelected=kTRUE,evSelByVertex=kTRUE,evselByPileup=kTRUE,evSelByPS=kTRUE;
+
+  TH1F* hWhyEvRejected=0x0;
+  if(fOnOff[3]){
+    hWhyEvRejected=(TH1F*)fOutputEvSelection->FindObject("hWhyEvRejected");
+     if(hWhyEvRejected) hWhyEvRejected->Fill(-1); 
+  }
+
   //select event
   if(!fCuts->IsEventSelected(aod)) {
     evSelected=kFALSE;
-    if(fCuts->GetWhyRejection()==1) {fNEntries->Fill(1); evselByPileup=kFALSE;}// rejected for pileup
-    if(fCuts->GetWhyRejection()==2 || fCuts->GetWhyRejection()==3) evSelbyCentrality=kFALSE; //rejected by centrality
-    if(fCuts->GetWhyRejection()==4) evSelByVertex=kFALSE; //rejected by vertex
-    if(fCuts->GetWhyRejection()==5) fNEntries->Fill(5);//tmp
-    if(fCuts->GetWhyRejection()==6 && fOnOff[3]) ((AliCounterCollection*)fOutputEvSelection->FindObject("evselection"))->Count(Form("evnonsel:zvtx/Run:%d",runNumber));
-    if(fCuts->GetWhyRejection()==7) { evSelByPS=kFALSE; }
+    if(fCuts->IsEventRejectedDueToPileupSPD()) {
+      if(hWhyEvRejected) hWhyEvRejected->Fill(0); 
+      evselByPileup=kFALSE;
+    }// rejected for pileup
+    if(fCuts->IsEventRejectedDueToCentrality()) {
+      if(hWhyEvRejected) hWhyEvRejected->Fill(1); 
+      evSelbyCentrality=kFALSE; //rejected by centrality
+    }
+    if(fCuts->IsEventRejectedDueToNotRecoVertex() ||
+       fCuts->IsEventRejectedDueToVertexContributors()){ 
+      evSelByVertex=kFALSE; 
+      if(hWhyEvRejected) hWhyEvRejected->Fill(2);
+    }
+    if(fCuts->IsEventRejectedDueToTrigger()){
+      if(hWhyEvRejected) hWhyEvRejected->Fill(3);
+    }
+    if(fCuts->IsEventRejectedDueToZVertexOutsideFiducialRegion()) {
+      evSelByVertex=kFALSE; 
+      if(fOnOff[3]) ((AliCounterCollection*)fOutputEvSelection->FindObject("evselection"))->Count(Form("evnonsel:zvtx/Run:%d",runNumber)); 
+      if(hWhyEvRejected) hWhyEvRejected->Fill(4);
+    }
+    if(fCuts->IsEventRejectedDuePhysicsSelection()) { 
+      evSelByPS=kFALSE;
+      if(hWhyEvRejected) hWhyEvRejected->Fill(5); 
+    }
   }
-  if(evSelected){
+  if(evSelected && fOnOff[3]){
     TH2F* hTrigS=(TH2F*)fOutputEvSelection->FindObject("hTrigCentSel");
     hTrigS->Fill(-1.,centrality);
 
@@ -861,7 +1394,9 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     if(evSelMask & (AliVEvent::kEMCEJE | AliVEvent::kEMCEGA)) hTrigS->Fill(7.,centrality);
     if(evSelMask & (((AliVEvent::kCMUS5 | AliVEvent::kMUSH7) | (AliVEvent::kMUL7 | AliVEvent::kMUU7)) |  (AliVEvent::kMUS7 | AliVEvent::kMUON))) hTrigS->Fill(8.,centrality);
     if(evSelMask & (AliVEvent::kPHI1 | AliVEvent::kPHI7)) hTrigS->Fill(9.,centrality);
-    if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)) hTrigS->Fill(10.,centrality);
+    if(evSelMask & (AliVEvent::kTRD)) hTrigS->Fill(10.,centrality);
+    if(evSelMask & (AliVEvent::kHighMult)) hTrigS->Fill(11.,centrality);
+    if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)) hTrigS->Fill(12.,centrality);
   }
   
   if(evSelected || (!evSelbyCentrality && evSelByVertex && evselByPileup && evSelByPS)){ //events selected or not selected because of centrality
@@ -872,6 +1407,10 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
       Float_t secondCentf =fCuts->GetCentrality(aod,fEstimator);
       Int_t secondCent = (Int_t)(secondCentf+0.5);
       Int_t mincent=stdCent-stdCent%10;
+      AliAODVZERO *vzeroAOD = (AliAODVZERO*)aod->GetVZEROData();
+      Float_t vzeroMult = vzeroAOD->GetMTotV0A() +  vzeroAOD->GetMTotV0C();
+      AliCentrality *aodcent = aod->GetCentrality();
+      Float_t spdCentf = aodcent->GetCentralityPercentile("CL1");
       if(stdCentf==-1) {
        mincent=-10; 
        stdCent=-1;
@@ -895,6 +1434,13 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        ((TH1F*)fOutputCheckCentrality->FindObject("hMultIn"))->Fill(aod->GetHeader()->GetRefMultiplicity());
       }
       ((TH2F*)fOutputCheckCentrality->FindObject("hMultvsPercentile"))->Fill(aod->GetHeader()->GetRefMultiplicity(),stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile"))->Fill(aod->GetTracklets()->GetNumberOfTracklets(),stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCTracksvsPercentile"))->Fill(nSelTracksTPCOnly,stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCITSTracksvsPercentile"))->Fill(nSelTracksTPCITS,stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCITS1SPDTracksvsPercentile"))->Fill(nSelTracksTPCITS1SPD,stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hV0MultiplicityPercentile"))->Fill(vzeroMult,stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hV0MultiplicityNtrackletsIn"))->Fill(vzeroMult,aod->GetTracklets()->GetNumberOfTracklets());
+      ((TH2F*)fOutputCheckCentrality->FindObject("hStdPercentileSPDPercentile"))->Fill(stdCentf,spdCentf);
 
       PostData(6,fOutputCheckCentrality);
 
@@ -908,9 +1454,24 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
   if(fOnOff[3]){
     const AliVVertex *vertex = aod->GetPrimaryVertex();
+    Double_t xvtx=vertex->GetX();
+    Double_t yvtx=vertex->GetY();
     Double_t zvtx=vertex->GetZ();
-    if(evSelected || (!evSelected && TMath::Abs(zvtx) > 10.))
+    Int_t vtxTyp=0;
+    if(vertex->GetNContributors()<=0) vtxTyp=-1;
+    TString title=vertex->GetTitle();
+    if(title.Contains("Z")) vtxTyp=3;
+    if(title.Contains("3D")) vtxTyp=2;    
+    ((TH1F*)fOutputEvSelection->FindObject("hxvtx"))->Fill(xvtx);
+    ((TH1F*)fOutputEvSelection->FindObject("hyvtx"))->Fill(yvtx);
     ((TH1F*)fOutputEvSelection->FindObject("hzvtx"))->Fill(zvtx);
+    ((TH1F*)fOutputEvSelection->FindObject("hWhichVert"))->Fill(vtxTyp);
+    if(evSelected){
+      ((TH1F*)fOutputEvSelection->FindObject("hxvtxSelEv"))->Fill(xvtx);
+      ((TH1F*)fOutputEvSelection->FindObject("hyvtxSelEv"))->Fill(yvtx);
+      ((TH1F*)fOutputEvSelection->FindObject("hzvtxSelEv"))->Fill(zvtx);
+      ((TH1F*)fOutputEvSelection->FindObject("hWhichVertSelEv"))->Fill(vtxTyp);
+    }
   }
 
   if(!evSelected) {
@@ -924,14 +1485,22 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     delete [] pdgdaughters;
     return;
   }
-  AliPIDResponse* respF=pidHF->GetPidResponse();
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
+  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
+
+  //AliPIDResponse* respF=pidHF->GetPidResponse();
   AliTPCPIDResponse* tpcres=new AliTPCPIDResponse();
-  if(pidHF->GetOldPid()) pidHF->SetBetheBloch(*tpcres);
   Bool_t oldPID=pidHF->GetOldPid();
+  if(oldPID){ 
+    Double_t alephParameters[5];
+    pidHF->GetTPCBetheBlochParams(alephParameters);
+    tpcres->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
+  }
 
 
   Int_t ntracks=0;
-  Int_t isGoodTrack=0, isFakeTrack=0;
+  Int_t isGoodTrack=0, isFakeTrack=0, isSelTrack=0;
 
   if(aod) ntracks=aod->GetNTracks();
 
@@ -939,11 +1508,48 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     //loop on tracks in the event
     for (Int_t k=0;k<ntracks;k++){
       AliAODTrack* track=aod->GetTrack(k);
-      AliAODPid *pid = track->GetDetPid();
 
+      // Track selection cuts
+      if(track->GetID()<0) continue;
+      Double_t d0z0[2],covd0z0[3];
+      track->PropagateToDCA(vtx1,aod->GetMagneticField(),99999.,d0z0,covd0z0);
+      if(track->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)){
+       ((TH1F*)fOutputTrack->FindObject("hd0TracksFilterBit4"))->Fill(d0z0[0]);
+      }
+      ULong_t trStatus=track->GetStatus();
+      if(trStatus&AliESDtrack::kITSrefit){
+       if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)){
+         ((TH1F*)fOutputTrack->FindObject("hd0TracksSPDany"))->Fill(d0z0[0]);
+         if(track->HasPointOnITSLayer(0)){
+           ((TH1F*)fOutputTrack->FindObject("hd0TracksSPDin"))->Fill(d0z0[0]);
+         }
+       }
+      }
+
+      Bool_t selTrack=kTRUE;
+       if (!((trStatus & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
+         !((trStatus & AliVTrack::kITSrefit) == AliVTrack::kITSrefit)){
+       selTrack=kFALSE;
+      }
+
+      Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
+      Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
+      if (track->GetTPCNclsF()>0) {
+       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
+      }
+      if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ){
+       selTrack=kFALSE;        
+      }
+      if(selTrack){
+       if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)){
+         ((TH1F*)fOutputTrack->FindObject("hd0TracksTPCITSSPDany"))->Fill(d0z0[0]);
+       }
+      }
+      
+      AliAODPid *pid = track->GetDetPid();
+      if(!pid && fDebug>1) cout<<"No AliAODPid found"<<endl;
 
-      if(fOnOff[1]){
-       if(!pid)  {if (fDebug>1)cout<<"No AliAODPid found"<<endl; continue;}
+      if(pid && fOnOff[1]){
        Double_t times[AliPID::kSPECIES];
        pid->GetIntegratedTimes(times);
     
@@ -953,44 +1559,82 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        //check TOF
        TH1F* htmpfl=((TH1F*)fOutputPID->FindObject("hTOFflags"));
        htmpfl->Fill(0.);
-       if (track->GetStatus()&AliESDtrack::kTPCout) htmpfl->Fill(1.);
-       if (track->GetStatus()&AliESDtrack::kTOFout) htmpfl->Fill(2.);
-       if (track->GetStatus()&AliESDtrack::kTIME) htmpfl->Fill(3.);
-       if (track->GetStatus()&AliESDtrack::kTOFpid) htmpfl->Fill(4.);
-       if (track->GetStatus()&AliESDtrack::kTOFmismatch) htmpfl->Fill(5.);
-
-       if(pidHF && pidHF->CheckStatus(track,"TOF")){
+       if (trStatus&AliESDtrack::kTPCout) htmpfl->Fill(1.);
+       if (trStatus&AliESDtrack::kTOFout) htmpfl->Fill(2.);
+       if (trStatus&AliESDtrack::kTIME) htmpfl->Fill(3.);
+       if (trStatus&AliESDtrack::kTOFpid) htmpfl->Fill(4.);
+       if (trStatus&AliESDtrack::kTOFmismatch) htmpfl->Fill(5.);
+
+       Bool_t isTOFok=kFALSE;
+       if(pidResp){
+         Double_t prob[AliPID::kSPECIES];
+         if(pidResp->ComputeTOFProbability(track,AliPID::kSPECIES,prob)==AliPIDResponse::kDetPidOk){
+           isTOFok=kTRUE;
+           htmpfl->Fill(6.);
+         }
+       }
+      
+       if(selTrack && isTOFok){
+         Double_t tofTime=pid->GetTOFsignal();
+         AliTOFHeader* tofH=(AliTOFHeader*)aod->GetTOFHeader();
+         if (tofH && (TMath::Abs(tofRes[0]) <= 1.E-16) ) { // new AOD
+            // with new AOD we need to retrieve startTime, subtract it and retrieve correctly TOF PID resolutions  *PA*
+           AliTOFPIDResponse tofResp=pidResp->GetTOFResponse();
+           Double_t startTime = tofResp.GetStartTime(track->P());
+           Float_t startTimeRes = tofResp.GetStartTimeRes(track->P());  
+           Int_t startTimeMask = tofResp.GetStartTimeMask(track->P());  
+           ((TH1F*)fOutputPID->FindObject("hTOFstartTimeDistrib"))->Fill(startTime);
+           ((TH1F*)fOutputPID->FindObject("hTOFstartTimeMask"))->Fill(startTimeMask);
+           ((TH1F*)fOutputPID->FindObject("hTOFstartTimeRes"))->Fill(startTimeRes);
+           tofTime-=startTime;
+           for (Int_t type=0;type<AliPID::kSPECIES;type++) tofRes[type]=tofResp.GetExpectedSigma(track->P(),times[type],AliPID::ParticleMassZ(type)); 
+         }
          ((TH1F*)fOutputPID->FindObject("hTOFtime"))->Fill(times[AliPID::kProton]);
-         ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptime"))->Fill(track->P(),pid->GetTOFsignal()-times[3]); //3 is kaon
-         ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(pid->GetTOFsignal());
+         ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptime"))->Fill(track->P(),tofTime-times[3]); //3 is kaon
+         ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(tofTime);
          if (pid->GetTOFsignal()< 0) ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(-1);
 
-         
-         // test TOF sigma PID
-         if (tofRes[2] != 0.) {   // protection against 'old' AODs...
-           ((TH2F*)fOutputPID->FindObject("hTOFsigmaKSigPid"))->Fill(track->P(),(pid->GetTOFsignal()-times[AliPID::kKaon])/tofRes[3]);
-           ((TH2F*)fOutputPID->FindObject("hTOFsigmaPionSigPid"))->Fill(track->P(),(pid->GetTOFsignal()-times[AliPID::kPion])/tofRes[2]);
-           ((TH2F*)fOutputPID->FindObject("hTOFsigmaProtonSigPid"))->Fill(track->P(),(pid->GetTOFsignal()-times[AliPID::kProton])/tofRes[4]);
-           for (Int_t iS=2; iS<5; iS++){ //we plot TOF Pid resolution for 3-sigma identified particles
-             if ( (TMath::Abs(times[iS]-pid->GetTOFsignal())/tofRes[iS])<3.){
-               switch (iS) {
-               case AliPID::kPion:
-                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigPion"))->Fill(tofRes[iS]);
-                 break;
-               case AliPID::kKaon:
-                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigKaon"))->Fill(tofRes[iS]);
-                 break;
-               case AliPID::kProton:
-                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigProton"))->Fill(tofRes[iS]);
-                 break;
-               default:
-                 break;
-               }
+         Double_t nsigma[3]={-10,-10,-10};
+         nsigma[0]=pidResp->NumberOfSigmasTOF(track,AliPID::kPion);
+         nsigma[1]=pidResp->NumberOfSigmasTOF(track,AliPID::kKaon);
+         nsigma[2]=pidResp->NumberOfSigmasTOF(track,AliPID::kProton);
+
+         ((TH2F*)fOutputPID->FindObject("hTOFsigmaKSigPid"))->Fill(track->P(),nsigma[1]);
+         ((TH2F*)fOutputPID->FindObject("hTOFsigmaPionSigPid"))->Fill(track->P(),nsigma[0]);
+         ((TH2F*)fOutputPID->FindObject("hTOFsigmaProtonSigPid"))->Fill(track->P(),nsigma[2]);
+         if(fReadMC){
+           Int_t label=track->GetLabel();
+           if(label<=0) continue;
+           AliMCParticle* mcpart=(AliMCParticle*)mcArray->At(label);
+           if(mcpart){
+             Int_t abspdgcode=TMath::Abs(mcpart->PdgCode());
+             if(abspdgcode==211) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCPionSigPid"))->Fill(track->P(),nsigma[0]);
+             if(abspdgcode==321) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCKSigPid"))->Fill(track->P(),nsigma[1]);
+             if(abspdgcode==2212) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCProtonSigPid"))->Fill(track->P(),nsigma[2]);
+
+           }
+         }
+
+         for (Int_t iS=2; iS<5; iS++){ //we plot TOF Pid resolution for 3-sigma identified particles
+           if ( TMath::Abs(nsigma[iS-2])<3.){
+             switch (iS) {
+             case AliPID::kPion:
+               ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigPion"))->Fill(tofRes[iS]);
+               break;
+             case AliPID::kKaon:
+               ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigKaon"))->Fill(tofRes[iS]);
+               break;
+             case AliPID::kProton:
+               ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigProton"))->Fill(tofRes[iS]);
+               break;
+             default:
+               break;
              }
            }
          }
        }//if TOF status
-
+       //}
+      
        if(pidHF && pidHF->CheckStatus(track,"TPC")){ 
 
          Double_t TPCp=pid->GetTPCmomentum();
@@ -998,14 +1642,31 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          ((TH1F*)fOutputPID->FindObject("hTPCsig"))->Fill(TPCsignal);
          ((TH1F*)fOutputPID->FindObject("hTPCsigvsp"))->Fill(TPCp,TPCsignal);
          //if (pidHF->IsKaonRaw(track, "TOF"))
-         if(!oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaK"))->Fill(TPCp,respF->NumberOfSigmasTPC(track,AliPID::kKaon));
-         if (oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaK"))->Fill(TPCp,tpcres->GetNumberOfSigmas(TPCp,TPCsignal,track->GetTPCNcls(),AliPID::kKaon));
-         //if (pidHF->IsPionRaw(track, "TOF"))
-         if(oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaPion"))->Fill(TPCp,tpcres->GetNumberOfSigmas(TPCp,TPCsignal,track->GetTPCNcls(),AliPID::kPion));
-         if(!oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaPion"))->Fill(TPCp,respF->NumberOfSigmasTPC(track,AliPID::kPion));
-         //if (pidHF->IsProtonRaw(track,"TOF"))
-         if(oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaProton"))->Fill(TPCp,tpcres->GetNumberOfSigmas(TPCp,TPCsignal,track->GetTPCNcls(),AliPID::kProton));
-         if(!oldPID) ((TH2F*)fOutputPID->FindObject("hTPCsigmaProton"))->Fill(TPCp,respF->NumberOfSigmasTPC(track,AliPID::kProton));
+         Double_t nsigma[3]={-10,-10,-10};
+         pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kPion,nsigma[0]);     
+         pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kKaon,nsigma[1]);     
+         pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kProton,nsigma[2]);   
+
+         ((TH2F*)fOutputPID->FindObject("hTPCsigmaK"))->Fill(TPCp,nsigma[1]);
+         
+         ((TH2F*)fOutputPID->FindObject("hTPCsigmaPion"))->Fill(TPCp,nsigma[0]);         
+         ((TH2F*)fOutputPID->FindObject("hTPCsigmaProton"))->Fill(TPCp,nsigma[2]);
+         
+         if(fReadMC){
+           Int_t label=track->GetLabel();
+           if(label<=0) continue;
+           AliMCParticle* mcpart=(AliMCParticle*)mcArray->At(label);
+           if(mcpart){
+             Int_t abspdgcode=TMath::Abs(mcpart->PdgCode());
+             if(abspdgcode==211) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCPion"))->Fill(track->P(),nsigma[0]);
+             if(abspdgcode==321) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCK"))->Fill(track->P(),nsigma[1]);
+             if(abspdgcode==2212) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCProton"))->Fill(track->P(),nsigma[2]);
+
+           }
+
+         }
+
+
        }//if TPC status
       } //end PID histograms
 
@@ -1023,6 +1684,44 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        }
        ((TH1F*)fOutputTrack->FindObject("hnClsITS"))->Fill(nclsTot);
        ((TH1F*)fOutputTrack->FindObject("hnClsSPD"))->Fill(nclsSPD);
+
+       if(fFillDistrTrackEffChecks && track->GetStatus()&AliESDtrack::kITSrefit &&
+          track->GetStatus()&AliESDtrack::kTPCrefit){
+
+         ((TH1F*)fOutputTrack->FindObject("hPtAllTracks"))->Fill(track->Pt());
+         ((TH1F*)fOutputTrack->FindObject("hPhiAllTracks"))->Fill(track->Phi());
+         ((TH1F*)fOutputTrack->FindObject("hEtaAllTracks"))->Fill(track->Eta());
+         ((TH2F*)fOutputTrack->FindObject("hEtavsPhiAllTracks"))->Fill(track->Phi(),track->Eta());
+         ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPtAllTracks"))->Fill(track->Pt(),track->GetTPCNcls());
+         ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPhiAllTracks"))->Fill(track->Phi(),track->GetTPCNcls());
+         ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsEtaAllTracks"))->Fill(track->Eta(),track->GetTPCNcls());
+
+         ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPtAllTracks"))->Fill(track->Pt(),nCrossedRowsTPC);
+         ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPhiAllTracks"))->Fill(track->Phi(),nCrossedRowsTPC);
+         ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsEtaAllTracks"))->Fill(track->Eta(),nCrossedRowsTPC);
+
+         ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPtAllTracks"))->Fill(track->Pt(),ratioCrossedRowsOverFindableClustersTPC);
+         ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPhiAllTracks"))->Fill(track->Phi(),ratioCrossedRowsOverFindableClustersTPC);
+         ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsEtaAllTracks"))->Fill(track->Eta(),ratioCrossedRowsOverFindableClustersTPC);
+         
+         if(!(track->HasPointOnITSLayer(0)) && !(track->HasPointOnITSLayer(1))){ //no SPD points
+           ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(0);
+         } 
+         if(track->HasPointOnITSLayer(0) && !(track->HasPointOnITSLayer(1))){ //kOnlyFirst
+           ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(1);
+         } 
+         if(!(track->HasPointOnITSLayer(0)) && track->HasPointOnITSLayer(1)){ //kOnlySecond
+           ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(2);
+         }
+         if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)){ //kBoth
+           ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(3);
+         } 
+         ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPtAllTracks"))->Fill(track->Pt(), nclsTot);
+         ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPhiAllTracks"))->Fill(track->Phi(), nclsTot);
+         ((TH2F*)fOutputTrack->FindObject("hNITSclsvsEtaAllTracks"))->Fill(track->Eta(), nclsTot);
+
+         }
+
        if(track->Pt()>0.3 &&
           TMath::Abs(track->Eta())<0.8 &&
           track->GetStatus()&AliESDtrack::kITSrefit &&
@@ -1046,31 +1745,33 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          else fNEntries->Fill(9); 
        }
 
-       if(isSimpleMode){
 
-         if (track->Pt()>0.3 &&
-             track->GetStatus()&AliESDtrack::kTPCrefit &&
-             track->GetStatus()&AliESDtrack::kITSrefit &&
-             /*nclsTot>3 &&*/
-             nclsSPD>0) {//count good tracks
+       if (track->Pt()>0.3 &&
+           track->GetStatus()&AliESDtrack::kTPCrefit &&
+           track->GetStatus()&AliESDtrack::kITSrefit &&
+           /*nclsTot>3 &&*/
+           nclsSPD>0) {//count good tracks
 
-           
-           if(fReadMC && label<0) {
-             ((TH1F*)fOutputTrack->FindObject("hptFakeTr"))->Fill(track->Pt());
-             isFakeTrack++;    
-           } else {
-             ((TH1F*)fOutputTrack->FindObject("hptGoodTr"))->Fill(track->Pt());
-             isGoodTrack++;
-           }
+       
+         if(fReadMC && label<0) {
+           ((TH1F*)fOutputTrack->FindObject("hptFakeTr"))->Fill(track->Pt());
+           isFakeTrack++;      
+         } else {
+           ((TH1F*)fOutputTrack->FindObject("hptGoodTr"))->Fill(track->Pt());
+           isGoodTrack++;
          }
-       } //simple mode: no IsSelected on tracks: use "manual" cuts   
+       }
+       if(fCuts->IsDaughterSelected(track,&vESD,fCuts->GetTrackCuts())){
+         isSelTrack++;
+       }//select tracks for our analyses
       } //fill track histos
     } //end loop on tracks
 
-      //fill once per event
+    //fill once per event
     if(fOnOff[0]){
       if (fReadMC) ((TH1F*)fOutputTrack->FindObject("hdistrFakeTr"))->Fill(isFakeTrack);
       ((TH1F*)fOutputTrack->FindObject("hdistrGoodTr"))->Fill(isGoodTrack);
+      ((TH1F*)fOutputTrack->FindObject("hdistrSelTr"))->Fill(isSelTrack);
     }
 
     if(!isSimpleMode){
@@ -1082,13 +1783,34 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
       for (Int_t iCand = 0; iCand < nCand; iCand++) {
        AliAODRecoDecayHF *d = (AliAODRecoDecayHF*)arrayProng->UncheckedAt(iCand);
-       if(d->GetSelectionMap()) {
+       if(fUseSelectionBit && d->GetSelectionMap()) {
          if(fDecayChannel==AliAnalysisTaskSEHFQA::kD0toKpi && !d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)) continue; //skip the D0 from Dstar
          if(fDecayChannel==AliAnalysisTaskSEHFQA::kDplustoKpipi && !d->HasSelectionBit(AliRDHFCuts::kDplusCuts)) continue; //skip the 3 prong !D+
        }
 
        if(fReadMC){ 
-         Int_t labD = d->MatchToMC(pdg,mcArray,ndaugh,pdgdaughters);
+
+         Int_t labD = -1;
+         if (fDecayChannel==AliAnalysisTaskSEHFQA::kLambdactoV0 && (dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0()) {
+
+           Int_t pdgDgLctoV0bachelor[2]={2212,310};
+           Int_t pdgDgV0toDaughters[2]={211,211};
+           Int_t mcLabelK0S = (dynamic_cast<AliAODRecoCascadeHF*>(d))->MatchToMC(pdg,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE); // Lc->K0S+p and cc
+           pdgDgLctoV0bachelor[1]=3122, pdgDgLctoV0bachelor[0]=211;
+           pdgDgV0toDaughters[0]=2212,  pdgDgV0toDaughters[1]=211;
+           Int_t mcLabelLambda = (dynamic_cast<AliAODRecoCascadeHF*>(d))->MatchToMC(pdg,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE); // Lc->Lambda+pi and cc
+           if (mcLabelK0S!=-1 || mcLabelLambda!=-1) AliInfo(Form("mcLabelK0S=%d - mcLabelLambda=%d",mcLabelK0S,mcLabelLambda));
+
+           if (mcLabelK0S!=-1 && mcLabelLambda!=-1)
+             AliInfo("Strange: current Lc->V0+bachelor candidate has two MC different labels!");
+           else if (mcLabelK0S>-1 && mcLabelLambda==-1)
+             labD = mcLabelK0S;
+           else if (mcLabelLambda>-1 && mcLabelK0S==-1)
+             labD = mcLabelLambda;
+         }
+         else
+           labD = d->MatchToMC(pdg,mcArray,ndaugh,pdgdaughters);
+
          if(labD>=0){
            AliAODMCParticle *partD = (AliAODMCParticle*)mcArray->At(labD);
            Int_t label=partD->GetMother();
@@ -1097,19 +1819,30 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
              mot = (AliAODMCParticle*)mcArray->At(label);
              label=mot->GetMother();
            }
-           Int_t pdgMotCode = mot->GetPdgCode();
+           if(mot){
+             Int_t pdgMotCode = mot->GetPdgCode();
        
-           if(TMath::Abs(pdgMotCode)==4) fNEntries->Fill(6); //from primary charm
-           if(TMath::Abs(pdgMotCode)==5) fNEntries->Fill(7); //from beauty
-
+             if(TMath::Abs(pdgMotCode)==4) fNEntries->Fill(6); //from primary charm
+             if(TMath::Abs(pdgMotCode)==5) fNEntries->Fill(7); //from beauty
+           }
          }
        }//end MC
-       else fNEntries->Fill(6); //count the candidates (data)
+       fNEntries->Fill(5); //count the candidates (data and MC)
 
        for(Int_t id=0;id<ndaugh;id++){
-
          //other histograms to be filled when the cut object is given
-         AliAODTrack* track=(AliAODTrack*)d->GetDaughter(id);
+         AliAODTrack* track=0;
+
+         if (fDecayChannel==AliAnalysisTaskSEHFQA::kLambdactoV0 && (dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0()) {
+           if (id==0)
+             track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->GetBachelor();
+           else if (id==1)
+             track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0PositiveTrack();
+           else if (id==2)
+             track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0NegativeTrack();
+         }
+         else 
+           track=(AliAODTrack*)d->GetDaughter(id);
 
          //track quality
 
@@ -1121,35 +1854,93 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
              
              if(fReadMC && label<0) {
                isFakeTrack++;
-               ((TH1F*)fOutputTrack->FindObject("hptFakeTr"))->Fill(track->Pt());
+               ((TH1F*)fOutputTrack->FindObject("hptFakeTrFromDaugh"))->Fill(track->Pt());
           
                ((TH1F*)fOutputTrack->FindObject("hd0f"))->Fill(d->Getd0Prong(id));
              } else {
-               isGoodTrack++;
-               ((TH1F*)fOutputTrack->FindObject("hptGoodTr"))->Fill(track->Pt());
-               ((TH1F*)fOutputTrack->FindObject("hd0"))->Fill(d->Getd0Prong(id));
+               ((TH1F*)fOutputTrack->FindObject("hptGoodTrFromDaugh"))->Fill(track->Pt());
+               ((TH1F*)fOutputTrack->FindObject("hd0dau"))->Fill(d->Getd0Prong(id));
                Double_t d0rphiz[2],covd0[3];
                Bool_t isDCA=track->PropagateToDCA(aod->GetPrimaryVertex(),aod->GetMagneticField(),9999.,d0rphiz,covd0);
-               if(isDCA) ((TH1F*)fOutputTrack->FindObject("hd0z"))->Fill(d0rphiz[1]);
+               if(isDCA) ((TH1F*)fOutputTrack->FindObject("hd0zdau"))->Fill(d0rphiz[1]);
              }
            }
            if (fCuts->IsSelected(d,AliRDHFCuts::kAll,aod) && fOnOff[1]){
-         
-             AliAODPid *pid = track->GetDetPid();
-             Double_t times[5];
-             pid->GetIntegratedTimes(times);
-             if(pidHF && pidHF->CheckStatus(track,"TOF")) ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptimeAC"))->Fill(track->P(),pid->GetTOFsignal()-times[AliPID::kKaon]);
-             if(pidHF && pidHF->CheckStatus(track,"TPC")) ((TH2F*)fOutputPID->FindObject("hTPCsigvspAC"))->Fill(pid->GetTPCmomentum(),pid->GetTPCsignal());
+             fNEntries->Fill(3); //candidates passing analysis cuts
+
+             if(fFillDistrTrackEffChecks){
+               Int_t nITScls = 0;
+               Int_t nSPDcls = 0;
+               Double_t nTPCCrossedRows = track->GetTPCClusterInfo(2,1);
+               Double_t ratioCrossedRowsOverFcls = 1.0;
+               if(track->GetTPCNclsF()>0){
+                 ratioCrossedRowsOverFcls = (nTPCCrossedRows)/(track->GetTPCNclsF());
+               }
+               for(Int_t l=0;l<6;l++) {
+                 if(TESTBIT(track->GetITSClusterMap(),l)) {
+                   nITScls++; if(l<2) nSPDcls++;
+                 }
+               }
 
-             fNEntries->Fill(3);
+               ((TH1F*)fOutputTrack->FindObject("hPtDaughters"))->Fill(track->Pt());
+               ((TH1F*)fOutputTrack->FindObject("hPhiDaughters"))->Fill(track->Phi());
+               ((TH1F*)fOutputTrack->FindObject("hEtaDaughters"))->Fill(track->Eta());
+               ((TH2F*)fOutputTrack->FindObject("hEtavsPhiDaughters"))->Fill(track->Phi(),track->Eta());
+               
+               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPtDaughters"))->Fill(track->Pt(),track->GetTPCNcls());
+               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPhiDaughters"))->Fill(track->Phi(),track->GetTPCNcls());
+               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsEtaDaughters"))->Fill(track->Eta(),track->GetTPCNcls());
+
+               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPtDaughters"))->Fill(track->Pt(),nTPCCrossedRows);
+               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPhiDaughters"))->Fill(track->Phi(),nTPCCrossedRows);
+               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsEtaDaughters"))->Fill(track->Eta(),nTPCCrossedRows);
+               
+               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPtDaughters"))->Fill(track->Pt(),ratioCrossedRowsOverFcls);
+               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPhiDaughters"))->Fill(track->Phi(),ratioCrossedRowsOverFcls);
+               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsEtaDaughters"))->Fill(track->Eta(),ratioCrossedRowsOverFcls);
+              
+               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPtDaughters"))->Fill(track->Pt(), nITScls);
+               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPhiDaughters"))->Fill(track->Phi(), nITScls);
+               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsEtaDaughters"))->Fill(track->Eta(), nITScls);
+               if(!(track->HasPointOnITSLayer(0)) && !(track->HasPointOnITSLayer(1))){ //no SPD points
+                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(0);
+               } 
+               if(track->HasPointOnITSLayer(0) && !(track->HasPointOnITSLayer(1))){ //kOnlyFirst
+                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(1);
+               } 
+               if(!(track->HasPointOnITSLayer(0)) && track->HasPointOnITSLayer(1)){ //kOnlySecond
+                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(2);
+               }
+               if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)){ //kBoth
+                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(3);
+               } 
+             }
+            
+           
+           AliAODPid *pid = track->GetDetPid();
+             if(pid){
+               Double_t times[5];
+               pid->GetIntegratedTimes(times);
+               if(pidHF && pidHF->CheckStatus(track,"TOF")){
+                 Double_t tofTime=pid->GetTOFsignal();
+                 AliTOFHeader* tofH=(AliTOFHeader*)aod->GetTOFHeader();
+                 Double_t tofRes[AliPID::kSPECIES];
+                 pid->GetTOFpidResolution(tofRes);
+                 if (tofH && (TMath::Abs(tofRes[0]) <= 1.E-16) ) { // new AOD
+                   AliTOFPIDResponse tofResp=pidHF->GetPidResponse()->GetTOFResponse();
+                   Double_t startTime=tofResp.GetStartTime(track->P());
+                   tofTime-=startTime;
+                 }
+                 ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptimeAC"))->Fill(track->P(),tofTime-times[AliPID::kKaon]);
+               }
+               if(pidHF && pidHF->CheckStatus(track,"TPC")) ((TH2F*)fOutputPID->FindObject("hTPCsigvspAC"))->Fill(pid->GetTPCmomentum(),pid->GetTPCsignal());
+             }
+             
            } //end analysis cuts
          } //end acceptance and track cuts
        } //end loop on tracks in the candidate
       } //end loop on candidates
-      if(fOnOff[0]){
-       if(fReadMC) ((TH1F*)fOutputTrack->FindObject("hdistrFakeTr"))->Fill(isFakeTrack);
-       ((TH1F*)fOutputTrack->FindObject("hdistrGoodTr"))->Fill(isGoodTrack);
-      }
+      
     }
   } //end if on pid or track histograms
 
@@ -1164,6 +1955,93 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
 }
 
+//____________________________________________________________________________
+void AliAnalysisTaskSEHFQA::FillFlowObs(AliAODEvent *aod){
+  //fills the flow observables
+  Double_t cc;
+  cc = fCuts->GetCentrality(aod);
+  ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(0., cc);
+
+  UInt_t mask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+  UInt_t trigger=AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
+  if(mask & trigger) {
+    ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(1.,cc); // fired
+    if (mask & AliVEvent::kMB) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(2.,cc);
+    if (mask & AliVEvent::kCentral) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(3.,cc);
+    if (mask & AliVEvent::kSemiCentral) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(4.,cc);
+    Bool_t rejected=false;
+    if(cc<0 || cc>60) rejected=true;
+    const AliVVertex *vertex = aod->GetPrimaryVertex();
+    Double_t zvtx=vertex->GetZ();
+    if(TMath::Abs(zvtx)>fCuts->GetMaxVtxZ()) rejected=true;
+    if(rejected) return; //not interesting for flow QA
+  } else {
+    return;
+  }
+
+  // event accepted
+  ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(5.,cc);
+  fRFPcuts->SetParamType(AliFlowTrackCuts::kGlobal);
+  fRFPcuts->SetPtRange(0.2,5.);
+  fRFPcuts->SetEtaRange(-0.8,0.8);
+  fRFPcuts->SetMinNClustersTPC(70);
+  fRFPcuts->SetMinChi2PerClusterTPC(0.2);
+  fRFPcuts->SetMaxChi2PerClusterTPC(4.0);
+  fRFPcuts->SetAcceptKinkDaughters(kFALSE);
+  fRFPcuts->SetEvent(aod);
+
+  TString ref[3] = {"FB1","FB128","VZE"};
+  Double_t psi[3];
+  for(Int_t i=0; i!=3; ++i) {
+    if(i==0) { // switching to bit 1
+      fRFPcuts->SetMinimalTPCdedx(10.);
+      fRFPcuts->SetAODfilterBit(1);
+    } else { // switching to bit 128
+      fRFPcuts->SetMinimalTPCdedx(-1);
+      fRFPcuts->SetAODfilterBit(128);
+    }
+    if(i>1) {
+      fRFPcuts->SetParamType(AliFlowTrackCuts::kV0);
+      fRFPcuts->SetEtaRange(-5,+5);
+      fRFPcuts->SetPhiMin(0);
+      fRFPcuts->SetPhiMax(TMath::TwoPi());
+    }
+    fFlowEvent->Fill(fRFPcuts,fRFPcuts);
+    fFlowEvent->TagSubeventsInEta(-5,0,0,+5);
+    // getting informationt
+    AliFlowVector vQ, vQaQb[2];
+    fFlowEvent->Get2Qsub(vQaQb,2);
+    vQ = vQaQb[0]+vQaQb[1];
+    Double_t dMa=vQaQb[0].GetMult();
+    Double_t dMb=vQaQb[1].GetMult();
+    if( dMa<2 || dMb<2 ) {
+      ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(6.,cc); //???
+      continue;
+    }
+    psi[i] = vQ.Phi()/2;
+    // publishing
+    ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(0,cc,vQaQb[0].X()/dMa,dMa); // Qx-
+    ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(1,cc,vQaQb[0].Y()/dMa,dMa); // Qy-
+    ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(2,cc,vQaQb[1].X()/dMb,dMb); // Qx+
+    ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(3,cc,vQaQb[1].Y()/dMb,dMb); // Qy+
+    ((TH2F*) fOutputFlowObs->FindObject( Form("h%s_AngleQ",ref[i].Data()) ))->Fill(psi[i],cc); // Psi
+    AliFlowTrackSimple *track;
+    for(Int_t t=0; t!=fFlowEvent->NumberOfTracks(); ++t) {
+      track = (AliFlowTrackSimple*) fFlowEvent->GetTrack(t);
+      if(!track) continue;
+      if(!track->InRPSelection()) continue;
+      ((TH3F*) fOutputFlowObs->FindObject( Form("h%s_PhiEta",ref[i].Data()) ))->Fill(track->Phi(),track->Eta(),cc,track->Weight()); //PhiEta
+    }
+  
+  //histo filled only for TPCFB1
+  if (i==0) {
+    ((TH2F*) fOutputFlowObs->FindObject("hCentVsMultRPS"))->Fill(fFlowEvent->GetNumberOfRPs(),cc);
+  }
+  }
+  // TPC vs VZERO
+  ((TH3F*) fOutputFlowObs->FindObject( "hTPCVZE_AngleQ" ))->Fill(psi[0],psi[2],cc);
+}
+
 //____________________________________________________________________________
 void AliAnalysisTaskSEHFQA::Terminate(Option_t */*option*/){
   //terminate analysis