]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDcheckESD.cxx
changed function signature
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDcheckESD.cxx
index 015ab6999c1ff4ef30e44dc246d6c2e8c486b427..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>
@@ -43,6 +47,7 @@
 #include <TROOT.h>
 #include <TChain.h>
 #include <TParticle.h>
+#include <TTimeStamp.h>
 
 #include "AliLog.h"
 #include "AliAnalysisManager.h"
@@ -51,6 +56,7 @@
 #include "AliMCEvent.h"
 #include "AliESDInputHandler.h"
 #include "AliMCEventHandler.h"
+#include "AliESDpid.h"
 
 #include "AliESDtrack.h"
 #include "AliMCParticle.h"
@@ -84,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);
 }
 
@@ -101,6 +108,7 @@ AliTRDcheckESD::AliTRDcheckESD(char* name):
   ,fNRefFigures(0)
   ,fESD(NULL)
   ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
   ,fHistos(NULL)
   ,fResults(NULL)
 {
@@ -133,12 +141,31 @@ void AliTRDcheckESD::UserCreateOutputObjects()
   // Create Output Containers (TObjectArray containing 1D histograms)
   //
   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;
@@ -152,12 +179,26 @@ Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
   }
 
   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
     if(!(arr = (TObjArray*)fResults->At(kNCl))) return kFALSE;
@@ -263,8 +304,454 @@ Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)
       }
       if(nPlots) leg->Draw();
     }
-
     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;
 }
@@ -358,7 +845,7 @@ void AliTRDcheckESD::UserExec(Option_t *){
     Float_t theta=esdTrack->Theta();
     Float_t phi=esdTrack->Phi();
     Int_t nClustersTPC = esdTrack->GetTPCNcls();
-    Float_t eta=-TMath::Log(TMath::Tan(theta/2.));
+    Float_t eta=esdTrack->Eta();
     if(selected) {
       nTracksAcc++;   // number of tracks in acceptance and DCA cut
       // fill pt distribution at this stage
@@ -390,7 +877,7 @@ void AliTRDcheckESD::UserExec(Option_t *){
     // pid quality
     Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin);
 
-    TH3F *hhh;
+    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);
@@ -407,14 +894,14 @@ void AliTRDcheckESD::UserExec(Option_t *){
     if(esdTrack->Charge()>0) {
       h = (TH1F*)fHistos->At(kPt3pos); h->Fill(pt);
       // fill eta-phi map of TPC positive ref. tracks
-      if(localCoordGood && localMomGood) {
+      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) {
+      if(localCoordGood && localMomGood && esdTrack->GetP()>0.5) {
         hhh = (TH3F*)fHistos->At(kTPCRefTracksNeg); hhh->Fill(eta, localSagitaPhi, pt);
       }
     }
@@ -430,20 +917,20 @@ void AliTRDcheckESD::UserExec(Option_t *){
       if(esdTrack->Charge()>0) {
         h = (TH1F*)fHistos->At(kPt4pos); h->Fill(pt);
        // fill eta-phi map of TRD positive ref. tracks
-       if(localCoordGood && localMomGood) {
+       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) {
+       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) {
+      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);
       }
@@ -451,16 +938,49 @@ void AliTRDcheckESD::UserExec(Option_t *){
       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;
+        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));
-           Qtot += 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);
          }
         }
-        h = (TH2F*)fHistos->At(kQtotP); h->Fill(esdTrack->GetTRDmomentum(iPlane), fgkQs*Qtot);
+        // 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);
@@ -558,8 +1078,6 @@ void AliTRDcheckESD::UserExec(Option_t *){
   h->Fill(nTracksAcc);
   h = (TH1I*)fHistos->At(kNTracksTPC);
   h->Fill(nTracksTPC);
-  
-  PostData(1, fHistos);
 }
 
 //____________________________________________________________________
@@ -576,9 +1094,9 @@ TObjArray* AliTRDcheckESD::Histos()
 
   // clusters per track
   const Int_t kNpt(30);
-  Float_t Pt(0.2);
+  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;
+  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());
@@ -592,9 +1110,9 @@ TObjArray* AliTRDcheckESD::Histos()
 
   // status bits histogram
   const Int_t kNbits(5);
-  Float_t Bits(.5);
+  Float_t bits(.5);
   Float_t binsBits[kNbits+1];
-  for(Int_t i=0; i<kNbits+1; i++,Bits+=1.) binsBits[i]=Bits;
+  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());
@@ -615,10 +1133,10 @@ TObjArray* AliTRDcheckESD::Histos()
 
   // pt resolution
   const Int_t kNdpt(100), kNspec(4*AliPID::kSPECIES);
-  Float_t DPt(-3.), Spec(-0.5);
+  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());
@@ -790,9 +1308,37 @@ TObjArray* AliTRDcheckESD::Histos()
   // <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, 2000, 0., 2000.);
+                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"))){
@@ -861,6 +1407,16 @@ TObjArray* AliTRDcheckESD::Histos()
   } 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;
 }
 
@@ -1074,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};
@@ -1095,11 +1651,21 @@ void AliTRDcheckESD::Terminate(Option_t *)
     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: 
   case kPositron: return AliPID::kElectron;  
@@ -1183,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;
+}