]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/vertexingHF/AliAnalysisTaskSEDplus.cxx
Update of D+ classes: added acceptance cut, added histograms (Francesco)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSEDplus.cxx
index de16c0a726f9e2838590742f06840e232ebf64f2..352ee09e4fb74c61dca319782280d1a49badb5fb 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/////////////////////////////////////////////////////////////
-//
-// AliAnalysisTaskSE for the extraction of signal(e.g D+) of heavy flavor
-// decay candidates with the MC truth.
+//*************************************************************************
+// Class AliAnalysisTaskSEDplus
+// AliAnalysisTaskSE for the D+ candidates Invariant Mass Histogram and 
+//comparison of heavy-flavour decay candidates
+// to MC truth (kinematics stored in the AOD)
 // Authors: Renu Bala, bala@to.infn.it
 // F. Prino, prino@to.infn.it
 // G. Ortona, ortona@to.infn.it
 
 #include <TClonesArray.h>
 #include <TNtuple.h>
+#include <TCanvas.h>
 #include <TList.h>
 #include <TString.h>
 #include <TH1F.h>
 #include <TDatabasePDG.h>
 
 #include "AliAnalysisManager.h"
+#include "AliRDHFCutsDplustoKpipi.h"
 #include "AliAODHandler.h"
 #include "AliAODEvent.h"
 #include "AliAODVertex.h"
@@ -47,82 +50,118 @@ ClassImp(AliAnalysisTaskSEDplus)
 //________________________________________________________________________
 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
 AliAnalysisTaskSE(),
-fOutput(0), 
-fHistNEvents(0),
-fNtupleDplus(0),
-fUpmasslimit(1.965),
-fLowmasslimit(1.765),
-fNPtBins(0),
-fFillNtuple(kFALSE),
-fReadMC(kFALSE),
-fDoLS(kFALSE),
-fVHF(0)
+  fOutput(0), 
+  fHistNEvents(0),
+  fPtVsMass(0),
+  fPtVsMassTC(0),
+  fYVsPt(0),
+  fYVsPtTC(0),
+  fYVsPtSig(0),
+  fYVsPtSigTC(0),
+  fNtupleDplus(0),
+  fUpmasslimit(1.965),
+  fLowmasslimit(1.765),
+  fNPtBins(0),
+  fBinWidth(0.002),
+  fListCuts(0),
+  fRDCutsProduction(0),
+  fRDCutsAnalysis(0),
+  fFillNtuple(kFALSE),
+  fReadMC(kFALSE),
+  fDoLS(kFALSE)
 {
    // Default constructor
 }
 
 //________________________________________________________________________
-AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,Bool_t fillNtuple):
+AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,AliRDHFCutsDplustoKpipi *dpluscutsana,AliRDHFCutsDplustoKpipi *dpluscutsprod,Bool_t fillNtuple):
 AliAnalysisTaskSE(name),
 fOutput(0),
 fHistNEvents(0),
+fPtVsMass(0),
+fPtVsMassTC(0),
+fYVsPt(0),
+fYVsPtTC(0),
+fYVsPtSig(0),
+fYVsPtSigTC(0),
 fNtupleDplus(0),
 fUpmasslimit(1.965),
 fLowmasslimit(1.765),
 fNPtBins(0),
+fBinWidth(0.002),
+fListCuts(0),
+fRDCutsProduction(dpluscutsprod),
+fRDCutsAnalysis(dpluscutsana),
 fFillNtuple(fillNtuple),
 fReadMC(kFALSE),
