]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliAnalysisTaskSELambdac.cxx
Compilation with Root6, lost in the previous commit
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSELambdac.cxx
index d867512912c4d9079ed875da0a4c0883f8a9f9ba..ac329759799bade8d11fba26b0754136ab9dab12 100644 (file)
 #include "AliInputEventHandler.h"
 #include "AliPID.h"
 #include "AliNormalizationCounter.h"
-
+#include "AliVertexingHFUtils.h"
 ClassImp(AliAnalysisTaskSELambdac)
 
 
 //________________________________________________________________________
-  AliAnalysisTaskSELambdac::AliAnalysisTaskSELambdac():
-    AliAnalysisTaskSE(),
-    fOutput(0), 
-    fHistNEvents(0),
-    fhChi2(0),
-    fhMassPtGreater3(0),
-    fhMassPtGreater3TC(0),
-    fhMassPtGreater3Kp(0),
-    fhMassPtGreater3KpTC(0),
-    fhMassPtGreater3Lpi(0),
-    fhMassPtGreater3LpiTC(0),
-    fhMassPtGreater3Dk(0),
-    fhMassPtGreater3DkTC(0),
-    fhMassPtGreater33Pr(0),
-    fhMassPtGreater33PrTC(0),
-    fhMassPtGreater2(0),
-    fhMassPtGreater2TC(0),
-    fhMassPtGreater2Kp(0),
-    fhMassPtGreater2KpTC(0),
-    fhMassPtGreater2Lpi(0),
-    fhMassPtGreater2LpiTC(0),
-    fhMassPtGreater2Dk(0),
-    fhMassPtGreater2DkTC(0),
-    fhMassPtGreater23Pr(0),
-    fhMassPtGreater23PrTC(0),
-    fNtupleLambdac(0),
-    fUpmasslimit(2.486),
-    fLowmasslimit(2.086),
-    fNPtBins(0),
-    fRDCutsAnalysis(0),
-    fRDCutsProduction(0),
-    fListCuts(0),
-    fFillNtuple(kFALSE),
-    fReadMC(kFALSE),
-    fMCPid(kFALSE),
-    fRealPid(kFALSE),
-    fResPid(kTRUE),
-    fUseKF(kFALSE),
-    fAnalysis(kFALSE),
-    fVHF(0),
-    fFillVarHists(kFALSE),
-    fMultiplicityHists(kFALSE),
-    fPriorsHists(kFALSE),
-    fNentries(0),
-    fOutputMC(0),
-    fAPriori(0),
-    fMultiplicity(0),
-    //fUtilPid(0),
-    fPIDResponse(0),
-    fCounter(0)
+AliAnalysisTaskSELambdac::AliAnalysisTaskSELambdac():
+AliAnalysisTaskSE(),
+  fOutput(0), 
+  fHistNEvents(0),
+  fhChi2(0),
+  fhMassPtGreater3(0),
+  fhMassPtGreater3TC(0),
+  fhMassPtGreater3Kp(0),
+  fhMassPtGreater3KpTC(0),
+  fhMassPtGreater3Lpi(0),
+  fhMassPtGreater3LpiTC(0),
+  fhMassPtGreater3Dk(0),
+  fhMassPtGreater3DkTC(0),
+  fhMassPtGreater33Pr(0),
+  fhMassPtGreater33PrTC(0),
+  fhMassPtGreater2(0),
+  fhMassPtGreater2TC(0),
+  fhMassPtGreater2Kp(0),
+  fhMassPtGreater2KpTC(0),
+  fhMassPtGreater2Lpi(0),
+  fhMassPtGreater2LpiTC(0),
+  fhMassPtGreater2Dk(0),
+  fhMassPtGreater2DkTC(0),
+  fhMassPtGreater23Pr(0),
+  fhMassPtGreater23PrTC(0),
+  fhEta3Prong(0),
+  fhEta3ProngAcc(0),
+  fhEta3ProngProd(0),
+  fhEta3ProngAn(0),
+  fhRap3Prong(0),
+  fhRap3ProngAcc(0),
+  fhRap3ProngProd(0),
+  fhRap3ProngAn(0),
+  fhSelectBit(0),
+  fhProtonPtProngLcPt(0),
+  fhBProtonPtProngLcPt(0),
+  fhProtond0ProngLcPt(0),
+  fhBProtond0ProngLcPt(0),
+  fhKaonPtProngLcPt(0),
+  fhBKaonPtProngLcPt(0),
+  fhKaond0ProngLcPt(0),
+  fhBKaond0ProngLcPt(0),
+  fhPionPtProngLcPt(0),
+  fhBPionPtProngLcPt(0),
+  fhPiond0ProngLcPt(0),
+  fhBPiond0ProngLcPt(0),
+  fhDist12PrimLcPt(0),
+  fhBDist12PrimLcPt(0),
+  fhSigmaVertLcPt(0),
+  fhBSigmaVertLcPt(0),
+  fhdcasLcPt(0),
+  fhBdcasLcPt(0),
+  fhCosPointingAngleLcPt(0),
+  fhBCosPointingAngleLcPt(0),
+  fhDecayLengthLcPt(0),
+  fhBDecayLengthLcPt(0),
+  fhSum2LcPt(0),
+  fhBSum2LcPt(0),
+  fhPtMaxLcPt(0),
+  fhBPtMaxLcPt(0),
+  fNtupleLambdac(0),
+  fUpmasslimit(2.486),
+  fLowmasslimit(2.086),
+  fNPtBins(0),
+  fRDCutsAnalysis(0),
+  fRDCutsProduction(0),
+  fListCuts(0),
+  fFillNtuple(kFALSE),
+  fReadMC(kFALSE),
+  fMCPid(kFALSE),
+  fRealPid(kFALSE),
+  fResPid(kTRUE),
+  fUseKF(kFALSE),
+  fAnalysis(kFALSE),
+  fVHF(0),
+  fFillVarHists(kFALSE),
+  fMultiplicityHists(kFALSE),
+  fPriorsHists(kFALSE),
+  fLcCut(kFALSE),
+  fLcPIDCut(kFALSE),    
+  fNentries(0),
+  fOutputMC(0),
+  fAPriori(0),
+  fMultiplicity(0),
+//fUtilPid(0),
+  fPIDResponse(0),
+  fCounter(0)
 {
   // Default constructor
   Float_t ptlims[7]={0.,2.,4.,6.,8.,12.,24.};
@@ -155,6 +192,41 @@ AliAnalysisTaskSELambdac::AliAnalysisTaskSELambdac(const char *name,Bool_t fillN
   fhMassPtGreater2DkTC(0),
   fhMassPtGreater23Pr(0),
   fhMassPtGreater23PrTC(0),
+  fhEta3Prong(0),
+  fhEta3ProngAcc(0),
+  fhEta3ProngProd(0),
+  fhEta3ProngAn(0),
+  fhRap3Prong(0),
+  fhRap3ProngAcc(0),
+  fhRap3ProngProd(0),
+  fhRap3ProngAn(0),
+  fhSelectBit(0),
+  fhProtonPtProngLcPt(0),
+  fhBProtonPtProngLcPt(0),
+  fhProtond0ProngLcPt(0),
+  fhBProtond0ProngLcPt(0),
+  fhKaonPtProngLcPt(0),
+  fhBKaonPtProngLcPt(0),
+  fhKaond0ProngLcPt(0),
+  fhBKaond0ProngLcPt(0),
+  fhPionPtProngLcPt(0),
+  fhBPionPtProngLcPt(0),
+  fhPiond0ProngLcPt(0),
+  fhBPiond0ProngLcPt(0),
+  fhDist12PrimLcPt(0),
+  fhBDist12PrimLcPt(0),
+  fhSigmaVertLcPt(0),
+  fhBSigmaVertLcPt(0),
+  fhdcasLcPt(0),
+  fhBdcasLcPt(0),
+  fhCosPointingAngleLcPt(0),
+  fhBCosPointingAngleLcPt(0),
+  fhDecayLengthLcPt(0),
+  fhBDecayLengthLcPt(0),
+  fhSum2LcPt(0),
+  fhBSum2LcPt(0),
+  fhPtMaxLcPt(0),
+  fhBPtMaxLcPt(0),
   fNtupleLambdac(0),
   fUpmasslimit(2.486),
   fLowmasslimit(2.086),
@@ -173,6 +245,8 @@ AliAnalysisTaskSELambdac::AliAnalysisTaskSELambdac(const char *name,Bool_t fillN
   fFillVarHists(kFALSE),
   fMultiplicityHists(kFALSE),
   fPriorsHists(kFALSE),
+  fLcCut(kFALSE),
+  fLcPIDCut(kFALSE),
   fNentries(0),
   fOutputMC(0),
   fAPriori(0),
@@ -348,11 +422,11 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
 
   TString hisname;
   Int_t index=0;
-  Int_t indexLS=0;
+  //  Int_t indexLS=0;
   for(Int_t i=0;i<fNPtBins;i++){
 
     index=GetHistoIndex(i);
-    indexLS=GetLSHistoIndex(i);
+    //    indexLS=GetLSHistoIndex(i);
 
     hisname.Form("hMassPt%d",i);
     fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
@@ -423,6 +497,30 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
     fMassHist3PrTC[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
     fMassHist3PrTC[index]->Sumw2();
 
+    index=GetLbHistoIndex(i); 
+    hisname.Form("hSigLbPt%d",i);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]->Sumw2();
+    hisname.Form("hSigLbPt%dTC",i);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]->Sumw2();
+
+    index=GetcOnlyHistoIndex(i); 
+    hisname.Form("hSigcOnlyPt%d",i);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]->Sumw2();
+    hisname.Form("hSigcOnlyPt%dTC",i);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]->Sumw2();
+   
+    index=GetNoQuarkHistoIndex(i); 
+    hisname.Form("hSigNoQuarkPt%d",i);
+    fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHist[index]->Sumw2();
+    hisname.Form("hSigNoQuarkPt%dTC",i);
+    fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
+    fMassHistTC[index]->Sumw2();
+
     index=GetBackgroundHistoIndex(i); 
     hisname.Form("hBkgPt%d",i);
     fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),200,fLowmasslimit,fUpmasslimit);
