]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDcheckESD.cxx
trigger names changed (Markus)
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDcheckESD.cxx
index f1e8f32ec17ebc59a03011b04c94586af4ebe752..2f47c744400177aad2831eb8eefc04dfea788f2a 100644 (file)
 //////////////////////////////////////////////////////
 
 #include <TClonesArray.h>
+#include <TCanvas.h>
 #include <TObjArray.h>
 #include <TPad.h>
 #include <TLegend.h>
+#include <TLatex.h>
+#include <TLine.h>
 #include <TF1.h>
 #include <TH2I.h>
+#include <TH2F.h>
 #include <TH3S.h>
+#include <TH3F.h>
+#include <TProfile2D.h>
+#include <TProfile.h>
 #include <TGraphErrors.h>
 #include <TGraphAsymmErrors.h>
 #include <TFile.h>
@@ -40,6 +47,7 @@
 #include <TROOT.h>
 #include <TChain.h>
 #include <TParticle.h>
+#include <TTimeStamp.h>
 
 #include "AliLog.h"
 #include "AliAnalysisManager.h"
@@ -48,6 +56,7 @@
 #include "AliMCEvent.h"
 #include "AliESDInputHandler.h"
 #include "AliMCEventHandler.h"
+#include "AliESDpid.h"
 
 #include "AliESDtrack.h"
 #include "AliMCParticle.h"
@@ -62,9 +71,18 @@ ClassImp(AliTRDcheckESD)
 const Float_t AliTRDcheckESD::fgkxTPC = 290.;
 const Float_t AliTRDcheckESD::fgkxTOF = 365.;
 const UChar_t AliTRDcheckESD::fgkNgraph[AliTRDcheckESD::kNrefs] ={
-0, 4, 2, 10};
+8, 4, 2, 20};
 FILE* AliTRDcheckESD::fgFile = NULL;
 
+const Float_t AliTRDcheckESD::fgkEvVertexZ = 15.;
+const Int_t   AliTRDcheckESD::fgkEvVertexN = 1;
+const Float_t AliTRDcheckESD::fgkTrkDCAxy  = 40.;
+const Float_t AliTRDcheckESD::fgkTrkDCAz   = 15.;
+const Int_t   AliTRDcheckESD::fgkNclTPC    = 100;
+const Float_t AliTRDcheckESD::fgkPt        = 0.2;
+const Float_t AliTRDcheckESD::fgkEta       = 0.9;
+const Float_t AliTRDcheckESD::fgkQs        = 0.002;
+
 //____________________________________________________________________
 AliTRDcheckESD::AliTRDcheckESD():
   AliAnalysisTaskSE()
@@ -72,13 +90,14 @@ AliTRDcheckESD::AliTRDcheckESD():
   ,fNRefFigures(0)
   ,fESD(NULL)
   ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
   ,fHistos(NULL)
   ,fResults(NULL)
 {
   //
   // Default constructor
   //
-  SetNameTitle("checkESD", "Check TRD @ ESD level");
+  SetNameTitle("TRDcheckESD", "Check TRD @ ESD level");
   SetMC(kTRUE);
 }
 
@@ -89,6 +108,7 @@ AliTRDcheckESD::AliTRDcheckESD(char* name):
   ,fNRefFigures(0)
   ,fESD(NULL)
   ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
   ,fHistos(NULL)
   ,fResults(NULL)
 {
@@ -120,15 +140,32 @@ void AliTRDcheckESD::UserCreateOutputObjects()
   //
   // Create Output Containers (TObjectArray containing 1D histograms)
   //
-  //OpenFile(0, "RECREATE");  
-
   Histos();
+  PostData(1, fHistos);
 }
 