-fDoLS(kFALSE),
-fVHF(0)
+fDoLS(kFALSE)
 {
-  Double_t ptlim[5]={0.,2.,3.,5,9999999.};
-  SetPtBinLimit(5, ptlim);
+  // 
+  // Standrd constructor
+  //
+  //Double_t ptlim[5]={0.,2.,3.,5,9999999.};
+   //SetPtBinLimit(5, ptlim);
+  SetPtBinLimit(fRDCutsAnalysis->GetNPtBins()+1,fRDCutsAnalysis->GetPtBinLimits());
   // Default constructor
    // Output slot #1 writes into a TList container
   DefineOutput(1,TList::Class());  //My private output
-
+ // Output slot #2 writes cut to private output
+  //  DefineOutput(2,AliRDHFCutsDplustoKpipi::Class());
+  DefineOutput(2,TList::Class());
   if(fFillNtuple){
-    // Output slot #2 writes into a TNtuple container
-    DefineOutput(2,TNtuple::Class());  //My private output
+    // Output slot #3 writes into a TNtuple container
+    DefineOutput(3,TNtuple::Class());  //My private output
   }
 }
 
 //________________________________________________________________________
 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
 {
+  //
   // Destructor
+  //
   if (fOutput) {
     delete fOutput;
     fOutput = 0;
   }
-  if (fVHF) {
-    delete fVHF;
-    fVHF = 0;
+
+  if (fListCuts) {
+    delete fListCuts;
+    fListCuts = 0;
   }
-  
-  // if(fArrayBinLimits) {
-  //delete fArrayBinLimits;
-  //fArrayBinLimits= 0;
-  //} 
-  
+
+  if(fRDCutsProduction){
+    delete fRDCutsProduction;
+    fRDCutsProduction = 0;
+  }
+
+   if(fRDCutsAnalysis){
+    delete fRDCutsAnalysis;
+    fRDCutsAnalysis = 0;
+  }
+
 }  
 //_________________________________________________________________
 void  AliAnalysisTaskSEDplus::SetMassLimits(Float_t range){
+  // set invariant mass limits
+  Float_t bw=GetBinWidth();
   fUpmasslimit = 1.865+range;
   fLowmasslimit = 1.865-range;
+  SetBinWidth(bw);
 }
 //_________________________________________________________________
 void  AliAnalysisTaskSEDplus::SetMassLimits(Float_t lowlimit, Float_t uplimit){
+  // set invariant mass limits
   if(uplimit>lowlimit)
     {
+      Float_t bw=GetBinWidth();
       fUpmasslimit = lowlimit;
       fLowmasslimit = uplimit;
+      SetBinWidth(bw);
     }
 }
-
-
 //________________________________________________________________________
-void AliAnalysisTaskSEDplus::SetPtBinLimit(Int_t n, Double_t* lim){
+void AliAnalysisTaskSEDplus::SetPtBinLimit(Int_t n, Float_t* lim){
   // define pt bins for analysis
   if(n>kMaxPtBins){
     printf("Max. number of Pt bins = %d\n",kMaxPtBins);
@@ -149,20 +188,37 @@ void AliAnalysisTaskSEDplus::SetPtBinLimit(Int_t n, Double_t* lim){
     for(Int_t i=0; i<fNPtBins+1; i++) printf(" Bin%d = %8.2f-%8.2f\n",i,fArrayBinLimits[i],fArrayBinLimits[i+1]);    
   }
 }
+//________________________________________________________________
+void AliAnalysisTaskSEDplus::SetBinWidth(Float_t w){
+  Float_t width=w;
+  Int_t nbins=(Int_t)((fUpmasslimit-fLowmasslimit)/width+0.5);
+  Int_t missingbins=4-nbins%4;
+  nbins=nbins+missingbins;
+  width=(fUpmasslimit-fLowmasslimit)/nbins;
+  if(missingbins!=0){
+    printf("AliAnalysisTaskSEDplus::SetBinWidth: W-bin width of %f will produce histograms not rebinnable by 4. New width set to %f\n",w,width);
+  }
+  else{
+    if(fDebug>1) printf("AliAnalysisTaskSEDplus::SetBinWidth: width set to %f\n",width);
+  }
+  fBinWidth=width;
+}
 //_________________________________________________________________
 Double_t  AliAnalysisTaskSEDplus::GetPtBinLimit(Int_t ibin){
+  // get pt bin limit
   if(ibin>fNPtBins)return -1;
   return fArrayBinLimits[ibin];
 } 
-
+//_________________________________________________________________
+Int_t AliAnalysisTaskSEDplus::GetNBinsHistos(){
+  return (Int_t)((fUpmasslimit-fLowmasslimit)/fBinWidth+0.5);
+}
 //_________________________________________________________________
 void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesArray *arrayLikeSign,AliAODEvent *aod,AliAODVertex *vtx1, Int_t nDplusOS){
-
-/*
- * Fill the Like Sign histograms
- */
-
-  Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
+  //
+  //
+  // Fill the Like Sign histograms
+  //
 
   //count pos/neg tracks
   Int_t nPosTrks=0,nNegTrks=0;
@@ -200,7 +256,7 @@ void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesA
       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
       unsetvtx=kTRUE;
     }
-    if(d->SelectDplus(fVHF->GetDplusCuts()))nDplusLS++;
+    if(fRDCutsProduction->IsSelected(d,AliRDHFCuts::kCandidate))nDplusLS++;
     if(unsetvtx) d->UnsetOwnPrimaryVtx();
   }
 
@@ -218,38 +274,11 @@ void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesA
       unsetvtx=kTRUE;
     }
  