@@ -459,9 +557,11 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
     fMassHist3PrTC[index]->Sumw2();
   }
   
+   for(Int_t ii=0; ii<6*fNPtBins; ii++){
+    fOutput->Add(fMassHist[ii]);
+    fOutput->Add(fMassHistTC[ii]);
+  }
   for(Int_t i=0; i<3*fNPtBins; i++){
-    fOutput->Add(fMassHist[i]);
-    fOutput->Add(fMassHistTC[i]);
     fOutput->Add(fMassHistLpi[i]);
     fOutput->Add(fMassHistLpiTC[i]);
     fOutput->Add(fMassHistKp[i]);
@@ -471,7 +571,31 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
     fOutput->Add(fMassHist3Pr[i]);
     fOutput->Add(fMassHist3PrTC[i]);
   }
-
+  fhEta3Prong          = new TH2F("hEta3Prong","hEta3Prong;3-Prong p_{T} GeV/c;3-Prong #eta",75,0.,15.,50,-2.0,2.0);
+  fhEta3ProngAcc       = new TH2F("hEta3ProngAcc","hEta3ProngAcc;3-Prong p_{T} GeV/c;3-Prong #eta",75,0.,15.,50,-2.0,2.0);
+  fhEta3ProngProd      = new TH2F("hEta3ProngProd","hEta3ProngProd;3-Prong p_{T} GeV/c;3-Prong #eta",75,0.,15.,50,-2.0,2.0);
+  fhEta3ProngAn            = new TH2F("hEta3ProngAn","hEta3ProngAn;3-Prong p_{T} GeV/c;3-Prong #eta",75,0.,15.,50,-2.0,2.0);
+  fhRap3Prong          = new TH2F("hRap3Prong","hRap3Prong;3-Prong p_{T} GeV/c;3-Prong y",75,0.,15.,50,-2.0,2.0);
+  fhRap3ProngAcc       = new TH2F("hRap3ProngAcc","hRap3ProngAcc;3-Prong p_{T} GeV/c;3-Prong y",75,0.,15.,50,-2.0,2.0);
+  fhRap3ProngProd      = new TH2F("hRap3ProngProd","hRap3ProngProd;3-Prong p_{T} GeV/c;3-Prong y",75,0.,15.,50,-2.0,2.0);
+  fhRap3ProngAn            = new TH2F("hRap3ProngAn","hRap3ProngAn;3-Prong p_{T} GeV/c;3-Prong y",75,0.,15.,50,-2.0,2.0);
+    
+  fhSelectBit                  = new TH1F("hSelectBit","hSelectBit",5,-0.5,5.5);
+  fhSelectBit->GetXaxis()->SetBinLabel(2,"All");
+  fhSelectBit->GetXaxis()->SetBinLabel(3,"SelectionMap");
+  fhSelectBit->GetXaxis()->SetBinLabel(4,"!LcCut");
+  fhSelectBit->GetXaxis()->SetBinLabel(5,"!LcPID");
+
+  fOutput->Add(fhEta3Prong);
+  fOutput->Add(fhEta3ProngAcc);
+  fOutput->Add(fhEta3ProngProd);
+  fOutput->Add(fhEta3ProngAn);
+  fOutput->Add(fhRap3Prong);
+  fOutput->Add(fhRap3ProngAcc);
+  fOutput->Add(fhRap3ProngProd);
+  fOutput->Add(fhRap3ProngAn);
+  fOutput->Add(fhSelectBit);
+  
   fHistNEvents = new TH1F("fHistNEvents", "Number of processed events; ; Events",3,-1.5,1.5);
   fHistNEvents->Sumw2();
   fHistNEvents->SetMinimum(0);