+//____________________________________________________________________
+void AliTRDcheckESD::MakeSummary(){
+  //
+  // Draw summary plots for the ESDcheck task
+  //
+  TCanvas *cOut = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  GetRefFigure(4);
+  cOut->SaveAs("trackingSummary.gif");
+
+  cOut = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  GetRefFigure(5);
+  cOut->SaveAs("pidSummary.gif");
+}
 
 //____________________________________________________________________
 Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
 {
+  //
+  // Produce reference Plots during PostProcessing
+  //
   if(ifig>=fNRefFigures){
     AliWarning(Form("Ref plot %d not available. Valid only up to %d", ifig, fNRefFigures));
     return kFALSE;
@@ -136,30 +173,66 @@ Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
   if(!gPad){
     AliWarning("Please provide a canvas to draw results.");
     return kFALSE;
+  } else {
+    gPad->SetLogx(0);gPad->SetLogy(0);
+    gPad->SetMargin(0.125, 0.015, 0.1, 0.015);
   }
 
   const Char_t *title[20];
+  Float_t nada(0.0);
   TH1 *hF(NULL);
+  TH1 *hFeffP(NULL); TH1 *hFeffN(NULL);
+  TH2 *h2F(NULL); TH2 *h2Feff(NULL);
+  TH2 *h2FtpcP(NULL); TH2 *h2FtpcN(NULL);
+  TH2 *h2FtrdP(NULL); TH2 *h2FtrdN(NULL);
+  TH3 *h3F(NULL);
   if((hF=(TH1S*)gROOT->FindObject("hFcheckESD"))) delete hF;
   TLegend *leg(NULL);
+  TList *l(NULL); TVirtualPad *pad(NULL);
   TGraphErrors *g(NULL);TGraphAsymmErrors *ga(NULL);
   TObjArray *arr(NULL);
+  TProfile2D *hProf2D(NULL);
+  TProfile *hProf(NULL);
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  TLine line;
+  TTimeStamp now;
+  TF1* fitFunc(NULL);
   switch(ifig){
   case kNCl: // number of clusters/track
-    ((TH1I*)fResults->At(kNCl))->Draw("c");
+    if(!(arr = (TObjArray*)fResults->At(kNCl))) return kFALSE;
+
+    leg = new TLegend(.83, .7, .99, .96);
+    leg->SetHeader("Species");
+    leg->SetBorderSize(0); leg->SetFillStyle(0);
+    for(Int_t ig(0); ig<fgkNgraph[kNCl]; ig++){
+      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;
+      if(!g->GetN()) continue;
+      g->Draw(ig?"pc":"apc"); leg->AddEntry(g, g->GetTitle(), "pl");
+      if(ig) continue;
+      hF=g->GetHistogram();
+      hF->SetXTitle("no of clusters");
+      hF->SetYTitle("entries"); 
+      hF->GetYaxis()->CenterTitle(1);
+      hF->GetYaxis()->SetTitleOffset(1.2);
+      hF->SetMinimum(5);
+    }
+    leg->Draw(); gPad->SetLogy();
     break;
   case kTRDstat: // Efficiency
     if(!(arr = (TObjArray*)fResults->At(kTRDstat))) return kFALSE;
-    leg = new TLegend(.65, .7, .95, .99);
+    leg = new TLegend(.62, .77, .98, .98);
     leg->SetHeader("TRD Efficiency");
-    leg->SetBorderSize(1); leg->SetFillColor(0);
+    leg->SetBorderSize(0); leg->SetFillStyle(0);
     title[0] = "Geometrical (TRDin/TPCout)";
     title[1] = "Tracking (TRDout/TRDin)";
     title[2] = "PID (TRDpid/TRDin)";
     title[3] = "Refit (TRDrefit/TRDin)";
     hF = new TH1S("hFcheckESD", ";p [GeV/c];Efficiency", 10, 0.1, 10.);
-    hF->SetMaximum(1.3);
+    hF->SetMaximum(1.4);
     hF->GetXaxis()->SetMoreLogLabels();
+    hF->GetYaxis()->CenterTitle(1);
     hF->Draw("p");
     for(Int_t ig(0); ig<fgkNgraph[kTRDstat]; ig++){
       if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;
@@ -189,23 +262,40 @@ Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
     break;
   case kPtRes: // Pt resolution @ vertex
     if(!(arr = (TObjArray*)fResults->At(kPtRes))) return kFALSE;
-    gPad->SetMargin(0.1, 0.22, 0.1, 0.023);
+    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
+    pad = ((TVirtualPad*)l->At(0)); pad->cd(); pad->SetLogx();
+    pad->SetMargin(0.1, 0.022, 0.1, 0.023);
+    hF = new TH1S("hFcheckESD", "ITS+TPC+TRD;p_{t} [GeV/c];#Delta p_{t} / p_{t} [%]", 10, 0.2, 10.);
+    hF->SetMaximum(10.);hF->SetMinimum(-3.);
+    hF->GetXaxis()->SetMoreLogLabels();
+    hF->GetXaxis()->SetTitleOffset(1.2);
+    hF->GetYaxis()->CenterTitle();
+    hF->Draw("p");
+    //for(Int_t ig(0); ig<fgkNgraph[kPtRes]/2; ig++){
+    for(Int_t ig(2); ig<6; ig++){
+      if(!(g = (TGraphErrors*)arr->At(ig))) continue;
+      if(!g->GetN()) continue;
+      g->Draw("pl");
+      //PutTrendValue(name[id], g->GetMean(2));
+      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));
+    }
+    pad = ((TVirtualPad*)l->At(1)); pad->cd(); pad->SetLogx();
+    pad->SetMargin(0.1, 0.22, 0.1, 0.023);
+    hF = (TH1*)hF->Clone("hFcheckESD1");
+    hF->SetTitle("ITS+TPC");
+    hF->SetMaximum(10.);hF->SetMinimum(-3.);
+    hF->Draw("p");
     leg = new TLegend(.78, .1, .99, .98);
     leg->SetHeader("P_{t} @ DCA");
     leg->SetBorderSize(1); leg->SetFillColor(0);
     leg->SetTextAlign(22);
     leg->SetTextFont(12);
     leg->SetTextSize(0.03813559);
-    hF = new TH1S("hFcheckESD", ";p_{t} [GeV/c];#Delta p_{t} / p_{t} [%]", 10, 0.2, 10.);
-    hF->SetMaximum(10.);hF->SetMinimum(-3.);
-    hF->GetXaxis()->SetMoreLogLabels();
-    hF->GetXaxis()->SetTitleOffset(1.2);
-    hF->GetYaxis()->CenterTitle();
-    hF->Draw("p");
     {
       Int_t nPlots(0);
-      for(Int_t ig(0); ig<fgkNgraph[kPtRes]; ig++){
-        if(!(g = (TGraphErrors*)arr->At(ig))) continue;//return kFALSE;
+      //for(Int_t ig(fgkNgraph[kPtRes]/2); ig<fgkNgraph[kPtRes]; ig++){
+      for(Int_t ig(12); ig<16; ig++){
+        if(!(g = (TGraphErrors*)arr->At(ig))) continue;
         if(!g->GetN()) continue;
         nPlots++;
         g->Draw("pl"); leg->AddEntry(g, g->GetTitle(), "pl");
@@ -214,8 +304,454 @@ Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
       }
       if(nPlots) leg->Draw();
     }
-    gPad->SetLogx();
     break;
+  case 4:            // plot a 3x3 canvas with tracking related histograms
+    gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+    gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+    gPad->Divide(3,3,0.,0.);
+    l=gPad->GetListOfPrimitives();
+    // eta-phi distr. for positive TPC tracks
+    pad = ((TVirtualPad*)l->At(0)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE); 
+    h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos));
+    h2FtpcP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtpcP->SetStats(kFALSE);
+    h2FtpcP->GetXaxis()->SetTitle("#eta");
+    h2FtpcP->GetXaxis()->CenterTitle();
+    h2FtpcP->GetXaxis()->SetTitleSize(0.07);
+    h2FtpcP->GetXaxis()->SetTitleOffset(0.8);
+    h2FtpcP->GetXaxis()->SetLabelSize(0.05);
+    h2FtpcP->GetYaxis()->SetTitle("detector #varphi");
+    h2FtpcP->GetYaxis()->CenterTitle();
+    h2FtpcP->GetYaxis()->SetTitleSize(0.07);
+    h2FtpcP->GetYaxis()->SetTitleOffset(0.8);
+    h2FtpcP->GetYaxis()->SetLabelSize(0.05);
+    h2FtpcP->SetTitle("");
+    h2FtpcP->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TPC positive ref. tracks");
+    //-----------------
+    // eta-phi distr. for negative TPC tracks
+    pad = ((TVirtualPad*)l->At(1)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg));
+    h2FtpcN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtpcN->SetStats(kFALSE);
+    h2FtpcN->GetXaxis()->SetTitle("#eta");
+    h2FtpcN->GetXaxis()->CenterTitle();
+    h2FtpcN->GetXaxis()->SetTitleSize(0.07);
+    h2FtpcN->GetXaxis()->SetTitleOffset(0.8);
+    h2FtpcN->GetXaxis()->SetLabelSize(0.05);
+    h2FtpcN->GetYaxis()->SetTitle("detector #varphi");
+    h2FtpcN->GetYaxis()->CenterTitle();
+    h2FtpcN->GetYaxis()->SetTitleSize(0.07);
+    h2FtpcN->GetYaxis()->SetTitleOffset(0.8);
+    h2FtpcN->GetYaxis()->SetLabelSize(0.05);
+    h2FtpcN->SetTitle("");
+    h2FtpcN->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TPC negative ref. tracks");
+    // eta-phi distr. for positive TRD tracks
+    pad = ((TVirtualPad*)l->At(3)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos));
+    h2FtrdP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtrdP->SetStats(kFALSE);
+    h2FtrdP->GetXaxis()->SetTitle("#eta");
+    h2FtrdP->GetXaxis()->CenterTitle();
+    h2FtrdP->GetXaxis()->SetTitleSize(0.07);
+    h2FtrdP->GetXaxis()->SetTitleOffset(0.8);
+    h2FtrdP->GetXaxis()->SetLabelSize(0.05);
+    h2FtrdP->GetYaxis()->SetTitle("detector #varphi");
+    h2FtrdP->GetYaxis()->CenterTitle();
+    h2FtrdP->GetYaxis()->SetTitleSize(0.07);
+    h2FtrdP->GetYaxis()->SetTitleOffset(0.8);
+    h2FtrdP->GetYaxis()->SetLabelSize(0.05);
+    h2FtrdP->SetMaximum(h2FtpcP->GetMaximum());
+    h2FtrdP->SetTitle("");
+    h2FtrdP->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD positive ref. tracks");
+    //-----------------
+    // eta-phi distr. for negative TRD tracks
+    pad = ((TVirtualPad*)l->At(4)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg));
+    h2FtrdN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtrdN->SetStats(kFALSE);
+    h2FtrdN->GetXaxis()->SetTitle("#eta");
+    h2FtrdN->GetXaxis()->CenterTitle();
+    h2FtrdN->GetXaxis()->SetTitleSize(0.07);
+    h2FtrdN->GetXaxis()->SetTitleOffset(0.8);
+    h2FtrdN->GetXaxis()->SetLabelSize(0.05);
+    h2FtrdN->GetYaxis()->SetTitle("detector #varphi");
+    h2FtrdN->GetYaxis()->CenterTitle();
+    h2FtrdN->GetYaxis()->SetTitleSize(0.07);
+    h2FtrdN->GetYaxis()->SetTitleOffset(0.8);
+    h2FtrdN->GetYaxis()->SetLabelSize(0.05);
+    h2FtrdN->SetMaximum(h2FtpcN->GetMaximum());
+    h2FtrdN->SetTitle("");
+    h2FtrdN->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD negative ref. tracks");
+    // eta-phi efficiency for positive TRD tracks
+    pad = ((TVirtualPad*)l->At(6)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h2Feff = (TH2F*)h2FtrdP->Clone();
+    h2Feff->Reset();
+    h2Feff->SetStats(kFALSE);
+    h2Feff->Divide(h2FtrdP, h2FtpcP);
+    h2Feff->GetXaxis()->SetTitle("#eta");
+    h2Feff->GetXaxis()->CenterTitle();
+    h2Feff->GetXaxis()->SetTitleSize(0.07);
+    h2Feff->GetXaxis()->SetTitleOffset(0.8);
+    h2Feff->GetXaxis()->SetLabelSize(0.05);
+    h2Feff->GetYaxis()->SetTitle("detector #varphi");
+    h2Feff->GetYaxis()->CenterTitle();
+    h2Feff->GetYaxis()->SetTitleSize(0.07);
+    h2Feff->GetYaxis()->SetTitleOffset(0.8);
+    h2Feff->GetYaxis()->SetLabelSize(0.05);
+    h2Feff->SetMaximum(1.0);
+    h2Feff->SetTitle("");
+    h2Feff->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "Efficiency positive tracks");
+    // eta-phi efficiency for negative TRD tracks
+    pad = ((TVirtualPad*)l->At(7)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h2Feff = (TH2F*)h2FtrdN->Clone();
+    h2Feff->Reset();
+    h2Feff->SetStats(kFALSE);
+    h2Feff->Divide(h2FtrdN, h2FtpcN);
+    h2Feff->GetXaxis()->SetTitle("#eta");
+    h2Feff->GetXaxis()->CenterTitle();
+    h2Feff->GetXaxis()->SetTitleSize(0.07);
+    h2Feff->GetXaxis()->SetTitleOffset(0.8);
+    h2Feff->GetXaxis()->SetLabelSize(0.05);
+    h2Feff->GetYaxis()->SetTitle("detector #varphi");
+    h2Feff->GetYaxis()->CenterTitle();
+    h2Feff->GetYaxis()->SetTitleSize(0.07);
+    h2Feff->GetYaxis()->SetTitleOffset(0.8);
+    h2Feff->GetYaxis()->SetLabelSize(0.05);
+    h2Feff->SetMaximum(1.0);
+    h2Feff->SetTitle("");
+    h2Feff->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "Efficiency negative tracks");
+    
+    // <ntracklets> vs (phi,eta)
+    pad = ((TVirtualPad*)l->At(2)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvNtrkl));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(6.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");
+    // TPC-TRD matching efficiency vs pt
+    pad = ((TVirtualPad*)l->At(5)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+    pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hFeffP = EfficiencyTRD(1);
+    hFeffN = EfficiencyTRD(-1);
+    h2F=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.1);
+    h2F->SetStats(kFALSE);
+    h2F->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+    h2F->GetXaxis()->SetTitleOffset(0.8); 
+    h2F->GetXaxis()->SetTitleSize(0.07);
+    h2F->GetXaxis()->CenterTitle();
+    h2F->GetXaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->SetTitle("TRD-TPC matching efficiency");
+    h2F->GetYaxis()->SetTitleOffset(0.8); 
+    h2F->GetYaxis()->SetTitleSize(0.07);
+    h2F->GetYaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->CenterTitle();
+    h2F->Draw();
+    line.SetLineStyle(2);
+    line.SetLineWidth(2);
+    line.DrawLine(h2F->GetXaxis()->GetXmin(), 0.7, h2F->GetXaxis()->GetXmax(), 0.7);
+    line.DrawLine(h2F->GetXaxis()->GetXmin(), 0.9, h2F->GetXaxis()->GetXmax(), 0.9);
+    hFeffP->SetMarkerStyle(20);
+    hFeffP->SetMarkerColor(2);
+    hFeffN->SetMarkerStyle(22);
+    hFeffN->SetMarkerColor(4);
+    hFeffP->Draw("same");
+    hFeffN->Draw("same");
+    leg=new TLegend(0.65, 0.2, 0.95, 0.4);
+    leg->SetFillColor(0);
+    leg->AddEntry(hFeffP, "positives", "p");
+    leg->AddEntry(hFeffN, "negatives", "p");
+    leg->Draw();
+    // create trending values for the TPC-TRD matching efficiency
+    // fit the efficiency histos with a constant in the range [1.0,1.5] GeV/c
+    fitFunc = new TF1("constantFunc","[0]",1.0,1.5);
+    hFeffP->Fit(fitFunc,"Q0","",1.0,1.5);
+    PutTrendValue("TrackingEffPos1GeV", fitFunc->GetParameter(0));
+    PutTrendValue("TrackingEffPos1GeVErr", fitFunc->GetParError(0));
+    hFeffN->Fit(fitFunc,"Q0","",1.0,1.5);
+    PutTrendValue("TrackingEffNeg1GeV", fitFunc->GetParameter(0));
+    PutTrendValue("TrackingEffNeg1GeVErr", fitFunc->GetParError(0));
+    // Nclusters per TRD track
+    pad = ((TVirtualPad*)l->At(8)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);
+    pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    pad->SetLogz();
+    h2F = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD));
+    h2F->SetStats(kFALSE);
+    h2F->SetTitle("");
+    h2F->GetXaxis()->SetTitle("p [GeV/c]");
+    h2F->GetXaxis()->SetTitleOffset(0.8); 
+    h2F->GetXaxis()->SetTitleSize(0.07);
+    h2F->GetXaxis()->CenterTitle();
+    h2F->GetXaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->SetTitle("#clusters per TRD track");
+    h2F->GetYaxis()->SetTitleOffset(0.8); 
+    h2F->GetYaxis()->SetTitleSize(0.07);
+    h2F->GetYaxis()->CenterTitle();
+    h2F->GetYaxis()->SetLabelSize(0.05);
+    h2F->Draw("colz");
+    break;
+  case 5:            // plot a 3x3 canvas with PID related histograms
+    gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+    gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+    gPad->Divide(3,3,0.,0.);
+    l=gPad->GetListOfPrimitives();
+    // eta-phi distr. for <Qtot> in layer 0
+    pad = ((TVirtualPad*)l->At(0)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+0));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 0");
+    // eta-phi distr. for <Qtot> in layer 1
+    pad = ((TVirtualPad*)l->At(3)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+1));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 1");
+    // eta-phi distr. for <Qtot> in layer 2
+    pad = ((TVirtualPad*)l->At(6)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+2));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 2");
+    // eta-phi distr. for <Qtot> in layer 3
+    pad = ((TVirtualPad*)l->At(1)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+3));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 3");
+    // eta-phi distr. for <Qtot> in layer 4
+    pad = ((TVirtualPad*)l->At(4)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+4));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 4");
+    // eta-phi distr. for <Qtot> in layer 5
+    pad = ((TVirtualPad*)l->At(7)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+5));
+    hProf2D->SetStats(kFALSE);
+    hProf2D->SetTitle("");
+    hProf2D->GetXaxis()->SetTitle("#eta");
+    hProf2D->GetXaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetXaxis()->SetTitleSize(0.07);
+    hProf2D->GetXaxis()->CenterTitle();
+    hProf2D->GetXaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->SetTitle("detector #varphi");
+    hProf2D->GetYaxis()->SetTitleOffset(0.8); 
+    hProf2D->GetYaxis()->SetTitleSize(0.07);
+    hProf2D->GetYaxis()->SetLabelSize(0.05);
+    hProf2D->GetYaxis()->CenterTitle();
+    hProf2D->SetMinimum(0.);
+    hProf2D->SetMaximum(25.);
+    hProf2D->Draw("colz");
+    lat->DrawLatex(-0.9, 3.6, "TRD <Q_{tot}> Layer 5");
+    // PH versus slice number
+    pad = ((TVirtualPad*)l->At(2)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h2F = dynamic_cast<TH2F*>(fHistos->At(kPHSlice));
+    hF = Proj2D((TH2F*)h2F);
+    h2F->SetStats(kFALSE);
+    h2F->SetTitle("");
+    h2F->GetXaxis()->SetTitle("slice");
+    h2F->GetXaxis()->SetTitleOffset(0.8); 
+    h2F->GetXaxis()->SetTitleSize(0.07);
+    h2F->GetXaxis()->CenterTitle();
+    h2F->GetXaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->SetTitle("PH");
+    h2F->GetYaxis()->SetTitleOffset(0.8); 
+    h2F->GetYaxis()->SetTitleSize(0.07);
+    h2F->GetYaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->CenterTitle();
+    h2F->Draw("colz");
+    hF->SetLineWidth(2);
+    hF->Draw("same");
+    // Qtot vs P
+    pad = ((TVirtualPad*)l->At(5)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    pad->SetLogz();
+    h2F = dynamic_cast<TH2F*>(fHistos->At(kQtotP));
+    h2F->SetStats(kFALSE);
+    h2F->SetTitle("");
+    h2F->GetXaxis()->SetTitle("P [GeV/c]");
+    h2F->GetXaxis()->SetTitleOffset(0.8); 
+    h2F->GetXaxis()->SetTitleSize(0.07);
+    h2F->GetXaxis()->CenterTitle();
+    h2F->GetXaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->SetRangeUser(0.0,100.0);
+    h2F->GetYaxis()->SetTitle("Q_{tot}");
+    h2F->GetYaxis()->SetTitleOffset(0.8); 
+    h2F->GetYaxis()->SetTitleSize(0.07);
+    h2F->GetYaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->CenterTitle();
+    h2F->Draw("colz");
+    // create trending value for the average Qtot at 1 GeV/c
+    hProf = h2F->ProfileX("profileQtot",1,h2F->GetYaxis()->FindBin(40.));
+    PutTrendValue("AvQtot1GeV", hProf->GetBinContent(hProf->GetXaxis()->FindBin(1.)));
+    PutTrendValue("AvQtot1GeVErr", hProf->GetBinError(hProf->GetXaxis()->FindBin(1.)));
+    // PH versus slice number for TPC pions and electrons
+    pad = ((TVirtualPad*)l->At(8)); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    h2FtrdP = dynamic_cast<TH2F*>(fHistos->At(kPHSliceTPCpions));
+    h2FtrdN = dynamic_cast<TH2F*>(fHistos->At(kPHSliceTPCelectrons));
+    hFeffP = Proj2D((TH2F*)h2FtrdP);
+    hFeffN = Proj2D((TH2F*)h2FtrdN);
+    h2F = new TH2F("PHvsSlice","",10,h2FtrdN->GetXaxis()->GetXmin(),h2FtrdN->GetXaxis()->GetXmax(),
+                  10,h2FtrdN->GetYaxis()->GetXmin(),h2FtrdN->GetYaxis()->GetXmax());
+    h2F->SetStats(kFALSE);
+    h2F->SetTitle("");
+    h2F->GetXaxis()->SetTitle("slice");
+    h2F->GetXaxis()->SetTitleOffset(0.8); 
+    h2F->GetXaxis()->SetTitleSize(0.07);
+    h2F->GetXaxis()->CenterTitle();
+    h2F->GetXaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->SetTitle("PH");
+    h2F->GetYaxis()->SetTitleOffset(0.8); 
+    h2F->GetYaxis()->SetTitleSize(0.07);
+    h2F->GetYaxis()->SetLabelSize(0.05);
+    h2F->GetYaxis()->CenterTitle();
+    h2F->Draw();
+    hFeffN->SetLineWidth(2);
+    hFeffN->SetLineColor(2);
+    hFeffP->SetLineWidth(2);
+    hFeffP->SetLineColor(4);
+    hFeffN->Draw("same");
+    hFeffP->Draw("same");
+    leg=new TLegend(0.65, 0.8, 0.95, 0.95);
+    leg->SetFillColor(0);
+    leg->AddEntry(hFeffP, "TPC pions", "l");
+    leg->AddEntry(hFeffN, "TPC electrons", "l");
+    leg->Draw();
+    break;    
   }
   return kTRUE;
 }
