]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliAnalysisTaskSEHFQA.cxx
Updates
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSEHFQA.cxx
index 95a69138a02bb1874c2ec41382963ecfd6b6e55a..fff02bc0dee2489f2fa33c9822362256b5bb07af 100644 (file)
@@ -80,7 +80,7 @@ ClassImp(AliAnalysisTaskSEHFQA)
 //____________________________________________________________________________
 
 AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA():AliAnalysisTaskSE(),
-  fNEntries(0x0),
+  fOutputEntries(0x0),
   fOutputPID(0x0),
   fOutputTrack(0x0),
   fOutputCounters(0x0),
@@ -109,7 +109,7 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA():AliAnalysisTaskSE(),
 //____________________________________________________________________________
 AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSEHFQA::DecChannel ch,AliRDHFCuts* cuts):
   AliAnalysisTaskSE(name),
-  fNEntries(0x0),
+  fOutputEntries(0x0),
   fOutputPID(0x0),
   fOutputTrack(0x0),
   fOutputCounters(0x0),
@@ -138,8 +138,8 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
   fOnOff[3]=kTRUE;
   fOnOff[4]=kTRUE;
 
-  // Output slot #1 writes into a TH1F container (number of events)
-  DefineOutput(1,TH1F::Class());  //My private output
+  // Output slot #1 writes into a TList container (number of events)
+  DefineOutput(1,TList::Class());
   // Output slot #2 writes into a TList container (PID)
   if (fOnOff[1]) DefineOutput(2,TList::Class());  //My private output
   // Output slot #3 writes into a TList container (Tracks)
@@ -184,7 +184,8 @@ AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSE
 AliAnalysisTaskSEHFQA::~AliAnalysisTaskSEHFQA()
 {
   //destructor
-  delete fNEntries;
+
+  delete fOutputEntries;
 
   delete fOutputPID;
 
@@ -272,23 +273,39 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
   if(fDebug > 1) printf("AnalysisTaskSEHFQA::UserCreateOutputObjects() \n");
 
   //count events
-
-  fNEntries=new TH1F(GetOutputSlot(1)->GetContainer()->GetName(), "Counts the number of events", 10,-0.5,9.5);
-  fNEntries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
-  fNEntries->GetXaxis()->SetBinLabel(2,"Pile-up Rej");
-  fNEntries->GetXaxis()->SetBinLabel(3,"No VertexingHF");
-  fNEntries->GetXaxis()->SetBinLabel(4,"nCandidates(AnCuts)");
-  fNEntries->GetXaxis()->SetBinLabel(5,"EventsWithGoodVtx");
-  //fNEntries->GetXaxis()->SetBinLabel(6,"N. of 0SMH");
-  fNEntries->GetXaxis()->SetBinLabel(6,"N candidates");
+  fOutputEntries=new TList();
+  fOutputEntries->SetOwner();
+  fOutputEntries->SetName(GetOutputSlot(1)->GetContainer()->GetName());
+
+
+  TString hnameEntries="hNentries";
+  TH1F* hNentries=new TH1F(hnameEntries.Data(), "Counts the number of events", 10,-0.5,9.5);
+  hNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
+  hNentries->GetXaxis()->SetBinLabel(2,"Pile-up Rej");
+  hNentries->GetXaxis()->SetBinLabel(3,"No VertexingHF");
+  hNentries->GetXaxis()->SetBinLabel(4,"nCandidates(AnCuts)");
+  hNentries->GetXaxis()->SetBinLabel(5,"EventsWithGoodVtx");
+  hNentries->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");
+    hNentries->GetXaxis()->SetBinLabel(7,"MC Cand from c");
+    hNentries->GetXaxis()->SetBinLabel(8,"MC Cand from b");
+    hNentries->GetXaxis()->SetBinLabel(9,"N fake Trks");
+    hNentries->GetXaxis()->SetBinLabel(10,"N true Trks");
   }
 