@@ -810,6 +934,32 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
   TH2F *hBpiSigmaVspTPC=new TH2F(hisname.Data(),hisname.Data(),100,0.,5.0,100,-10.0,10.0);
   fOutputMC->Add(hBpiSigmaVspTPC);
 
+  //Jaime Lc specific
+  hisname.Form("hLcRealTot");
+  TH1F *hLambdaRealTot=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hLambdaRealTot);
+  hisname.Form("hbLcRealTot");
+  TH1F *hbLambdaRealTot=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hbLambdaRealTot);
+  hisname.Form("hLcIDTot");
+  TH1F *hLambdaIDTot=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hLambdaIDTot);
+  hisname.Form("hbLcIDTot");
+  TH1F *hbLambdaIDTot=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hbLambdaIDTot);
+  hisname.Form("hLcIDGood");
+  TH1F *hLambdaIDGood=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hLambdaIDGood);
+  hisname.Form("hbLcIDGood");
+  TH1F *hbLambdaIDGood=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hbLambdaIDGood);
+  hisname.Form("hLcnoID");
+  TH1F *hLambdanoID=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hLambdanoID);
+  hisname.Form("hbLcnoID");
+  TH1F *hbLambdanoID=new TH1F(hisname.Data(),hisname.Data(),100,0.,15.0);
+  fOutputMC->Add(hbLambdanoID);
+  
   // other generic 
   hisname.Form("hLcpt");
   TH1F *hLcPt=new TH1F(hisname.Data(),hisname.Data(),100,0.,5.0);
@@ -866,7 +1016,97 @@ void AliAnalysisTaskSELambdac::UserCreateOutputObjects()
   TH1F *hBPtMax=new TH1F(hisname.Data(),hisname.Data(),100,0.,5.);
   fOutputMC->Add(hBPtMax);
 
-
+//2D Var x Lc Pt
+  hisname.Form("hpptProngLcPt");
+  fhProtonPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhProtonPtProngLcPt);
+  hisname.Form("hbpptProngLcPt");
+  fhBProtonPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhBProtonPtProngLcPt);
+  
+  hisname.Form("hpd0ProngLcPt");
+  fhProtond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,0.1);
+  fOutputMC->Add(fhProtond0ProngLcPt);
+  hisname.Form("hbpd0ProngLcPt");
+  fhBProtond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,0.1);
+  fOutputMC->Add(fhBProtond0ProngLcPt);
+  hisname.Form("hKptProngLcPt");
+  fhKaonPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhKaonPtProngLcPt);
+  hisname.Form("hbKptProngLcPt");
+  fhBKaonPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhBKaonPtProngLcPt);
+   
+  hisname.Form("hKd0ProngLcPt");
+  fhKaond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,0.1);
+  fOutputMC->Add(fhKaond0ProngLcPt);
+  hisname.Form("hbKd0ProngLcPt");
+  fhBKaond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,0.1);
+  fOutputMC->Add(fhBKaond0ProngLcPt);
+
+  hisname.Form("hpiptProngLcPt");
+  fhPionPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhPionPtProngLcPt);
+  hisname.Form("hbpiptProngLcPt");
+  fhBPionPtProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.0);
+  fOutputMC->Add(fhBPionPtProngLcPt);
+
+  hisname.Form("hpid0ProngLcPt");
+  fhPiond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,-0.1);
+  fOutputMC->Add(fhPiond0ProngLcPt);
+  hisname.Form("hbpid0ProngLcPt");
+  fhBPiond0ProngLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,-0.1,0.1);
+  fOutputMC->Add(fhBPiond0ProngLcPt);
+  hisname.Form("hDist12toPrimLcPt");
+  fhDist12PrimLcPt = new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,1.0);
+  fOutputMC->Add(fhDist12PrimLcPt);
+  hisname.Form("hbDist12toPrimLcPt");
+  fhBDist12PrimLcPt = new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,1.0);
+  fOutputMC->Add(fhBDist12PrimLcPt);
+
+  hisname.Form("hSigmaVertLcPt");
+  fhSigmaVertLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,60,0.,0.06);
+  fOutputMC->Add(fhSigmaVertLcPt);
+  hisname.Form("hbSigmaVertLcPt");
+  fhBSigmaVertLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,60,0.,0.06);
+  fOutputMC->Add(fhBSigmaVertLcPt);
+
+  hisname.Form("hDCAsLcPt");
+  fhdcasLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,200,0.,0.1);
+  fOutputMC->Add(fhdcasLcPt);
+  hisname.Form("hbDCAsLcPt");
+  fhBdcasLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,200,0.,0.1);
+  fOutputMC->Add(fhBdcasLcPt);
+  
+  hisname.Form("hCosPointingAngleLcPt");
+  fhCosPointingAngleLcPt = new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,40,0.,1.);
+  fOutputMC->Add(fhCosPointingAngleLcPt);
+  hisname.Form("hbCosPointingAngleLcPt");
+  fhBCosPointingAngleLcPt = new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,40,0.,1.);
+  fOutputMC->Add(fhBCosPointingAngleLcPt);
+
+  hisname.Form("hDecayLengthLcPt");
+  fhDecayLengthLcPt    = new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,0.1);
+  fOutputMC->Add(fhDecayLengthLcPt);
+  hisname.Form("hbDecayLengthLcPt");
+  fhBDecayLengthLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,0.1);
+  fOutputMC->Add(fhBDecayLengthLcPt);
+
+  hisname.Form("hSum2LcPt");
+  fhSum2LcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,0.1);
+  fOutputMC->Add(fhSum2LcPt);
+  hisname.Form("hbSum2LcPt");
+  fhBSum2LcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,0.1);
+  fOutputMC->Add(fhBSum2LcPt);
+
+  hisname.Form("hptmaxLcPt");
+  fhPtMaxLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.);
+  fOutputMC->Add(fhPtMaxLcPt);
+  hisname.Form("hbptmaxLcPt");
+  fhBPtMaxLcPt=new TH2F(hisname.Data(),hisname.Data(),75,0.,15.,100,0.,5.);
+  fOutputMC->Add(fhBPtMaxLcPt); 
 
   fAPriori = new TList(); // AdC
   fAPriori->SetOwner(); // AdC