-    if(d->SelectDplus(fVHF->GetDplusCuts())){
+    if(fRDCutsProduction->IsSelected(d,AliRDHFCuts::kCandidate)){
 
       //set tight cuts values
       Int_t iPtBin=-1;
       Double_t ptCand = d->Pt();
-      if(ptCand<2.){
-       //iPtBin=0;
-       cutsDplus[7]=0.08;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.970;
-       cutsDplus[10]=0.0055;
-      }
-      else if(ptCand>2. && ptCand<3){ 
-       //iPtBin=1;
-       cutsDplus[7]=0.08;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.987;
-       cutsDplus[10]=0.005;
-      }else if(ptCand>3. && ptCand<5){ 
-       //iPtBin=2;
-       cutsDplus[7]=0.1;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.990;
-       cutsDplus[10]=0.0035;
-      }else{
-       //iPtBin=3;
-       cutsDplus[7]=0.1;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.995;
-       cutsDplus[10]=0.001;
-      }
-      
       for(Int_t ibin=0;ibin<fNPtBins&&iPtBin<0&&ptCand>fArrayBinLimits[0]&&ptCand<fArrayBinLimits[fNPtBins];ibin++){
        if(ptCand<fArrayBinLimits[ibin+1])iPtBin=ibin;
       }
@@ -258,7 +287,7 @@ void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesA
        return;
       }
 
-      Bool_t passTightCuts=d->SelectDplus(cutsDplus);
+      Int_t passTightCuts=fRDCutsAnalysis->IsSelected(d,AliRDHFCuts::kCandidate);
 
       Int_t sign= d->GetCharge();
       Float_t wei=1;
@@ -276,15 +305,30 @@ void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesA
       }
 
       Float_t invMass = d->InvMassDplus();
-      
-      
+      Double_t dlen=d->DecayLength();
+      Double_t cosp=d->CosPointingAngle();
+      Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
+     Double_t dca=d->GetDCA();   
+     Double_t sigvert=d->GetSigmaVert();   
+     Double_t ptmax=0;
+     for(Int_t i=0;i<3;i++){
+       if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
+     }
+     
       index=GetLSHistoIndex(iPtBin);
       fMassHistLS[index]->Fill(invMass,wei);
       fMassHistLS[index+1]->Fill(invMass);
       fMassHistLS[index+2]->Fill(invMass,wei2);
       fMassHistLS[index+3]->Fill(invMass,wei3);
       fMassHistLS[index+4]->Fill(invMass,wei4);
-
+      
+      Int_t indexcut=GetHistoIndex(iPtBin);
+      fCosPHistLS[indexcut]->Fill(cosp);
+      fDLenHistLS[indexcut]->Fill(dlen);
+      fSumd02HistLS[indexcut]->Fill(sumD02);
+      fSigVertHistLS[indexcut]->Fill(sigvert);
+      fPtMaxHistLS[indexcut]->Fill(ptmax);
+      fDCAHistLS[indexcut]->Fill(dca);
       
       if(passTightCuts){
        fMassHistLSTC[index]->Fill(invMass,wei);
@@ -304,18 +348,25 @@ void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesA
 
 }
 