@@ -246,7 +782,20 @@ void AliTRDcheckESD::UserExec(Option_t *){
       }
     }
   }
-  TH2 *h(NULL);
+  TH1 *h(NULL);
+  
+  // fill event vertex histos
+  h = (TH1F*)fHistos->At(kTPCVertex);
+  if(fESD->GetPrimaryVertexTPC()) h->Fill(fESD->GetPrimaryVertexTPC()->GetZv());
+  h = (TH1F*)fHistos->At(kEventVertex);
+  if(fESD->GetPrimaryVertex()) h->Fill(fESD->GetPrimaryVertex()->GetZv());
+  // fill the uncutted number of tracks
+  h = (TH1I*)fHistos->At(kNTracksAll);
+  h->Fill(fESD->GetNumberOfTracks());
+  
+  // counters for number of tracks in acceptance&DCA and for those with a minimum of TPC clusters
+  Int_t nTracksAcc=0;
+  Int_t nTracksTPC=0;
   
   AliESDtrack *esdTrack(NULL);
   for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){
@@ -254,19 +803,190 @@ void AliTRDcheckESD::UserExec(Option_t *){
 
     // track status
     ULong_t status = esdTrack->GetStatus(); //PrintStatus(status);
-    if(!Bool_t(status & AliESDtrack::kTPCout)) continue;
-    if(esdTrack->GetKinkIndex(0) > 0) continue;
 
-    //Int_t nTPC(esdTrack->GetNcls(1));
+    // track selection
+    Bool_t selected(kTRUE);
+    if(esdTrack->Pt() < fgkPt){ 
+      AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Pt[%5.2f]", fESD->GetEventNumberInFile(), itrk, esdTrack->Pt()));
+      selected = kFALSE;
+    }
+    if(TMath::Abs(esdTrack->Eta()) > fgkEta){
+      AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Eta[%5.2f]", fESD->GetEventNumberInFile(), itrk, TMath::Abs(esdTrack->Eta())));
+      selected = kFALSE;
+    }
+    if(!Bool_t(status & AliESDtrack::kTPCout)){
+      AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] !TPCout", fESD->GetEventNumberInFile(), itrk));
+      selected = kFALSE;
+    }
+    if(esdTrack->GetKinkIndex(0) > 0){
+      AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Kink", fESD->GetEventNumberInFile(), itrk));
+      selected = kFALSE;
+    }
+    
+    Float_t par[2], cov[3];
+    esdTrack->GetImpactParameters(par, cov);
+    if(selected && esdTrack->GetTPCNcls()>=10) {
+      // fill DCA histograms
+      h = (TH1F*)fHistos->At(kDCAxy); h->Fill(par[0]);
+      h = (TH1F*)fHistos->At(kDCAz); h->Fill(par[1]);
+      // fill pt distribution at this stage
+      h = (TH1F*)fHistos->At(kPt1); h->Fill(esdTrack->Pt());
+    }
+    if(IsCollision()){ // cuts on DCA
+      if(TMath::Abs(par[0]) > fgkTrkDCAxy){ 
+        AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAxy[%f]", fESD->GetEventNumberInFile(), itrk, TMath::Abs(par[0])));
+        selected = kFALSE;
+      }
+      if(TMath::Abs(par[1]) > fgkTrkDCAz){ 
+        AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAz[%f]", fESD->GetEventNumberInFile(), itrk, TMath::Abs(par[1])));
+        selected = kFALSE;
+      }
+    }
+    Float_t theta=esdTrack->Theta();
+    Float_t phi=esdTrack->Phi();
+    Int_t nClustersTPC = esdTrack->GetTPCNcls();
+    Float_t eta=esdTrack->Eta();
+    if(selected) {
+      nTracksAcc++;   // number of tracks in acceptance and DCA cut
+      // fill pt distribution at this stage
+      h = (TH1F*)fHistos->At(kPt2); h->Fill(esdTrack->Pt());
+      // TPC nclusters distribution
+      h = (TH1I*)fHistos->At(kNTPCCl); h->Fill(nClustersTPC);
+      if(esdTrack->Pt()>1.0) {
+        h = (TH1I*)fHistos->At(kNTPCCl2); h->Fill(nClustersTPC);
+      }
+      // (eta,nclustersTPC) distrib of TPC ref. tracks
+      h = (TH2F*)fHistos->At(kEtaNclsTPC); h->Fill(eta, nClustersTPC);
+      // (phi,nclustersTPC) distrib of TPC ref. tracks
+      h = (TH2F*)fHistos->At(kPhiNclsTPC); h->Fill(phi, nClustersTPC);
+      
+    }
+      
+    if(nClustersTPC < fgkNclTPC){ 
+      AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] NclTPC[%d]", fESD->GetEventNumberInFile(), itrk, nClustersTPC));
+      selected = kFALSE;
+    }
+    if(!selected) continue;
+    
+    // number of TPC reference tracks
+    nTracksTPC++;
+    
     Int_t nTRD(esdTrack->GetNcls(2));
     Double_t pt(esdTrack->Pt());