@@ -1144,10 +1384,10 @@ void AliAnalysisTaskSELambdac::UserExec(Option_t */*option*/)
 
   if (fMultiplicityHists && fReadMC) {
     fillthis="hPrimariesvsAOD";
-    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNTracks(),numberOfPrimaries);
+    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNumberOfTracks(),numberOfPrimaries);
 
     fillthis="hAll2MultiplicityInEvent";
-    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNTracks());
+    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNumberOfTracks());
 
     fillthis="hAll2MultiplicityPrimaryInEvent";
     ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(numberOfPrimaries);
@@ -1177,10 +1417,9 @@ void AliAnalysisTaskSELambdac::UserExec(Option_t */*option*/)
   fCounter->StoreEvent(aod,fRDCutsProduction,fReadMC);
   TString trigclass=aod->GetFiredTriggerClasses();
   if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
-  Bool_t isEvSelAnCuts,isEvSelProdCuts;
-  isEvSelProdCuts=fRDCutsProduction->IsEventSelected(aod);
-  isEvSelAnCuts=fRDCutsAnalysis->IsEventSelected(aod);
-  if(!isEvSelProdCuts){
+  Bool_t isEvSelProdCuts=fRDCutsProduction->IsEventSelected(aod);
+  Bool_t isEvSelAnCuts=fRDCutsAnalysis->IsEventSelected(aod);
+  if(!isEvSelProdCuts || !isEvSelAnCuts){
     if(fRDCutsProduction->GetWhyRejection()==1) // rejected for pileup
       fNentries->Fill(13);
     return;
@@ -1207,16 +1446,27 @@ void AliAnalysisTaskSELambdac::UserExec(Option_t */*option*/)
       unsetvtx=kTRUE;
     }
 
-    //if(d->GetSelectionMap()) {if(!d->HasSelectionBit(AliRDHFCuts::kLcCuts)) continue;}
-    //if(d->GetSelectionMap()) {if(!d->HasSelectionBit(AliRDHFCuts::kLcPID)) continue;}
+    //Filter bit selection and QA:
+    fhSelectBit->Fill(1);
+    if(d->GetSelectionMap()){
+      fhSelectBit->Fill(2);
+      if(!d->HasSelectionBit(AliRDHFCuts::kLcCuts))  fhSelectBit->Fill(3);
+      if(!d->HasSelectionBit(AliRDHFCuts::kLcPID))   fhSelectBit->Fill(4);
+      if(fLcCut&&!d->HasSelectionBit(AliRDHFCuts::kLcCuts))            continue;
+      if(fLcPIDCut&&!d->HasSelectionBit(AliRDHFCuts::kLcPID))          continue;
+    }
 
     Int_t isSelectedTracks = fRDCutsProduction->IsSelected(d,AliRDHFCuts::kTracks,aod);
     if(!isSelectedTracks) continue;
-
+    fhEta3Prong->Fill(d->Pt(),d->Eta());
+    fhRap3Prong->Fill(d->Pt(),d->Y(4122));
+    
     isThereA3prongWithGoodTracks=kTRUE;
 
     if (fRDCutsProduction->IsInFiducialAcceptance(d->Pt(),d->Y(4122))) {fNentries->Fill(6);}else{continue;}
-
+    fhEta3ProngAcc->Fill(d->Pt(),d->Eta());
+    fhRap3ProngAcc->Fill(d->Pt(),d->Y(4122));
+    
     Int_t ptbin=fRDCutsProduction->PtBin(d->Pt());
     if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
 
@@ -1243,7 +1493,7 @@ void AliAnalysisTaskSELambdac::UserExec(Option_t */*option*/)
 
   if (fMultiplicityHists && fReadMC) {
     fillthis="hAllMultiplicityInEvent";
-    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNTracks());
+    ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(aod->GetNumberOfTracks());
 
     fillthis="hAllMultiplicityPrimaryInEvent";
     ((TH1I*)fMultiplicity->FindObject(fillthis))->Fill(numberOfPrimaries);
@@ -1329,14 +1579,14 @@ void AliAnalysisTaskSELambdac::Terminate(Option_t */*option*/)
 Int_t AliAnalysisTaskSELambdac::MatchToMCLambdac(AliAODRecoDecayHF3Prong *d,TClonesArray *arrayMC) const{
   // check if the candidate is a Lambdac decaying in pKpi or in the resonant channels
   Int_t lambdacLab[3]={0,0,0};
-  Int_t pdgs[3]={0,0,0};
+  //  Int_t pdgs[3]={0,0,0};
   for(Int_t i=0;i<3;i++){
     AliAODTrack *daugh=(AliAODTrack*)d->GetDaughter(i);
     Int_t lab=daugh->GetLabel();
     if(lab<0) return 0;
     AliAODMCParticle *part= (AliAODMCParticle*)arrayMC->At(lab);
     if(!part) continue;
-    pdgs[i]=part->GetPdgCode();
+    //    pdgs[i]=part->GetPdgCode();
     Int_t partPdgcode = TMath::Abs(part->GetPdgCode());
     if(partPdgcode==211 || partPdgcode==321 || partPdgcode==2212){
       Int_t motherLabel=part->GetMother();
@@ -1369,9 +1619,9 @@ Bool_t AliAnalysisTaskSELambdac::GetLambdacDaugh(AliAODMCParticle *part,TClonesA
   // check if the particle is a lambdac and if its decay mode is the correct one 
   Int_t numberOfLambdac=0;
   if(TMath::Abs(part->GetPdgCode())!=4122) return kFALSE;
-  Int_t daughTmp[2];
-  daughTmp[0]=part->GetDaughter(0);
-  daughTmp[1]=part->GetDaughter(1);
+  // Int_t daughTmp[2];
+  // daughTmp[0]=part->GetDaughter(0);
+  // daughTmp[1]=part->GetDaughter(1);
   Int_t nDaugh = (Int_t)part->GetNDaughters();
   if(nDaugh<2) return kFALSE;
   if(nDaugh>3) return kFALSE;
@@ -1586,7 +1836,7 @@ void AliAnalysisTaskSELambdac::FillMassHists(AliAODEvent *aod,AliAODRecoDecayHF3
 {
 
   //if MC PID or no PID, unset PID
-  if(!fRealPid) cuts->SetUsePID(kFALSE);
+  //if(!fRealPid) cuts->SetUsePID(kFALSE);
   Int_t selection=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);
   if(selection>0){
     nSelectedloose[0]=nSelectedloose[0]+1;
@@ -1609,10 +1859,20 @@ void AliAnalysisTaskSELambdac::FillMassHists(AliAODEvent *aod,AliAODRecoDecayHF3
     Float_t xDecay=0.;
     Float_t yDecay=0.;
     Float_t zDecay=0.;
+    //    Bool_t IsInjected   = -1; 
+    Bool_t IsLc                = 0;
+    Bool_t IsLcfromLb  = 0;
+    Bool_t IsLcfromc   = 0;
+    Bool_t IsLcFromq = 0;
 
     if(fReadMC){
+      //      AliAODMCHeader *mcHeader2 = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+      AliVertexingHFUtils *util = new AliVertexingHFUtils();
+      //      IsInjected = util->IsCandidateInjected(part,mcHeader2,arrayMC)?1:0;
+   
       labDp = MatchToMCLambdac(part,arrayMC);
       if(labDp>0){
+       IsLc = 1;
        AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
        AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
        AliAODMCParticle *dg1 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(1));
@@ -1626,10 +1886,17 @@ void AliAnalysisTaskSELambdac::FillMassHists(AliAODEvent *aod,AliAODRecoDecayHF3
        pdgCode=TMath::Abs(partDp->GetPdgCode());
        pdgCode1=TMath::Abs(dg0->GetPdgCode());
        pdgCode2=TMath::Abs(dg1->GetPdgCode());
-
+        Int_t pdgMom=util->CheckOrigin(arrayMC,partDp,kFALSE);
+          if(pdgMom == 5) IsLcfromLb =1;
+          if(pdgMom == 4) IsLcfromc =1; 
+        Int_t isThereaQuark=util->CheckOrigin(arrayMC,partDp,kTRUE);
+       if(isThereaQuark>0) IsLcFromq = 1;
+          
+       
       }else{
        pdgCode=-1;
       }
+      delete util;
     }
 
     Double_t invMasspKpi=-1.;
@@ -1696,33 +1963,39 @@ void AliAnalysisTaskSELambdac::FillMassHists(AliAODEvent *aod,AliAODRecoDecayHF3
    
     Int_t passTightCuts=0;
     if(fAnalysis) {
-     passTightCuts=fRDCutsAnalysis->IsSelected(part,AliRDHFCuts::kCandidate,aod);
-     if(fUseKF){
-      Int_t pdgs[3]={0,0,0};
-      if(invMasspKpi>0.){
-       pdgs[0]=2212;pdgs[1]=321;pdgs[2]=211;
-       if(!VertexingKF(part,pdgs,field)) {
-        invMasspKpi=-1.;
-       invMasspKpi3Pr=-1.;
-       invMasspKpiDk=-1.;
-       invMasspKpiLpi=-1.;
-       invMasspKpiKp=-1.;
-       }
+      passTightCuts=fRDCutsAnalysis->IsSelected(part,AliRDHFCuts::kCandidate,aod);
+      if(fUseKF){
+       Int_t pdgs[3]={0,0,0};
+       if(invMasspKpi>0.){
+         pdgs[0]=2212;pdgs[1]=321;pdgs[2]=211;
+         if(!VertexingKF(part,pdgs,field)) {
+           invMasspKpi=-1.;
+           invMasspKpi3Pr=-1.;
+           invMasspKpiDk=-1.;
+           invMasspKpiLpi=-1.;
+           invMasspKpiKp=-1.;
+         }
+       }
+       if(invMasspiKp>0.){
+         pdgs[0]=211;pdgs[1]=321;pdgs[2]=2212;
+         if(!VertexingKF(part,pdgs,field)) {
+           invMasspiKp=-1.;
+           invMasspiKp3Pr=-1.;
+           invMasspiKpDk=-1.;
+           invMasspiKpLpi=-1.;
+           invMasspiKpKp=-1.;
+         }
+       }
       }
-      if(invMasspiKp>0.){
-       pdgs[0]=211;pdgs[1]=321;pdgs[2]=2212;
-       if(!VertexingKF(part,pdgs,field)) {
-         invMasspiKp=-1.;
-         invMasspiKp3Pr=-1.;
-         invMasspiKpDk=-1.;
-         invMasspiKpLpi=-1.;
-         invMasspiKpKp=-1.;
-       }
-     }
-   }
-    if(passTightCuts>0) nSelectedtight[0]=nSelectedtight[0]+1;
-  }
-
+      if(passTightCuts>0) nSelectedtight[0]=nSelectedtight[0]+1;
+    }
+    // Eta and y plots:
+    fhEta3ProngProd->Fill(part->Pt(),part->Eta());
+    fhRap3ProngProd->Fill(part->Pt(),part->Y(4122));
+    if(passTightCuts>0){
+      fhEta3ProngAn->Fill(part->Pt(),part->Eta());
+      fhRap3ProngAn->Fill(part->Pt(),part->Y(4122));
+    }
     Float_t tmp[24];
     if (fFillNtuple) {
       tmp[0]=pdgCode;
@@ -2062,6 +2335,67 @@ void AliAnalysisTaskSELambdac::FillMassHists(AliAODEvent *aod,AliAODRecoDecayHF3
              if(invMasspKpi3Pr>0.&& passTightCuts==1) fMassHist3PrTC[index]->Fill(invMasspKpi3Pr);
            }
          }      
+    
+         if(IsLc && IsLcfromLb){
+          index=GetLbHistoIndex(iPtBin);
+          if(invMasspiKp>0. && invMasspKpi>0.){
+               if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp,0.5);
+               if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi,0.5);
+         }else{
+               if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp);
+               if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi);
+         } 
+          if(passTightCuts>0){         
+                if(invMasspiKp>0. && invMasspKpi>0. && passTightCuts==3){
+                       if(invMasspiKp>0.) fMassHistTC[index]->Fill(invMasspiKp,0.5);
+                               if(invMasspKpi>0.) fMassHistTC[index]->Fill(invMasspKpi,0.5);
+               }else{
+                       if(invMasspiKp>0. && passTightCuts==2) fMassHistTC[index]->Fill(invMasspiKp); 
+                        if(invMasspKpi>0.&& passTightCuts==1) fMassHistTC[index]->Fill(invMasspKpi);
+                }
+         }
+        }
+        if(IsLc && !IsLcfromLb && IsLcfromc)  {
+           index=GetcOnlyHistoIndex(iPtBin);
+           if(invMasspiKp>0. && invMasspKpi>0.){
+                       if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp,0.5);
+                       if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi,0.5);
+          }else{
+                           if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp);
+                           if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi);
+          } 
+           if(passTightCuts>0){
+              if(invMasspiKp>0. && invMasspKpi>0. && passTightCuts==3){
+              if(invMasspiKp>0.) fMassHistTC[index]->Fill(invMasspiKp,0.5);
+              if(invMasspKpi>0.) fMassHistTC[index]->Fill(invMasspKpi,0.5);
+           }else{
+               if(invMasspiKp>0. && passTightCuts==2) fMassHistTC[index]->Fill(invMasspiKp);
+               if(invMasspKpi>0.&& passTightCuts==1) fMassHistTC[index]->Fill(invMasspKpi);
+           }
+          }
+
+       }
+
+         if(IsLc && !IsLcFromq)  {
+           index=GetNoQuarkHistoIndex(iPtBin);
+           if(invMasspiKp>0. && invMasspKpi>0.){
+                       if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp,0.5);
+                       if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi,0.5);
+          }else{
+                           if(invMasspiKp>0.) fMassHist[index]->Fill(invMasspiKp);
+                           if(invMasspKpi>0.) fMassHist[index]->Fill(invMasspKpi);
+          } 
+           if(passTightCuts>0){
+              if(invMasspiKp>0. && invMasspKpi>0. && passTightCuts==3){
+              if(invMasspiKp>0.) fMassHistTC[index]->Fill(invMasspiKp,0.5);
+              if(invMasspKpi>0.) fMassHistTC[index]->Fill(invMasspKpi,0.5);
+           }else{
+               if(invMasspiKp>0. && passTightCuts==2) fMassHistTC[index]->Fill(invMasspiKp);
+               if(invMasspKpi>0.&& passTightCuts==1) fMassHistTC[index]->Fill(invMasspKpi);
+           }
+          }
+
+        }
      
        }else{
          index=GetBackgroundHistoIndex(iPtBin);
@@ -2159,10 +2493,23 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
 
   Int_t pdgDgLctopKpi[3]={2212,321,211};
   Int_t lab=-9999;
-  if(fReadMC)
+  //  Bool_t IsLcfromLb=0;
+  Bool_t IsLcfromc=0;
+  if(fReadMC){
     lab=part->MatchToMC(4122,arrMC,3,pdgDgLctopKpi); //return MC particle label if the array corresponds to a Lc, -1 if not (cf. AliAODRecoDecay.cxx)
-
-  Int_t isSelectedPID=cuts->IsSelectedPID(part); // 0 rejected, 1 Lc -> p K- pi+ (K at center because different sign is there),
+    if(lab>0){
+      AliAODMCParticle *partDp = (AliAODMCParticle*)arrMC->At(lab);
+      AliVertexingHFUtils *util = new AliVertexingHFUtils();
+      Int_t pdgMom=util->CheckOrigin(arrMC,partDp,kFALSE);
+      //      if(pdgMom == 5) IsLcfromLb =1;
+      if(pdgMom == 4) IsLcfromc =1; 
+      delete util;
+    }
+  }
+ // Int_t isSelectedPID=cuts->IsSelectedPID(part); // 0 rejected, 1 Lc -> p K- pi+ (K at center because different sign is there),
+                                                 // 2 Lc -> pi+ K- p (K at center because different sign is there),
+                                                 // 3 both (it should never happen...)
+  Int_t isSelectedPID=cuts->IsSelected(part,AliRDHFCuts::kPID,aod); // 0 rejected, 1 Lc -> p K- pi+ (K at center because different sign is there),
                                                  // 2 Lc -> pi+ K- p (K at center because different sign is there),
                                                  // 3 both (it should never happen...)
 
@@ -2182,6 +2529,7 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
   Double_t minvLcpKpi = part->InvMassLcpKpi();
   Double_t minvLcpiKp = part->InvMassLcpiKp();
 
+
   //check pdg of the prongs
   Int_t labprong[3]={-1,-1,-1};
   if(fReadMC){
@@ -2208,55 +2556,76 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
   }
 
   //fill hRealTot ---> PID efficiency denominators
-  cuts->SetUsePID(kFALSE); //PAOLA
-  Int_t selectionCandidate=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);//PAOLA
-  if(fReadMC && selectionCandidate>0) { // 3prongs candidate x Lc (no PID)
-    if(lab>0){ // Signal
+  //cuts->SetUsePID(kFALSE); //PAOLA
+  Int_t selectionTrack = cuts->IsSelected(part,AliRDHFCuts::kTracks,aod);
+  
+  //IsInjected check    
+  Bool_t IsInjected = 0;
+  if(fReadMC){
+    AliAODMCHeader *mcHeader2 = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+    AliVertexingHFUtils *util = new AliVertexingHFUtils();
+    IsInjected = util->IsCandidateInjected(part,mcHeader2,arrMC)?1:0;
+    delete util;
+  }
+  if(fReadMC && selectionTrack>0) { // 3prongs candidate x Lc (only track selection) Jaime
+    Int_t isReal=0;
+    if(lab>0 &&  IsLcfromc){ // Signal
       for (Int_t iprong=0; iprong<3; iprong++) {
        switch (pdgProngMC[iprong]) {
        case 2212:
          fillthis="hpRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        case 321:
          fillthis="hKRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        case 211:
          fillthis="hpiRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        default:
          break;
        }
       }
-    } else { // bkg
+       fillthis="hLcRealTot";
+       if(isReal==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
+    //Marcel: Should we zero isReal
+    } else if(!IsInjected) { // bkg  // bkg
       for (Int_t iprong=0; iprong<3; iprong++) {
        switch (pdgProngMC[iprong]) {
        case 2212:
          fillthis="hbpRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        case 321:
          fillthis="hbKRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        case 211:
          fillthis="hbpiRealTot";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+         isReal++;
          break;
        default:
          break;
        }
       }
+    fillthis="hbLcRealTot";
+       if(isReal==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt()); 
     }
   }
 
 
-  cuts->SetUsePID(kTRUE); //PAOLA
+  //cuts->SetUsePID(kTRUE); //PAOLA
   Int_t selection=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);
 
-  if ( (lab>0 && fReadMC) ||             // signal X MC
+  if ( (lab>0 && fReadMC && IsLcfromc) ||             // signal X MC
        (isSelectedPID>0 && !fReadMC) ) { // signal+bkg X real data
 
     fillthis="hMass";
@@ -2278,7 +2647,8 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
     if (selection>0) { // 3prongs candidate x Lc (yes PID)
 
       Double_t ptmax=0.;
-
+      Int_t isID=0;
+      Int_t isCorrect=0;
       for (Int_t iprong=0; iprong<3; iprong++) {
        if (part->PtProng(iprong)>ptmax) ptmax=part->PtProng(iprong);
 
@@ -2307,8 +2677,12 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
          fillthis="hpptProng";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+          fillthis="hpptProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->PtProng(iprong));
          fillthis="hpd0Prong";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+          fillthis="hpd0ProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
          fillthis="hpSignalVspTPC";
          ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
          fillthis="hpSignalVspTOF";
@@ -2332,9 +2706,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                         //      hIDGood, hnoID ---> PID numerators
            fillthis="hpIDTot";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+           isID++;
            if(pdgProngMC[iprong]==2212) { // id protons
              fillthis="hpIDGood";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isCorrect++;  
            }
            else { // misidentified electrons, muons, pions and kaons
              fillthis="hnopIDp";
@@ -2350,8 +2726,12 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
          fillthis="hKptProng";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+          fillthis="hKptProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->PtProng(iprong));
          fillthis="hKd0Prong";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+          fillthis="hKd0ProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
          fillthis="hKSignalVspTPC";
          ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
          fillthis="hKSignalVspTOF";
@@ -2375,9 +2755,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                         //      hIDGood, hnoID ---> PID numerators
            fillthis="hKIDTot";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+           isID++;
            if(pdgProngMC[iprong]==321) { // id kaons
              fillthis="hKIDGood";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isCorrect++;
            }
            else { // misidentified electrons, muons, pions and protons
              fillthis="hnokIDk";
@@ -2393,8 +2775,13 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
          fillthis="hpiptProng";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+          fillthis="hpiptProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->PtProng(iprong));
          fillthis="hpid0Prong";
          ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+          fillthis="hpid0ProngLcPt";
+         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
+          
          fillthis="hpiSignalVspTPC";
          ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
          fillthis="hpiSignalVspTOF";
@@ -2418,9 +2805,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                         //      hIDGood, hnoID ---> PID numerators
            fillthis="hpiIDTot";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+           isID++;
            if(pdgProngMC[iprong]==211) { // id pions
              fillthis="hpiIDGood";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isCorrect++;
            }
            else { // misidentified electrons, muons, kaons and protons
              fillthis="hnopiIDpi";
@@ -2433,35 +2822,59 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
          break;
        }
 
-      } //end loop on prongs
+      }//end loop on prongs
+
+      //Jaime Lc checks
+      fillthis="hLcIDTot";
+      if(isID==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
+      fillthis="hLcIDGood";
+      if(isCorrect==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
+      fillthis="hLcnoID";
+      if(isCorrect<3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
 
       //now histograms where we don't need to check identity
+      fillthis="hLcpt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
       fillthis = "hDist12toPrim";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetDist12toPrim());
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetDist23toPrim());
+      fillthis = "hDist12toPrimLcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetDist12toPrim());
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetDist23toPrim());
       fillthis = "hSigmaVert";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetSigmaVert());
+      fillthis = "hSigmaVertLcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetSigmaVert());
       fillthis = "hDCAs";
       Double_t dcas[3];
       part->GetDCAs(dcas);
       for (Int_t idca=0;idca<3;idca++) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dcas[idca]);
+      fillthis = "hDCAsLcPt";
+      for (Int_t idca=0;idca<3;idca++) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),dcas[idca]);
       fillthis = "hCosPointingAngle";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->CosPointingAngle());
+      fillthis = "hCosPointingAngleLcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->CosPointingAngle());
       fillthis = "hDecayLength";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->DecayLength());