-//________________________________________________________________________
-void AliAnalysisTaskSEDplus::Init()
-{
-  // Initialization
 
+//__________________________________________
+void AliAnalysisTaskSEDplus::Init(){
+  //
+  // Initialization
+  //
   if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
-
-  gROOT->LoadMacro("ConfigVertexingHF.C");
-
-  fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");  
-  fVHF->PrintStatus();
-
+  
+  //PostData(2,fRDCutsloose);//we should then put those cuts in a tlist if we have more than 1
+  fListCuts=new TList();
+  AliRDHFCutsDplustoKpipi *production = new AliRDHFCutsDplustoKpipi();
+  production=fRDCutsProduction;
+  AliRDHFCutsDplustoKpipi *analysis = new AliRDHFCutsDplustoKpipi();
+  analysis=fRDCutsAnalysis;
+  
+  fListCuts->Add(production);
+  fListCuts->Add(analysis);
+  PostData(2,fListCuts);
+  
   return;
 }
 
@@ -334,90 +385,261 @@ void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
   TString hisname;
   Int_t index=0;
   Int_t indexLS=0;
+  Int_t nbins=GetNBinsHistos();
   for(Int_t i=0;i<fNPtBins;i++){
 
     index=GetHistoIndex(i);
     indexLS=GetLSHistoIndex(i);
+
     hisname.Form("hMassPt%d",i);
-    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHist[index]->Sumw2();
+    hisname.Form("hCosPAllPt%d",i);
+    fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHist[index]->Sumw2();
+    hisname.Form("hDLenAllPt%d",i);
+    fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHist[index]->Sumw2();
+    hisname.Form("hSumd02AllPt%d",i);
+    fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02Hist[index]->Sumw2();
+    hisname.Form("hSigVertAllPt%d",i);
+    fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHist[index]->Sumw2();
+    hisname.Form("hPtMaxAllPt%d",i);
+    fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHist[index]->Sumw2();
+
+    hisname.Form("hDCAAllPt%d",i);
+    fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHist[index]->Sumw2();
+
+
+
     hisname.Form("hMassPt%dTC",i);
-    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistTC[index]->Sumw2();
-    hisname.Form("hLSPt%dTC",i);
-    fMassHistLSTC[indexLS] = new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
-    fMassHistLSTC[indexLS]->Sumw2();
+
+
+
+
+    
+    hisname.Form("hCosPAllPt%dLS",i);
+    fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHistLS[index]->Sumw2();
+    hisname.Form("hDLenAllPt%dLS",i);
+    fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHistLS[index]->Sumw2();
+    hisname.Form("hSumd02AllPt%dLS",i);
+    fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02HistLS[index]->Sumw2();
+    hisname.Form("hSigVertAllPt%dLS",i);
+    fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHistLS[index]->Sumw2();
+    hisname.Form("hPtMaxAllPt%dLS",i);
+    fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHistLS[index]->Sumw2();
+    
+    hisname.Form("hDCAAllPt%dLS",i);
+    fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHistLS[index]->Sumw2();
+    
     hisname.Form("hLSPt%dLC",i);
-    fMassHistLS[indexLS] = new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLS[indexLS] = new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLS[indexLS]->Sumw2();
     
+    hisname.Form("hLSPt%dTC",i);
+    fMassHistLSTC[indexLS] = new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
+    fMassHistLSTC[indexLS]->Sumw2();
+
+
+    
     index=GetSignalHistoIndex(i);    
     indexLS++;
     hisname.Form("hSigPt%d",i);
-    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHist[index]->Sumw2();
+    hisname.Form("hCosPSigPt%d",i);
+    fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHist[index]->Sumw2();
+    hisname.Form("hDLenSigPt%d",i);
+    fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHist[index]->Sumw2();
+    hisname.Form("hSumd02SigPt%d",i);
+    fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02Hist[index]->Sumw2();
+    hisname.Form("hSigVertSigPt%d",i);
+    fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHist[index]->Sumw2();
+    hisname.Form("hPtMaxSigPt%d",i);
+    fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHist[index]->Sumw2();    
+
+    hisname.Form("hDCASigPt%d",i);
+    fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHist[index]->Sumw2();    
+
+
     hisname.Form("hSigPt%dTC",i);
-    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistTC[index]->Sumw2();
+
     hisname.Form("hLSPt%dLCnw",i);
-    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLS[indexLS]->Sumw2();
     hisname.Form("hLSPt%dTCnw",i);
-    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLSTC[indexLS]->Sumw2();
 
+
+    
+    hisname.Form("hCosPSigPt%dLS",i);
+    fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHistLS[index]->Sumw2();
+    hisname.Form("hDLenSigPt%dLS",i);
+    fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHistLS[index]->Sumw2();
+    hisname.Form("hSumd02SigPt%dLS",i);
+    fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02HistLS[index]->Sumw2();
+    hisname.Form("hSigVertSigPt%dLS",i);
+    fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHistLS[index]->Sumw2();
+    hisname.Form("hPtMaxSigPt%dLS",i);
+    fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHistLS[index]->Sumw2();
+
+    hisname.Form("hDCASigPt%dLS",i);
+    fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHistLS[index]->Sumw2();
+    
+
+
     index=GetBackgroundHistoIndex(i); 
     indexLS++;
     hisname.Form("hBkgPt%d",i);
-    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHist[index]->Sumw2();
+    hisname.Form("hCosPBkgPt%d",i);
+    fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHist[index]->Sumw2();
+    hisname.Form("hDLenBkgPt%d",i);
+    fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHist[index]->Sumw2();
+    hisname.Form("hSumd02BkgPt%d",i);
+    fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02Hist[index]->Sumw2();
+    hisname.Form("hSigVertBkgPt%d",i);
+    fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHist[index]->Sumw2();
+    hisname.Form("hPtMaxBkgPt%d",i);
+    fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHist[index]->Sumw2();
+
+    hisname.Form("hDCABkgPt%d",i);
+    fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHist[index]->Sumw2();
+
+
     hisname.Form("hBkgPt%dTC",i);
-    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistTC[index]->Sumw2();
+
     hisname.Form("hLSPt%dLCntrip",i);
-    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLS[indexLS]->Sumw2();
     hisname.Form("hLSPt%dTCntrip",i);
-    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLSTC[indexLS]->Sumw2();
 
+    
+    hisname.Form("hCosPBkgPt%dLS",i);
+    fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
+    fCosPHistLS[index]->Sumw2();
+    hisname.Form("hDLenBkgPt%dLS",i);
+    fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
+    fDLenHistLS[index]->Sumw2();
+    hisname.Form("hSumd02BkgPt%dLS",i);
+    fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
+    fSumd02HistLS[index]->Sumw2();
+    hisname.Form("hSigVertBkgPt%dLS",i);
+    fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fSigVertHistLS[index]->Sumw2();
+    hisname.Form("hPtMaxBkgPt%dLS",i);
+    fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
+    fPtMaxHistLS[index]->Sumw2();
+    hisname.Form("hDCABkgPt%dLS",i);
+    fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
+    fDCAHistLS[index]->Sumw2();
+    
+
     indexLS++;
     hisname.Form("hLSPt%dLCntripsinglecut",i);
-    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLS[indexLS]->Sumw2();
     hisname.Form("hLSPt%dTCntripsinglecut",i);
-    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLSTC[indexLS]->Sumw2();
 
     indexLS++;
     hisname.Form("hLSPt%dLCspc",i);
-    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLS[indexLS]->Sumw2();
     hisname.Form("hLSPt%dTCspc",i);
-    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
+    fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
     fMassHistLSTC[indexLS]->Sumw2();
   }
   
   for(Int_t i=0; i<3*fNPtBins; i++){
     fOutput->Add(fMassHist[i]);
+     fOutput->Add(fCosPHist[i]);
+    fOutput->Add(fDLenHist[i]);
+    fOutput->Add(fSumd02Hist[i]);
+    fOutput->Add(fSigVertHist[i]);
+    fOutput->Add(fPtMaxHist[i]);
+    fOutput->Add(fDCAHist[i]);
     fOutput->Add(fMassHistTC[i]);
   }
+  for(Int_t i=0; i<3*fNPtBins&&fDoLS; i++){
+    fOutput->Add(fCosPHistLS[i]);
+    fOutput->Add(fDLenHistLS[i]);
+    fOutput->Add(fSumd02HistLS[i]);
+    fOutput->Add(fSigVertHistLS[i]);
+    fOutput->Add(fPtMaxHistLS[i]);  
+    fOutput->Add(fDCAHistLS[i]);  
+  }
   for(Int_t i=0; i<5*fNPtBins&&fDoLS; i++){
     fOutput->Add(fMassHistLS[i]);
     fOutput->Add(fMassHistLSTC[i]);
   }
-
+  
 
   fHistNEvents = new TH1F("fHistNEvents", "Number of processed events; ; Events",3,-1.5,1.5);
- fHistNEvents->Sumw2();
- fHistNEvents->SetMinimum(0);
- fOutput->Add(fHistNEvents);
+  fHistNEvents->Sumw2();
+  fHistNEvents->SetMinimum(0);
+  fOutput->Add(fHistNEvents);
+
+  fPtVsMass=new TH2F("hPtVsMass","PtVsMass (prod. cuts)",nbins,fLowmasslimit,fUpmasslimit,40,0.,20.);
+  fPtVsMassTC=new TH2F("hPtVsMassTC","PtVsMass (analysis cuts)",nbins,fLowmasslimit,fUpmasslimit,40,0.,20.);  
+  fYVsPt=new TH2F("hYVsPt","YvsPt (prod. cuts)",40,0.,20.,80,-2.,2.);
+  fYVsPtTC=new TH2F("hYVsPtTC","YvsPt (analysis cuts)",40,0.,20.,80,-2.,2.);
+  fYVsPtSig=new TH2F("hYVsPtSig","YvsPt (MC, only sig., prod. cuts)",40,0.,20.,80,-2.,2.);
+  fYVsPtSigTC=new TH2F("hYVsPtSigTC","YvsPt (MC, only Sig, analysis cuts)",40,0.,20.,80,-2.,2.);
+
+  fOutput->Add(fPtVsMass);
+  fOutput->Add(fPtVsMassTC);
+  fOutput->Add(fYVsPt);
+  fOutput->Add(fYVsPtTC);
+  fOutput->Add(fYVsPtSig);
+  fOutput->Add(fYVsPtSigTC);
 
   if(fFillNtuple){
     OpenFile(2); // 2 is the slot number of the ntuple
-    fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:PtTrue:VxTrue:VyTrue:VzTrue:Ptpi:PtK:Ptpi2:PtRec:PointingAngle:DecLeng:VxRec:VyRec:VzRec:InvMass:sigvert:d0Pi:d0K:d0Pi2");
+   
+    fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:PtTrue:VxTrue:VyTrue:VzTrue:Ptpi:PtK:Ptpi2:PtRec:PointingAngle:DecLeng:VxRec:VyRec:VzRec:InvMass:sigvert:d0Pi:d0K:d0Pi2:dca:d0square");  
+    
   }
-
+  
   return;
 }
 