-  fNEntries->GetXaxis()->SetNdivisions(1,kFALSE);
+  hNentries->GetXaxis()->SetNdivisions(1,kFALSE);
+
+  hnameEntries="HasSelBit";
+  TH2F* hNentriesSelBit=new TH2F(hnameEntries.Data(), "Counts the number of events with SelectionBit", 5,0.,5.,100,0.,30.);
+  hNentriesSelBit->GetXaxis()->SetBinLabel(1,"Dplus");
+  hNentriesSelBit->GetXaxis()->SetBinLabel(2,"Ds");
+  hNentriesSelBit->GetXaxis()->SetBinLabel(3,"LcKpi");
+  hNentriesSelBit->GetXaxis()->SetBinLabel(4,"D0toKpi");
+  hNentriesSelBit->GetXaxis()->SetBinLabel(5,"Dstar");
+
+  fOutputEntries->Add(hNentries);
+  fOutputEntries->Add(hNentriesSelBit);
+
 
   //PID
   if(fOnOff[1]){
@@ -504,6 +521,10 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       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="hptGoodTrFromDaugh_filt";
+      TH1F* hptGoodTrFromDaugh_filt=new TH1F(hname.Data(),"Pt distribution of 'good' candidate's daughters, cuts level;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
+      hptGoodTrFromDaugh_filt->SetTitleOffset(1.3,"Y");
+      fOutputTrack->Add(hptGoodTrFromDaugh_filt);
     }
 
     hname="hdistrGoodTr";
@@ -517,15 +538,28 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     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="hd0dau_filt";
+    TH1F* hd0dau_filt=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of D daughter tracks, cut level;d_{0rphi}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+
     hname="hd0dauphi";
     TH2F* hd0dauphi=new TH2F(hname.Data(), "Impact parameter (rphi) distribution of D daughter tracks versus #phi; #phi [rad]; d_{0rphi} [cm]",400,0,6.3,200,-0.1,0.1);
 
+    hname="hd0dauphi_filt";
+    TH2F* hd0dauphi_filt=new TH2F(hname.Data(), "Impact parameter (rphi) distribution of D daughter tracks versus #phi, cut level; #phi [rad]; d_{0rphi} [cm]",400,0,6.3,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="hd0zdau_filt";
+    TH1F* hd0zdau_filt=new TH1F(hname.Data(),"Impact parameter (z) distribution of D daughter tracks, cut level;d_{0z}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+
+
     hname="hd0zdauphi";
     TH2F* hd0zdauphi=new TH2F(hname.Data(), "Impact parameter (z) distribution of D daughter tracks versus #phi; #phi [rad]; d_{0z} [cm]",400,0,6.3,200,-0.1,0.1);
 
+    hname="hd0zdauphi_filt";
+    TH2F* hd0zdauphi_filt=new TH2F(hname.Data(), "Impact parameter (z) distribution of D daughter tracks versus #phi, filtering level; #phi [rad]; d_{0z} [cm]",400,0,6.3,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);
 
@@ -705,6 +739,10 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputTrack->Add(hd0dauphi);
     fOutputTrack->Add(hd0zdau);
     fOutputTrack->Add(hd0zdauphi);
+    fOutputTrack->Add(hd0dau_filt);
+    fOutputTrack->Add(hd0dauphi_filt);
+    fOutputTrack->Add(hd0zdau_filt);
+    fOutputTrack->Add(hd0zdauphi_filt);
     
 
     if(fReadMC){
@@ -715,6 +753,10 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       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);
 
+      hname="hd0f_filt";
+      TH1F* hd0f_filt=new TH1F(hname.Data(),"Impact parameter distribution of fake tracks, cut level;d_{0}[cm];Entries/10^{3} cm",200,-0.1,0.1);
+
+
       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");
@@ -723,12 +765,17 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
        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);
+
+       hname="hptFakeTrFromDaugh_filt";
+       TH1F* hptFakeTrFromDaughFilt=new TH1F(hname.Data(),"Pt distribution of fake tracks from daughters, cut level;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
+       hptFakeTrFromDaughFilt->SetTitleOffset(1.3,"Y");
+       fOutputTrack->Add(hptFakeTrFromDaughFilt);
       }
 
       fOutputTrack->Add(hptFakeTr);
       fOutputTrack->Add(hdistrFakeTr);
       fOutputTrack->Add(hd0f);
-   
+      fOutputTrack->Add(hd0f_filt);
     }
   }
 