-    //Double_t eta(esdTrack->Eta());
-    //Double_t phi(esdTrack->Phi());
     Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p);
     // pid quality
-    //esdTrack->GetTRDntrackletsPID();
     Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin);
 
+    TH3F *hhh(NULL);
+    // find position and momentum of the track at entrance in TRD
+    Double_t localCoord[3] = {0., 0., 0.};
+    Bool_t localCoordGood = esdTrack->GetXYZAt(298., fESD->GetMagneticField(), localCoord);
+    if(localCoordGood) {
+      hhh = (TH3F*)fHistos->At(kPropagXYvsP); hhh->Fill(localCoord[0], localCoord[1], esdTrack->GetP());
+      hhh = (TH3F*)fHistos->At(kPropagRZvsP); hhh->Fill(localCoord[2], TMath::Sqrt(localCoord[0]*localCoord[0]+localCoord[1]*localCoord[1]), esdTrack->GetP());
+    }
+    Double_t localMom[3] = {0., 0., 0.};
+    Bool_t localMomGood = esdTrack->GetPxPyPzAt(298., fESD->GetMagneticField(), localMom);
+    Double_t localPhi = (localMomGood ? TMath::ATan2(localMom[1], localMom[0]) : 0.0);
+    Double_t localSagitaPhi = (localCoordGood ? TMath::ATan2(localCoord[1], localCoord[0]) : 0.0);
+
+    // fill pt distribution at this stage
+    if(esdTrack->Charge()>0) {
+      h = (TH1F*)fHistos->At(kPt3pos); h->Fill(pt);
+      // fill eta-phi map of TPC positive ref. tracks
+      if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
+        hhh = (TH3F*)fHistos->At(kTPCRefTracksPos); hhh->Fill(eta, localSagitaPhi, pt);
+      }
+    }
+    if(esdTrack->Charge()<0) {
+      h = (TH1F*)fHistos->At(kPt3neg); h->Fill(pt);
+      // fill eta-phi map of TPC negative ref. tracks
+      if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
+        hhh = (TH3F*)fHistos->At(kTPCRefTracksNeg); hhh->Fill(eta, localSagitaPhi, pt);
+      }
+    }
+    // TPC dE/dx vs P
+    h = (TH2F*)fHistos->At(kTPCDedx); h->Fill(esdTrack->GetP(), esdTrack->GetTPCsignal());
+    // (eta,phi) distrib of TPC ref. tracks
+    h = (TH2F*)fHistos->At(kEtaPhi); h->Fill(eta, phi);
+        
+    Int_t nTRDtrkl = esdTrack->GetTRDntracklets();
+    // TRD reference tracks
+    if(nTRDtrkl>=1) {
+      // fill pt distribution at this stage
+      if(esdTrack->Charge()>0) {
+        h = (TH1F*)fHistos->At(kPt4pos); h->Fill(pt);
+       // fill eta-phi map of TRD positive ref. tracks
+       if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
+          hhh = (TH3F*)fHistos->At(kTRDRefTracksPos); hhh->Fill(eta, localSagitaPhi, pt);
+        }
+      }
+      if(esdTrack->Charge()<0) {
+        h = (TH1F*)fHistos->At(kPt4neg); h->Fill(pt);
+       // fill eta-phi map of TRD negative ref. tracks
+       if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
+          hhh = (TH3F*)fHistos->At(kTRDRefTracksNeg); hhh->Fill(eta, localSagitaPhi, pt);
+        }
+      }
+      TProfile2D *h2d;
+      // fill eta-phi map of TRD negative ref. tracks
+      if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
+        h2d = (TProfile2D*)fHistos->At(kTRDEtaPhiAvNtrkl); h2d->Fill(eta, localSagitaPhi, (Float_t)nTRDtrkl);
+       h2d = (TProfile2D*)fHistos->At(kTRDEtaDeltaPhiAvNtrkl); h2d->Fill(eta, localPhi-localSagitaPhi, (Float_t)nTRDtrkl);
+      }
+      // ntracklets/track vs P
+      h = (TH2F*)fHistos->At(kNTrackletsTRD); h->Fill(esdTrack->GetP(), nTRDtrkl);
+      // ntracklets/track vs P
+      h = (TH2F*)fHistos->At(kNClsTrackTRD); h->Fill(esdTrack->GetP(), esdTrack->GetTRDncls());
+      // TPC pid ------------------------------------------------
+      Double_t pionSigmas = fESDpid->NumberOfSigmasTPC(esdTrack,AliPID::kPion);
+      Double_t protonSigmas = fESDpid->NumberOfSigmasTPC(esdTrack,AliPID::kProton);
+      Double_t kaonSigmas = fESDpid->NumberOfSigmasTPC(esdTrack,AliPID::kKaon);
+      Double_t electronSigmas = fESDpid->NumberOfSigmasTPC(esdTrack,AliPID::kElectron);
+      Bool_t isTPCElectron = (TMath::Abs(electronSigmas)<2.0 && 
+                             TMath::Abs(pionSigmas)>3.0 && 
+                             TMath::Abs(kaonSigmas)>3.0 &&
+                             TMath::Abs(protonSigmas)>3.0 &&
+                             nClustersTPC>120 && 
+                              esdTrack->GetP()>2.0 ? kTRUE : kFALSE);
+      Bool_t isTPCPion = (TMath::Abs(pionSigmas)<2.0 &&
+                         TMath::Abs(kaonSigmas)>3.0 &&
+                         TMath::Abs(protonSigmas)>3.0 && 
+                         esdTrack->GetP() > 2.0 ? kTRUE : kFALSE);
+      // --------------------------------------------------------
+      // (slicePH,sliceNo) distribution and Qtot from slices
+      for(Int_t iPlane=0; iPlane<6; iPlane++) {
+        Float_t qtot=0;
+        for(Int_t iSlice=0; iSlice<8; iSlice++) {
+         if(esdTrack->GetTRDslice(iPlane, iSlice)>20.) {
+           h = (TH2F*)fHistos->At(kPHSlice); h->Fill(iSlice, esdTrack->GetTRDslice(iPlane, iSlice));
+           if(isTPCElectron) {
+             h = (TH2F*)fHistos->At(kPHSliceTPCelectrons); h->Fill(iSlice, esdTrack->GetTRDslice(iPlane, iSlice));
+             h = (TH2F*)fHistos->At(kTPCdedxElectrons); h->Fill(esdTrack->GetP(), esdTrack->GetTPCsignal());
+           }
+           if(isTPCPion) {
+             h = (TH2F*)fHistos->At(kPHSliceTPCpions); h->Fill(iSlice, esdTrack->GetTRDslice(iPlane, iSlice));
+             h = (TH2F*)fHistos->At(kTPCdedxPions); h->Fill(esdTrack->GetP(), esdTrack->GetTPCsignal());
+           }
+           qtot += esdTrack->GetTRDslice(iPlane, iSlice);
+         }
+        }
+        // Qtot>100 to avoid noise
+        if(qtot>100.) {
+          h = (TH2F*)fHistos->At(kQtotP); h->Fill(esdTrack->GetTRDmomentum(iPlane), fgkQs*qtot);
+       }
+       // Qtot>100 to avoid noise
+       // fgkQs*Qtot<40. so that the average will give a value close to the peak
+       if(localCoordGood && localMomGood && qtot>100. && fgkQs*qtot<40.) {
+         h2d = (TProfile2D*)fHistos->At(kTRDEtaPhiAvQtot+iPlane);
+         h2d->Fill(eta, localSagitaPhi, fgkQs*qtot);
+       }
+      }
+      // theta distribution
+      h = (TH1F*)fHistos->At(kTheta); h->Fill(theta);
+      h = (TH1F*)fHistos->At(kPhi); h->Fill(phi);
+    }  // end if nTRDtrkl>=1
+    
     // look at external track param
     const AliExternalTrackParam *op = esdTrack->GetOuterParam();
     const AliExternalTrackParam *ip = esdTrack->GetInnerParam();