@@ -427,10 +649,7 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
   // Execute analysis for current event:
   // heavy flavor candidates association to MC truth
 
-   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
- fHistNEvents->Fill(0); // count event
-  // Post the data already here
-  PostData(1,fOutput);
+  AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
   
   TClonesArray *array3Prong = 0;
   TClonesArray *arrayLikeSign =0;
@@ -438,8 +657,8 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
     // In case there is an AOD handler writing a standard AOD, use the AOD 
     // event in memory rather than the input (ESD) event.    
     aod = dynamic_cast<AliAODEvent*> (AODEvent());
-    // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
-    // have to taken from the AOD event hold by the AliAODExtension
+     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
+     // have to taken from the AOD event hold by the AliAODExtension
     AliAODHandler* aodHandler = (AliAODHandler*) 
       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     if(aodHandler->GetExtensions()) {
@@ -462,6 +681,14 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
     return;
   }
 
+
+  // fix for temporary bug in ESDfilter 
+  // the AODs with null vertex pointer didn't pass the PhysSel
+  if(!aod->GetPrimaryVertex()) return;
+
+  fHistNEvents->Fill(0); // count event
+  // Post the data already here
+  PostData(1,fOutput);
  
   TClonesArray *arrayMC=0;
   AliAODMCHeader *mcHeader=0;
