]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Updates by Ionut
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Nov 2012 08:39:05 +0000 (08:39 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Nov 2012 08:39:05 +0000 (08:39 +0000)
- added ITS cuts for reference tracks
- reject events which are triggered by trigger classes "NOTRD" or "MUON".
- add trigger-class as selection variable in CF container.

PWGPP/TRD/AliTRDcheckESD.cxx
PWGPP/TRD/AliTRDcheckESD.h
PWGPP/TRD/macros/AddTRDcheckESD.C

index 90fa23f39d04b0018116bd3dfdf90150d36a45ca..af2b320f8bc98492cbab9bc49c65c0a370739c65 100644 (file)
-/**************************************************************************\r
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
-*                                                                        *\r
-* Author: The ALICE Off-line Project.                                    *\r
-* Contributors are mentioned in the code where appropriate.              *\r
-*                                                                        *\r
-* Permission to use, copy, modify and distribute this software and its   *\r
-* documentation strictly for non-commercial purposes is hereby granted   *\r
-* without fee, provided that the above copyright notice appears in all   *\r
-* copies and that both the copyright notice and this permission notice   *\r
-* appear in the supporting documentation. The authors make no claims     *\r
-* about the suitability of this software for any purpose. It is          *\r
-* provided "as is" without express or implied warranty.                  *\r
-**************************************************************************/\r
-\r
-/////////////////////////////////////////////////////\r
-//\r
-// Check basic detector results at ESD level\r
-//   - Geometrical efficiency  \r
-//   - Tracking efficiency  \r
-//   - PID efficiency  \r
-//   - Refit efficiency  \r
-//\r
-// Author\r
-//   Alex Bercuci <A.Bercuci@gsi.de>\r
-//   Ionut Arsene <i.c.arsene@gsi.de>\r
-//\r
-//////////////////////////////////////////////////////\r
-\r
-#include <TClonesArray.h>\r
-#include <TCanvas.h>\r
-#include <TObjArray.h>\r
-#include <TPad.h>\r
-#include <TLegend.h>\r
-#include <TLatex.h>\r
-#include <TLine.h>\r
-#include <TF1.h>\r
-#include <TH1D.h>\r
-#include <TH2D.h>\r
-#include <TH3D.h>\r
-#include <TH2I.h>\r
-#include <TH2F.h>\r
-#include <TH3S.h>\r
-#include <TH3F.h>\r
-#include <TProfile2D.h>\r
-#include <TProfile.h>\r
-#include <TGraphErrors.h>\r
-#include <TGraphAsymmErrors.h>\r
-#include <TFile.h>\r
-#include <TTree.h>\r
-#include <TROOT.h>\r
-#include <TChain.h>\r
-#include <TParticle.h>\r
-#include <TTimeStamp.h>\r
-#include <TRandom.h>\r
-#include <TString.h>\r
-\r
-#include "AliLog.h"\r
-#include "AliAnalysisManager.h"\r
-#include "AliAnalysisCuts.h"\r
-#include "AliPhysicsSelection.h"\r
-#include "AliESDEvent.h"\r
-#include "AliESDkink.h"\r
-#include "AliMCEvent.h"\r
-#include "AliESDInputHandler.h"\r
-#include "AliMCEventHandler.h"\r
-#include "AliESDpid.h"\r
-\r
-#include "AliESDtrack.h"\r
-#include "AliMCParticle.h"\r
-#include "AliPID.h"\r
-#include "AliStack.h"\r
-#include "AliTrackReference.h"\r
-//#include "AliESDCentrality.h"\r
-#include "AliMultiplicity.h"\r
-#include "AliCFContainer.h"\r
-\r
-#include "AliTRDcheckESD.h"\r
-#include <iostream>\r
-using namespace std;\r
-\r
-ClassImp(AliTRDcheckESD)\r
-\r
-const Float_t AliTRDcheckESD::fgkxTPC = 290.;\r
-const Float_t AliTRDcheckESD::fgkxTOF = 365.;\r
-const UChar_t AliTRDcheckESD::fgkNgraph[AliTRDcheckESD::kNrefs] ={\r
-8, 4, 2, 20};\r
-FILE* AliTRDcheckESD::fgFile = NULL;\r
-\r
-const Float_t AliTRDcheckESD::fgkEvVertexZ = 15.;\r
-const Int_t   AliTRDcheckESD::fgkEvVertexN = 1;\r
-const Float_t AliTRDcheckESD::fgkTrkDCAxy  = 40.;\r
-const Float_t AliTRDcheckESD::fgkTrkDCAz   = 15.;\r
-const Int_t   AliTRDcheckESD::fgkNclTPC    = 100;\r
-const Float_t AliTRDcheckESD::fgkPt        = 0.2;\r
-const Float_t AliTRDcheckESD::fgkEta       = 0.9;\r
-const Float_t AliTRDcheckESD::fgkQs        = 0.002;\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::AliTRDcheckESD():\r
-  AliAnalysisTaskSE()\r
-  ,fStatus(0)\r
-  ,fNRefFigures(0)\r
-  ,fESD(NULL)\r
-  ,fMC(NULL)\r
-  ,fESDpid(new AliESDpid)\r
-  ,fHistos(NULL)\r
-  ,fResults(NULL)\r
-  ,fExpertCF(NULL)\r
-  ,fMatchingPhiEtaCF(NULL)\r
-  ,fMatchingPtCF(NULL)\r
-  ,fBunchCrossingsCF(NULL)\r
-  ,fCentralityCF(NULL)\r
-  ,fQtotCF(NULL)\r
-  ,fPulseHeightCF(NULL)\r
-  ,fReferenceTrackFilter(NULL)\r
-  ,fPhysSelTriggersEnabled(kFALSE)\r
-  ,fUserEnabledTriggers("")\r
-  ,fNAssignedTriggers(0)\r
-{\r
-  //\r
-  // Default constructor\r
-  //\r
-  for(Int_t i=0; i<kNTrdCfVariables; ++i) {\r
-    fExpertCFVars[i] = -1;\r
-    fMatchingPhiEtaCFVars[i] = -1;\r
-    fMatchingPtCFVars[i] = -1;\r
-    fBunchCrossingsCFVars[i] = -1;\r
-    fCentralityCFVars[i] = -1;\r
-    fQtotCFVars[i] = -1;\r
-    fPulseHeightCFVars[i] = -1;\r
-    fExpertCFVarsEnabled[i] = kFALSE;\r
-    fExpertCFVarNBins[i] = 0;\r
-    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;\r
-    fExpertCFVarBins[i] = "";\r
-  }\r
-  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;\r
-  SetNameTitle("TRDcheckESD", "Check TRD @ ESD level");\r
-  SetMC(kTRUE);\r
-}\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::AliTRDcheckESD(char* name):\r
-  AliAnalysisTaskSE(name)\r
-  ,fStatus(0)\r
-  ,fNRefFigures(0)\r
-  ,fESD(NULL)\r
-  ,fMC(NULL)\r
-  ,fESDpid(new AliESDpid)\r
-  ,fHistos(NULL)\r
-  ,fResults(NULL)\r
-  ,fExpertCF(NULL)\r
-  ,fMatchingPhiEtaCF(NULL)\r
-  ,fMatchingPtCF(NULL)\r
-  ,fBunchCrossingsCF(NULL)\r
-  ,fCentralityCF(NULL)\r
-  ,fQtotCF(NULL)\r
-  ,fPulseHeightCF(NULL)\r
-  ,fReferenceTrackFilter(NULL)\r
-  ,fPhysSelTriggersEnabled(kFALSE)\r
-  ,fUserEnabledTriggers("")\r
-  ,fNAssignedTriggers(0)\r
-{\r
-  //\r
-  // Default constructor\r
-  //\r
-  for(Int_t i=0; i<kNTrdCfVariables; ++i) {\r
-    fExpertCFVars[i] = -1;\r
-    fMatchingPhiEtaCFVars[i] = -1;\r
-    fMatchingPtCFVars[i] = -1;\r
-    fBunchCrossingsCFVars[i] = -1;\r
-    fCentralityCFVars[i] = -1;\r
-    fQtotCFVars[i] = -1;\r
-    fPulseHeightCFVars[i] = -1;\r
-    fExpertCFVarsEnabled[i] = kFALSE;\r
-    fExpertCFVarNBins[i] = 0;\r
-    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;\r
-    fExpertCFVarBins[i] = "";\r
-  }\r
-  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;\r
-  SetMC(kTRUE);\r
-  SetTitle("Check TRD @ ESD level");\r
-  DefineOutput(1, TObjArray::Class());\r
-}\r
-\r
-//____________________________________________________________________\r
-AliTRDcheckESD::~AliTRDcheckESD()\r
-{\r
-  // Destructor\r
-  if(fHistos && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){\r
-    if(fHistos->IsOwner()) fHistos->Delete();\r
-    delete fHistos;\r
-    fHistos = NULL;\r
-  }\r
-  \r
-  if(fResults){\r
-    fResults->Delete();\r
-    delete fResults;\r
-  }\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, \r
-                                   Int_t nbins, Double_t lowLim, Double_t highLim) {\r
-  //\r
-  // Configure variables for the expert CF container\r
-  //\r
-  fExpertCFVarsEnabled[var] = kTRUE;\r
-  fExpertCFVarNBins[var] = nbins;\r
-  fExpertCFVarRanges[var][0] = lowLim;\r
-  fExpertCFVarRanges[var][1] = highLim;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, \r
-                                   const Char_t* bins) {\r
-  //\r
-  // Configure variables for the expert CF container\r
-  //\r
-  fExpertCFVarsEnabled[var] = kTRUE;\r
-  fExpertCFVarBins[var] = bins;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::UserCreateOutputObjects()\r
-{      \r
-  //\r
-  // Create Output Containers (TObjectArray containing 1D histograms)\r
-  //\r
-  Histos();\r
-  PostData(1, fHistos);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::MakeSummaryFromCF(Double_t* trendValues, const Char_t* triggerName, Bool_t useIsolatedBC, Bool_t cutTOFbc){\r
-  //\r
-  // Draw summary plots for the ESDcheck task using the CF container\r
-  //\r
-\r
-  cout << "Make summary from CF" << endl;\r
-  TCanvas *cOut=0x0;\r
-  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");\r
-  cOut = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  PlotTrackingSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("trackingSummary.gif");\r
-  \r
-  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");\r
-  cOut = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  //GetRefFigure(6);\r
-  PlotPidSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("pidSummary.gif");\r
-\r
-  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");\r
-  cOut = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);\r
-  cOut->cd();\r
-  //GetRefFigure(7);\r
-  PlotCentSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);\r
-  cOut->SaveAs("centSummary.gif");\r
-\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::MakeSummary(Double_t* trendValues){\r
-  //\r
-  // Draw summary plots for the ESDcheck task\r
-  //\r
-  // Old method to draw summary pictures from histograms. Use the MakeSummaryFromCF() when CF container is present\r
-  \r
-  cout << "Make summary" << endl;\r
-  TCanvas *cTracking=0x0;\r
-  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");\r
-  cTracking = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);\r
-  cTracking->cd();\r
-  //GetRefFigure(5);\r
-  if(PlotTrackingSummary(0, trendValues))\r
-    cTracking->SaveAs("trackingSummary.gif");\r
-  \r
-  TCanvas* cPid = 0x0;\r
-  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");\r
-  cPid = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);\r
-  cPid->cd();\r
-  //GetRefFigure(6);\r
-  if(PlotPidSummary(0, trendValues))\r
-    cPid->SaveAs("pidSummary.gif");\r
-\r
-  TCanvas* cCent=0x0;\r
-  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");\r
-  cCent = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);\r
-  cCent->cd();\r
-  //GetRefFigure(7);\r
-  if(PlotCentSummary(trendValues))\r
-    cCent->SaveAs("centSummary.gif");\r
-}\r
-\r
-//____________________________________________________________________\r
-Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig)\r
-{\r
-  //\r
-  // Produce reference Plots during PostProcessing\r
-  //\r
-  if(ifig>=fNRefFigures){\r
-    AliWarning(Form("Ref plot %d not available. Valid only up to %d", ifig, fNRefFigures));\r
-    return kFALSE;\r
-  }\r
-  if(!gPad){\r
-    AliWarning("Please provide a canvas to draw results.");\r
-    return kFALSE;\r
-  } else {\r
-    gPad->SetLogx(0);gPad->SetLogy(0);\r
-    gPad->SetMargin(0.125, 0.015, 0.1, 0.015);\r
-  }\r
-\r
-  const Char_t *title[20];\r
-  TH1 *hF(NULL);\r
-  if((hF=(TH1S*)gROOT->FindObject("hFcheckESD"))) delete hF;\r
-  TLegend *leg(NULL);\r
-  TList *l(NULL); TVirtualPad *pad(NULL);\r
-  TGraphErrors *g(NULL);TGraphAsymmErrors *ga(NULL);\r
-  TObjArray *arr(NULL);\r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  TLine line;\r
-  TTimeStamp now;\r
-  switch(ifig){\r
-  case kNCl: // number of clusters/track\r
-    if(!(arr = (TObjArray*)fResults->At(kNCl))) return kFALSE;\r
-\r
-    leg = new TLegend(.83, .7, .99, .96);\r
-    leg->SetHeader("Species");\r
-    leg->SetBorderSize(0); leg->SetFillStyle(0);\r
-    for(Int_t ig(0); ig<fgkNgraph[kNCl-1]; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;\r
-      if(!g->GetN()) continue;\r
-      g->Draw(ig?"pc":"apc"); leg->AddEntry(g, g->GetTitle(), "pl");\r
-      if(ig) continue;\r
-      hF=g->GetHistogram();\r
-      hF->SetXTitle("no of clusters");\r
-      hF->SetYTitle("entries"); \r
-      hF->GetYaxis()->CenterTitle(1);\r
-      hF->GetYaxis()->SetTitleOffset(1.2);\r
-      hF->SetMinimum(5);\r
-    }\r
-    leg->Draw(); gPad->SetLogy();\r
-    break;\r
-  case kTRDstat: // Efficiency\r
-    if(!(arr = (TObjArray*)fResults->At(kTRDstat))) return kFALSE;\r
-    leg = new TLegend(.62, .77, .98, .98);\r
-    leg->SetHeader("TRD Efficiency");\r
-    leg->SetBorderSize(0); leg->SetFillStyle(0);\r
-    title[0] = "Geometrical (TRDin/TPCout)";\r
-    title[1] = "Tracking (TRDout/TRDin)";\r
-    title[2] = "PID (TRDpid/TRDin)";\r
-    title[3] = "Refit (TRDrefit/TRDin)";\r
-    hF = new TH1S("hFcheckESD", ";p [GeV/c];Efficiency", 10, 0.1, 10.);\r
-    hF->SetMaximum(1.4);\r
-    hF->GetXaxis()->SetMoreLogLabels();\r
-    hF->GetYaxis()->CenterTitle(1);\r
-    hF->Draw("p");\r
-    for(Int_t ig(0); ig<fgkNgraph[kTRDstat-1]; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;\r
-      g->Draw("pl"); leg->AddEntry(g, title[ig], "pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    leg->Draw(); gPad->SetLogx();\r
-    break;\r
-  case kTRDmom: // Energy loss\r
-    if(!(arr = (TObjArray*)fResults->At(kTRDmom))) return kFALSE;\r
-    leg = new TLegend(.65, .7, .95, .99);\r
-    leg->SetHeader("Energy Loss");\r
-    leg->SetBorderSize(1); leg->SetFillColor(0);\r
-    title[0] = "Max & 90% quantile";\r
-    title[1] = "Mean & 60% quantile";\r
-    hF = new TH1S("hFcheckESD", ";layer;#Delta E", 6, -0.5, 5.5);\r
-    hF->SetMaximum(1.3);hF->SetMinimum(-.3);\r
-    hF->Draw("p");\r
-    for(Int_t ig(0); ig<fgkNgraph[kTRDmom-1]; ig++){\r
-      if(!(ga = (TGraphAsymmErrors*)arr->At(ig))) return kFALSE;\r
-      ga->Draw("pl"); leg->AddEntry(ga, title[ig], "pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    leg->Draw();gPad->SetLogx(kFALSE);\r
-    break;\r
-  case kPtRes: // Pt resolution @ vertex\r
-    if(!(arr = (TObjArray*)fResults->At(kPtRes))) return kFALSE;\r
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); \r
-    pad = ((TVirtualPad*)l->At(0)); pad->cd(); pad->SetLogx();\r
-    pad->SetMargin(0.1, 0.022, 0.1, 0.023);\r
-    hF = new TH1S("hFcheckESD", "ITS+TPC+TRD;p_{t} [GeV/c];#Delta p_{t} / p_{t} [%]", 10, 0.2, 10.);\r
-    hF->SetMaximum(10.);hF->SetMinimum(-3.);\r
-    hF->GetXaxis()->SetMoreLogLabels();\r
-    hF->GetXaxis()->SetTitleOffset(1.2);\r
-    hF->GetYaxis()->CenterTitle();\r
-    hF->Draw("p");\r
-    //for(Int_t ig(0); ig<fgkNgraph[kPtRes-1]/2; ig++){\r
-    for(Int_t ig(2); ig<6; ig++){\r
-      if(!(g = (TGraphErrors*)arr->At(ig))) continue;\r
-      if(!g->GetN()) continue;\r
-      g->Draw("pl");\r
-      //PutTrendValue(name[id], g->GetMean(2));\r
-      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-    }\r
-    pad = ((TVirtualPad*)l->At(1)); pad->cd(); pad->SetLogx();\r
-    pad->SetMargin(0.1, 0.22, 0.1, 0.023);\r
-    hF = (TH1*)hF->Clone("hFcheckESD1");\r
-    hF->SetTitle("ITS+TPC");\r
-    hF->SetMaximum(10.);hF->SetMinimum(-3.);\r
-    hF->Draw("p");\r
-    leg = new TLegend(.78, .1, .99, .98);\r
-    leg->SetHeader("P_{t} @ DCA");\r
-    leg->SetBorderSize(1); leg->SetFillColor(0);\r
-    leg->SetTextAlign(22);\r
-    leg->SetTextFont(12);\r
-    leg->SetTextSize(0.03813559);\r
-    {\r
-      Int_t nPlots(0);\r
-      //for(Int_t ig(fgkNgraph[kPtRes-1]/2); ig<fgkNgraph[kPtRes-1]; ig++){\r
-      for(Int_t ig(12); ig<16; ig++){\r
-        if(!(g = (TGraphErrors*)arr->At(ig))) continue;\r
-        if(!g->GetN()) continue;\r
-        nPlots++;\r
-        g->Draw("pl"); leg->AddEntry(g, g->GetTitle(), "pl");\r
-        //PutTrendValue(name[id], g->GetMean(2));\r
-        //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));\r
-      }\r
-      if(nPlots) leg->Draw();\r
-    }\r
-    break;\r
-  case 5: // plot a 3x3 canvas with tracking related histograms\r
-    PlotTrackingSummary(0);\r
-    break;\r
-    \r
-  case 6: // plot a 3x3 canvas with PID related histograms\r
-    PlotPidSummary(0);\r
-    break;\r
-\r
-  case 7: // plot a 3x3 canvas with centrality dependence histograms\r
-    PlotCentSummary();\r
-    break;\r
-\r
-  }\r
-  return kTRUE;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::UserExec(Option_t *){\r
-  //\r
-  // Run the Analysis\r
-  //\r
-  fESD = dynamic_cast<AliESDEvent*>(InputEvent());\r
-  fMC = MCEvent();\r
-\r
-  if(!fESD){\r
-    AliError("ESD event missing.");\r
-    return;\r
-  }\r
-  \r
-  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());\r
-  if(!inputHandler) return;\r
-  \r
-  if(!fPhysSelTriggersEnabled) {\r
-    InitializeCFContainers();\r
-    fPhysSelTriggersEnabled = kTRUE;\r
-  }\r
-    \r
-  UInt_t isSelected = AliVEvent::kAny;\r
-  if(inputHandler){\r
-    if(inputHandler->GetEventSelection()) {\r
-      isSelected = inputHandler->IsEventSelected();\r
-    }\r
-  }\r
-  if(!isSelected) return;\r
-  \r
-  TString triggerClasses = fESD->GetFiredTriggerClasses();\r
-  //cout << "triggers fired:  " << triggerClasses.Data() << endl;\r
-  TObjArray* triggers = triggerClasses.Tokenize(" ");\r
-  if(triggers->GetEntries()<1) return;\r
-  Int_t triggerIndices[kNMaxAssignedTriggers] = {0};\r
-  for(Int_t i=0; i<triggers->GetEntries(); ++i) {\r
-    //cout << "check trigger " << triggers->At(i)->GetName() << endl;\r
-    if(i>=kNMaxAssignedTriggers) continue;\r
-    triggerIndices[i] = GetTriggerIndex(triggers->At(i)->GetName(), kFALSE);\r
-  }  \r
-  if(!fNAssignedTriggers) {\r
-    triggerIndices[0] = 1;\r
-    ((TH1F*)fHistos->At(kTriggerDefs))->Fill(triggerIndices[0]);\r
-  }\r
-  else {\r
-    for(Int_t i=0; i<triggers->GetEntries(); ++i) \r
-      ((TH1F*)fHistos->At(kTriggerDefs))->Fill(triggerIndices[i]);\r
-  }\r
-  \r
-  // Get MC information if available\r
-  AliStack * fStack = NULL;\r
-  if(HasMC()){\r
-    if(!fMC){ \r
-      AliWarning("MC event missing");\r
-      SetMC(kFALSE);\r
-    } else {\r
-      if(!(fStack = fMC->Stack())){\r
-        AliWarning("MC stack missing");\r
-        SetMC(kFALSE);\r
-      }\r
-    }\r
-  }\r
-  TH1 *h(NULL);\r
-  \r
-  Double_t values[kNTrdCfVariables];      // array where the CF container variables are stored\r
-  values[kEventVtxZ] = fESD->GetPrimaryVertex()->GetZv();\r
-  values[kEventBC] = fESD->GetBunchCrossNumber();\r
-  \r
-  const AliMultiplicity* mult=fESD->GetMultiplicity();\r
-  Double_t itsNTracklets = mult->GetNumberOfTracklets();\r
-  if(itsNTracklets<1) return;\r
-  Int_t multLimits[6] = {0, 700, 1400, 2100, 2800, 3500};\r
-  Int_t centralityClass = 0;\r
-  for(Int_t iCent=0; iCent<5; ++iCent) {\r
-    if(itsNTracklets>=multLimits[iCent] && itsNTracklets<multLimits[iCent+1])\r
-      centralityClass=iCent+1;\r
-  }\r
-  values[kEventMult] = itsNTracklets;\r
-  if(centralityClass == 0) return;\r
-  \r
-  Double_t* valuesMatchingPhiEtaCF = new Double_t[fMatchingPhiEtaCF->GetNVar()];\r
-  Double_t* valuesMatchingPtCF = new Double_t[fMatchingPtCF->GetNVar()];\r
-  Double_t* valuesBCCF = new Double_t[fBunchCrossingsCF->GetNVar()];\r
-  Double_t* valuesCentCF = new Double_t[fCentralityCF->GetNVar()];\r
-  Double_t* valuesQtotCF = new Double_t[fQtotCF->GetNVar()];\r
-  Double_t* valuesPHCF = new Double_t[fPulseHeightCF->GetNVar()];\r
-  Double_t* valuesExpertCF = (fExpertCF ? new Double_t[fExpertCF->GetNVar()] : 0x0);\r
-  \r
-  AliESDtrack *esdTrack(NULL);\r
-  for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){\r
-    esdTrack = fESD->GetTrack(itrk);\r
-    if(!fReferenceTrackFilter->IsSelected(esdTrack)) continue;\r
-    \r
-    ULong_t status = esdTrack->GetStatus(); //PrintStatus(status);\r
-            \r
-    // pid quality\r
-    Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin);\r
-\r
-    // find position and momentum of the track at entrance in TRD\r
-    Double_t rTRD[6] = {298.0, 311.0, 324.0, 337.0, 350.0, 363.0};\r
-    Double_t localCoord[6][3] = {{0.0}};\r
-    Bool_t localCoordGood[6];\r
-    for(Int_t il=0;il<6;++il) localCoordGood[il] = esdTrack->GetXYZAt(rTRD[il], fESD->GetMagneticField(), localCoord[il]);\r
-    Double_t localMom[6][3] = {{0.0}};\r
-    Bool_t localMomGood[6];\r
-    for(Int_t il=0; il<6; ++il) localMomGood[il] = esdTrack->GetPxPyPzAt(rTRD[il], fESD->GetMagneticField(), localMom[il]);\r
-    //Double_t localPhi = (localMomGood ? TMath::ATan2(localMom[1], localMom[0]) : 0.0);\r
-    Double_t localSagitaPhi[6] = {-999.};\r
-    for(Int_t il=0; il<6; ++il) localSagitaPhi[il] = (localCoordGood[il] ? TMath::ATan2(localCoord[il][1], localCoord[il][0]) : -999.);\r
-\r
-    values[kTrackTOFBC]      = esdTrack->GetTOFBunchCrossing(fESD->GetMagneticField());\r
-    Float_t dcaXY=0.0; Float_t dcaZ=0.0;\r
-    esdTrack->GetImpactParameters(dcaXY, dcaZ);\r
-    values[kTrackDCAxy]  = dcaXY;\r
-    values[kTrackDCAz]   = dcaZ;\r
-    values[kTrackCharge] = esdTrack->Charge();\r
-    values[kTrackPhi]    = localSagitaPhi[0];\r
-    values[kTrackEta]    = esdTrack->Eta();\r
-    values[kTrackPt]     = esdTrack->Pt();\r
-    values[kTrackP]      = esdTrack->P();\r
-    values[kTrackTrdTracklets] = esdTrack->GetTRDntracklets();\r
-    values[kTrackTrdClusters] = esdTrack->GetTRDncls();\r
-    for(Int_t i=0; i<6; ++i) values[kTrackQtot+i] = 0.0;\r
-        \r
-    if(localCoordGood[0] && localMomGood[0]) {\r
-      for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-       values[kEventTrigger] = triggerIndices[itrig];\r
-       if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-         for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-         fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 0);\r
-       }\r
-       if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-         for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-         fMatchingPtCF->Fill(valuesMatchingPtCF, 0);\r
-       }\r
-       if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)\r
-         if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-           fBunchCrossingsCF->Fill(valuesBCCF, 0);\r
-         }\r
-       if(fExpertCF) {\r
-         if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0))\r
-           if(fExpertCF->GetStep("TPC")>=0 && fExpertCF->GetStep("TPC")<3) {\r
-             for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-             fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TPC"));\r
-           }\r
-       }\r
-      }\r
-    }\r
-            \r
-    // TRD reference tracks\r
-    if(values[kTrackTrdTracklets]>=1) {\r
-      // (slicePH,sliceNo) distribution and Qtot from slices\r
-      for(Int_t iPlane=0; iPlane<6; iPlane++) {\r
-        values[kTrackQtot+iPlane] = fgkQs*esdTrack->GetTRDslice(iPlane, 0);\r
-       values[kTrackPhi] = localSagitaPhi[iPlane];\r
-       for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-         values[kEventTrigger] = triggerIndices[itrig];\r
-         if((fCentralityCF->GetVar("trigger")<0 && itrig==0) || (fCentralityCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fCentralityCF->GetNVar(); ++iv) valuesCentCF[iv] = values[fCentralityCFVars[iv]];\r
-           valuesCentCF[fCentralityCF->GetNVar()-1] = values[kTrackQtot+iPlane];\r
-           fCentralityCF->Fill(valuesCentCF, 0);\r
-         }\r
-         if(values[kTrackTrdTracklets]>=4)\r
-           if((fQtotCF->GetVar("trigger")<0 && itrig==0) || (fQtotCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fQtotCF->GetNVar()-2; ++iv) valuesQtotCF[iv] = values[fQtotCFVars[iv]];\r
-             valuesQtotCF[fQtotCF->GetNVar()-2] = values[kTrackQtot+iPlane];\r
-             valuesQtotCF[fQtotCF->GetNVar()-1] = iPlane;\r
-             fQtotCF->Fill(valuesQtotCF, 0);\r
-           }\r
-       }\r
-        for(Int_t iSlice=0; iSlice<8; iSlice++) {\r
-         if(esdTrack->GetTRDslice(iPlane, iSlice)>20.) {\r
-           values[kTrackPHslice+iSlice] =  fgkQs*esdTrack->GetTRDslice(iPlane, iSlice);\r
-           h = (TH2F*)fHistos->At(kPHSlice); h->Fill(iSlice, values[kTrackPHslice+iSlice]);\r
-           h = (TH2F*)fHistos->At(kPHSlice+centralityClass); h->Fill(iSlice, values[kTrackPHslice+iSlice]);\r
-           for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-             values[kEventTrigger] = triggerIndices[itrig];\r
-             if((fPulseHeightCF->GetVar("trigger")<0 && itrig==0) || (fPulseHeightCF->GetVar("trigger")>=0)) {\r
-               for(Int_t iv=0; iv<fPulseHeightCF->GetNVar()-2; ++iv) valuesPHCF[iv] = values[fPulseHeightCFVars[iv]];\r
-               valuesPHCF[fPulseHeightCF->GetNVar()-2] = values[kTrackPHslice+iSlice];\r
-               valuesPHCF[fPulseHeightCF->GetNVar()-1] = iSlice;\r
-               fPulseHeightCF->Fill(valuesPHCF, 0);\r
-             }\r
-           }\r
-         }\r
-       }\r
-      }\r
-      values[kTrackPhi] = localSagitaPhi[0];\r
-            \r
-      if(localCoordGood[0] && localMomGood[0]) {\r
-       for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-         values[kEventTrigger] = triggerIndices[itrig];\r
-         if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-           fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 1);\r
-         }\r
-         if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-           for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-           fMatchingPtCF->Fill(valuesMatchingPtCF, 1);\r
-         }\r
-         if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)\r
-           if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-             fBunchCrossingsCF->Fill(valuesBCCF, 1);\r
-           }\r
-         if(fExpertCF) {\r
-           if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {\r
-             if(fExpertCF->GetStep("TRD")>=0 && fExpertCF->GetStep("TRD")<3) {\r
-               for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-               fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TRD"));\r
-             }\r
-           }\r
-         } \r
-       }\r
-        if(Bool_t(status & AliESDtrack::kTOFpid)) {\r
-         for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {\r
-           values[kEventTrigger] = triggerIndices[itrig];\r
-           if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];\r
-             fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 2);\r
-           }\r
-           if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {\r
-             for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];\r
-             fMatchingPtCF->Fill(valuesMatchingPtCF, 2);\r
-           }\r
-           if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)\r
-             if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {\r
-               for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];\r
-               fBunchCrossingsCF->Fill(valuesBCCF, 2);\r
-             }\r
-           if(fExpertCF) {\r
-             if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {\r
-               if(fExpertCF->GetStep("TOF")>=0 && fExpertCF->GetStep("TOF")<3) {\r
-                 for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];\r
-                 fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TOF"));\r
-               }\r
-             }\r
-           }\r
-         }\r
-       }\r
-      }\r
-    }  // end if nTRDtrkl>=1\r
-    \r
-    // look at external track param\r
-    const AliExternalTrackParam *op = esdTrack->GetOuterParam();\r
-    const AliExternalTrackParam *ip = esdTrack->GetInnerParam();\r
-\r
-    Double_t pt(0.), pt0(0.), ptTRD(0.); \r
-    // read MC info if available\r
-    Bool_t kFOUND(kFALSE), kPhysPrim(kFALSE);\r
-    AliMCParticle *mcParticle(NULL);\r
-    if(HasMC()){\r
-      AliTrackReference *ref(NULL); \r
-      Int_t fLabel(esdTrack->GetLabel());\r
-      Int_t fIdx(TMath::Abs(fLabel));\r
-      if(!fStack || fIdx > fStack->GetNtrack()) continue; \r
-      \r
-      // read MC particle \r
-      if(!(mcParticle = (AliMCParticle*) fMC->GetTrack(fIdx))) {\r
-        AliWarning(Form("MC particle missing. Label[ %d].", fLabel));\r
-        continue;\r
-      }\r
-  \r
-      pt   = esdTrack->Pt();\r
-      pt0  = mcParticle->Pt();\r
-      //Double_t eta0 = mcParticle->Eta();\r
-      //Double_t phi0 = mcParticle->Phi();\r
-      kPhysPrim = fMC->IsPhysicalPrimary(fIdx);\r
-\r
-      // read track references\r
-      Int_t nRefs = mcParticle->GetNumberOfTrackReferences();\r
-      if(!nRefs){\r
-        AliWarning(Form("No TR found for track @ Label[%d].", fLabel));\r
-        continue;\r
-      }\r
-      Int_t iref = 0;\r
-      while(iref<nRefs){\r
-        ref = mcParticle->GetTrackReference(iref);\r
-        if(ref->LocalX() > fgkxTPC) break;\r
-        ref=NULL; iref++;\r
-      }\r
-      if(ref){ \r
-        if(ref->LocalX() > fgkxTOF){ // track skipping TRD fiducial volume\r
-          ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));\r
-        }\r
-      } else { // track stopped in TPC \r
-        ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));\r
-      }\r
-      ptTRD = ref->Pt();kFOUND=kTRUE;\r
-    } else { // use reconstructed values\r
-      if(op){\r
-        Double_t x(op->GetX());\r
-        if(x<fgkxTOF && x>fgkxTPC){\r
-          ptTRD=op->Pt();\r
-          kFOUND=kTRUE;\r
-        }\r
-      }\r
-\r
-      if(!kFOUND && ip){\r
-        ptTRD=ip->Pt();\r
-        kFOUND=kTRUE;\r
-      }\r
-    }     // end if(HasMC())\r
-\r
-    if(kFOUND){\r
-      h = (TH2I*)fHistos->At(kTRDstat);\r
-      if(status & AliESDtrack::kTPCout) h->Fill(ptTRD, kTPCout);\r
-      if(status & AliESDtrack::kTRDin) h->Fill(ptTRD, kTRDin);\r
-      if(kBarrel && (status & AliESDtrack::kTRDout)) h->Fill(ptTRD, kTRDout);\r
-      if(kBarrel && (status & AliESDtrack::kTRDpid)) h->Fill(ptTRD, kTRDpid);\r
-      if(kBarrel && (status & AliESDtrack::kTRDrefit)) h->Fill(ptTRD, kTRDref);\r
-    }\r
-    Int_t idx(HasMC() ? Pdg2Idx(TMath::Abs(mcParticle->PdgCode())): 0)\r
-         ,sgn(esdTrack->Charge()<0?0:1);\r
-    if(kBarrel && kPhysPrim) {\r
-      TH3 *h3 = (TH3S*)fHistos->At(kPtRes);\r
-      Int_t offset = (status & AliESDtrack::kTRDrefit) ? 0 : 10; \r
-      h3->Fill(pt0, 1.e2*(pt/pt0-1.), \r
-        offset + 2*idx + sgn);\r
-    }\r
-    ((TH1*)fHistos->At(kNCl))->Fill(esdTrack->GetTRDncls(), 2*idx + sgn);\r
-    if(ip){\r
-      h = (TH2I*)fHistos->At(kTRDmom);\r
-      Float_t pTRD(0.);\r
-      for(Int_t ily=6; ily--;){\r
-        if((pTRD=esdTrack->GetTRDmomentum(ily))<0.) continue;\r
-        h->Fill(ip->GetP()-pTRD, ily);\r
-      }\r
-    }\r
-  }  // end loop over tracks\r
-  \r
-  \r
-  triggers->Delete(); delete triggers;\r
-  delete [] valuesMatchingPhiEtaCF;\r
-  delete [] valuesMatchingPtCF;\r
-  delete [] valuesBCCF;\r
-  delete [] valuesCentCF;\r
-  delete [] valuesQtotCF;\r
-  delete [] valuesPHCF;\r
-  if(valuesExpertCF) delete [] valuesExpertCF;\r
-  \r
-  PostData(1, fHistos);\r
-}\r
-\r
-//____________________________________________________________________\r
-TObjArray* AliTRDcheckESD::Histos()\r
-{\r
-// Retrieve histograms array if already build or build it\r
-\r
-  if(fHistos) return fHistos;\r
-\r
-  fHistos = new TObjArray(kNhistos+1);\r
-  fHistos->SetOwner(kTRUE);\r
-\r
-  TH1 *h = NULL;\r
-\r
-  // clusters per track\r
-  const Int_t kNpt(30);\r
-  Float_t pt(0.2);\r
-  Float_t binsPt[kNpt+1];\r
-  for(Int_t i=0;i<kNpt+1; i++,pt+=(TMath::Exp(i*i*.001)-1.)) binsPt[i]=pt;\r
-  if(!(h = (TH2I*)gROOT->FindObject("hNCl"))){\r
-    h = new TH2I("hNCl", "Clusters per TRD track;N_{cl}^{TRD};SPECIES;entries", 60, 0., 180., 10, -0.5, 9.5);\r
-    TAxis *ay(h->GetYaxis());\r
-    ay->SetLabelOffset(0.015);\r
-    for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-      ay->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      ay->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-    }\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNCl); fNRefFigures++;\r
-\r
-  // status bits histogram\r
-  const Int_t kNbits(5);\r
-  Float_t bits(.5);\r
-  Float_t binsBits[kNbits+1];\r
-  for(Int_t i=0; i<kNbits+1; i++,bits+=1.) binsBits[i]=bits;\r
-  if(!(h = (TH2I*)gROOT->FindObject("hTRDstat"))){\r
-    h = new TH2I("hTRDstat", "TRD status bits;p_{t} @ TRD [GeV/c];status;entries", kNpt, binsPt, kNbits, binsBits);\r
-    TAxis *ay(h->GetYaxis());\r
-    ay->SetBinLabel(1, "kTPCout");\r
-    ay->SetBinLabel(2, "kTRDin");\r
-    ay->SetBinLabel(3, "kTRDout");\r
-    ay->SetBinLabel(4, "kTRDpid");\r
-    ay->SetBinLabel(5, "kTRDrefit");\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTRDstat);\r
-\r
-  // energy loss\r
-  if(!(h = (TH2I*)gROOT->FindObject("hTRDmom"))){\r
-    h = new TH2I("hTRDmom", "TRD energy loss;p_{inner} - p_{ly} [GeV/c];ly;entries", 100, -1., 2., 6, -0.5, 5.5);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTRDmom);\r
-  //if(!HasMC()) return fHistos;\r
-\r
-  // pt resolution\r
-  const Int_t kNdpt(100), kNspec(4*AliPID::kSPECIES);\r
-  Float_t dpt(-3.), spec(-0.5);\r
-  Float_t binsDPt[kNdpt+1], binsSpec[kNspec+1];\r
-  for(Int_t i=0; i<kNdpt+1; i++,dpt+=6.e-2) binsDPt[i]=dpt;\r
-  for(Int_t i=0; i<kNspec+1; i++,spec+=1.) binsSpec[i]=spec;\r
-  if(!(h = (TH3S*)gROOT->FindObject("hPtRes"))){\r
-    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);\r
-    TAxis *az(h->GetZaxis());\r
-    az->SetLabelOffset(0.015);\r
-    for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-      az->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(10+2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i)));\r
-      az->SetBinLabel(10+2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i)));\r
-    }\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPtRes);\r
-\r
-  // TPC event vertex distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hTPCVertex"))){\r
-    h = new TH1F("hTPCVertex", "Event vertex Z coord. from TPC tracks", 100, -25., 25.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTPCVertex);\r
-  \r
-  // Event vertex\r
-  if(!(h = (TH1F*)gROOT->FindObject("hEventVertex"))){\r
-    h = new TH1F("hEventVertex", "Event vertex Z coord.", 100, -25., 25.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEventVertex);\r
-  \r
-  // Number of all tracks\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAll"))){\r
-    h = new TH1I("hNTracksAll", "Number of tracks per event, event vertex cuts", 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksAll);\r
-  \r
-  // Number of tracks in acceptance and DCA cut\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksAcc"))){\r
-    h = new TH1I("hNTracksAcc", Form("Number of tracks per event, |#eta|<%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                                    fgkEta, fgkTrkDCAxy, fgkTrkDCAz), 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksAcc);\r
-  \r
-  // Number of tracks in TPC (Ncls>10)\r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTracksTPC"))){\r
-    h = new TH1I("hNTracksTPC", Form("Number of tracks per event, |#eta|<%.1f, pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                    fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 5000, 0, 5000);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTracksTPC);\r
-  \r
-  // Distribution of DCA-xy\r
-  if(!(h = (TH1F*)gROOT->FindObject("hDCAxy"))){\r
-    h = new TH1F("hDCAxy", "Distribution of transverse DCA", 100, -100., 100.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kDCAxy);\r
-  \r
-  // Distribution of DCA-z\r
-  if(!(h = (TH1F*)gROOT->FindObject("hDCAz"))){\r
-    h = new TH1F("hDCAz", "Distribution of longitudinal DCA", 100, -100., 100.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kDCAz);\r
-  \r
-  Double_t binPtLimits[33] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,\r
-                            1.0, 1.1, 1.2, 1.3, 1.4, \r
-                            1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0,\r
-                            3.4, 3.8, 4.2, 4.6, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};\r
-  // Pt distributions\r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt1"))){\r
-    h = new TH1F("hPt1", Form("dN/dpt, |#eta|<%.1f and pt>%.1f", fgkEta, fgkPt), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt1);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt2"))){\r
-    h = new TH1F("hPt2", Form("dN/dpt, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                             fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt2);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt3pos"))){\r
-    h = new TH1F("hPt3pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt3pos);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt3neg"))){\r
-    h = new TH1F("hPt3neg", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt3neg);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt4pos"))){\r
-    h = new TH1F("hPt4pos", Form("dN/dpt (positives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt4pos);\r
-  \r
-  if(!(h = (TH1F*)gROOT->FindObject("hPt4neg"))){\r
-    h = new TH1F("hPt4pos", Form("dN/dpt (negatives), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 32, binPtLimits);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPt4neg);\r
-  \r
-  // theta distribution of TRD tracks\r
-  if(!(h = (TH1F*)gROOT->FindObject("hTheta"))){\r
-    h = new TH1F("hTheta", Form("dN/d#theta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 220,.5,2.7);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTheta);\r
-  \r
-  // phi distribution of TRD tracks\r
-  if(!(h = (TH1F*)gROOT->FindObject("hPhi"))){\r
-    h = new TH1F("hPhi", Form("dN/d#varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq 1",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 157,0,6.28);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPhi);\r
-  \r
-  // TPC cluster distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hNTPCCl"))){\r
-    h = new TH1I("hNTPCCl", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTPCCl);\r
-  \r
-  if(!(h = (TH1I*)gROOT->FindObject("hNTPCCl2"))){\r
-    h = new TH1F("hNTPCCl2", Form("Number of TPC clusters/track, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, pt>1.0 GeV/c",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 160, 0, 160);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kNTPCCl2);\r
-  \r
-  // dE/dx vs P for TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hTPCDedx"))){\r
-    h = new TH2F("hTPCDedx", Form("TPC dE/dx vs P, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 150, 0, 150.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kTPCDedx);\r
-  \r
-  // eta,phi distribution of TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hEtaPhi"))){\r
-    h = new TH2F("hEtaPhi", Form("TPC (#eta,#varphi), |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 50, -1, 1, 157, 0, 6.28);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEtaPhi);\r
-  \r
-  // Nclusters vs eta distribution for TPC tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hEtaNclsTPC"))){\r
-    h = new TH2F("hEtaNclsTPC", Form("TPC Nclusters vs. #eta, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 50, -1, 1, 160, 0, 160.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kEtaNclsTPC);\r
-  \r
-  // Nclusters vs phi distribution for TPC reference tracks\r
-  if(!(h = (TH2F*)gROOT->FindObject("hPhiNclsTPC"))){\r
-    h = new TH2F("hPhiNclsTPC", Form("TPC Nclusters vs. #varphi, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz), 157, 0, 6.28, 160, 0, 160.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPhiNclsTPC);\r
-\r
-  // SPD multiplicity distribution\r
-  if(!(h = (TH1F*)gROOT->FindObject("hSPDMult"))){\r
-    h = new TH1F("hSPDMult", "SPD multiplicity", 10000, -0.5, 9999.5);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kSPDMult);\r
-\r
-  // Ntracklets/track vs P for TRD reference tracks\r
-  Double_t binsP[19] = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0,\r
-                       2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hNTrackletsTRD_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hNTrackletsTRD_cent%d",iCent+1), Form("TRD Ntracklets/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                                              iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 7, -0.5, 6.5);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kNTrackletsTRD+iCent);\r
-  }\r
-  \r
-  // Nclusters/track vs P for TRD reference tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hNClsTrackTRD_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hNClsTrackTRD_cent%d",iCent+1), Form("TRD Nclusters/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                                             iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 300, 0., 300.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kNClsTrackTRD+iCent);\r
-  }  \r
-\r
-  // <PH> vs slice number for TRD reference tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSlice_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSlice_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                   iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 200, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSlice+iCent);\r
-  }\r
-\r
-  // <PH> vs slice number for TRD reference tracklets, from TPC pions\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCpions_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSliceTPCpions_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC pions",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSliceTPCpions+iCent);\r
-  }\r
-\r
-  // TPC dE/dx vs P for TRD reference tracks, pions\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxPions_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hTPCdedxPions_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC pions, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                        iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCdedxPions+iCent);\r
-  }\r
-\r
-  // <PH> vs slice number for TRD reference tracklets, from TPC electrons\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCelectrons_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hPHSliceTPCelectrons_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d,|#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC electrons",\r
-                                               iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kPHSliceTPCelectrons+iCent);\r
-  }\r
-\r
-  // TPC dE/dx vs P for TRD reference tracks, electrons\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxElectrons_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hTPCdedxElectrons_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC electrons, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                            iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCdedxElectrons+iCent);\r
-  }\r
-\r
-  // Qtot vs P for TRD reference tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH2F*)gROOT->FindObject(Form("hQtotP_cent%d",iCent+1)))){\r
-      h = new TH2F(Form("hQtotP_cent%d",iCent+1), Form("Qtot(from slices) vs P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 400, 0., 20);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kQtotP+iCent);\r
-  }\r
-  \r
-  // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-  if(!(h = (TH3F*)gROOT->FindObject("hPropagXYvsP"))){\r
-    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",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-500,500, 100,-500,500, 10, 0.,10.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPropagXYvsP);\r
-  \r
-  // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-  if(!(h = (TH3F*)gROOT->FindObject("hPropagRZvsP"))){\r
-    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",\r
-                fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100,-350., 350., 100,0.,500., 10, 0.,10.);\r
-  } else h->Reset();\r
-  fHistos->AddAt(h, kPropagRZvsP);\r
-  \r
-  Double_t etaBinLimits[101];  \r
-  for(Int_t i=0; i<101; i++) etaBinLimits[i] = -1.0 + i*2.0/100.;\r
-  Double_t phiBinLimits[151];\r
-  for(Int_t i=0; i<151; i++) phiBinLimits[i] = -1.1*TMath::Pi() + i*2.2*TMath::Pi()/150.;\r
-  // (eta,detector phi,P) distribution of reference TPC positive tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksPos_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTPCRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCRefTracksPos+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TPC negative tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksNeg_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTPCRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTPCRefTracksNeg+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 4 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos4_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos4+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 5 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos5_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos5+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD positive tracks with 6 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos6_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksPos6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksPos6+iCent);\r
-  }\r
-  \r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 4 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg4_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg4+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 5 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg5_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg5+iCent);\r
-  }\r
-\r
-  // (eta,detector phi,P) distribution of reference TRD negative tracks with 6 tracklets\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg6_cent%d",iCent+1)))){\r
-      h = new TH3F(Form("hTRDRefTracksNeg6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDRefTracksNeg6+iCent);\r
-  }\r
-\r
-\r
-  // (eta,detector phi) profile of average number of TRD tracklets/track\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1)))){\r
-      h = new TProfile2D(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta,detector #varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDEtaPhiAvNtrkl+iCent);\r
-  }\r
-\r
-  // (eta,delta phi) profile of average number of TRD tracklets/track\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1)))){\r
-      h = new TProfile2D(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta, #Delta#varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                                                       iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 50, -0.4*TMath::Pi(), 0.4*TMath::Pi());\r
-    } else h->Reset();\r
-    fHistos->AddAt(h, kTRDEtaDeltaPhiAvNtrkl+iCent);\r
-  }  \r
-\r
-  // (eta, detector phi) profile of average tracklet Qtot from slices\r
-  for(Int_t iCent=0; iCent<=5; ++iCent) {\r
-    for(Int_t iLayer=0;iLayer<6;iLayer++) {\r
-      if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1)))) {\r
-       h = new TProfile2D(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1),\r
-                          Form("<Q_{tot}> vs (#eta, detector #varphi) for TRD reference tracks (layer %d), centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",\r
-                               iLayer, iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, -1.0, 1.0, 150, -1.1*TMath::Pi(), 1.1*TMath::Pi());\r
-      } else h->Reset();\r
-      fHistos->AddAt(h, kTRDEtaPhiAvQtot+iCent*6+iLayer);\r
-    }\r
-  }\r
-  \r
-  // Trigger definitions\r
-  if(!(h=(TH1F*)gROOT->FindObject("hTriggerDefs"))) {\r
-    h = new TH1F("hTriggerDefs", "Trigger definitions", kNMaxAssignedTriggers, 0.5, 0.5+Float_t(kNMaxAssignedTriggers));\r
-  }\r
-  else h->Reset();\r
-  fHistos->AddAt(h, kTriggerDefs);\r
-\r
-  // dummy histo\r
-  if(!(h=(TH1F*)gROOT->FindObject("hDummy"))) {\r
-    h = new TH1F("hDummy", "Dummy hist", 10, 0., 1.);\r
-  }\r
-  else h->Reset();\r
-  fHistos->AddAt(h, 0);\r
-  \r
-  fMatchingPhiEtaCF = CreateCFContainer("MatchingPhiEta", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fMatchingPhiEtaCF, kMatchingPhiEtaCF);\r
-  fMatchingPtCF = CreateCFContainer("MatchingPt", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fMatchingPtCF, kMatchingPtCF);\r
-  fBunchCrossingsCF = CreateCFContainer("BunchCrossingsCF", "CF container with bunch crossings dependent data");\r
-  fHistos->AddAt(fBunchCrossingsCF, kBunchCrossingsCF);\r
-  fCentralityCF = CreateCFContainer("CentralityCF", "CF container with TRD-TPC matching data");\r
-  fHistos->AddAt(fCentralityCF, kCentralityCF);\r
-  fQtotCF = CreateCFContainer("QtotCF", "CF container with TRD tracklet charge data");\r
-  fHistos->AddAt(fQtotCF, kQtotCF);\r
-  fPulseHeightCF = CreateCFContainer("PulseHeightCF", "CF container with TRD tracklet PH data");\r
-  fHistos->AddAt(fPulseHeightCF, kPulseHeightCF);\r
-  fExpertCF = CreateCFContainer("ExpertCF", "CF container with customized information");\r
-  if(fExpertCF) fHistos->AddAt(fExpertCF, kExpertCF);\r
-  \r
-  return fHistos;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-void AliTRDcheckESD::InitializeCFContainers() {\r
-  //\r
-  //  Initialize the CF container\r
-  //\r
-  AliAnalysisManager* man=AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());\r
-  if(!inputHandler) return;\r
-  \r
-  AliPhysicsSelection* physSel = (AliPhysicsSelection*)inputHandler->GetEventSelection();\r
-  const TList* trigList = (physSel ? physSel->GetCollisionTriggerClasses() : 0x0);\r
-  const TList* bgTrigList = (physSel ? physSel->GetBGTriggerClasses() : 0x0);\r
-  \r
-  // Add collision triggers from PhysicsSelection\r
-  if(trigList) {\r
-    for(Int_t it=0; it<trigList->GetEntries(); ++it) {\r
-      TString trigName = trigList->At(it)->GetName();\r
-      TObjArray* arr = trigName.Tokenize(" ");\r
-      trigName = arr->At(0)->GetName();\r
-      trigName.Remove(0,1);\r
-      TObjArray* arr2 = trigName.Tokenize(",");\r
-      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {\r
-        // Assign an index into the trigger histogram and the CF container for this trigger\r
-        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);\r
-      }\r
-      arr2->Delete(); delete arr2;\r
-      arr->Delete(); delete arr;\r
-    }\r
-  }\r
-  // Add background triggers from PhysicsSelection\r
-  if(bgTrigList) {\r
-    for(Int_t it=0; it<bgTrigList->GetEntries(); ++it) {\r
-      TString trigName = bgTrigList->At(it)->GetName();\r
-      TObjArray* arr = trigName.Tokenize(" ");\r
-      trigName = arr->At(0)->GetName();\r
-      trigName.Remove(0,1);\r
-      TObjArray* arr2 = trigName.Tokenize(",");\r
-      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {\r
-        // Assign an index into the trigger histogram and the CF container for this trigger\r
-        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);\r
-      }\r
-      arr2->Delete(); delete arr2;\r
-      arr->Delete(); delete arr;\r
-    }\r
-  }\r
-  if(!fNAssignedTriggers) {GetTriggerIndex("All triggers", kTRUE);}\r
-  \r
-  // Add user enabled triggers\r
-  TObjArray* arr = fUserEnabledTriggers.Tokenize(";");\r
-  for(Int_t it=0; it<arr->GetEntries(); ++it) {\r
-    GetTriggerIndex(arr->At(it)->GetName(), kTRUE);\r
-  }\r
-  arr->Delete(); delete arr;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-AliCFContainer* AliTRDcheckESD::CreateCFContainer(const Char_t* name, const Char_t* title) {\r
-  //\r
-  //  make a CF container\r
-  //\r
-  // create a CF container and add it to the list of histograms\r
-  Int_t nbinsCf[kNTrdCfVariables];\r
-  for(Int_t i=0;i<kNTrdCfVariables;++i) nbinsCf[i]=0;\r
-  nbinsCf[kEventVtxZ]         =    5;\r
-  nbinsCf[kEventMult]         =    5;\r
-  nbinsCf[kEventTrigger]      =    kNMaxAssignedTriggers;\r
-  nbinsCf[kEventBC]           = 3500;\r
-  nbinsCf[kTrackTOFBC]        =    2;\r
-  nbinsCf[kTrackDCAxy]        =    9;\r
-  nbinsCf[kTrackDCAz]         =    5;\r
-  nbinsCf[kTrackCharge]       =    2;\r
-  nbinsCf[kTrackPhi]          =  180;\r
-  nbinsCf[kTrackEta]          =   90;\r
-  nbinsCf[kTrackPt]           =   18;\r
-  nbinsCf[kTrackP]            =   17;\r
-  nbinsCf[kTrackTrdTracklets] =    7;\r
-  nbinsCf[kTrackTrdClusters]  =  200;\r
-  for(Int_t i=0;i<6;++i) nbinsCf[kTrackQtot+i] = 100;\r
-  for(Int_t i=0;i<8;++i) nbinsCf[kTrackPHslice+i] = 400;\r
-  //Double_t evVtxLims[2]      = {-10.,+10.};\r
-  Double_t evMultLims[6]     = {0.0, 700., 1400., 2100., 2800., 3500.};\r
-  //Double_t evTriggerLims[2]  = {0.5, 0.5+Float_t(kNMaxAssignedTriggers)};\r
-  Double_t evBCLims[2]       = {-0.5, +3499.5};\r
-  //Double_t trkTOFBClims[3]   = {-0.5, 0.5, 5.5};\r
-  //Double_t trkDCAxyLims[10]  = {-10.0,  -6.0, -3.0,  -2.0,  -1.0,   \r
-  //                               +1.0, +2.0,  +3.0,  +6.0, +10.0};    \r
-  //Double_t trkDCAzLims[2]    = {-15.0, +15.0};    \r
-  Double_t trkChargeLims[2]  = {-1.5, +1.5};\r
-  Double_t trkPhiLims[2]     = {-1.001*TMath::Pi(), +1.001*TMath::Pi()};\r
-  Double_t trkEtaLims[2]     = {-0.9, +0.9};\r
-  Double_t trkPtLims[19]     = {0.0, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, \r
-                                3.5, 4.0, 4.5,  5.0, 6.0,  7.0, 8.0,  9.0, 10.0};\r
-  Double_t trkPLims[18]      = {0.0, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.7, 2.0, 2.5, \r
-                                3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 9.0, 12.0};\r
-  Double_t trkTrdNLims[2]    = {-0.5, 6.5};\r
-  Double_t trkTrdNclsLims[2] = {-0.5, 199.5};\r
-  Double_t trkQtotLims[2]    = {0.0, 20.};\r
-  /*Double_t trkQtotLims[20]   = {0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0,\r
-                                5.5, 6.0, 6.5, 7.0, 8.0, 9.0,10.0,12.0,15.0,20.0};*/\r
-  const Char_t* varNames[kNTrdCfVariables] = {"vtxZ", "multiplicity", "trigger", "BC", "TOFBC", "DCAxy", "DCAz",\r
-    "charge", "phi", "eta", "pt", "P", "tracklets", "clusters", \r
-    "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7",\r
-    "Qtot0", "Qtot1", "Qtot2", "Qtot3", "Qtot4", "Qtot5"};\r
-  \r
-  AliCFContainer* cf;\r
-  TString nameStr=name;\r
-  if(nameStr.Contains("MatchingPhiEta")) {\r
-    fMatchingPhiEtaCFVars[0] = kTrackCharge;       fMatchingPhiEtaCFVars[1] = kTrackPhi; fMatchingPhiEtaCFVars[2] = kTrackEta;\r
-    fMatchingPhiEtaCFVars[3] = kTrackTrdTracklets;\r
-    const Int_t nVars = 4;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPhiEtaCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, trkChargeLims[0], trkChargeLims[1]);\r
-    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(2, trkEtaLims[0], trkEtaLims[1]);\r
-    cf->SetBinLimits(3, trkTrdNLims[0], trkTrdNLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPhiEtaCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("MatchingPt")) {\r
-    fMatchingPtCFVars[0] = kEventMult; fMatchingPtCFVars[1] = kTrackCharge;        fMatchingPtCFVars[2] = kTrackPhi; \r
-    fMatchingPtCFVars[3] = kTrackPt;   fMatchingPtCFVars[4] = kTrackTrdTracklets;\r
-    const Int_t nVars = 5;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPtCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, evMultLims);\r
-    cf->SetBinLimits(1, trkChargeLims[0], trkChargeLims[1]);\r
-    cf->SetBinLimits(2, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(3, trkPtLims);\r
-    cf->SetBinLimits(4, trkTrdNLims[0], trkTrdNLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPtCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("BunchCrossings")) {\r
-    fBunchCrossingsCFVars[0] = kEventBC; fBunchCrossingsCFVars[1] = kTrackPhi;\r
-    const Int_t nVars = 2;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fBunchCrossingsCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 3, nVars, nBins);\r
-    cf->SetBinLimits(0, evBCLims[0], evBCLims[1]);\r
-    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fBunchCrossingsCFVars[i]]);\r
-    cf->SetStepTitle(0, "TPC");\r
-    cf->SetStepTitle(1, "TRD");\r
-    cf->SetStepTitle(2, "TOF");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Centrality")) {\r
-    fCentralityCFVars[0] = kEventMult; fCentralityCFVars[1] = kTrackP; fCentralityCFVars[2] = kTrackTrdClusters; \r
-    fCentralityCFVars[3] = kTrackQtot;\r
-    const Int_t nVars = 4;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fCentralityCFVars[i]];\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    cf->SetBinLimits(0, evMultLims);\r
-    cf->SetBinLimits(1, trkPLims);\r
-    cf->SetBinLimits(2, trkTrdNclsLims[0], trkTrdNclsLims[1]);\r
-    cf->SetBinLimits(3, trkQtotLims[0], trkQtotLims[1]);\r
-    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fCentralityCFVars[i]]);\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Qtot")) {\r
-    fQtotCFVars[0] = kTrackPhi; fQtotCFVars[1] = kTrackEta; fQtotCFVars[2] = kTrackQtot; \r
-    const Int_t nVars = 4;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fQtotCFVars[i]];\r
-    nBins[2] = 50;\r
-    nBins[nVars-1] = 6;\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    cf->SetBinLimits(0, trkPhiLims[0], trkPhiLims[1]);\r
-    cf->SetBinLimits(1, trkEtaLims[0], trkEtaLims[1]);\r
-    cf->SetBinLimits(2, trkQtotLims[0], trkQtotLims[1]);\r
-    cf->SetBinLimits(3, -0.5, 5.5);\r
-    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fQtotCFVars[i]]);\r
-    cf->SetVarTitle(nVars-1, "layer");\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("PulseHeight")) {\r
-    fPulseHeightCFVars[0] = kTrackP; fPulseHeightCFVars[1] = kTrackPHslice; \r
-    const Int_t nVars = 3;\r
-    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fPulseHeightCFVars[i]];\r
-    nBins[nVars-1] = 8;\r
-    cf = new AliCFContainer(name, title, 1, nVars, nBins);\r
-    //cf->SetBinLimits(0, evTriggerLims[0], evTriggerLims[1]);\r
-    cf->SetBinLimits(0, trkPLims);\r
-    cf->SetBinLimits(1, trkQtotLims[0], trkQtotLims[1]);\r
-    cf->SetBinLimits(2, -0.5, 7.5);\r
-    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fPulseHeightCFVars[i]]);\r
-    cf->SetVarTitle(nVars-1, "slice");\r
-    cf->SetStepTitle(0, "TRD");\r
-    return cf;\r
-  }\r
-  if(nameStr.Contains("Expert")) {\r
-    Int_t nVars = 0;\r
-    Int_t nBins[kNTrdCfVariables];\r
-    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {\r
-      if(!fExpertCFVarsEnabled[ivar]) continue;\r
-      if(fExpertCFVarBins[ivar][0]=='\0') {\r
-       nBins[nVars] = fExpertCFVarNBins[ivar];\r
-       nVars++;\r
-      }\r
-      else {\r
-        TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");\r
-        nBins[nVars] = arr->GetEntries()-1;\r
-        if(nBins[nVars]>0) nVars++;\r
-        arr->Delete(); delete arr;\r
-      }\r
-    }\r
-    if(nVars<1) return 0x0;\r
-    Int_t nSteps = 0; for(Int_t i=0; i<3; ++i) if(fExpertCFEnabledSteps[i]) nSteps++;\r
-    if(nSteps<1) return 0x0;\r
-    cf = new AliCFContainer(name, title, nSteps, nVars, nBins);\r
-    Int_t iUsedVar = 0;\r
-    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {\r
-      if(!fExpertCFVarsEnabled[ivar]) continue;\r
-      if(fExpertCFVarBins[ivar][0]=='\0'){\r
-        cf->SetBinLimits(iUsedVar, fExpertCFVarRanges[ivar][0], fExpertCFVarRanges[ivar][1]);\r
-      } else {\r
-        TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");\r
-        if(arr->GetEntries()-1>0) {\r
-          Double_t* binLims = new Double_t[arr->GetEntries()];\r
-          for(Int_t ib=0;ib<arr->GetEntries();++ib) {\r
-            TString binStr = arr->At(ib)->GetName();\r
-            binLims[ib] = binStr.Atof();\r
-          }\r
-          cf->SetBinLimits(iUsedVar++, binLims);\r
-        }\r
-        arr->Delete(); delete arr;\r
-      }\r
-      cf->SetVarTitle(iUsedVar, varNames[ivar]);\r
-    }\r
-    const Char_t* stepNames[3] = {"TPC","TRD","TOF"};\r
-    Int_t iUsedStep = 0;\r
-    for(Int_t istep=0; istep<3; ++istep) {\r
-      if(fExpertCFEnabledSteps[istep]) cf->SetStepTitle(iUsedStep++, stepNames[istep]);\r
-    }\r
-    return cf;\r
-  }  \r
-  return 0x0;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-Bool_t AliTRDcheckESD::Load(const Char_t *file, const Char_t *dir, const Char_t *name)\r
-{\r
-// Load data from performance file\r
-\r
-  if(!TFile::Open(file)){\r
-    AliWarning(Form("Couldn't open file %s.", file));\r
-    return kFALSE;\r
-  }\r
-  if(dir){\r
-    if(!gFile->cd(dir)){\r
-      AliWarning(Form("Couldn't cd to %s in %s.", dir, file));\r
-      return kFALSE;\r
-    }\r
-  }\r
-  TObjArray *o(NULL);\r
-  const Char_t *tn=(name ? name : GetName());\r
-  if(!(o = (TObjArray*)gDirectory->Get(tn))){\r
-    AliWarning(Form("Missing histogram container %s.", tn));\r
-    return kFALSE;\r
-  }\r
-  fHistos = (TObjArray*)o->Clone(GetName());\r
-  fMatchingPhiEtaCF = (AliCFContainer*)fHistos->At(kMatchingPhiEtaCF);\r
-  fMatchingPtCF = (AliCFContainer*)fHistos->At(kMatchingPtCF);\r
-  fBunchCrossingsCF = (AliCFContainer*)fHistos->At(kBunchCrossingsCF);\r
-  fCentralityCF = (AliCFContainer*)fHistos->At(kCentralityCF);\r
-  fQtotCF = (AliCFContainer*)fHistos->At(kQtotCF);\r
-  fPulseHeightCF = (AliCFContainer*)fHistos->At(kPulseHeightCF);\r
-  fExpertCF = (AliCFContainer*)fHistos->At(kExpertCF);\r
-  \r
-  /*\r
-  TObjArray *cfs(NULL);\r
-  if(!(cfs = (TObjArray*)gDirectory->Get(Form("%s_CF", tn)))){\r
-    AliWarning(Form("Missing CFs container %s_CF.", tn));\r
-    fCfList = NULL;\r
-    //return kFALSE;\r
-  } \r
-  else\r
-    fCfList = (TObjArray*)cfs->Clone(Form("%s_CF_clone", GetName()));\r
-  */\r
-  \r
-  gFile->Close();\r
-  return kTRUE;\r
-}\r
-\r
-//_______________________________________________________\r
-Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val)\r
-{\r
-// Dump trending value to default file\r
-\r
-  if(!fgFile){\r
-    fgFile = fopen("TRD.Performance.txt", "at");\r
-  }\r
-  fprintf(fgFile, "%s_%s %f\n", GetName(), name, val);\r
-  return kTRUE;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::Terminate(Option_t *)\r
-{\r
-  // Steer post-processing \r
-  if(!fHistos){\r
-    fHistos = dynamic_cast<TObjArray *>(GetOutputData(1));\r
-    if(!fHistos){\r
-      AliError("Histogram container not found in output");\r
-      return;\r
-    }\r
-  }\r
-\r
-  //  fNRefFigures = 15;\r
-  //  return;\r
-\r
-  const Char_t *name[kNrefs] = {\r
-    "Ncl", "Eff", "Eloss", "PtResDCA"\r
-  };\r
-\r
-  TObjArray *arr(NULL); TGraph *g(NULL);\r
-  if(!fResults){\r
-    fResults = new TObjArray(kNrefs);\r
-    fResults->SetOwner();\r
-    fResults->SetName("results");\r
-    for(Int_t iref(0); iref<kNrefs; iref++){\r
-      fResults->AddAt(arr = new TObjArray(fgkNgraph[iref]), iref);\r
-      arr->SetName(name[iref]);  arr->SetOwner();\r
-      switch(iref+1){\r
-      case kNCl:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-          g->SetName(Form("s%d", ig));\r
-          switch(ig){\r
-          case 0: g->SetTitle("ALL"); break;\r
-          case 1: g->SetTitle("NEG"); break;\r
-          case 2: g->SetTitle("POS"); break;\r
-          default: g->SetTitle(AliPID::ParticleLatexName(ig-3)); break;\r
-          };\r
-        }\r
-        break;\r
-      case kTRDmom:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphAsymmErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-        }\r
-        break;\r
-      case kPtRes:\r
-       for(Int_t idx(0); idx<AliPID::kSPECIES; idx++){\r
-          Int_t ig(2*idx);\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(kRed-idx); \r
-          g->SetMarkerColor(kRed-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("s%d", ig), Form("res %s", AliPID::ParticleLatexName(idx)));\r
-          arr->AddAt(g = new TGraphErrors(), ig+1);\r
-          g->SetLineColor(kBlue-idx); \r
-          g->SetMarkerColor(kBlue-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("m%d", ig+1), Form("sys %s", AliPID::ParticleLatexName(idx)));\r
-\r
-          ig+=10;\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(kRed-idx); \r
-          g->SetMarkerColor(kRed-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("s%d", ig), Form("sigma %s", AliPID::ParticleLatexName(idx)));\r
-          arr->AddAt(g = new TGraphErrors(), ig+1);\r
-          g->SetLineColor(kBlue-idx); \r
-          g->SetMarkerColor(kBlue-idx); \r
-          g->SetMarkerStyle(20+idx); \r
-          g->SetNameTitle(Form("m%d", ig+1), Form("mean %s", AliPID::ParticleLatexName(idx)));\r
-        }\r
-        break;\r
-      default:\r
-       for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){\r
-          arr->AddAt(g = new TGraphErrors(), ig);\r
-          g->SetLineColor(ig+1); \r
-          g->SetMarkerColor(ig+1); \r
-          g->SetMarkerStyle(ig+20); \r
-        }\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  TH1 *h1[2] = {NULL, NULL};\r
-  TH2I *h2(NULL);\r
-  TAxis *ax(NULL);\r
-\r
-  // No of clusters\r
-  if(!(h2 = (TH2I*)fHistos->At(kNCl))) return;\r
-  ax = h2->GetXaxis();\r
-  arr = (TObjArray*)fResults->At(kNCl);\r
-  \r
-  // All tracks\r
-  h1[0] = h2->ProjectionX("Ncl_px");\r
-  TGraphErrors *ge(NULL);\r
-  if((ge=(TGraphErrors*)arr->At(0))){\r
-    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-      ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));\r
-    }\r
-  }\r
-\r
-  // All charged tracks\r
-  TH1 *hNclCh[2] = {(TH1D*)h1[0]->Clone("NEG"), (TH1D*)h1[0]->Clone("POS")};\r
-  hNclCh[0]->Reset();hNclCh[1]->Reset();\r
-  for(Int_t is(1); is<=AliPID::kSPECIES; is++){\r
-    hNclCh[0]->Add(h2->ProjectionX("Ncl_px", 2*is-1, 2*is-1)); // neg\r
-    hNclCh[1]->Add(h2->ProjectionX("Ncl_px", 2*is, 2*is));     // pos\r
-  }\r
-  if(Int_t(hNclCh[0]->GetEntries()) && (ge=(TGraphErrors*)arr->At(1))){\r
-    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-      ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[0]->GetBinContent(ib));\r
-    }\r
-  }\r
-  \r
-  if(Int_t(hNclCh[1]->GetEntries()) && (ge=(TGraphErrors*)arr->At(2))){\r
-    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-      ge->SetPoint(ib-2, ax->GetBinCenter(ib), hNclCh[1]->GetBinContent(ib));\r
-    }\r
-  }\r
-  // Species wise\r
-  for(Int_t is(1); is<=AliPID::kSPECIES; is++){\r
-    h1[0] = h2->ProjectionX("Ncl_px", 2*is-1, 2*is);\r
-    if(!Int_t(h1[0]->GetEntries())) continue;\r
-    if(!(ge=(TGraphErrors*)arr->At(2+is))) continue;\r
-    for(Int_t ib=2; ib<=ax->GetNbins(); ib++){\r
-      ge->SetPoint(ib-2, ax->GetBinCenter(ib), h1[0]->GetBinContent(ib));\r
-    }\r
-  }\r
-  \r
-  fNRefFigures = 1;\r
-\r
-  // EFFICIENCY\r
-  // geometrical efficiency\r
-  if(!(h2 = (TH2I*)fHistos->At(kTRDstat))) return;\r
-  arr = (TObjArray*)fResults->At(kTRDstat-1);\r
-  h1[0] = h2->ProjectionX("checkESDx0", kTPCout, kTPCout);\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDin, kTRDin);\r
-  Process(h1, (TGraphErrors*)arr->At(0));\r
-  delete h1[0];delete h1[1];\r
-  // tracking efficiency\r
-  h1[0] = h2->ProjectionX("checkESDx0", kTRDin, kTRDin);\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDout, kTRDout);\r
-  Process(h1, (TGraphErrors*)arr->At(1));\r
-  delete h1[1];\r
-  // PID efficiency\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDpid, kTRDpid);\r
-  Process(h1, (TGraphErrors*)arr->At(2));\r
-  delete h1[1];\r
-  // Refit efficiency\r
-  h1[1] = h2->ProjectionX("checkESDx1", kTRDref, kTRDref);\r
-  Process(h1, (TGraphErrors*)arr->At(3));\r
-  delete h1[1];\r
-  fNRefFigures++;\r
-\r
-  // ENERGY LOSS\r
-  if(!(h2 = dynamic_cast<TH2I*>(fHistos->At(kTRDmom)))) return;\r
-  if((arr = (TObjArray*)fResults->At(kTRDmom-1))){\r
-    TGraphAsymmErrors *g06 = (TGraphAsymmErrors*)arr->At(0), *g09 = (TGraphAsymmErrors*)arr->At(1);\r
-    if(g06 && g09){\r
-      ax=h2->GetXaxis();\r
-      const Int_t nq(4);\r
-      const Double_t xq[nq] = {0.05, 0.2, 0.8, 0.95};\r
-      Double_t yq[nq];\r
-      for(Int_t ily=6; ily--;){\r
-        h1[0] = h2->ProjectionX("checkESDp0", ily+1, ily+1);\r
-        h1[0]->GetQuantiles(nq,yq,xq);\r
-        g06->SetPoint(ily, Float_t(ily), ax->GetBinCenter(h1[0]->GetMaximumBin()));\r
-        g06->SetPointError(ily, 0., 0., TMath::Abs(yq[0]), yq[3]);\r
-        g09->SetPoint(ily, Float_t(ily), h1[0]->GetMean());\r
-        g09->SetPointError(ily, 0., 0., TMath::Abs(yq[1]), yq[2]);\r
-\r
-        //printf(" max[%f] mean[%f] q[%f %f %f %f]\n", ax->GetBinCenter(h1[0]->GetMaximumBin()), h1[0]->GetMean(), yq[0], yq[1], yq[2], yq[3]);\r
-        delete h1[0];\r
-      }\r
-      fNRefFigures++;\r
-    }\r
-  }\r
-//  if(!HasMC()) return;\r
-\r
-  // Pt RESOLUTION @ DCA\r
-  TH3S* h3(NULL); TGraphErrors *gg[2] = {NULL,NULL};\r
-  if(!(h3 = dynamic_cast<TH3S*>(fHistos->At(kPtRes)))) return;\r
-  if((arr = (TObjArray*)fResults->At(kPtRes-1))){\r
-    TAxis *az(h3->GetZaxis());\r
-    for(Int_t i(0); i<AliPID::kSPECIES; i++){\r
-      Int_t idx(2*i);\r
-      az->SetRange(idx+1, idx+2);\r
-      gg[1] = (TGraphErrors*)arr->At(idx);\r
-      gg[0] = (TGraphErrors*)arr->At(idx+1);\r
-      Process2D((TH2*)h3->Project3D("yx"), gg);\r
-\r
-      idx+=10;\r
-      az->SetRange(idx+1, idx+2);\r
-      gg[1] = (TGraphErrors*)arr->At(idx);\r
-      gg[0] = (TGraphErrors*)arr->At(idx+1);\r
-      Process2D((TH2*)h3->Project3D("yx"), gg);\r
-    }\r
-    fNRefFigures++;\r
-  }\r
-  fNRefFigures++;\r
-  // 3x3 tracking summary canvases for every centrality class\r
-  fNRefFigures++;\r
-  // 3x3 PID summary canvases for every centrality class\r
-  fNRefFigures++;\r
-  // 3x3 for centrality dependent pictures\r
-  fNRefFigures++;\r
-  \r
-  //DoTrending();  \r
-}\r
-\r
-//____________________________________________________________________\r
-Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg) const\r
-{\r
-  //\r
-  // Helper function converting PDG code into AliPID index\r
-  //\r
-  switch(pdg){\r
-  case kElectron: \r
-  case kPositron: return AliPID::kElectron;  \r
-  case kMuonPlus:\r
-  case kMuonMinus: return AliPID::kMuon;  \r
-  case kPiPlus: \r
-  case kPiMinus: return AliPID::kPion;  \r
-  case kKPlus: \r
-  case kKMinus: return AliPID::kKaon;\r
-  case kProton: \r
-  case kProtonBar: return AliPID::kProton;\r
-  } \r
-  return -1;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::Process(TH1 **h1, TGraphErrors *g)\r
-{\r
-// Generic function to process one reference plot\r
-\r
-  if(!g) return;\r
-  Int_t n1 = 0, n2 = 0, ip=0;\r
-  Double_t eff = 0.;\r
-\r
-  TAxis *ax = h1[0]->GetXaxis();\r
-  for(Int_t ib=1; ib<=ax->GetNbins(); ib++){\r
-    if(!(n1 = (Int_t)h1[0]->GetBinContent(ib))) continue;\r
-    n2 = (Int_t)h1[1]->GetBinContent(ib);\r
-    eff = n2/Float_t(n1);\r
-\r
-    ip=g->GetN();\r
-    g->SetPoint(ip, ax->GetBinCenter(ib), eff);\r
-    g->SetPointError(ip, 0., n2 ? eff*TMath::Sqrt(1./n1+1./n2) : 0.);\r
-  }\r
-}  \r
-//________________________________________________________\r
-void AliTRDcheckESD::Process2D(TH2 * const h2, TGraphErrors **g)\r
-{\r
-  //\r
-  // Do the processing\r
-  //\r
-\r
-  if(!g[0] || !g[1]) return;\r
-  Int_t n = 0;\r
-  if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);\r
-  if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);\r
-  TF1 f("fg", "gaus", -3.,3.);\r
-  for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){\r
-    Double_t x = h2->GetXaxis()->GetBinCenter(ibin);\r
-    TH1D *h = h2->ProjectionY("py", ibin, ibin);\r
-    if(h->GetEntries()<100) continue;\r
-    //AdjustF1(h, f);\r
-\r
-    h->Fit(&f, "QN");\r
-    Int_t ip = g[0]->GetN();\r
-    g[0]->SetPoint(ip, x, f.GetParameter(1));\r
-    g[0]->SetPointError(ip, 0., f.GetParError(1));\r
-    g[1]->SetPoint(ip, x, f.GetParameter(2));\r
-    g[1]->SetPointError(ip, 0., f.GetParError(2));\r
-  }\r
-  return;\r
-}\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::PrintStatus(ULong_t status)\r
-{\r
-// Dump track status to stdout\r
-\r
-  printf("ITS[i(%d) o(%d) r(%d)] TPC[i(%d) o(%d) r(%d) p(%d)] TRD[i(%d) o(%d) r(%d) p(%d) s(%d)] HMPID[o(%d) p(%d)]\n"\r
-    ,Bool_t(status & AliESDtrack::kITSin)\r
-    ,Bool_t(status & AliESDtrack::kITSout)\r
-    ,Bool_t(status & AliESDtrack::kITSrefit)\r
-    ,Bool_t(status & AliESDtrack::kTPCin)\r
-    ,Bool_t(status & AliESDtrack::kTPCout)\r
-    ,Bool_t(status & AliESDtrack::kTPCrefit)\r
-    ,Bool_t(status & AliESDtrack::kTPCpid)\r
-    ,Bool_t(status & AliESDtrack::kTRDin)\r
-    ,Bool_t(status & AliESDtrack::kTRDout)\r
-    ,Bool_t(status & AliESDtrack::kTRDrefit)\r
-    ,Bool_t(status & AliESDtrack::kTRDpid)\r
-    ,Bool_t(status & AliESDtrack::kTRDStop)\r
-    ,Bool_t(status & AliESDtrack::kHMPIDout)\r
-    ,Bool_t(status & AliESDtrack::kHMPIDpid)\r
-  );\r
-}\r
-\r
-//____________________________________________________________________\r
-TH1D* AliTRDcheckESD::Proj2D(TH2* hist, TH1* fitErr) {\r
-  //\r
-  // project the PH vs Slice 2D-histo into a 1D histo\r
-  //\r
-  \r
-  TH1D* hProjection = (TH1D*)hist->ProjectionX(Form("hProjection_%f", gRandom->Rndm()));\r
-  hProjection->Reset();\r
-  \r
-  TF1* fitLandau = new TF1("landauFunc","landau",0.,2000.);\r
-  TH1D *hD;\r
-  for(Int_t iBin=1;iBin<=hist->GetXaxis()->GetNbins();iBin++) {\r
-    if(gROOT->FindObject("projection"))\r
-      delete gROOT->FindObject("projection");\r
-    hD = (TH1D*)hist->ProjectionY("projection",iBin,iBin);\r
-    hD->Rebin(4);\r
-    if(hD->Integral()>10) {\r
-      fitLandau->SetParameter(1, hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParLimits(1, 0.2*hD->GetBinCenter(hD->GetMaximumBin()), 3.0*hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParameter(0, 1000.);\r
-      fitLandau->SetParLimits(0, 1., 10000000.);\r
-      fitLandau->SetParameter(2, 0.5*hD->GetBinCenter(hD->GetMaximumBin()));\r
-      fitLandau->SetParLimits(2, 0.01*hD->GetBinCenter(hD->GetMaximumBin()), 1.0*hD->GetBinCenter(hD->GetMaximumBin()));\r
-      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());\r
-      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());\r
-      hProjection->SetBinContent(iBin, fitLandau->GetParameter(1));\r
-      hProjection->SetBinError(iBin, fitLandau->GetParameter(2));\r
-      if(fitErr) {\r
-       fitErr->SetBinContent(iBin, fitLandau->GetParameter(1));\r
-       fitErr->SetBinError(iBin, fitLandau->GetParError(1));\r
-      }\r
-    }\r
-    else{\r
-      hProjection->SetBinContent(iBin, 0);\r
-      hProjection->SetBinError(iBin, 0);\r
-    }\r
-  }\r
-  return hProjection;\r
-}\r
-\r
-//____________________________________________________________________\r
-TH2F* AliTRDcheckESD::Proj3D(TH3* hist, TH2* accMap, Int_t zbinLow, Int_t zbinHigh, Float_t &entries) {\r
-  //\r
-  //  Project a 3D histogram to a 2D histogram in the Z axis interval [zbinLow,zbinHigh] \r
-  //  Return the 2D histogram and also the number of entries into this projection (entries)\r
-\r
-  Int_t nBinsX = hist->GetXaxis()->GetNbins();   // X and Y axis bins are assumed to be all equal\r
-  Float_t minX = hist->GetXaxis()->GetXmin();\r
-  Float_t maxX = hist->GetXaxis()->GetXmax();\r
-  Int_t nBinsY = hist->GetYaxis()->GetNbins();\r
-  Float_t minY = hist->GetYaxis()->GetXmin();\r
-  Float_t maxY = hist->GetYaxis()->GetXmax();\r
-  Int_t nBinsZ = hist->GetZaxis()->GetNbins();  // Z axis bins (pt) might have different widths\r
-\r
-  TH2F* projHisto = (TH2F*)gROOT->FindObject("projHisto");\r
-  if(projHisto) \r
-    projHisto->Reset();\r
-  else\r
-    projHisto = new TH2F("projHisto", "projection", nBinsX, minX, maxX, nBinsY, minY, maxY);\r
-\r
-  for(Int_t iZ=1; iZ<=nBinsZ; iZ++) {\r
-    if(iZ<zbinLow) continue;\r
-    if(iZ>zbinHigh) continue;\r
-    for(Int_t iX=1; iX<=nBinsX; iX++) {\r
-      for(Int_t iY=1; iY<=nBinsY; iY++) {\r
-        if(accMap) {\r
-          if(accMap->GetBinContent(iX,iY)>0.1)\r
-            projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));\r
-        }\r
-        else    // no acc. cut \r
-          projHisto->SetBinContent(iX, iY, projHisto->GetBinContent(iX, iY)+hist->GetBinContent(iX,iY,iZ));\r
-        // count only the entries which are inside the acceptance map\r
-        if(accMap) {\r
-          if(accMap->GetBinContent(iX,iY)>0.1)\r
-            entries+=hist->GetBinContent(iX,iY,iZ);\r
-        }\r
-        else    // no acc. cut\r
-          entries+=hist->GetBinContent(iX,iY,iZ);\r
-      }\r
-    }\r
-  }\r
-  return projHisto;\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]) {\r
-  //\r
-  // Check the active super-modules\r
-  //\r
-  Double_t entries[18] = {0.0};\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  for(Int_t phiBin=1; phiBin<=phiProj->GetXaxis()->GetNbins(); ++phiBin) {\r
-    Double_t phi = phiProj->GetBinCenter(phiBin);\r
-    Int_t sm = -1;\r
-    for(Int_t ism=0; ism<18; ++ism) \r
-      if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1]) sm = ism;\r
-    if(sm==-1) continue;\r
-    entries[sm] += phiProj->GetBinContent(phiBin);\r
-  }\r
-  Double_t avEntries = Double_t(phiProj->Integral())/18.0;\r
-  for(Int_t ism=0; ism<18; ++ism) \r
-    if(entries[ism]>0.5*avEntries) activeSM[ism] = kTRUE;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-TH1F* AliTRDcheckESD::EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, \r
-                                         Int_t stepNom, Int_t stepDenom, const Char_t* varStr/*="pt"*/, const Char_t* type/*="TPCTRD"*/) {\r
-  //\r
-  // Use the CF container to extract the efficiency vs pt\r
-  //\r
-  Int_t varTrackPhi = cf->GetVar("phi");\r
-  Int_t var = cf->GetVar(varStr);\r
-    \r
-  TH1D* phiProj = (TH1D*)cf->Project(1, varTrackPhi);\r
-  Bool_t activeSM[18] = {kFALSE};\r
-  CheckActiveSM(phiProj, activeSM); delete phiProj;\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  \r
-  TString effTypeStr = type;\r
-  if(effTypeStr.Contains("TRDTOF")) {\r
-    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)\r
-      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));\r
-  }\r
-  TH2D* hDenomPhiVar = (TH2D*)cf->Project(stepDenom, var, varTrackPhi);\r
-  if(effTypeStr.Contains("TPCTRD")) {\r
-    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)\r
-      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));\r
-  }\r
-  TH2D* hNomPhiVar = (TH2D*)cf->Project(stepNom, var, varTrackPhi);\r
-  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);\r
-  \r
-  TH1F* hEff = new TH1F(Form("hEff%s_%d_%d_%f", varStr, stepNom, stepDenom, gRandom->Rndm()), "", \r
-                       hNomPhiVar->GetXaxis()->GetNbins(), hNomPhiVar->GetXaxis()->GetXbins()->GetArray());\r
-  for(Int_t ivar=1; ivar<=hEff->GetXaxis()->GetNbins(); ++ivar) {\r
-    Double_t nom = 0.0; Double_t denom = 0.0;\r
-    Double_t eff = 0.0; Double_t err = 0.0;\r
-    for(Int_t iphi=1; iphi<=hNomPhiVar->GetYaxis()->GetNbins(); ++iphi) {\r
-      Double_t phi = hNomPhiVar->GetYaxis()->GetBinCenter(iphi);\r
-      Bool_t isActive = kFALSE;\r
-      for(Int_t ism=0; ism<18; ++ism) \r
-        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) \r
-         isActive = kTRUE;\r
-      if(!isActive) continue;\r
-      nom += hNomPhiVar->GetBinContent(ivar, iphi);\r
-      denom += hDenomPhiVar->GetBinContent(ivar, iphi);\r
-    }\r
-    eff = (denom>0.001 ? nom/denom : 0.0);\r
-    err = (denom>0.001 && (denom-nom)>0.001 && nom>0.001 ? (TMath::Sqrt(nom*(denom-nom)/denom/denom/denom)) : 0.0);\r
-    hEff->SetBinContent(ivar, eff);\r
-    hEff->SetBinError(ivar, err);\r
-  }   // end loop over pt bins\r
-  delete hNomPhiVar; delete hDenomPhiVar;\r
-  return hEff;\r
-}\r
-\r
-\r
-//____________________________________________________________________\r
-TH1F* AliTRDcheckESD::EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance) {\r
-  //\r
-  // Calculate the TRD-TPC matching efficiency as function of pt\r
-  //\r
-  \r
-  if(!tpc3D || !trd3D) return NULL;\r
-  Int_t nBinsZ = trd3D->GetZaxis()->GetNbins();\r
-  // project everything on the eta-phi map to obtain an acceptance map\r
-  Float_t nada = 0.;\r
-  TH2F *trdAcc = (useAcceptance ? (TH2F*)Proj3D(trd3D, 0x0, 1, nBinsZ, nada)->Clone(Form("trdAcc%f", gRandom->Rndm())) : 0x0);\r
-  TH1D *phiProj = (trdAcc ? trdAcc->ProjectionY(Form("phiProj%f", gRandom->Rndm())) : 0x0);\r
-  \r
-  // prepare the acceptance map\r
-  Bool_t activeSM[18] = {kFALSE};\r
-  Double_t smPhiLimits[19];\r
-  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;\r
-  if(phiProj) {\r
-    CheckActiveSM(phiProj, activeSM);   // get the active SMs\r
-    trdAcc->Reset();\r
-    // Put 1 entry in every bin which belongs to an active SM\r
-    for(Int_t iY=1; iY<=trdAcc->GetYaxis()->GetNbins(); ++iY) {\r
-      Double_t phi = trdAcc->GetYaxis()->GetBinCenter(iY);\r
-      Bool_t isActive = kFALSE;\r
-      for(Int_t ism=0; ism<18; ++ism) {\r
-        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) {\r
-         isActive = kTRUE;\r
-        }\r
-      }\r
-      if(!isActive) continue;\r
-      for(Int_t iX=1; iX<=trdAcc->GetXaxis()->GetNbins(); ++iX) \r
-        if(trdAcc->GetXaxis()->GetBinCenter(iX)>=-0.85 && trdAcc->GetXaxis()->GetBinCenter(iX)<=0.85) trdAcc->SetBinContent(iX, iY, 1.0);\r
-    }  // end for over Y(phi) bins\r
-  }  // end if phiProj\r
-    \r
-  // get the bin limits from the Z axis of 3D histos\r
-  Float_t *ptBinLimits = new Float_t[nBinsZ+1];\r
-  for(Int_t i=1; i<=nBinsZ; i++) {\r
-    ptBinLimits[i-1] = trd3D->GetZaxis()->GetBinLowEdge(i);\r
-  }\r
-  ptBinLimits[nBinsZ] = trd3D->GetZaxis()->GetBinUpEdge(nBinsZ);\r
-  \r
-  TH1F *efficiency = new TH1F(Form("eff%d", Int_t(1000000.0*gRandom->Rndm())), "TRD-TPC matching efficiency", nBinsZ, ptBinLimits);\r
-  \r
-  // loop over Z bins\r
-  Bool_t effGood = kFALSE;\r
-  for(Int_t i=1; i<=nBinsZ; i++) {\r
-    Float_t tpcEntries = 0.0; Float_t trdEntries = 0.0;\r
-    Proj3D(tpc3D, trdAcc, i, i, tpcEntries);\r
-    Proj3D(trd3D, trdAcc, i, i, trdEntries);\r
-    Float_t ratio = 0;\r
-    if(tpcEntries>0) ratio = trdEntries/tpcEntries;\r
-    Float_t error = 0;\r
-    if(tpcEntries>0 && trdEntries>0 && (tpcEntries-trdEntries)>=0.0) \r
-      error = TMath::Sqrt(trdEntries*(tpcEntries-trdEntries)/tpcEntries/tpcEntries/tpcEntries);\r
-    if(ratio>0.001) {\r
-      efficiency->SetBinContent(i,ratio);\r
-      efficiency->SetBinError(i,error);\r
-      effGood = kTRUE;\r
-    }\r
-  }     // end loop over Z bins\r
-  if(!effGood) return 0x0;\r
-  \r
-  return efficiency;\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::PlotCentSummaryFromCF(Double_t* /*trendValues*/, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  // Make the centrality summary figure from the CF container \r
-  // \r
-  if(!fMatchingPtCF) return;\r
-  AliCFContainer* cf = 0x0;    \r
-  \r
-  TLatex* lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001); gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  TVirtualPad* pad=0x0;\r
-  \r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.3);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  \r
-  Int_t padsForEffs[5] = {0,3,6,1,4};\r
-  for(Int_t iCent=1; iCent<6; ++iCent) {\r
-    pad = ((TVirtualPad*)l->At(padsForEffs[iCent-1])); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEffPt->Draw();\r
-    TLine line;\r
-    line.SetLineStyle(2);\r
-    line.SetLineWidth(2);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-    \r
-    cf = fMatchingPtCF;\r
-    cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-       \r
-    cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  \r
-    TH1F* hEffPosAll = EfficiencyFromPhiPt(cf,  0,  6, 1, 0);\r
-    TH1F* hEffPosTrk4 = EfficiencyFromPhiPt(cf, 4,  4, 1, 0);  \r
-    TH1F* hEffPosTrk5 = EfficiencyFromPhiPt(cf, 5,  5, 1, 0);\r
-    TH1F* hEffPosTrk6 = EfficiencyFromPhiPt(cf, 6,  6, 1, 0);\r
-     \r
-    cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  \r
-    TH1F* hEffNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);  \r
-    TH1F* hEffNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);  \r
-    TH1F* hEffNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);  \r
-    TH1F* hEffNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-    cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);  \r
-    cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  \r
-    \r
-    SetStyle(hEffPosAll,  1, kRed, 1, 24, kRed, 1);\r
-    SetStyle(hEffPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-    SetStyle(hEffPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-    SetStyle(hEffPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-    SetStyle(hEffNegAll,  1, kBlue, 1, 24, kBlue, 1);\r
-    SetStyle(hEffNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-    SetStyle(hEffNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-    SetStyle(hEffNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-    hEffPosAll->Draw("same");\r
-    hEffNegAll->Draw("same");\r
-    hEffPosTrk4->Draw("same");\r
-    hEffNegTrk4->Draw("same");\r
-    hEffPosTrk5->Draw("same");\r
-    hEffNegTrk5->Draw("same");\r
-    hEffPosTrk6->Draw("same");\r
-    hEffNegTrk6->Draw("same");    \r
-        \r
-    TLegend* leg=new TLegend(0.18, 0.7, 0.77, 0.89);\r
-    if(iCent==1) {\r
-      leg->SetFillColor(0);\r
-      leg->SetNColumns(2);\r
-      leg->SetMargin(0.1);\r
-      leg->SetBorderSize(0);\r
-      leg->AddEntry(hEffPosAll,  "pos. (#geq 1 tracklet)", "p");\r
-      leg->AddEntry(hEffNegAll,  "neg. (#geq 1 tracklet)", "p");\r
-      leg->AddEntry(hEffPosTrk4, "pos. (4 tracklets)", "p");\r
-      leg->AddEntry(hEffNegTrk4, "neg. (4 tracklets)", "p");\r
-      leg->AddEntry(hEffPosTrk5, "pos. (5 tracklets)", "p");\r
-      leg->AddEntry(hEffNegTrk5, "neg. (5 tracklets)", "p");\r
-      leg->AddEntry(hEffPosTrk6, "pos. (6 tracklets)", "p");     \r
-      leg->AddEntry(hEffNegTrk6, "neg. (6 tracklets)", "p");\r
-      leg->Draw();\r
-    }\r
-    lat->DrawLatex(0.2, 1.32, Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent)));\r
-  }   // end for loop over multiplicity classes\r
-  \r
-  // Reset the modified user ranges of the CF container\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0., 3500.);\r
-     \r
-  // Cluster distributions in all multiplicity classes\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");\r
-  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);\r
-  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNcls->SetStats(kFALSE);\r
-  rangeNcls->Draw();\r
-    \r
-  TH1D* hNcls[6]={0x0};\r
-  TLegend* legCls=new TLegend(0.7, 0.75, 0.97, 0.97);\r
-  legCls->SetBorderSize(0);\r
-  legCls->SetFillColor(0);\r
-  legCls->SetMargin(0.15);\r
-  cf = fCentralityCF;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    if(iCent>0)\r
-      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-    hNcls[iCent] = (TH1D*)cf->Project(0, cf->GetVar("clusters"));\r
-    if(!hNcls[iCent]) continue;\r
-    \r
-    hNcls[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-    Double_t maximum = hNcls[iCent]->GetMaximum();\r
-    if(maximum>1.0)\r
-      hNcls[iCent]->Scale(1.0/maximum);\r
-    hNcls[iCent]->SetStats(kFALSE);\r
-    hNcls[iCent]->SetTitle("");\r
-    hNcls[iCent]->SetLineWidth(2);\r
-    \r
-    if(hNcls[iCent]->Integral()>0.01) {\r
-      hNcls[iCent]->Draw("same");\r
-      legCls->AddEntry(hNcls[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), \r
-                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");\r
-    }\r
-  }\r
-  legCls->Draw();\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 6.0, kTRUE);\r
-  \r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");\r
-  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);\r
-  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtot->SetStats(kFALSE);\r
-  rangeQtot->Draw();\r
-  \r
-  TH1D* hQtot[6]={0x0};\r
-  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.97);\r
-  leg2->SetFillColor(0);\r
-  leg2->SetBorderSize(0);\r
-  \r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    if(iCent>0)\r
-      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);\r
-    \r
-    hQtot[iCent] = (TH1D*)cf->Project(0, cf->GetVar("Qtot0"));\r
-    if(!hQtot[iCent]) continue;\r
-    hQtot[iCent]->SetBinContent(1, 0);\r
-    \r
-    Double_t maximum = hQtot[iCent]->GetMaximum();\r
-    if(maximum>1.0)\r
-      hQtot[iCent]->Scale(1.0/maximum);\r
-    hQtot[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-    hQtot[iCent]->SetStats(kFALSE);\r
-    hQtot[iCent]->SetTitle("");\r
-    hQtot[iCent]->SetLineWidth(2);\r
-    if(hQtot[iCent]->Integral()>0.01) {\r
-      hQtot[iCent]->Draw(iCent==0 ? "" : "same");\r
-      leg2->AddEntry(hQtot[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), \r
-                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");\r
-    }\r
-  }\r
-  leg2->Draw();\r
-  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 5.0, kTRUE);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::PlotTrackingSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  //  Plot tracking summary\r
-  //\r
-  if(!fMatchingPhiEtaCF || !fMatchingPtCF || !fCentralityCF || !fBunchCrossingsCF) return;\r
-  AliCFContainer* cf = 0x0;  \r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-  \r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  // eta-phi distr. for positive TPC tracks\r
-  TVirtualPad* pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
\r
-  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);\r
-  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  // find all the isolated bunch crossings with entries\r
-  TH2D* hTPCrefPos = 0x0; TH2D* hTRDrefPos = 0x0; TH2D* hTOFrefPos = 0x0;\r
-  TH2D* hTPCrefNeg = 0x0; TH2D* hTRDrefNeg = 0x0; TH2D* hTOFrefNeg = 0x0;\r
-  cf = fMatchingPhiEtaCF;\r
-  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);\r
-  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);      // positive charges\r
-  hTPCrefPos = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTRDrefPos = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTOFrefPos = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);      // negative charges\r
-  hTPCrefNeg = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTRDrefNeg = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  hTOFrefNeg = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);      // reset charge cut\r
-    \r
-  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);  \r
-  \r
-  //----------------------------------------------\r
-  // eta-phi efficiency for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTRDeffPos = (hTRDrefPos ? (TH2D*)hTRDrefPos->Clone("hTRDeffPos") : 0x0);\r
-  if(hTRDeffPos) {\r
-    hTRDeffPos->Reset();\r
-    hTRDeffPos->SetStats(kFALSE);\r
-    hTRDeffPos->Divide(hTRDrefPos, hTPCrefPos);\r
-    hTRDeffPos->SetMaximum(1.0);\r
-    hTRDeffPos->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for positive tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi efficiency for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(3)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTRDeffNeg = (hTRDrefNeg ? (TH2D*)hTRDrefNeg->Clone("hTRDeffNeg") : 0x0);\r
-  if(hTRDeffNeg) {\r
-    hTRDeffNeg->Reset();\r
-    hTRDeffNeg->SetStats(kFALSE);\r
-    hTRDeffNeg->Divide(hTRDrefNeg, hTPCrefNeg);\r
-    hTRDeffNeg->SetMaximum(1.0);\r
-    hTRDeffNeg->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for negative tracks");\r
-    DrawTRDGrid();  \r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi TRD-TOF matching efficiency for positive tracks\r
-  pad = ((TVirtualPad*)l->At(1)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTOFeffPos = (hTOFrefPos ? (TH2D*)hTOFrefPos->Clone("hTOFeffPos") : 0x0);\r
-  if(hTOFeffPos) {\r
-    hTOFeffPos->Reset();\r
-    hTOFeffPos->SetStats(kFALSE);\r
-    hTOFeffPos->Divide(hTOFrefPos, hTRDrefPos);\r
-    hTOFeffPos->SetMaximum(1.0);\r
-    hTOFeffPos->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for positive tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  //----------------------------------------------\r
-  // eta-phi TRD-TOF matching efficiency for negative tracks\r
-  pad = ((TVirtualPad*)l->At(4)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  \r
-  TH2D* hTOFeffNeg = (hTOFrefNeg ? (TH2D*)hTOFrefNeg->Clone("hTOFeffNeg") : 0x0);\r
-  if(hTOFeffNeg) {\r
-    hTOFeffNeg->Reset();\r
-    hTOFeffNeg->SetStats(kFALSE);\r
-    hTOFeffNeg->Divide(hTOFrefNeg, hTRDrefNeg);\r
-    hTOFeffNeg->SetMaximum(1.0);\r
-    hTOFeffNeg->Draw("samecolz");\r
-    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for negative tracks");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  if(hTRDrefPos) delete hTRDrefPos; if(hTPCrefPos) delete hTPCrefPos; if(hTOFrefPos) delete hTOFrefPos;\r
-  if(hTRDrefNeg) delete hTRDrefNeg; if(hTPCrefNeg) delete hTPCrefNeg; if(hTOFrefNeg) delete hTOFrefNeg;\r
-  \r
-  // switch to the Pt cf container\r
-  cf = fMatchingPtCF;\r
-  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  \r
-  TH1F* hTRDEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);\r
-  TH1F* hTOFEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-  TH1F* hTOFEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");\r
-  \r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  \r
-  TH1F* hTRDEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);\r
-  TH1F* hTOFEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");\r
-  TH1F* hTRDEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);\r
-  TH1F* hTOFEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");\r
-  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  \r
-  \r
-  TF1* funcConst = new TF1("constFunc", "[0]", 1.0, 3.0);\r
-  if(trendValues) {\r
-    if(hTRDEffPtPosAll && hTRDEffPtPosAll->Integral()>0.1) {\r
-      hTRDEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[0] = funcConst->GetParameter(0);\r
-      trendValues[1] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTRDEffPtNegAll && hTRDEffPtNegAll->Integral()>0.1) {\r
-      hTRDEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[2] = funcConst->GetParameter(0);\r
-      trendValues[3] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTOFEffPtPosAll && hTOFEffPtPosAll->Integral()>0.1) {\r
-      hTOFEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[4] = funcConst->GetParameter(0);\r
-      trendValues[5] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  if(trendValues) { \r
-    if(hTOFEffPtNegAll && hTOFEffPtNegAll->Integral()>0.1) {\r
-      hTOFEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);\r
-      trendValues[6] = funcConst->GetParameter(0);\r
-      trendValues[7] = funcConst->GetParError(0);\r
-    }\r
-  }\r
-  \r
-  //---------------------------------------------------------\r
-  // TPC-TRD matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(6)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEffPt->Draw();\r
-  lat->DrawLatex(0.2, 1.42, "TPC-TRD matching efficiency");\r
-  //++++++++++++++++++\r
-  TLine line;\r
-  line.SetLineStyle(2);\r
-  line.SetLineWidth(2);\r
-  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.7, 0.89);\r
-  leg->SetNColumns(2);\r
-  leg->SetMargin(0.15);\r
-  leg->SetBorderSize(0);\r
-  leg->SetFillColor(0);\r
-\r
-  SetStyle(hTRDEffPtPosAll, 1, kRed, 1, 24, kRed, 1);\r
-  SetStyle(hTRDEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-  SetStyle(hTRDEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-  SetStyle(hTRDEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-  if(hTRDEffPtPosAll) {hTRDEffPtPosAll->Draw("same"); leg->AddEntry(hTRDEffPtPosAll, "pos. (#geq 1 tracklet)", "p");}\r
-  if(hTRDEffPtNegAll) {hTRDEffPtNegAll->Draw("same"); leg->AddEntry(hTRDEffPtNegAll, "neg. (#geq 1 tracklet)", "p");}\r
-  hTRDEffPtPosTrk4->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk4, "pos. (4 tracklets)", "p");\r
-  hTRDEffPtNegTrk4->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk4, "neg. (4 tracklets)", "p");\r
-  hTRDEffPtPosTrk5->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk5, "pos. (5 tracklets)", "p");\r
-  hTRDEffPtNegTrk5->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk5, "neg. (5 tracklets)", "p");\r
-  hTRDEffPtPosTrk6->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk6, "pos. (6 tracklets)", "p");\r
-  hTRDEffPtNegTrk6->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk6, "neg. (6 tracklets)", "p");\r
-  \r
-  leg->Draw();\r
-  \r
-  //---------------------------------------------------------\r
-  // TRD-TOF matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(7)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  rangeEffPt->Draw();\r
-  lat->DrawLatex(0.2, 1.42, "TRD-TOF matching efficiency");\r
-  SetStyle(hTOFEffPtPosAll, 1, kRed, 1, 24, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);\r
-  SetStyle(hTOFEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);\r
-  SetStyle(hTOFEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);\r
-  SetStyle(hTOFEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);\r
-  if(hTOFEffPtPosAll) hTOFEffPtPosAll->Draw("same"); \r
-  hTOFEffPtPosTrk4->Draw("same"); \r
-  hTOFEffPtPosTrk5->Draw("same"); \r
-  hTOFEffPtPosTrk6->Draw("same"); \r
-  if(hTOFEffPtNegAll) hTOFEffPtNegAll->Draw("same"); \r
-  hTOFEffPtNegTrk4->Draw("same"); \r
-  hTOFEffPtNegTrk5->Draw("same"); \r
-  hTOFEffPtNegTrk6->Draw("same");  \r
-    \r
-  //-----------------------------------------------------\r
-  // <ntracklets> vs (phi,eta)\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");\r
-  \r
-  cf = fMatchingPhiEtaCF;\r
-  TH3D* hNtracklets = (TH3D*)cf->Project(1, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("tracklets"));\r
-  \r
-  TProfile2D* hNtrackletsProf = hNtracklets->Project3DProfile();\r
-  delete hNtracklets;\r
-  if(hNtrackletsProf) {\r
-    hNtrackletsProf->SetStats(kFALSE);\r
-    hNtrackletsProf->SetMinimum(0.);\r
-    hNtrackletsProf->SetMaximum(6.);\r
-    hNtrackletsProf->Draw("samecolz");\r
-    DrawTRDGrid();\r
-  }\r
-  \r
-  // calculate the trend value for tracklets/track\r
-  cf = fMatchingPtCF;\r
-  TH2D* hNtrackletsVsP = (TH2D*)cf->Project(1, cf->GetVar("pt"), cf->GetVar("tracklets"));\r
-  if(trendValues &&  hNtrackletsVsP && hNtrackletsVsP->GetEntries()>0.1) {\r
-    TProfile* hNtrackletsVsPprof = hNtrackletsVsP->ProfileX("hNtrackletsVsPprof");\r
-    hNtrackletsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-    trendValues[8] = funcConst->GetParameter(0);\r
-    trendValues[9] = funcConst->GetParError(0);\r
-    delete hNtrackletsVsP;\r
-  }\r
-      \r
-  //--------------------------------------------------------------\r
-  // Nclusters per TRD track vs momentum\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  \r
-  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");\r
-  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);\r
-  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNclsP->SetStats(kFALSE);\r
-  rangeNclsP->Draw();\r
-  lat->DrawLatex(1.0, 205., "TRD Clusters / track");\r
-  \r
-  cf = fCentralityCF;\r
-  TH2D* hNclsVsP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("clusters"));\r
-  if(hNclsVsP) {\r
-    hNclsVsP->SetStats(kFALSE);\r
-    hNclsVsP->Draw("samecolz");\r
-  }    \r
-  \r
-  if(trendValues && hNclsVsP && hNclsVsP->GetEntries()>10) {\r
-    TProfile* hNclsVsPprof = hNclsVsP->ProfileX("hNclsVsPprof");\r
-    hNclsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-    trendValues[10] = funcConst->GetParameter(0);\r
-    trendValues[11] = funcConst->GetParError(0);\r
-  }\r
-    \r
-  //--------------------------------------------------------------\r
-  // TRD-TPC and TOF-TRD matching efficiency vs bunch crossing\r
-  pad = ((TVirtualPad*)l->At(8)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-\r
-  cf = fBunchCrossingsCF;\r
-  TH1F* hTRDEffBC = EfficiencyFromPhiPt(cf, 0, 6, 1, 0, "BC", "TPCTRD");\r
-  TH1F* hTOFEffBC = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "BC", "TRDTOF");\r
-  \r
-  if(gROOT->FindObject("rangeBC")) delete gROOT->FindObject("rangeBC");\r
-  TH2F* rangeBC = new TH2F("rangeBC", "", 10, -0.5, 3499.5, 10, 0.0, 1.4);\r
-  rangeBC->SetStats(kFALSE);\r
-  SetStyle(rangeBC->GetXaxis(), "Bunch crossing", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeBC->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeBC->Draw();\r
-  \r
-  TLegend* legBC=new TLegend(0.8, 0.7, 0.95, 0.89);\r
-  legBC->SetBorderSize(0);\r
-  legBC->SetMargin(0.15);\r
-  legBC->SetFillColor(0);\r
-  if(hTRDEffBC) {\r
-    hTRDEffBC->SetStats(kFALSE);\r
-    SetStyle(hTRDEffBC, 1, kRed, 2, 24, kRed, 1); legBC->AddEntry(hTRDEffBC, "TPC-TRD", "p");\r
-    SetStyle(hTOFEffBC, 1, kBlue, 2, 24, kBlue, 1); legBC->AddEntry(hTOFEffBC, "TRD-TOF", "p");\r
-    hTRDEffBC->Draw("same");\r
-    hTOFEffBC->Draw("same");\r
-    legBC->Draw();\r
-    lat->DrawLatex(200., 1.42, "Matching efficiency at 1<p_{T}<3 GeV/c");\r
-  }\r
-    \r
-  // reset the user range on the event multiplicity\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-  \r
-  delete funcConst;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::PlotPidSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {\r
-  //\r
-  // Centrality summary\r
-  //\r
-  if(!fQtotCF || !fPulseHeightCF || !fCentralityCF) return;\r
-  \r
-  AliCFContainer* cf = 0x0;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);\r
-  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);\r
-  \r
-  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);  \r
-  \r
-  // eta-phi distr. for <Qtot> in layer 0\r
-  TVirtualPad* pad;\r
-  TProfile2D* hProf2D;\r
-  cf = fQtotCF;\r
-  for(Int_t iLayer=0; iLayer<6; ++iLayer) {\r
-    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+1))); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEtaPhi->Draw();\r
-    \r
-    cf->SetRangeUser(cf->GetVar("layer"), Double_t(iLayer), Double_t(iLayer));\r
-    TH3D* hQtotEtaPhi = (TH3D*)cf->Project(0, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("Qtot0"));\r
-    hProf2D = (hQtotEtaPhi ? hQtotEtaPhi->Project3DProfile() : 0x0);\r
-    if(hQtotEtaPhi) delete hQtotEtaPhi;\r
-    \r
-    if(hProf2D) {\r
-      hProf2D->SetName(Form("Qtot_layer%d",iLayer));\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(4.);\r
-      hProf2D->Draw("samecolz");\r
-    }\r
-    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));\r
-    DrawTRDGrid();\r
-  }\r
-  cf->SetRangeUser(cf->GetVar("layer"), 0.0, 5.0);\r
-    \r
-  // PH versus slice number\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  \r
-  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");\r
-  TH2F* rangePHslice=new TH2F("rangePHslice", "", 8, -0.5, 7.5, 10, 0.0, 6.);\r
-  rangePHslice->SetStats(kFALSE);\r
-  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);\r
-  rangePHslice->Draw();\r
-  \r
-  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);\r
-  \r
-  cf = fPulseHeightCF;\r
-  TH2D* hPH = (TH2D*)cf->Project(0, cf->GetVar("slice"), cf->GetVar("PH0"));\r
-  TH1D* hSliceErr = new TH1D(Form("hSliceErr%f", gRandom->Rndm()), "", hPH->GetXaxis()->GetNbins(), hPH->GetXaxis()->GetXbins()->GetArray());\r
-  TH1D* hLandauFit = Proj2D(hPH, hSliceErr);\r
-  hPH->SetStats(kFALSE);\r
-  hPH->Draw("samecolz");\r
-  if(trendValues) {\r
-    hSliceErr->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);\r
-    trendValues[12] = funcPol1->GetParameter(0);  // PH plateau\r
-    trendValues[13] = funcPol1->GetParError(0);   // PH plateau\r
-    trendValues[14] = funcPol1->GetParameter(1);  // PH slope\r
-    trendValues[15] = funcPol1->GetParError(1);   // PH slope\r
-  }\r
-  hLandauFit->SetLineWidth(2);\r
-  hLandauFit->SetLineStyle(2);\r
-  hLandauFit->Draw("same");\r
-  \r
-  delete funcPol1; delete hSliceErr;\r
-  \r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  \r
-  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");\r
-  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);\r
-  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtotP->SetStats(kFALSE);\r
-  rangeQtotP->Draw();\r
-  \r
-  cf = fCentralityCF;\r
-  TH2D* hQtotP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("Qtot0"));\r
-    \r
-  if(hQtotP)\r
-    for(Int_t i=1; i<=hQtotP->GetXaxis()->GetNbins(); ++i) \r
-      hQtotP->SetBinContent(i, 1, 0.0);  \r
-  TH1D* hQtotProj = (hQtotP ? Proj2D(hQtotP) : 0x0);\r
-  if(hQtotProj) SetStyle(hQtotProj, 2, kBlue, 2, 1, kBlue, 1);\r
-  if(trendValues && hQtotProj && hQtotProj->GetEntries()>2) {\r
-    trendValues[16] = hQtotProj->GetBinContent(hQtotProj->FindBin(1.0));   // Landau MPV at 1GeV/c\r
-    trendValues[17] = hQtotProj->GetBinError(hQtotProj->FindBin(1.0));     // Landau width at 1 GeV/c\r
-  }\r
-  if(hQtotP) {\r
-    hQtotP->SetStats(kFALSE);\r
-    hQtotP->Draw("samecolz");\r
-    hQtotProj->Draw("same");\r
-  }\r
-  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotCentSummary(Double_t* /*trendValues*/) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex* lat=new TLatex();\r
-  lat->SetTextSize(0.06);\r
-  lat->SetTextColor(2);\r
-\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  \r
-  TPad* pad=0x0;  \r
-\r
-  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");\r
-  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  \r
-  TH3F *h3(NULL), *h3p(NULL), *h3n(NULL);\r
-  Int_t padsForEffs[5] = {0,3,6,1,4};\r
-  for(Int_t iCent=1; iCent<6; ++iCent) {\r
-    // TPC-TRD matching efficiencies\r
-    pad = ((TPad*)l->At(padsForEffs[iCent-1])); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    \r
-    if(!(h3p = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+iCent)))) continue;\r
-    if(!(h3n = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+iCent)))) continue;\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+iCent)))) continue;\r
-    TH1F* hFeffP = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+iCent)))) continue;\r
-    TH1F* hFeffN = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+iCent)))) continue;\r
-    TH1F* hFeffP4 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+iCent)))) continue;\r
-    TH1F* hFeffN4 = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+iCent)))) continue;\r
-    TH1F* hFeffP5 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+iCent)))) continue;\r
-    TH1F* hFeffN5 = EfficiencyTRD(h3n, h3, kTRUE);\r
-    // =============================================\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+iCent)))) continue;\r
-    TH1F* hFeffP6 = EfficiencyTRD(h3p, h3, kTRUE);\r
-    //\r
-    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+iCent)))) continue;\r
-    TH1F* hFeffN6 = EfficiencyTRD(h3n, h3, kTRUE);\r
-  \r
-    rangeEffPt->Draw();\r
-    \r
-    TLine line;\r
-    line.SetLineStyle(2);\r
-    line.SetLineWidth(2);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);\r
-    line.SetLineStyle(1);\r
-    line.SetLineWidth(1);\r
-    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 1.0, rangeEffPt->GetXaxis()->GetXmax(), 1.0);\r
-    if(hFeffP) SetStyle(hFeffP, 1, kRed, 1, 24, kRed, 1);\r
-    if(hFeffP4) SetStyle(hFeffP4, 1, kRed, 1, 25, kRed, 1);\r
-    if(hFeffP5) SetStyle(hFeffP5, 1, kRed, 1, 26, kRed, 1);\r
-    if(hFeffP6) SetStyle(hFeffP6, 1, kRed, 1, 27, kRed, 1);\r
-    if(hFeffN) SetStyle(hFeffN, 1, kBlue, 1, 24, kBlue, 1);\r
-    if(hFeffN4) SetStyle(hFeffN4, 1, kBlue, 1, 25, kBlue, 1);\r
-    if(hFeffN5) SetStyle(hFeffN5, 1, kBlue, 1, 26, kBlue, 1);\r
-    if(hFeffN6) SetStyle(hFeffN6, 1, kBlue, 1, 27, kBlue, 1);\r
-    \r
-    TLegend* leg=new TLegend(0.16, 0.7, 0.61, 0.89);\r
-    leg->SetFillColor(0);\r
-    leg->SetNColumns(2);\r
-    leg->SetTextSize(0.039);\r
-    leg->SetMargin(0.1);\r
-    if(hFeffP && hFeffP->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP->Draw("same");\r
-      leg->AddEntry(hFeffP, "pos. (#geq 1 trcklt)", "p");\r
-    }\r
-    if(hFeffN && hFeffN->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN->Draw("same");\r
-      leg->AddEntry(hFeffN, "neg. (#geq 1 trcklt)", "p");\r
-    }\r
-    if(hFeffP4 && hFeffP4->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP4->Draw("same");\r
-      leg->AddEntry(hFeffP4, "pos. (4 trcklts)", "p");\r
-    }\r
-    if(hFeffN4 && hFeffN4->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN4->Draw("same");\r
-      leg->AddEntry(hFeffN4, "neg. (4 trcklts)", "p");\r
-    }\r
-    if(hFeffP5 && hFeffP5->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP5->Draw("same");\r
-      leg->AddEntry(hFeffP5, "pos. (5 trcklts)", "p");\r
-    }\r
-    if(hFeffN5 && hFeffN5->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN5->Draw("same");\r
-      leg->AddEntry(hFeffN5, "neg. (5 trcklts)", "p");\r
-    }\r
-    if(hFeffP6 && hFeffP6->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffP6->Draw("same");\r
-      leg->AddEntry(hFeffP6, "pos. (6 trcklts)", "p");\r
-    }\r
-    if(hFeffN6 && hFeffN6->Integral()>0.001) {\r
-      isGoodForSaving = kTRUE;\r
-      hFeffN6->Draw("same");\r
-      leg->AddEntry(hFeffN6, "neg. (6 trklts)", "p");\r
-    }\r
-    \r
-    if(isGoodForSaving) {\r
-      if(iCent==1) leg->Draw();\r
-      lat->DrawLatex(5.6, 1.3, Form("Centrality class %d", iCent));\r
-      lat->DrawLatex(0.5, 1.42, "TPC-TRD matching efficiency");\r
-    }\r
-  }   // end loop over multiplicity intervals\r
-\r
-  // Number of clusters per TRD track\r
-  pad = ((TPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");\r
-  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);\r
-  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNcls->SetStats(kFALSE);\r
-  rangeNcls->Draw();\r
-  \r
-  TH2F* h2F[6]; TH1D* proj[6];\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.5, 0.95);\r
-  leg->SetFillColor(0);\r
-  Bool_t isGood=kFALSE;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {\r
-    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+iCent));\r
-    proj[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projCent%d",iCent)) : 0x0);\r
-    if(proj[iCent]) {\r
-      proj[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-      Double_t maximum = proj[iCent]->GetMaximum();\r
-      if(maximum>1.0)\r
-        proj[iCent]->Scale(1.0/maximum);\r
-      proj[iCent]->SetStats(kFALSE);\r
-      proj[iCent]->Draw("same");\r
-      leg->AddEntry(proj[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");\r
-      isGood = kTRUE;\r
-    }\r
-  }\r
-  if(isGood) leg->Draw();\r
-  isGoodForSaving = isGoodForSaving || isGood;\r
-  \r
-  // Qtot vs P\r
-  pad = ((TPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");\r
-  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);\r
-  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtot->SetStats(kFALSE);\r
-  rangeQtot->Draw();\r
-  \r
-  TH1D* projQ[6];\r
-  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.95);\r
-  leg2->SetFillColor(0);\r
-  isGood = kFALSE;\r
-  for(Int_t iCent=0; iCent<6; ++iCent) {  \r
-    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kQtotP+iCent));\r
-    projQ[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projQCent%d",iCent)) : 0x0);\r
-    if(projQ[iCent]) {\r
-      projQ[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);\r
-      Double_t maximum = projQ[iCent]->GetMaximum();\r
-      if(maximum>1.0)\r
-        projQ[iCent]->Scale(1.0/maximum);\r
-      projQ[iCent]->SetStats(kFALSE);\r
-      projQ[iCent]->Draw("same");\r
-      leg2->AddEntry(projQ[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");\r
-      isGood = kTRUE;\r
-    }\r
-  }\r
-  if(isGood) leg2->Draw();\r
-  isGoodForSaving = isGoodForSaving || isGood;\r
-  return isGoodForSaving;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotTrackingSummary(Int_t centralityClass, Double_t* trendValues) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  // eta-phi distr. for positive TPC tracks\r
-  TVirtualPad* pad = ((TVirtualPad*)l->At(0)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TPC positive ref. tracks");\r
-  \r
-  TH3F* h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass));\r
-  TH2F* h2FtpcP = 0x0;\r
-  Float_t nada=0.0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtpcP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtpcP->SetStats(kFALSE);\r
-    h2FtpcP->Draw("samecolz"); isGoodForSaving = kTRUE;\r
-    isGoodForSaving = kTRUE;\r
-  }\r
-  //-----------------\r
-  // eta-phi distr. for negative TPC tracks\r
-  pad = ((TVirtualPad*)l->At(1)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TPC negative ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass));\r
-  TH2F* h2FtpcN = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtpcN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtpcN->SetStats(kFALSE);\r
-    h2FtpcN->Draw("samecolz"); \r
-    isGoodForSaving = kTRUE;\r
-  }\r
-  //----------------------------------------------\r
-  // eta-phi distr. for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(3)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD positive ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass));\r
-  TH2F* h2FtrdP = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtrdP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtrdP->SetStats(kFALSE);\r
-    h2FtrdP->SetMaximum((h2FtpcP ? h2FtpcP->GetMaximum() : h2FtrdP->GetMaximum()));\r
-    h2FtrdP->Draw("samecolz"); \r
-    isGoodForSaving=kTRUE;\r
-  }\r
-  //--------------------------------------------\r
-  // eta-phi distr. for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(4)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD negative ref. tracks");\r
-  \r
-  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass));\r
-  TH2F* h2FtrdN = 0x0;\r
-  if(h3F && h3F->GetEntries()>10) {\r
-    h2FtrdN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();\r
-    h2FtrdN->SetStats(kFALSE);\r
-    h2FtrdN->SetMaximum(h2FtpcN ? h2FtpcN->GetMaximum() : h2FtrdN->GetMaximum());\r
-    h2FtrdN->Draw("samecolz"); \r
-    isGoodForSaving=kTRUE;\r
-  }\r
-  //----------------------------------------------\r
-  // eta-phi efficiency for positive TRD tracks\r
-  pad = ((TVirtualPad*)l->At(6)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "Efficiency positive tracks");\r
-  \r
-  TH2F* h2Feff = (h2FtrdP ? (TH2F*)h2FtrdP->Clone("h2FeffPos") : 0x0);\r
-  if(h2Feff) {\r
-    h2Feff->Reset();\r
-    h2Feff->SetStats(kFALSE);\r
-    h2Feff->Divide(h2FtrdP, h2FtpcP);\r
-    h2Feff->SetMaximum(1.0);\r
-    if(h2Feff->GetEntries()>1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-  }\r
-  //-------------------------------------------------\r
-  // eta-phi efficiency for negative TRD tracks\r
-  pad = ((TVirtualPad*)l->At(7)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "Efficiency negative tracks");\r
-  \r
-  h2Feff = (h2FtrdN ? (TH2F*)h2FtrdN->Clone("h2FeffNeg") : 0x0);\r
-  if(h2Feff) {\r
-    h2Feff->Reset();\r
-    h2Feff->SetStats(kFALSE);\r
-    h2Feff->Divide(h2FtrdN, h2FtpcN);\r
-    h2Feff->SetMaximum(1.0);\r
-    if(h2Feff->GetEntries()>0.1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-  }\r
-  //-----------------------------------------------------\r
-  // <ntracklets> vs (phi,eta)\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  rangeEtaPhi->Draw();\r
-  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");\r
-  \r
-  TProfile2D* hProf2D;\r
-  if((hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvNtrkl+centralityClass)))) {\r
-    if(hProf2D->GetEntries()>10) {\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(6.);\r
-      if(hProf2D->GetEntries()>1) { hProf2D->Draw("samecolz"); isGoodForSaving = kTRUE; }\r
-    }\r
-  }\r
-  //---------------------------------------------------------\r
-  // TPC-TRD matching efficiency vs pt\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  TH1F* hFeffP = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass)), kTRUE);\r
-  TH1F* hFeffN = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass)), kTRUE);\r
-  TH1F* hFeffP4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+centralityClass)), kTRUE);\r
-  TH1F* hFeffN4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+centralityClass)), kTRUE);\r
-  TH1F* hFeffP5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+centralityClass)), kTRUE);\r
-  TH1F* hFeffN5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+centralityClass)), kTRUE);\r
-  TH1F* hFeffP6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+centralityClass)), kTRUE);\r
-  TH1F* hFeffN6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),\r
-        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+centralityClass)), kTRUE);\r
-  \r
-  TF1* funcConst = new TF1("funcConst", "[0]", 1.0, 3.0);\r
-  \r
-  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");\r
-  TH2F* rangeEffPt2=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);\r
-  rangeEffPt2->SetStats(kFALSE);\r
-  SetStyle(rangeEffPt2->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEffPt2->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEffPt2->Draw();\r
-  lat->DrawLatex(0.5, 1.42, "TRD-TPC matching efficiency");\r
-  //++++++++++++++++++\r
-  TLine line;\r
-  line.SetLineStyle(2);\r
-  line.SetLineWidth(2);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.7, rangeEffPt2->GetXaxis()->GetXmax(), 0.7);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.9, rangeEffPt2->GetXaxis()->GetXmax(), 0.9);\r
-  line.SetLineStyle(1);\r
-  line.SetLineWidth(1);\r
-  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 1.0, rangeEffPt2->GetXaxis()->GetXmax(), 1.0);\r
-  TLegend* leg=new TLegend(0.2, 0.7, 0.6, 0.89);\r
-  leg->SetNColumns(2);\r
-  leg->SetFillColor(0);\r
-  if(hFeffP){\r
-    hFeffP->SetMarkerStyle(24);\r
-    hFeffP->SetMarkerColor(2);\r
-    hFeffP->SetLineColor(2);\r
-    if(trendValues && hFeffP->GetEntries()>1) {\r
-      hFeffP->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-      trendValues[0] = funcConst->GetParameter(0);\r
-      trendValues[1] = funcConst->GetParError(0);\r
-    }\r
-    if(hFeffP->Integral()>0.001) {\r
-      hFeffP->Draw("same"); \r
-      leg->AddEntry(hFeffP, "positives (#geq 1 tracklet)", "p");\r
-    }\r
-  }\r
-  if(hFeffN){\r
-    hFeffN->SetMarkerStyle(24);\r
-    hFeffN->SetMarkerColor(4);\r
-    hFeffN->SetLineColor(4);\r
-    if(trendValues && hFeffN->GetEntries()>1) {\r
-      hFeffN->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-      trendValues[2] = funcConst->GetParameter(0);\r
-      trendValues[3] = funcConst->GetParError(0);\r
-    }\r
-    if(hFeffN->Integral()>0.001) {\r
-      hFeffN->Draw("same"); \r
-      leg->AddEntry(hFeffN, "negatives (#geq 1 tracklet)", "p");\r
-    }\r
-  }\r
-  if(hFeffP4){\r
-    hFeffP4->SetMarkerStyle(25);\r
-    hFeffP4->SetMarkerColor(2);\r
-    hFeffP4->SetLineColor(2);\r
-    if(hFeffP4->Integral()>0.001) {\r
-      hFeffP4->Draw("same"); \r
-      leg->AddEntry(hFeffP4, "positives (4 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN4){\r
-    hFeffN4->SetMarkerStyle(25);\r
-    hFeffN4->SetMarkerColor(4);\r
-    hFeffN4->SetLineColor(4);\r
-    if(hFeffN4->Integral()>0.001) {\r
-      hFeffN4->Draw("same"); \r
-      leg->AddEntry(hFeffN4, "negatives (4 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffP5){\r
-    hFeffP5->SetMarkerStyle(26);\r
-    hFeffP5->SetMarkerColor(2);\r
-    hFeffP5->SetLineColor(2);\r
-    if(hFeffP5->Integral()>0.001) {\r
-      hFeffP5->Draw("same"); \r
-      leg->AddEntry(hFeffP5, "positives (5 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN5){\r
-    hFeffN5->SetMarkerStyle(26);\r
-    hFeffN5->SetMarkerColor(4);\r
-    hFeffN5->SetLineColor(4);\r
-    if(hFeffN5->Integral()>0.001) {\r
-      hFeffN5->Draw("same"); \r
-      leg->AddEntry(hFeffN5, "negatives (5 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffP6){\r
-    hFeffP6->SetMarkerStyle(27);\r
-    hFeffP6->SetMarkerColor(2);\r
-    hFeffP6->SetLineColor(2);\r
-    if(hFeffP6->Integral()>0.001) {\r
-      hFeffP6->Draw("same"); \r
-      leg->AddEntry(hFeffP6, "positives (6 tracklets)", "p");\r
-    }\r
-  }\r
-  if(hFeffN6){\r
-    hFeffN6->SetMarkerStyle(27);\r
-    hFeffN6->SetMarkerColor(4);\r
-    hFeffN6->SetLineColor(4);\r
-    if(hFeffN6->Integral()>0.001) {\r
-      hFeffN6->Draw("same"); \r
-      leg->AddEntry(hFeffN6, "negatives (6 tracklets)", "p");\r
-    }\r
-  }\r
-  leg->Draw();\r
-  \r
-  //--------------------------------------------------------------\r
-  // Nclusters per TRD track\r
-  pad = ((TVirtualPad*)l->At(8)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");\r
-  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);\r
-  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeNclsP->SetStats(kFALSE);\r
-  rangeNclsP->Draw();\r
-  lat->DrawLatex(1.0, 205., "TRD Clusters / track");\r
-  \r
-  TH2F* hNclsVsP=0x0;\r
-  if((hNclsVsP = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+centralityClass)))) {\r
-    hNclsVsP->SetStats(kFALSE);\r
-    if(hNclsVsP->GetEntries()>10) {\r
-      hNclsVsP->Draw("samecolz"); isGoodForSaving=kTRUE;\r
-      if(trendValues) {\r
-        TProfile* h2FProf = hNclsVsP->ProfileX("nclsVsPprof");\r
-        h2FProf->Fit(funcConst, "QME0", "goff", 1.0, 3.0);\r
-        trendValues[4] = funcConst->GetParameter(0);\r
-        trendValues[5] = funcConst->GetParError(0);\r
-      }\r
-    }\r
-  }\r
-  \r
-  delete funcConst;\r
-  return isGoodForSaving;\r
-}\r
-\r
-\r
-//_________________________________________________________________\r
-Bool_t AliTRDcheckESD::PlotPidSummary(Int_t centralityClass, Double_t* trendValues) {\r
-\r
-  Bool_t isGoodForSaving=kFALSE;\r
-  \r
-  TLatex *lat=new TLatex();\r
-  lat->SetTextSize(0.07);\r
-  lat->SetTextColor(2);\r
-  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);\r
-  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);\r
-  gPad->Divide(3,3,0.,0.);\r
-  TList* l=gPad->GetListOfPrimitives();\r
-  // eta-phi distr. for <Qtot> in layer 0\r
-  TVirtualPad* pad;\r
-  TProfile2D* hProf2D;\r
-  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");\r
-  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);\r
-  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeEtaPhi->SetStats(kFALSE);\r
-  \r
-  for(Int_t iLayer=0; iLayer<6; ++iLayer) {\r
-    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+1))); pad->cd();\r
-    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-    pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-    rangeEtaPhi->Draw();\r
-    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));\r
-    \r
-    if(!(hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+6*centralityClass+iLayer)))) continue;\r
-    if(hProf2D && hProf2D->GetEntries()>10) {\r
-      hProf2D->SetStats(kFALSE);\r
-      hProf2D->SetMinimum(0.);\r
-      hProf2D->SetMaximum(4.);\r
-      if(hProf2D->GetEntries()>10) { hProf2D->Draw("samecolz"); isGoodForSaving=kTRUE; }\r
-    }\r
-  }\r
-    \r
-  // PH versus slice number\r
-  pad = ((TVirtualPad*)l->At(2)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");\r
-  TH2F* rangePHslice = new TH2F("rangePHslice", "", 10, -0.5, 7.5, 10, 0.0, 2000.0);\r
-  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);\r
-  rangePHslice->SetStats(kFALSE);\r
-  rangePHslice->Draw();\r
-  \r
-  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);\r
-  \r
-  TH2F* h2F;\r
-  TH1D* hF;\r
-  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kPHSlice+centralityClass)))) {\r
-    if(h2F && h2F->GetEntries()>10) {\r
-      hF = Proj2D(h2F);\r
-      h2F->SetStats(kFALSE);\r
-      h2F->Draw("samecolz");\r
-      isGoodForSaving=kTRUE;\r
-      if(trendValues) {\r
-        hF->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);\r
-        trendValues[6] = funcPol1->GetParameter(0);\r
-        trendValues[7] = funcPol1->GetParError(0);\r
-        trendValues[8] = funcPol1->GetParameter(1);\r
-        trendValues[9] = funcPol1->GetParError(1);\r
-      }\r
-      hF->SetLineWidth(2);\r
-      hF->Draw("same");\r
-    }\r
-  }\r
-  delete funcPol1;\r
-\r
-  // Qtot vs P\r
-  pad = ((TVirtualPad*)l->At(5)); pad->cd();\r
-  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);\r
-  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);\r
-  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);\r
-  pad->SetLogz();\r
-  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");\r
-  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);\r
-  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);\r
-  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);\r
-  rangeQtotP->SetStats(kFALSE);\r
-  rangeQtotP->Draw();\r
-  \r
-  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kQtotP+centralityClass)))) {\r
-    if(h2F && h2F->GetEntries()>10) {\r
-      h2F->SetStats(kFALSE);\r
-      h2F->Draw("samecolz");\r
-      isGoodForSaving=kTRUE;\r
-      hF = Proj2D(h2F);\r
-      hF->SetLineWidth(2);\r
-      hF->Draw("same");\r
-      if(trendValues) {\r
-        trendValues[10] = hF->GetBinContent(hF->FindBin(1.0));\r
-        trendValues[11] = hF->GetBinError(hF->FindBin(1.0));\r
-      }\r
-    }\r
-  }\r
-  return isGoodForSaving;\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::DrawTRDGrid() {\r
-  //\r
-  //   Draw a grid of lines showing the TRD supermodule and stack structure in (eta,phi) coordinates.\r
-  //   The canvas on which to draw must already exist.\r
-  //\r
-  TLine line;\r
-  line.SetLineColor(2);\r
-  line.SetLineWidth(1);\r
-  line.SetLineStyle(2);\r
-  for(Int_t i=0; i<=9; ++i) {\r
-    line.DrawLine(-1.0, 2.0*TMath::Pi()/18.0*i, +1.0, 2.0*TMath::Pi()/18.0*i);\r
-    line.DrawLine(-1.0, -2.0*TMath::Pi()/18.0*i, +1.0, -2.0*TMath::Pi()/18.0*i);\r
-  }\r
-  line.DrawLine(-0.85, -3.2, -0.85, +3.2);\r
-  line.DrawLine(-0.54, -3.2, -0.54, +3.2);\r
-  line.DrawLine(-0.16, -3.2, -0.16, +3.2);\r
-  line.DrawLine(+0.16, -3.2, +0.16, +3.2);\r
-  line.DrawLine(+0.54, -3.2, +0.54, +3.2);\r
-  line.DrawLine(+0.85, -3.2, +0.85, +3.2);\r
-}\r
-\r
-//_________________________________________________________________\r
-void AliTRDcheckESD::SetStyle(TH1* hist, \r
-                             Int_t lineStyle, Int_t lineColor, Int_t lineWidth, \r
-                             Int_t markerStyle, Int_t markerColor, Int_t markerSize) {\r
-  //\r
-  // Set style settings for histograms\r
-  //\r
-  if(!hist) return;\r
-  hist->SetLineStyle(lineStyle);\r
-  hist->SetLineColor(lineColor);\r
-  hist->SetLineWidth(lineWidth);\r
-  hist->SetMarkerStyle(markerStyle);\r
-  hist->SetMarkerColor(markerColor);\r
-  hist->SetMarkerSize(markerSize);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, \r
-                              Float_t labelSize) {\r
-  //\r
-  // Set style settings for axes\r
-  //\r
-  if(!axis) return;\r
-  axis->SetTitle(title);\r
-  axis->SetTitleSize(titleSize);\r
-  axis->SetTitleOffset(titleOffset); \r
-  axis->CenterTitle(centerTitle);\r
-  axis->SetLabelSize(labelSize);\r
-}\r
-\r
-//____________________________________________________________________\r
-void AliTRDcheckESD::FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]) {\r
-  //\r
-  // Find the isolated bunch crossings\r
-  //\r
-  Int_t isolationSize = 5;      // number of free bunches in both directions\r
-  for(Int_t bcBin=1; bcBin<=bcHist->GetXaxis()->GetNbins(); ++bcBin) {\r
-    Int_t bc = TMath::Nint(bcHist->GetBinCenter(bcBin));\r
-    if(bc<-0.001 || bc>3499.01) {\r
-      isIsolated[bc] = kFALSE;\r
-      continue;\r
-    }\r
-    Double_t entries = bcHist->GetBinContent(bcBin);\r
-    if(entries<0.001) {\r
-      isIsolated[bc] = kFALSE;\r
-      continue;     // no entries\r
-    }\r
-        \r
-    // check isolation\r
-    isIsolated[bc] = kTRUE;\r
-    for(Int_t ibc = TMath::Max(1,bcBin-isolationSize); ibc<=TMath::Min(3499, bcBin+isolationSize); ++ibc) {\r
-      if(ibc==bcBin) continue;\r
-      if(bcHist->GetBinContent(ibc)>0.01) {\r
-        isIsolated[bc] = kFALSE;\r
-        break;\r
-      }\r
-    }\r
-  }   // end loop over BC bins\r
-  \r
-  cout << "Isolated bunches: " << endl;\r
-  for(Int_t ibc=0; ibc<3500; ++ibc) \r
-    if(isIsolated[ibc]) cout << "BC #" << ibc << endl; \r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetTriggerIndex(const Char_t* name, Bool_t createNew/*=kTRUE*/) {\r
-  //\r
-  //  Return the index of trigger "name" in the trigger histogram.\r
-  //  If the index for this trigger does not exist yet, then assign one if createNew is set to TRUE \r
-  //\r
-  //cout << "GetTriggerIndex for " << name << endl;\r
-  TH1F* triggerHist = (TH1F*)fHistos->At(kTriggerDefs);\r
-  TString nameStr=name;\r
-  for(Int_t i=1; i<=triggerHist->GetXaxis()->GetNbins(); ++i) {\r
-    if(!nameStr.CompareTo(triggerHist->GetXaxis()->GetBinLabel(i))) {\r
-      //cout << "       index found: " << i << endl;\r
-      return i;\r
-    }\r
-  }\r
-  if(createNew) {\r
-    triggerHist->GetXaxis()->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fMatchingPhiEtaCF->GetVar("trigger")>=0) {\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fMatchingPtCF->GetVar("trigger")>=0) {\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fBunchCrossingsCF->GetVar("trigger")>=0) {\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);\r
-      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    if(fCentralityCF->GetVar("trigger")>=0) \r
-      fCentralityCF->GetAxis(fCentralityCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fQtotCF->GetVar("trigger")>=0) \r
-      fQtotCF->GetAxis(fQtotCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fPulseHeightCF->GetVar("trigger")>=0)\r
-      fPulseHeightCF->GetAxis(fPulseHeightCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    if(fExpertCF) {\r
-      if(fExpertCF->GetVar("trigger")>=0)\r
-        for(Int_t istep=0; istep<fExpertCF->GetNStep(); ++istep) \r
-         fExpertCF->GetAxis(fExpertCF->GetVar("trigger"), istep)->SetBinLabel(fNAssignedTriggers+1, name);\r
-    }\r
-    \r
-    ++fNAssignedTriggers;\r
-    return fNAssignedTriggers+1;\r
-  }\r
-  else {\r
-    return -1;\r
-  }\r
-}\r
-\r
-//__________________________________________________________________________________________________\r
-void AliTRDcheckESD::PrintTriggers() const {\r
-  //\r
-  //  Print the available triggers for this run\r
-  //\r
-  if(!fHistos) {\r
-    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;\r
-    return;\r
-  }\r
-  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);\r
-  cout << "Triggers found in this run" << endl;\r
-  cout << "==========================" << endl;\r
-  cout << "Name   Index   Entries    " << endl;\r
-  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {\r
-    if(hTriggers->GetXaxis()->GetBinLabel(it)[0]!='\0') {\r
-      cout << hTriggers->GetXaxis()->GetBinLabel(it) << "  " << hTriggers->GetXaxis()->GetBinCenter(it) << "  " << hTriggers->GetBinContent(it) << endl;\r
-    }\r
-  }\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetTriggerCounter(const Char_t* triggerName) const {\r
-  //\r
-  // Get the number of events for a given trigger name\r
-  //\r
-  if(!fHistos) {\r
-    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;\r
-    return -1;\r
-  }\r
-  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);\r
-  Int_t counter = -1;\r
-  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {\r
-    TString trgString = hTriggers->GetXaxis()->GetBinLabel(it);\r
-    if(!trgString.CompareTo(triggerName)) \r
-      counter = (Int_t)hTriggers->GetBinContent(it);\r
-  }\r
-  if(counter<0) {cout << "AliTRDcheckESD::GetTriggerCounter()  Trigger not found !!";}\r
-  return counter;\r
-}\r
-\r
-\r
-//__________________________________________________________________________________________________________\r
-Int_t AliTRDcheckESD::GetNAssignedTriggers() {\r
-  //\r
-  // Return the number of assigned triggers\r
-  //\r
-  return fNAssignedTriggers;\r
-}\r
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+/////////////////////////////////////////////////////
+//
+// Check basic detector results at ESD level
+//   - Geometrical efficiency  
+//   - Tracking efficiency  
+//   - PID efficiency  
+//   - Refit efficiency  
+//
+// Author
+//   Alex Bercuci <A.Bercuci@gsi.de>
+//   Ionut Arsene <i.c.arsene@gsi.de>
+//
+//////////////////////////////////////////////////////
+
+#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 <TH1D.h>
+#include <TH2D.h>
+#include <TH3D.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>
+#include <TTree.h>
+#include <TROOT.h>
+#include <TChain.h>
+#include <TParticle.h>
+#include <TTimeStamp.h>
+#include <TRandom.h>
+#include <TString.h>
+
+#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisCuts.h"
+#include "AliPhysicsSelection.h"
+#include "AliESDEvent.h"
+#include "AliESDkink.h"
+#include "AliMCEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliESDpid.h"
+
+#include "AliESDtrack.h"
+#include "AliMCParticle.h"
+#include "AliPID.h"
+#include "AliStack.h"
+#include "AliTrackReference.h"
+//#include "AliESDCentrality.h"
+#include "AliMultiplicity.h"
+#include "AliCFContainer.h"
+
+#include "AliTRDcheckESD.h"
+#include <iostream>
+using std::cout;
+using std::endl;
+
+ClassImp(AliTRDcheckESD)
+
+const Float_t AliTRDcheckESD::fgkxTPC = 290.;
+const Float_t AliTRDcheckESD::fgkxTOF = 365.;
+const UChar_t AliTRDcheckESD::fgkNgraph[AliTRDcheckESD::kNrefs] ={
+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()
+  ,fStatus(0)
+  ,fNRefFigures(0)
+  ,fESD(NULL)
+  ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
+  ,fHistos(NULL)
+  ,fResults(NULL)
+  ,fExpertCF(NULL)
+  ,fMatchingPhiEtaCF(NULL)
+  ,fMatchingPtCF(NULL)
+  ,fBunchCrossingsCF(NULL)
+  ,fCentralityCF(NULL)
+  ,fQtotCF(NULL)
+  ,fPulseHeightCF(NULL)
+  ,fReferenceTrackFilter(NULL)
+  ,fPhysSelTriggersEnabled(kFALSE)
+  ,fUserEnabledTriggers("")
+  ,fNAssignedTriggers(0)
+{
+  //
+  // Default constructor
+  //
+  for(Int_t i=0; i<kNTrdCfVariables; ++i) {
+    fExpertCFVars[i] = -1;
+    fMatchingPhiEtaCFVars[i] = -1;
+    fMatchingPtCFVars[i] = -1;
+    fBunchCrossingsCFVars[i] = -1;
+    fCentralityCFVars[i] = -1;
+    fQtotCFVars[i] = -1;
+    fPulseHeightCFVars[i] = -1;
+    fExpertCFVarsEnabled[i] = kFALSE;
+    fExpertCFVarNBins[i] = 0;
+    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;
+    fExpertCFVarBins[i] = "";
+  }
+  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;
+  SetNameTitle("TRDcheckESD", "Check TRD @ ESD level");
+  SetMC(kTRUE);
+}
+
+//____________________________________________________________________
+AliTRDcheckESD::AliTRDcheckESD(char* name):
+  AliAnalysisTaskSE(name)
+  ,fStatus(0)
+  ,fNRefFigures(0)
+  ,fESD(NULL)
+  ,fMC(NULL)
+  ,fESDpid(new AliESDpid)
+  ,fHistos(NULL)
+  ,fResults(NULL)
+  ,fExpertCF(NULL)
+  ,fMatchingPhiEtaCF(NULL)
+  ,fMatchingPtCF(NULL)
+  ,fBunchCrossingsCF(NULL)
+  ,fCentralityCF(NULL)
+  ,fQtotCF(NULL)
+  ,fPulseHeightCF(NULL)
+  ,fReferenceTrackFilter(NULL)
+  ,fPhysSelTriggersEnabled(kFALSE)
+  ,fUserEnabledTriggers("")
+  ,fNAssignedTriggers(0)
+{
+  //
+  // Default constructor
+  //
+  for(Int_t i=0; i<kNTrdCfVariables; ++i) {
+    fExpertCFVars[i] = -1;
+    fMatchingPhiEtaCFVars[i] = -1;
+    fMatchingPtCFVars[i] = -1;
+    fBunchCrossingsCFVars[i] = -1;
+    fCentralityCFVars[i] = -1;
+    fQtotCFVars[i] = -1;
+    fPulseHeightCFVars[i] = -1;
+    fExpertCFVarsEnabled[i] = kFALSE;
+    fExpertCFVarNBins[i] = 0;
+    fExpertCFVarRanges[i][0] = -999.; fExpertCFVarRanges[i][1] = -999.;
+    fExpertCFVarBins[i] = "";
+  }
+  fExpertCFEnabledSteps[0] = kFALSE; fExpertCFEnabledSteps[1] = kFALSE; fExpertCFEnabledSteps[2] = kFALSE;
+  SetMC(kTRUE);
+  SetTitle("Check TRD @ ESD level");
+  DefineOutput(1, TObjArray::Class());
+}
+
+//____________________________________________________________________
+AliTRDcheckESD::~AliTRDcheckESD()
+{
+  // Destructor
+  if(fHistos && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){
+    if(fHistos->IsOwner()) fHistos->Delete();
+    delete fHistos;
+    fHistos = NULL;
+  }
+  
+  if(fResults){
+    fResults->Delete();
+    delete fResults;
+  }
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, 
+                                   Int_t nbins, Double_t lowLim, Double_t highLim) {
+  //
+  // Configure variables for the expert CF container
+  //
+  fExpertCFVarsEnabled[var] = kTRUE;
+  fExpertCFVarNBins[var] = nbins;
+  fExpertCFVarRanges[var][0] = lowLim;
+  fExpertCFVarRanges[var][1] = highLim;
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, 
+                                   const Char_t* bins) {
+  //
+  // Configure variables for the expert CF container
+  //
+  fExpertCFVarsEnabled[var] = kTRUE;
+  fExpertCFVarBins[var] = bins;
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::UserCreateOutputObjects()
+{      
+  //
+  // Create Output Containers (TObjectArray containing 1D histograms)
+  //
+  Histos();
+  PostData(1, fHistos);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::MakeSummaryFromCF(Double_t* trendValues, const Char_t* triggerName, Bool_t useIsolatedBC, Bool_t cutTOFbc){
+  //
+  // Draw summary plots for the ESDcheck task using the CF container
+  //
+
+  cout << "Make summary from CF" << endl;
+  TCanvas *cOut=0x0;
+  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");
+  cOut = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  PlotTrackingSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  cOut->SaveAs("trackingSummary.gif");
+  
+  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");
+  cOut = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  //GetRefFigure(6);
+  PlotPidSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  cOut->SaveAs("pidSummary.gif");
+
+  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");
+  cOut = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);
+  cOut->cd();
+  //GetRefFigure(7);
+  PlotCentSummaryFromCF(trendValues, triggerName, useIsolatedBC, cutTOFbc);
+  cOut->SaveAs("centSummary.gif");
+
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::MakeSummary(Double_t* trendValues){
+  //
+  // Draw summary plots for the ESDcheck task
+  //
+  // Old method to draw summary pictures from histograms. Use the MakeSummaryFromCF() when CF container is present
+  
+  cout << "Make summary" << endl;
+  TCanvas *cTracking=0x0;
+  if(gROOT->FindObject("trackingSummary")) delete gROOT->FindObject("trackingSummary");
+  cTracking = new TCanvas("trackingSummary", "Tracking summary for the ESD task", 1600, 1200);
+  cTracking->cd();
+  //GetRefFigure(5);
+  if(PlotTrackingSummary(0, trendValues))
+    cTracking->SaveAs("trackingSummary.gif");
+  
+  TCanvas* cPid = 0x0;
+  if(gROOT->FindObject("pidSummary")) delete gROOT->FindObject("pidSummary");
+  cPid = new TCanvas("pidSummary", "PID summary for the ESD task", 1600, 1200);
+  cPid->cd();
+  //GetRefFigure(6);
+  if(PlotPidSummary(0, trendValues))
+    cPid->SaveAs("pidSummary.gif");
+
+  TCanvas* cCent=0x0;
+  if(gROOT->FindObject("centSummary")) delete gROOT->FindObject("centSummary");
+  cCent = new TCanvas("centSummary", "Centrality summary for the ESD task", 1600, 1200);
+  cCent->cd();
+  //GetRefFigure(7);
+  if(PlotCentSummary(trendValues))
+    cCent->SaveAs("centSummary.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;
+  }
+  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];
+  TH1 *hF(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);
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  TLine line;
+  TTimeStamp now;
+  switch(ifig){
+  case kNCl: // number of clusters/track
+    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-1]; 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(.62, .77, .98, .98);
+    leg->SetHeader("TRD Efficiency");
+    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.4);
+    hF->GetXaxis()->SetMoreLogLabels();
+    hF->GetYaxis()->CenterTitle(1);
+    hF->Draw("p");
+    for(Int_t ig(0); ig<fgkNgraph[kTRDstat-1]; ig++){
+      if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE;
+      g->Draw("pl"); leg->AddEntry(g, title[ig], "pl");
+      //PutTrendValue(name[id], g->GetMean(2));
+      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));
+    }
+    leg->Draw(); gPad->SetLogx();
+    break;
+  case kTRDmom: // Energy loss
+    if(!(arr = (TObjArray*)fResults->At(kTRDmom))) return kFALSE;
+    leg = new TLegend(.65, .7, .95, .99);
+    leg->SetHeader("Energy Loss");
+    leg->SetBorderSize(1); leg->SetFillColor(0);
+    title[0] = "Max & 90% quantile";
+    title[1] = "Mean & 60% quantile";
+    hF = new TH1S("hFcheckESD", ";layer;#Delta E", 6, -0.5, 5.5);
+    hF->SetMaximum(1.3);hF->SetMinimum(-.3);
+    hF->Draw("p");
+    for(Int_t ig(0); ig<fgkNgraph[kTRDmom-1]; ig++){
+      if(!(ga = (TGraphAsymmErrors*)arr->At(ig))) return kFALSE;
+      ga->Draw("pl"); leg->AddEntry(ga, title[ig], "pl");
+      //PutTrendValue(name[id], g->GetMean(2));
+      //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));
+    }
+    leg->Draw();gPad->SetLogx(kFALSE);
+    break;
+  case kPtRes: // Pt resolution @ vertex
+    if(!(arr = (TObjArray*)fResults->At(kPtRes))) return kFALSE;
+    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-1]/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);
+    {
+      Int_t nPlots(0);
+      //for(Int_t ig(fgkNgraph[kPtRes-1]/2); ig<fgkNgraph[kPtRes-1]; 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");
+        //PutTrendValue(name[id], g->GetMean(2));
+        //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2));
+      }
+      if(nPlots) leg->Draw();
+    }
+    break;
+  case 5: // plot a 3x3 canvas with tracking related histograms
+    PlotTrackingSummary(0);
+    break;
+    
+  case 6: // plot a 3x3 canvas with PID related histograms
+    PlotPidSummary(0);
+    break;
+
+  case 7: // plot a 3x3 canvas with centrality dependence histograms
+    PlotCentSummary();
+    break;
+
+  }
+  return kTRUE;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::UserExec(Option_t *){
+  //
+  // Run the Analysis
+  //
+  fESD = dynamic_cast<AliESDEvent*>(InputEvent());
+  fMC = MCEvent();
+
+  if(!fESD){
+    AliError("ESD event missing.");
+    return;
+  }
+  
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if(!inputHandler) return;
+  
+  if(!fPhysSelTriggersEnabled) {
+    InitializeCFContainers();
+    fPhysSelTriggersEnabled = kTRUE;
+  }
+    
+  UInt_t isSelected = AliVEvent::kAny;
+  if(inputHandler){
+    if(inputHandler->GetEventSelection()) {
+      isSelected = inputHandler->IsEventSelected();
+    }
+  }
+  if(!isSelected) return;
+
+  TString triggerClasses = fESD->GetFiredTriggerClasses();
+  //  cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++triggers fired:  " << triggerClasses.Data() << endl;
+  TObjArray* triggers = triggerClasses.Tokenize(" ");
+  TObjArray* userTriggers = fUserEnabledTriggers.Tokenize(";");
+  if(triggers->GetEntries()<1) return;
+  Bool_t hasGoodTriggers = kFALSE;
+  Int_t triggerIndices[kNMaxAssignedTriggers] = {0};
+  Int_t nTrigFired=0;
+  for(Int_t i=0; i<triggers->GetEntries(); ++i) {
+    //    cout << "check trigger " << triggers->At(i)->GetName() << endl;
+    TString trigStr=triggers->At(i)->GetName();
+    if(!trigStr.Contains("NOTRD") && !trigStr.Contains("MUON")) hasGoodTriggers = kTRUE;    // check wheter TRD was read out in this event
+    if(i>=kNMaxAssignedTriggers) continue;
+    //    triggerIndices[i] = GetTriggerIndex(triggers->At(i)->GetName(), kFALSE);
+    for(Int_t j=0;j<userTriggers->GetEntries();++j) {
+      TString userTrigStr=userTriggers->At(j)->GetName();
+      if(trigStr.Contains(userTrigStr.Data())) {
+       triggerIndices[nTrigFired] = GetTriggerIndex(userTrigStr.Data(), kFALSE);
+       if(triggerIndices[nTrigFired]==-1) triggerIndices[nTrigFired]=1;  // 0-assigned to all other triggers
+       ++nTrigFired;
+      }
+    }
+    triggerIndices[nTrigFired] = GetTriggerIndex(trigStr.Data(), kFALSE);
+    if(triggerIndices[nTrigFired]==-1) triggerIndices[nTrigFired]=1;  // 0-assigned to all other triggers
+    ++nTrigFired;
+  } 
+  //  Int_t nTRDtracks = fESD->GetNumberOfTrdTracks();
+  //  Int_t nGlobalTracks = fESD->GetNumberOfTracks();
+  //cout << "TRD/All tracks: " << nTRDtracks << "/" << nGlobalTracks << endl;
+  for(Int_t i=0; i<nTrigFired; ++i) 
+    ((TH1F*)fHistos->At(kTriggerDefs))->Fill(triggerIndices[i]);
+
+  if(!hasGoodTriggers) {
+    PostData(1, fHistos);
+    return;
+  }
+  
+  // Get MC information if available
+  AliStack * fStack = NULL;
+  if(HasMC()){
+    if(!fMC){ 
+      AliWarning("MC event missing");
+      SetMC(kFALSE);
+    } else {
+      if(!(fStack = fMC->Stack())){
+        AliWarning("MC stack missing");
+        SetMC(kFALSE);
+      }
+    }
+  }
+  TH1 *h(NULL);
+  
+  Double_t values[kNTrdCfVariables];      // array where the CF container variables are stored
+  values[kEventVtxZ] = fESD->GetPrimaryVertex()->GetZv();
+  values[kEventBC] = fESD->GetBunchCrossNumber();
+  
+  const AliMultiplicity* mult=fESD->GetMultiplicity();
+  Double_t itsNTracklets = mult->GetNumberOfTracklets();
+  if(itsNTracklets<1) return;
+  Int_t multLimits[6] = {0, 700, 1400, 2100, 2800, 3500};
+  Int_t centralityClass = 0;
+  for(Int_t iCent=0; iCent<5; ++iCent) {
+    if(itsNTracklets>=multLimits[iCent] && itsNTracklets<multLimits[iCent+1])
+      centralityClass=iCent+1;
+  }
+  values[kEventMult] = itsNTracklets;
+  if(centralityClass == 0) return;
+  
+  Double_t* valuesMatchingPhiEtaCF = new Double_t[fMatchingPhiEtaCF->GetNVar()];
+  Double_t* valuesMatchingPtCF = new Double_t[fMatchingPtCF->GetNVar()];
+  Double_t* valuesBCCF = new Double_t[fBunchCrossingsCF->GetNVar()];
+  Double_t* valuesCentCF = new Double_t[fCentralityCF->GetNVar()];
+  Double_t* valuesQtotCF = new Double_t[fQtotCF->GetNVar()];
+  Double_t* valuesPHCF = new Double_t[fPulseHeightCF->GetNVar()];
+  Double_t* valuesExpertCF = (fExpertCF ? new Double_t[fExpertCF->GetNVar()] : 0x0);
+  
+  AliESDtrack *esdTrack(NULL);
+  for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){
+    esdTrack = fESD->GetTrack(itrk);
+    //    cout << "track pt/eta: " << esdTrack->Pt() << "/" << esdTrack->Eta() << endl;
+    Float_t dcaxy,dcaz;
+    esdTrack->GetImpactParameters(dcaxy,dcaz);
+    //    cout << "dca xy/z: " << dcaxy << "/" << dcaz << endl;
+    //    cout << "TPC ncls: " << esdTrack->GetTPCNcls() << endl;
+    //    cout << "ITS hit map: ";
+    //    for (Int_t iC=0; iC<6; iC++) {
+    //      cout << ((esdTrack->GetITSClusterMap())&(1<<(iC)) ? "1" : "0") << flush;
+    //    }
+    //    cout << endl;
+    if(!fReferenceTrackFilter->IsSelected(esdTrack)) continue;
+    //    cout << "track passed" << endl;    
+
+    ULong_t status = esdTrack->GetStatus(); //PrintStatus(status);
+            
+    // pid quality
+    Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin);
+
+    // find position and momentum of the track at entrance in TRD
+    Double_t rTRD[6] = {298.0, 311.0, 324.0, 337.0, 350.0, 363.0};
+    Double_t localCoord[6][3] = {{0.0}};
+    Bool_t localCoordGood[6];
+    for(Int_t il=0;il<6;++il) localCoordGood[il] = esdTrack->GetXYZAt(rTRD[il], fESD->GetMagneticField(), localCoord[il]);
+    Double_t localMom[6][3] = {{0.0}};
+    Bool_t localMomGood[6];
+    for(Int_t il=0; il<6; ++il) localMomGood[il] = esdTrack->GetPxPyPzAt(rTRD[il], fESD->GetMagneticField(), localMom[il]);
+    //Double_t localPhi = (localMomGood ? TMath::ATan2(localMom[1], localMom[0]) : 0.0);
+    Double_t localSagitaPhi[6] = {-999.};
+    for(Int_t il=0; il<6; ++il) localSagitaPhi[il] = (localCoordGood[il] ? TMath::ATan2(localCoord[il][1], localCoord[il][0]) : -999.);
+
+    values[kTrackTOFBC]      = esdTrack->GetTOFBunchCrossing(fESD->GetMagneticField());
+    Float_t dcaXY=0.0; Float_t dcaZ=0.0;
+    esdTrack->GetImpactParameters(dcaXY, dcaZ);
+    values[kTrackDCAxy]  = dcaXY;
+    values[kTrackDCAz]   = dcaZ;
+    values[kTrackCharge] = esdTrack->Charge();
+    values[kTrackPhi]    = localSagitaPhi[0];
+    values[kTrackEta]    = esdTrack->Eta();
+    values[kTrackPt]     = esdTrack->Pt();
+    values[kTrackP]      = esdTrack->P();
+    values[kTrackTrdTracklets] = esdTrack->GetTRDntracklets();
+    values[kTrackTrdClusters] = esdTrack->GetTRDncls();
+    for(Int_t i=0; i<6; ++i) values[kTrackQtot+i] = 0.0;
+        
+    if(localCoordGood[0] && localMomGood[0]) {
+      for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {
+       values[kEventTrigger] = triggerIndices[itrig];
+       if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {
+         for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];
+         fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 0);
+       }
+       if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {
+         for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];
+         fMatchingPtCF->Fill(valuesMatchingPtCF, 0);
+       }
+       if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)
+         if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {
+           for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];
+           fBunchCrossingsCF->Fill(valuesBCCF, 0);
+         }
+       if(fExpertCF) {
+         if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0))
+           if(fExpertCF->GetStep("TPC")>=0 && fExpertCF->GetStep("TPC")<3) {
+             for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];
+             fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TPC"));
+           }
+       }
+      }
+    }
+            
+    // TRD reference tracks
+    if(values[kTrackTrdTracklets]>=1) {
+      // (slicePH,sliceNo) distribution and Qtot from slices
+      for(Int_t iPlane=0; iPlane<6; iPlane++) {
+        values[kTrackQtot+iPlane] = fgkQs*esdTrack->GetTRDslice(iPlane, 0);
+       values[kTrackPhi] = localSagitaPhi[iPlane];
+       for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {
+         values[kEventTrigger] = triggerIndices[itrig];
+         if((fCentralityCF->GetVar("trigger")<0 && itrig==0) || (fCentralityCF->GetVar("trigger")>=0)) {
+           for(Int_t iv=0; iv<fCentralityCF->GetNVar(); ++iv) valuesCentCF[iv] = values[fCentralityCFVars[iv]];
+           valuesCentCF[fCentralityCF->GetNVar()-1] = values[kTrackQtot+iPlane];
+           fCentralityCF->Fill(valuesCentCF, 0);
+         }
+         if(values[kTrackTrdTracklets]>=4)
+           if((fQtotCF->GetVar("trigger")<0 && itrig==0) || (fQtotCF->GetVar("trigger")>=0)) {
+             for(Int_t iv=0; iv<fQtotCF->GetNVar()-2; ++iv) valuesQtotCF[iv] = values[fQtotCFVars[iv]];
+             valuesQtotCF[fQtotCF->GetNVar()-2] = values[kTrackQtot+iPlane];
+             valuesQtotCF[fQtotCF->GetNVar()-1] = iPlane;
+             fQtotCF->Fill(valuesQtotCF, 0);
+           }
+       }
+        for(Int_t iSlice=0; iSlice<8; iSlice++) {
+         if(esdTrack->GetTRDslice(iPlane, iSlice)>20.) {
+           values[kTrackPHslice+iSlice] =  fgkQs*esdTrack->GetTRDslice(iPlane, iSlice);
+           h = (TH2F*)fHistos->At(kPHSlice); h->Fill(iSlice, values[kTrackPHslice+iSlice]);
+           h = (TH2F*)fHistos->At(kPHSlice+centralityClass); h->Fill(iSlice, values[kTrackPHslice+iSlice]);
+           for(Int_t itrig=0; itrig<triggers->GetEntries(); ++itrig) {
+             values[kEventTrigger] = triggerIndices[itrig];
+             if((fPulseHeightCF->GetVar("trigger")<0 && itrig==0) || (fPulseHeightCF->GetVar("trigger")>=0)) {
+               for(Int_t iv=0; iv<fPulseHeightCF->GetNVar()-2; ++iv) valuesPHCF[iv] = values[fPulseHeightCFVars[iv]];
+               valuesPHCF[fPulseHeightCF->GetNVar()-2] = values[kTrackPHslice+iSlice];
+               valuesPHCF[fPulseHeightCF->GetNVar()-1] = iSlice;
+               fPulseHeightCF->Fill(valuesPHCF, 0);
+             }
+           }
+         }
+       }
+      }
+      values[kTrackPhi] = localSagitaPhi[0];
+            
+      if(localCoordGood[0] && localMomGood[0]) {
+       for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {
+         values[kEventTrigger] = triggerIndices[itrig];
+         if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {
+           for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];
+           fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 1);
+         }
+         if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {
+           for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];
+           fMatchingPtCF->Fill(valuesMatchingPtCF, 1);
+         }
+         if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)
+           if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {
+             for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];
+             fBunchCrossingsCF->Fill(valuesBCCF, 1);
+           }
+         if(fExpertCF) {
+           if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {
+             if(fExpertCF->GetStep("TRD")>=0 && fExpertCF->GetStep("TRD")<3) {
+               for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];
+               fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TRD"));
+             }
+           }
+         } 
+       }
+        if(Bool_t(status & AliESDtrack::kTOFpid)) {
+         for(Int_t itrig=0; itrig<nTrigFired; ++itrig) {
+           values[kEventTrigger] = triggerIndices[itrig];
+           if((fMatchingPhiEtaCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPhiEtaCF->GetVar("trigger")>=0)) {
+             for(Int_t iv=0; iv<fMatchingPhiEtaCF->GetNVar(); ++iv) valuesMatchingPhiEtaCF[iv] = values[fMatchingPhiEtaCFVars[iv]];
+             fMatchingPhiEtaCF->Fill(valuesMatchingPhiEtaCF, 2);
+           }
+           if((fMatchingPtCF->GetVar("trigger")<0 && itrig==0) || (fMatchingPtCF->GetVar("trigger")>=0)) {
+             for(Int_t iv=0; iv<fMatchingPtCF->GetNVar(); ++iv) valuesMatchingPtCF[iv] = values[fMatchingPtCFVars[iv]];
+             fMatchingPtCF->Fill(valuesMatchingPtCF, 2);
+           }
+           if(values[kTrackPt]>1.0 && values[kTrackPt]<3.0)
+             if((fBunchCrossingsCF->GetVar("trigger")<0 && itrig==0) || (fBunchCrossingsCF->GetVar("trigger")>=0)) {
+               for(Int_t iv=0; iv<fBunchCrossingsCF->GetNVar(); ++iv) valuesBCCF[iv] = values[fBunchCrossingsCFVars[iv]];
+               fBunchCrossingsCF->Fill(valuesBCCF, 2);
+             }
+           if(fExpertCF) {
+             if((fExpertCF->GetVar("trigger")<0 && itrig==0) || (fExpertCF->GetVar("trigger")>=0)) {
+               if(fExpertCF->GetStep("TOF")>=0 && fExpertCF->GetStep("TOF")<3) {
+                 for(Int_t iv=0; iv<fExpertCF->GetNVar(); ++iv) valuesExpertCF[iv] = values[fExpertCFVars[iv]];
+                 fExpertCF->Fill(valuesExpertCF, fExpertCF->GetStep("TOF"));
+               }
+             }
+           }
+         }
+       }
+      }
+    }  // end if nTRDtrkl>=1
+    
+    // look at external track param
+    const AliExternalTrackParam *op = esdTrack->GetOuterParam();
+    const AliExternalTrackParam *ip = esdTrack->GetInnerParam();
+
+    Double_t pt(0.), pt0(0.), ptTRD(0.); 
+    // read MC info if available
+    Bool_t kFOUND(kFALSE), kPhysPrim(kFALSE);
+    AliMCParticle *mcParticle(NULL);
+    if(HasMC()){
+      AliTrackReference *ref(NULL); 
+      Int_t fLabel(esdTrack->GetLabel());
+      Int_t fIdx(TMath::Abs(fLabel));
+      if(!fStack || fIdx > fStack->GetNtrack()) continue; 
+      
+      // read MC particle 
+      if(!(mcParticle = (AliMCParticle*) fMC->GetTrack(fIdx))) {
+        AliWarning(Form("MC particle missing. Label[ %d].", fLabel));
+        continue;
+      }
+  
+      pt   = esdTrack->Pt();
+      pt0  = mcParticle->Pt();
+      //Double_t eta0 = mcParticle->Eta();
+      //Double_t phi0 = mcParticle->Phi();
+      kPhysPrim = fMC->IsPhysicalPrimary(fIdx);
+
+      // read track references
+      Int_t nRefs = mcParticle->GetNumberOfTrackReferences();
+      if(!nRefs){
+        AliWarning(Form("No TR found for track @ Label[%d].", fLabel));
+        continue;
+      }
+      Int_t iref = 0;
+      while(iref<nRefs){
+        ref = mcParticle->GetTrackReference(iref);
+        if(ref->LocalX() > fgkxTPC) break;
+        ref=NULL; iref++;
+      }
+      if(ref){ 
+        if(ref->LocalX() > fgkxTOF){ // track skipping TRD fiducial volume
+          ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));
+        }
+      } else { // track stopped in TPC 
+        ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0));
+      }
+      ptTRD = ref->Pt();kFOUND=kTRUE;
+    } else { // use reconstructed values
+      if(op){
+        Double_t x(op->GetX());
+        if(x<fgkxTOF && x>fgkxTPC){
+          ptTRD=op->Pt();
+          kFOUND=kTRUE;
+        }
+      }
+
+      if(!kFOUND && ip){
+        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)) h->Fill(ptTRD, kTRDout);
+      if(kBarrel && (status & AliESDtrack::kTRDpid)) h->Fill(ptTRD, kTRDpid);
+      if(kBarrel && (status & AliESDtrack::kTRDrefit)) h->Fill(ptTRD, kTRDref);
+    }
+    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 offset = (status & AliESDtrack::kTRDrefit) ? 0 : 10; 
+      h3->Fill(pt0, 1.e2*(pt/pt0-1.), 
+        offset + 2*idx + sgn);
+    }
+    ((TH1*)fHistos->At(kNCl))->Fill(esdTrack->GetTRDncls(), 2*idx + sgn);
+    if(ip){
+      h = (TH2I*)fHistos->At(kTRDmom);
+      Float_t pTRD(0.);
+      for(Int_t ily=6; ily--;){
+        if((pTRD=esdTrack->GetTRDmomentum(ily))<0.) continue;
+        h->Fill(ip->GetP()-pTRD, ily);
+      }
+    }
+  }  // end loop over tracks
+  
+  
+  
+  delete [] valuesMatchingPhiEtaCF;
+  delete [] valuesMatchingPtCF;
+  delete [] valuesBCCF;
+  delete [] valuesCentCF;
+  delete [] valuesQtotCF;
+  delete [] valuesPHCF;
+  if(valuesExpertCF) delete [] valuesExpertCF;
+  
+  PostData(1, fHistos);
+}
+
+//____________________________________________________________________
+TObjArray* AliTRDcheckESD::Histos()
+{
+// Retrieve histograms array if already build or build it
+
+  if(fHistos) return fHistos;
+
+  fHistos = new TObjArray(kNhistos+1);
+  fHistos->SetOwner(kTRUE);
+
+  TH1 *h = NULL;
+
+  // 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 = (TH2I*)gROOT->FindObject("hNCl"))){
+    h = new TH2I("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 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());
+    ay->SetBinLabel(1, "kTPCout");
+    ay->SetBinLabel(2, "kTRDin");
+    ay->SetBinLabel(3, "kTRDout");
+    ay->SetBinLabel(4, "kTRDpid");
+    ay->SetBinLabel(5, "kTRDrefit");
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDstat);
+
+  // energy loss
+  if(!(h = (TH2I*)gROOT->FindObject("hTRDmom"))){
+    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;
+
+  // pt resolution
+  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;
+  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(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);
+  
+  Double_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, 150, 0, 150.);
+  } 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);
+
+  // SPD multiplicity distribution
+  if(!(h = (TH1F*)gROOT->FindObject("hSPDMult"))){
+    h = new TH1F("hSPDMult", "SPD multiplicity", 10000, -0.5, 9999.5);
+  } else h->Reset();
+  fHistos->AddAt(h, kSPDMult);
+
+  // 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};
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hNTrackletsTRD_cent%d",iCent+1)))){
+      h = new TH2F(Form("hNTrackletsTRD_cent%d",iCent+1), Form("TRD Ntracklets/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                                              iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 7, -0.5, 6.5);
+    } else h->Reset();
+    fHistos->AddAt(h, kNTrackletsTRD+iCent);
+  }
+  
+  // Nclusters/track vs P for TRD reference tracks
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hNClsTrackTRD_cent%d",iCent+1)))){
+      h = new TH2F(Form("hNClsTrackTRD_cent%d",iCent+1), Form("TRD Nclusters/track vs. P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                                             iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 300, 0., 300.);
+    } else h->Reset();
+    fHistos->AddAt(h, kNClsTrackTRD+iCent);
+  }  
+
+  // <PH> vs slice number for TRD reference tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSlice_cent%d",iCent+1)))){
+      h = new TH2F(Form("hPHSlice_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                   iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 200, 0., 2000.);
+    } else h->Reset();
+    fHistos->AddAt(h, kPHSlice+iCent);
+  }
+
+  // <PH> vs slice number for TRD reference tracklets, from TPC pions
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCpions_cent%d",iCent+1)))){
+      h = new TH2F(Form("hPHSliceTPCpions_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC pions",
+                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);
+    } else h->Reset();
+    fHistos->AddAt(h, kPHSliceTPCpions+iCent);
+  }
+
+  // TPC dE/dx vs P for TRD reference tracks, pions
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxPions_cent%d",iCent+1)))){
+      h = new TH2F(Form("hTPCdedxPions_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC pions, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                        iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);
+    } else h->Reset();
+    fHistos->AddAt(h, kTPCdedxPions+iCent);
+  }
+
+  // <PH> vs slice number for TRD reference tracklets, from TPC electrons
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hPHSliceTPCelectrons_cent%d",iCent+1)))){
+      h = new TH2F(Form("hPHSliceTPCelectrons_cent%d",iCent+1), Form("<PH> vs sliceNo, centrality %d,|#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, TPC electrons",
+                                               iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 8, -0.5, 7.5, 100, 0., 2000.);
+    } else h->Reset();
+    fHistos->AddAt(h, kPHSliceTPCelectrons+iCent);
+  }
+
+  // TPC dE/dx vs P for TRD reference tracks, electrons
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hTPCdedxElectrons_cent%d",iCent+1)))){
+      h = new TH2F(Form("hTPCdedxElectrons_cent%d",iCent+1), Form("TPC dE/dx vs P, TPC electrons, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                            iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, 0.1,10.1, 100, 0,100.);
+    } else h->Reset();
+    fHistos->AddAt(h, kTPCdedxElectrons+iCent);
+  }
+
+  // Qtot vs P for TRD reference tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH2F*)gROOT->FindObject(Form("hQtotP_cent%d",iCent+1)))){
+      h = new TH2F(Form("hQtotP_cent%d",iCent+1), Form("Qtot(from slices) vs P, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 18, binsP, 400, 0., 20);
+    } else h->Reset();
+    fHistos->AddAt(h, kQtotP+iCent);
+  }
+  
+  // (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);
+  
+  Double_t etaBinLimits[101];  
+  for(Int_t i=0; i<101; i++) etaBinLimits[i] = -1.0 + i*2.0/100.;
+  Double_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
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksPos_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTPCRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTPCRefTracksPos+iCent);
+  }
+  
+  // (eta,detector phi,P) distribution of reference TPC negative tracks
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTPCRefTracksNeg_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTPCRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TPC negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d",
+                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTPCRefTracksNeg+iCent);
+  }
+  
+  // (eta,detector phi,P) distribution of reference TRD positive tracks
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksPos_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksPos+iCent);
+  }
+  
+  // (eta,detector phi,P) distribution of reference TRD negative tracks
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksNeg_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                           iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksNeg+iCent);
+  }
+
+  // (eta,detector phi,P) distribution of reference TRD positive tracks with 4 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos4_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksPos4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksPos4+iCent);
+  }
+
+  // (eta,detector phi,P) distribution of reference TRD positive tracks with 5 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos5_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksPos5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksPos5+iCent);
+  }
+
+  // (eta,detector phi,P) distribution of reference TRD positive tracks with 6 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksPos6_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksPos6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD positive reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksPos6+iCent);
+  }
+  
+  // (eta,detector phi,P) distribution of reference TRD negative tracks with 4 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg4_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksNeg4_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksNeg4+iCent);
+  }
+
+  // (eta,detector phi,P) distribution of reference TRD negative tracks with 5 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg5_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksNeg5_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                 iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksNeg5+iCent);
+  }
+
+  // (eta,detector phi,P) distribution of reference TRD negative tracks with 6 tracklets
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TH3F*)gROOT->FindObject(Form("hTRDRefTracksNeg6_cent%d",iCent+1)))){
+      h = new TH3F(Form("hTRDRefTracksNeg6_cent%d",iCent+1), Form("(#eta,detector #varphi,p) for TRD negative reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                                  iCent+1, fgkEta, fgkPt, fgkTrkDCAxy, fgkTrkDCAz, fgkNclTPC), 100, etaBinLimits, 150, phiBinLimits, 32, binPtLimits);
+    } else h->Reset();
+    fHistos->AddAt(h, kTRDRefTracksNeg6+iCent);
+  }
+
+
+  // (eta,detector phi) profile of average number of TRD tracklets/track
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1)))){
+      h = new TProfile2D(Form("hTRDEtaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta,detector #varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                  iCent+1, 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+iCent);
+  }
+
+  // (eta,delta phi) profile of average number of TRD tracklets/track
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1)))){
+      h = new TProfile2D(Form("hTRDEtaDeltaPhiAvNtrkl_cent%d",iCent+1), Form("<Ntracklets/track> vs (#eta, #Delta#varphi) for TRD reference tracks, centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                                                       iCent+1, 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+iCent);
+  }  
+
+  // (eta, detector phi) profile of average tracklet Qtot from slices
+  for(Int_t iCent=0; iCent<=5; ++iCent) {
+    for(Int_t iLayer=0;iLayer<6;iLayer++) {
+      if(!(h = (TProfile2D*)gROOT->FindObject(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1)))) {
+       h = new TProfile2D(Form("hTRDEtaPhiAvQtot_Layer%d_cent%d",iLayer,iCent+1),
+                          Form("<Q_{tot}> vs (#eta, detector #varphi) for TRD reference tracks (layer %d), centrality %d, |#eta|<%.1f and pt>%.1f, |DCAxy|<%.1f, |DCAz|<%.1f, TPC nclusters>%d, nTRDtracklets#geq1",
+                               iLayer, iCent+1, 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+iCent*6+iLayer);
+    }
+  }
+  
+  // Trigger definitions
+  if(!(h=(TH1F*)gROOT->FindObject("hTriggerDefs"))) {
+    h = new TH1F("hTriggerDefs", "Trigger definitions", kNMaxAssignedTriggers, 0.5, 0.5+Float_t(kNMaxAssignedTriggers));
+  }
+  else h->Reset();
+  fHistos->AddAt(h, kTriggerDefs);
+
+  // dummy histo
+  if(!(h=(TH1F*)gROOT->FindObject("hDummy"))) {
+    h = new TH1F("hDummy", "Dummy hist", 10, 0., 1.);
+  }
+  else h->Reset();
+  fHistos->AddAt(h, 0);
+  
+  fMatchingPhiEtaCF = CreateCFContainer("MatchingPhiEta", "CF container with TRD-TPC matching data");
+  fHistos->AddAt(fMatchingPhiEtaCF, kMatchingPhiEtaCF);
+  fMatchingPtCF = CreateCFContainer("MatchingPt", "CF container with TRD-TPC matching data");
+  fHistos->AddAt(fMatchingPtCF, kMatchingPtCF);
+  fBunchCrossingsCF = CreateCFContainer("BunchCrossingsCF", "CF container with bunch crossings dependent data");
+  fHistos->AddAt(fBunchCrossingsCF, kBunchCrossingsCF);
+  fCentralityCF = CreateCFContainer("CentralityCF", "CF container with TRD-TPC matching data");
+  fHistos->AddAt(fCentralityCF, kCentralityCF);
+  fQtotCF = CreateCFContainer("QtotCF", "CF container with TRD tracklet charge data");
+  fHistos->AddAt(fQtotCF, kQtotCF);
+  fPulseHeightCF = CreateCFContainer("PulseHeightCF", "CF container with TRD tracklet PH data");
+  fHistos->AddAt(fPulseHeightCF, kPulseHeightCF);
+  fExpertCF = CreateCFContainer("ExpertCF", "CF container with customized information");
+  if(fExpertCF) fHistos->AddAt(fExpertCF, kExpertCF);
+  
+  return fHistos;
+}
+
+
+//__________________________________________________________________________________________________________
+void AliTRDcheckESD::InitializeCFContainers() {
+  //
+  //  Initialize the CF container
+  //
+  AliAnalysisManager* man=AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if(!inputHandler) return;
+
+  GetTriggerIndex("All triggers", kTRUE);
+
+  AliPhysicsSelection* physSel = (AliPhysicsSelection*)inputHandler->GetEventSelection();
+  const TList* trigList = (physSel ? physSel->GetCollisionTriggerClasses() : 0x0);
+  const TList* bgTrigList = (physSel ? physSel->GetBGTriggerClasses() : 0x0);
+  
+  // Add collision triggers from PhysicsSelection
+  if(trigList) {
+    for(Int_t it=0; it<trigList->GetEntries(); ++it) {
+      TString trigName = trigList->At(it)->GetName();
+      TObjArray* arr = trigName.Tokenize(" ");
+      trigName = arr->At(0)->GetName();
+      trigName.Remove(0,1);
+      TObjArray* arr2 = trigName.Tokenize(",");
+      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {
+        // Assign an index into the trigger histogram and the CF container for this trigger
+        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);
+      }
+    }
+  }
+  // Add background triggers from PhysicsSelection
+  if(bgTrigList) {
+    for(Int_t it=0; it<bgTrigList->GetEntries(); ++it) {
+      TString trigName = bgTrigList->At(it)->GetName();
+      TObjArray* arr = trigName.Tokenize(" ");
+      trigName = arr->At(0)->GetName();
+      trigName.Remove(0,1);
+      TObjArray* arr2 = trigName.Tokenize(",");
+      for(Int_t jt=0; jt<arr2->GetEntries(); ++jt) {
+        // Assign an index into the trigger histogram and the CF container for this trigger
+        GetTriggerIndex(arr2->At(jt)->GetName(), kTRUE);
+      }
+    }
+  }
+    
+  // Add user enabled triggers
+  TObjArray* arr = fUserEnabledTriggers.Tokenize(";");
+  for(Int_t it=0; it<arr->GetEntries(); ++it) {
+    GetTriggerIndex(arr->At(it)->GetName(), kTRUE);
+  }
+}
+
+
+//__________________________________________________________________________________________________________
+AliCFContainer* AliTRDcheckESD::CreateCFContainer(const Char_t* name, const Char_t* title) {
+  //
+  //  make a CF container
+  //
+  // create a CF container and add it to the list of histograms
+  Int_t nbinsCf[kNTrdCfVariables];
+  for(Int_t i=0;i<kNTrdCfVariables;++i) nbinsCf[i]=0;
+  nbinsCf[kEventVtxZ]         =    5;
+  nbinsCf[kEventMult]         =    5;
+  nbinsCf[kEventTrigger]      =    kNMaxAssignedTriggers;
+  nbinsCf[kEventBC]           = 3500;
+  nbinsCf[kTrackTOFBC]        =    2;
+  nbinsCf[kTrackDCAxy]        =    9;
+  nbinsCf[kTrackDCAz]         =    5;
+  nbinsCf[kTrackCharge]       =    2;
+  nbinsCf[kTrackPhi]          =  180;
+  nbinsCf[kTrackEta]          =   90;
+  nbinsCf[kTrackPt]           =   18;
+  nbinsCf[kTrackP]            =   17;
+  nbinsCf[kTrackTrdTracklets] =    7;
+  nbinsCf[kTrackTrdClusters]  =  200;
+  for(Int_t i=0;i<6;++i) nbinsCf[kTrackQtot+i] = 100;
+  for(Int_t i=0;i<8;++i) nbinsCf[kTrackPHslice+i] = 400;
+  //Double_t evVtxLims[2]      = {-10.,+10.};
+  Double_t evMultLims[6]     = {0.0, 700., 1400., 2100., 2800., 3500.};
+  Double_t evTriggerLims[2]  = {0.5, 0.5+Float_t(kNMaxAssignedTriggers)};
+  Double_t evBCLims[2]       = {-0.5, +3499.5};
+  //Double_t trkTOFBClims[3]   = {-0.5, 0.5, 5.5};
+  //Double_t trkDCAxyLims[10]  = {-10.0,  -6.0, -3.0,  -2.0,  -1.0,   
+  //                               +1.0, +2.0,  +3.0,  +6.0, +10.0};    
+  //Double_t trkDCAzLims[2]    = {-15.0, +15.0};    
+  Double_t trkChargeLims[2]  = {-1.5, +1.5};
+  Double_t trkPhiLims[2]     = {-1.001*TMath::Pi(), +1.001*TMath::Pi()};
+  Double_t trkEtaLims[2]     = {-0.9, +0.9};
+  Double_t trkPtLims[19]     = {0.0, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 
+                                3.5, 4.0, 4.5,  5.0, 6.0,  7.0, 8.0,  9.0, 10.0};
+  Double_t trkPLims[18]      = {0.0, 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};
+  Double_t trkTrdNLims[2]    = {-0.5, 6.5};
+  Double_t trkTrdNclsLims[2] = {-0.5, 199.5};
+  Double_t trkQtotLims[2]    = {0.0, 20.};
+  /*Double_t trkQtotLims[20]   = {0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0,
+                                5.5, 6.0, 6.5, 7.0, 8.0, 9.0,10.0,12.0,15.0,20.0};*/
+  const Char_t* varNames[kNTrdCfVariables] = {"vtxZ", "multiplicity", "trigger", "BC", "TOFBC", "DCAxy", "DCAz",
+    "charge", "phi", "eta", "pt", "P", "tracklets", "clusters", 
+    "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7",
+    "Qtot0", "Qtot1", "Qtot2", "Qtot3", "Qtot4", "Qtot5"};
+  
+  AliCFContainer* cf;
+  TString nameStr=name;
+  if(nameStr.Contains("MatchingPhiEta")) {
+    fMatchingPhiEtaCFVars[0] = kTrackCharge;       fMatchingPhiEtaCFVars[1] = kTrackPhi; fMatchingPhiEtaCFVars[2] = kTrackEta;
+    fMatchingPhiEtaCFVars[3] = kTrackTrdTracklets; fMatchingPhiEtaCFVars[4] = kEventTrigger;
+    const Int_t nVars = 5;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPhiEtaCFVars[i]];
+    cf = new AliCFContainer(name, title, 3, nVars, nBins);
+    cf->SetBinLimits(0, trkChargeLims[0], trkChargeLims[1]);
+    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);
+    cf->SetBinLimits(2, trkEtaLims[0], trkEtaLims[1]);
+    cf->SetBinLimits(3, trkTrdNLims[0], trkTrdNLims[1]);
+    cf->SetBinLimits(4, evTriggerLims[0], evTriggerLims[1]);
+    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPhiEtaCFVars[i]]);
+    cf->SetStepTitle(0, "TPC");
+    cf->SetStepTitle(1, "TRD");
+    cf->SetStepTitle(2, "TOF");
+    return cf;
+  }
+  if(nameStr.Contains("MatchingPt")) {
+    fMatchingPtCFVars[0] = kEventMult; fMatchingPtCFVars[1] = kTrackCharge;        fMatchingPtCFVars[2] = kTrackPhi; 
+    fMatchingPtCFVars[3] = kTrackPt;   fMatchingPtCFVars[4] = kTrackTrdTracklets;  fMatchingPtCFVars[5] = kEventTrigger;
+    const Int_t nVars = 6;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fMatchingPtCFVars[i]];
+    cf = new AliCFContainer(name, title, 3, nVars, nBins);
+    cf->SetBinLimits(0, evMultLims);
+    cf->SetBinLimits(1, trkChargeLims[0], trkChargeLims[1]);
+    cf->SetBinLimits(2, trkPhiLims[0], trkPhiLims[1]);
+    cf->SetBinLimits(3, trkPtLims);
+    cf->SetBinLimits(4, trkTrdNLims[0], trkTrdNLims[1]);
+    cf->SetBinLimits(5, evTriggerLims[0], evTriggerLims[1]);
+    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fMatchingPtCFVars[i]]);
+    cf->SetStepTitle(0, "TPC");
+    cf->SetStepTitle(1, "TRD");
+    cf->SetStepTitle(2, "TOF");
+    return cf;
+  }
+  if(nameStr.Contains("BunchCrossings")) {
+    fBunchCrossingsCFVars[0] = kEventBC; fBunchCrossingsCFVars[1] = kTrackPhi;
+    const Int_t nVars = 2;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fBunchCrossingsCFVars[i]];
+    cf = new AliCFContainer(name, title, 3, nVars, nBins);
+    cf->SetBinLimits(0, evBCLims[0], evBCLims[1]);
+    cf->SetBinLimits(1, trkPhiLims[0], trkPhiLims[1]);
+    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fBunchCrossingsCFVars[i]]);
+    cf->SetStepTitle(0, "TPC");
+    cf->SetStepTitle(1, "TRD");
+    cf->SetStepTitle(2, "TOF");
+    return cf;
+  }
+  if(nameStr.Contains("Centrality")) {
+    fCentralityCFVars[0] = kEventMult; fCentralityCFVars[1] = kTrackP; fCentralityCFVars[2] = kTrackTrdClusters; 
+    fCentralityCFVars[3] = kTrackQtot; fCentralityCFVars[4] = kEventTrigger;
+    const Int_t nVars = 5;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars; ++i) nBins[i] = nbinsCf[fCentralityCFVars[i]];
+    cf = new AliCFContainer(name, title, 1, nVars, nBins);
+    cf->SetBinLimits(0, evMultLims);
+    cf->SetBinLimits(1, trkPLims);
+    cf->SetBinLimits(2, trkTrdNclsLims[0], trkTrdNclsLims[1]);
+    cf->SetBinLimits(3, trkQtotLims[0], trkQtotLims[1]);
+    cf->SetBinLimits(4, evTriggerLims[0], evTriggerLims[1]);
+    for(Int_t i=0; i<nVars; ++i) cf->SetVarTitle(i, varNames[fCentralityCFVars[i]]);
+    cf->SetStepTitle(0, "TRD");
+    return cf;
+  }
+  if(nameStr.Contains("Qtot")) {
+    fQtotCFVars[0] = kTrackPhi; fQtotCFVars[1] = kTrackEta; fQtotCFVars[2] = kTrackQtot; 
+    fQtotCFVars[3] = kEventTrigger;
+    const Int_t nVars = 5;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fQtotCFVars[i]];
+    nBins[2] = 50;
+    nBins[nVars-1] = 6;
+    cf = new AliCFContainer(name, title, 1, nVars, nBins);
+    cf->SetBinLimits(0, trkPhiLims[0], trkPhiLims[1]);
+    cf->SetBinLimits(1, trkEtaLims[0], trkEtaLims[1]);
+    cf->SetBinLimits(2, trkQtotLims[0], trkQtotLims[1]);
+    cf->SetBinLimits(3, evTriggerLims[0], evTriggerLims[1]);
+    cf->SetBinLimits(4, -0.5, 5.5);
+    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fQtotCFVars[i]]);
+    cf->SetVarTitle(nVars-1, "layer");
+    cf->SetStepTitle(0, "TRD");
+    return cf;
+  }
+  if(nameStr.Contains("PulseHeight")) {
+    fPulseHeightCFVars[0] = kTrackP; fPulseHeightCFVars[1] = kTrackPHslice; fPulseHeightCFVars[2] = kEventTrigger;
+    const Int_t nVars = 4;
+    Int_t nBins[nVars]; for(Int_t i=0; i<nVars-1; ++i) nBins[i] = nbinsCf[fPulseHeightCFVars[i]];
+    nBins[nVars-1] = 8;
+    cf = new AliCFContainer(name, title, 1, nVars, nBins);
+    //cf->SetBinLimits(0, evTriggerLims[0], evTriggerLims[1]);
+    cf->SetBinLimits(0, trkPLims);
+    cf->SetBinLimits(1, trkQtotLims[0], trkQtotLims[1]);
+    cf->SetBinLimits(2, evTriggerLims[0], evTriggerLims[1]);
+    cf->SetBinLimits(3, -0.5, 7.5);
+    for(Int_t i=0; i<nVars-1; ++i) cf->SetVarTitle(i, varNames[fPulseHeightCFVars[i]]);
+    cf->SetVarTitle(nVars-1, "slice");
+    cf->SetStepTitle(0, "TRD");
+    return cf;
+  }
+  if(nameStr.Contains("Expert")) {
+    Int_t nVars = 0;
+    Int_t nBins[kNTrdCfVariables];
+    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {
+      if(!fExpertCFVarsEnabled[ivar]) continue;
+      if(fExpertCFVarBins[ivar][0]=='\0') {
+       nBins[nVars] = fExpertCFVarNBins[ivar];
+       nVars++;
+      }
+      else {
+       TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");
+       nBins[nVars] = arr->GetEntries()-1;
+       if(nBins[nVars]>0) nVars++;
+      }
+    }
+    if(nVars<1) return 0x0;
+    Int_t nSteps = 0; for(Int_t i=0; i<3; ++i) if(fExpertCFEnabledSteps[i]) nSteps++;
+    if(nSteps<1) return 0x0;
+    cf = new AliCFContainer(name, title, nSteps, nVars, nBins);
+    Int_t iUsedVar = 0;
+    for(Int_t ivar=0; ivar<kNTrdCfVariables; ++ivar) {
+      if(!fExpertCFVarsEnabled[ivar]) continue;
+      if(fExpertCFVarBins[ivar][0]=='\0')
+       cf->SetBinLimits(iUsedVar, fExpertCFVarRanges[ivar][0], fExpertCFVarRanges[ivar][1]);
+      else {
+       TObjArray* arr = fExpertCFVarBins[ivar].Tokenize(";");
+       if(arr->GetEntries()-1>0) {
+         Double_t* binLims = new Double_t[arr->GetEntries()];
+         for(Int_t ib=0;ib<arr->GetEntries();++ib) {
+           TString binStr = arr->At(ib)->GetName();
+           binLims[ib] = binStr.Atof();
+         }
+         cf->SetBinLimits(iUsedVar++, binLims);
+       }
+      }
+      cf->SetVarTitle(iUsedVar, varNames[ivar]);
+    }
+    const Char_t* stepNames[3] = {"TPC","TRD","TOF"};
+    Int_t iUsedStep = 0;
+    for(Int_t istep=0; istep<3; ++istep) {
+      if(fExpertCFEnabledSteps[istep]) cf->SetStepTitle(iUsedStep++, stepNames[istep]);
+    }
+    return cf;
+  }  
+  return 0x0;
+}
+
+
+//____________________________________________________________________
+Bool_t AliTRDcheckESD::Load(const Char_t *file, const Char_t *dir, const Char_t *name)
+{
+// Load data from performance file
+
+  if(!TFile::Open(file)){
+    AliWarning(Form("Couldn't open file %s.", file));
+    return kFALSE;
+  }
+  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());
+  fMatchingPhiEtaCF = (AliCFContainer*)fHistos->At(kMatchingPhiEtaCF);
+  fMatchingPtCF = (AliCFContainer*)fHistos->At(kMatchingPtCF);
+  fBunchCrossingsCF = (AliCFContainer*)fHistos->At(kBunchCrossingsCF);
+  fCentralityCF = (AliCFContainer*)fHistos->At(kCentralityCF);
+  fQtotCF = (AliCFContainer*)fHistos->At(kQtotCF);
+  fPulseHeightCF = (AliCFContainer*)fHistos->At(kPulseHeightCF);
+  fExpertCF = (AliCFContainer*)fHistos->At(kExpertCF);
+  
+  /*
+  TObjArray *cfs(NULL);
+  if(!(cfs = (TObjArray*)gDirectory->Get(Form("%s_CF", tn)))){
+    AliWarning(Form("Missing CFs container %s_CF.", tn));
+    fCfList = NULL;
+    //return kFALSE;
+  } 
+  else
+    fCfList = (TObjArray*)cfs->Clone(Form("%s_CF_clone", GetName()));
+  */
+  
+  gFile->Close();
+  return kTRUE;
+}
+
+//_______________________________________________________
+Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val)
+{
+// Dump trending value to default file
+
+  if(!fgFile){
+    fgFile = fopen("TRD.Performance.txt", "at");
+  }
+  fprintf(fgFile, "%s_%s %f\n", GetName(), name, val);
+  return kTRUE;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::Terminate(Option_t *)
+{
+  // Steer post-processing 
+  if(!fHistos){
+    fHistos = dynamic_cast<TObjArray *>(GetOutputData(1));
+    if(!fHistos){
+      AliError("Histogram container not found in output");
+      return;
+    }
+  }
+
+  //  fNRefFigures = 15;
+  //  return;
+
+  const Char_t *name[kNrefs] = {
+    "Ncl", "Eff", "Eloss", "PtResDCA"
+  };
+
+  TObjArray *arr(NULL); TGraph *g(NULL);
+  if(!fResults){
+    fResults = new TObjArray(kNrefs);
+    fResults->SetOwner();
+    fResults->SetName("results");
+    for(Int_t iref(0); iref<kNrefs; iref++){
+      fResults->AddAt(arr = new TObjArray(fgkNgraph[iref]), iref);
+      arr->SetName(name[iref]);  arr->SetOwner();
+      switch(iref+1){
+      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);
+          g->SetLineColor(ig+1); 
+          g->SetMarkerColor(ig+1); 
+          g->SetMarkerStyle(ig+20); 
+        }
+        break;
+      case kPtRes:
+       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+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+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:
+       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); 
+        }
+        break;
+      }
+    }
+  }
+  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
+  if(!(h2 = (TH2I*)fHistos->At(kTRDstat))) return;
+  arr = (TObjArray*)fResults->At(kTRDstat-1);
+  h1[0] = h2->ProjectionX("checkESDx0", kTPCout, kTPCout);
+  h1[1] = h2->ProjectionX("checkESDx1", kTRDin, kTRDin);
+  Process(h1, (TGraphErrors*)arr->At(0));
+  delete h1[0];delete h1[1];
+  // tracking efficiency
+  h1[0] = h2->ProjectionX("checkESDx0", kTRDin, kTRDin);
+  h1[1] = h2->ProjectionX("checkESDx1", kTRDout, kTRDout);
+  Process(h1, (TGraphErrors*)arr->At(1));
+  delete h1[1];
+  // PID efficiency
+  h1[1] = h2->ProjectionX("checkESDx1", kTRDpid, kTRDpid);
+  Process(h1, (TGraphErrors*)arr->At(2));
+  delete h1[1];
+  // Refit efficiency
+  h1[1] = h2->ProjectionX("checkESDx1", kTRDref, kTRDref);
+  Process(h1, (TGraphErrors*)arr->At(3));
+  delete h1[1];
+  fNRefFigures++;
+
+  // ENERGY LOSS
+  if(!(h2 = dynamic_cast<TH2I*>(fHistos->At(kTRDmom)))) return;
+  arr = (TObjArray*)fResults->At(kTRDmom-1);
+  TGraphAsymmErrors *g06 = (TGraphAsymmErrors*)arr->At(0), *g09 = (TGraphAsymmErrors*)arr->At(1);
+  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];
+  for(Int_t ily=6; ily--;){
+    h1[0] = h2->ProjectionX("checkESDp0", ily+1, ily+1);
+    h1[0]->GetQuantiles(nq,yq,xq);
+    g06->SetPoint(ily, Float_t(ily), ax->GetBinCenter(h1[0]->GetMaximumBin()));
+    g06->SetPointError(ily, 0., 0., TMath::Abs(yq[0]), yq[3]);
+    g09->SetPoint(ily, Float_t(ily), h1[0]->GetMean());
+    g09->SetPointError(ily, 0., 0., TMath::Abs(yq[1]), yq[2]);
+
+    //printf(" max[%f] mean[%f] q[%f %f %f %f]\n", ax->GetBinCenter(h1[0]->GetMaximumBin()), h1[0]->GetMean(), yq[0], yq[1], yq[2], yq[3]);
+    delete h1[0];
+  }
+  fNRefFigures++;
+//  if(!HasMC()) return;
+
+  // Pt RESOLUTION @ DCA
+  TH3S* h3(NULL); TGraphErrors *gg[2] = {NULL,NULL};
+  if(!(h3 = dynamic_cast<TH3S*>(fHistos->At(kPtRes)))) return;
+  arr = (TObjArray*)fResults->At(kPtRes-1);
+  TAxis *az(h3->GetZaxis());
+  for(Int_t i(0); i<AliPID::kSPECIES; 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);
+  }
+  fNRefFigures++;
+  
+  fNRefFigures++;
+  // 3x3 tracking summary canvases for every centrality class
+  fNRefFigures++;
+  // 3x3 PID summary canvases for every centrality class
+  fNRefFigures++;
+  // 3x3 for centrality dependent pictures
+  fNRefFigures++;
+  
+  //DoTrending();  
+}
+
+//____________________________________________________________________
+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;  
+  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 -1;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::Process(TH1 **h1, TGraphErrors *g)
+{
+// Generic function to process one reference plot
+
+  Int_t n1 = 0, n2 = 0, ip=0;
+  Double_t eff = 0.;
+
+  TAxis *ax = h1[0]->GetXaxis();
+  for(Int_t ib=1; ib<=ax->GetNbins(); ib++){
+    if(!(n1 = (Int_t)h1[0]->GetBinContent(ib))) continue;
+    n2 = (Int_t)h1[1]->GetBinContent(ib);
+    eff = n2/Float_t(n1);
+
+    ip=g->GetN();
+    g->SetPoint(ip, ax->GetBinCenter(ib), eff);
+    g->SetPointError(ip, 0., n2 ? eff*TMath::Sqrt(1./n1+1./n2) : 0.);
+  }
+}  
+//________________________________________________________
+void AliTRDcheckESD::Process2D(TH2 * const h2, TGraphErrors **g)
+{
+  //
+  // Do the processing
+  //
+
+  Int_t n = 0;
+  if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);
+  if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);
+  TF1 f("fg", "gaus", -3.,3.);
+  for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
+    Double_t x = h2->GetXaxis()->GetBinCenter(ibin);
+    TH1D *h = h2->ProjectionY("py", ibin, ibin);
+    if(h->GetEntries()<100) continue;
+    //AdjustF1(h, f);
+
+    h->Fit(&f, "QN");
+    Int_t ip = g[0]->GetN();
+    g[0]->SetPoint(ip, x, f.GetParameter(1));
+    g[0]->SetPointError(ip, 0., f.GetParError(1));
+    g[1]->SetPoint(ip, x, f.GetParameter(2));
+    g[1]->SetPointError(ip, 0., f.GetParError(2));
+  }
+  return;
+}
+//____________________________________________________________________
+void AliTRDcheckESD::PrintStatus(ULong_t status)
+{
+// Dump track status to stdout
+
+  printf("ITS[i(%d) o(%d) r(%d)] TPC[i(%d) o(%d) r(%d) p(%d)] TRD[i(%d) o(%d) r(%d) p(%d) s(%d)] HMPID[o(%d) p(%d)]\n"
+    ,Bool_t(status & AliESDtrack::kITSin)
+    ,Bool_t(status & AliESDtrack::kITSout)
+    ,Bool_t(status & AliESDtrack::kITSrefit)
+    ,Bool_t(status & AliESDtrack::kTPCin)
+    ,Bool_t(status & AliESDtrack::kTPCout)
+    ,Bool_t(status & AliESDtrack::kTPCrefit)
+    ,Bool_t(status & AliESDtrack::kTPCpid)
+    ,Bool_t(status & AliESDtrack::kTRDin)
+    ,Bool_t(status & AliESDtrack::kTRDout)
+    ,Bool_t(status & AliESDtrack::kTRDrefit)
+    ,Bool_t(status & AliESDtrack::kTRDpid)
+    ,Bool_t(status & AliESDtrack::kTRDStop)
+    ,Bool_t(status & AliESDtrack::kHMPIDout)
+    ,Bool_t(status & AliESDtrack::kHMPIDpid)
+  );
+}
+
+//____________________________________________________________________
+TH1D* AliTRDcheckESD::Proj2D(TH2* hist, TH1* fitErr) {
+  //
+  // project the PH vs Slice 2D-histo into a 1D histo
+  //
+  
+  TH1D* hProjection = (TH1D*)hist->ProjectionX(Form("hProjection_%f", gRandom->Rndm()));
+  hProjection->Reset();
+  
+  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);
+    hD->Rebin(4);
+    if(hD->Integral()>10) {
+      fitLandau->SetParameter(1, hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParLimits(1, 0.2*hD->GetBinCenter(hD->GetMaximumBin()), 3.0*hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParameter(0, 1000.);
+      fitLandau->SetParLimits(0, 1., 10000000.);
+      fitLandau->SetParameter(2, 0.5*hD->GetBinCenter(hD->GetMaximumBin()));
+      fitLandau->SetParLimits(2, 0.01*hD->GetBinCenter(hD->GetMaximumBin()), 1.0*hD->GetBinCenter(hD->GetMaximumBin()));
+      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());
+      hD->Fit(fitLandau, "Q0", "", hD->GetXaxis()->GetXmin(), hD->GetXaxis()->GetXmax());
+      hProjection->SetBinContent(iBin, fitLandau->GetParameter(1));
+      hProjection->SetBinError(iBin, fitLandau->GetParameter(2));
+      if(fitErr) {
+       fitErr->SetBinContent(iBin, fitLandau->GetParameter(1));
+       fitErr->SetBinError(iBin, fitLandau->GetParError(1));
+      }
+    }
+    else{
+      hProjection->SetBinContent(iBin, 0);
+      hProjection->SetBinError(iBin, 0);
+    }
+  }
+  return hProjection;
+}
+
+//____________________________________________________________________
+TH2F* AliTRDcheckESD::Proj3D(TH3* hist, TH2* 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
+
+  TH2F* projHisto = (TH2F*)gROOT->FindObject("projHisto");
+  if(projHisto) 
+    projHisto->Reset();
+  else
+    projHisto = new TH2F("projHisto", "projection", nBinsX, minX, maxX, nBinsY, minY, maxY);
+
+  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) {
+          if(accMap->GetBinContent(iX,iY)>0.1)
+            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) {
+          if(accMap->GetBinContent(iX,iY)>0.1)
+            entries+=hist->GetBinContent(iX,iY,iZ);
+        }
+        else    // no acc. cut
+          entries+=hist->GetBinContent(iX,iY,iZ);
+      }
+    }
+  }
+  return projHisto;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]) {
+  //
+  // Check the active super-modules
+  //
+  Double_t entries[18] = {0.0};
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  for(Int_t phiBin=1; phiBin<=phiProj->GetXaxis()->GetNbins(); ++phiBin) {
+    Double_t phi = phiProj->GetBinCenter(phiBin);
+    Int_t sm = -1;
+    for(Int_t ism=0; ism<18; ++ism) 
+      if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1]) sm = ism;
+    if(sm==-1) continue;
+    entries[sm] += phiProj->GetBinContent(phiBin);
+  }
+  Double_t avEntries = Double_t(phiProj->Integral())/18.0;
+  for(Int_t ism=0; ism<18; ++ism) 
+    if(entries[ism]>0.5*avEntries) activeSM[ism] = kTRUE;
+}
+
+
+//__________________________________________________________________________________________________
+TH1F* AliTRDcheckESD::EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, 
+                                         Int_t stepNom, Int_t stepDenom, const Char_t* varStr/*="pt"*/, const Char_t* type/*="TPCTRD"*/) {
+  //
+  // Use the CF container to extract the efficiency vs pt
+  //
+  Int_t varTrackPhi = cf->GetVar("phi");
+  Int_t var = cf->GetVar(varStr);
+    
+  TH1D* phiProj = (TH1D*)cf->Project(1, varTrackPhi);
+  Bool_t activeSM[18] = {kFALSE};
+  CheckActiveSM(phiProj, activeSM); delete phiProj;
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  
+  TString effTypeStr = type;
+  if(effTypeStr.Contains("TRDTOF")) {
+    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)
+      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));
+  }
+  TH2D* hDenomPhiVar = (TH2D*)cf->Project(stepDenom, var, varTrackPhi);
+  if(effTypeStr.Contains("TPCTRD")) {
+    if(minNtrkl>-1 && minNtrkl<7 && maxNtrkl>-1 && maxNtrkl<7)
+      cf->SetRangeUser(cf->GetVar("tracklets"), Double_t(minNtrkl), Double_t(maxNtrkl));
+  }
+  TH2D* hNomPhiVar = (TH2D*)cf->Project(stepNom, var, varTrackPhi);
+  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);
+  
+  TH1F* hEff = new TH1F(Form("hEff%s_%d_%d_%f", varStr, stepNom, stepDenom, gRandom->Rndm()), "", 
+                       hNomPhiVar->GetXaxis()->GetNbins(), hNomPhiVar->GetXaxis()->GetXbins()->GetArray());
+  for(Int_t ivar=1; ivar<=hEff->GetXaxis()->GetNbins(); ++ivar) {
+    Double_t nom = 0.0; Double_t denom = 0.0;
+    Double_t eff = 0.0; Double_t err = 0.0;
+    for(Int_t iphi=1; iphi<=hNomPhiVar->GetYaxis()->GetNbins(); ++iphi) {
+      Double_t phi = hNomPhiVar->GetYaxis()->GetBinCenter(iphi);
+      Bool_t isActive = kFALSE;
+      for(Int_t ism=0; ism<18; ++ism) 
+        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) 
+         isActive = kTRUE;
+      if(!isActive) continue;
+      nom += hNomPhiVar->GetBinContent(ivar, iphi);
+      denom += hDenomPhiVar->GetBinContent(ivar, iphi);
+    }
+    eff = (denom>0.001 ? nom/denom : 0.0);
+    err = (denom>0.001 && (denom-nom)>0.001 && nom>0.001 ? (TMath::Sqrt(nom*(denom-nom)/denom/denom/denom)) : 0.0);
+    hEff->SetBinContent(ivar, eff);
+    hEff->SetBinError(ivar, err);
+  }   // end loop over pt bins
+  delete hNomPhiVar; delete hDenomPhiVar;
+  return hEff;
+}
+
+
+//____________________________________________________________________
+TH1F* AliTRDcheckESD::EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance) {
+  //
+  // Calculate the TRD-TPC matching efficiency as function of pt
+  //
+  
+  if(!tpc3D || !trd3D) return NULL;
+  Int_t nBinsZ = trd3D->GetZaxis()->GetNbins();
+  // project everything on the eta-phi map to obtain an acceptance map
+  Float_t nada = 0.;
+  TH2F *trdAcc = (useAcceptance ? (TH2F*)Proj3D(trd3D, 0x0, 1, nBinsZ, nada)->Clone(Form("trdAcc%f", gRandom->Rndm())) : 0x0);
+  TH1D *phiProj = (trdAcc ? trdAcc->ProjectionY(Form("phiProj%f", gRandom->Rndm())) : 0x0);
+  
+  // prepare the acceptance map
+  Bool_t activeSM[18] = {kFALSE};
+  Double_t smPhiLimits[19];
+  for(Int_t ism=0; ism<=18; ++ism) smPhiLimits[ism] = -TMath::Pi() + (2.0*TMath::Pi()/18.0)*ism;
+  if(phiProj) {
+    CheckActiveSM(phiProj, activeSM);   // get the active SMs
+    trdAcc->Reset();
+    // Put 1 entry in every bin which belongs to an active SM
+    for(Int_t iY=1; iY<=trdAcc->GetYaxis()->GetNbins(); ++iY) {
+      Double_t phi = trdAcc->GetYaxis()->GetBinCenter(iY);
+      Bool_t isActive = kFALSE;
+      for(Int_t ism=0; ism<18; ++ism) {
+        if(phi>=smPhiLimits[ism] && phi<smPhiLimits[ism+1] && activeSM[ism]) {
+         isActive = kTRUE;
+        }
+      }
+      if(!isActive) continue;
+      for(Int_t iX=1; iX<=trdAcc->GetXaxis()->GetNbins(); ++iX) 
+        if(trdAcc->GetXaxis()->GetBinCenter(iX)>=-0.85 && trdAcc->GetXaxis()->GetBinCenter(iX)<=0.85) trdAcc->SetBinContent(iX, iY, 1.0);
+    }  // end for over Y(phi) bins
+  }  // end if phiProj
+    
+  // 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(Form("eff%d", Int_t(1000000.0*gRandom->Rndm())), "TRD-TPC matching efficiency", nBinsZ, ptBinLimits);
+  
+  // loop over Z bins
+  Bool_t effGood = kFALSE;
+  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 && (tpcEntries-trdEntries)>=0.0) 
+      error = TMath::Sqrt(trdEntries*(tpcEntries-trdEntries)/tpcEntries/tpcEntries/tpcEntries);
+    if(ratio>0.001) {
+      efficiency->SetBinContent(i,ratio);
+      efficiency->SetBinError(i,error);
+      effGood = kTRUE;
+    }
+  }     // end loop over Z bins
+  if(!effGood) return 0x0;
+  
+  return efficiency;
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::PlotCentSummaryFromCF(Double_t* /*trendValues*/, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  // Make the centrality summary figure from the CF container 
+  // 
+  if(!fMatchingPtCF) return;
+  AliCFContainer* cf = 0x0;    
+  
+  TLatex* lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001); gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  TVirtualPad* pad=0x0;
+  
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);
+  
+  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");
+  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.3);
+  rangeEffPt->SetStats(kFALSE);
+  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  
+  Int_t padsForEffs[5] = {0,3,6,1,4};
+  for(Int_t iCent=1; iCent<6; ++iCent) {
+    pad = ((TVirtualPad*)l->At(padsForEffs[iCent-1])); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    rangeEffPt->Draw();
+    TLine line;
+    line.SetLineStyle(2);
+    line.SetLineWidth(2);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);
+    
+    cf = fMatchingPtCF;
+    cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);
+       
+    cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  
+    TH1F* hEffPosAll = EfficiencyFromPhiPt(cf,  0,  6, 1, 0);
+    TH1F* hEffPosTrk4 = EfficiencyFromPhiPt(cf, 4,  4, 1, 0);  
+    TH1F* hEffPosTrk5 = EfficiencyFromPhiPt(cf, 5,  5, 1, 0);
+    TH1F* hEffPosTrk6 = EfficiencyFromPhiPt(cf, 6,  6, 1, 0);
+     
+    cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  
+    TH1F* hEffNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);  
+    TH1F* hEffNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);  
+    TH1F* hEffNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);  
+    TH1F* hEffNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);
+    cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);  
+    cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  
+    
+    SetStyle(hEffPosAll,  1, kRed, 1, 24, kRed, 1);
+    SetStyle(hEffPosTrk4, 1, kRed, 1, 25, kRed, 1);
+    SetStyle(hEffPosTrk5, 1, kRed, 1, 26, kRed, 1);
+    SetStyle(hEffPosTrk6, 1, kRed, 1, 27, kRed, 1);
+    SetStyle(hEffNegAll,  1, kBlue, 1, 24, kBlue, 1);
+    SetStyle(hEffNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+    SetStyle(hEffNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+    SetStyle(hEffNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+    hEffPosAll->Draw("same");
+    hEffNegAll->Draw("same");
+    hEffPosTrk4->Draw("same");
+    hEffNegTrk4->Draw("same");
+    hEffPosTrk5->Draw("same");
+    hEffNegTrk5->Draw("same");
+    hEffPosTrk6->Draw("same");
+    hEffNegTrk6->Draw("same");    
+        
+    TLegend* leg=new TLegend(0.18, 0.7, 0.77, 0.89);
+    if(iCent==1) {
+      leg->SetFillColor(0);
+      leg->SetNColumns(2);
+      leg->SetMargin(0.1);
+      leg->SetBorderSize(0);
+      leg->AddEntry(hEffPosAll,  "pos. (#geq 1 tracklet)", "p");
+      leg->AddEntry(hEffNegAll,  "neg. (#geq 1 tracklet)", "p");
+      leg->AddEntry(hEffPosTrk4, "pos. (4 tracklets)", "p");
+      leg->AddEntry(hEffNegTrk4, "neg. (4 tracklets)", "p");
+      leg->AddEntry(hEffPosTrk5, "pos. (5 tracklets)", "p");
+      leg->AddEntry(hEffNegTrk5, "neg. (5 tracklets)", "p");
+      leg->AddEntry(hEffPosTrk6, "pos. (6 tracklets)", "p");     
+      leg->AddEntry(hEffNegTrk6, "neg. (6 tracklets)", "p");
+      leg->Draw();
+    }
+    lat->DrawLatex(0.2, 1.32, Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent)));
+  }   // end for loop over multiplicity classes
+  
+  // Reset the modified user ranges of the CF container
+  cf->SetRangeUser(cf->GetVar("multiplicity"), 0., 3500.);
+     
+  // Cluster distributions in all multiplicity classes
+  pad = ((TVirtualPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");
+  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);
+  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeNcls->SetStats(kFALSE);
+  rangeNcls->Draw();
+    
+  TH1D* hNcls[6]={0x0};
+  TLegend* legCls=new TLegend(0.7, 0.75, 0.97, 0.97);
+  legCls->SetBorderSize(0);
+  legCls->SetFillColor(0);
+  legCls->SetMargin(0.15);
+  cf = fCentralityCF;
+  for(Int_t iCent=0; iCent<6; ++iCent) {
+    if(iCent>0)
+      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);
+    hNcls[iCent] = (TH1D*)cf->Project(0, cf->GetVar("clusters"));
+    if(!hNcls[iCent]) continue;
+    
+    hNcls[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+    Double_t maximum = hNcls[iCent]->GetMaximum();
+    if(maximum>1.0)
+      hNcls[iCent]->Scale(1.0/maximum);
+    hNcls[iCent]->SetStats(kFALSE);
+    hNcls[iCent]->SetTitle("");
+    hNcls[iCent]->SetLineWidth(2);
+    
+    if(hNcls[iCent]->Integral()>0.01) {
+      hNcls[iCent]->Draw("same");
+      legCls->AddEntry(hNcls[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), 
+                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");
+    }
+  }
+  legCls->Draw();
+  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 6.0, kTRUE);
+  
+  // Qtot vs P
+  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);
+  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");
+  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);
+  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtot->SetStats(kFALSE);
+  rangeQtot->Draw();
+  
+  TH1D* hQtot[6]={0x0};
+  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.97);
+  leg2->SetFillColor(0);
+  leg2->SetBorderSize(0);
+  
+  for(Int_t iCent=0; iCent<6; ++iCent) {
+    if(iCent>0)
+      cf->SetRangeUser(cf->GetVar("multiplicity"), Double_t(iCent), Double_t(iCent), kTRUE);
+    
+    hQtot[iCent] = (TH1D*)cf->Project(0, cf->GetVar("Qtot0"));
+    if(!hQtot[iCent]) continue;
+    hQtot[iCent]->SetBinContent(1, 0);
+    
+    Double_t maximum = hQtot[iCent]->GetMaximum();
+    if(maximum>1.0)
+      hQtot[iCent]->Scale(1.0/maximum);
+    hQtot[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+    hQtot[iCent]->SetStats(kFALSE);
+    hQtot[iCent]->SetTitle("");
+    hQtot[iCent]->SetLineWidth(2);
+    if(hQtot[iCent]->Integral()>0.01) {
+      hQtot[iCent]->Draw(iCent==0 ? "" : "same");
+      leg2->AddEntry(hQtot[iCent], (iCent==0 ? "all centralities" : Form("%.0f < SPD tracklets < %.0f", cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinLowEdge(iCent), 
+                                                                          cf->GetAxis(cf->GetVar("multiplicity"),0)->GetBinUpEdge(iCent))), "l");
+    }
+  }
+  leg2->Draw();
+  cf->SetRangeUser(cf->GetVar("multiplicity"), 0.0, 5.0, kTRUE);
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc
+}
+
+
+//_________________________________________________________________
+void AliTRDcheckESD::PlotTrackingSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  //  Plot tracking summary
+  //
+  if(!fMatchingPhiEtaCF || !fMatchingPtCF || !fCentralityCF || !fBunchCrossingsCF) return;
+  AliCFContainer* cf = 0x0;  
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+  
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  
+  // eta-phi distr. for positive TPC tracks
+  TVirtualPad* 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);
+  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);
+  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);
+  
+  // find all the isolated bunch crossings with entries
+  TH2D* hTPCrefPos = 0x0; TH2D* hTRDrefPos = 0x0; TH2D* hTOFrefPos = 0x0;
+  TH2D* hTPCrefNeg = 0x0; TH2D* hTRDrefNeg = 0x0; TH2D* hTOFrefNeg = 0x0;
+  cf = fMatchingPhiEtaCF;
+  cf->SetRangeUser(cf->GetVar("tracklets"), 0.0, 6.0);
+  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);      // positive charges
+  hTPCrefPos = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));
+  hTRDrefPos = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));
+  hTOFrefPos = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));
+  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);      // negative charges
+  hTPCrefNeg = (TH2D*)cf->Project(0, cf->GetVar("eta"), cf->GetVar("phi"));
+  hTRDrefNeg = (TH2D*)cf->Project(1, cf->GetVar("eta"), cf->GetVar("phi"));
+  hTOFrefNeg = (TH2D*)cf->Project(2, cf->GetVar("eta"), cf->GetVar("phi"));
+  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);      // reset charge cut
+    
+  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);  
+  
+  //----------------------------------------------
+  // eta-phi efficiency for positive TRD 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);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTRDeffPos = (hTRDrefPos ? (TH2D*)hTRDrefPos->Clone("hTRDeffPos") : 0x0);
+  if(hTRDeffPos) {
+    hTRDeffPos->Reset();
+    hTRDeffPos->SetStats(kFALSE);
+    hTRDeffPos->Divide(hTRDrefPos, hTPCrefPos);
+    hTRDeffPos->SetMaximum(1.0);
+    hTRDeffPos->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for positive tracks");
+    DrawTRDGrid();
+  }
+  
+  //----------------------------------------------
+  // eta-phi efficiency for negative 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);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTRDeffNeg = (hTRDrefNeg ? (TH2D*)hTRDrefNeg->Clone("hTRDeffNeg") : 0x0);
+  if(hTRDeffNeg) {
+    hTRDeffNeg->Reset();
+    hTRDeffNeg->SetStats(kFALSE);
+    hTRDeffNeg->Divide(hTRDrefNeg, hTPCrefNeg);
+    hTRDeffNeg->SetMaximum(1.0);
+    hTRDeffNeg->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.6, "TPC-TRD matching for negative tracks");
+    DrawTRDGrid();  
+  }
+  
+  //----------------------------------------------
+  // eta-phi TRD-TOF matching efficiency for positive 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);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTOFeffPos = (hTOFrefPos ? (TH2D*)hTOFrefPos->Clone("hTOFeffPos") : 0x0);
+  if(hTOFeffPos) {
+    hTOFeffPos->Reset();
+    hTOFeffPos->SetStats(kFALSE);
+    hTOFeffPos->Divide(hTOFrefPos, hTRDrefPos);
+    hTOFeffPos->SetMaximum(1.0);
+    hTOFeffPos->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for positive tracks");
+    DrawTRDGrid();
+  }
+  
+  //----------------------------------------------
+  // eta-phi TRD-TOF matching efficiency for negative 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);
+  rangeEtaPhi->Draw();
+  
+  TH2D* hTOFeffNeg = (hTOFrefNeg ? (TH2D*)hTOFrefNeg->Clone("hTOFeffNeg") : 0x0);
+  if(hTOFeffNeg) {
+    hTOFeffNeg->Reset();
+    hTOFeffNeg->SetStats(kFALSE);
+    hTOFeffNeg->Divide(hTOFrefNeg, hTRDrefNeg);
+    hTOFeffNeg->SetMaximum(1.0);
+    hTOFeffNeg->Draw("samecolz");
+    lat->DrawLatex(-0.9, 3.6, "TRD-TOF matching for negative tracks");
+    DrawTRDGrid();
+  }
+  
+  if(hTRDrefPos) delete hTRDrefPos; if(hTPCrefPos) delete hTPCrefPos; if(hTOFrefPos) delete hTOFrefPos;
+  if(hTRDrefNeg) delete hTRDrefNeg; if(hTPCrefNeg) delete hTPCrefNeg; if(hTOFrefNeg) delete hTOFrefNeg;
+  
+  // switch to the Pt cf container
+  cf = fMatchingPtCF;
+  cf->SetRangeUser(cf->GetVar("charge"), +1.0, +1.0);  
+  TH1F* hTRDEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);
+  TH1F* hTOFEffPtPosAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);
+  TH1F* hTOFEffPtPosTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);
+  TH1F* hTOFEffPtPosTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);
+  TH1F* hTOFEffPtPosTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");
+  
+  cf->SetRangeUser(cf->GetVar("charge"), -1.0, -1.0);  
+  TH1F* hTRDEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 1, 0);
+  TH1F* hTOFEffPtNegAll = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 1, 0);
+  TH1F* hTOFEffPtNegTrk4 = EfficiencyFromPhiPt(cf, 4, 4, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 1, 0);
+  TH1F* hTOFEffPtNegTrk5 = EfficiencyFromPhiPt(cf, 5, 5, 2, 1, "pt", "TRDTOF");
+  TH1F* hTRDEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 1, 0);
+  TH1F* hTOFEffPtNegTrk6 = EfficiencyFromPhiPt(cf, 6, 6, 2, 1, "pt", "TRDTOF");
+  cf->SetRangeUser(cf->GetVar("charge"), -1.0, +1.0);  
+  
+  TF1* funcConst = new TF1("constFunc", "[0]", 1.0, 3.0);
+  if(trendValues) {
+    if(hTRDEffPtPosAll && hTRDEffPtPosAll->Integral()>0.1) {
+      hTRDEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[0] = funcConst->GetParameter(0);
+      trendValues[1] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTRDEffPtNegAll && hTRDEffPtNegAll->Integral()>0.1) {
+      hTRDEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[2] = funcConst->GetParameter(0);
+      trendValues[3] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTOFEffPtPosAll && hTOFEffPtPosAll->Integral()>0.1) {
+      hTOFEffPtPosAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[4] = funcConst->GetParameter(0);
+      trendValues[5] = funcConst->GetParError(0);
+    }
+  }
+  if(trendValues) { 
+    if(hTOFEffPtNegAll && hTOFEffPtNegAll->Integral()>0.1) {
+      hTOFEffPtNegAll->Fit(funcConst, "Q0ME", "goff", 1.0, 3.0);
+      trendValues[6] = funcConst->GetParameter(0);
+      trendValues[7] = funcConst->GetParError(0);
+    }
+  }
+  
+  //---------------------------------------------------------
+  // TPC-TRD matching efficiency vs pt
+  pad = ((TVirtualPad*)l->At(6)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");
+  TH2F* rangeEffPt=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);
+  rangeEffPt->SetStats(kFALSE);
+  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  rangeEffPt->Draw();
+  lat->DrawLatex(0.2, 1.42, "TPC-TRD matching efficiency");
+  //++++++++++++++++++
+  TLine line;
+  line.SetLineStyle(2);
+  line.SetLineWidth(2);
+  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);
+  line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);
+  TLegend* leg=new TLegend(0.2, 0.7, 0.7, 0.89);
+  leg->SetNColumns(2);
+  leg->SetMargin(0.15);
+  leg->SetBorderSize(0);
+  leg->SetFillColor(0);
+
+  SetStyle(hTRDEffPtPosAll, 1, kRed, 1, 24, kRed, 1);
+  SetStyle(hTRDEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+  SetStyle(hTRDEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);
+  SetStyle(hTRDEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+  if(hTRDEffPtPosAll) {hTRDEffPtPosAll->Draw("same"); leg->AddEntry(hTRDEffPtPosAll, "pos. (#geq 1 tracklet)", "p");}
+  if(hTRDEffPtNegAll) {hTRDEffPtNegAll->Draw("same"); leg->AddEntry(hTRDEffPtNegAll, "neg. (#geq 1 tracklet)", "p");}
+  hTRDEffPtPosTrk4->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk4, "pos. (4 tracklets)", "p");
+  hTRDEffPtNegTrk4->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk4, "neg. (4 tracklets)", "p");
+  hTRDEffPtPosTrk5->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk5, "pos. (5 tracklets)", "p");
+  hTRDEffPtNegTrk5->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk5, "neg. (5 tracklets)", "p");
+  hTRDEffPtPosTrk6->Draw("same"); leg->AddEntry(hTRDEffPtPosTrk6, "pos. (6 tracklets)", "p");
+  hTRDEffPtNegTrk6->Draw("same"); leg->AddEntry(hTRDEffPtNegTrk6, "neg. (6 tracklets)", "p");
+  
+  leg->Draw();
+  
+  //---------------------------------------------------------
+  // TRD-TOF matching efficiency vs pt
+  pad = ((TVirtualPad*)l->At(7)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  rangeEffPt->Draw();
+  lat->DrawLatex(0.2, 1.42, "TRD-TOF matching efficiency");
+  SetStyle(hTOFEffPtPosAll, 1, kRed, 1, 24, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk4, 1, kRed, 1, 25, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk5, 1, kRed, 1, 26, kRed, 1);
+  SetStyle(hTOFEffPtPosTrk6, 1, kRed, 1, 27, kRed, 1);
+  SetStyle(hTOFEffPtNegAll, 1, kBlue, 1, 24, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk4, 1, kBlue, 1, 25, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk5, 1, kBlue, 1, 26, kBlue, 1);
+  SetStyle(hTOFEffPtNegTrk6, 1, kBlue, 1, 27, kBlue, 1);
+  if(hTOFEffPtPosAll) hTOFEffPtPosAll->Draw("same"); 
+  hTOFEffPtPosTrk4->Draw("same"); 
+  hTOFEffPtPosTrk5->Draw("same"); 
+  hTOFEffPtPosTrk6->Draw("same"); 
+  if(hTOFEffPtNegAll) hTOFEffPtNegAll->Draw("same"); 
+  hTOFEffPtNegTrk4->Draw("same"); 
+  hTOFEffPtNegTrk5->Draw("same"); 
+  hTOFEffPtNegTrk6->Draw("same");  
+    
+  //-----------------------------------------------------
+  // <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);
+  
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");
+  
+  cf = fMatchingPhiEtaCF;
+  TH3D* hNtracklets = (TH3D*)cf->Project(1, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("tracklets"));
+  
+  TProfile2D* hNtrackletsProf = hNtracklets->Project3DProfile();
+  delete hNtracklets;
+  if(hNtrackletsProf) {
+    hNtrackletsProf->SetStats(kFALSE);
+    hNtrackletsProf->SetMinimum(0.);
+    hNtrackletsProf->SetMaximum(6.);
+    hNtrackletsProf->Draw("samecolz");
+    DrawTRDGrid();
+  }
+  
+  // calculate the trend value for tracklets/track
+  cf = fMatchingPtCF;
+  TH2D* hNtrackletsVsP = (TH2D*)cf->Project(1, cf->GetVar("pt"), cf->GetVar("tracklets"));
+  if(trendValues &&  hNtrackletsVsP && hNtrackletsVsP->GetEntries()>0.1) {
+    TProfile* hNtrackletsVsPprof = hNtrackletsVsP->ProfileX("hNtrackletsVsPprof");
+    hNtrackletsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+    trendValues[8] = funcConst->GetParameter(0);
+    trendValues[9] = funcConst->GetParError(0);
+    delete hNtrackletsVsP;
+  }
+      
+  //--------------------------------------------------------------
+  // Nclusters per TRD track vs momentum
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  
+  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");
+  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);
+  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);
+  rangeNclsP->SetStats(kFALSE);
+  rangeNclsP->Draw();
+  lat->DrawLatex(1.0, 205., "TRD Clusters / track");
+  
+  cf = fCentralityCF;
+  TH2D* hNclsVsP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("clusters"));
+  if(hNclsVsP) {
+    hNclsVsP->SetStats(kFALSE);
+    hNclsVsP->Draw("samecolz");
+  }    
+  
+  if(trendValues && hNclsVsP && hNclsVsP->GetEntries()>10) {
+    TProfile* hNclsVsPprof = hNclsVsP->ProfileX("hNclsVsPprof");
+    hNclsVsPprof->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+    trendValues[10] = funcConst->GetParameter(0);
+    trendValues[11] = funcConst->GetParError(0);
+  }
+    
+  //--------------------------------------------------------------
+  // TRD-TPC and TOF-TRD matching efficiency vs bunch crossing
+  pad = ((TVirtualPad*)l->At(8)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+
+  cf = fBunchCrossingsCF;
+  TH1F* hTRDEffBC = EfficiencyFromPhiPt(cf, 0, 6, 1, 0, "BC", "TPCTRD");
+  TH1F* hTOFEffBC = EfficiencyFromPhiPt(cf, 0, 6, 2, 1, "BC", "TRDTOF");
+  
+  if(gROOT->FindObject("rangeBC")) delete gROOT->FindObject("rangeBC");
+  TH2F* rangeBC = new TH2F("rangeBC", "", 10, -0.5, 3499.5, 10, 0.0, 1.4);
+  rangeBC->SetStats(kFALSE);
+  SetStyle(rangeBC->GetXaxis(), "Bunch crossing", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeBC->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  rangeBC->Draw();
+  
+  TLegend* legBC=new TLegend(0.8, 0.7, 0.95, 0.89);
+  legBC->SetBorderSize(0);
+  legBC->SetMargin(0.15);
+  legBC->SetFillColor(0);
+  if(hTRDEffBC) {
+    hTRDEffBC->SetStats(kFALSE);
+    SetStyle(hTRDEffBC, 1, kRed, 2, 24, kRed, 1); legBC->AddEntry(hTRDEffBC, "TPC-TRD", "p");
+    SetStyle(hTOFEffBC, 1, kBlue, 2, 24, kBlue, 1); legBC->AddEntry(hTOFEffBC, "TRD-TOF", "p");
+    hTRDEffBC->Draw("same");
+    hTOFEffBC->Draw("same");
+    legBC->Draw();
+    lat->DrawLatex(200., 1.42, "Matching efficiency at 1<p_{T}<3 GeV/c");
+  }
+    
+  // reset the user range on the event multiplicity
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc
+  
+  delete funcConst;
+}
+
+
+//_________________________________________________________________
+void AliTRDcheckESD::PlotPidSummaryFromCF(Double_t* trendValues, const Char_t* /*triggerName*/, Bool_t /*useIsolatedBC*/, Bool_t /*cutTOFbc*/) {
+  //
+  // Centrality summary
+  //
+  if(!fQtotCF || !fPulseHeightCF || !fCentralityCF) return;
+  
+  AliCFContainer* cf = 0x0;
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  
+  //cf->SetRangeUser(stepDCAxy, -0.999, +0.999);
+  //cf->SetRangeUser(stepDCAz, -3.0, +3.0);
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, 0.0, 0.0);
+  
+  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);  
+  
+  // eta-phi distr. for <Qtot> in layer 0
+  TVirtualPad* pad;
+  TProfile2D* hProf2D;
+  cf = fQtotCF;
+  for(Int_t iLayer=0; iLayer<6; ++iLayer) {
+    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+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);
+    rangeEtaPhi->Draw();
+    
+    cf->SetRangeUser(cf->GetVar("layer"), Double_t(iLayer), Double_t(iLayer));
+    TH3D* hQtotEtaPhi = (TH3D*)cf->Project(0, cf->GetVar("phi"), cf->GetVar("eta"), cf->GetVar("Qtot0"));
+    hProf2D = (hQtotEtaPhi ? hQtotEtaPhi->Project3DProfile() : 0x0);
+    if(hQtotEtaPhi) delete hQtotEtaPhi;
+    
+    if(hProf2D) {
+      hProf2D->SetName(Form("Qtot_layer%d",iLayer));
+      hProf2D->SetStats(kFALSE);
+      hProf2D->SetMinimum(0.);
+      hProf2D->SetMaximum(4.);
+      hProf2D->Draw("samecolz");
+    }
+    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));
+    DrawTRDGrid();
+  }
+  cf->SetRangeUser(cf->GetVar("layer"), 0.0, 5.0);
+    
+  // PH versus slice number
+  pad = ((TVirtualPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  
+  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");
+  TH2F* rangePHslice=new TH2F("rangePHslice", "", 8, -0.5, 7.5, 10, 0.0, 6.);
+  rangePHslice->SetStats(kFALSE);
+  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);
+  rangePHslice->Draw();
+  
+  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);
+  
+  cf = fPulseHeightCF;
+  TH2D* hPH = (TH2D*)cf->Project(0, cf->GetVar("slice"), cf->GetVar("PH0"));
+  TH1D* hSliceErr = new TH1D(Form("hSliceErr%f", gRandom->Rndm()), "", hPH->GetXaxis()->GetNbins(), hPH->GetXaxis()->GetXbins()->GetArray());
+  TH1D* hLandauFit = Proj2D(hPH, hSliceErr);
+  hPH->SetStats(kFALSE);
+  hPH->Draw("samecolz");
+  if(trendValues) {
+    hSliceErr->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);
+    trendValues[12] = funcPol1->GetParameter(0);  // PH plateau
+    trendValues[13] = funcPol1->GetParError(0);   // PH plateau
+    trendValues[14] = funcPol1->GetParameter(1);  // PH slope
+    trendValues[15] = funcPol1->GetParError(1);   // PH slope
+  }
+  hLandauFit->SetLineWidth(2);
+  hLandauFit->SetLineStyle(2);
+  hLandauFit->Draw("same");
+  
+  delete funcPol1; delete hSliceErr;
+  
+  // Qtot vs P
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.1);
+  pad->SetTopMargin(0.03); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  
+  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");
+  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);
+  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtotP->SetStats(kFALSE);
+  rangeQtotP->Draw();
+  
+  cf = fCentralityCF;
+  TH2D* hQtotP = (TH2D*)cf->Project(0, cf->GetVar("P"), cf->GetVar("Qtot0"));
+    
+  if(hQtotP)
+    for(Int_t i=1; i<=hQtotP->GetXaxis()->GetNbins(); ++i) 
+      hQtotP->SetBinContent(i, 1, 0.0);  
+  TH1D* hQtotProj = (hQtotP ? Proj2D(hQtotP) : 0x0);
+  if(hQtotProj) SetStyle(hQtotProj, 2, kBlue, 2, 1, kBlue, 1);
+  if(trendValues && hQtotProj && hQtotProj->GetEntries()>2) {
+    trendValues[16] = hQtotProj->GetBinContent(hQtotProj->FindBin(1.0));   // Landau MPV at 1GeV/c
+    trendValues[17] = hQtotProj->GetBinError(hQtotProj->FindBin(1.0));     // Landau width at 1 GeV/c
+  }
+  if(hQtotP) {
+    hQtotP->SetStats(kFALSE);
+    hQtotP->Draw("samecolz");
+    hQtotProj->Draw("same");
+  }
+  //if(cutTOFbc) cf->SetRangeUser(stepTOFBC, -1000.0, +1000.0);  // reset the cut on TOFbc
+}
+
+
+//_________________________________________________________________
+Bool_t AliTRDcheckESD::PlotCentSummary(Double_t* /*trendValues*/) {
+
+  Bool_t isGoodForSaving=kFALSE;
+  
+  TLatex* lat=new TLatex();
+  lat->SetTextSize(0.06);
+  lat->SetTextColor(2);
+
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  
+  TPad* pad=0x0;  
+
+  if(gROOT->FindObject("rangeEffPt")) delete gROOT->FindObject("rangeEffPt");
+  TH2F* rangeEffPt=new TH2F("rangeEffPt", "",10,0.,10.,10,0.,1.4);
+  rangeEffPt->SetStats(kFALSE);
+  SetStyle(rangeEffPt->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  
+  TH3F *h3(NULL), *h3p(NULL), *h3n(NULL);
+  Int_t padsForEffs[5] = {0,3,6,1,4};
+  for(Int_t iCent=1; iCent<6; ++iCent) {
+    // TPC-TRD matching efficiencies
+    pad = ((TPad*)l->At(padsForEffs[iCent-1])); pad->cd();
+    pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02); pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+    pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+    
+    if(!(h3p = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+iCent)))) continue;
+    if(!(h3n = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+iCent)))) continue;
+    // =============================================
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+iCent)))) continue;
+    TH1F* hFeffP = EfficiencyTRD(h3p, h3, kTRUE);
+    //
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+iCent)))) continue;
+    TH1F* hFeffN = EfficiencyTRD(h3n, h3, kTRUE);
+    // =============================================
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+iCent)))) continue;
+    TH1F* hFeffP4 = EfficiencyTRD(h3p, h3, kTRUE);
+    //
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+iCent)))) continue;
+    TH1F* hFeffN4 = EfficiencyTRD(h3n, h3, kTRUE);
+    // =============================================
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+iCent)))) continue;
+    TH1F* hFeffP5 = EfficiencyTRD(h3p, h3, kTRUE);
+    //
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+iCent)))) continue;
+    TH1F* hFeffN5 = EfficiencyTRD(h3n, h3, kTRUE);
+    // =============================================
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+iCent)))) continue;
+    TH1F* hFeffP6 = EfficiencyTRD(h3p, h3, kTRUE);
+    //
+    if(!(h3 = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+iCent)))) continue;
+    TH1F* hFeffN6 = EfficiencyTRD(h3n, h3, kTRUE);
+  
+    rangeEffPt->Draw();
+    
+    TLine line;
+    line.SetLineStyle(2);
+    line.SetLineWidth(2);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.7, rangeEffPt->GetXaxis()->GetXmax(), 0.7);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 0.9, rangeEffPt->GetXaxis()->GetXmax(), 0.9);
+    line.SetLineStyle(1);
+    line.SetLineWidth(1);
+    line.DrawLine(rangeEffPt->GetXaxis()->GetXmin(), 1.0, rangeEffPt->GetXaxis()->GetXmax(), 1.0);
+    if(hFeffP) SetStyle(hFeffP, 1, kRed, 1, 24, kRed, 1);
+    if(hFeffP4) SetStyle(hFeffP4, 1, kRed, 1, 25, kRed, 1);
+    if(hFeffP5) SetStyle(hFeffP5, 1, kRed, 1, 26, kRed, 1);
+    if(hFeffP6) SetStyle(hFeffP6, 1, kRed, 1, 27, kRed, 1);
+    if(hFeffN) SetStyle(hFeffN, 1, kBlue, 1, 24, kBlue, 1);
+    if(hFeffN4) SetStyle(hFeffN4, 1, kBlue, 1, 25, kBlue, 1);
+    if(hFeffN5) SetStyle(hFeffN5, 1, kBlue, 1, 26, kBlue, 1);
+    if(hFeffN6) SetStyle(hFeffN6, 1, kBlue, 1, 27, kBlue, 1);
+    
+    TLegend* leg=new TLegend(0.16, 0.7, 0.61, 0.89);
+    leg->SetFillColor(0);
+    leg->SetNColumns(2);
+    leg->SetTextSize(0.039);
+    leg->SetMargin(0.1);
+    if(hFeffP && hFeffP->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffP->Draw("same");
+      leg->AddEntry(hFeffP, "pos. (#geq 1 trcklt)", "p");
+    }
+    if(hFeffN && hFeffN->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffN->Draw("same");
+      leg->AddEntry(hFeffN, "neg. (#geq 1 trcklt)", "p");
+    }
+    if(hFeffP4 && hFeffP4->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffP4->Draw("same");
+      leg->AddEntry(hFeffP4, "pos. (4 trcklts)", "p");
+    }
+    if(hFeffN4 && hFeffN4->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffN4->Draw("same");
+      leg->AddEntry(hFeffN4, "neg. (4 trcklts)", "p");
+    }
+    if(hFeffP5 && hFeffP5->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffP5->Draw("same");
+      leg->AddEntry(hFeffP5, "pos. (5 trcklts)", "p");
+    }
+    if(hFeffN5 && hFeffN5->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffN5->Draw("same");
+      leg->AddEntry(hFeffN5, "neg. (5 trcklts)", "p");
+    }
+    if(hFeffP6 && hFeffP6->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffP6->Draw("same");
+      leg->AddEntry(hFeffP6, "pos. (6 trcklts)", "p");
+    }
+    if(hFeffN6 && hFeffN6->Integral()>0.001) {
+      isGoodForSaving = kTRUE;
+      hFeffN6->Draw("same");
+      leg->AddEntry(hFeffN6, "neg. (6 trklts)", "p");
+    }
+    
+    if(isGoodForSaving) {
+      if(iCent==1) leg->Draw();
+      lat->DrawLatex(5.6, 1.3, Form("Centrality class %d", iCent));
+      lat->DrawLatex(0.5, 1.42, "TPC-TRD matching efficiency");
+    }
+  }   // end loop over multiplicity intervals
+
+  // Number of clusters per TRD track
+  pad = ((TPad*)l->At(2)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.02); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  if(gROOT->FindObject("rangeNcls")) delete gROOT->FindObject("rangeNcls");
+  TH2F* rangeNcls = new TH2F("rangeNcls", "", 10, 0.0, 199.9, 10, 0.0, 1.199);
+  SetStyle(rangeNcls->GetXaxis(), "# TRD clusters", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNcls->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeNcls->SetStats(kFALSE);
+  rangeNcls->Draw();
+  
+  TH2F* h2F[6]; TH1D* proj[6];
+  TLegend* leg=new TLegend(0.2, 0.7, 0.5, 0.95);
+  leg->SetFillColor(0);
+  Bool_t isGood=kFALSE;
+  for(Int_t iCent=0; iCent<6; ++iCent) {
+    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+iCent));
+    proj[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projCent%d",iCent)) : 0x0);
+    if(proj[iCent]) {
+      proj[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+      Double_t maximum = proj[iCent]->GetMaximum();
+      if(maximum>1.0)
+        proj[iCent]->Scale(1.0/maximum);
+      proj[iCent]->SetStats(kFALSE);
+      proj[iCent]->Draw("same");
+      leg->AddEntry(proj[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");
+      isGood = kTRUE;
+    }
+  }
+  if(isGood) leg->Draw();
+  isGoodForSaving = isGoodForSaving || isGood;
+  
+  // Qtot vs P
+  pad = ((TPad*)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);
+  if(gROOT->FindObject("rangeQtot")) delete gROOT->FindObject("rangeQtot");
+  TH2F* rangeQtot = new TH2F("rangeQtot", "", 10, 0.0, 9.999, 10, 0.0, 1.199);
+  SetStyle(rangeQtot->GetXaxis(), "Q_{tot} (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtot->GetYaxis(), "entries (a.u.)", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtot->SetStats(kFALSE);
+  rangeQtot->Draw();
+  
+  TH1D* projQ[6];
+  TLegend* leg2=new TLegend(0.6, 0.7, 0.9, 0.95);
+  leg2->SetFillColor(0);
+  isGood = kFALSE;
+  for(Int_t iCent=0; iCent<6; ++iCent) {  
+    h2F[iCent] = dynamic_cast<TH2F*>(fHistos->At(kQtotP+iCent));
+    projQ[iCent] = (h2F[iCent] && h2F[iCent]->GetEntries()>10 ? h2F[iCent]->ProjectionY(Form("projQCent%d",iCent)) : 0x0);
+    if(projQ[iCent]) {
+      projQ[iCent]->SetLineColor(iCent<4 ? iCent+1 : iCent+2);
+      Double_t maximum = projQ[iCent]->GetMaximum();
+      if(maximum>1.0)
+        projQ[iCent]->Scale(1.0/maximum);
+      projQ[iCent]->SetStats(kFALSE);
+      projQ[iCent]->Draw("same");
+      leg2->AddEntry(projQ[iCent], (iCent==0 ? "all centralities" : Form("centrality class %d", iCent)), "l");
+      isGood = kTRUE;
+    }
+  }
+  if(isGood) leg2->Draw();
+  isGoodForSaving = isGoodForSaving || isGood;
+  return isGoodForSaving;
+}
+
+
+//_________________________________________________________________
+Bool_t AliTRDcheckESD::PlotTrackingSummary(Int_t centralityClass, Double_t* trendValues) {
+
+  Bool_t isGoodForSaving=kFALSE;
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  // eta-phi distr. for positive TPC tracks
+  TVirtualPad* 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);
+  if(gROOT->FindObject("rangeEtaPhi")) delete gROOT->FindObject("rangeEtaPhi");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi", "", 10, -0.99, +0.99, 10, -3.4, +3.4);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TPC positive ref. tracks");
+  
+  TH3F* h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass));
+  TH2F* h2FtpcP = 0x0;
+  Float_t nada=0.0;
+  if(h3F && h3F->GetEntries()>10) {
+    h2FtpcP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtpcP->SetStats(kFALSE);
+    h2FtpcP->Draw("samecolz"); isGoodForSaving = kTRUE;
+    isGoodForSaving = kTRUE;
+  }
+  //-----------------
+  // 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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TPC negative ref. tracks");
+  
+  h3F = dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass));
+  TH2F* h2FtpcN = 0x0;
+  if(h3F && h3F->GetEntries()>10) {
+    h2FtpcN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtpcN->SetStats(kFALSE);
+    h2FtpcN->Draw("samecolz"); 
+    isGoodForSaving = kTRUE;
+  }
+  //----------------------------------------------
+  // 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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TRD positive ref. tracks");
+  
+  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass));
+  TH2F* h2FtrdP = 0x0;
+  if(h3F && h3F->GetEntries()>10) {
+    h2FtrdP = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtrdP->SetStats(kFALSE);
+    h2FtrdP->SetMaximum((h2FtpcP ? h2FtpcP->GetMaximum() : h2FtrdP->GetMaximum()));
+    h2FtrdP->Draw("samecolz"); 
+    isGoodForSaving=kTRUE;
+  }
+  //--------------------------------------------
+  // 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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TRD negative ref. tracks");
+  
+  h3F = dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass));
+  TH2F* h2FtrdN = 0x0;
+  if(h3F && h3F->GetEntries()>10) {
+    h2FtrdN = (TH2F*)Proj3D((TH3F*)h3F, 0x0, 1, h3F->GetZaxis()->GetNbins(), nada)->Clone();
+    h2FtrdN->SetStats(kFALSE);
+    h2FtrdN->SetMaximum(h2FtpcN ? h2FtpcN->GetMaximum() : h2FtrdN->GetMaximum());
+    h2FtrdN->Draw("samecolz"); 
+    isGoodForSaving=kTRUE;
+  }
+  //----------------------------------------------
+  // 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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "Efficiency positive tracks");
+  
+  TH2F* h2Feff = (h2FtrdP ? (TH2F*)h2FtrdP->Clone("h2FeffPos") : 0x0);
+  if(h2Feff) {
+    h2Feff->Reset();
+    h2Feff->SetStats(kFALSE);
+    h2Feff->Divide(h2FtrdP, h2FtpcP);
+    h2Feff->SetMaximum(1.0);
+    if(h2Feff->GetEntries()>1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }
+  }
+  //-------------------------------------------------
+  // 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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "Efficiency negative tracks");
+  
+  h2Feff = (h2FtrdN ? (TH2F*)h2FtrdN->Clone("h2FeffNeg") : 0x0);
+  if(h2Feff) {
+    h2Feff->Reset();
+    h2Feff->SetStats(kFALSE);
+    h2Feff->Divide(h2FtrdN, h2FtpcN);
+    h2Feff->SetMaximum(1.0);
+    if(h2Feff->GetEntries()>0.1) { h2Feff->Draw("samecolz"); isGoodForSaving=kTRUE; }
+  }
+  //-----------------------------------------------------
+  // <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);
+  rangeEtaPhi->Draw();
+  lat->DrawLatex(-0.9, 3.6, "TRD <N_{tracklets}>");
+  
+  TProfile2D* hProf2D;
+  if((hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvNtrkl+centralityClass)))) {
+    if(hProf2D->GetEntries()>10) {
+      hProf2D->SetStats(kFALSE);
+      hProf2D->SetMinimum(0.);
+      hProf2D->SetMaximum(6.);
+      if(hProf2D->GetEntries()>1) { hProf2D->Draw("samecolz"); isGoodForSaving = kTRUE; }
+    }
+  }
+  //---------------------------------------------------------
+  // TPC-TRD matching efficiency vs pt
+  pad = ((TVirtualPad*)l->At(5)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.02);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  TH1F* hFeffP = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),
+              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos+centralityClass)), kTRUE);
+  TH1F* hFeffN = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),
+              dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg+centralityClass)), kTRUE);
+  TH1F* hFeffP4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos4+centralityClass)), kTRUE);
+  TH1F* hFeffN4 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg4+centralityClass)), kTRUE);
+  TH1F* hFeffP5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos5+centralityClass)), kTRUE);
+  TH1F* hFeffN5 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg5+centralityClass)), kTRUE);
+  TH1F* hFeffP6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksPos+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksPos6+centralityClass)), kTRUE);
+  TH1F* hFeffN6 = EfficiencyTRD(dynamic_cast<TH3F*>(fHistos->At(kTPCRefTracksNeg+centralityClass)),
+        dynamic_cast<TH3F*>(fHistos->At(kTRDRefTracksNeg6+centralityClass)), kTRUE);
+  
+  TF1* funcConst = new TF1("funcConst", "[0]", 1.0, 3.0);
+  
+  if(gROOT->FindObject("rangeEffPt2")) delete gROOT->FindObject("rangeEffPt2");
+  TH2F* rangeEffPt2=new TH2F("rangeEffPt2", "",10,0.,10.,10,0.,1.4);
+  rangeEffPt2->SetStats(kFALSE);
+  SetStyle(rangeEffPt2->GetXaxis(), "p_{T} [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEffPt2->GetYaxis(), "efficiency", 0.07, 0.8, kTRUE, 0.05);
+  rangeEffPt2->Draw();
+  lat->DrawLatex(0.5, 1.42, "TRD-TPC matching efficiency");
+  //++++++++++++++++++
+  TLine line;
+  line.SetLineStyle(2);
+  line.SetLineWidth(2);
+  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.7, rangeEffPt2->GetXaxis()->GetXmax(), 0.7);
+  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 0.9, rangeEffPt2->GetXaxis()->GetXmax(), 0.9);
+  line.SetLineStyle(1);
+  line.SetLineWidth(1);
+  line.DrawLine(rangeEffPt2->GetXaxis()->GetXmin(), 1.0, rangeEffPt2->GetXaxis()->GetXmax(), 1.0);
+  TLegend* leg=new TLegend(0.2, 0.7, 0.6, 0.89);
+  leg->SetNColumns(2);
+  leg->SetFillColor(0);
+  if(hFeffP){
+    hFeffP->SetMarkerStyle(24);
+    hFeffP->SetMarkerColor(2);
+    hFeffP->SetLineColor(2);
+    if(trendValues && hFeffP->GetEntries()>1) {
+      hFeffP->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+      trendValues[0] = funcConst->GetParameter(0);
+      trendValues[1] = funcConst->GetParError(0);
+    }
+    if(hFeffP->Integral()>0.001) {
+      hFeffP->Draw("same"); 
+      leg->AddEntry(hFeffP, "positives (#geq 1 tracklet)", "p");
+    }
+  }
+  if(hFeffN){
+    hFeffN->SetMarkerStyle(24);
+    hFeffN->SetMarkerColor(4);
+    hFeffN->SetLineColor(4);
+    if(trendValues && hFeffN->GetEntries()>1) {
+      hFeffN->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+      trendValues[2] = funcConst->GetParameter(0);
+      trendValues[3] = funcConst->GetParError(0);
+    }
+    if(hFeffN->Integral()>0.001) {
+      hFeffN->Draw("same"); 
+      leg->AddEntry(hFeffN, "negatives (#geq 1 tracklet)", "p");
+    }
+  }
+  if(hFeffP4){
+    hFeffP4->SetMarkerStyle(25);
+    hFeffP4->SetMarkerColor(2);
+    hFeffP4->SetLineColor(2);
+    if(hFeffP4->Integral()>0.001) {
+      hFeffP4->Draw("same"); 
+      leg->AddEntry(hFeffP4, "positives (4 tracklets)", "p");
+    }
+  }
+  if(hFeffN4){
+    hFeffN4->SetMarkerStyle(25);
+    hFeffN4->SetMarkerColor(4);
+    hFeffN4->SetLineColor(4);
+    if(hFeffN4->Integral()>0.001) {
+      hFeffN4->Draw("same"); 
+      leg->AddEntry(hFeffN4, "negatives (4 tracklets)", "p");
+    }
+  }
+  if(hFeffP5){
+    hFeffP5->SetMarkerStyle(26);
+    hFeffP5->SetMarkerColor(2);
+    hFeffP5->SetLineColor(2);
+    if(hFeffP5->Integral()>0.001) {
+      hFeffP5->Draw("same"); 
+      leg->AddEntry(hFeffP5, "positives (5 tracklets)", "p");
+    }
+  }
+  if(hFeffN5){
+    hFeffN5->SetMarkerStyle(26);
+    hFeffN5->SetMarkerColor(4);
+    hFeffN5->SetLineColor(4);
+    if(hFeffN5->Integral()>0.001) {
+      hFeffN5->Draw("same"); 
+      leg->AddEntry(hFeffN5, "negatives (5 tracklets)", "p");
+    }
+  }
+  if(hFeffP6){
+    hFeffP6->SetMarkerStyle(27);
+    hFeffP6->SetMarkerColor(2);
+    hFeffP6->SetLineColor(2);
+    if(hFeffP6->Integral()>0.001) {
+      hFeffP6->Draw("same"); 
+      leg->AddEntry(hFeffP6, "positives (6 tracklets)", "p");
+    }
+  }
+  if(hFeffN6){
+    hFeffN6->SetMarkerStyle(27);
+    hFeffN6->SetMarkerColor(4);
+    hFeffN6->SetLineColor(4);
+    if(hFeffN6->Integral()>0.001) {
+      hFeffN6->Draw("same"); 
+      leg->AddEntry(hFeffN6, "negatives (6 tracklets)", "p");
+    }
+  }
+  leg->Draw();
+  
+  //--------------------------------------------------------------
+  // Nclusters per TRD track
+  pad = ((TVirtualPad*)l->At(8)); pad->cd();
+  pad->SetLeftMargin(0.15); pad->SetRightMargin(0.12);
+  pad->SetTopMargin(0.1); pad->SetBottomMargin(0.15);
+  pad->SetGridx(kFALSE); pad->SetGridy(kFALSE);
+  pad->SetLogz();
+  if(gROOT->FindObject("rangeNclsP")) delete gROOT->FindObject("rangeNclsP");
+  TH2F* rangeNclsP = new TH2F("rangeNclsP", "", 10, 0.0, 11.99, 10, 0.0, 199.0);
+  SetStyle(rangeNclsP->GetXaxis(), "p [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeNclsP->GetYaxis(), "#clusters", 0.07, 0.8, kTRUE, 0.05);
+  rangeNclsP->SetStats(kFALSE);
+  rangeNclsP->Draw();
+  lat->DrawLatex(1.0, 205., "TRD Clusters / track");
+  
+  TH2F* hNclsVsP=0x0;
+  if((hNclsVsP = dynamic_cast<TH2F*>(fHistos->At(kNClsTrackTRD+centralityClass)))) {
+    hNclsVsP->SetStats(kFALSE);
+    if(hNclsVsP->GetEntries()>10) {
+      hNclsVsP->Draw("samecolz"); isGoodForSaving=kTRUE;
+      if(trendValues) {
+        TProfile* h2FProf = hNclsVsP->ProfileX("nclsVsPprof");
+        h2FProf->Fit(funcConst, "QME0", "goff", 1.0, 3.0);
+        trendValues[4] = funcConst->GetParameter(0);
+        trendValues[5] = funcConst->GetParError(0);
+      }
+    }
+  }
+  
+  delete funcConst;
+  return isGoodForSaving;
+}
+
+
+//_________________________________________________________________
+Bool_t AliTRDcheckESD::PlotPidSummary(Int_t centralityClass, Double_t* trendValues) {
+
+  Bool_t isGoodForSaving=kFALSE;
+  
+  TLatex *lat=new TLatex();
+  lat->SetTextSize(0.07);
+  lat->SetTextColor(2);
+  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.001);
+  gPad->SetLeftMargin(0.001); gPad->SetRightMargin(0.001);
+  gPad->Divide(3,3,0.,0.);
+  TList* l=gPad->GetListOfPrimitives();
+  // eta-phi distr. for <Qtot> in layer 0
+  TVirtualPad* pad;
+  TProfile2D* hProf2D;
+  if(gROOT->FindObject("rangeEtaPhi2")) delete gROOT->FindObject("rangeEtaPhi2");
+  TH2F* rangeEtaPhi = new TH2F("rangeEtaPhi2", "", 10, -0.99, +0.99, 10, -3.4, +3.4);
+  SetStyle(rangeEtaPhi->GetXaxis(), "#eta", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeEtaPhi->GetYaxis(), "detector #varphi", 0.07, 0.8, kTRUE, 0.05);
+  rangeEtaPhi->SetStats(kFALSE);
+  
+  for(Int_t iLayer=0; iLayer<6; ++iLayer) {
+    pad = ((TVirtualPad*)l->At((iLayer<3 ? iLayer*3 : (iLayer-3)*3+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);
+    rangeEtaPhi->Draw();
+    lat->DrawLatex(-0.9, 3.6, Form("TRD <Q_{tot}> Layer %d", iLayer));
+    
+    if(!(hProf2D = dynamic_cast<TProfile2D*>(fHistos->At(kTRDEtaPhiAvQtot+6*centralityClass+iLayer)))) continue;
+    if(hProf2D && hProf2D->GetEntries()>10) {
+      hProf2D->SetStats(kFALSE);
+      hProf2D->SetMinimum(0.);
+      hProf2D->SetMaximum(4.);
+      if(hProf2D->GetEntries()>10) { hProf2D->Draw("samecolz"); isGoodForSaving=kTRUE; }
+    }
+  }
+    
+  // 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);
+  if(gROOT->FindObject("rangePHslice")) delete gROOT->FindObject("rangePHslice");
+  TH2F* rangePHslice = new TH2F("rangePHslice", "", 10, -0.5, 7.5, 10, 0.0, 2000.0);
+  SetStyle(rangePHslice->GetXaxis(), "slice", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangePHslice->GetYaxis(), "PH", 0.07, 0.8, kTRUE, 0.05);
+  rangePHslice->SetStats(kFALSE);
+  rangePHslice->Draw();
+  
+  TF1* funcPol1 = new TF1("funcPol1", "[0]+[1]*x", 2.9, 6.4);
+  
+  TH2F* h2F;
+  TH1D* hF;
+  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kPHSlice+centralityClass)))) {
+    if(h2F && h2F->GetEntries()>10) {
+      hF = Proj2D(h2F);
+      h2F->SetStats(kFALSE);
+      h2F->Draw("samecolz");
+      isGoodForSaving=kTRUE;
+      if(trendValues) {
+        hF->Fit(funcPol1, "QME0", "goff", 2.9, 6.4);
+        trendValues[6] = funcPol1->GetParameter(0);
+        trendValues[7] = funcPol1->GetParError(0);
+        trendValues[8] = funcPol1->GetParameter(1);
+        trendValues[9] = funcPol1->GetParError(1);
+      }
+      hF->SetLineWidth(2);
+      hF->Draw("same");
+    }
+  }
+  delete funcPol1;
+
+  // 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();
+  if(gROOT->FindObject("rangeQtotP")) delete gROOT->FindObject("rangeQtotP");
+  TH2F* rangeQtotP = new TH2F("rangeQtotP", "", 10, 0.0, 11.99, 10, 0.0, 11.99);
+  SetStyle(rangeQtotP->GetXaxis(), "P [GeV/c]", 0.07, 0.8, kTRUE, 0.05);
+  SetStyle(rangeQtotP->GetYaxis(), "Q_{tot}", 0.07, 0.8, kTRUE, 0.05);
+  rangeQtotP->SetStats(kFALSE);
+  rangeQtotP->Draw();
+  
+  if((h2F = dynamic_cast<TH2F*>(fHistos->At(kQtotP+centralityClass)))) {
+    if(h2F && h2F->GetEntries()>10) {
+      h2F->SetStats(kFALSE);
+      h2F->Draw("samecolz");
+      isGoodForSaving=kTRUE;
+      hF = Proj2D(h2F);
+      hF->SetLineWidth(2);
+      hF->Draw("same");
+      if(trendValues) {
+        trendValues[10] = hF->GetBinContent(hF->FindBin(1.0));
+        trendValues[11] = hF->GetBinError(hF->FindBin(1.0));
+      }
+    }
+  }
+  return isGoodForSaving;
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::DrawTRDGrid() {
+  //
+  //   Draw a grid of lines showing the TRD supermodule and stack structure in (eta,phi) coordinates.
+  //   The canvas on which to draw must already exist.
+  //
+  TLine line;
+  line.SetLineColor(2);
+  line.SetLineWidth(1);
+  line.SetLineStyle(2);
+  for(Int_t i=0; i<=9; ++i) {
+    line.DrawLine(-1.0, 2.0*TMath::Pi()/18.0*i, +1.0, 2.0*TMath::Pi()/18.0*i);
+    line.DrawLine(-1.0, -2.0*TMath::Pi()/18.0*i, +1.0, -2.0*TMath::Pi()/18.0*i);
+  }
+  line.DrawLine(-0.85, -3.2, -0.85, +3.2);
+  line.DrawLine(-0.54, -3.2, -0.54, +3.2);
+  line.DrawLine(-0.16, -3.2, -0.16, +3.2);
+  line.DrawLine(+0.16, -3.2, +0.16, +3.2);
+  line.DrawLine(+0.54, -3.2, +0.54, +3.2);
+  line.DrawLine(+0.85, -3.2, +0.85, +3.2);
+}
+
+//_________________________________________________________________
+void AliTRDcheckESD::SetStyle(TH1* hist, 
+                             Int_t lineStyle, Int_t lineColor, Int_t lineWidth, 
+                             Int_t markerStyle, Int_t markerColor, Int_t markerSize) {
+  //
+  // Set style settings for histograms
+  //
+  if(!hist) return;
+  hist->SetLineStyle(lineStyle);
+  hist->SetLineColor(lineColor);
+  hist->SetLineWidth(lineWidth);
+  hist->SetMarkerStyle(markerStyle);
+  hist->SetMarkerColor(markerColor);
+  hist->SetMarkerSize(markerSize);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, 
+                              Float_t labelSize) {
+  //
+  // Set style settings for axes
+  //
+  if(!axis) return;
+  axis->SetTitle(title);
+  axis->SetTitleSize(titleSize);
+  axis->SetTitleOffset(titleOffset); 
+  axis->CenterTitle(centerTitle);
+  axis->SetLabelSize(labelSize);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]) {
+  //
+  // Find the isolated bunch crossings
+  //
+  Int_t isolationSize = 5;      // number of free bunches in both directions
+  for(Int_t bcBin=1; bcBin<=bcHist->GetXaxis()->GetNbins(); ++bcBin) {
+    Int_t bc = TMath::Nint(bcHist->GetBinCenter(bcBin));
+    if(bc<-0.001 || bc>3499.01) {
+      isIsolated[bc] = kFALSE;
+      continue;
+    }
+    Double_t entries = bcHist->GetBinContent(bcBin);
+    if(entries<0.001) {
+      isIsolated[bc] = kFALSE;
+      continue;     // no entries
+    }
+        
+    // check isolation
+    isIsolated[bc] = kTRUE;
+    for(Int_t ibc = TMath::Max(1,bcBin-isolationSize); ibc<=TMath::Min(3499, bcBin+isolationSize); ++ibc) {
+      if(ibc==bcBin) continue;
+      if(bcHist->GetBinContent(ibc)>0.01) {
+        isIsolated[bc] = kFALSE;
+        break;
+      }
+    }
+  }   // end loop over BC bins
+  
+  cout << "Isolated bunches: " << endl;
+  for(Int_t ibc=0; ibc<3500; ++ibc) 
+    if(isIsolated[ibc]) cout << "BC #" << ibc << endl; 
+}
+
+
+//__________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetTriggerIndex(const Char_t* name, Bool_t createNew/*=kTRUE*/) {
+  //
+  //  Return the index of trigger "name" in the trigger histogram.
+  //  If the index for this trigger does not exist yet, then assign one if createNew is set to TRUE 
+  //
+  //cout << "GetTriggerIndex for " << name << endl;
+  TH1F* triggerHist = (TH1F*)fHistos->At(kTriggerDefs);
+  TString nameStr=name;
+  for(Int_t i=1; i<=triggerHist->GetXaxis()->GetNbins(); ++i) {
+    if(!nameStr.CompareTo(triggerHist->GetXaxis()->GetBinLabel(i))) {
+      //cout << "       index found: " << i << endl;
+      return i;
+    }
+  }
+  if(createNew) {
+    triggerHist->GetXaxis()->SetBinLabel(fNAssignedTriggers+1, name);
+    if(fMatchingPhiEtaCF->GetVar("trigger")>=0) {
+      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);
+      fMatchingPhiEtaCF->GetAxis(fMatchingPhiEtaCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);
+    }
+    if(fMatchingPtCF->GetVar("trigger")>=0) {
+      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);
+      fMatchingPtCF->GetAxis(fMatchingPtCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);
+    }
+    if(fBunchCrossingsCF->GetVar("trigger")>=0) {
+      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 1)->SetBinLabel(fNAssignedTriggers+1, name);
+      fBunchCrossingsCF->GetAxis(fBunchCrossingsCF->GetVar("trigger"), 2)->SetBinLabel(fNAssignedTriggers+1, name);
+    }
+    if(fCentralityCF->GetVar("trigger")>=0) 
+      fCentralityCF->GetAxis(fCentralityCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+    if(fQtotCF->GetVar("trigger")>=0) 
+      fQtotCF->GetAxis(fQtotCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+    if(fPulseHeightCF->GetVar("trigger")>=0)
+      fPulseHeightCF->GetAxis(fPulseHeightCF->GetVar("trigger"), 0)->SetBinLabel(fNAssignedTriggers+1, name);
+    if(fExpertCF) {
+      if(fExpertCF->GetVar("trigger")>=0)
+        for(Int_t istep=0; istep<fExpertCF->GetNStep(); ++istep) 
+         fExpertCF->GetAxis(fExpertCF->GetVar("trigger"), istep)->SetBinLabel(fNAssignedTriggers+1, name);
+    }
+    
+    ++fNAssignedTriggers;
+    return fNAssignedTriggers+1;
+  }
+  else {
+    return -1;
+  }
+}
+
+//__________________________________________________________________________________________________
+void AliTRDcheckESD::PrintTriggers() const {
+  //
+  //  Print the available triggers for this run
+  //
+  if(!fHistos) {
+    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;
+    return;
+  }
+  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);
+  cout << "Triggers found in this run" << endl;
+  cout << "==========================" << endl;
+  cout << "Name   Index   Entries    " << endl;
+  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {
+    if(hTriggers->GetXaxis()->GetBinLabel(it)[0]!='\0') {
+      cout << hTriggers->GetXaxis()->GetBinLabel(it) << "  " << hTriggers->GetXaxis()->GetBinCenter(it) << "  " << hTriggers->GetBinContent(it) << endl;
+    }
+  }
+}
+
+
+//__________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetTriggerCounter(const Char_t* triggerName) const {
+  //
+  // Get the number of events for a given trigger name
+  //
+  if(!fHistos) {
+    cout << "Warning in AliTRDcheckESD::PrintTriggers(): No file loaded!" << endl;
+    return -1;
+  }
+  TH1F* hTriggers = (TH1F*)fHistos->At(kTriggerDefs);
+  Int_t counter = -1;
+  for(Int_t it=1; it<hTriggers->GetXaxis()->GetNbins(); ++it) {
+    TString trgString = hTriggers->GetXaxis()->GetBinLabel(it);
+    if(!trgString.CompareTo(triggerName)) 
+      counter = (Int_t)hTriggers->GetBinContent(it);
+  }
+  if(counter<0) {cout << "AliTRDcheckESD::GetTriggerCounter()  Trigger not found !!";}
+  return counter;
+}
+
+
+//__________________________________________________________________________________________________________
+Int_t AliTRDcheckESD::GetNAssignedTriggers() {
+  //
+  // Return the number of assigned triggers
+  //
+  return fNAssignedTriggers;
+}
index 62f2ad97e3c3cfd4b5cb72e28c1d6fd80f2a7c33..e5172e8d63df28391cc5ee0a5a89b0d6ef624687 100644 (file)
-#ifndef ALITRDCHECKESD_H\r
-#define ALITRDCHECKESD_H\r
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * See cxx source for full Copyright notice                               */\r
-\r
-/* $Id: AliTRDcheckESD.h 27496 2008-07-22 08:35:45Z cblume $ */\r
-\r
-/////////////////////////////////////////////////////\r
-//\r
-// Check basic detector results at ESD level\r
-//\r
-// Author\r
-//   Alex Bercuci <A.Bercuci@gsi.de>\r
-//\r
-//////////////////////////////////////////////////////\r
-\r
-#ifndef ALIANALYSISTASK_H\r
-#include "AliAnalysisTaskSE.h"\r
-#endif\r
-\r
-class AliESDEvent;\r
-class AliMCEvent;\r
-class AliESDpid;\r
-class AliCFContainer;\r
-class AliAnalysisCuts;\r
-class TH1;\r
-class TH2;\r
-class TH1F;\r
-class TH1D;\r
-class TH2F;\r
-class TH3F;\r
-class TH3;\r
-class TObjArray;\r
-class TGraph;\r
-class TGraphErrors;\r
-class TAxis;\r
-\r
-class AliTRDcheckESD : public AliAnalysisTaskSE {\r
-public:\r
-  enum ETRDcheckESDstatus {\r
-     kMC        = BIT(0)  // use MC info\r
-    ,kCollision = BIT(1)  // \r
-  };\r
-  enum ETRDcheckESDhistos {\r
-    kNCl = 1                // number of clusters per track\r
-   ,kTRDstat                // TRD tracks status\r
-   ,kTRDmom                 // TRD track momentum\r
-   ,kPtRes                  // Pt resolution @ vertex for TRD\r
-   ,kTPCVertex              // event vertex from TPC\r
-   ,kEventVertex            // event vertex\r
-   ,kNTracksAll             // ntracks - all\r
-   ,kNTracksAcc             // ntracks - inside acc. and DCA cut\r
-   ,kNTracksTPC             // additional cut on number of TPC clusters\r
-   ,kDCAxy                  // transverse DCA \r
-   ,kDCAz                   // z - DCA\r
-   ,kPt1                    // Pt distribution, eta and ptmin cuts\r
-   ,kPt2                    // Pt distribution, cuts from kPt1 and DCA cuts\r
-   ,kPt3pos                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for positives (>100)\r
-   ,kPt3neg                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for negatives (>100)\r
-   ,kPt4pos                 // Pt distribution, cuts from kPt3pos and at least one TRD tracklet\r
-   ,kPt4neg                 // Pt distribution, cuts from kPt3neg and at least one TRD tracklet\r
-   ,kTheta                  // distribution of theta for tracks passing the cuts from kPt4pos and kPt4neg\r
-   ,kPhi                    // distribution of phi for tracks passing the cuts from kPt4pos and kPt4neg\r
-   ,kNTPCCl                 // number of TPC clusters, cuts from kPt2\r
-   ,kNTPCCl2                // number of TPC clusters, cuts from kPt2 + pt>1 GeV/c\r
-   ,kTPCDedx                // TPC dE/dx, cuts from kPt3pos or kPt3neg\r
-   ,kEtaPhi                 // (eta,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kEtaNclsTPC             // (TPC_Ncls,eta) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kPhiNclsTPC             // (TPC_Ncls,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg\r
-   ,kSPDMult                // SPD multiplicity\r
-   ,kNTrackletsTRD          // (TRD tracklets per track, P) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kNClsTrackTRD=kNTrackletsTRD+6    // (TRD clusters per track, P) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPHSlice=kNClsTrackTRD+6         // (slicePH,sliceNo) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPHSliceTPCpions=kPHSlice+6      // (slicePH,sliceNo) distribution for TPC pions, after cuts from kPt4pos or kPt4neg \r
-   ,kTPCdedxPions=kPHSliceTPCpions+6     // (TPC dedx,P) for selected TPC pions\r
-   ,kPHSliceTPCelectrons=kTPCdedxPions+6    // (slicePH,sliceNo) distribution for TPC electrons, after cuts from kPt4pos or kPt4neg\r
-   ,kTPCdedxElectrons=kPHSliceTPCelectrons+6   // (TPC dedx,P) for selected TPC electrons\r
-   ,kQtotP=kTPCdedxElectrons+6              // (total Q from slices, momentum) distribution, after cuts from kPt4pos or kPt4neg\r
-   ,kPropagXYvsP=kQtotP+6       // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-   ,kPropagRZvsP            // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)\r
-   ,kTPCRefTracksPos        // (eta,detector phi,Pt) distribution of reference TPC positive tracks (fulfill cuts from kPt3pos)\r
-   ,kTPCRefTracksNeg=kTPCRefTracksPos+6    // (eta,detector phi,Pt) distribution of reference TPC negative tracks (fulfill cuts from kPt3neg)\r
-   ,kTRDRefTracksPos=kTPCRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks (fulfill cuts from kPt4pos)\r
-   ,kTRDRefTracksNeg=kTRDRefTracksPos+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks (fulfill cuts from kPt4neg)\r
-   ,kTRDRefTracksPos4=kTRDRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks with 4 tracklets (fulfill cuts from kPt4pos)\r
-   ,kTRDRefTracksNeg4=kTRDRefTracksPos4+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks with 4 tracklets (fulfill cuts from kPt4neg)\r
-   ,kTRDRefTracksPos5=kTRDRefTracksNeg4+6\r
-   ,kTRDRefTracksNeg5=kTRDRefTracksPos5+6\r
-   ,kTRDRefTracksPos6=kTRDRefTracksNeg5+6\r
-   ,kTRDRefTracksNeg6=kTRDRefTracksPos6+6\r
-   ,kTRDEtaPhiAvNtrkl=kTRDRefTracksNeg6+6       // (eta, detector phi) profile of average number of tracklets\r
-   ,kTRDEtaDeltaPhiAvNtrkl=kTRDEtaPhiAvNtrkl+6  // (eta, delta-phi) profile of average number of tracklets\r
-                                         // delta-phi is the angle made by the track with the normal to the chamber entrance plane\r
-   ,kTRDEtaPhiAvQtot=kTRDEtaDeltaPhiAvNtrkl+6      // (eta, detector phi) profile of total tracklet charge from slices                     \r
-   ,kTriggerDefs=kTRDEtaPhiAvQtot+36\r
-   ,kMatchingPhiEtaCF\r
-   ,kMatchingPtCF\r
-   ,kBunchCrossingsCF\r
-   ,kCentralityCF\r
-   ,kQtotCF\r
-   ,kPulseHeightCF\r
-   ,kExpertCF\r
-   ,kNhistos      // number of histograms\r
-   ,kNrefs   = 4  // number of reference plots\r
-  };\r
-  enum ETrdCfVariables {\r
-    kEventVtxZ=0,\r
-    kEventMult,\r
-    kEventTrigger,\r
-    kEventBC,\r
-    kTrackTOFBC,\r
-    kTrackDCAxy,\r
-    kTrackDCAz,\r
-    kTrackCharge,\r
-    kTrackPhi,\r
-    kTrackEta,\r
-    kTrackPt,\r
-    kTrackP,\r
-    kTrackTrdTracklets,\r
-    kTrackTrdClusters,\r
-    kTrackPHslice,\r
-    kTrackQtot=kTrackPHslice+8,\r
-    kNTrdCfVariables=kTrackQtot+6,\r
-    kNMaxAssignedTriggers = 50\r
-  };\r
-  enum ETRDcheckESDbits {\r
-    kTPCout = 1 // track left TPC\r
-   ,kTRDin      // track reach TRD fiducial volume\r
-   ,kTRDout     // track reconstructed in TRD\r
-   ,kTRDpid     // PID calculated in TRD\r
-   ,kTRDref     // track refitted in TRD\r
-  };\r
-  \r
-  AliTRDcheckESD();\r
-  AliTRDcheckESD(char* name);\r
-  virtual ~AliTRDcheckESD();\r
-  \r
-  void          UserCreateOutputObjects();\r
-  Bool_t        GetRefFigure(Int_t ifig);\r
-  Int_t         GetNRefFigures() const  { return fNRefFigures; } \r
-  void          UserExec(Option_t *);\r
-\r
-  void          SetRefTrackFilter(AliAnalysisCuts* const filter) {fReferenceTrackFilter = filter;}\r
-  \r
-  Bool_t        HasMC() const { return TESTBIT(fStatus, kMC);}\r
-  Bool_t        IsCollision() const {return TESTBIT(fStatus, kCollision);}\r
-  void          SetCollision(Bool_t set=kTRUE) {set ? SETBIT(fStatus, kCollision) : CLRBIT(fStatus, kCollision);}\r
-  TObjArray*    Histos();\r
-  AliCFContainer* GetMatchingPhiEtaCF() const {return fMatchingPhiEtaCF;}\r
-  AliCFContainer* GetMatchingPtCF() const {return fMatchingPtCF;}\r
-  AliCFContainer* GetBunchCrossingsCF() const {return fBunchCrossingsCF;}\r
-  AliCFContainer* GetCentralityCF() const {return fCentralityCF;}\r
-  AliCFContainer* GetQtotCF() const {return fQtotCF;}\r
-  AliCFContainer* GetPulseHeightCF() const {return fPulseHeightCF;}\r
-  AliCFContainer* GetExpertCF() const {return fExpertCF;}\r
-  Int_t         GetTriggerCounter(const Char_t* triggerName) const;\r
-  void          PrintTriggers() const;\r
-  Bool_t        Load(const Char_t *fn="AnalysisResults.root", const Char_t *dir="TRD_Performance", const Char_t *name=NULL);\r
-  void          SetMC(Bool_t mc = kTRUE) { mc ? SETBIT(fStatus, kMC) : CLRBIT(fStatus, kMC);}\r
-  Bool_t        PutTrendValue(const Char_t *name, Double_t val);\r
-  void          Terminate(Option_t *);\r
-  void          MakeSummary(Double_t* trendValues=0x0);\r
-  void          MakeSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="", Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);\r
-  //virtual Long64_t Merge(TCollection* list);\r
-  Int_t         GetNAssignedTriggers();\r
-  void          AddUserTrigger(const Char_t* name) {fUserEnabledTriggers += name; fUserEnabledTriggers += ";";}\r
-  \r
-  // configure the expert CF container\r
-  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, Int_t nbins, Double_t lowLim, Double_t highLim);\r
-  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, const Char_t* bins);\r
-  void          EnableExpertCFStep(Int_t step) {if(step>=0 && step<3) fExpertCFEnabledSteps[step] = kTRUE;}\r
-  \r
-private:\r
-  static const Float_t fgkxTPC; // end radial position of TPC\r
-  static const Float_t fgkxTOF; // start radial position of TOF\r
-  static const UChar_t fgkNgraph[kNrefs]; // number of graphs/ref plot\r
-\r
-  Bool_t PlotTrackingSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);     // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  Bool_t PlotPidSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);          // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  Bool_t PlotCentSummary(Double_t* trendValues=0x0);                                  // centrality dependent plots\r
-\r
-  void PlotTrackingSummaryFromCF(Double_t* trendValues=0x0,\r
-                                const Char_t* triggerName="",\r
-                                 Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);   // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  void PlotPidSummaryFromCF(Double_t* trendValues=0x0,\r
-                           const Char_t* triggerName="",\r
-                            Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);        // 1 <= centralityClass <= 5; 0-all centrality classes together\r
-  void PlotCentSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="",\r
-                             Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);       // centrality dependent plots\r
-  \r
-  AliTRDcheckESD(const AliTRDcheckESD&);\r
-  AliTRDcheckESD& operator=(const AliTRDcheckESD&);\r
-  Int_t         Pdg2Idx(Int_t pdg) const;\r
-  void          Process(TH1 **h, TGraphErrors *g);\r
-  void          Process2D(TH2 * const h, TGraphErrors **g);\r
-  void          PrintStatus(ULong_t s);\r
-  TH2F*         Proj3D(TH3* hist, TH2* accMap, Int_t binLow, Int_t binHigh, Float_t &entries);\r
-  TH1D*         Proj2D(TH2* hist, TH1* fitErr=0x0);\r
-  TH1F*         EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance=kTRUE);\r
-  TH1F*         EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, Int_t stepNom, Int_t stepDenom, const Char_t* varStr="pt", const Char_t* type="TPCTRD");\r
-  void          DrawTRDGrid();\r
-  void          SetStyle(TH1* hist, Int_t lineStyle, Int_t lineColor, Int_t lineWidth, \r
-                         Int_t markerStyle, Int_t markerColor, Int_t markerSize);\r
-  void          SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, \r
-                         Float_t labelSize);\r
-  void          CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]);\r
-  void          FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]);\r
-  void          InitializeCFContainers();\r
-  AliCFContainer* CreateCFContainer(const Char_t* name, const Char_t *title);\r
-  Int_t         GetTriggerIndex(const Char_t* name, Bool_t createNew=kTRUE);\r
-  \r
-  Int_t            fStatus;            // bit mask for controlling the task\r
-  Int_t            fNRefFigures;       // number of current ref plots\r
-  AliESDEvent      *fESD;              //! ESD event\r
-  AliMCEvent       *fMC;               //! MC event\r
-  AliESDpid        *fESDpid;           //  ESD pid object \r
-  TObjArray        *fHistos;           //! QA histos\r
-  TObjArray        *fResults;          // QA graphs\r
-  static FILE      *fgFile;            //! trend file streamer\r
-  \r
-  AliCFContainer*  fExpertCF;          // CF container configured for expert checks\r
-  Int_t            fExpertCFVars[kNTrdCfVariables];\r
-  Bool_t           fExpertCFVarsEnabled[kNTrdCfVariables];\r
-  Int_t            fExpertCFVarNBins[kNTrdCfVariables];\r
-  Double_t         fExpertCFVarRanges[kNTrdCfVariables][2];\r
-  TString          fExpertCFVarBins[kNTrdCfVariables];\r
-  Bool_t           fExpertCFEnabledSteps[3];      // enabled steps 0-TPC; 1-TRD; 2-TOF\r
-  \r
-  AliCFContainer*  fMatchingPhiEtaCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fMatchingPhiEtaCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fMatchingPtCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fMatchingPtCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fBunchCrossingsCF;  //\r
-  Int_t            fBunchCrossingsCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fCentralityCF;        // Small CF containers tuned for running over central QA \r
-  Int_t            fCentralityCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fQtotCF;         //\r
-  Int_t            fQtotCFVars[kNTrdCfVariables];\r
-  AliCFContainer*  fPulseHeightCF;     //\r
-  Int_t            fPulseHeightCFVars[kNTrdCfVariables];\r
-  \r
-  AliAnalysisCuts* fReferenceTrackFilter;     // reference track filter\r
-  Bool_t           fPhysSelTriggersEnabled;   // flag wheter physics selection triggers were enabled\r
-  TString          fUserEnabledTriggers;      // list of user enabled triggers\r
-  Int_t            fNAssignedTriggers;        // number of assigned triggers\r
-    \r
-  // Vertex selection\r
-  static const Float_t fgkEvVertexZ;// cm\r
-  static const Int_t   fgkEvVertexN;// cm\r
-  // Track selection\r
-  static const Float_t fgkTrkDCAxy; // cm\r
-  static const Float_t fgkTrkDCAz;  // cm\r
-  static const Int_t   fgkNclTPC;   // N clusters TPC\r
-  static const Float_t fgkPt;       // min. pt\r
-  static const Float_t fgkEta;      // eta range\r
-  \r
-  static const Float_t fgkQs;      // scale for the total charge\r
-\r
-  ClassDef(AliTRDcheckESD, 9)          // user oriented TRD analysis based on ESD-MC data\r
-};\r
-#endif\r
+#ifndef ALITRDCHECKESD_H
+#define ALITRDCHECKESD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTRDcheckESD.h 27496 2008-07-22 08:35:45Z cblume $ */
+
+/////////////////////////////////////////////////////
+//
+// Check basic detector results at ESD level
+//
+// Author
+//   Alex Bercuci <A.Bercuci@gsi.de>
+//
+//////////////////////////////////////////////////////
+
+#ifndef ALIANALYSISTASK_H
+#include "AliAnalysisTaskSE.h"
+#endif
+
+class AliESDEvent;
+class AliMCEvent;
+class AliESDpid;
+class AliCFContainer;
+class AliAnalysisCuts;
+class TH1;
+class TH2;
+class TH1F;
+class TH1D;
+class TH2F;
+class TH3F;
+class TH3;
+class TObjArray;
+class TGraph;
+class TGraphErrors;
+class TAxis;
+
+class AliTRDcheckESD : public AliAnalysisTaskSE {
+public:
+  enum ETRDcheckESDstatus {
+     kMC        = BIT(0)  // use MC info
+    ,kCollision = BIT(1)  // 
+  };
+  enum ETRDcheckESDhistos {
+    kNCl = 1                // number of clusters per track
+   ,kTRDstat                // TRD tracks status
+   ,kTRDmom                 // TRD track momentum
+   ,kPtRes                  // Pt resolution @ vertex for TRD
+   ,kTPCVertex              // event vertex from TPC
+   ,kEventVertex            // event vertex
+   ,kNTracksAll             // ntracks - all
+   ,kNTracksAcc             // ntracks - inside acc. and DCA cut
+   ,kNTracksTPC             // additional cut on number of TPC clusters
+   ,kDCAxy                  // transverse DCA 
+   ,kDCAz                   // z - DCA
+   ,kPt1                    // Pt distribution, eta and ptmin cuts
+   ,kPt2                    // Pt distribution, cuts from kPt1 and DCA cuts
+   ,kPt3pos                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for positives (>100)
+   ,kPt3neg                 // Pt distribution, cuts from kPt2 and cut on TPC clusters for negatives (>100)
+   ,kPt4pos                 // Pt distribution, cuts from kPt3pos and at least one TRD tracklet
+   ,kPt4neg                 // Pt distribution, cuts from kPt3neg and at least one TRD tracklet
+   ,kTheta                  // distribution of theta for tracks passing the cuts from kPt4pos and kPt4neg
+   ,kPhi                    // distribution of phi for tracks passing the cuts from kPt4pos and kPt4neg
+   ,kNTPCCl                 // number of TPC clusters, cuts from kPt2
+   ,kNTPCCl2                // number of TPC clusters, cuts from kPt2 + pt>1 GeV/c
+   ,kTPCDedx                // TPC dE/dx, cuts from kPt3pos or kPt3neg
+   ,kEtaPhi                 // (eta,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg
+   ,kEtaNclsTPC             // (TPC_Ncls,eta) distrib. for tracks after the cuts from kPt3pos or kPt3neg
+   ,kPhiNclsTPC             // (TPC_Ncls,phi) distrib. for tracks after the cuts from kPt3pos or kPt3neg
+   ,kSPDMult                // SPD multiplicity
+   ,kNTrackletsTRD          // (TRD tracklets per track, P) distribution, after cuts from kPt4pos or kPt4neg
+   ,kNClsTrackTRD=kNTrackletsTRD+6    // (TRD clusters per track, P) distribution, after cuts from kPt4pos or kPt4neg
+   ,kPHSlice=kNClsTrackTRD+6         // (slicePH,sliceNo) distribution, after cuts from kPt4pos or kPt4neg
+   ,kPHSliceTPCpions=kPHSlice+6      // (slicePH,sliceNo) distribution for TPC pions, after cuts from kPt4pos or kPt4neg 
+   ,kTPCdedxPions=kPHSliceTPCpions+6     // (TPC dedx,P) for selected TPC pions
+   ,kPHSliceTPCelectrons=kTPCdedxPions+6    // (slicePH,sliceNo) distribution for TPC electrons, after cuts from kPt4pos or kPt4neg
+   ,kTPCdedxElectrons=kPHSliceTPCelectrons+6   // (TPC dedx,P) for selected TPC electrons
+   ,kQtotP=kTPCdedxElectrons+6              // (total Q from slices, momentum) distribution, after cuts from kPt4pos or kPt4neg
+   ,kPropagXYvsP=kQtotP+6       // (X,Y,momentum) distribution after AliESDtrack::PropagateTo(r=300.)
+   ,kPropagRZvsP            // (R,Z,momentum) distribution after AliESDtrack::PropagateTo(r=300.)
+   ,kTPCRefTracksPos        // (eta,detector phi,Pt) distribution of reference TPC positive tracks (fulfill cuts from kPt3pos)
+   ,kTPCRefTracksNeg=kTPCRefTracksPos+6    // (eta,detector phi,Pt) distribution of reference TPC negative tracks (fulfill cuts from kPt3neg)
+   ,kTRDRefTracksPos=kTPCRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks (fulfill cuts from kPt4pos)
+   ,kTRDRefTracksNeg=kTRDRefTracksPos+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks (fulfill cuts from kPt4neg)
+   ,kTRDRefTracksPos4=kTRDRefTracksNeg+6        // (eta,detector phi,Pt) distribution of reference TRD positive tracks with 4 tracklets (fulfill cuts from kPt4pos)
+   ,kTRDRefTracksNeg4=kTRDRefTracksPos4+6        // (eta,detector phi,Pt) distribution of reference TRD negative tracks with 4 tracklets (fulfill cuts from kPt4neg)
+   ,kTRDRefTracksPos5=kTRDRefTracksNeg4+6
+   ,kTRDRefTracksNeg5=kTRDRefTracksPos5+6
+   ,kTRDRefTracksPos6=kTRDRefTracksNeg5+6
+   ,kTRDRefTracksNeg6=kTRDRefTracksPos6+6
+   ,kTRDEtaPhiAvNtrkl=kTRDRefTracksNeg6+6       // (eta, detector phi) profile of average number of tracklets
+   ,kTRDEtaDeltaPhiAvNtrkl=kTRDEtaPhiAvNtrkl+6  // (eta, delta-phi) profile of average number of tracklets
+                                         // delta-phi is the angle made by the track with the normal to the chamber entrance plane
+   ,kTRDEtaPhiAvQtot=kTRDEtaDeltaPhiAvNtrkl+6      // (eta, detector phi) profile of total tracklet charge from slices                     
+   ,kTriggerDefs=kTRDEtaPhiAvQtot+36
+   ,kMatchingPhiEtaCF
+   ,kMatchingPtCF
+   ,kBunchCrossingsCF
+   ,kCentralityCF
+   ,kQtotCF
+   ,kPulseHeightCF
+   ,kExpertCF
+   ,kNhistos      // number of histograms
+   ,kNrefs   = 4  // number of reference plots
+  };
+  enum ETrdCfVariables {
+    kEventVtxZ=0,
+    kEventMult,
+    kEventTrigger,
+    kEventBC,
+    kTrackTOFBC,
+    kTrackDCAxy,
+    kTrackDCAz,
+    kTrackCharge,
+    kTrackPhi,
+    kTrackEta,
+    kTrackPt,
+    kTrackP,
+    kTrackTrdTracklets,
+    kTrackTrdClusters,
+    kTrackPHslice,
+    kTrackQtot=kTrackPHslice+8,
+    kNTrdCfVariables=kTrackQtot+6,
+    kNMaxAssignedTriggers = 100
+  };
+  enum ETRDcheckESDbits {
+    kTPCout = 1 // track left TPC
+   ,kTRDin      // track reach TRD fiducial volume
+   ,kTRDout     // track reconstructed in TRD
+   ,kTRDpid     // PID calculated in TRD
+   ,kTRDref     // track refitted in TRD
+  };
+  
+  AliTRDcheckESD();
+  AliTRDcheckESD(char* name);
+  virtual ~AliTRDcheckESD();
+  
+  void          UserCreateOutputObjects();
+  Bool_t        GetRefFigure(Int_t ifig);
+  Int_t         GetNRefFigures() const  { return fNRefFigures; } 
+  void          UserExec(Option_t *);
+
+  void          SetRefTrackFilter(AliAnalysisCuts* const filter) {fReferenceTrackFilter = filter;}
+  
+  Bool_t        HasMC() const { return TESTBIT(fStatus, kMC);}
+  Bool_t        IsCollision() const {return TESTBIT(fStatus, kCollision);}
+  void          SetCollision(Bool_t set=kTRUE) {set ? SETBIT(fStatus, kCollision) : CLRBIT(fStatus, kCollision);}
+  TObjArray*    Histos();
+  AliCFContainer* GetMatchingPhiEtaCF() const {return fMatchingPhiEtaCF;}
+  AliCFContainer* GetMatchingPtCF() const {return fMatchingPtCF;}
+  AliCFContainer* GetBunchCrossingsCF() const {return fBunchCrossingsCF;}
+  AliCFContainer* GetCentralityCF() const {return fCentralityCF;}
+  AliCFContainer* GetQtotCF() const {return fQtotCF;}
+  AliCFContainer* GetPulseHeightCF() const {return fPulseHeightCF;}
+  AliCFContainer* GetExpertCF() const {return fExpertCF;}
+  Int_t         GetTriggerCounter(const Char_t* triggerName) const;
+  void          PrintTriggers() const;
+  Bool_t        Load(const Char_t *fn="AnalysisResults.root", const Char_t *dir="TRD_Performance", const Char_t *name=NULL);
+  void          SetMC(Bool_t mc = kTRUE) { mc ? SETBIT(fStatus, kMC) : CLRBIT(fStatus, kMC);}
+  Bool_t        PutTrendValue(const Char_t *name, Double_t val);
+  void          Terminate(Option_t *);
+  void          MakeSummary(Double_t* trendValues=0x0);
+  void          MakeSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="", Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);
+  //virtual Long64_t Merge(TCollection* list);
+  Int_t         GetNAssignedTriggers();
+  void          AddUserTrigger(const Char_t* name) {fUserEnabledTriggers += name; fUserEnabledTriggers += ";";}
+  
+  // configure the expert CF container
+  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, Int_t nbins, Double_t lowLim, Double_t highLim);
+  void          AddExpertCFVar(AliTRDcheckESD::ETrdCfVariables var, const Char_t* bins);
+  void          EnableExpertCFStep(Int_t step) {if(step>=0 && step<3) fExpertCFEnabledSteps[step] = kTRUE;}
+  
+private:
+  static const Float_t fgkxTPC; // end radial position of TPC
+  static const Float_t fgkxTOF; // start radial position of TOF
+  static const UChar_t fgkNgraph[kNrefs]; // number of graphs/ref plot
+
+  Bool_t PlotTrackingSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);     // 1 <= centralityClass <= 5; 0-all centrality classes together
+  Bool_t PlotPidSummary(Int_t centralityClass=1, Double_t* trendValues=0x0);          // 1 <= centralityClass <= 5; 0-all centrality classes together
+  Bool_t PlotCentSummary(Double_t* trendValues=0x0);                                  // centrality dependent plots
+
+  void PlotTrackingSummaryFromCF(Double_t* trendValues=0x0,
+                                const Char_t* triggerName="",
+                                 Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);   // 1 <= centralityClass <= 5; 0-all centrality classes together
+  void PlotPidSummaryFromCF(Double_t* trendValues=0x0,
+                           const Char_t* triggerName="",
+                            Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);        // 1 <= centralityClass <= 5; 0-all centrality classes together
+  void PlotCentSummaryFromCF(Double_t* trendValues=0x0, const Char_t* triggerName="",
+                             Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE);       // centrality dependent plots
+  
+  AliTRDcheckESD(const AliTRDcheckESD&);
+  AliTRDcheckESD& operator=(const AliTRDcheckESD&);
+  Int_t         Pdg2Idx(Int_t pdg) const;
+  void          Process(TH1 **h, TGraphErrors *g);
+  void          Process2D(TH2 * const h, TGraphErrors **g);
+  void          PrintStatus(ULong_t s);
+  TH2F*         Proj3D(TH3* hist, TH2* accMap, Int_t binLow, Int_t binHigh, Float_t &entries);
+  TH1D*         Proj2D(TH2* hist, TH1* fitErr=0x0);
+  TH1F*         EfficiencyTRD(TH3* tpc3D, TH3* trd3D, Bool_t useAcceptance=kTRUE);
+  TH1F*         EfficiencyFromPhiPt(AliCFContainer* cf, Int_t minNtrkl, Int_t maxNtrkl, Int_t stepNom, Int_t stepDenom, const Char_t* varStr="pt", const Char_t* type="TPCTRD");
+  void          DrawTRDGrid();
+  void          SetStyle(TH1* hist, Int_t lineStyle, Int_t lineColor, Int_t lineWidth, 
+                         Int_t markerStyle, Int_t markerColor, Int_t markerSize);
+  void          SetStyle(TAxis* axis, const Char_t* title, Float_t titleSize, Float_t titleOffset, Bool_t centerTitle, 
+                         Float_t labelSize);
+  void          CheckActiveSM(TH1D* phiProj, Bool_t activeSM[18]);
+  void          FindIsolatedBCs(TH1D* bcHist, Bool_t isIsolated[3500]);
+  void          InitializeCFContainers();
+  AliCFContainer* CreateCFContainer(const Char_t* name, const Char_t *title);
+  Int_t         GetTriggerIndex(const Char_t* name, Bool_t createNew=kTRUE);
+  
+  Int_t            fStatus;            // bit mask for controlling the task
+  Int_t            fNRefFigures;       // number of current ref plots
+  AliESDEvent      *fESD;              //! ESD event
+  AliMCEvent       *fMC;               //! MC event
+  AliESDpid        *fESDpid;           //  ESD pid object 
+  TObjArray        *fHistos;           //! QA histos
+  TObjArray        *fResults;          // QA graphs
+  static FILE      *fgFile;            //! trend file streamer
+  
+  AliCFContainer*  fExpertCF;          // CF container configured for expert checks
+  Int_t            fExpertCFVars[kNTrdCfVariables];
+  Bool_t           fExpertCFVarsEnabled[kNTrdCfVariables];
+  Int_t            fExpertCFVarNBins[kNTrdCfVariables];
+  Double_t         fExpertCFVarRanges[kNTrdCfVariables][2];
+  TString          fExpertCFVarBins[kNTrdCfVariables];
+  Bool_t           fExpertCFEnabledSteps[3];      // enabled steps 0-TPC; 1-TRD; 2-TOF
+  
+  AliCFContainer*  fMatchingPhiEtaCF;        // Small CF containers tuned for running over central QA 
+  Int_t            fMatchingPhiEtaCFVars[kNTrdCfVariables];
+  AliCFContainer*  fMatchingPtCF;        // Small CF containers tuned for running over central QA 
+  Int_t            fMatchingPtCFVars[kNTrdCfVariables];
+  AliCFContainer*  fBunchCrossingsCF;  //
+  Int_t            fBunchCrossingsCFVars[kNTrdCfVariables];
+  AliCFContainer*  fCentralityCF;        // Small CF containers tuned for running over central QA 
+  Int_t            fCentralityCFVars[kNTrdCfVariables];
+  AliCFContainer*  fQtotCF;         //
+  Int_t            fQtotCFVars[kNTrdCfVariables];
+  AliCFContainer*  fPulseHeightCF;     //
+  Int_t            fPulseHeightCFVars[kNTrdCfVariables];
+  
+  AliAnalysisCuts* fReferenceTrackFilter;     // reference track filter
+  Bool_t           fPhysSelTriggersEnabled;   // flag wheter physics selection triggers were enabled
+  TString          fUserEnabledTriggers;      // list of user enabled triggers
+  Int_t            fNAssignedTriggers;        // number of assigned triggers
+    
+  // Vertex selection
+  static const Float_t fgkEvVertexZ;// cm
+  static const Int_t   fgkEvVertexN;// cm
+  // Track selection
+  static const Float_t fgkTrkDCAxy; // cm
+  static const Float_t fgkTrkDCAz;  // cm
+  static const Int_t   fgkNclTPC;   // N clusters TPC
+  static const Float_t fgkPt;       // min. pt
+  static const Float_t fgkEta;      // eta range
+  
+  static const Float_t fgkQs;      // scale for the total charge
+
+  ClassDef(AliTRDcheckESD, 9)          // user oriented TRD analysis based on ESD-MC data
+};
+#endif
index 7377494e646b58722d1e269b17519ceb1de4415d..f71deb718e311ffb29f07eb1acc011861f43d609 100644 (file)
@@ -1,3 +1,4 @@
+
 #if ! defined (__CINT__) || defined (__MAKECINT__)
 #include "AliLog.h"
 #include "AliAnalysisManager.h"