+      fillthis = "hDecayLengthLcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->DecayLength());
       Double_t sum2=part->Getd0Prong(0)*part->Getd0Prong(0)+
        part->Getd0Prong(1)*part->Getd0Prong(1)+
        part->Getd0Prong(2)*part->Getd0Prong(2);
       fillthis = "hSum2";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(sum2);
+      fillthis = "hSum2LcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),sum2);
       fillthis = "hptmax";
       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(ptmax);
-      fillthis="hLcpt";
-      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
+      fillthis = "hptmaxLcPt";
+      ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),ptmax);
+
 
     } // end if (selection)
 
-  } else if( lab<=0 && fReadMC) { // bkg x MC
+  }else if( lab<=0 && fReadMC && !IsInjected ) { // bkg x MC
 
     fillthis="hbMass";
 
@@ -2485,6 +2898,8 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
       if (selection>0) { // 3prongs candidate x Lc (yes PID)
 
        Double_t ptmax=0.;
+       Int_t isID=0;
+       Int_t isCorrect=0;
        for (Int_t iprong=0; iprong<3; iprong++) {
          if(part->PtProng(iprong)>ptmax)ptmax=part->PtProng(iprong);
 
@@ -2514,8 +2929,12 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
            fillthis="hbpptProng";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+            fillthis="hbpptProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->PtProng(iprong));
            fillthis="hbpd0Prong";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+            fillthis="hbpd0ProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
            fillthis="hbpSignalVspTPC";
            ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
            fillthis="hbpSignalVspTOF";
@@ -2538,9 +2957,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                         //      hbIDGood, hbnoID ---> PID numerators
              fillthis="hbpIDTot";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isID++;
              if(pdgProngMC[iprong]==2212) { // id protons
                fillthis="hbpIDGood";
                ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+               isCorrect++;
              }
              else { // misidentified electrons, muons, pions and kaons
                fillthis="hbnopIDp";
@@ -2556,8 +2977,12 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
            fillthis="hbKptProng";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+            fillthis="hbKptProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->PtProng(iprong));
            fillthis="hbKd0Prong";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+            fillthis="hbKd0ProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
            fillthis="hbKSignalVspTPC";
            ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
            fillthis="hbKSignalVspTOF";
@@ -2580,9 +3005,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                           //      hIDGood, hnoID ---> PID numerators
              fillthis="hbKIDTot";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isID++;
              if(pdgProngMC[iprong]==321) { // id kaons
                fillthis="hbKIDGood";
                ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+               isCorrect++;
              }
              else { // misidentified electrons, muons, pions and protons
                fillthis="hbnokIDk";
@@ -2598,8 +3025,12 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dedxTPC);
            fillthis="hbpiptProng";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+           fillthis="hbpiptProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
            fillthis="hbpid0Prong";
            ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Getd0Prong(iprong));
+            fillthis="hbpid0ProngLcPt";
+           ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->Getd0Prong(iprong));
            fillthis="hbpiSignalVspTPC";
            ((TH2F*)fOutputMC->FindObject(fillthis))->Fill(momTPC,dedxTPC);
            fillthis="hbpiSignalVspTOF";
@@ -2622,9 +3053,11 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
                           //      hIDGood, hnonIDTot ---> PID numerators
              fillthis="hbpiIDTot";
              ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+             isID++;
              if(pdgProngMC[iprong]==211) { // id pions
                fillthis="hbpiIDGood";
                ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->PtProng(iprong));
+               isCorrect++;
              }
              else { // misidentified electrons, muons, kaons and protons
                fillthis="hbnopiIDpi";
@@ -2638,32 +3071,53 @@ void AliAnalysisTaskSELambdac::FillVarHists(AliAODRecoDecayHF3Prong *part,
          }
 
        } //end loop on prongs
+       
+       fillthis="hbLcIDTot";
+       if(isID==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt()); 
+       fillthis="hbLcIDGood";
+       if(isCorrect==3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
+       fillthis="hbLcnoID";
+       if(isCorrect<3) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
 
        //now histograms where we don't need to check identity
        fillthis="hbLcpt";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt());
-
+       
        fillthis = "hbDist12toPrim";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetDist12toPrim());
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetDist23toPrim());
+       fillthis = "hbDist12toPrimLcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetDist12toPrim());
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetDist23toPrim());
        fillthis = "hbSigmaVert";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->GetSigmaVert());