@@ -494,7 +721,8 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
   Int_t nOS=0;
   Int_t index;
   Int_t pdgDgDplustoKpipi[3]={321,211,211};
-  Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
+  // Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};//TO REMOVE
+  //Double_t *cutsDplus = new (Double_t*)fRDCuts->GetCuts();
   for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
     AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
     
@@ -505,42 +733,16 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
       unsetvtx=kTRUE;
     }
 
-    if(d->SelectDplus(fVHF->GetDplusCuts())) {
+    if(fRDCutsProduction->IsSelected(d,AliRDHFCuts::kCandidate)) {
       Int_t iPtBin = -1;
       Double_t ptCand = d->Pt();
-      
-      if(ptCand<2.){
-       //iPtBin=0;
-       cutsDplus[7]=0.08;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.970;
-       cutsDplus[10]=0.0055;
-      }
-      else if(ptCand>2. && ptCand<3){ 
-       //iPtBin=1;
-       cutsDplus[7]=0.08;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.987;
-       cutsDplus[10]=0.005;
-      }else if(ptCand>3. && ptCand<5){ 
-       //iPtBin=2;
-       cutsDplus[7]=0.1;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.990;
-       cutsDplus[10]=0.0035;
-      }else{
-       //iPtBin=3;
-       cutsDplus[7]=0.1;
-       cutsDplus[8]=0.5;
-       cutsDplus[9]=0.995;
-       cutsDplus[10]=0.001;
-      }
-      
+
       for(Int_t ibin=0;ibin<fNPtBins&&iPtBin<0&&ptCand>fArrayBinLimits[0]&&ptCand<fArrayBinLimits[fNPtBins];ibin++){
        if(ptCand<fArrayBinLimits[ibin+1])iPtBin=ibin;
       }
       
-      Bool_t passTightCuts=d->SelectDplus(cutsDplus);
+      Int_t passTightCuts=fRDCutsAnalysis->IsSelected(d,AliRDHFCuts::kCandidate);
+
       Int_t labDp=-1;
       Float_t deltaPx=0.;
       Float_t deltaPy=0.;
@@ -568,8 +770,15 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
        }
       }
       Double_t invMass=d->InvMassDplus();