@@ -778,6 +825,9 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hname="hntrklvsPercentile01";
     TH2F* hntrklvsPercentile01=new TH2F(hname.Data(),"N tracklets vs Percentile |#eta|<1;ntracklets;percentile",5000,-0.5,4999.5,240,-10.,110);
       
+    hname="hntrklvsPercentile01AllEv";
+    TH2F* hntrklvsPercentile01AllEv=new TH2F(hname.Data(),"N tracklets vs Percentile |#eta|<1 - All Events;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);
 
@@ -793,6 +843,9 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     hname="hStdEstimSignalNtrackletsIn";
     TH2F*hStdEstimSignalNtrackletsIn = new TH2F(hname.Data(),"Std estimator signal vs Number of tracklets in the CC;Std estimator signal;number of tracklets",1000,-0.5,9999.5,5000,-0.5,4999.5);
 
+    hname="hStdEstimSignal";
+    TH1F*hStdEstimSignal = new TH1F(hname.Data(),"Std estimator signal",700,0,1400);
+
     hname="hStdPercentileSecondPercentile";
     TH2F* hStdPercentileSecondPercentile = new TH2F(hname.Data(),"Std estimator Percentile Vs Second Estimator Percentile;Std estimator percentile;Second estimator percentile",120,-10.,110,120,-10.,110);
 
@@ -806,10 +859,12 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
     fOutputCheckCentrality->Add(hMultvsPercentile);
     fOutputCheckCentrality->Add(hntrklvsPercentile);
     fOutputCheckCentrality->Add(hntrklvsPercentile01);
+    fOutputCheckCentrality->Add(hntrklvsPercentile01AllEv);
     fOutputCheckCentrality->Add(hnTPCTracksvsPercentile);
     fOutputCheckCentrality->Add(hnTPCITSTracksvsPercentile);
     fOutputCheckCentrality->Add(hnTPCITS1SPDTracksvsPercentile);
     fOutputCheckCentrality->Add(hStdEstimSignalPercentile);
+    fOutputCheckCentrality->Add(hStdEstimSignal);
     fOutputCheckCentrality->Add(hStdEstimSignalNtrackletsIn);
     fOutputCheckCentrality->Add(hStdPercentileSecondPercentile);
     fOutputCheckCentrality->Add(hStdSignalSecondSignal);
@@ -822,7 +877,8 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
       TH1F* hNtracklets=new TH1F(hname.Data(),"Number of tracklets;ntracklets;Entries",5000,-0.5,4999.5);
       hname="hNtracklets01";
       TH1F* hNtracklets01=new TH1F(hname.Data(),"Number of tracklets |#eta|<1;ntracklets;Entries",5000,-0.5,4999.5);
-        
+      hname="hNtracklets01AllEv";
+      TH1F* hNtracklets01AllEv=new TH1F(hname.Data(),"Number of tracklets |#eta|<1 - All events;ntracklets;Entries",5000,-0.5,4999.5);
       hname="hMult";
       TH1F* hMult=new TH1F(hname.Data(),"Multiplicity;multiplicity;Entries",10000,-0.5,9999.5);
       hname="hMultFBit4";
@@ -834,6 +890,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
 
       fOutputTrack->Add(hNtracklets);
       fOutputTrack->Add(hNtracklets01);
+      fOutputTrack->Add(hNtracklets01AllEv);
       fOutputTrack->Add(hMult);
       fOutputTrack->Add(hMultFBit4);
       fOutputTrack->Add(hMultC05);
@@ -1075,7 +1132,7 @@ void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
   }
 
   // Post the data