@@ -12,6 +13,7 @@ AliESDtrackCuts* SetupESDcuts();
 void AddTRDcheckESD(AliAnalysisManager *mgr)
 {
   //AliLog::SetClassDebugLevel("AliTRDcheckESD", 5);
+  //  AliInfo("aaaaaa6666666666");
   AliTRDcheckESD *checkESD = new AliTRDcheckESD((char*)"TRDcheckESD");
   checkESD->SetRefTrackFilter(SetupESDcuts());
   mgr->AddTask(checkESD);
@@ -19,7 +21,11 @@ void AddTRDcheckESD(AliAnalysisManager *mgr)
   checkESD->SetMC(mc);
   checkESD->SetCollision(/*kFALSE*/);
   checkESD->SetDebugLevel(0);
-
+  checkESD->AddUserTrigger("WU");
+  checkESD->AddUserTrigger("QU");
+  checkESD->AddUserTrigger("SE");
+  checkESD->AddUserTrigger("JT");
+  
   mgr->ConnectInput(checkESD,  0, mgr->GetCommonInputContainer());  
   mgr->ConnectOutput(checkESD, 1, mgr->CreateContainer(checkESD->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("%s:TRD_Performance",mgr->GetCommonFileName())));
 }
@@ -34,6 +40,8 @@ AliESDtrackCuts* SetupESDcuts() {
   esdCuts->SetMaxDCAToVertexXY(1.);
   esdCuts->SetMaxDCAToVertexZ(3.);
   esdCuts->SetMinNClustersTPC(70);
+  esdCuts->SetRequireITSRefit(kTRUE);
+  //esdCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
   return esdCuts;
 }