@@ -324,27 +1044,25 @@ void AliTRDcheckESD::UserExec(Option_t *){
         ptTRD=ip->Pt();
         kFOUND=kTRUE;
       }
-    }
+    }     // end if(HasMC())
 
     if(kFOUND){
       h = (TH2I*)fHistos->At(kTRDstat);
       if(status & AliESDtrack::kTPCout) h->Fill(ptTRD, kTPCout);
       if(status & AliESDtrack::kTRDin) h->Fill(ptTRD, kTRDin);
-      if(kBarrel && (status & AliESDtrack::kTRDout)){ 
-        ((TH1*)fHistos->At(kNCl))->Fill(nTRD);
-        h->Fill(ptTRD, kTRDout);
-      }
+      if(kBarrel && (status & AliESDtrack::kTRDout)) h->Fill(ptTRD, kTRDout);
       if(kBarrel && (status & AliESDtrack::kTRDpid)) h->Fill(ptTRD, kTRDpid);
       if(kBarrel && (status & AliESDtrack::kTRDrefit)) h->Fill(ptTRD, kTRDref);
     }
-    if(HasMC() && 
-      kBarrel && kPhysPrim &&
-      TMath::Abs(eta0) < 0.9 &&
-      (status & AliESDtrack::kTRDrefit)) {
+    Int_t idx(HasMC() ? Pdg2Idx(TMath::Abs(mcParticle->PdgCode())): 0)
+         ,sgn(esdTrack->Charge()<0?0:1);
+    if(kBarrel && kPhysPrim) {
       TH3 *h3 = (TH3S*)fHistos->At(kPtRes);
-      Int_t sgn = mcParticle->Charge()>0?1:-1;
-      h3->Fill(pt0, 1.e2*(pt/pt0-1.), sgn*Pdg2Idx(TMath::Abs(mcParticle->PdgCode())));
+      Int_t offset = (status & AliESDtrack::kTRDrefit) ? 0 : 10; 
+      h3->Fill(pt0, 1.e2*(pt/pt0-1.), 
+        offset + 2*idx + sgn);
     }
+    ((TH1*)fHistos->At(kNCl))->Fill(nTRD, 2*idx + sgn);
     if(ip){
       h = (TH2I*)fHistos->At(kTRDmom);
       Float_t pTRD(0.);
@@ -353,8 +1071,13 @@ void AliTRDcheckESD::UserExec(Option_t *){
         h->Fill(ip->GetP()-pTRD, ily);
       }
     }
-  }  
-  PostData(1, fHistos);
+  }  // end loop over tracks
+  
+  // fill the number of tracks histograms
+  h = (TH1I*)fHistos->At(kNTracksAcc);
+  h->Fill(nTracksAcc);
+  h = (TH1I*)fHistos->At(kNTracksTPC);
+  h->Fill(nTracksTPC);
 }
 
 //____________________________________________________________________
@@ -369,18 +1092,27 @@ TObjArray* AliTRDcheckESD::Histos()
 
   TH1 *h = NULL;
 
-  // clusters per tracklet
-  if(!(h = (TH1I*)gROOT->FindObject("hNCl"))){
-    h = new TH1I("hNCl", "Clusters per TRD track;N_{cl}^{TRD};entries", 100, 0., 200.);
+  // clusters per track
+  const Int_t kNpt(30);
+  Float_t pt(0.2);
+  Float_t binsPt[kNpt+1];
+  for(Int_t i=0;i<kNpt+1; i++,pt+=(TMath::Exp(i*i*.001)-1.)) binsPt[i]=pt;
+  if(!(h = (TH2S*)gROOT->FindObject("hNCl"))){
+    h = new TH2S("hNCl", "Clusters per TRD track;N_{cl}^{TRD};SPECIES;entries", 60, 0., 180., 10, -0.5, 9.5);
+    TAxis *ay(h->GetYaxis());
+    ay->SetLabelOffset(0.015);
+    for(Int_t i(0); i<AliPID::kSPECIES; i++){
+      ay->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));
+      ay->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));
+    }
   } else h->Reset();
   fHistos->AddAt(h, kNCl); fNRefFigures++;
 
   // status bits histogram
-  const Int_t kNpt(10), kNbits(5);
-  Float_t Pt(0.1), Bits(.5);
-  Float_t binsPt[kNpt+1], binsBits[kNbits+1];
-  for(Int_t i=0;i<kNpt+1; i++,Pt+=(TMath::Exp(i*i*.015)-1.)) binsPt[i]=Pt;
-  for(Int_t i=0; i<kNbits+1; i++,Bits+=1.) binsBits[i]=Bits;
+  const Int_t kNbits(5);
+  Float_t bits(.5);
+  Float_t binsBits[kNbits+1];
+  for(Int_t i=0; i<kNbits+1; i++,bits+=1.) binsBits[i]=bits;
   if(!(h = (TH2I*)gROOT->FindObject("hTRDstat"))){
     h = new TH2I("hTRDstat", "TRD status bits;p_{t} @ TRD [GeV/c];status;entries", kNpt, binsPt, kNbits, binsBits);
     TAxis *ay(h->GetYaxis());
@@ -397,44 +1129,320 @@ TObjArray* AliTRDcheckESD::Histos()
     h = new TH2I("hTRDmom", "TRD energy loss;p_{inner} - p_{ly} [GeV/c];ly;entries", 100, -1., 2., 6, -0.5, 5.5);
   } else h->Reset();
   fHistos->AddAt(h, kTRDmom);
-  if(!HasMC()) return fHistos;
+  //if(!HasMC()) return fHistos;
 
   // pt resolution
-  const Int_t kNdpt(100), kNspec(2*AliPID::kSPECIES+1);
-  Float_t DPt(-3.), Spec(-AliPID::kSPECIES-0.5);
+  const Int_t kNdpt(100), kNspec(4*AliPID::kSPECIES);
+  Float_t dpt(-3.), spec(-0.5);
   Float_t binsDPt[kNdpt+1], binsSpec[kNspec+1];
-  for(Int_t i=0; i<kNdpt+1; i++,DPt+=6.e-2) binsDPt[i]=DPt;
-  for(Int_t i=0; i<kNspec+1; i++,Spec+=1.) binsSpec[i]=Spec;
+  for(Int_t i=0; i<kNdpt+1; i++,dpt+=6.e-2) binsDPt[i]=dpt;
+  for(Int_t i=0; i<kNspec+1; i++,spec+=1.) binsSpec[i]=spec;
   if(!(h = (TH3S*)gROOT->FindObject("hPtRes"))){
     h = new TH3S("hPtRes", "P_{t} resolution @ DCA;p_{t}^{MC} [GeV/c];#Delta p_{t}/p_{t}^{MC} [%];SPECIES", kNpt, binsPt, kNdpt, binsDPt, kNspec, binsSpec);
     TAxis *az(h->GetZaxis());
+    az->SetLabelOffset(0.015);
     for(Int_t i(0); i<AliPID::kSPECIES; i++){
-      az->SetBinLabel(5-i, AliPID::ParticleLatexName(i));
-      az->SetBinLabel(7+i, AliPID::ParticleLatexName(i));
+      az->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));
+      az->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));
+      az->SetBinLabel(10+2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));
+      az->SetBinLabel(10+2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));
     }
   } else h->Reset();
   fHistos->AddAt(h, kPtRes);
 