-  PostData(1,fNEntries);
+  PostData(1,fOutputEntries);
 
   if(fOnOff[1]) PostData(2,fOutputPID);
   if(fOnOff[0]) PostData(3,fOutputTrack);
@@ -1095,7 +1152,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
   if(fDebug>2) printf("Analysing decay %d\n",fDecayChannel);
   // Post the data already here
-  PostData(1,fNEntries);
+  PostData(1,fOutputEntries);
   if(fOnOff[1]) PostData(2,fOutputPID);
   if(fOnOff[0]) PostData(3,fOutputTrack);
   PostData(4,fCuts);
@@ -1105,6 +1162,12 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   }
 
   TClonesArray *arrayProng =0;
+
+  // Load all the branches of the DeltaAOD - needed for SelectionBit counting
+  TClonesArray *arrayProng1 =0;
+  TClonesArray *arrayProng2 =0;
+  TClonesArray *arrayProng3 =0;
+
   Int_t pdg=0;
   Int_t *pdgdaughters=0x0;
 
@@ -1274,7 +1337,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   if(!arrayProng) {
     AliInfo("Branch not found! The output will contain only track related histograms\n");
     isSimpleMode=kTRUE;
-    fNEntries->Fill(2);
+    ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(2);
   }
   
   TClonesArray *mcArray = 0;
@@ -1307,10 +1370,13 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   
   UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
   Double_t centrality=fCuts->GetCentrality(aod);
-  Double_t multiplicity=aod->GetHeader()->GetRefMultiplicity();
+  AliAODHeader * header = dynamic_cast<AliAODHeader*>(aod->GetHeader());
+  if(!header) AliFatal("Not a standard AOD");
+
+  Double_t multiplicity=header->GetRefMultiplicity();
   Int_t runNumber = aod->GetRunNumber();
   TString trigClass=aod->GetFiredTriggerClasses();
-  Int_t nAODtracks=aod->GetNTracks();
+  Int_t nAODtracks=aod->GetNumberOfTracks();
   Int_t nSelTracksTPCOnly=0;
   Int_t nSelTracksTPCITS=0;
   Int_t nSelTracksTPCITS1SPD=0;