-
-      Float_t tmp[22];
+      Double_t rapid=d->YDplus();
+      fYVsPt->Fill(ptCand,rapid);
+      if(passTightCuts) fYVsPtTC->Fill(ptCand,rapid);
+      Bool_t isFidAcc=fRDCutsAnalysis->IsInFiducialAcceptance(ptCand,rapid);
+      if(isFidAcc){
+       fPtVsMass->Fill(invMass,ptCand);
+       if(passTightCuts) fPtVsMassTC->Fill(invMass,ptCand);
+      }
+      Float_t tmp[24];
       if(fFillNtuple){           
        tmp[0]=pdgCode;
        tmp[1]=deltaPx;
@@ -592,51 +801,76 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
        tmp[18]=d->GetSigmaVert();
        tmp[19]=d->Getd0Prong(0);
        tmp[20]=d->Getd0Prong(1);
-       tmp[21]=d->Getd0Prong(2);         
+       tmp[21]=d->Getd0Prong(2);
+       tmp[22]=d->GetDCA();
+       tmp[23]=d->Prodd0d0(); 
        fNtupleDplus->Fill(tmp);
-       PostData(2,fNtupleDplus);
+       PostData(3,fNtupleDplus);
+      }
+      Double_t dlen=d->DecayLength();
+      Double_t cosp=d->CosPointingAngle();
+      Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
+      Double_t dca=d->GetDCA();
+      Double_t sigvert=d->GetSigmaVert();         
+      Double_t ptmax=0;
+      for(Int_t i=0;i<3;i++){
+       if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
       }
-
       if(iPtBin>=0){
       
        index=GetHistoIndex(iPtBin);
-       fMassHist[index]->Fill(invMass);
-       if(passTightCuts){
-         fMassHistTC[index]->Fill(invMass);
-
+       if(isFidAcc){
+         fMassHist[index]->Fill(invMass);
+         fCosPHist[index]->Fill(cosp);
+         fDLenHist[index]->Fill(dlen);
+         fSumd02Hist[index]->Fill(sumD02);
+         fSigVertHist[index]->Fill(sigvert);
+         fPtMaxHist[index]->Fill(ptmax);
+         fDCAHist[index]->Fill(dca);
+         
+         if(passTightCuts){
+           fMassHistTC[index]->Fill(invMass);
+         }
        }
        
        if(fReadMC){
          if(labDp>=0) {
            index=GetSignalHistoIndex(iPtBin);
-           fMassHist[index]->Fill(invMass);
-
-           if(passTightCuts){
-             fMassHistTC[index]->Fill(invMass);
-
-           }
-           
+           if(isFidAcc){
+             fMassHist[index]->Fill(invMass);
+             fCosPHist[index]->Fill(cosp);
+             fDLenHist[index]->Fill(dlen);
+             fSumd02Hist[index]->Fill(sumD02);
+             fSigVertHist[index]->Fill(sigvert);
+             fPtMaxHist[index]->Fill(ptmax);
+             fDCAHist[index]->Fill(dca);
+             if(passTightCuts){
+               fMassHistTC[index]->Fill(invMass);            
+             }
+           }       
+           fYVsPtSig->Fill(ptCand,rapid);
+           if(passTightCuts) fYVsPtSigTC->Fill(ptCand,rapid);
          }else{
            index=GetBackgroundHistoIndex(iPtBin);
-           fMassHist[index]->Fill(invMass);
-
-           if(passTightCuts){
-             fMassHistTC[index]->Fill(invMass);
-
+           if(isFidAcc){
+             fMassHist[index]->Fill(invMass);
+             fCosPHist[index]->Fill(cosp);
+             fDLenHist[index]->Fill(dlen);
+             fSumd02Hist[index]->Fill(sumD02);
+             fSigVertHist[index]->Fill(sigvert);
+             fPtMaxHist[index]->Fill(ptmax);
+             fDCAHist[index]->Fill(dca);
+             if(passTightCuts){
+               fMassHistTC[index]->Fill(invMass);
+             }
            }   
          }
        }
-      }
-      /*
-      //start OS analysis
-      if(labDp<0)fHistOSbkg->Fill(d->InvMassDplus());
-      fHistOS->Fill(d->InvMassDplus());
-      */
-      nOS++;
+      }    
     }
     if(unsetvtx) d->UnsetOwnPrimaryVtx();
   }
+  
   //start LS analysis
   if(fDoLS && arrayLikeSign) LSAnalysis(array3Prong,arrayLikeSign,aod,vtx1,nOS);
   
@@ -658,57 +892,138 @@ void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
     printf("ERROR: fOutput not available\n");
     return;
   }
- fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEvents"));
+  fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEvents"));
+  fYVsPt = dynamic_cast<TH2F*>(fOutput->FindObject("hYVsPt"));
+  fYVsPtTC = dynamic_cast<TH2F*>(fOutput->FindObject("hYVsPtTC"));
+  fYVsPtSig = dynamic_cast<TH2F*>(fOutput->FindObject("hYVsPtSig"));
+  fYVsPtSigTC = dynamic_cast<TH2F*>(fOutput->FindObject("hYVsPtSigTC"));
+  fPtVsMass = dynamic_cast<TH2F*>(fOutput->FindObject("hPtVsMass"));
+  fPtVsMassTC = dynamic_cast<TH2F*>(fOutput->FindObject("hPtVsMassTC"));
+
+  TString hisname;
+  Int_t index=0;
 
- TString hisname;
- Int_t index=0;
- Int_t indexLS=0;
- for(Int_t i=0;i<fNPtBins;i++){
+  Int_t indexLS=0;
+  for(Int_t i=0;i<fNPtBins;i++){
     index=GetHistoIndex(i);
     if(fDoLS)indexLS=GetLSHistoIndex(i);
     hisname.Form("hMassPt%d",i);
     fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hCosPAllPt%d",i);
+    fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDLenAllPt%d",i);
+    fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSumd02AllPt%d",i);
+    fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSigVertAllPt%d",i);
+    fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hPtMaxAllPt%d",i);
+    fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDCAAllPt%d",i);
+    fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     hisname.Form("hMassPt%dTC",i);
     fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     if(fDoLS){
-      hisname.Form("hLSPt%dTC",i);
-      fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
       hisname.Form("hLSPt%dLC",i);
       fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hCosPAllPt%dLS",i);
+      fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDLenAllPt%dLS",i);
+      fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSumd02AllPt%dLS",i);
+      fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSigVertAllPt%dLS",i);
+      fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hPtMaxAllPt%dLS",i);
+      fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDCAAllPt%dLS",i);
+      fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      
+      hisname.Form("hLSPt%dTC",i);
+      fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      
     } 
     
     index=GetSignalHistoIndex(i);    
     if(fDoLS)indexLS++;
     hisname.Form("hSigPt%d",i);
     fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hCosPSigPt%d",i);
+    fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDLenSigPt%d",i);
+    fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSumd02SigPt%d",i);
+    fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSigVertSigPt%d",i);
+    fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hPtMaxSigPt%d",i);
+    fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDCASigPt%d",i);
+    fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    
     hisname.Form("hSigPt%dTC",i);
     fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     if(fDoLS){
       hisname.Form("hLSPt%dLCnw",i);
       fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hCosPSigPt%dLS",i);
+      fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDLenSigPt%dLS",i);
+      fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSumd02SigPt%dLS",i);
+      fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSigVertSigPt%dLS",i);
+      fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hPtMaxSigPt%dLS",i);
+      fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDCASigPt%dLS",i);
+      fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+
       hisname.Form("hLSPt%dTCnw",i);
       fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     }
-
+    
     index=GetBackgroundHistoIndex(i); 
     if(fDoLS)indexLS++;
     hisname.Form("hBkgPt%d",i);
     fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hCosPBkgPt%d",i);
+    fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDLenBkgPt%d",i);
+    fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSumd02BkgPt%d",i);
+    fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hSigVertBkgPt%d",i);
+    fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hPtMaxBkgPt%d",i);
+    fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+    hisname.Form("hDCABkgPt%d",i);
+    fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     hisname.Form("hBkgPt%dTC",i);
     fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
     if(fDoLS){
       hisname.Form("hLSPt%dLCntrip",i);
       fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
  
+
+      hisname.Form("hCosPBkgPt%dLS",i);
+      fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDLenBkgPt%dLS",i);
+      fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSumd02BkgPt%dLS",i);
+      fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hSigVertBkgPt%dLS",i);
+      fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hPtMaxBkgPt%dLS",i);
+      fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      hisname.Form("hDCABkgPt%dLS",i);
+      fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
+      
       hisname.Form("hLSPt%dTCntrip",i);
       fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
-    
-
+      
+      
       indexLS++;
       hisname.Form("hLSPt%dLCntripsinglecut",i);
       fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
@@ -728,9 +1043,15 @@ void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
   }
 
   if(fFillNtuple){
-    fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
+    fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(3));
   }
 
-
+  TCanvas *c1=new TCanvas("c1","D+ invariant mass distribution",500,500);
+  c1->cd();
+  TH1F *hMassPt=(TH1F*)fOutput->FindObject("hMassPt3TC");
+  hMassPt->SetLineColor(kBlue);
+  hMassPt->SetXTitle("M[GeV/c^{2}]"); 
+  hMassPt->Draw();
   return;
 }