+  // TPC event vertex distribution
+  if(!(h = (TH1F*)gROOT->FindObject("hTPCVertex"))){
+    h = new TH1F("hTPCVertex", "Event vertex Z coord. from TPC tracks", 100, -25., 25.);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCVertex);
+  
+  // Event vertex
+  if(!(h = (TH1F*)gROOT->FindObject("hEventVertex"))){
+    h = new TH1F("hEventVertex", "Event vertex Z coord.", 100, -25., 25.);
+  } else h->Reset();
+  fHistos->AddAt(h, kEventVertex);
+  
+  // Number of all tracks
+  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAll"))){
+    h = new TH1I("hNTracksAll", "Number of tracks per event, event vertex cuts", 5000, 0, 5000);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTracksAll);
+  
+  // Number of tracks in acceptance and DCA cut
+  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAcc"))){
+    h = new TH1I("hNTracksAcc", Form("Number of tracks per event, |#eta|<%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",
+                                    fgkEta, fgkTrkDCAxy, fgkTrkDCAz), 5000, 0, 5000);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTracksAcc);
+  
+  // Number of tracks in TPC (Ncls>10)
+  if(!(h = (TH1I*)gROOT->FindObject("hNTracksTPC"))){
+    h = new TH1I("hNTracksTPC", Form("Number of tracks per event, |#eta|<%.1f, pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                    fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 5000, 0, 5000);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTracksTPC);
+  
+  // Distribution of DCA-xy
+  if(!(h = (TH1F*)gROOT->FindObject("hDCAxy"))){
+    h = new TH1F("hDCAxy", "Distribution of transverse DCA", 100, -100., 100.);
+  } else h->Reset();
+  fHistos->AddAt(h, kDCAxy);
+  
+  // Distribution of DCA-z
+  if(!(h = (TH1F*)gROOT->FindObject("hDCAz"))){
+    h = new TH1F("hDCAz", "Distribution of longitudinal DCA", 100, -100., 100.);
+  } else h->Reset();
+  fHistos->AddAt(h, kDCAz);
+  
+  Float_t binPtLimits[33] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
+                            1.0, 1.1, 1.2, 1.3, 1.4, 
+                            1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0,
+                            3.4, 3.8, 4.2, 4.6, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
+  // Pt distributions
+  if(!(h = (TH1F*)gROOT->FindObject("hPt1"))){
+    h = new TH1F("hPt1", Form("dN/dpt, |#eta|<%.1f and pt>%.1f", fgkEta, fgkPt), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt1);
+  
+  if(!(h = (TH1F*)gROOT->FindObject("hPt2"))){
+    h = new TH1F("hPt2", Form("dN/dpt, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",
+                             fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt2);
+  
+  if(!(h = (TH1F*)gROOT->FindObject("hPt3pos"))){
+    h = new TH1F("hPt3pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt3pos);
+  
+  if(!(h = (TH1F*)gROOT->FindObject("hPt3neg"))){
+    h = new TH1F("hPt3neg", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt3neg);
+  
+  if(!(h = (TH1F*)gROOT->FindObject("hPt4pos"))){
+    h = new TH1F("hPt4pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt4pos);
+  
+  if(!(h = (TH1F*)gROOT->FindObject("hPt4neg"))){
+    h = new TH1F("hPt4pos", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kPt4neg);
+  
+  // theta distribution of TRD tracks
+  if(!(h = (TH1F*)gROOT->FindObject("hTheta"))){
+    h = new TH1F("hTheta", Form("dN/d#theta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 220,.5,2.7);
+  } else h->Reset();
+  fHistos->AddAt(h, kTheta);
+  
+  // phi distribution of TRD tracks
+  if(!(h = (TH1F*)gROOT->FindObject("hPhi"))){
+    h = new TH1F("hPhi", Form("dN/d#varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 157,0,6.28);
+  } else h->Reset();
+  fHistos->AddAt(h, kPhi);
+  
+  // TPC cluster distribution
+  if(!(h = (TH1F*)gROOT->FindObject("hNTPCCl"))){
+    h = new TH1I("hNTPCCl", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTPCCl);
+  
+  if(!(h = (TH1I*)gROOT->FindObject("hNTPCCl2"))){
+    h = new TH1F("hNTPCCl2", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, pt>1.0 GeV/c",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTPCCl2);
+  
+  // dE/dx vs P for TPC reference tracks
+  if(!(h = (TH2F*)gROOT->FindObject("hTPCDedx"))){
+    h = new TH2F("hTPCDedx", Form("TPC dE/dx vs P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 120, 0,600.);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCDedx);
+  
+  // eta,phi distribution of TPC reference tracks
+  if(!(h = (TH2F*)gROOT->FindObject("hEtaPhi"))){
+    h = new TH2F("hEtaPhi", Form("TPC (#eta,#varphi), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 50, -1, 1, 157, 0, 6.28);
+  } else h->Reset();
+  fHistos->AddAt(h, kEtaPhi);
+  
+  // Nclusters vs eta distribution for TPC tracks
+  if(!(h = (TH2F*)gROOT->FindObject("hEtaNclsTPC"))){
+    h = new TH2F("hEtaNclsTPC", Form("TPC Nclusters vs. #eta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 50, -1, 1, 160, 0, 160.);
+  } else h->Reset();
+  fHistos->AddAt(h, kEtaNclsTPC);
+  
+  // Nclusters vs phi distribution for TPC reference tracks
+  if(!(h = (TH2F*)gROOT->FindObject("hPhiNclsTPC"))){
+    h = new TH2F("hPhiNclsTPC", Form("TPC Nclusters vs. #varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 157, 0, 6.28, 160, 0, 160.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPhiNclsTPC);
+  
+  // Ntracklets/track vs P for TRD reference tracks
+  Double_t binsP[19] = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0,
+                       2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};
+  if(!(h = (TH2F*)gROOT->FindObject("hNTrackletsTRD"))){
+    h = new TH2F("hNTrackletsTRD", Form("TRD Ntracklets/track vs. P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 7, -0.5, 6.5);
+  } else h->Reset();
+  fHistos->AddAt(h, kNTrackletsTRD);
+  
+  // Nclusters/track vs P for TRD reference tracks
+  if(!(h = (TH2F*)gROOT->FindObject("hNClsTrackTRD"))){
+    h = new TH2F("hNClsTrackTRD", Form("TRD Nclusters/track vs. P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 180, 0., 180.);
+  } else h->Reset();
+  fHistos->AddAt(h, kNClsTrackTRD);
+  
+  // <PH> vs slice number for TRD reference tracklets
+  if(!(h = (TH2F*)gROOT->FindObject("hPHSlice"))){
+    h = new TH2F("hPHSlice", Form("<PH> vs sliceNo, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 200, 0., 2000.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPHSlice);
+
+  // <PH> vs slice number for TRD reference tracklets, from TPC pions
+  if(!(h = (TH2F*)gROOT->FindObject("hPHSliceTPCpions"))){
+    h = new TH2F("hPHSliceTPCpions", Form("<PH> vs sliceNo, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC pions",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPHSliceTPCpions);
+
+  // TPC dE/dx vs P for TRD reference tracks, pions
+  if(!(h = (TH2F*)gROOT->FindObject("hTPCdedxPions"))){
+    h = new TH2F("hTPCdedxPions", Form("TPC dE/dx vs P, TPC pions, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCdedxPions);
+
+  // <PH> vs slice number for TRD reference tracklets, from TPC electrons
+  if(!(h = (TH2F*)gROOT->FindObject("hPHSliceTPCelectrons"))){
+    h = new TH2F("hPHSliceTPCelectrons", Form("<PH> vs sliceNo, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC electrons",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPHSliceTPCelectrons);
+
+  // TPC dE/dx vs P for TRD reference tracks, electrons
+  if(!(h = (TH2F*)gROOT->FindObject("hTPCdedxElectrons"))){
+    h = new TH2F("hTPCdedxElectrons", Form("TPC dE/dx vs P, TPC electrons, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCdedxElectrons);
+  
+  // Qtot vs P for TRD reference tracklets
+  if(!(h = (TH2F*)gROOT->FindObject("hQtotP"))){
+    h = new TH2F("hQtotP", Form("Qtot(from slices) vs P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 400, 0., 200);
+  } else h->Reset();
+  fHistos->AddAt(h, kQtotP);
+  
+  // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)
+  if(!(h = (TH3F*)gROOT->FindObject("hPropagXYvsP"))){
+    h = new TH3F("hPropagXYvsP", Form("(x,y) vs P after AliESDtrack::PropagateTo(r=300.), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-500,500, 100,-500,500, 10, 0.,10.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPropagXYvsP);
+  
+  // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)
+  if(!(h = (TH3F*)gROOT->FindObject("hPropagRZvsP"))){
+    h = new TH3F("hPropagRZvsP", Form("(r,z) vs P after AliESDtrack::PropagateTo(r=300.), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-350., 350., 100,0.,500., 10, 0.,10.);
+  } else h->Reset();
+  fHistos->AddAt(h, kPropagRZvsP);
+  
+  Float_t etaBinLimits[101];   
+  for(Int_t i=0; i<101; i++) etaBinLimits[i] = -1.0 + i*2.0/100.;
+  Float_t phiBinLimits[151];
+  for(Int_t i=0; i<151; i++) phiBinLimits[i] = -1.1*TMath::Pi() + i*2.2*TMath::Pi()/150.;
+  // (eta,detector phi,P) distribution of reference TPC positive tracks
+  if(!(h = (TH3F*)gROOT->FindObject("hTPCRefTracksPos"))){
+    h = new TH3F("hTPCRefTracksPos", Form("(#eta,detector #varphi,p) for TPC positive reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCRefTracksPos);
+  
+  // (eta,detector phi,P) distribution of reference TPC negative tracks
+  if(!(h = (TH3F*)gROOT->FindObject("hTPCRefTracksNeg"))){
+    h = new TH3F("hTPCRefTracksNeg", Form("(#eta,detector #varphi,p) for TPC negative reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kTPCRefTracksNeg);
+  
+  // (eta,detector phi,P) distribution of reference TRD positive tracks
+  if(!(h = (TH3F*)gROOT->FindObject("hTRDRefTracksPos"))){
+    h = new TH3F("hTRDRefTracksPos", Form("(#eta,detector #varphi,p) for TRD positive reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDRefTracksPos);
+  
+  // (eta,detector phi,P) distribution of reference TRD negative tracks
+  if(!(h = (TH3F*)gROOT->FindObject("hTRDRefTracksNeg"))){
+    h = new TH3F("hTRDRefTracksNeg", Form("(#eta,detector #varphi,p) for TRD negative reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDRefTracksNeg);
+  
+  // (eta,detector phi) profile of average number of TRD tracklets/track
+  if(!(h = (TProfile2D*)gROOT->FindObject("hTRDEtaPhiAvNtrkl"))){
+    h = new TProfile2D("hTRDEtaPhiAvNtrkl", Form("<Ntracklets/track> vs (#eta,detector #varphi) for TRD reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDEtaPhiAvNtrkl);
+
+  // (eta,delta phi) profile of average number of TRD tracklets/track
+  if(!(h = (TProfile2D*)gROOT->FindObject("hTRDEtaDeltaPhiAvNtrkl"))){
+    h = new TProfile2D("hTRDEtaDeltaPhiAvNtrkl", Form("<Ntracklets/track> vs (#eta, #Delta#varphi) for TRD reference tracks, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 50, -0.4*TMath::Pi(), 0.4*TMath::Pi());
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDEtaDeltaPhiAvNtrkl);
+  
+  // (eta, detector phi) profile of average tracklet Qtot from slices
+  for(Int_t iLayer=0;iLayer<6;iLayer++) {
+    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvQtot_Layer%d",iLayer)))) {
+      h = new TProfile2D(Form("hTRDEtaPhiAvQtot_Layer%d",iLayer),
+                        Form("<Q_{tot}> vs (#eta, detector #varphi) for TRD reference tracks (layer %d), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                             iLayer, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDEtaPhiAvQtot+iLayer);
+  }
+
   return fHistos;
 }
 
 //____________________________________________________________________
-Bool_t AliTRDcheckESD::Load(const Char_t *filename, const Char_t *name)
+Bool_t AliTRDcheckESD::Load(const Char_t *file, const Char_t *dir, const Char_t *name)
 {
 // Load data from performance file
 
-  if(!TFile::Open(filename)){
-    AliWarning(Form("Couldn't open file %s.", filename));
+  if(!TFile::Open(file)){
+    AliWarning(Form("Couldn't open file %s.", file));
     return kFALSE;
   }
-  TObjArray *o = NULL;
-  if(!(o = (TObjArray*)gFile->Get(name ? name : GetName()))){
-    AliWarning("Missing histogram container.");
+  if(dir){
+    if(!gFile->cd(dir)){
+      AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
+      return kFALSE;
+    }
+  }
+  TObjArray *o(NULL);
+  const Char_t *tn=(name ? name : GetName());
+  if(!(o = (TObjArray*)gDirectory->Get(tn))){
+    AliWarning(Form("Missing histogram container %s.", tn));
     return kFALSE;
   }
   fHistos = (TObjArray*)o->Clone(GetName());
   gFile->Close();
-  SETBIT(fStatus, kLoad);
   return kTRUE;
 }
 
@@ -454,7 +1462,7 @@ Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val)
 void AliTRDcheckESD::Terminate(Option_t *)
 {
 // Steer post-processing 
-  if(!IsLoad()){
+  if(!fHistos){
     fHistos = dynamic_cast<TObjArray *>(GetOutputData(1));
     if(!fHistos){
       AliError("Histogram container not found in output");
@@ -474,6 +1482,21 @@ void AliTRDcheckESD::Terminate(Option_t *)
       fResults->AddAt(arr = new TObjArray(fgkNgraph[iref]), iref);
       arr->SetName(name[iref]);  arr->SetOwner();
       switch(iref){
+      case kNCl:
+        for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){
+          arr->AddAt(g = new TGraphErrors(), ig);
+          g->SetLineColor(ig+1); 
+          g->SetMarkerColor(ig+1); 
+          g->SetMarkerStyle(ig+20); 
+          g->SetName(Form("s%d", ig));
+          switch(ig){
+          case 0: g->SetTitle("ALL"); break;
+          case 1: g->SetTitle("NEG"); break;
+          case 2: g->SetTitle("POS"); break;
+          default: g->SetTitle(AliPID::ParticleLatexName(ig-3)); break;
+          };
+        }
+        break;
       case kTRDmom:
         for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){
           arr->AddAt(g = new TGraphAsymmErrors(), ig);
@@ -483,17 +1506,30 @@ void AliTRDcheckESD::Terminate(Option_t *)
         }
         break;
       case kPtRes:
-        for(Int_t im(fgkNgraph[iref]/2), ig(im), idx(0); ig--; idx+=ig){
-         arr->AddAt(g = new TGraphErrors(), ig);
+        for(Int_t idx(0); idx<AliPID::kSPECIES; idx++){
+          Int_t ig(2*idx);
+          arr->AddAt(g = new TGraphErrors(), ig);
           g->SetLineColor(kRed-idx); 
           g->SetMarkerColor(kRed-idx); 
-          g->SetMarkerStyle(20+ig); 
-          g->SetNameTitle(Form("s%d", ig), Form("res %s", AliPID::ParticleLatexName(ig)));
-          arr->AddAt(g = new TGraphErrors(), im+ig);
+          g->SetMarkerStyle(20+idx); 
+          g->SetNameTitle(Form("s%d", ig), Form("res %s", AliPID::ParticleLatexName(idx)));
+          arr->AddAt(g = new TGraphErrors(), ig+1);
           g->SetLineColor(kBlue-idx); 
           g->SetMarkerColor(kBlue-idx); 
-          g->SetMarkerStyle(20+ig); 
-          g->SetNameTitle(Form("m%d", ig), Form("sys %s", AliPID::ParticleLatexName(ig)));
+          g->SetMarkerStyle(20+idx); 
+          g->SetNameTitle(Form("m%d", ig+1), Form("sys %s", AliPID::ParticleLatexName(idx)));
+
+          ig+=10;
+          arr->AddAt(g = new TGraphErrors(), ig);
+          g->SetLineColor(kRed-idx); 
+          g->SetMarkerColor(kRed-idx); 
+          g->SetMarkerStyle(20+idx); 
+          g->SetNameTitle(Form("s%d", ig), Form("sigma %s", AliPID::ParticleLatexName(idx)));
+          arr->AddAt(g = new TGraphErrors(), ig+1);
+          g->SetLineColor(kBlue-idx); 
+          g->SetMarkerColor(kBlue-idx); 
+          g->SetMarkerStyle(20+idx); 
+          g->SetNameTitle(Form("m%d", ig+1), Form("mean %s", AliPID::ParticleLatexName(idx)));
         }
         break;
       default:
@@ -507,14 +1543,54 @@ void AliTRDcheckESD::Terminate(Option_t *)
       }
     }
   }
+  TH1 *h1[2] = {NULL, NULL};
+  TH2I *h2(NULL);
+  TAxis *ax(NULL);
+
+  // No of clusters
+  if(!(h2 = (TH2I*)fHistos->At(kNCl))) return;
+  ax = h2->GetXaxis();
+  arr = (TObjArray*)fResults->At(kNCl);
+  // All tracks
+  h1[0] = h2->ProjectionX("Ncl_px");
+  TGraphErrors *ge=(TGraphErrors*)arr->At(0);
+  for(Int_t ib=2; ib<=ax->GetNbins(); ib++){
+    ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));
+  }
+  // All charged tracks
+  TH1 *hNclCh[2] = {(TH1D*)h1[0]->Clone("NEG"), (TH1D*)h1[0]->Clone("POS")};
+  hNclCh[0]->Reset();hNclCh[1]->Reset();
+  for(Int_t is(1); is<=AliPID::kSPECIES; is++){
+    hNclCh[0]->Add(h2->ProjectionX("Ncl_px", 2*is-1, 2*is-1)); // neg
+    hNclCh[1]->Add(h2->ProjectionX("Ncl_px", 2*is, 2*is));     // pos
+  }
+  if(Int_t(hNclCh[0]->GetEntries())){
+    ge=(TGraphErrors*)arr->At(1);
+    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){
+      ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[0]->GetBinContent(ib));
+    }
+  }
+  if(Int_t(hNclCh[1]->GetEntries())){
+    ge=(TGraphErrors*)arr->At(2);
+    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){
+      ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[1]->GetBinContent(ib));
+    }
+  }
+  // Species wise
+  for(Int_t is(1); is<=AliPID::kSPECIES; is++){
+    h1[0] = h2->ProjectionX("Ncl_px", 2*is-1, 2*is);
+    if(!Int_t(h1[0]->GetEntries())) continue;
+    ge=(TGraphErrors*)arr->At(2+is);
+    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){
+      ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));
+    }
+  }
   fNRefFigures = 1;
 
   // EFFICIENCY
   // geometrical efficiency
-  TH2I *h2(NULL);
   if(!(h2 = (TH2I*)fHistos->At(kTRDstat))) return;
   arr = (TObjArray*)fResults->At(kTRDstat);
-  TH1 *h1[2] = {NULL, NULL};
   h1[0] = h2->ProjectionX("checkESDx0", kTPCout, kTPCout);
   h1[1] = h2->ProjectionX("checkESDx1", kTRDin, kTRDin);
   Process(h1, (TGraphErrors*)arr->At(0));
@@ -538,7 +1614,7 @@ void AliTRDcheckESD::Terminate(Option_t *)
   if(!(h2 = dynamic_cast<TH2I*>(fHistos->At(kTRDmom)))) return;
   arr = (TObjArray*)fResults->At(kTRDmom);
   TGraphAsymmErrors *g06 = (TGraphAsymmErrors*)arr->At(0), *g09 = (TGraphAsymmErrors*)arr->At(1);
-  TAxis *ax=h2->GetXaxis();
+  ax=h2->GetXaxis();
   const Int_t nq(4);
   const Double_t xq[nq] = {0.05, 0.2, 0.8, 0.95};
   Double_t yq[nq];
@@ -554,7 +1630,7 @@ void AliTRDcheckESD::Terminate(Option_t *)
     delete h1[0];
   }
   fNRefFigures++;
-  if(!HasMC()) return;
+//  if(!HasMC()) return;
 
   // Pt RESOLUTION @ DCA
   TH3S* h3(NULL); TGraphErrors *gg[2] = {NULL,NULL};
@@ -562,27 +1638,47 @@ void AliTRDcheckESD::Terminate(Option_t *)
   arr = (TObjArray*)fResults->At(kPtRes);
   TAxis *az(h3->GetZaxis());
   for(Int_t i(0); i<AliPID::kSPECIES; i++){
-    az->SetRange(5-i, 5-i); 
-    gg[1] = (TGraphErrors*)arr->At(4-i);
-    gg[0] = (TGraphErrors*)arr->At(9-i);
+    Int_t idx(2*i);
+    az->SetRange(idx+1, idx+2); 
+    gg[1] = (TGraphErrors*)arr->At(idx);
+    gg[0] = (TGraphErrors*)arr->At(idx+1);
+    Process2D((TH2*)h3->Project3D("yx"), gg);
+
+    idx+=10;
+    az->SetRange(idx+1, idx+2); 
+    gg[1] = (TGraphErrors*)arr->At(idx);
+    gg[0] = (TGraphErrors*)arr->At(idx+1);
     Process2D((TH2*)h3->Project3D("yx"), gg);
-    //az->SetRange(7+i, 7+i);
-    //Process2D((TH2*)h3->Project3D("yx"), gg);
   }
   fNRefFigures++;
+  
+  // 3x3 tracking summary canvas
+  fNRefFigures++;
+  // 3x3 PID summary canvas
+  fNRefFigures++;
+  // 3x4 PID summary canvas (TRD Qtot for TPC pions and protons)
+  fNRefFigures++;
 }
 
 //____________________________________________________________________
-Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg)
+Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg) const
 {
+  //
+  // Helper function converting PDG code into AliPID index
+  //
   switch(pdg){
-  case kElectron: return AliPID::kElectron+1;  
-  case kMuonMinus: return AliPID::kMuon+1;  
-  case kPiPlus: return AliPID::kPion+1;  
-  case kKPlus: return AliPID::kKaon+1;
-  case kProton: return AliPID::kProton+1;
+  case kElectron: 
+  case kPositron: return AliPID::kElectron;  
+  case kMuonPlus:
+  case kMuonMinus: return AliPID::kMuon;  
+  case kPiPlus: 
+  case kPiMinus: return AliPID::kPion;  
+  case kKPlus: 
+  case kKMinus: return AliPID::kKaon;
+  case kProton: 
+  case kProtonBar: return AliPID::kProton;
   } 
-  return 0;
+  return -1;
 }
 
 //____________________________________________________________________
@@ -653,3 +1749,124 @@ void AliTRDcheckESD::PrintStatus(ULong_t status)
   );
 }
 
+//____________________________________________________________________
+TH1F* AliTRDcheckESD::Proj2D(TH2F* hist) {
+  //
+  // project the PH vs Slice 2D-histo into a 1D histo
+  //
+  TH1F* hProjection = new TH1F("hProjection","", hist->GetXaxis()->GetNbins(), 
+                              hist->GetXaxis()->GetXmin(), hist->GetXaxis()->GetXmax());
+  TF1* fitLandau = new TF1("landauFunc","landau",0.,2000.);
+  TH1D *hD;
+  for(Int_t iBin=1;iBin<=hist->GetXaxis()->GetNbins();iBin++) {
+    if(gROOT->FindObject("projection"))
+      delete gROOT->FindObject("projection");
+    hD = (TH1D*)hist->ProjectionY("projection",iBin,iBin);
+    if(hD->Integral()>1) {
+      fitLandau->SetParameter(1, hD->GetBinCenter(hD->GetMaximumBin()));
+      hD->Fit(fitLandau, "MEQ0", "", 0., 2.0*hD->GetBinCenter(hD->GetMaximumBin()));
+      hProjection->SetBinContent(iBin, fitLandau->GetParameter(1));
+      hProjection->SetBinError(iBin, fitLandau->GetParError(1));
+    }
+    else{
+      hProjection->SetBinContent(iBin, 0);
+      hProjection->SetBinError(iBin, 0);
+    }
+  }
+  return hProjection;
+}
+
+//____________________________________________________________________
+TH2F* AliTRDcheckESD::Proj3D(TH3F* hist, TH2F* accMap, Int_t zbinLow, Int_t zbinHigh, Float_t &entries) {
+  //
+  //  Project a 3D histogram to a 2D histogram in the Z axis interval [zbinLow,zbinHigh] 
+  //  Return the 2D histogram and also the number of entries into this projection (entries)
+
+  Int_t nBinsX = hist->GetXaxis()->GetNbins();   // X and Y axis bins are assumed to be all equal
+  Float_t minX = hist->GetXaxis()->GetXmin();
+  Float_t maxX = hist->GetXaxis()->GetXmax();
+  Int_t nBinsY = hist->GetYaxis()->GetNbins();
+  Float_t minY = hist->GetYaxis()->GetXmin();
+  Float_t maxY = hist->GetYaxis()->GetXmax();
+  Int_t nBinsZ = hist->GetZaxis()->GetNbins();  // Z axis bins (pt) might have different widths
+  //Float_t minZ = hist->GetZaxis()->GetXmin();
+  //Float_t maxZ = hist->GetZaxis()->GetXmax();
+
+  TH2F* projHisto = (TH2F*)gROOT->FindObject("projHisto");
+  if(projHisto) 
+    projHisto->Reset();
+  else
+    projHisto = new TH2F("projHisto", "projection", nBinsX, minX, maxX, nBinsY, minY, maxY);
+
+  const Double_t kMinAccFraction = 0.1;
+  entries = 0.0;
+  Double_t maxAcc = (accMap ? accMap->GetMaximum() : -1);
+  
+  for(Int_t iZ=1; iZ<=nBinsZ; iZ++) {
+    if(iZ<zbinLow) continue;
+    if(iZ>zbinHigh) continue;
+    for(Int_t iX=1; iX<=nBinsX; iX++) {
+      for(Int_t iY=1; iY<=nBinsY; iY++) {
+       if(accMap && maxAcc>0) {
+         if(accMap->GetBinContent(iX,iY)/maxAcc>kMinAccFraction)
+           projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));
+       }
+       else    // no acc. cut 
+         projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));
+       // count only the entries which are inside the acceptance map
+       if(accMap && maxAcc>0) { 
+         if(accMap->GetBinContent(iX,iY)/maxAcc>kMinAccFraction)
+           entries+=hist->GetBinContent(iX,iY,iZ);
+       }
+       else    // no acc. cut
+         entries+=hist->GetBinContent(iX,iY,iZ);
+      }
+    }
+  }
+  return projHisto;
+}
+//____________________________________________________________________
+TH1F* AliTRDcheckESD::EfficiencyTRD(Short_t positives) {
+  //
+  // Calculate the TRD-TPC matching efficiency as function of pt
+  //
+  TH3F* tpc3D(NULL); TH3F* trd3D(NULL);
+  if(positives>0) {      // get the histos for positive tracks  
+    if(!(tpc3D = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos)))) return 0x0;
+    if(!(trd3D = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos)))) return 0x0;
+  }
+  else {      // get the histos for positive tracks
+    if(!(tpc3D = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg)))) return 0x0;
+    if(!(trd3D = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg)))) return 0x0;
+  }
+  
+  Int_t nBinsZ = trd3D->GetZaxis()->GetNbins();
+  // project everything on the eta-phi map to obtain an acceptance map (make sure there is enough statistics)
+  Float_t nada = 0.;
+  TH2F *trdAcc = (TH2F*)Proj3D(trd3D, 0x0, 1, nBinsZ, nada)->Clone();
+  // get the bin limits from the Z axis of 3D histos
+  Float_t *ptBinLimits = new Float_t[nBinsZ+1];
+  for(Int_t i=1; i<=nBinsZ; i++) {
+    ptBinLimits[i-1] = trd3D->GetZaxis()->GetBinLowEdge(i);
+  }
+  ptBinLimits[nBinsZ] = trd3D->GetZaxis()->GetBinUpEdge(nBinsZ);
+  TH1F *efficiency = new TH1F("eff", "TRD-TPC matching efficiency", nBinsZ, ptBinLimits);
+  // loop over Z bins
+  for(Int_t i=1; i<=nBinsZ; i++) {
+    Float_t tpcEntries = 0.0; Float_t trdEntries = 0.0;
+    Proj3D(tpc3D, trdAcc, i, i, tpcEntries);
+    Proj3D(trd3D, trdAcc, i, i, trdEntries);
+    Float_t ratio = 0;
+    if(tpcEntries>0) ratio = trdEntries/tpcEntries;
+    Float_t error = 0;
+    if(tpcEntries>0 && trdEntries>0) 
+      error = ratio*TMath::Sqrt((1.0/tpcEntries)+(1.0/trdEntries));
+    if(ratio>0.0) {
+      efficiency->SetBinContent(i,ratio);
+      efficiency->SetBinError(i,error);
+    }
+  }     // end loop over Z bins
+  
+  efficiency->SetLineColor((positives>0 ? 2 : 4));
+  return efficiency;
+}