]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliAnalysisTaskSEHFQA.cxx
Set bin labels to avoid warning when merging
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSEHFQA.cxx
index bde4cd85108567436598a7322551bd029fcb2fe7..517add6410546dbd58eefa4ce6eb163cbad0d1b2 100644 (file)
@@ -36,6 +36,7 @@
 #include <AliAnalysisDataContainer.h>
 #include "AliAnalysisManager.h"
 #include "AliESDtrack.h"
+#include "AliESDVertex.h"
 #include "AliVertexerTracks.h"
 #include "AliPID.h"
 #include "AliTPCPIDResponse.h"
@@ -57,6 +58,7 @@
 #include "AliRDHFCutsDStartoKpipi.h"
 #include "AliRDHFCutsD0toKpi.h"
 #include "AliRDHFCutsLctopKpi.h"
+#include "AliRDHFCutsLctoV0.h"
 #include "AliInputEventHandler.h"
 
 #include "AliFlowEvent.h"
@@ -66,6 +68,9 @@
 
 #include "AliAnalysisTaskSEHFQA.h"
 
+using std::cout;
+using std::endl;
+
 ClassImp(AliAnalysisTaskSEHFQA)
 
 //____________________________________________________________________________
@@ -151,6 +156,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)
@@ -235,6 +243,13 @@ void AliAnalysisTaskSEHFQA::Init(){
       PostData(4,copycut);
     }
     break;
+  case kLambdactoV0:
+    {
+      AliRDHFCutsLctoV0* copycut=new AliRDHFCutsLctoV0(*(static_cast<AliRDHFCutsLctoV0*>(fCuts)));
+      // Post the data
+      PostData(4,copycut);
+    }
+    break;
 
   default:
     return;
@@ -355,6 +370,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
@@ -376,10 +421,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);
@@ -388,10 +445,21 @@ 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="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="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);
 
@@ -406,13 +474,14 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputTrack->Add(hnClsSPD);
     fOutputTrack->Add(hptGoodTr);
     fOutputTrack->Add(hdistrGoodTr);
+    fOutputTrack->Add(hdistrSelTr);
     fOutputTrack->Add(hd0);
     fOutputTrack->Add(hd0z);
 
     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);
@@ -420,6 +489,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);
@@ -466,14 +541,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);
   
@@ -546,7 +648,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
 
     AliCounterCollection *trigCounter=new AliCounterCollection("trigCounter");
     trigCounter->AddRubric("run",500000);
-    trigCounter->AddRubric("triggerType","All/Any/MB/Cent/SemiCent/EMCAL");
+    trigCounter->AddRubric("triggerType","All/Any/MB/Cent/SemiCent/EMCAL/MUON/NoPhysSelMUON/NoPhysSelEvNot7/NoPhysSelCMUP1/NoPhysSelMB/NoPhysSelCent/NoPhysSelSemiCent");
     trigCounter->Init();
 
     fOutputEvSelection->Add(evselection);
@@ -732,6 +834,16 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          pdgdaughters[2]=211;//pi
        }
        break; 
+      case kLambdactoV0:
+       arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadeHF");
+       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) {
@@ -796,6 +908,16 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        pdgdaughters[2]=211;//pi
       }
       break; 
+      case kLambdactoV0:
+       arrayProng=(TClonesArray*)aod->GetList()->FindObject("CascadeHF");
+       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;
@@ -837,6 +959,31 @@ 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);
@@ -849,7 +996,21 @@ 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);
@@ -890,6 +1051,7 @@ 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);
@@ -915,6 +1077,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);
 
@@ -961,6 +1129,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;
@@ -984,6 +1156,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);
 
@@ -1013,18 +1192,18 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     delete [] pdgdaughters;
     return;
   }
-  AliPIDResponse* respF=pidHF->GetPidResponse();
+  //AliPIDResponse* respF=pidHF->GetPidResponse();
   AliTPCPIDResponse* tpcres=new AliTPCPIDResponse();
-  if(pidHF->GetOldPid()){ 
+  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]);
   }
-  Bool_t oldPID=pidHF->GetOldPid();
 
 
   Int_t ntracks=0;
-  Int_t isGoodTrack=0, isFakeTrack=0;
+  Int_t isGoodTrack=0, isFakeTrack=0, isSelTrack=0;
 
   if(aod) ntracks=aod->GetNTracks();
 
@@ -1032,11 +1211,11 @@ 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);
+      if(track->GetID()<0) continue;
       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);
     
@@ -1058,31 +1237,46 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(pid->GetTOFsignal());
          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};
+         pidHF->GetnSigmaTOF(track,(Int_t)AliPID::kPion,nsigma[0]);     
+         pidHF->GetnSigmaTOF(track,(Int_t)AliPID::kKaon,nsigma[1]);     
+         pidHF->GetnSigmaTOF(track,(Int_t)AliPID::kProton,nsigma[2]);   
+
+         ((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")){ 
 
@@ -1091,14 +1285,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
 
@@ -1139,31 +1350,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){
@@ -1190,11 +1403,12 @@ 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)
@@ -1214,12 +1428,11 @@ 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("hptGoodTrFromDaugh"))->Fill(track->Pt());
                ((TH1F*)fOutputTrack->FindObject("hd0"))->Fill(d->Getd0Prong(id));
                Double_t d0rphiz[2],covd0[3];
                Bool_t isDCA=track->PropagateToDCA(aod->GetPrimaryVertex(),aod->GetMagneticField(),9999.,d0rphiz,covd0);
@@ -1229,20 +1442,18 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
            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());
-
+             if(pid){
+               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);
            } //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