+       fillthis = "hbSigmaVertLcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->GetSigmaVert());
        fillthis = "hbDCAs";
        Double_t dcas[3];
        part->GetDCAs(dcas);
-       for (Int_t idca=0;idca<3;idca++)
-         ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dcas[idca]);
+       for (Int_t idca=0;idca<3;idca++) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(dcas[idca]);
+       fillthis = "hbDCAsLcPt";
+       for (Int_t idca=0;idca<3;idca++) ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),dcas[idca]);
        fillthis = "hbCosPointingAngle";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->CosPointingAngle());
+       fillthis = "hbCosPointingAngleLcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->CosPointingAngle());
        fillthis = "hbDecayLength";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->DecayLength());
+       fillthis = "hbDecayLengthLcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),part->DecayLength());
        Double_t sum2=part->Getd0Prong(0)*part->Getd0Prong(0)+
-         part->Getd0Prong(1)*part->Getd0Prong(1)+
-         part->Getd0Prong(2)*part->Getd0Prong(2);
+       part->Getd0Prong(1)*part->Getd0Prong(1)+
+       part->Getd0Prong(2)*part->Getd0Prong(2);
        fillthis = "hbSum2";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(sum2);
+       fillthis = "hbSum2LcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),sum2);
        fillthis = "hbptmax";
        ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(ptmax);