@@ -1329,7 +1395,8 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   }
 
   for (Int_t k=0;k<nAODtracks;k++){
-    AliAODTrack* track=aod->GetTrack(k);
+    AliAODTrack* track=dynamic_cast<AliAODTrack*>(aod->GetTrack(k));
+    if(!track) AliFatal("Not a standard AOD");
     if(track->GetID()<0) continue;
     Int_t nclsTot=0,nclsSPD=0;
     for(Int_t l=0;l<6;l++) {
@@ -1365,7 +1432,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     trigCount->Count(Form("triggerType:All/Run:%d",runNumber));
     trigCount2->Count(Form("triggerType:All/Run:%d",runNumber));
     if(evSelMask==0){
-      if(aod->GetEventType()!=7){
+      if(aod->GetEventType()!=7 || trigClass.Contains("BEAMB")){
        trigCount->Count(Form("triggerType:NoPhysSelEvNot7/Run:%d",runNumber));
        trigCount2->Count(Form("triggerType:NoPhysSelEvNot7/Run:%d",runNumber));
       }else if(trigClass.Contains("CMUP1")){
@@ -1522,8 +1589,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   }
 
   // count event
-  fNEntries->Fill(0);
-
+  ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(0);
   //count events with good vertex
   // AOD primary vertex
   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
@@ -1534,11 +1600,11 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   const AliESDVertex vESD(pos,cov,100.,100);
 
   TString primTitle = vtx1->GetTitle();
-  if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) fNEntries->Fill(4);
+  if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(4);
 
   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
   //TString trigclass=aod->GetFiredTriggerClasses();
-  //if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNEntries->Fill(5); //tmp
+  //if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) hNentries->Fill(5); //tmp
 
 
 
@@ -1734,18 +1800,19 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
       if(stdCent<fCuts->GetMinCentrality() || stdCent>fCuts->GetMaxCentrality()){
        ((TH1F*)fOutputCheckCentrality->FindObject("hNtrackletsOut"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
-       ((TH1F*)fOutputCheckCentrality->FindObject("hMultOut"))->Fill(aod->GetHeader()->GetRefMultiplicity());
+       ((TH1F*)fOutputCheckCentrality->FindObject("hMultOut"))->Fill(header->GetRefMultiplicity());
       }else{
        ((TH1F*)fOutputCheckCentrality->FindObject("hNtrackletsIn"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
-       ((TH1F*)fOutputCheckCentrality->FindObject("hMultIn"))->Fill(aod->GetHeader()->GetRefMultiplicity());
+       ((TH1F*)fOutputCheckCentrality->FindObject("hMultIn"))->Fill(header->GetRefMultiplicity());
       }
-      ((TH2F*)fOutputCheckCentrality->FindObject("hMultvsPercentile"))->Fill(aod->GetHeader()->GetRefMultiplicity(),stdCentf);
+      ((TH2F*)fOutputCheckCentrality->FindObject("hMultvsPercentile"))->Fill(header->GetRefMultiplicity(),stdCentf);
       ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile"))->Fill(aod->GetTracklets()->GetNumberOfTracklets(),stdCentf);
       ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile01"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.),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("hStdEstimSignalPercentile"))->Fill(stdSignal,stdCentf);
+      ((TH1F*)fOutputCheckCentrality->FindObject("hStdEstimSignal"))->Fill(stdSignal);
       ((TH2F*)fOutputCheckCentrality->FindObject("hStdEstimSignalNtrackletsIn"))->Fill(stdSignal,aod->GetTracklets()->GetNumberOfTracklets());
       ((TH2F*)fOutputCheckCentrality->FindObject("hStdPercentileSecondPercentile"))->Fill(stdCentf,secondCentf);
       ((TH2F*)fOutputCheckCentrality->FindObject("hStdSignalSecondSignal"))->Fill(stdSignal,secondSignal);
@@ -1756,10 +1823,20 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
       if(fOnOff[0]){
        ((TH1F*)fOutputTrack->FindObject("hNtracklets"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
        ((TH1F*)fOutputTrack->FindObject("hNtracklets01"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.));
-       ((TH1F*)fOutputTrack->FindObject("hMult"))->Fill(aod->GetHeader()->GetRefMultiplicity());
+       ((TH1F*)fOutputTrack->FindObject("hMult"))->Fill(header->GetRefMultiplicity());
        ((TH1F*)fOutputTrack->FindObject("hMultFBit4"))->Fill(ntracksFBit4);
-       ((TH1F*)fOutputTrack->FindObject("hMultComb05"))->Fill(aod->GetHeader()->GetRefMultiplicityComb05());
-       ((TH1F*)fOutputTrack->FindObject("hMultComb08"))->Fill(aod->GetHeader()->GetRefMultiplicityComb08());
+       ((TH1F*)fOutputTrack->FindObject("hMultComb05"))->Fill(header->GetRefMultiplicityComb05());
+       ((TH1F*)fOutputTrack->FindObject("hMultComb08"))->Fill(header->GetRefMultiplicityComb08());
+      }
+    }
+  }
+
+  if(evSelected || (!evSelbyCentrality && evSelByVertex && evselByPileup && evSelByPS) || (!evSelByVertex && evselByPileup && evSelByPS)){ //events selected or not selected because of centrality
+    if(fOnOff[2] && fCuts->GetUseCentrality()){
+      ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile01AllEv"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.),fCuts->GetCentrality(aod));
+    }else{
+      if(fOnOff[0]){
+       ((TH1F*)fOutputTrack->FindObject("hNtracklets01AllEv"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.));
       }
     }
   }
@@ -1797,6 +1874,46 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
     delete [] pdgdaughters;
     return;
   }
+
+  // load all the branches and fill the SelectionBit histo
+  if(fUseSelectionBit){
+    
+    //load branches
+    arrayProng1=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
+    Int_t nCand = arrayProng1->GetEntriesFast();
+    arrayProng2=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
+    Int_t nCand2 = arrayProng2->GetEntriesFast();
+    arrayProng3=(TClonesArray*)aod->GetList()->FindObject("Dstar");
+    Int_t nCand3 = arrayProng3->GetEntriesFast();
+    
+    // D+, Ds and Lc
+    for (Int_t iCand = 0; iCand < nCand; iCand++) {
+      AliAODRecoDecayHF *d = (AliAODRecoDecayHF*)arrayProng1->UncheckedAt(iCand);
+      Double_t ptCand_selBit = d->Pt();
+      if(fUseSelectionBit && d->GetSelectionMap()) {
+       if(d->HasSelectionBit(AliRDHFCuts::kDplusCuts)) ((TH2F*)fOutputEntries->FindObject("HasSelBit"))->Fill(0.0,ptCand_selBit);
+               if(d->HasSelectionBit(AliRDHFCuts::kDsCuts)) ((TH2F*)fOutputEntries->FindObject("HasSelBit"))->Fill(1.0,ptCand_selBit);
+       if(d->HasSelectionBit(AliRDHFCuts::kLcCuts)) ((TH2F*)fOutputEntries->FindObject("HasSelBit"))->Fill(2.0,ptCand_selBit);
+      }
+    }
+    // D0kpi
+    for (Int_t iCand = 0; iCand < nCand2; iCand++) {
+      AliAODRecoDecayHF *d = (AliAODRecoDecayHF*)arrayProng2->UncheckedAt(iCand);
+      Double_t ptCand_selBit = d->Pt();
+      if(fUseSelectionBit && d->GetSelectionMap()) {
+       if(d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)) ((TH2F*)fOutputEntries->FindObject("HasSelBit"))->Fill(4.0,ptCand_selBit);
+      }     
+    }
+    // Dstar
+    for (Int_t iCand = 0; iCand < nCand3; iCand++) {
+      AliAODRecoDecayHF *d = (AliAODRecoDecayHF*)arrayProng3->UncheckedAt(iCand);
+      Double_t ptCand_selBit = d->Pt();
+      if(fUseSelectionBit && d->GetSelectionMap()) {
+               if(d->HasSelectionBit(AliRDHFCuts::kDstarCuts)) ((TH2F*)fOutputEntries->FindObject("HasSelBit"))->Fill(3.0,ptCand_selBit);
+      }
+    }
+  }
+
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
   AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
@@ -1814,12 +1931,13 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
   Int_t ntracks=0;
   Int_t isGoodTrack=0, isFakeTrack=0, isSelTrack=0;
 
-  if(aod) ntracks=aod->GetNTracks();
+  if(aod) ntracks=aod->GetNumberOfTracks();
 
   if(fOnOff[0] || fOnOff[1]){
     //loop on tracks in the event
     for (Int_t k=0;k<ntracks;k++){
-      AliAODTrack* track=aod->GetTrack(k);
+      AliAODTrack* track=dynamic_cast<AliAODTrack*>(aod->GetTrack(k));
+      if(!track) AliFatal("Not a standard AOD");
 
       // Track selection cuts
       if(track->GetID()<0) continue;
@@ -1843,15 +1961,18 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          !((trStatus & AliVTrack::kITSrefit) == AliVTrack::kITSrefit)){
        selTrack=kFALSE;
       }
-
+      if(!track->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)){ // BIT(4) standard cuts with very loose DCA
+        selTrack=kFALSE;
+      }
+      if(TMath::Abs(track->Eta())>0.9){
+        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]);
@@ -1947,7 +2068,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        }//if TOF status
        //}
       
-       if(pidHF && pidHF->CheckStatus(track,"TPC")){ 
+       if(pidHF && pidHF->CheckStatus(track,"TPC") && selTrack){ 
 
          Double_t TPCp=pid->GetTPCmomentum();
          Double_t TPCsignal=pid->GetTPCsignal();
@@ -2057,8 +2178,8 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
        Int_t label=0;
        if(fReadMC){
          label=track->GetLabel();
-         if (label<0)fNEntries->Fill(8);
-         else fNEntries->Fill(9); 
+         if (label<0)((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(8);
+         else ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(9);
        }
 
 
@@ -2140,12 +2261,12 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
            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) ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(6); //from primary charm
+             if(TMath::Abs(pdgMotCode)==5) ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(7); //from beauty
            }
          }
        }//end MC
-       fNEntries->Fill(5); //count the candidates (data and MC)
+       ((TH1F*)fOutputEntries->FindObject("hNentries"))->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
@@ -2162,6 +2283,38 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
          else 
            track=(AliAODTrack*)d->GetDaughter(id);
 
+
+         // filtering cut level
+         
+         if (fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(pdg)) && fCuts->IsSelected(d,AliRDHFCuts::kAll,aod)) {
+           
+           Int_t label=0;
+           if(fReadMC)label=track->GetLabel();
+           if(fOnOff[0]){
+             
+             if(fReadMC && label<0) {
+               isFakeTrack++;
+               ((TH1F*)fOutputTrack->FindObject("hptFakeTrFromDaugh_filt"))->Fill(track->Pt());
+          
+               ((TH1F*)fOutputTrack->FindObject("hd0f_filt"))->Fill(d->Getd0Prong(id));
+             } else {
+               ((TH1F*)fOutputTrack->FindObject("hptGoodTrFromDaugh_filt"))->Fill(track->Pt());
+               ((TH1F*)fOutputTrack->FindObject("hd0dau_filt"))->Fill(d->Getd0Prong(id));
+                Double_t phidaughter = d->PhiProng(id);
+               if(phidaughter<0) phidaughter=2.0*TMath::Pi()+phidaughter;
+               ((TH2F*)fOutputTrack->FindObject("hd0dauphi_filt"))->Fill(phidaughter, 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("hd0zdau_filt"))->Fill(d0rphiz[1]);
+                 ((TH2F*)fOutputTrack->FindObject("hd0zdauphi_filt"))->Fill(phidaughter,d0rphiz[1]);
+               }
+             }
+           }
+         }
+
+
+
          //track quality
 
          if (fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(pdg)) && fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod)) {
@@ -2252,7 +2405,7 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
 
            if (fCuts->IsSelected(d,AliRDHFCuts::kAll,aod) && fOnOff[1]){
-             fNEntries->Fill(3); //candidates passing analysis cuts         
+              ((TH1F*)fOutputEntries->FindObject("hNentries"))->Fill(3); //candidates passing analysis cuts
 
            AliAODPid *pid = track->GetDetPid();
              if(pid){
@@ -2283,13 +2436,12 @@ void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
 
   delete tpcres;
   delete [] pdgdaughters;
-  PostData(1,fNEntries);
+  PostData(1,fOutputEntries);
   if(fOnOff[1]) PostData(2,fOutputPID);
   if(fOnOff[0]) PostData(3,fOutputTrack);
   PostData(4,fCuts);
   if(fOnOff[2]) PostData(5,fOutputCounters);
   //Post data 6 done in case of centrality on   
-
 }
 
 //____________________________________________________________________________
@@ -2383,8 +2535,8 @@ void AliAnalysisTaskSEHFQA::FillFlowObs(AliAODEvent *aod){
 void AliAnalysisTaskSEHFQA::Terminate(Option_t */*option*/){
   //terminate analysis
 
 fNEntries = dynamic_cast<TH1F*>(GetOutputData(1));
-  if(!fNEntries){
fOutputEntries = dynamic_cast<TList*> (GetOutputData(1));
+  if (!fOutputEntries && fOnOff[1]) {
     printf("ERROR: %s not available\n",GetOutputSlot(1)->GetContainer()->GetName());
     return;
   }
@@ -2403,3 +2555,4 @@ void AliAnalysisTaskSEHFQA::Terminate(Option_t */*option*/){
 
 }
 
+