+       fillthis = "hbptmaxLcPt";
+       ((TH1F*)fOutputMC->FindObject(fillthis))->Fill(part->Pt(),ptmax);
 
       } // end if (selection)
 
@@ -2683,7 +3137,7 @@ void AliAnalysisTaskSELambdac::FillAPrioriConcentrations(AliAODRecoDecayHF3Prong
 {
 
   // FillAPrioriConcentrations
-  cuts->SetUsePID(kFALSE); //Annalisa
+  //cuts->SetUsePID(kFALSE); //Annalisa
   Int_t isSelected3ProngByLc=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);
 
   TString fillthis="";
@@ -2724,7 +3178,7 @@ void AliAnalysisTaskSELambdac::FillAPrioriConcentrations(AliAODRecoDecayHF3Prong
     }
   }
 
-  cuts->SetUsePID(kTRUE); //Annalisa
+  //cuts->SetUsePID(kTRUE); //Annalisa
 
 }
 
@@ -2849,7 +3303,7 @@ Int_t AliAnalysisTaskSELambdac::NumberPrimaries(const AliAODEvent *aods)
   
   TClonesArray *aodtracks=(TClonesArray *)aods->GetTracks();
  
-  // for(Int_t ji=0;ji<aods->GetNTracks();ji++)
+  // for(Int_t ji=0;ji<aods->GetNumberOfTracks();ji++)
   for(Int_t ji=0;ji<aodtracks->GetEntriesFast();ji++)
     {
       AliAODTrack*aodTrack=(AliAODTrack*)aodtracks->UncheckedAt(ji);
@@ -2878,7 +3332,7 @@ void AliAnalysisTaskSELambdac::MultiplicityStudies(AliAODRecoDecayHF3Prong *part
   if(fReadMC)
     lab=part->MatchToMC(4122,arrMC,3,pdgDgLctopKpi); //return MC particle label if the array corresponds to a Lc, -1 if not (cf. AliAODRecoDecay.cxx)
 
-  cuts->SetUsePID(kFALSE); //Annalisa
+  //cuts->SetUsePID(kFALSE); //Annalisa
   Int_t isSelected3ProngByLc=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);
 
   if(isSelected3ProngByLc>0 && fReadMC) {
@@ -3148,7 +3602,7 @@ void AliAnalysisTaskSELambdac::MultiplicityStudies(AliAODRecoDecayHF3Prong *part
   Double_t minvLcpKpi = part->InvMassLcpKpi();
   Double_t minvLcpiKp = part->InvMassLcpiKp();
 
-  cuts->SetUsePID(kTRUE); //Annalisa
+  //cuts->SetUsePID(kTRUE); //Annalisa
   Int_t isSelected3ProngByLcPID=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod);
   if (isSelected3ProngByLcPID>0) {
     if (TMath::Abs(minvLcpKpi-mPDG)<invmasscut || TMath::Abs(minvLcpiKp-mPDG)<invmasscut) {