- bunch crossing selection in PWG1/TRD
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 21 Jul 2011 11:22:50 +0000 (11:22 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 21 Jul 2011 11:22:50 +0000 (11:22 +0000)
- move TRDresolution task from TH3 to THnSparse -  development ongoing
- summary plots from TRDresolution available
- new calibration task TRDcheckTRK used for testing during PWG1
  - cluster position reconstruction
  - track propagation in TRD
  - etc

18 files changed:
PWG1/PWG1LinkDef.h
PWG1/TRD/AliTRDcheckTRK.cxx [new file with mode: 0644]
PWG1/TRD/AliTRDcheckTRK.h [new file with mode: 0644]
PWG1/TRD/AliTRDinfoGen.cxx
PWG1/TRD/AliTRDinfoGen.h
PWG1/TRD/AliTRDpwg1Helper.cxx
PWG1/TRD/AliTRDpwg1Helper.h
PWG1/TRD/AliTRDrecoTask.cxx
PWG1/TRD/AliTRDrecoTask.h
PWG1/TRD/AliTRDresolution.cxx
PWG1/TRD/AliTRDresolution.h
PWG1/TRD/info/AliTRDclusterInfo.cxx
PWG1/TRD/info/AliTRDclusterInfo.h
PWG1/TRD/info/AliTRDtrackInfo.cxx
PWG1/TRD/info/AliTRDtrackInfo.h
PWG1/TRD/macros/AddTRDcheckTRK.C [new file with mode: 0644]
PWG1/TRD/macros/AddTRDresolution.C
PWG1/macros/AddTrainPerformanceTRD.C

index 189bc1d..52180e5 100644 (file)
 #pragma link C++ class  AliTRDeventInfo+;
 #pragma link C++ class  AliTRDpidInfo+;
 #pragma link C++ class  AliTRDpidInfo::AliTRDpidData+;
-#pragma link C++ class  AliTRDcheckESD+;
 #pragma link C++ class  AliTRDinfoGen+;
 #pragma link C++ class  AliTRDrecoTask+;
+#pragma link C++ class  AliTRDcheckESD+;
 #pragma link C++ class  AliTRDcheckDET+;
+#pragma link C++ class  AliTRDcheckPID+;
+#pragma link C++ class  AliTRDcheckTRK+;
 #pragma link C++ class  AliTRDresolution+;
 #pragma link C++ class  AliTRDefficiency+;
 #pragma link C++ class  AliTRDefficiencyMC+;
-#pragma link C++ class  AliTRDcheckPID+;
 #pragma link C++ class  AliTRDv0Monitor+;
 #pragma link C++ class  AliTRDonlineTrackletFilter;
 #pragma link C++ class  AliTRDonlineTrackletQA;
diff --git a/PWG1/TRD/AliTRDcheckTRK.cxx b/PWG1/TRD/AliTRDcheckTRK.cxx
new file mode 100644 (file)
index 0000000..d8b150c
--- /dev/null
@@ -0,0 +1,431 @@
+/**************************************************************************
+* 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-commercialf 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.                  *
+**************************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  TRD tracker systematic                                                //
+//
+//
+//  Authors:                                                              //
+//    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include "TROOT.h"
+#include "TAxis.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+#include "TObjArray.h"
+#include "THnSparse.h"
+#include <TVectorT.h>
+
+#include "AliLog.h"
+
+#include "AliTRDcluster.h"
+#include "AliTRDseedV1.h"
+#include "AliTRDtrackV1.h"
+#include "AliTRDtrackerV1.h"
+#include "AliTRDtransform.h"
+
+#include "AliTRDcheckTRK.h"
+
+ClassImp(AliTRDcheckTRK)
+
+Bool_t  AliTRDcheckTRK::fgKalmanUpdate = kTRUE;
+Bool_t  AliTRDcheckTRK::fgClRecalibrate = kFALSE;
+Float_t AliTRDcheckTRK::fgKalmanStep = 2.;
+//__________________________________________________________________________
+AliTRDcheckTRK::AliTRDcheckTRK()
+  : AliTRDrecoTask()
+{
+// Default constructor
+  SetNameTitle("TRDtrackerSys", "TRD Tracker Systematic");
+  Float_t pt0(0.2);
+  for(Int_t j(0); j<=kNpt; j++){
+    pt0+=(TMath::Exp(j*j*.002)-1.);
+    fPtBins[j]=pt0;
+  }
+  memset(fProj, 0, 10*sizeof(TH1*));
+}
+
+//__________________________________________________________________________
+AliTRDcheckTRK::AliTRDcheckTRK(char* name)
+  : AliTRDrecoTask(name, "TRD Tracker Systematic")
+{
+// User constructor
+  InitFunctorList();
+  Float_t pt0(0.2);
+  for(Int_t j(0); j<=kNpt; j++){
+    pt0+=(TMath::Exp(j*j*.002)-1.);
+    fPtBins[j]=pt0;
+  }
+  memset(fProj, 0, 10*sizeof(TH1*));
+}
+
+//__________________________________________________________________________
+AliTRDcheckTRK::~AliTRDcheckTRK()
+{
+// Destructor
+}
+
+//__________________________________________________________________________
+Int_t AliTRDcheckTRK::GetPtBin(Float_t pt)
+{
+// Find pt bin according to local pt segmentation
+  Int_t ipt(0);
+  while(ipt<kNpt){
+    if(pt<fPtBins[ipt]) break;
+    ipt++;
+  }
+  return TMath::Max(0,ipt);
+}
+
+//__________________________________________________________________________
+Int_t AliTRDcheckTRK::GetSpeciesByMass(Float_t m)
+{
+// Find particle index by mass
+// 0 electron
+// 1 muon
+// 2 pion
+// 3 kaon
+// 4 proton
+
+  for(Int_t is(0); is<AliPID::kSPECIES; is++) if(TMath::Abs(m-AliPID::ParticleMass(is))<1.e-4) return is;
+  return -1;
+}
+
+
+//__________________________________________________________________________
+Bool_t AliTRDcheckTRK::GetRefFigure(Int_t ifig)
+{
+  switch(ifig){
+  case 0:
+    if(!MakeProjectionEtaPhi()) return kFALSE;
+    break;
+  }
+  return kTRUE;
+}
+
+//__________________________________________________________________________
+TObjArray* AliTRDcheckTRK::Histos()
+{
+  //
+  // Create QA histogram tree
+  //
+
+  if(fContainer) return fContainer;
+
+  THnSparseI *h(NULL);
+  fContainer = new TObjArray(kNclasses);
+  fContainer->SetOwner(kTRUE);
+
+  const Char_t *ccn[kNclasses] = {"Entry", "Propag"};
+  const Char_t *ctt[kNclasses] = {"r-#phi/z/angular residuals @ entry", "r-#phi/z/angular residuals each ly"};
+
+  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+  Int_t   bins[kNdim+1] = {Int_t(kNbunchCross)/*bc*/, 180/*phi*/, 50/*eta*/, Int_t(kNcharge)*AliPID::kSPECIES+1/*chg*species*/, kNpt/*pt*/, 50/*dy*/, 50/*dz*/, 40/*dphi*/, AliTRDgeometry::kNlayer};
+  Double_t min[kNdim+1] = {-0.5, -TMath::Pi(), -1., -AliPID::kSPECIES-0.5, -0.5, -1.5, -2.5, -10., -0.5},
+           max[kNdim+1] = {Int_t(kNbunchCross)-0.5, TMath::Pi(), 1., AliPID::kSPECIES+0.5, kNpt-0.5, 1.5, 2.5, 10., AliTRDgeometry::kNlayer-0.5};
+  Char_t hn[100], ht[700];
+  snprintf(hn, 100, "h%s", ccn[kEntry]);
+  if(!(h = (THnSparseI*)gROOT->FindObject(hn))){
+    snprintf(ht, 700, "%s;bunch cross;#phi [rad];#eta;chg*spec*rc;bin_p_{t};#Deltay [cm];#Deltaz [cm];#Delta#phi [deg];", ctt[kEntry]);
+    h = new THnSparseI(hn, ht, kNdim, bins, min, max);
+  } else h->Reset();
+  fContainer->AddAt(h, kEntry);
+
+  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+  min[5] = -0.15; max[5] = 0.15;
+  snprintf(hn, 100, "h%s", ccn[kPropagation]);
+  if(!(h = (THnSparseI*)gROOT->FindObject(hn))){
+    snprintf(ht, 700, "%s;bunch cross;#phi [rad];#eta;chg*spec*rc;bin_p_{t};#Deltay [cm];#Deltaz [cm];#Delta#phi [deg];layer;", ctt[kPropagation]);
+    h = new THnSparseI(hn, ht, kNdim+1, bins, min, max);
+  } else h->Reset();
+  fContainer->AddAt(h, kPropagation);
+
+  return fContainer;
+}
+
+//__________________________________________________________________________
+TH1* AliTRDcheckTRK::PlotEntry(const AliTRDtrackV1 *track)
+{
+// comment needed
+  if(track) fkTrack = track;
+  if(!fkTrack){
+    AliDebug(4, "No Track defined.");
+    return NULL;
+  }
+  // check container
+  THnSparseI *h=(THnSparseI*)fContainer->At(kEntry);
+  if(!h){
+    AliError(Form("Missing container @ %d", Int_t(kEntry)));
+    return NULL;
+  }
+  // check input track status
+  AliExternalTrackParam *tin(NULL);
+  if(!(tin = fkTrack->GetTrackIn())){
+    AliError("Track did not entered TRD fiducial volume.");
+    return NULL;
+  }
+  // check first tracklet
+  AliTRDseedV1 *fTracklet(fkTrack->GetTracklet(0));
+  if(!fTracklet){
+    AliDebug(3, "No Tracklet in ly[0]. Skip track.");
+    return NULL;
+  }
+  // check radial position
+  Double_t x = tin->GetX();
+  if(TMath::Abs(x-fTracklet->GetX())>1.e-3){
+    AliDebug(1, Form("Tracklet did not match Track. dx[cm]=%+4.1f", x-fTracklet->GetX()));
+    return NULL;
+  }
+
+  Double_t xyz[3];
+  if(!tin->GetXYZ(xyz)){
+    AliDebug(1, "Failed getting global track postion");
+    xyz[0]=x; xyz[1]=0.; xyz[2]=0.;
+  }
+  Float_t mass(fkTrack->GetMass()),
+          eta(tin->Eta()),
+          phi(TMath::ATan2(xyz[1], xyz[0]));
+  Int_t charge(fkTrack->Charge()),
+        species(GetSpeciesByMass(mass)),
+        bc(fkESD->GetTOFbc());
+  const Double_t *parR(tin->GetParameter());
+  Double_t dyt(parR[0] - fTracklet->GetYfit(0)), dzt(parR[1] - fTracklet->GetZfit(0)),
+            phit(fTracklet->GetYfit(1)),
+            tilt(fTracklet->GetTilt());
+
+  // correct for tilt rotation
+  Double_t dy  = dyt - dzt*tilt,
+           dz  = dzt + dyt*tilt;
+  phit       += tilt*parR[3];
+  Double_t dphi = TMath::ASin(parR[2])-TMath::ATan(phit);
+
+  Double_t val[kNdim];
+  val[kBC]          = (bc>=kNbunchCross)?(kNbunchCross-1):bc;
+  val[kPhi]         = phi;
+  val[kEta]         = eta;
+  val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:charge*(species+1);
+  val[kPt]          = GetPtBin(tin->Pt());
+  val[kYrez]        = dy;
+  val[kZrez]        = dz;
+  val[kPrez]        = dphi*TMath::RadToDeg();
+  h->Fill(val);
+  return NULL;
+}
+
+//__________________________________________________________________________
+TH1* AliTRDcheckTRK::PlotPropagation(const AliTRDtrackV1 *track)
+{
+// comment needed
+
+  if(track) fkTrack = track;
+  if(!fkTrack){
+    AliDebug(4, "No Track defined.");
+    return NULL;
+  }
+  // check container
+  THnSparseI *h=(THnSparseI*)fContainer->At(kPropagation);
+  if(!h){
+    AliError(Form("Missing container @ %d", Int_t(kPropagation)));
+    return NULL;
+  }
+  // check input track status
+  AliExternalTrackParam *tin(NULL);
+  if(!(tin = fkTrack->GetTrackIn())){
+    AliError("Track did not entered TRD fiducial volume.");
+    return NULL;
+  }
+  
+  Float_t mass(fkTrack->GetMass());
+  Int_t charge(fkTrack->Charge()),
+        species(GetSpeciesByMass(mass)),
+        bc(fkESD->GetTOFbc()+1);
+  TVectorD dX(AliTRDgeometry::kNlayer),
+           dY(AliTRDgeometry::kNlayer),
+           dZ(AliTRDgeometry::kNlayer),
+           dPhi(AliTRDgeometry::kNlayer),
+           vPt(AliTRDgeometry::kNlayer),
+           vPhi(AliTRDgeometry::kNlayer),
+           vEta(AliTRDgeometry::kNlayer),
+           budget(AliTRDgeometry::kNlayer),
+           cCOV(AliTRDgeometry::kNlayer*15);
+  const Int_t nopt(1000); Char_t opt[nopt];
+
+  // propagation
+  //snprintf(opt, nopt, "");
+
+  AliTRDseedV1 *tr(NULL);
+  Double_t val[kNdim+1];
+  if(PropagateKalman(fkTrack, tin, &dX, &dY, &dZ, &dPhi, &vPt, &vPhi, &vEta, &budget, &cCOV, opt)){
+    val[kBC]=(bc>=kNbunchCross)?(kNbunchCross-1):bc;
+    for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
+      if(dX[ily]<0.) continue;
+      if(!(tr = fkTrack->GetTracklet(ily))) continue;
+      val[kPhi]         = vPhi[ily];
+      val[kEta]         = vEta[ily];
+      val[kSpeciesChgRC]= tr->IsRowCross()?0:charge*(species+1);
+      val[kPt]          = GetPtBin(vPt[ily]);
+      val[kYrez]        = dY[ily];
+      val[kZrez]        = dZ[ily];
+      val[kPrez]        = dPhi[ily]*TMath::RadToDeg();
+      val[kNdim]        = ily;
+      h->Fill(val);
+    }
+  }
+
+  return NULL;
+}
+
+
+//___________________________________________________
+Bool_t AliTRDcheckTRK::PropagateKalman(const AliTRDtrackV1 *t, AliExternalTrackParam *ref, TVectorD *dx, TVectorD *dy, TVectorD *dz, TVectorD *dphi, TVectorD *pt, TVectorD *eta, TVectorD *phi, TVectorD *budget, TVectorD *cov, Option_t */*opt*/)
+{
+// Propagate Kalman from the first TRD tracklet to
+// last one and save residuals in the y, z and pt.
+// The track is intialized from the reference "ref".
+//
+// This is to calibrate the dEdx and MS corrections
+
+  Int_t ntracklets(t->GetNumberOfTracklets());
+  if(!ntracklets) return kFALSE;
+  if(ref->Pt()<1.e-3) return kFALSE;
+
+  AliTRDseedV1 *tr(NULL);
+  for(Int_t itr(AliTRDgeometry::kNlayer); itr--;){
+    (*dx)[itr] = -1.; (*dy)[itr] = 100.; (*dz)[itr] = 100.; (*dphi)[itr] = 100.;
+  }
+
+  // Initialize TRD track to the reference
+  AliTRDtrackV1 tt;
+  tt.Set(ref->GetX(), ref->GetAlpha(), ref->GetParameter(), ref->GetCovariance());
+  tt.SetMass(t->GetMass());
+
+  Double_t x0(ref->GetX()), xyz[3] = {0., 0., 0.};
+  for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
+    if(!(tr = t->GetTracklet(ily))) continue;
+    if(fgClRecalibrate){
+      AliTRDtransform trans(tr->GetDetector());
+      AliTRDcluster *c(NULL);
+      tr->ResetClusterIter(kFALSE);
+      while((c = tr->PrevCluster())) trans.Recalibrate(c, kFALSE);
+      tr->FitRobust();
+    }
+    if(!AliTRDtrackerV1::PropagateToX(tt, tr->GetX0(), fgKalmanStep)) continue;
+    if(fgKalmanUpdate){
+      Double_t x(tr->GetX0()),
+               p[2] = { tr->GetYfit(0), tr->GetZfit(0)},
+               covTrklt[3];
+      tr->GetCovAt(x, covTrklt);
+      if(!((AliExternalTrackParam&)tt).Update(p, covTrklt)) continue;
+    }
+    if(!tt.GetXYZ(xyz)) continue;
+    (*phi)[ily] = TMath::ATan2(xyz[1], xyz[0]);
+    (*eta)[ily] = tt.Eta();
+    (*dx)[ily]  = tt.GetX() - x0;
+    (*pt)[ily]  = tt.Pt();
+    if(budget) (*budget)[ily] = tt.GetBudget(0);
+    if(cov){
+      const Double_t *cc(tt.GetCovariance());
+      for(Int_t ic(0), jp(ily*15); ic<15; ic++, jp++) (*cov)[jp]=cc[ic];
+    }
+    const Double_t *parR(tt.GetParameter());
+    Double_t dyt(parR[0] - tr->GetYfit(0)), dzt(parR[1] - tr->GetZfit(0)),
+             dydx(tr->GetYfit(1)),
+             tilt(tr->GetTilt());
+    // correct for tilt rotation
+    (*dy)[ily]  = dyt - dzt*tilt;
+    (*dz)[ily]  = dzt + dyt*tilt;
+    dydx       += tilt*parR[3];
+    (*dphi)[ily]= TMath::ASin(parR[2])-TMath::ATan(dydx);
+  }
+  return kTRUE;
+}
+
+
+//__________________________________________________________________________
+Bool_t AliTRDcheckTRK::MakeProjectionEtaPhi()
+{
+// Get dy residual projection as a function of eta and phi
+
+  if(fProj[0] && fProj[1]) return kTRUE;
+  if(!fContainer || fContainer->GetEntries() != kNclasses){
+    AliError("Missing/Wrong data container.");
+    return kFALSE;
+  }
+  THnSparse *H(NULL);
+  if(!(H = (THnSparse*)fContainer->At(kEntry))){
+    AliError(Form("Missing/Wrong data @ %d.", Int_t(kEntry)));
+    return kFALSE;
+  }
+
+  Int_t  coord[kNdim]; memset(coord, 0, sizeof(Int_t) * kNdim); Double_t v = 0.;
+  TAxis *abc(H->GetAxis(kBC)),
+        *aphi(H->GetAxis(kPhi)),
+        *aeta(H->GetAxis(kEta)),
+        *as(H->GetAxis(kSpeciesChgRC)),
+        *apt(H->GetAxis(kPt)),
+        *ay(H->GetAxis(kYrez)),
+        *az(H->GetAxis(kZrez)),
+        *ap(H->GetAxis(kPrez));
+  Int_t neta(aeta->GetNbins()), nphi(aphi->GetNbins());
+  TH3I *h3[3];
+  h3[0] = new TH3I("h30", Form("r-#phi residuals for neg tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
+  h3[1] = new TH3I("h31", Form("z residuals for row cross;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), az->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            az->GetNbins(), az->GetXmin(), az->GetXmax());
+  h3[2] = new TH3I("h32", Form("r-#phi residuals for pos tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
+  for (Long64_t ib(0); ib < H->GetNbins(); ib++) {
+    v = H->GetBinContent(ib, coord);
+    if(coord[kBC]>1) continue; // bunch cross cut
+    // species selection
+    if(coord[kSpeciesChgRC]<6){
+      h3[0]->AddBinContent(
+        h3[0]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
+    } else if(coord[kSpeciesChgRC]==6) {
+      h3[1]->AddBinContent(
+        h3[1]->GetBin(coord[kEta], coord[kPhi], coord[kZrez]), v);
+    } else if(coord[kSpeciesChgRC]>6) {
+      h3[2]->AddBinContent(
+        h3[2]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
+    }
+  }
+  printf("start Z projection\n");
+  TH2F *h2[3];
+  for(Int_t iproj(0); iproj<3; iproj++){
+    h2[iproj] = new TH2F(Form("h2%d", iproj),
+            Form("%s;%s;%s;%s", h3[iproj]->GetTitle(), aeta->GetTitle(), aphi->GetTitle(), h3[iproj]->GetZaxis()->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax());
+    for(Int_t iphi(1); iphi<=nphi; iphi++){
+      for(Int_t ieta(1); ieta<=neta; ieta++){
+        TH1 *h = h3[iproj]->ProjectionZ(Form("hy%d", iproj), ieta, ieta, iphi, iphi);
+        h2[iproj]->SetBinContent(ieta, iphi, h->GetEntries()>20?h->GetMean():-999.);
+      }
+    }
+  }
+
+  return kTRUE;
+}
diff --git a/PWG1/TRD/AliTRDcheckTRK.h b/PWG1/TRD/AliTRDcheckTRK.h
new file mode 100644 (file)
index 0000000..38226d3
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef ALITRDCHECKTRK_H
+#define ALITRDCHECKTRK_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  TRD tracker systematic                                                //
+//                                                                        //
+//  Authors:                                                              //
+//    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef ALITRDRECOTASK_H
+#include "AliTRDrecoTask.h"
+#endif
+
+template <typename Value> class TVectorT;
+typedef struct TVectorT<Double_t> TVectorD;
+class TH1;
+class TObjArray;
+class AliExternalTrackParam;
+class AliTRDtrackV1;
+class AliTRDcheckTRK : public AliTRDrecoTask
+{
+public:
+  enum ETRDcheckTRKconst {
+     kNbunchCross = 3  // no of classes for bunch crossing
+    ,kNpt         = 24 // no of log bins in pt spectrum
+    ,kNcharge     = 2
+  };
+  enum ETRDcheckTRKclasses {
+     kEntry = 0
+    ,kPropagation
+    ,kNclasses
+  };
+  enum ETRDcheckTRKprojs {
+    kBC    = 0 // bunch cross
+    ,kPhi
+    ,kEta
+    ,kSpeciesChgRC
+    ,kPt
+    ,kYrez
+    ,kZrez
+    ,kPrez
+    ,kNdim  // no of dimensions in the THnSparse
+  };
+  AliTRDcheckTRK();
+  AliTRDcheckTRK(char* name);
+  virtual ~AliTRDcheckTRK();
+  static Float_t  GetKalmanStep()                      { return fgKalmanStep;}
+  Int_t           GetSpeciesByMass(Float_t m);
+  Int_t           GetPtBin(Float_t pt);
+  Bool_t          GetRefFigure(Int_t ifig);
+  static Bool_t   HasClRecalibrate()                   { return fgClRecalibrate;}
+  static Bool_t   HasKalmanUpdate()                    { return fgKalmanUpdate;}
+  TObjArray*      Histos();
+  TH1*            PlotEntry(const AliTRDtrackV1 *t=NULL);
+  TH1*            PlotPropagation(const AliTRDtrackV1 *t=NULL);
+  static Bool_t   PropagateKalman(const AliTRDtrackV1 *t, AliExternalTrackParam *ref,
+                    TVectorD *dx, TVectorD *dy, TVectorD *dz, TVectorD *dphi,
+                    TVectorD *pt, TVectorD *phi, TVectorD *eta,
+                    TVectorD *budget=NULL, TVectorD *c=NULL, Option_t *opt="");
+  static void     SetKalmanStep(Float_t step)          { fgKalmanStep=step;}
+  static void     SetClRecalibrate(Bool_t set=kTRUE)   { fgClRecalibrate=set;}
+  static void     SetKalmanUpdate(Bool_t set=kTRUE)    { fgKalmanUpdate=set;}
+
+private:
+  AliTRDcheckTRK(const AliTRDcheckTRK&);
+  AliTRDcheckTRK& operator=(const AliTRDcheckTRK&);
+  Bool_t          MakeProjectionEtaPhi();
+
+  // kalman related settings
+  static Bool_t  fgKalmanUpdate;  // update Kalman with TRD point
+  static Bool_t  fgClRecalibrate; // recalibrate clusters and recalculate tracklet fit
+  static Float_t fgKalmanStep;    // Kalman stepping
+
+  Double_t       fPtBins[kNpt+1]; // discretization of pt range
+  TH1            *fProj[10];      //! array of histo projections
+
+  ClassDef(AliTRDcheckTRK, 1) // TRD tracker systematic
+};
+
+#endif
\ No newline at end of file
index facf98c..20baad9 100644 (file)
@@ -212,7 +212,7 @@ Bool_t AliTRDinfoGen::GetRefFigure(Int_t)
     AliWarning("Please provide a canvas to draw results.");\r
     return kFALSE;\r
   }\r
-  fContainer->At(0)->Draw("bar");\r
+  fContainer->At(kStatTrk)->Draw("bar");\r
   return kTRUE;\r
 }\r
 \r
@@ -232,7 +232,7 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE);\r
 \r
   // define general monitor\r
-  fContainer = new TObjArray(2); fContainer->SetOwner(kTRUE);\r
+  fContainer = new TObjArray(kNclasses); fContainer->SetOwner(kTRUE);\r
   TH1 *h=new TH1I("hStat", "Run statistics;Observable;Entries", Int_t(kNObjects), -0.5, Float_t(kNObjects)-0.5);\r
   TAxis *ax(h->GetXaxis());\r
   ax->SetBinLabel(Int_t(kTracksESD) + 1, "ESD");\r
@@ -249,14 +249,16 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   ax->SetBinLabel(Int_t(kKinkMC) + 1, "KinkMC");\r
   ax->SetBinLabel(Int_t(kBarrelFriend) + 1, "BFriend");\r
   ax->SetBinLabel(Int_t(kSAFriend) + 1, "SFriend");\r
-  fContainer->AddAt(h, 0);\r
+  fContainer->AddAt(h, kStatTrk);\r
   h=new TH1I("hEv", "Run statistics;Event Class;Entries", 4, -0.5, 3.5);\r
   ax = h->GetXaxis();\r
   ax->SetBinLabel(1, "Low");\r
   ax->SetBinLabel(2, "High");\r
   ax->SetBinLabel(3, "Cosmic");\r
   ax->SetBinLabel(4, "Calib");\r
-  fContainer->AddAt(h, 1);\r
+  fContainer->AddAt(h, kEvType);\r
+  h=new TH1I("hBC", "TOF Bunch Cross statistics;bc index;Entries", 21, -0.5, 20.5);\r
+  fContainer->AddAt(h, kBunchCross);\r
   PostData(AliTRDpwg1Helper::kMonitor, fContainer);\r
 }\r
 \r
@@ -347,8 +349,12 @@ void AliTRDinfoGen::UserExec(Option_t *){
     }\r
     SetInitOCDB();\r
   }\r
+\r
+  AliDebug(2, "+++++++++++++++++++++++++++++++++++++++");\r
+  AliDebug(2, Form("Analyse Ev[%d]", fESDev->GetEventNumberInFile()));\r
+\r
   // set reco param valid for this event\r
-  TH1 *h = (TH1I*)fContainer->At(1);\r
+  TH1 *h = (TH1I*)fContainer->At(kEvType);\r
   if(!fRecos){\r
     fgReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());\r
     h->Fill(0);\r
@@ -358,14 +364,14 @@ void AliTRDinfoGen::UserExec(Option_t *){
       Int_t es(reco->GetEventSpecie());\r
       if(!(es&fESDev->GetEventSpecie())) continue;\r
       fgReconstructor->SetRecoParam(reco);\r
-      if(AliLog::GetDebugLevel("PWG1/TRD", "AliTRDinfoGen")>2) reco->Dump();\r
+      if(AliLog::GetDebugLevel("PWG1/TRD", "AliTRDinfoGen")>5) reco->Dump();\r
       TString s;\r
       if(es&AliRecoParam::kLowMult){ s="LowMult"; h->Fill(0);}\r
       else if(es&AliRecoParam::kHighMult){ s="HighMult"; h->Fill(1);}\r
       else if(es&AliRecoParam::kCosmic){ s="Cosmic"; h->Fill(2);}\r
       else if(es&AliRecoParam::kCalib){ s="Calib"; h->Fill(3);}\r
       else s="Unknown";\r
-      AliDebug(1, Form("Using reco param \"%s\" for event %d.", s.Data(), fESDev->GetEventNumberInFile()));\r
+      AliDebug(2, Form("  Using reco param \"%s\" for event %d.", s.Data(), fESDev->GetEventNumberInFile()));\r
       break;\r
     }\r
   }\r
@@ -422,7 +428,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
   // Determine centrality\r
   // Author: Ionut Arsene <I.C.Arsene@gsi.de>\r
   Int_t centralityBin = -1;\r
-  AliDebug(2, Form("Beam Type: %s", fESDev->GetESDRun()->GetBeamType()));\r
+  AliDebug(2, Form("  Beam Type: %s", fESDev->GetESDRun()->GetBeamType()));\r
   if(TString(fESDev->GetESDRun()->GetBeamType()).Contains("Pb-Pb")){\r
     centralityBin = 4;\r
     const AliMultiplicity *mult = fESDev->GetMultiplicity();\r
@@ -434,9 +440,10 @@ void AliTRDinfoGen::UserExec(Option_t *){
       if(zdcNeutronEnergy>centralitySlopes[iCent-1]*itsNTracklets && zdcNeutronEnergy<centralitySlopes[iCent]*itsNTracklets)\r
         centralityBin=iCent - 1;\r
     }\r
-    AliDebug(1, Form("Centrality Class: %d", centralityBin));\r
+    AliDebug(2, Form("  Centrality Class: %d", centralityBin));\r
   }\r
   fEventInfo->SetCentrality(centralityBin);\r
+  AliDebug(2, Form("  Bunch Crosses: %d", fESDev->GetBunchCrossNumber()));\r
 \r
   Bool_t *trackMap(NULL);\r
   AliStack * mStack(NULL);\r
@@ -486,7 +493,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
   for(Int_t itrk = 0; itrk < nTracksESD; itrk++){\r
     new(fTrackInfo) AliTRDtrackInfo();\r
     esdTrack = fESDev->GetTrack(itrk);\r
-    AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2)));\r
+    AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d] TOF-BC[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2), esdTrack->GetTOFBunchCrossing()));\r
 \r
     if(esdTrack->GetStatus()&AliESDtrack::kTPCout) nTPC++;\r
     if(esdTrack->GetStatus()&AliESDtrack::kTRDout) nTRDout++;\r
@@ -561,6 +568,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
     // some other Informations which we may wish to store in order to find problematic cases\r
     fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0));\r
     fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1)));\r
+    fTrackInfo->SetTOFbc(static_cast<UShort_t>(esdTrack->GetTOFBunchCrossing()));\r
     nclsTrklt = 0;\r
   \r
     // set V0pid info\r
@@ -593,6 +601,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
           while((cl = tracklet->NextCluster())) cl->Use(0);\r
         }\r
         fTrackInfo->SetTrack(track);\r
+        h = (TH1I*)fContainer->At(kBunchCross); h->Fill(esdTrack->GetTOFBunchCrossing());\r
         break;\r
       }\r
       AliDebug(3, Form("Ntracklets[%d]\n", fTrackInfo->GetNTracklets()));\r
@@ -613,30 +622,30 @@ void AliTRDinfoGen::UserExec(Option_t *){
         Bool_t selected(kTRUE);\r
         if(UseLocalTrkSelection()){\r
           if(esdTrack->Pt() < fgkPt){ \r
-            AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Pt[%5.2f]", fESDev->GetEventNumberInFile(), itrk, esdTrack->Pt()));\r
+            AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Pt[%5.2f]", itrk, fESDev->GetEventNumberInFile(), esdTrack->Pt()));\r
             selected = kFALSE;\r
           }\r
           if(selected && TMath::Abs(esdTrack->Eta()) > fgkEta){\r
-            AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Eta[%5.2f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(esdTrack->Eta())));\r
+            AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Eta[%5.2f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(esdTrack->Eta())));\r
             selected = kFALSE;\r
           }\r
           if(selected && esdTrack->GetTPCNcls() < fgkNclTPC){ \r
-            AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] NclTPC[%d]", fESDev->GetEventNumberInFile(), itrk, esdTrack->GetTPCNcls()));\r
+            AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] NclTPC[%d]", itrk, fESDev->GetEventNumberInFile(), esdTrack->GetTPCNcls()));\r
             selected = kFALSE;\r
           }\r
           Float_t par[2], cov[3];\r
           esdTrack->GetImpactParameters(par, cov);\r
           if(IsCollision()){ // cuts on DCA\r
             if(selected && TMath::Abs(par[0]) > fgkTrkDCAxy){ \r
-              AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAxy[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[0])));\r
+              AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAxy[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[0])));\r
               selected = kFALSE;\r
             }\r
             if(selected && TMath::Abs(par[1]) > fgkTrkDCAz){ \r
-              AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAz[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[1])));\r
+              AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAz[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[1])));\r
               selected = kFALSE;\r
             }\r
           } else if(selected && fMCev && !fMCev->IsPhysicalPrimary(alab)){;\r
-            AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Primary", fESDev->GetEventNumberInFile(), itrk));\r
+            AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Primary", itrk, fESDev->GetEventNumberInFile()));\r
             selected = kFALSE;\r
           }\r
         }\r
@@ -728,7 +737,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
     ,nKink, nKinkMC, fTracksKink->GetEntries()\r
   ));\r
   // save track statistics\r
-  h = (TH1I*)fContainer->At(0);\r
+  h = (TH1I*)fContainer->At(kStatTrk);\r
   h->Fill(Float_t(kTracksESD), nTracksESD);\r
   h->Fill(Float_t(kTracksMC), nTracksMC);\r
   h->Fill(Float_t(kV0), fV0List->GetEntries());\r
index 8267199..684edb0 100644 (file)
@@ -39,23 +39,28 @@ public:
    ,kOCDB                 = BIT(22)\r
   };\r
   enum AliTRDinfoGenObjects{\r
-    kTracksESD     =  0\r
-    ,kTracksMC     =  1\r
-    ,kV0           =  2\r
-    ,kTPC          =  3\r
-    ,kTRDin        =  4\r
-    ,kTRDout       =  5\r
-    ,kBarrel       =  6\r
-    ,kBarrelMC     =  7\r
-    ,kSA           =  8\r
-    ,kSAMC         =  9\r
-    ,kKink         = 10\r
-    ,kKinkMC       = 11\r
-    ,kBarrelFriend = 12\r
-    ,kSAFriend     = 13\r
-    ,kNObjects     = 14\r
+     kTracksESD =  0\r
+    ,kTracksMC\r
+    ,kV0\r
+    ,kTPC\r
+    ,kTRDin\r
+    ,kTRDout\r
+    ,kBarrel\r
+    ,kBarrelMC\r
+    ,kSA\r
+    ,kSAMC\r
+    ,kKink\r
+    ,kKinkMC\r
+    ,kBarrelFriend\r
+    ,kSAFriend\r
+    ,kNObjects\r
+  };\r
+  enum AliTRDinfoGenClasses{\r
+     kStatTrk = 0\r
+    ,kEvType\r
+    ,kBunchCross\r
+    ,kNclasses\r
   };\r
-\r
   AliTRDinfoGen();\r
   AliTRDinfoGen(char* name);\r
   virtual ~AliTRDinfoGen();\r
index 8d1e6bc..4d32877 100644 (file)
@@ -7,8 +7,8 @@
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
+#include "TError.h"
 #include <Rtypes.h>
-#include <TError.h>
 #include <TMath.h>
 #include <TObjArray.h>
 #include <TObjString.h>
@@ -31,6 +31,7 @@ const Char_t * AliTRDpwg1Helper::fgkTRDtaskClassName[AliTRDpwg1Helper::kNTRDTASK
   ,"AliTRDresolution"
   ,"AliTRDcheckPID"
   ,"AliTRDv0Monitor"
+  ,"AliTRDcheckTRK"
   ,"AliTRDcalibration"
   ,"AliTRDefficiencyMC"
   ,"AliTRDalignmentTask"
@@ -47,6 +48,7 @@ const Char_t * AliTRDpwg1Helper::fgkTRDtaskOpt[AliTRDpwg1Helper::kNTRDTASKS+1] =
   ,"RES"
   ,"PID"
   ,"V0"
+  ,"TRK"
   ,"CAL"
   ,"EFFC"
   ,"ALGN"
@@ -76,6 +78,7 @@ Int_t AliTRDpwg1Helper::ParseOptions(Char_t *trd)
 //     "PID"  : TRD PID - pion efficiency
 //     "V0"   : monitor V0 performance for use in TRD PID calibration
 // ------- Calibration tasks ----------
+//     "TRK"  : multidimensional tracking performance resolution
 //     "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations
 //     "MULT"  : TRD single track selection
 //     "CLRES": clusters Resolution
@@ -104,10 +107,11 @@ Int_t AliTRDpwg1Helper::ParseOptions(Char_t *trd)
         foundOpt = kTRUE;
         break;
       }
-      if(!foundOpt) Info("ParseOptions()", Form("TRD task %s not implemented (yet).", s.Data()));
+      if(!foundOpt) Warning("AliTRDpwg1Helper::ParseOptions()", Form("TRD task %s not implemented (yet).", s.Data()));
     }
   }
   // extra rules for calibration tasks
+  if(TESTBIT(fSteerTask, kCheckTRK)) SETBIT(fSteerTask, kResolution);
   if(TESTBIT(fSteerTask, kCalibration)) SETBIT(fSteerTask, kCheckDET);
   if(TESTBIT(fSteerTask, kMultiplicity)) SETBIT(fSteerTask, kEfficiency);
   if(TESTBIT(fSteerTask, kEfficiencyMC)) SETBIT(fSteerTask, kEfficiency);
@@ -150,15 +154,15 @@ void AliTRDpwg1Helper::MergeProd(const Char_t *mark, const Char_t *files, const
   }
 
   if(nBatches==1){
-    Info("MergeProd()", "Rename 1 merged file.");
+    Info("AliTRDpwg1Helper::MergeProd()", "Rename 1 merged file.");
     gSystem->Exec(Form("mv merge/%d_%d_%s %s", level, first, mark, mark));
   } else if(nBatches<=nBatch){
-    Info("MergeProd()", Form("Merge %d files in 1 batch.", nBatches));
+    Info("AliTRDpwg1Helper::MergeProd()", Form("Merge %d files in 1 batch.", nBatches));
     if(!gSystem->Exec(Form("aliroot -b -q \'$ALICE_ROOT/PWG1/TRD/macros/mergeBatch.C(\"%s\", \"%s\", %d, 0, kFALSE)\'", mark, lMERGE, nBatches))) return;
     gSystem->Exec(Form("mv 0_%s %s", mark, mark));
   } else {
     level++;
-    Info("MergeProd()", Form("Merge level %d.", level));
+    Info("AliTRDpwg1Helper::MergeProd()", Form("Merge level %d.", level));
     MergeProd(mark, lMERGE, nBatch, level);
   }
   gSystem->Exec(Form("rm -fv %s %s", lMERGE, lPURGE));
@@ -190,16 +194,16 @@ const Char_t* AliTRDpwg1Helper::MergeBatch(const Char_t *mark, const Char_t *fil
     if(kSVN){ // download SVN info for trending
       if(gSystem->Exec(Form("if [ ! -f svnInfo.log ]; then cp -v %s/svnInfo.log %s; fi", Dirname(filename.c_str()), gSystem->ExpandPathName("$PWD"))) == 0) kSVN=kFALSE;
     }
-    Info("MergeBatch()", filename.c_str());
+    Info("AliTRDpwg1Helper::MergeBatch()", filename.c_str());
     if(!fFM.AddFile(filename.c_str())) return NULL;
     arr.Add(new TObjString(filename.c_str()));
     nbatch++;
     if(nbatch==nfiles) break;
   }
   if(!nbatch){
-    Warning("MergeBatch()", "NOTHING TO MERGE"); return NULL;
+    Warning("AliTRDpwg1Helper::MergeBatch()", "NOTHING TO MERGE"); return NULL;
   } else {
-    Info("MergeBatch()", "MERGING FILES[%d] START[%d] %s ... ", nbatch, first, ((nbatch<nfiles)?"INCOMPLETE":""));
+    Info("AliTRDpwg1Helper::MergeBatch()", "MERGING FILES[%d] START[%d] %s ... ", nbatch, first, ((nbatch<nfiles)?"INCOMPLETE":""));
   }
   if(!fFM.Merge()) return NULL;
 
index 1545068..ac7dae0 100644 (file)
@@ -14,33 +14,34 @@ class AliTRDpwg1Helper{
 public:
   enum ETRDinfoGenOutSlots {
     kEventInfo     = 1
-    ,kTracksBarrel  = 2
-    ,kTracksSA      = 3
-    ,kTracksKink    = 4
-    ,kV0List        = 5
-    ,kMonitor       = 6
-    ,kNOutSlots     = 7
+    ,kTracksBarrel
+    ,kTracksSA
+    ,kTracksKink
+    ,kV0List 
+    ,kMonitor
+    ,kNOutSlots
   };
 
   enum ETRDrecoTasks{
-    kCheckESD      = 0
-    ,kInfoGen       = 1
-    ,kCheckDET      = 2
-    ,kEfficiency    = 3
-    ,kResolution    = 4
-    ,kCheckPID      = 5
-    ,kV0Monitor     = 6
-    ,kCalibration   = 7
-    ,kEfficiencyMC  = 8
-    ,kAlignment     = 9
-    ,kPIDRefMaker   =10
-    ,kClErrParam    =11
-    ,kMultiplicity  =12
+    kCheckESD = 0
+    ,kInfoGen
+    ,kCheckDET
+    ,kEfficiency
+    ,kResolution
+    ,kCheckPID
+    ,kV0Monitor
+    ,kCheckTRK
+    ,kCalibration
+    ,kEfficiencyMC
+    ,kAlignment
+    ,kPIDRefMaker
+    ,kClErrParam
+    ,kMultiplicity
   };
 
   enum{
     kNTRDQATASKS = 7,
-    kNTRDCALIBTASKS = 6,
+    kNTRDCALIBTASKS = 7,
     kNTRDTASKS = kNTRDQATASKS + kNTRDCALIBTASKS
   };
 
index eaea05a..060f7f4 100644 (file)
 \r
 #include "AliLog.h"\r
 #include "AliAnalysisTask.h"\r
+#include "AliExternalTrackParam.h"\r
 \r
 #include "info/AliTRDeventInfo.h"\r
 #include "AliTRDrecoTask.h"\r
+#include "AliTRDtrackV1.h"\r
+#include "AliTRDpidUtil.h"\r
 \r
 ClassImp(AliTRDrecoTask)\r
 \r
@@ -47,6 +50,10 @@ AliTRDrecoTask::AliTRDrecoTask()
   ,fkTrack(NULL)\r
   ,fkMC(NULL)\r
   ,fkESD(NULL)\r
+  ,fSpecies(-6)\r
+  ,fPt(-1.)\r
+  ,fPhi(0.)\r
+  ,fEta(0.)\r
   ,fPlotFuncList(NULL)\r
   ,fRunTerminate(kFALSE)\r
 {\r
@@ -64,6 +71,10 @@ AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title)
   ,fkTrack(NULL)\r
   ,fkMC(NULL)\r
   ,fkESD(NULL)\r
+  ,fSpecies(-6)\r
+  ,fPt(-1.)\r
+  ,fPhi(0.)\r
+  ,fEta(0.)\r
   ,fPlotFuncList(NULL)\r
   ,fRunTerminate(kFALSE)\r
 {\r
@@ -147,6 +158,19 @@ void AliTRDrecoTask::UserExec(Option_t *)
     fkTrack = trackInfo->GetTrack();\r
     fkMC    = trackInfo->GetMCinfo();\r
     fkESD   = trackInfo->GetESDinfo();\r
+    // cache properties of the track at TRD entrance\r
+    // check input track status\r
+    AliExternalTrackParam *tin(NULL);\r
+    fPt=-1; fEta=0.; fPhi=0.; fSpecies=-6;\r
+    if(!fkTrack || !(tin = fkTrack->GetTrackIn())) AliDebug(2, "Track did not entered TRD fiducial volume.");\r
+    else {\r
+      fPt   = tin->Pt();\r
+      fEta  = tin->Eta();\r
+      Double_t xyz[3];\r
+      if(!tin->GetXYZ(xyz)) AliDebug(2, "Failed getting global track postion");\r
+      else fPhi  = TMath::ATan2(xyz[1], xyz[0]);\r
+      fSpecies= fkTrack->Charge()*(AliTRDpidUtil::Mass2Pid(fkTrack->GetMass())+1);\r
+    }\r
 \r
     TMethodCall *plot = NULL;\r
     plotIter.Reset();\r
index 8f3fd5d..d684ca8 100644 (file)
@@ -83,9 +83,13 @@ protected:
   TObjArray *fContainer;   //! container to store results\r
   AliTRDeventInfo *fEvent; //! Event Info\r
   TObjArray *fTracks;      //! Array of tracks\r
-  const AliTRDtrackV1    *fkTrack;         //! current track\r
+  const AliTRDtrackV1   *fkTrack;          //! current track\r
   const AliTRDtrackInfo::AliMCinfo  *fkMC; //! MC info\r
   const AliTRDtrackInfo::AliESDinfo *fkESD;//! ESD info\r
+  Char_t                 fSpecies;         //! species index +1 with charge sign\r
+  Float_t                fPt;              //! p_t of the track being analyzed\r
+  Float_t                fPhi;             //! phi of the track being analyzed\r
+  Float_t                fEta;             //! eta of the track being analyzed\r
 \r
 private:\r
   AliTRDrecoTask(const AliTRDrecoTask&);\r
@@ -96,7 +100,7 @@ private:
   static TList      *fgTrendPoint;          //! trend point\r
   static TTreeSRedirector *fgDebugStream;  //! Debug stream \r
 \r
-  ClassDef(AliTRDrecoTask, 3) // base TRD reconstruction task\r
+  ClassDef(AliTRDrecoTask, 4) // base TRD reconstruction task\r
 };\r
 \r
 #endif\r
index 62886b5..d41225d 100644 (file)
 ////////////////////////////////////////////////////////////////////////////
 
 #include <TSystem.h>
-
+#include <TStyle.h>
 #include <TROOT.h>
 #include <TObjArray.h>
 #include <TH3.h>
 #include <TH2.h>
 #include <TH1.h>
+#include <THnSparse.h>
 #include <TF1.h>
 #include <TCanvas.h>
 #include <TGaxis.h>
@@ -78,6 +79,7 @@
 
 #include "AliTRDresolution.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDtransform.h"
 #include "AliTRDpadPlane.h"
 #include "AliTRDcluster.h"
 #include "AliTRDseedV1.h"
 
 ClassImp(AliTRDresolution)
 
-UChar_t const AliTRDresolution::fgNproj[kNviews] = {
-  2, 2, 5, 5, 5,
+Int_t const   AliTRDresolution::fgkNbins[kNdim] = {
+  Int_t(kNbunchCross)/*bc*/,
+  180/*phi*/,
+  50/*eta*/,
+  Int_t(kNcharge)*AliPID::kSPECIES+1/*chg*species*/,
+  kNpt/*pt*/,
+  50/*dy*/,
+  50/*dz*/,
+  40/*dphi*/
+};  //! no of bins/projection
+Double_t const AliTRDresolution::fgkMin[kNdim] = {
+  -0.5,
+  -TMath::Pi(),
+  -1.,
+  -AliPID::kSPECIES-0.5,
+  -0.5,
+  -1.5,
+  -2.5,
+  -10.
+};    //! low limits for projections
+Double_t const AliTRDresolution::fgkMax[kNdim] = {
+  Int_t(kNbunchCross)-0.5,
+  TMath::Pi(),
+  1.,
+  AliPID::kSPECIES+0.5,
+  kNpt-0.5,
+  1.5,
+  2.5,
+  10.
+};    //! high limits for projections
+Char_t const *AliTRDresolution::fgkTitle[kNdim] = {
+  "bunch cross",
+  "#phi [rad]",
+  "#eta",
+  "chg*spec*rc",
+  "bin_p_{t}",
+  "#Deltay [cm]",
+  "#Deltaz [cm]",
+  "#Delta#phi [deg]"
+};  //! title of projection
+
+UChar_t const AliTRDresolution::fgNproj[kNclasses] = {
+  6, 5, 5, 5,
   2, 5, 11, 11, 11
 };
-Char_t const * AliTRDresolution::fgPerformanceName[kNviews] = {
-     "Charge"
-    ,"Cluster2Track"
+Char_t const * AliTRDresolution::fgPerformanceName[kNclasses] = {
+    "Cluster2Track"
     ,"Tracklet2Track"
     ,"Tracklet2TRDin" 
     ,"Tracklet2TRDout" 
@@ -107,74 +149,48 @@ Char_t const * AliTRDresolution::fgPerformanceName[kNviews] = {
     ,"TRDout2MC"
     ,"TRD2MC"
 };
-Char_t const * AliTRDresolution::fgParticle[11]={
-  " p bar", " K -", " #pi -", " #mu -", " e -",
-  " No PID",
-  " e +", " #mu +", " #pi +", " K +", " p",
-};
-
-// Configure segmentation for y resolution/residuals
-Int_t const AliTRDresolution::fgkNresYsegm[3] = {
-  AliTRDgeometry::kNsector
- ,AliTRDgeometry::kNsector*AliTRDgeometry::kNstack
- ,AliTRDgeometry::kNdet
-};
-Char_t const *AliTRDresolution::fgkResYsegmName[3] = {
-  "Sector", "Stack", "Detector"};
-
+Float_t AliTRDresolution::fgPtBin[kNpt+1] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
 
 //________________________________________________________
 AliTRDresolution::AliTRDresolution()
   :AliTRDrecoTask()
-  ,fSegmentLevel(0)
   ,fIdxPlot(0)
   ,fIdxFrame(0)
   ,fPtThreshold(1.)
   ,fDyRange(0.75)
+  ,fProj(NULL)
   ,fDBPDG(NULL)
-  ,fGraphS(NULL)
-  ,fGraphM(NULL)
   ,fCl(NULL)
   ,fMCcl(NULL)
-/*  ,fTrklt(NULL)
-  ,fMCtrklt(NULL)*/
 {
   //
   // Default constructor
   //
   SetNameTitle("TRDresolution", "TRD spatial and momentum resolution");
-  SetSegmentationLevel();
-  memset(fXcorr, 0, AliTRDgeometry::kNdet*30*sizeof(Float_t));
+  MakePtSegmentation();
 }
 
 //________________________________________________________
 AliTRDresolution::AliTRDresolution(char* name)
   :AliTRDrecoTask(name, "TRD spatial and momentum resolution")
-  ,fSegmentLevel(0)
   ,fIdxPlot(0)
   ,fIdxFrame(0)
   ,fPtThreshold(1.)
   ,fDyRange(0.75)
+  ,fProj(NULL)
   ,fDBPDG(NULL)
-  ,fGraphS(NULL)
-  ,fGraphM(NULL)
   ,fCl(NULL)
   ,fMCcl(NULL)
-/*  ,fTrklt(NULL)
-  ,fMCtrklt(NULL)*/
 {
   //
   // Default constructor
   //
 
   InitFunctorList();
-  SetSegmentationLevel();
-  memset(fXcorr, 0, AliTRDgeometry::kNdet*30*sizeof(Float_t));
+  MakePtSegmentation();
 
   DefineOutput(kClToTrk, TObjArray::Class()); // cluster2track
   DefineOutput(kClToMC, TObjArray::Class()); // cluster2mc
-/*  DefineOutput(kTrkltToTrk, TObjArray::Class()); // tracklet2track
-  DefineOutput(kTrkltToMC, TObjArray::Class()); // tracklet2mc*/
 }
 
 //________________________________________________________
@@ -184,12 +200,9 @@ AliTRDresolution::~AliTRDresolution()
   // Destructor
   //
 
-  if(fGraphS){fGraphS->Delete(); delete fGraphS;}
-  if(fGraphM){fGraphM->Delete(); delete fGraphM;}
+  if(fProj){fProj->Delete(); delete fProj;}
   if(fCl){fCl->Delete(); delete fCl;}
   if(fMCcl){fMCcl->Delete(); delete fMCcl;}
-/*  if(fTrklt){fTrklt->Delete(); delete fTrklt;}
-  if(fMCtrklt){fMCtrklt->Delete(); delete fMCtrklt;}*/
 }
 
 
@@ -207,18 +220,10 @@ void AliTRDresolution::InitExchangeContainers()
 {
 // Init containers for subsequent tasks (AliTRDclusterResolution)
 
-  fCl = new TObjArray(200);
-  fCl->SetOwner(kTRUE);
-  fMCcl = new TObjArray();
-  fMCcl->SetOwner(kTRUE);
-/*  fTrklt = new TObjArray();
-  fTrklt->SetOwner(kTRUE);
-  fMCtrklt = new TObjArray();
-  fMCtrklt->SetOwner(kTRUE);*/
+  fCl = new TObjArray(200); fCl->SetOwner(kTRUE);
+  fMCcl = new TObjArray(); fMCcl->SetOwner(kTRUE);
   PostData(kClToTrk, fCl);
   PostData(kClToMC, fMCcl);
-/*  PostData(kTrkltToTrk, fTrklt);
-  PostData(kTrkltToMC, fMCtrklt);*/
 }
 
 //________________________________________________________
@@ -230,7 +235,6 @@ void AliTRDresolution::UserExec(Option_t *opt)
 
   fCl->Delete();
   fMCcl->Delete();
-  if(!HasLoadCorrection()) LoadCorrection("correction.lst");
   AliTRDrecoTask::UserExec(opt);
 }
 
@@ -264,10 +268,10 @@ Bool_t AliTRDresolution::Pulls(Double_t* /*dyz[2]*/, Double_t* /*cov[3]*/, Doubl
 }
 
 //________________________________________________________
-TH1* AliTRDresolution::PlotCharge(const AliTRDtrackV1 *track)
+TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
 {
   //
-  // Plots the charge distribution
+  // Plot the cluster distributions
   //
 
   if(track) fkTrack = track;
@@ -275,168 +279,47 @@ TH1* AliTRDresolution::PlotCharge(const AliTRDtrackV1 *track)
     AliDebug(4, "No Track defined.");
     return NULL;
   }
-  TObjArray *arr = NULL;
-  if(!fContainer || !(arr = ((TObjArray*)fContainer->At(kCharge)))){
-    AliWarning("No output container defined.");
+  if(fkESD->GetTOFbc() > 1){
+    AliDebug(4, Form("Track with BC_index[%d] not used.", fkESD->GetTOFbc()));
     return NULL;
   }
-  TH3S* h = NULL;
-
-  AliTRDseedV1 *fTracklet = NULL;  
-  AliTRDcluster *c = NULL;
-  for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
-    if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
-    if(!fTracklet->IsOK()) continue;
-    Float_t x0 = fTracklet->GetX0();
-    Float_t dqdl, dl;
-    for(Int_t itb=AliTRDseedV1::kNtb; itb--;){
-      if(!(c = fTracklet->GetClusters(itb))){ 
-        if(!(c = fTracklet->GetClusters(AliTRDseedV1::kNtb+itb))) continue;
-      }
-      dqdl = fTracklet->GetdQdl(itb, &dl);
-      if(dqdl<1.e-5) continue;
-      dl /= 0.15; // dl/dl0, dl0 = 1.5 mm for nominal vd
-      (h = (TH3S*)arr->At(0))->Fill(dl, x0-c->GetX(), dqdl);
-    }
-
-//     if(!HasMCdata()) continue;
-//     UChar_t s;
-//     Float_t pt0, y0, z0, dydx0, dzdx0;
-//     if(!fMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, s)) continue;
-
-  }
-  return h;
-}
-
-
-//________________________________________________________
-TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
-{
-  //
-  // Plot the cluster distributions
-  //
-
-  if(track) fkTrack = track;
-  if(!fkTrack){
-    AliDebug(4, "No Track defined.");
+  if(fPt<fPtThreshold){
+    AliDebug(4, Form("Track with pt[%6.4f] under threshold.", fPt));
     return NULL;
   }
-  TObjArray *arr = NULL;
-  if(!fContainer || !(arr = ((TObjArray*)fContainer->At(kCluster)))){
+  THnSparse *H(NULL);
+  if(!fContainer || !(H = ((THnSparse*)fContainer->At(kCluster)))){
     AliWarning("No output container defined.");
     return NULL;
   }
-  ULong_t status = fkESD ? fkESD->GetStatus():0;
-
-  Int_t sgm[3];
-  Double_t covR[7], cov[3], dy[2], dz[2];
-  Float_t pt, x0, y0, z0, dydx, dzdx, tilt(0.);
-  const AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
-  AliTRDseedV1 *fTracklet(NULL);  TObjArray *clInfoArr(NULL);
-  // do LINEAR track refit if asked by the user
-  // it is the user responsibility to check if B=0T
-  Float_t param[10];  memset(param, 0, 10*sizeof(Float_t));
-  Int_t np(0), nrc(0); AliTrackPoint clusters[300];
-  if(HasTrackRefit()){
-    Bool_t kPrimary(kFALSE);
-    for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
-      if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
-      if(!fTracklet->IsOK()) continue;
-      x0   = fTracklet->GetX0();
-      tilt = fTracklet->GetTilt();
-      AliTRDcluster *c = NULL;
-      fTracklet->ResetClusterIter(kFALSE);
-      while((c = fTracklet->PrevCluster())){
-        Float_t xyz[3] = {c->GetX()+fXcorr[c->GetDetector()][c->GetLocalTimeBin()], c->GetY(), c->GetZ()};
-        clusters[np].SetCharge(tilt);
-        clusters[np].SetClusterType(0);
-        clusters[np].SetVolumeID(ily);
-        clusters[np].SetXYZ(xyz);
-        np++;
-      }
-      if(fTracklet->IsRowCross()){
-        Float_t xcross(0.), zcross(0.);
-        if(fTracklet->GetEstimatedCrossPoint(xcross, zcross)){
-          clusters[np].SetCharge(tilt);
-          clusters[np].SetClusterType(1);
-          clusters[np].SetVolumeID(ily);
-          clusters[np].SetXYZ(xcross, 0., zcross);
-          np++;
-          nrc++;
-        }
-      }
-      if(fTracklet->IsPrimary()) kPrimary = kTRUE;
-    }
-    if(kPrimary){
-      clusters[np].SetCharge(tilt);
-      clusters[np].SetClusterType(1);
-      clusters[np].SetVolumeID(-1);
-      clusters[np].SetXYZ(0., 0., 0.);
-      np++;
-    }
-    if(!FitTrack(np, clusters, param)) {
-      AliDebug(1, "Linear track Fit failed.");
-      return NULL;
-    }
-    if(HasTrackSelection()){
-      Bool_t kReject(kFALSE);
-      if(fkTrack->GetNumberOfTracklets() != AliTRDgeometry::kNlayer)  kReject = kTRUE; 
-      if(!kReject && !UseTrack(np, clusters, param)) kReject = kTRUE;
-      if(kReject){
-        AliDebug(1, "Reject track for residuals analysis.");
-        return NULL;
-      }
-    }
-  }
+
+  AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
+  Double_t val[kNdim]; Float_t exb, vd, t0, s2, dl, dt, corr;
+  TObjArray     *clInfoArr(NULL);
+  AliTRDseedV1  *fTracklet(NULL);
+  AliTRDcluster *c(NULL), *cc(NULL);
   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
     if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
     if(!fTracklet->IsOK()) continue;
-    x0 = fTracklet->GetX0();
-    pt = fTracklet->GetPt();
-    sgm[2] = fTracklet->GetDetector();
-    sgm[0] = AliTRDgeometry::GetSector(sgm[2]);
-    sgm[1] = sgm[0] * AliTRDgeometry::kNstack + AliTRDgeometry::GetStack(sgm[2]);
-    
-    // retrive the track angle with the chamber
-    if(HasTrackRefit()){
-      Float_t par[3];
-      if(!FitTracklet(ily, np, clusters, param, par)) continue;
-      dydx = par[2];//param[3];
-      dzdx = param[4];
-      y0   = par[1] + dydx * (x0 - par[0]);//param[1] + dydx * (x0 - param[0]);
-      z0   = param[2] + dzdx * (x0 - param[0]);
-    } else {
-      y0   = fTracklet->GetYfit(0);//fTracklet->GetYref(0);
-      z0   = fTracklet->GetZref(0);
-      dydx = fTracklet->GetYfit(1);//fTracklet->GetYref(1);
-      dzdx = fTracklet->GetZref(1);
-    }
-    /*printf("RC[%c] Primary[%c]\n"
-           "  Fit : y0[%f] z0[%f] dydx[%f] dzdx[%f]\n"
-           "  Ref:  y0[%f] z0[%f] dydx[%f] dzdx[%f]\n", fTracklet->IsRowCross()?'y':'n', fTracklet->IsPrimary()?'y':'n', y0, z0, dydx, dzdx
-           ,fTracklet->GetYref(0),fTracklet->GetZref(0),fTracklet->GetYref(1),fTracklet->GetZref(1));*/
-    tilt = fTracklet->GetTilt();
-    fTracklet->GetCovRef(covR);
-    Double_t t2(tilt*tilt)
-            ,corr(1./(1. + t2))
-            ,cost(TMath::Sqrt(corr));
-    AliTRDcluster *c = NULL;
-    fTracklet->ResetClusterIter(kFALSE);
-    while((c = fTracklet->PrevCluster())){
-      Float_t xc = c->GetX()+fXcorr[c->GetDetector()][c->GetLocalTimeBin()];
-      Float_t yc = c->GetY();
-      Float_t zc = c->GetZ();
-      Float_t dx = x0 - xc; 
-      Float_t yt = y0 - dx*dydx;
-      Float_t zt = z0 - dx*dzdx; 
-      dy[0] = yc-yt; dz[0]= zc-zt;
-
-      // rotate along pad
-      dy[1] = cost*(dy[0] - dz[0]*tilt);
-      dz[1] = cost*(dz[0] + dy[0]*tilt);
-      if(pt>fPtThreshold && c->IsInChamber()) ((TH3S*)arr->At(0))->Fill(fTracklet->GetYref(1), dy[0], sgm[fSegmentLevel]);
-
-      // tilt rotation of covariance for clusters
+    fTracklet->GetCalibParam(exb, vd, t0, s2, dl, dt);
+    val[kBC]  = ily;
+    val[kPhi] = fPhi;
+    val[kEta] = fEta;
+    val[kPt]  = TMath::ATan((fTracklet->GetYref(1) - exb)/(1+fTracklet->GetYref(1)*exb))*TMath::RadToDeg();
+    corr = fkTrack->Charge()/TMath::Sqrt(1.+fTracklet->GetYref(1)*fTracklet->GetYref(1)+fTracklet->GetZref(1)*fTracklet->GetZref(1))/vd;
+    fTracklet->ResetClusterIter(kTRUE);
+    while((c = fTracklet->NextCluster())){
+      Float_t xc(c->GetX());  Int_t tb(c->GetLocalTimeBin());
+
+      val[kYrez] = c->GetY()-fTracklet->GetYat(xc);
+      val[kZrez] = fTracklet->GetX0()-xc;
+      val[kPrez] = 0.; Int_t ic(0);
+      if((cc = fTracklet->GetClusters(tb-1))) {val[kPrez] += cc->GetQ(); ic++;}
+      if((cc = fTracklet->GetClusters(tb-2))) {val[kPrez] += cc->GetQ(); ic++;}
+      if(ic) val[kPrez] /= (ic*c->GetQ());
+      val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:(c->GetQ()*corr);
+      H->Fill(val);
+/*      // tilt rotation of covariance for clusters
       Double_t sy2(c->GetSigmaY2()), sz2(c->GetSigmaZ2());
       cov[0] = (sy2+t2*sz2)*corr;
       cov[1] = tilt*(sz2 - sy2)*corr;
@@ -444,10 +327,11 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
       // sum with track covariance
       cov[0]+=covR[0]; cov[1]+=covR[1]; cov[2]+=covR[2];
       Double_t dyz[2]= {dy[1], dz[1]};
-      Pulls(dyz, cov, tilt);
-      ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
+      Pulls(dyz, cov, tilt);*/
   
       // Get z-position with respect to anode wire
+      Float_t yt(fTracklet->GetYref(0)-val[kZrez]*fTracklet->GetYref(1)),
+              zt(fTracklet->GetZref(0)-val[kZrez]*fTracklet->GetZref(1));
       Int_t istk = geo->GetStack(c->GetDetector());
       AliTRDpadPlane *pp = geo->GetPadPlane(ily, istk);
       Float_t row0 = pp->GetRow0();
@@ -458,12 +342,12 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
       AliTRDclusterInfo *clInfo(NULL);
       clInfo = new AliTRDclusterInfo;
       clInfo->SetCluster(c);
-      Float_t covF[] = {cov[0], cov[1], cov[2]};
-      clInfo->SetGlobalPosition(yt, zt, dydx, dzdx, covF);
-      clInfo->SetResolution(dy[1]);
+      //Float_t covF[] = {cov[0], cov[1], cov[2]};
+      clInfo->SetGlobalPosition(yt, zt, fTracklet->GetYref(1), fTracklet->GetZref(1)/*, covF*/);
+      clInfo->SetResolution(val[kYrez]);
       clInfo->SetAnisochronity(d);
-      clInfo->SetDriftLength(dx);
-      clInfo->SetTilt(tilt);
+      clInfo->SetDriftLength(val[kZrez]);
+      clInfo->SetTilt(fTracklet->GetTilt());
       if(fCl) fCl->Add(clInfo);
       else AliDebug(1, "Cl exchange container missing. Activate by calling \"InitExchangeContainers()\"");
 
@@ -476,6 +360,7 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
       }
     }
     if(DebugLevel()>=1 && clInfoArr){
+      ULong_t status = fkESD->GetStatus();
       (*DebugStream()) << "cluster"
         <<"status="  << status
         <<"clInfo.=" << clInfoArr
@@ -485,7 +370,7 @@ TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
   }
   if(clInfoArr) delete clInfoArr;
 
-  return (TH3S*)arr->At(0);
+  return NULL;//H->Projection(kEta, kPhi);
 }
 
 
@@ -505,91 +390,87 @@ TH1* AliTRDresolution::PlotTracklet(const AliTRDtrackV1 *track)
     AliDebug(4, "No Track defined.");
     return NULL;
   }
-  TObjArray *arr = NULL;
-  if(!fContainer || !(arr = (TObjArray*)fContainer->At(kTrack ))){
+  if(fkESD->GetTOFbc()>1){
+    AliDebug(4, Form("Track with BC_index[%d] not used.", fkESD->GetTOFbc()));
+    return NULL;
+  }
+  THnSparse *H(NULL);
+  if(!fContainer || !(H = (THnSparse*)fContainer->At(kTracklet))){
     AliWarning("No output container defined.");
     return NULL;
   }
 
-  Int_t sgm[3];
-  Double_t cov[3], covR[7]/*, sqr[3], inv[3]*/;
-  Double_t pt, phi, tht, x, y, z, dx, dy[2], dz[2];
-  AliTRDseedV1 *fTracklet(NULL);  
+  Double_t val[kNdim+1];
+  AliTRDseedV1 *fTracklet(NULL);
   for(Int_t il(0); il<AliTRDgeometry::kNlayer; il++){
     if(!(fTracklet = fkTrack->GetTracklet(il))) continue;
     if(!fTracklet->IsOK()) continue;
-    sgm[2] = fTracklet->GetDetector();
-    sgm[0] = AliTRDgeometry::GetSector(sgm[2]);
-    sgm[1] = sgm[0] * AliTRDgeometry::kNstack + AliTRDgeometry::GetStack(sgm[2]);
-    x   = fTracklet->GetX();
-    y   = fTracklet->GetY();
-    z   = fTracklet->GetZ();
-    dx  = fTracklet->GetX0() - x;
-    pt  = fTracklet->GetPt();
-    phi = fTracklet->GetYref(1);
-    tht = fTracklet->GetZref(1);
-    // compute dy and dz
-    dy[0]= fTracklet->GetYref(0)-dx*fTracklet->GetYref(1) - y;
-    dz[0]= fTracklet->GetZref(0)-dx*fTracklet->GetZref(1) - z;
-    Double_t tilt(fTracklet->GetTilt())
-            ,t2(tilt*tilt)
-            ,corr(1./(1. + t2))
-            ,cost(TMath::Sqrt(corr));
-    Bool_t rc(fTracklet->IsRowCross());
-
-    // calculate residuals using tilt rotation
-    dy[1]= cost*(dy[0] - dz[0]*tilt);
-    dz[1]= cost*(dz[0] + dy[0]*tilt);
-    ((TH3S*)arr->At(0))->Fill(phi, dy[1], sgm[fSegmentLevel]+rc*fgkNresYsegm[fSegmentLevel]);
-    if(rc) ((TH2S*)arr->At(2))->Fill(tht, dz[1]);
-
-    // compute covariance matrix
-    fTracklet->GetCovAt(x, cov);
-    fTracklet->GetCovRef(covR);
-    cov[0] += covR[0]; cov[1] += covR[1]; cov[2] += covR[2]; 
-    Double_t dyz[2]= {dy[1], dz[1]};
-    Pulls(dyz, cov, tilt);
-    ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
-    ((TH3S*)arr->At(3))->Fill(tht, dyz[1], rc);
-
-    // calculate angular residuals and correct for tilt
-    Double_t phiTrklt = fTracklet->GetYfit(1);
-    phiTrklt += tilt*tht;
-    Double_t dphi((phi-phiTrklt)/(1-phi*phiTrklt));
-    Double_t dtht((tht-fTracklet->GetZfit(1))/(1-tht*fTracklet->GetZfit(1)));
-    ((TH3S*)arr->At(4))->Fill(phi, TMath::ATan(dphi), sgm[fSegmentLevel]);
+    val [kBC] = il; 
+    val[kPhi] = fPhi;
+    val[kEta] = fEta;
+    val[kSpeciesChgRC]= fSpecies;
+    val[kPt]  = GetPtBin(fTracklet->GetPt());
+    Double_t dyt(fTracklet->GetYref(0) - fTracklet->GetYfit(0)),
+             dzt(fTracklet->GetZref(0) - fTracklet->GetZfit(0)),
+             dydx(fTracklet->GetYfit(1)),
+             tilt(fTracklet->GetTilt());
+    // correct for tilt rotation
+    val[kYrez] = dyt - dzt*tilt;
+    val[kZrez] = dzt + dyt*tilt;
+    dydx+= tilt*fTracklet->GetZref(1);
+    val[kPrez] = TMath::ATan((fTracklet->GetYref(1) - dydx)/(1.+ fTracklet->GetYref(1)*dydx)) * TMath::RadToDeg();
+    if(fTracklet->IsRowCross()){
+      val[kSpeciesChgRC]= 0.;
+      val[kPrez] = fkTrack->Charge(); // may be better defined
+    } else {
+      Float_t exb, vd, t0, s2, dl, dt;
+      fTracklet->GetCalibParam(exb, vd, t0, s2, dl, dt);
+      val[kZrez] = TMath::ATan((fTracklet->GetYref(1) - exb)/(1+fTracklet->GetYref(1)*exb));
+    }
+    val[kNdim] = fTracklet->GetdQdl();
+    H->Fill(val);
+
+//     // compute covariance matrix
+//     fTracklet->GetCovAt(x, cov);
+//     fTracklet->GetCovRef(covR);
+//     cov[0] += covR[0]; cov[1] += covR[1]; cov[2] += covR[2]; 
+//     Double_t dyz[2]= {dy[1], dz[1]};
+//     Pulls(dyz, cov, tilt);
+//     ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
+//     ((TH3S*)arr->At(3))->Fill(tht, dyz[1], rc);
 
     if(DebugLevel()>=1){
+      Bool_t rc(fTracklet->IsRowCross());
       UChar_t err(fTracklet->GetErrorMsg());
-      Double_t yt = fTracklet->GetYref(0),
-               ytx= fTracklet->GetYref(0)-dx*fTracklet->GetYref(1);
-      Int_t ncl = fTracklet->GetN();
+      Double_t x(fTracklet->GetX()),
+               pt(fTracklet->GetPt()),
+               yt(fTracklet->GetYref(0)),
+               zt(fTracklet->GetZref(0)),
+               phi(fTracklet->GetYref(1)),
+               tht(fTracklet->GetZref(1));
+      Int_t ncl(fTracklet->GetN()),
+            det(fTracklet->GetDetector());
       (*DebugStream()) << "tracklet"
         <<"pt="  << pt
+        <<"x="   << x
         <<"yt="  << yt
-        <<"ytx=" << ytx
+        <<"zt="  << zt
         <<"phi=" << phi
         <<"tht=" << tht
-        <<"det=" << sgm[2]
+        <<"det=" << det
         <<"n="   << ncl
-        <<"x="   << x
-        <<"y="   << y
-        <<"z="   << z
-        <<"dx="  << dx
-        <<"dy0=" << dy[0]
-        <<"dz0=" << dz[0]
-        <<"dy="  << dy[1]
-        <<"dz="  << dz[1]
-        <<"dphi="<< dphi
-        <<"dtht="<< dtht
-        <<"dyp=" << dyz[0]
-        <<"dzp=" << dyz[1]
+        <<"dy0=" << dyt
+        <<"dz0=" << dzt
+        <<"dy="  << val[kYrez]
+        <<"dz="  << val[kZrez]
+        <<"dphi="<< val[kPrez]
+        <<"dQ  ="<< val[kNdim]
         <<"rc="  << rc
         <<"err=" << err
         << "\n";
     }
   }
-  return (TH2I*)arr->At(0);
+  return NULL;//H->Projection(kEta, kPhi);
 }
 
 
@@ -606,106 +487,76 @@ TH1* AliTRDresolution::PlotTrackIn(const AliTRDtrackV1 *track)
 // PID calculation. 
 
   if(track) fkTrack = track;
-  return NULL;
-/*  if(!fkTrack){
+  if(!fkTrack){
     AliDebug(4, "No Track defined.");
     return NULL;
   }
-  TObjArray *arr = NULL;
-  if(!fContainer || !(arr = (TObjArray*)fContainer->At(kTrackIn))){
-    AliWarning("No output container defined.");
+  // check container
+  THnSparseI *H=(THnSparseI*)fContainer->At(kTrackIn);
+  if(!H){
+    AliError(Form("Missing container @ %d", Int_t(kTrackIn)));
     return NULL;
   }
-  AliExternalTrackParam *tin = NULL;
+  // check input track status
+  AliExternalTrackParam *tin(NULL);
   if(!(tin = fkTrack->GetTrackIn())){
-    AliWarning("Track did not entered TRD fiducial volume.");
+    AliError("Track did not entered TRD fiducial volume.");
     return NULL;
   }
-  TH1 *h = NULL;
-  
-  Double_t x = tin->GetX();
-  AliTRDseedV1 *fTracklet = NULL;  
-  for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
-    if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
-    break;
-  }
-  if(!fTracklet || TMath::Abs(x-fTracklet->GetX())>1.e-3){
-    AliDebug(1, "Tracklet did not match Track.");
+  // check first tracklet
+  AliTRDseedV1 *fTracklet(fkTrack->GetTracklet(0));
+  if(!fTracklet){
+    AliDebug(3, "No Tracklet in ly[0]. Skip track.");
     return NULL;
   }
-  Int_t sgm[3];
-  sgm[2] = fTracklet->GetDetector();
-  sgm[0] = AliTRDgeometry::GetSector(sgm[2]);
-  sgm[1] = sgm[0] * AliTRDgeometry::kNstack + AliTRDgeometry::GetStack(sgm[2]);
-  Double_t tilt(fTracklet->GetTilt())
-          ,t2(tilt*tilt)
-          ,corr(1./(1. + t2))
-          ,cost(TMath::Sqrt(corr));
-  Bool_t rc(fTracklet->IsRowCross());
-
-  const Int_t kNPAR(5);
-  Double_t parR[kNPAR]; memcpy(parR, tin->GetParameter(), kNPAR*sizeof(Double_t));
-  Double_t covR[3*kNPAR]; memcpy(covR, tin->GetCovariance(), 3*kNPAR*sizeof(Double_t));
-  Double_t cov[3]; fTracklet->GetCovAt(x, cov);
-
-  // define sum covariances
-  TMatrixDSym COV(kNPAR); TVectorD PAR(kNPAR);
-  Double_t *pc = &covR[0], *pp = &parR[0];
-  for(Int_t ir=0; ir<kNPAR; ir++, pp++){
-    PAR(ir) = (*pp);
-    for(Int_t ic = 0; ic<=ir; ic++,pc++){ 
-      COV(ir,ic) = (*pc); COV(ic,ir) = (*pc);
-    }
-  }
-  PAR[4] = TMath::Abs(PAR[4]); // remove sign of pt !!
-  //COV.Print(); PAR.Print();
-
-  //TODO Double_t dydx =  TMath::Sqrt(1.-parR[2]*parR[2])/parR[2]; 
-  Double_t dy[2]={parR[0] - fTracklet->GetY(), 0.}
-          ,dz[2]={parR[1] - fTracklet->GetZ(), 0.}
-          ,dphi(TMath::ASin(PAR[2])-TMath::ATan(fTracklet->GetYfit(1)));
-  // calculate residuals using tilt rotation
-  dy[1] = cost*(dy[0] - dz[0]*tilt);
-  dz[1] = cost*(dz[0] + dy[0]*tilt);
-
-  if(1./PAR[4]>fPtThreshold) ((TH3S*)arr->At(0))->Fill(fTracklet->GetYref(1), dy[1], sgm[fSegmentLevel]+rc*fgkNresYsegm[fSegmentLevel]);
-  ((TH3S*)arr->At(2))->Fill(fTracklet->GetZref(1), dz[1], rc);
-  ((TH2I*)arr->At(4))->Fill(fTracklet->GetYref(1), dphi);
-
-  Double_t dyz[2] = {dy[1], dz[1]};
-  Double_t cc[3] = {COV(0,0)+cov[0], COV(0,1)+cov[1], COV(1,1)+cov[2]};
-  Pulls(dyz, cc, tilt);
-  ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
-  ((TH3S*)arr->At(3))->Fill(fTracklet->GetZref(1), dyz[1], rc);
-
-
-
-  // register reference histo for mini-task
-  h = (TH2I*)arr->At(0);
-
-  if(DebugLevel()>=2){
-    (*DebugStream()) << "trackIn"
-      << "x="       << x
-      << "P="       << &PAR
-      << "C="       << &COV
-      << "\n";
-
-    Double_t y = fTracklet->GetY(); 
-    Double_t z = fTracklet->GetZ(); 
-    (*DebugStream()) << "trackletIn"
-      << "y="       << y
-      << "z="       << z
-      << "Vy="      << cov[0]
-      << "Cyz="     << cov[1]
-      << "Vz="      << cov[2]
-      << "\n";
+  // check radial position
+  Double_t x = tin->GetX();
+  if(TMath::Abs(x-fTracklet->GetX())>1.e-3){
+    AliDebug(1, Form("Tracklet did not match Track. dx[cm]=%+4.1f", x-fTracklet->GetX()));
+    return NULL;
   }
 
+  Int_t bc(fkESD->GetTOFbc()%2);
+  const Double_t *parR(tin->GetParameter());
+  Double_t dyt(parR[0] - fTracklet->GetYfit(0)), dzt(parR[1] - fTracklet->GetZfit(0)),
+            phit(fTracklet->GetYfit(1)),
+            tilt(fTracklet->GetTilt());
+
+  // correct for tilt rotation
+  Double_t dy  = dyt - dzt*tilt,
+           dz  = dzt + dyt*tilt;
+  phit       += tilt*parR[3];
+  Double_t dphi = TMath::ASin(parR[2])-TMath::ATan(phit);
+
+  Double_t val[kNdim];
+  val[kBC]          = bc;
+  val[kPhi]         = fPhi;
+  val[kEta]         = fEta;
+  val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:fSpecies;
+  val[kPt]          = GetPtBin(fPt);
+  val[kYrez]        = dy;
+  val[kZrez]        = dz;
+  val[kPrez]        = dphi*TMath::RadToDeg();
+  H->Fill(val);
+
+  if(!HasMCdata()) return NULL; // H->Projection(kEta, kPhi);
+  if(!(H = (THnSparseI*)fContainer->At(kMCtrackIn))) {
+    AliError(Form("Missing container @ %d", Int_t(kMCtrackIn)));
+    return NULL;
+  }
 
-  if(!HasMCdata()) return h;
+  // get MC info
   UChar_t s;
-  Float_t dx, pt0, x0=fTracklet->GetX0(), y0, z0, dydx0, dzdx0;
-  if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, s)) return h;
+  Float_t pt0, eta, x0=fTracklet->GetX0(), y0, z0, dydx0, dzdx0;
+  if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, eta, s)) return NULL;
+  dyt = y0 - fTracklet->GetYfit(0);
+  dzt = z0 - fTracklet->GetZfit(0);
+  phit= fTracklet->GetYfit(1) + tilt*dzdx0;
+  Float_t phi = TMath::ATan2(y0, x0);
+  dy  = dyt - dzt*tilt;
+  dz  = dzt + dyt*tilt;
+  dphi= TMath::ASin(dydx0)-TMath::ATan(phit);
+
   Int_t pdg = fkMC->GetPDG(),
         sIdx(AliTRDpidUtil::Pdg2Pid(TMath::Abs(pdg))+1), // species index
         sign(0);
@@ -713,61 +564,18 @@ TH1* AliTRDresolution::PlotTrackIn(const AliTRDtrackV1 *track)
   TParticlePDG *ppdg(fDBPDG->GetParticle(pdg));
   if(ppdg) sign = ppdg->Charge() > 0. ? 1 : -1;
 
-  // translate to reference radial position
-  dx = x0 - x; y0 -= dx*dydx0; z0 -= dx*dzdx0;
-  Float_t norm = 1./TMath::Sqrt(1.+dydx0*dydx0); // 1/sqrt(1+tg^2(phi))
-  //Fill MC info
-  TVectorD PARMC(kNPAR);
-  PARMC[0]=y0; PARMC[1]=z0;
-  PARMC[2]=dydx0*norm; PARMC[3]=dzdx0*norm;
-  PARMC[4]=1./pt0;
-
-//   TMatrixDSymEigen eigen(COV);
-//   TVectorD evals = eigen.GetEigenValues();
-//   TMatrixDSym evalsm(kNPAR);
-//   for(Int_t ir=0; ir<kNPAR; ir++) for(Int_t ic=0; ic<kNPAR; ic++) evalsm(ir,ic) = (ir==ic ? evals(ir): 0.);
-//   TMatrixD evecs = eigen.GetEigenVectors();
-//   TMatrixD sqrcov(evecs, TMatrixD::kMult, TMatrixD(evalsm, TMatrixD::kMult, evecs.T()));
-  
-  // fill histos
-  if(!(arr = (TObjArray*)fContainer->At(kMCtrackIn))) {
-    AliWarning("No MC container defined.");
-    return h;
-  }
 
-  // y resolution/pulls
-  if(pt0>fPtThreshold) ((TH3S*)arr->At(0))->Fill(dydx0, PARMC[0]-PAR[0], sgm[fSegmentLevel]);
-  ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], (PARMC[0]-PAR[0])/TMath::Sqrt(COV(0,0)), (PARMC[1]-PAR[1])/TMath::Sqrt(COV(1,1)));
-  // z resolution/pulls
-  ((TH3S*)arr->At(2))->Fill(dzdx0, PARMC[1]-PAR[1], 0);
-  ((TH3S*)arr->At(3))->Fill(dzdx0, (PARMC[1]-PAR[1])/TMath::Sqrt(COV(1,1)), 0);
-  // phi resolution/snp pulls
-  ((TH2I*)arr->At(4))->Fill(dydx0, TMath::ASin(PARMC[2])-TMath::ASin(PAR[2]));
-  ((TH2I*)arr->At(5))->Fill(dydx0, (PARMC[2]-PAR[2])/TMath::Sqrt(COV(2,2)));
-  // theta resolution/tgl pulls
-  ((TH2I*)arr->At(6))->Fill(dzdx0, TMath::ATan((PARMC[3]-PAR[3])/(1-PARMC[3]*PAR[3])));
-  ((TH2I*)arr->At(7))->Fill(dzdx0, (PARMC[3]-PAR[3])/TMath::Sqrt(COV(3,3)));
-  // pt resolution\\1/pt pulls\\p resolution/pull
-  ((TH3S*)arr->At(8))->Fill(pt0, PARMC[4]/PAR[4]-1., sign*sIdx);
-  ((TH3S*)arr->At(9))->Fill(PARMC[4], (PARMC[4]-PAR[4])/TMath::Sqrt(COV(4,4)), sign*sIdx);
-
-  Double_t p0 = TMath::Sqrt(1.+ PARMC[3]*PARMC[3])*pt0, p;
-  p = TMath::Sqrt(1.+ PAR[3]*PAR[3])/PAR[4];
-  ((TH3S*)arr->At(10))->Fill(p0, p/p0-1., sign*sIdx);
-//   Float_t sp = 
-//     p*p*PAR[4]*PAR[4]*COV(4,4)
-//    +2.*PAR[3]*COV(3,4)/PAR[4]
-//    +PAR[3]*PAR[3]*COV(3,3)/p/p/PAR[4]/PAR[4]/PAR[4]/PAR[4];
-//   if(sp>0.) ((TH3S*)arr->At(11))->Fill(p0, (p0-p)/TMath::Sqrt(sp), sign*sIdx);
-
-  // fill debug for MC 
-  if(DebugLevel()>=3){
-    (*DebugStream()) << "trackInMC"
-      << "P="   << &PARMC
-      << "\n";
-  }
-  return h;
-*/
+  val[kBC]          = (bc>=kNbunchCross)?(kNbunchCross-1):bc;
+  val[kPhi]         = phi;
+  val[kEta]         = eta;
+  val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:sign*(sIdx+1);
+  val[kPt]          = GetPtBin(pt0);
+  val[kYrez]        = dy;
+  val[kZrez]        = dz;
+  val[kPrez]        = dphi*TMath::RadToDeg();
+  H->Fill(val);
+
+  return NULL; //H->Projection(kEta, kPhi);
 }
 
 //________________________________________________________
@@ -784,165 +592,6 @@ TH1* AliTRDresolution::PlotTrackOut(const AliTRDtrackV1 *track)
 
   if(track) fkTrack = track;
   return NULL;
-/*
-  if(!fkTrack){
-    AliDebug(4, "No Track defined.");
-    return NULL;
-  }
-  TObjArray *arr = NULL;
-  if(!fContainer || !(arr = (TObjArray*)fContainer->At(kTrackOut))){
-    AliWarning("No output container defined.");
-    return NULL;
-  }
-  AliExternalTrackParam *tout = NULL;
-  if(!(tout = fkTrack->GetTrackOut())){
-    AliDebug(2, "Track did not exit TRD.");
-    return NULL;
-  }
-  TH1 *h(NULL);
-  
-  Double_t x = tout->GetX();
-  AliTRDseedV1 *fTracklet(NULL);  
-  for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
-    if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
-    break;
-  }
-  if(!fTracklet || TMath::Abs(x-fTracklet->GetX())>1.e-3){
-    AliDebug(1, "Tracklet did not match Track position.");
-    return NULL;
-  }
-  Int_t sgm[3];
-  sgm[2] = fTracklet->GetDetector();
-  sgm[0] = AliTRDgeometry::GetSector(sgm[2]);
-  sgm[1] = sgm[0] * AliTRDgeometry::kNstack + AliTRDgeometry::GetStack(sgm[2]);
-  Double_t tilt(fTracklet->GetTilt())
-          ,t2(tilt*tilt)
-          ,corr(1./(1. + t2))
-          ,cost(TMath::Sqrt(corr));
-  Bool_t rc(fTracklet->IsRowCross());
-
-  const Int_t kNPAR(5);
-  Double_t parR[kNPAR]; memcpy(parR, tout->GetParameter(), kNPAR*sizeof(Double_t));
-  Double_t covR[3*kNPAR]; memcpy(covR, tout->GetCovariance(), 3*kNPAR*sizeof(Double_t));
-  Double_t cov[3]; fTracklet->GetCovAt(x, cov);
-
-  // define sum covariances
-  TMatrixDSym COV(kNPAR); TVectorD PAR(kNPAR);
-  Double_t *pc = &covR[0], *pp = &parR[0];
-  for(Int_t ir=0; ir<kNPAR; ir++, pp++){
-    PAR(ir) = (*pp);
-    for(Int_t ic = 0; ic<=ir; ic++,pc++){ 
-      COV(ir,ic) = (*pc); COV(ic,ir) = (*pc);
-    }
-  }
-  PAR[4] = TMath::Abs(PAR[4]); // remove sign of pt !!
-  //COV.Print(); PAR.Print();
-
-  //TODO Double_t dydx =  TMath::Sqrt(1.-parR[2]*parR[2])/parR[2]; 
-  Double_t dy[3]={parR[0] - fTracklet->GetY(), 0., 0.}
-          ,dz[3]={parR[1] - fTracklet->GetZ(), 0., 0.}
-          ,dphi(TMath::ASin(PAR[2])-TMath::ATan(fTracklet->GetYfit(1)));
-  // calculate residuals using tilt rotation
-  dy[1] = cost*(dy[0] - dz[0]*tilt);
-  dz[1] = cost*(dz[0] + dy[0]*tilt);
-
-  if(1./PAR[4]>fPtThreshold) ((TH3S*)arr->At(0))->Fill(fTracklet->GetYref(1), 1.e2*dy[1], sgm[fSegmentLevel]+rc*fgkNresYsegm[fSegmentLevel]); // scale to fit general residual range !!!
-  ((TH3S*)arr->At(2))->Fill(fTracklet->GetZref(1), dz[1], rc);
-  ((TH2I*)arr->At(4))->Fill(fTracklet->GetYref(1), dphi);
-
-  Double_t dyz[2] = {dy[1], dz[1]};
-  Double_t cc[3] = {COV(0,0)+cov[0], COV(0,1)+cov[1], COV(1,1)+cov[2]};
-  Pulls(dyz, cc, tilt);
-  ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
-  ((TH3S*)arr->At(3))->Fill(fTracklet->GetZref(1), dyz[1], rc);
-
-  // register reference histo for mini-task
-  h = (TH2I*)arr->At(0);
-
-  if(DebugLevel()>=2){
-    (*DebugStream()) << "trackOut"
-      << "x="       << x
-      << "P="       << &PAR
-      << "C="       << &COV
-      << "\n";
-
-    Double_t y = fTracklet->GetY(); 
-    Double_t z = fTracklet->GetZ(); 
-    (*DebugStream()) << "trackletOut"
-      << "y="       << y
-      << "z="       << z
-      << "Vy="      << cov[0]
-      << "Cyz="     << cov[1]
-      << "Vz="      << cov[2]
-      << "\n";
-  }
-
-
-  if(!HasMCdata()) return h;
-  UChar_t s;
-  Float_t dx, pt0, x0=fTracklet->GetX0(), y0, z0, dydx0, dzdx0;
-  if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, s)) return h;
-  Int_t pdg = fkMC->GetPDG(),
-        sIdx(AliTRDpidUtil::Pdg2Pid(TMath::Abs(pdg))+1), // species index
-        sign(0);
-  if(!fDBPDG) fDBPDG=TDatabasePDG::Instance();
-  TParticlePDG *ppdg(fDBPDG->GetParticle(pdg));
-  if(ppdg) sign = ppdg->Charge() > 0. ? 1 : -1;
-
-  // translate to reference radial position
-  dx = x0 - x; y0 -= dx*dydx0; z0 -= dx*dzdx0;
-  Float_t norm = 1./TMath::Sqrt(1.+dydx0*dydx0); // 1/sqrt(1+tg^2(phi))
-  //Fill MC info
-  TVectorD PARMC(kNPAR);
-  PARMC[0]=y0; PARMC[1]=z0;
-  PARMC[2]=dydx0*norm; PARMC[3]=dzdx0*norm;
-  PARMC[4]=1./pt0;
-
-//   TMatrixDSymEigen eigen(COV);
-//   TVectorD evals = eigen.GetEigenValues();
-//   TMatrixDSym evalsm(kNPAR);
-//   for(Int_t ir=0; ir<kNPAR; ir++) for(Int_t ic=0; ic<kNPAR; ic++) evalsm(ir,ic) = (ir==ic ? evals(ir): 0.);
-//   TMatrixD evecs = eigen.GetEigenVectors();
-//   TMatrixD sqrcov(evecs, TMatrixD::kMult, TMatrixD(evalsm, TMatrixD::kMult, evecs.T()));
-  
-  // fill histos
-  if(!(arr = (TObjArray*)fContainer->At(kMCtrackOut))){
-    AliWarning("No MC container defined.");
-    return h;
-  }
-  // y resolution/pulls
-  if(pt0>fPtThreshold) ((TH3S*)arr->At(0))->Fill(dydx0, PARMC[0]-PAR[0], sgm[fSegmentLevel]);
-  ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], (PARMC[0]-PAR[0])/TMath::Sqrt(COV(0,0)), (PARMC[1]-PAR[1])/TMath::Sqrt(COV(1,1)));
-  // z resolution/pulls
-  ((TH3S*)arr->At(2))->Fill(dzdx0, PARMC[1]-PAR[1], 0);
-  ((TH3S*)arr->At(3))->Fill(dzdx0, (PARMC[1]-PAR[1])/TMath::Sqrt(COV(1,1)), 0);
-  // phi resolution/snp pulls
-  ((TH2I*)arr->At(4))->Fill(dydx0, TMath::ASin(PARMC[2])-TMath::ASin(PAR[2]));
-  ((TH2I*)arr->At(5))->Fill(dydx0, (PARMC[2]-PAR[2])/TMath::Sqrt(COV(2,2)));
-  // theta resolution/tgl pulls
-  ((TH2I*)arr->At(6))->Fill(dzdx0, TMath::ATan((PARMC[3]-PAR[3])/(1-PARMC[3]*PAR[3])));
-  ((TH2I*)arr->At(7))->Fill(dzdx0, (PARMC[3]-PAR[3])/TMath::Sqrt(COV(3,3)));
-  // pt resolution\\1/pt pulls\\p resolution/pull
-  ((TH3S*)arr->At(8))->Fill(pt0, PARMC[4]/PAR[4]-1., sign*sIdx);
-  ((TH3S*)arr->At(9))->Fill(PARMC[4], (PARMC[4]-PAR[4])/TMath::Sqrt(COV(4,4)), sign*sIdx);
-
-  Double_t p0 = TMath::Sqrt(1.+ PARMC[3]*PARMC[3])*pt0, p;
-  p = TMath::Sqrt(1.+ PAR[3]*PAR[3])/PAR[4];
-  ((TH3S*)arr->At(10))->Fill(p0, p/p0-1., sign*sIdx);
-//   Float_t sp = 
-//     p*p*PAR[4]*PAR[4]*COV(4,4)
-//    +2.*PAR[3]*COV(3,4)/PAR[4]
-//    +PAR[3]*PAR[3]*COV(3,3)/p/p/PAR[4]/PAR[4]/PAR[4]/PAR[4];
-//   if(sp>0.) ((TH3S*)arr->At(11))->Fill(p0, (p0-p)/TMath::Sqrt(sp), sign*sIdx);
-
-  // fill debug for MC 
-  if(DebugLevel()>=3){
-    (*DebugStream()) << "trackOutMC"
-      << "P="   << &PARMC
-      << "\n";
-  }
-  return h;
-*/  
 }
 
 //________________________________________________________
@@ -970,32 +619,50 @@ TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
         sIdx(AliTRDpidUtil::Pdg2Pid(TMath::Abs(pdg))+1), // species index
         sign(0),
         sgm[3],
-        label(fkMC->GetLabel());
+        label(fkMC->GetLabel()),
+        fSegmentLevel(0);
   if(!fDBPDG) fDBPDG=TDatabasePDG::Instance();
   TParticlePDG *ppdg(fDBPDG->GetParticle(pdg));
   if(ppdg) sign = ppdg->Charge() > 0. ? 1 : -1;
 
   TObjArray *arr(NULL);TH1 *h(NULL);
+  AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
+  AliTRDseedV1 *fTracklet(NULL); TObjArray *clInfoArr(NULL);
   UChar_t s;
   Double_t xAnode, x, y, z, pt, dydx, dzdx, dzdl;
   Float_t pt0, x0, y0, z0, dx, dy, dz, dydx0, dzdx0;
   Double_t covR[7]/*, cov[3]*/;
-
+  
   if(DebugLevel()>=3){
-    TVectorD dX(12), dY(12), dZ(12), vPt(12), dPt(12), cCOV(12*15);
-    fkMC->PropagateKalman(&dX, &dY, &dZ, &vPt, &dPt, &cCOV);
-    (*DebugStream()) << "MCkalman"
-      << "pdg=" << pdg
-      << "dx="  << &dX
-      << "dy="  << &dY
-      << "dz="  << &dZ
-      << "pt="  << &vPt
-      << "dpt=" << &dPt
-      << "cov=" << &cCOV
-      << "\n";
+    // get first detector
+    Int_t det = -1;
+    for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
+      if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
+      det = fTracklet->GetDetector();
+      break;
+    }
+    if(det>=0){
+      TVectorD X(12), Y(12), Z(12), dX(12), dY(12), dZ(12), vPt(12), dPt(12), budget(12), cCOV(12*15);
+      Double_t m(-1.);
+      m = fkTrack->GetMass();
+      if(fkMC->PropagateKalman(&X, &Y, &Z, &dX, &dY, &dZ, &vPt, &dPt, &budget, &cCOV, m)){
+        (*DebugStream()) << "MCkalman"
+          << "pdg=" << pdg
+          << "det=" << det
+          << "x="   << &X
+          << "y="   << &Y
+          << "z="   << &Z
+          << "dx="  << &dX
+          << "dy="  << &dY
+          << "dz="  << &dZ
+          << "pt="  << &vPt
+          << "dpt=" << &dPt
+          << "bgt=" << &budget
+          << "cov=" << &cCOV
+          << "\n";
+      }
+    }
   }
-  AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
-  AliTRDseedV1 *fTracklet(NULL); TObjArray *clInfoArr(NULL);
   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
     if(!(fTracklet = fkTrack->GetTracklet(ily)))/* ||
        !fTracklet->IsOK())*/ continue;
@@ -1010,8 +677,8 @@ TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
     x0  = fTracklet->GetX0();
     //radial shift with respect to the MC reference (radial position of the pad plane)
     x= fTracklet->GetX();
-    Bool_t rc(fTracklet->IsRowCross());
-    if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, s)) continue;
+    Bool_t rc(fTracklet->IsRowCross()); Float_t eta;
+    if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, eta, s)) continue;
     xAnode  = fTracklet->GetX0();
 
     // MC track position at reference radial position
@@ -1050,7 +717,7 @@ TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
     if(pt0>fPtThreshold) ((TH3S*)arr->At(0))->Fill(dydx0, dy, sgm[fSegmentLevel]);
     ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dy/TMath::Sqrt(covR[0]), dz/TMath::Sqrt(covR[2]));
     // z resolution/pulls
-    ((TH3S*)arr->At(2))->Fill(dzdx0, dz, 0);
+    ((TH2S*)arr->At(2))->Fill(dzdx0, dz);
     ((TH3S*)arr->At(3))->Fill(dzdx0, dz/TMath::Sqrt(covR[2]), 0);
     // phi resolution/ snp pulls
     Double_t dtgp = (dydx - dydx0)/(1.- dydx*dydx0);
@@ -1133,7 +800,7 @@ TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
     tt.ResetClusterIter(kFALSE);
     while((c = tt.PrevCluster())){
       Float_t  q = TMath::Abs(c->GetQ());
-      x = c->GetX()+fXcorr[c->GetDetector()][c->GetLocalTimeBin()]; y = c->GetY();z = c->GetZ();
+      x = c->GetX();//+fXcorr[c->GetDetector()][c->GetLocalTimeBin()]; y = c->GetY();z = c->GetZ();
       dx = x0 - x; 
       ymc= y0 - dx*dydx0;
       zmc= z0 - dx*dzdx0;
@@ -1181,6 +848,37 @@ TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
 }
 
 
+//__________________________________________________________________________
+Int_t AliTRDresolution::GetPtBin(Float_t pt)
+{
+// Find pt bin according to local pt segmentation
+  Int_t ipt(0);
+  while(ipt<AliTRDresolution::kNpt){
+    if(pt<fgPtBin[ipt]) break;
+    ipt++;
+  }
+  return TMath::Max(0,ipt);
+}
+
+//________________________________________________________
+Float_t AliTRDresolution::GetMeanWithBoundary(TH1 *h, Float_t zm, Float_t zM, Float_t dz) const
+{
+// return mean of histogram "h"
+// if histo is empty returns -infinity
+// if few entries returns zM+epsilon
+// if mean less than zm returns zm-epsilon
+
+  Int_t ne(h->GetEntries());
+  if(ne==0) return -1.e+5;
+  else if(ne<20) return zM+0.5*dz;
+  else{
+    Float_t val(h->GetMean());
+    if(val<zm) return zm-0.5*dz;
+    else if(val>zM) return zM-0.5*dz;
+    else return val;
+  }
+}
+
 //________________________________________________________
 Bool_t AliTRDresolution::GetRefFigure(Int_t ifig)
 {
@@ -1188,798 +886,74 @@ Bool_t AliTRDresolution::GetRefFigure(Int_t ifig)
   // Get the reference figures
   //
 
-  Float_t xy[4] = {0., 0., 0., 0.};
   if(!gPad){
     AliWarning("Please provide a canvas to draw results.");
     return kFALSE;
   }
-  Int_t selection[100], n(0), selStart(0); // 
+/*  Int_t selection[100], n(0), selStart(0); // 
   Int_t ly0(0), dly(5);
-  //Int_t ly0(1), dly(2); // used for SA
-  TList *l(NULL); TVirtualPad *pad(NULL); 
-  TGraphErrors *g(NULL);TGraphAsymmErrors *ga(NULL);
+  TList *l(NULL); TVirtualPad *pad(NULL); */
   switch(ifig){
-  case 0: // charge resolution
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    ((TVirtualPad*)l->At(0))->cd();
-    ga=((TGraphAsymmErrors*)((TObjArray*)fGraphM->At(kCharge))->At(0));
-    if(ga->GetN()) ga->Draw("apl");
-    ((TVirtualPad*)l->At(1))->cd();
-    g = ((TGraphErrors*)((TObjArray*)fGraphS->At(kCharge))->At(0));
-    if(g->GetN()) g->Draw("apl");
+  case 0:
     break;
-  case 1: // cluster2track residuals
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -100.; xy[2] = .3; xy[3] = 1000.;
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kCluster, 0, 1, n, selection)) break;
-    pad=(TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kCluster, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 2: // cluster2track residuals
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -100.; xy[2] = .3; xy[3] = 1000.;
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kCluster, 0, 1, n, selection)) break;
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-0.5; xy[3] = 2.5;
-    pad=(TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    if(!GetGraphArray(xy, kCluster, 1, 1)) break;
-    return kTRUE;
-  case 3: // kTrack y
-    gPad->Divide(3, 2, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -20.; xy[2] = .3; xy[3] = 100.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection)) break;
-
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection)) break;
-
-    ((TVirtualPad*)l->At(2))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection)) break;
-
-    ((TVirtualPad*)l->At(3))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection, "[RC]")) break;
-
-    ((TVirtualPad*)l->At(4))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3+fgkNresYsegm[fSegmentLevel]; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection, "[RC]")) break;
-
-    ((TVirtualPad*)l->At(5))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3+fgkNresYsegm[fSegmentLevel]; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrack, 0, 1, n, selection, "[RC]")) break;
-    return kTRUE;
-  case 4: // kTrack z
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-
-    xy[0] = -1.; xy[1] = -150.; xy[2] = 1.; xy[3] = 1000.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selection[0]=1;
-    if(!GetGraphArray(xy, kTrack, 2, 1, 1, selection)) break;
-
-    xy[0] = -1.; xy[1] = -1500.; xy[2] = 1.; xy[3] = 10000.;
-    ((TVirtualPad*)l->At(1))->cd();
-    selection[0]=0;
-    if(!GetGraphArray(xy, kTrack, 2, 1, 1, selection)) break;
-
-    return kTRUE;
-  case 5: // kTrack  pulls
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kTrack, 1, 1)) break;
-
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kTrack, 3, 1)) break;
-    return kTRUE;
-  case 6: // kTrack  phi
-    xy[0] = -.3; xy[1] = -5.; xy[2] = .3; xy[3] = 50.;
-    if(GetGraph(&xy[0], kTrack , 4)) return kTRUE;
-    break;
-  case 7: // kTrackIn y
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -1500.; xy[2] = .3; xy[3] = 5000.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackIn, 0, 1, n, selection)) break;
-    pad=((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackIn, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 8: // kTrackIn y
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -1500.; xy[2] = .3; xy[3] = 5000.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackIn, 0, 1, n, selection)) break;
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 2.5;
-    pad=((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    if(!GetGraphArray(xy, kTrackIn, 1, 1)) break;
-    return kTRUE;
-  case 9: // kTrackIn z
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -1.; xy[1] = -1000.; xy[2] = 1.; xy[3] = 4000.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selection[0]=1;
-    if(!GetGraphArray(xy, kTrackIn, 2, 1, 1, selection)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    pad = ((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    if(!GetGraphArray(xy, kTrackIn, 3, 1)) break;
-    return kTRUE;
-  case 10: // kTrackIn phi
-    xy[0] = -.3; xy[1] = -5.; xy[2] = .3; xy[3] = 50.;
-    if(GetGraph(&xy[0], kTrackIn, 4)) return kTRUE;
-    break;
-  case 11: // kTrackOut y
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -50.; xy[2] = .3; xy[3] = 150.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackOut, 0, 1, n, selection)) break;
-    pad=((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackOut, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 12: // kTrackOut y
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.3; xy[1] = -50.; xy[2] = .3; xy[3] = 150.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kTrackOut, 0, 1, n, selection)) break;
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 2.5;
-    pad=((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    if(!GetGraphArray(xy, kTrackOut, 1, 1)) break;
-    return kTRUE;
-  case 13: // kTrackOut z
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -1.; xy[1] = -1000.; xy[2] = 1.; xy[3] = 4000.;
-    pad = ((TVirtualPad*)l->At(0)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    if(!GetGraphArray(xy, kTrackOut, 2, 1)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    pad = ((TVirtualPad*)l->At(1)); pad->cd();
-    pad->SetMargin(0.1, 0.1, 0.1, 0.01);
-    if(!GetGraphArray(xy, kTrackOut, 3, 1)) break;
-    return kTRUE;
-  case 14: // kTrackOut phi
-    xy[0] = -.3; xy[1] = -5.; xy[2] = .3; xy[3] = 50.;
-    if(GetGraph(&xy[0], kTrackOut, 4)) return kTRUE;
-    break;
-  case 15: // kMCcluster
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3]=650.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCcluster, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCcluster, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 16: // kMCcluster
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3]=650.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCcluster, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-    if(!GetGraphArray(xy, kMCcluster, 1, 1)) break;
-    return kTRUE;
-  case 17: //kMCtracklet [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3] =500.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtracklet, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtracklet, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 18: //kMCtracklet [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3] =500.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtracklet, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-    if(!GetGraphArray(xy, kMCtracklet, 1, 1)) break;
-    return kTRUE;
-  case 19: //kMCtracklet [z]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-100.; xy[2]=1.; xy[3] =2500.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtracklet, 2)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtracklet, 3)) break;
-    return kTRUE;
-  case 20: //kMCtracklet [phi]
-    xy[0]=-.3; xy[1]=-3.; xy[2]=.3; xy[3] =25.;
-    if(!GetGraph(&xy[0], kMCtracklet, 4)) break;
-    return kTRUE;
-  case 21: //kMCtrack [y] ly [0]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*0.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer1")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*0.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer1")) break;
-    return kTRUE;
-  case 22: //kMCtrack [y] ly [1]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*1.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer2")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*1.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer2")) break;
-    return kTRUE;
-  case 23: //kMCtrack [y] ly [2]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*2.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer3")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*2.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer3")) break;
-    return kTRUE;
-  case 24: //kMCtrack [y] ly [3]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*3.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer4")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*3.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer4")) break;
-    return kTRUE;
-  case 25: //kMCtrack [y] ly [4]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*4.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer5")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*4.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer5")) break;
-    return kTRUE;
-  case 26: //kMCtrack [y] ly [5]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-50.; xy[2]=.2; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*5.); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer6")) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=Int_t(fgkNresYsegm[fSegmentLevel]*5.5); for(n=0; n<fgkNresYsegm[fSegmentLevel]/2; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 0, 1, n, selection, "Layer6")) break;
-    return kTRUE;
-  case 27: //kMCtrack [y pulls] 
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 5.5;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<6; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 1, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=6; for(n=0; n<6; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrack, 1, 1, n, selection)) break;
-    return kTRUE;
-  case 28: //kMCtrack [z]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-1500.; xy[2]=1.; xy[3] =6000.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 2)) break;
-    xy[0] = -1.; xy[1] = -1.5; xy[2] = 1.; xy[3] = 5.;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 3)) break;
-    return kTRUE;
-  case 29: //kMCtrack [phi/snp]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.2; xy[1]=-0.5; xy[2]=.2; xy[3] =10.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 4)) break;
-    xy[0] = -.2; xy[1] = -1.5; xy[2] = .2; xy[3] = 5.;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 5)) break;
-    return kTRUE;
-  case 30: //kMCtrack [theta/tgl]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-0.5; xy[2]=1.; xy[3] =5.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 6)) break;
-    xy[0] = -.2; xy[1] = -0.5; xy[2] = .2; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrack, 7)) break;
-    return kTRUE;
-  case 31: //kMCtrack [pt]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // pi selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 2; // pi-
-      selection[n++] = il*11 + 8; // pi+
-    }
-    xy[0] = 0.2; xy[1] = -.7; xy[2] = 7.; xy[3] = 4.;
-    //xy[0] = 0.2; xy[1] = -1.; xy[2] = 7.; xy[3] = 10.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 8, kTRUE, n, selection, "#pi#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // mu selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 3; // mu-
-      selection[n++] = il*11 + 7; // mu+
-    }
-    if(!GetGraphArray(xy, kMCtrack, 8, kTRUE, n, selection, "#mu#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    return kTRUE;
-  case 32: //kMCtrack [pt]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // p selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 0; // p bar
-      selection[n++] = il*11 + 10; // p
-    }
-    xy[0] = 0.2; xy[1] = -.7; xy[2] = 7.; xy[3] = 8.;
-    //xy[0] = 0.2; xy[1] = -1.; xy[2] = 7.; xy[3] = 10.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 8, kTRUE, n, selection, "p&p bar")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // e selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 4; // e-
-      selection[n++] = il*11 + 6; // e+
-    }
-    xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 12.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 14.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 8, kTRUE, n, selection, "e#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    return kTRUE;
-  case 33: //kMCtrack [1/pt] pulls
-    xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 3.5;
-    //xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 4.5; // SA
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // pi selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 2; // pi-
-      selection[n++] = il*11 + 8; // pi+
-    }
-    if(!GetGraphArray(xy, kMCtrack, 9, kTRUE, n, selection, "#pi#pm")) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // mu selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 3; // mu-
-      selection[n++] = il*11 + 7; // mu+
-    }
-    if(!GetGraphArray(xy, kMCtrack, 9, kTRUE, n, selection, "#mu#pm")) break;
-    return kTRUE;
-  case 34: //kMCtrack [1/pt] pulls
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // p selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 0; // p bar
-      selection[n++] = il*11 + 10; // p
-    }
-    xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 3.5;
-    //xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 6.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 9, kTRUE, n, selection, "p & p bar")) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // e selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 4; // e-
-      selection[n++] = il*11 + 6; // e+
-    }
-    xy[0] = 0.; xy[1] = -2.; xy[2] = 2.; xy[3] = 4.5;
-    if(!GetGraphArray(xy, kMCtrack, 9, kTRUE, n, selection, "e#pm")) break;
-    return kTRUE;
-  case 35: //kMCtrack [p]
-    xy[0] = 0.2; xy[1] = -.7; xy[2] = 7.; xy[3] = 4.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 10.;
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // pi selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 2; // pi-
-      selection[n++] = il*11 + 8; // pi+
-    }
-    if(!GetGraphArray(xy, kMCtrack, 10, kTRUE, n, selection, "#pi#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // mu selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 3; // mu-
-      selection[n++] = il*11 + 7; // mu+
-    }
-    if(!GetGraphArray(xy, kMCtrack, 10, kTRUE, n, selection, "#mu#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    return kTRUE;
-  case 36: //kMCtrack [p]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // p selection
-    n=0;
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 0; // p bar
-      selection[n++] = il*11 + 10; // p
-    }
-    xy[0] = 0.2; xy[1] = -.7; xy[2] = 7.; xy[3] = 8.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 12.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 10, kTRUE, n, selection, "p & p bar")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    // e selection
-    n=0;    
-    for(Int_t il(ly0); il<AliTRDgeometry::kNlayer; il+=dly){
-      selection[n++] = il*11 + 4; // e-
-      selection[n++] = il*11 + 6; // e+
-    }
-    xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 12.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 14.; // SA
-    if(!GetGraphArray(xy, kMCtrack, 10, kTRUE, n, selection, "e#pm")) break;
-    pad->Modified(); pad->Update(); pad->SetLogx();
-    return kTRUE;
-  case 37: // kMCtrackIn [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.25; xy[1]=-1000.; xy[2]=.25; xy[3] =3000.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrackIn, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(&xy[0], kMCtrackIn, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 38: // kMCtrackIn [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.25; xy[1]=-1000.; xy[2]=.25; xy[3] =3000.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrackIn, 0, 1, n, selection)) break;
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrackIn, 1, 1)) break;
-    return kTRUE;
-  case 39: // kMCtrackIn [z]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-500.; xy[2]=1.; xy[3] =800.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtrackIn, 2, 1)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrackIn, 3, 1)) break;
-    return kTRUE;
-  case 40: // kMCtrackIn [phi|snp]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.25; xy[1]=-0.5; xy[2]=.25; xy[3] =2.5;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraph(&xy[0], kMCtrackIn, 4)) break;
-    xy[0] = -.25; xy[1] = -0.5; xy[2] = .25; xy[3] = 1.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraph(&xy[0], kMCtrackIn, 5)) break;
-    return kTRUE;
-  case 41: // kMCtrackIn [theta|tgl]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-1.; xy[2]=1.; xy[3] =4.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraph(&xy[0], kMCtrackIn, 6)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 1.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraph(&xy[0], kMCtrackIn, 7)) break;
-    return kTRUE;
-  case 42: // kMCtrackIn [pt]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = 0.2; xy[1] = -.8; xy[2] = 7.; xy[3] = 6.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 10.; // SA
-    pad=(TVirtualPad*)l->At(0); pad->cd(); pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackIn, 8, 1, n, selection)) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd(); pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackIn, 8, 1, n, selection)) break;
-    return kTRUE;
-  case 43: //kMCtrackIn [1/pt] pulls
-    xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 3.5;
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackIn, 9, 1, n, selection)) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackIn, 9, 1, n, selection)) break;
-    return kTRUE;
-  case 44: // kMCtrackIn [p]
-    xy[0] = 0.2; xy[1] = -.8; xy[2] = 7.; xy[3] = 6.;
-    //xy[0] = 0.2; xy[1] = -1.5; xy[2] = 7.; xy[3] = 10.;
-    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.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackIn, 10, 1, n, selection)) break;
-    pad = ((TVirtualPad*)l->At(1)); pad->cd();pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackIn, 10, 1,  n, selection)) break;
-    return kTRUE;
-  case 45: // kMCtrackOut [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=0; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrackOut, 0, 1, n, selection)) break;
-    ((TVirtualPad*)l->At(1))->cd();
-    selStart=fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(&xy[0], kMCtrackOut, 0, 1, n, selection)) break;
-    return kTRUE;
-  case 46: // kMCtrackOut [y]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.3; xy[1]=-50.; xy[2]=.3; xy[3] =400.;
-    ((TVirtualPad*)l->At(0))->cd();
-    selStart=2*fgkNresYsegm[fSegmentLevel]/3; for(n=0; n<fgkNresYsegm[fSegmentLevel]/3; n++) selection[n]=selStart+n;
-    if(!GetGraphArray(xy, kMCtrackOut, 0, 1, n, selection)) break;
-    xy[0] = -.5; xy[1] = -0.5; xy[2] = fgkNresYsegm[fSegmentLevel]-.5; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrackOut, 1, 1)) break;
-    return kTRUE;
-  case 47: // kMCtrackOut [z]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-500.; xy[2]=1.; xy[3] =1500.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraphArray(xy, kMCtrackOut, 2, 1)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 2.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraphArray(xy, kMCtrackOut, 3, 1)) break;
-    return kTRUE;
-  case 48: // kMCtrackOut [phi|snp]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-.25; xy[1]=-0.5; xy[2]=.25; xy[3] =2.5;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraph(&xy[0], kMCtrackOut, 4)) break;
-    xy[0] = -.25; xy[1] = -0.5; xy[2] = .25; xy[3] = 1.5;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraph(&xy[0], kMCtrackOut, 5)) break;
-    return kTRUE;
-  case 49: // kMCtrackOut [theta|tgl]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0]=-1.; xy[1]=-1.; xy[2]=1.; xy[3] =4.;
-    ((TVirtualPad*)l->At(0))->cd();
-    if(!GetGraph(&xy[0], kMCtrackOut, 6)) break;
-    xy[0] = -1.; xy[1] = -0.5; xy[2] = 1.; xy[3] = 15.;
-    ((TVirtualPad*)l->At(1))->cd();
-    if(!GetGraph(&xy[0], kMCtrackOut, 7)) break;
-    return kTRUE;
-  case 50: // kMCtrackOut [pt]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = 0.2; xy[1] = -.8; xy[2] = 7.; xy[3] = 6.;
-    pad=(TVirtualPad*)l->At(0); pad->cd(); pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackOut, 8, 1, n, selection)) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd();pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackOut, 8, 1, n, selection)) break;
-    return kTRUE;
-  case 51: //kMCtrackOut [1/pt] pulls
-    xy[0] = 0.; xy[1] = -1.; xy[2] = 2.; xy[3] = 3.5;
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    pad = (TVirtualPad*)l->At(0); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackOut, 9, 1, n, selection)) break;
-    pad = (TVirtualPad*)l->At(1); pad->cd();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackOut, 9, 1, n, selection)) break;
-    return kTRUE;
-  case 52: // kMCtrackOut [p]
-    gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); 
-    xy[0] = 0.2; xy[1] = -.8; xy[2] = 7.; xy[3] = 6.;
-    pad = ((TVirtualPad*)l->At(0));pad->cd();pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=2; selection[n++]=3; selection[n++]=7; selection[n++]=8;
-    if(!GetGraphArray(xy, kMCtrackOut, 10, 1, n, selection)) break;
-    pad = ((TVirtualPad*)l->At(1)); pad->cd();pad->SetLogx();
-    pad->SetMargin(0.125, 0.015, 0.1, 0.015);
-    n=0; selection[n++]=0; selection[n++]=4; selection[n++]=6; selection[n++]=10;
-    if(!GetGraphArray(xy, kMCtrackOut, 10, 1, n, selection)) break;
-    return kTRUE;
   }
   AliWarning(Form("Reference plot [%d] missing result", ifig));
   return kFALSE;
 }
 
+
+//________________________________________________________
+void AliTRDresolution::MakePtSegmentation(Float_t pt0, Float_t dpt)
+{
+// Build pt segments
+  for(Int_t j(0); j<=kNpt; j++){
+    pt0+=(TMath::Exp(j*j*dpt)-1.);
+    fgPtBin[j]=pt0;
+  }
+}
+
 //________________________________________________________
 void AliTRDresolution::MakeSummary()
 {
 // Build summary plots
 
-  if(!fGraphS || !fGraphM){
+  if(!fProj){
     AliError("Missing results");
     return;
   }  
-  Float_t xy[4] = {0., 0., 0., 0.};
-  Float_t range[2];
-  TH2 *h2 = new TH2I("h2SF", "", 20, -.2, .2, fgkNresYsegm[fSegmentLevel], -0.5, fgkNresYsegm[fSegmentLevel]-0.5);
-  h2->GetXaxis()->CenterTitle();
-  h2->GetYaxis()->CenterTitle();
-  h2->GetZaxis()->CenterTitle();h2->GetZaxis()->SetTitleOffset(1.4);
-
-  Int_t ih2(0), iSumPlot(0);
-  TCanvas *cOut = new TCanvas(Form("TRDsummary%s_%d", GetName(), iSumPlot++), "Cluster & Tracklet Resolution", 1024, 768);
-  cOut->Divide(3,2, 2.e-3, 2.e-3, kYellow-7);
-  TVirtualPad *p(NULL);
-
-  p=cOut->cd(1); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetTitle(Form("Cluster-Track R-Phi Residuals;tg(#phi);%s;Sigma [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphS->At(kCluster))->At(0), h2);
-  GetRange(h2, 1, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(2); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetTitle(Form("Cluster-Track R-Phi Systematics;tg(#phi);%s;Mean [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphM->At(kCluster))->At(0), h2);
-  GetRange(h2, 0, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(3); 
-  p->SetRightMargin(0.06);p->SetTopMargin(0.06);
-  xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-  if(!GetGraphArray(xy, kCluster, 1, 1)) return;
-
-  p=cOut->cd(4); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetTitle(Form("Tracklet-Track R-Phi Residuals;tg(#phi);%s;Sigma [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphS->At(kTrack))->At(0), h2);
-  GetRange(h2, 1, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(5); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetTitle(Form("Tracklet-Track R-Phi Systematics;tg(#phi);%s;Mean [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphM->At(kTrack))->At(0), h2);
-  GetRange(h2, 0, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(6); 
-  p->SetRightMargin(0.06);p->SetTopMargin(0.06);
-  xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-  if(!GetGraphArray(xy, kTrack, 1, 1)) return;
+  Int_t iSumPlot(0);
+  TVirtualPad *p(NULL); TCanvas *cOut(NULL);
+  TObjArray *arr(NULL);
 
+  // cluster resolution
+  // define palette
+  gStyle->SetPalette(1);
+  cOut = new TCanvas(Form("TRDsummary%s_%d", GetName(), iSumPlot++), "Cluster Resolution", 1024, 768);
+  cOut->Divide(3,2, 2.e-3, 2.e-3);
+  arr = (TObjArray*)fProj->At(kCluster);
+  for(Int_t iplot(0); iplot<fgNproj[kCluster]; iplot++){
+    p=cOut->cd(iplot+1);    p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712);
+    ((TH2*)arr->At(iplot))->Draw("colz");
+  }
   cOut->SaveAs(Form("%s.gif", cOut->GetName()));
 
-  if(!HasMCdata() ||
-    (!fGraphS->At(kMCcluster) || !fGraphM->At(kMCcluster) ||
-     !fGraphS->At(kMCtracklet) || !fGraphM->At(kMCtracklet))){
-    delete cOut;
-    return;
-  }
-  cOut->Clear(); cOut->SetName(Form("TRDsummary%s_%d", GetName(), iSumPlot++));
-  cOut->Divide(3, 2, 2.e-3, 2.e-3, kBlue-10);
-
-  p=cOut->cd(1);  
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetTitle(Form("Cluster-MC R-Phi Resolution;tg(#phi);%s;Sigma [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphS->At(kMCcluster))->At(0), h2);
-  GetRange(h2, 1, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(2);  
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetContour(7);
-  h2->SetTitle(Form("Cluster-MC R-Phi Systematics;tg(#phi);%s;Mean [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphM->At(kMCcluster))->At(0), h2);
-  GetRange(h2, 0, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(3); 
-  p->SetRightMargin(0.06);p->SetTopMargin(0.06);
-  xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-  if(!GetGraphArray(xy, kMCcluster, 1, 1)) AliWarning("Missing MC cluster plot.");
-
-  p=cOut->cd(4); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetContour(7);
-  h2->SetTitle(Form("Tracklet-MC R-Phi Resolution;tg(#phi);%s;Sigma [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphS->At(kMCtracklet))->At(0), h2);
-  GetRange(h2, 1, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(5); 
-  p->SetRightMargin(0.16);p->SetTopMargin(0.06);
-  h2=(TH2I*)h2->Clone(Form("h2SF_%d", ih2++));
-  h2->SetContour(7);
-  h2->SetTitle(Form("Tracklet-MC R-Phi Systematics;tg(#phi);%s;Mean [#mum]", fgkResYsegmName[fSegmentLevel]));
-  MakeSummaryPlot((TObjArray*)  ((TObjArray*)fGraphM->At(kMCtracklet))->At(0), h2);
-  GetRange(h2, 0, range);
-  h2->GetZaxis()->SetRangeUser(range[0], range[1]);
-  h2->Draw("colz");
-  h2->SetContour(7);
-
-  p=cOut->cd(6); 
-  p->SetRightMargin(0.06);p->SetTopMargin(0.06);
-  xy[0]=-.5; xy[1]=-0.5; xy[2]=fgkNresYsegm[fSegmentLevel]-.5; xy[3]=2.5;
-  if(!GetGraphArray(xy, kMCtracklet, 1, 1)){
-    AliWarning("Failed retrieve tracklet resolution plot.");
-  }
 
+  // trackIn systematic
+  // define palette
+  Int_t palette[50];
+  for (int i=1;i<49;i++) palette[i] = 50+i; palette[0]=kMagenta; palette[49]=kBlack;
+  gStyle->SetPalette(50, palette);
+  cOut = new TCanvas(Form("TRDsummary%s_%d", GetName(), iSumPlot++), "Track IN Resolution", 1024, 768);
+  cOut->Divide(3,2, 2.e-3, 2.e-3);
+  arr = (TObjArray*)fProj->At(kTrackIn); 
+  for(Int_t iplot(0); iplot<fgNproj[kTrackIn]; iplot++){
+    p=cOut->cd(iplot+1);    p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712);
+    ((TH2*)arr->At(iplot))->Draw("colz");
+  }
   cOut->SaveAs(Form("%s.gif", cOut->GetName()));
+
   delete cOut;
+  gStyle->SetPalette(1);
 }
 
 //________________________________________________________
@@ -2042,121 +1016,225 @@ void AliTRDresolution::GetRange(TH2 *h2, Char_t mod, Float_t *range)
   return;
 }
 
+
 //________________________________________________________
-void AliTRDresolution::MakeSummaryPlot(TObjArray *a, TH2 *h2)
+Bool_t AliTRDresolution::MakeProjectionCluster()
 {
-// Core functionality for MakeSummary function.  
-
-  h2->Reset();  
-  Double_t x,y;
-  TGraphErrors *g(NULL); TAxis *ax(h2->GetXaxis());
-  for(Int_t iseg(0); iseg<fgkNresYsegm[fSegmentLevel]; iseg++){
-    g=(TGraphErrors*)a->At(iseg);
-    for(Int_t in(0); in<g->GetN(); in++){
-      g->GetPoint(in, x, y);
-      h2->SetBinContent(ax->FindBin(x), iseg+1, y);
+// Analyse cluster
+  Int_t cidx = kCluster;
+  if(fProj && fProj->At(cidx)) return kTRUE;
+  if(!fContainer){
+    AliError("Missing data container.");
+    return kFALSE;
+  }
+  THnSparse *H(NULL);
+  if(!(H = (THnSparse*)fContainer->At(cidx))){
+    AliError(Form("Missing/Wrong data @ %d.", cidx));
+    return kFALSE;
+  }
+
+  TAxis *aphi(H->GetAxis(kPhi)),
+        *aeta(H->GetAxis(kEta)),
+        *as(H->GetAxis(kSpeciesChgRC)),
+        //*apt(H->GetAxis(kPt)),
+        *ay(H->GetAxis(kYrez));
+        //*az(H->GetAxis(kZrez)),
+        //*ap(H->GetAxis(kPrez));
+  Int_t neta(aeta->GetNbins()), nphi(aphi->GetNbins()), rcBin(as->GetNbins()/2 + 1);
+  TH3I *h3[fgNproj[cidx]];
+  for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
+    h3[ily] = new TH3I(Form("h3CL%d", ily), Form("r-#phi residuals @ ly[%d];%s;%s;%s", ily, aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
+           neta, aeta->GetXmin(), aeta->GetXmax(),
+           nphi, aphi->GetXmin(), aphi->GetXmax(),
+           ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
+  }
+  Int_t  coord[AliTRDresolution::kNdim]; memset(coord, 0, sizeof(Int_t) * AliTRDresolution::kNdim); Double_t v = 0.;
+  for (Long64_t ib(0); ib < H->GetNbins(); ib++) {
+    v = H->GetBinContent(ib, coord);
+    if(v<1.) continue;
+    if(coord[kSpeciesChgRC]==rcBin) continue; // row cross
+    Int_t ily(coord[kBC]-1);
+    h3[ily]->AddBinContent(h3[ily]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
+  }
+
+  TF1 fg("fg", "gaus", ay->GetXmin(), ay->GetXmax());
+  if(!fProj){
+    AliInfo("Building array of projections ...");
+    fProj = new TObjArray(kNclasses); fProj->SetOwner(kTRUE);
+  }
+  TObjArray *arr(NULL);
+  fProj->AddAt(arr = new TObjArray(fgNproj[cidx]), cidx);
+
+  TH2F *h2(NULL);
+  for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
+    arr->AddAt(h2 = new TH2F(Form("h2CLs%d", ily),
+            Form("Cl Resolution Ly[%d];%s;%s;#sigmay [#mum]", ily, aeta->GetTitle(), aphi->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax()), ily);
+    TAxis *ax = h2->GetZaxis();
+    ax->CenterTitle(); ax->SetTitleOffset(1.3);
+    ax->SetRangeUser(250, 500);
+    for(Int_t iphi(1); iphi<=nphi; iphi++){
+      for(Int_t ieta(1); ieta<=neta; ieta++){
+        TH1 *h = h3[ily]->ProjectionZ(Form("h1CLs%d", ily), ieta, ieta, iphi, iphi);
+        Int_t ne(h->GetEntries());
+        if(ne<100.) h2->SetBinContent(ieta, iphi, -999);
+        else {
+          fg.SetParameter(0, ne);fg.SetParameter(1, 0.);fg.SetParameter(2, 0.05);
+          h->Fit(&fg, "QW0");
+          Float_t val=TMath::Max(250., 1.e4*fg.GetParameter(2));
+          h2->SetBinContent(ieta, iphi, val);
+        }
+      }
     }
   }
+  for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++) delete h3[iproj];
+  return kTRUE;
 }
 
+//________________________________________________________
+Bool_t AliTRDresolution::MakeProjectionTracklet()
+{
+// Analyse tracklet
+  return kTRUE;
+  Int_t cidx = kTracklet;
+  if(fProj && fProj->At(cidx)) return kTRUE;
+  if(!fContainer){
+    AliError("Missing data container.");
+    return kFALSE;
+  }
+  THnSparse *H(NULL);
+  if(!(H = (THnSparse*)fContainer->At(cidx))){
+    AliError(Form("Missing/Wrong data @ %d.", cidx));
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
 
 //________________________________________________________
-Bool_t AliTRDresolution::PostProcess()
+Bool_t AliTRDresolution::MakeProjectionTrackIn()
 {
-// Fit, Project, Combine, Extract values from the containers filled during execution
+// Analyse track in
 
-  /*fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));*/
-  if (!fContainer) {
-    AliError("ERROR: list not available");
+  Int_t cidx = kTrackIn;
+  if(fProj && fProj->At(cidx)) return kTRUE;
+  if(!fContainer){
+    AliError("Missing data container.");
+    return kFALSE;
+  }
+  THnSparse *H(NULL);
+  if(!(H = (THnSparse*)fContainer->At(cidx))){
+    AliError(Form("Missing/Wrong data @ %d.", Int_t(cidx)));
     return kFALSE;
   }
 
-  // define general behavior parameters
-  const Color_t fgColorS[11]={
-  kOrange, kOrange-3, kMagenta+1, kViolet, kRed,
-  kGray,
-  kRed, kViolet, kMagenta+1, kOrange-3, kOrange
-  };
-  const Color_t fgColorM[11]={
-  kCyan-5, kAzure-4, kBlue-7, kBlue+2, kViolet+10,
-  kBlack,
-  kViolet+10, kBlue+2, kBlue-7, kAzure-4, kCyan-5
-  };
-  const Marker_t fgMarker[11]={
-  30, 30, 26, 25, 24,
-  28,
-  20, 21, 22, 29, 29
-  };
-
-  TGraph *gm= NULL, *gs= NULL;
-  if(!fGraphS && !fGraphM){ 
-    TObjArray *aM(NULL), *aS(NULL);
-    Int_t n = fContainer->GetEntriesFast();
-    fGraphS = new TObjArray(n); fGraphS->SetOwner();
-    fGraphM = new TObjArray(n); fGraphM->SetOwner();
-    for(Int_t ig(0), nc(0); ig<n; ig++){
-      fGraphM->AddAt(aM = new TObjArray(fgNproj[ig]), ig);
-      fGraphS->AddAt(aS = new TObjArray(fgNproj[ig]), ig);
-      
-      for(Int_t ic=0; ic<fgNproj[ig]; ic++, nc++){
-        AliDebug(2, Form("building G[%d] P[%d] N[%d]", ig, ic, fNcomp[nc]));
-        if(fNcomp[nc]>1){
-          TObjArray *agS(NULL), *agM(NULL);
-          aS->AddAt(agS = new TObjArray(fNcomp[nc]), ic); 
-          aM->AddAt(agM = new TObjArray(fNcomp[nc]), ic); 
-          for(Int_t is=fNcomp[nc]; is--;){
-            agS->AddAt(gs = new TGraphErrors(), is);
-            Int_t is0(is%11), il0(is/11);
-            gs->SetMarkerStyle(fgMarker[is0]);
-            gs->SetMarkerColor(fgColorS[is0]);
-            gs->SetLineColor(fgColorS[is0]);
-            gs->SetLineStyle(il0);gs->SetLineWidth(2);
-            gs->SetName(Form("s_%d_%02d_%02d", ig, ic, is));
-
-            agM->AddAt(gm = new TGraphErrors(), is);
-            gm->SetMarkerStyle(fgMarker[is0]);
-            gm->SetMarkerColor(fgColorM[is0]);
-            gm->SetLineColor(fgColorM[is0]);
-            gm->SetLineStyle(il0);gm->SetLineWidth(2);
-            gm->SetName(Form("m_%d_%02d_%02d", ig, ic, is));
-            // this is important for labels in the legend 
-            if(ic==0) {
-              gs->SetTitle(Form("%s %02d", fgkResYsegmName[fSegmentLevel], is%fgkNresYsegm[fSegmentLevel]));
-              gm->SetTitle(Form("%s %02d", fgkResYsegmName[fSegmentLevel], is%fgkNresYsegm[fSegmentLevel]));
-            } else if(ic==1) {
-              gs->SetTitle(Form("%s Ly[%d]", is%2 ?"z":"y", is/2));
-              gm->SetTitle(Form("%s Ly[%d]", is%2?"z":"y", is/2));
-            } else if(ic==2||ic==3) {
-              gs->SetTitle(Form("%s Ly[%d]", is%2 ?"RC":"no RC", is/2));
-              gm->SetTitle(Form("%s Ly[%d]", is%2?"RC":"no RC", is/2));
-            } else if(ic<=7) {
-              gs->SetTitle(Form("Layer[%d]", is%AliTRDgeometry::kNlayer));
-              gm->SetTitle(Form("Layer[%d]", is%AliTRDgeometry::kNlayer));
-            } else {
-              gs->SetTitle(Form("%s @ ly[%d]", fgParticle[is0], il0));
-              gm->SetTitle(Form("%s @ ly[%d]", fgParticle[is0], il0));
-            }
-          }
-        } else {
-          aS->AddAt(gs = new TGraphErrors(), ic);
-          gs->SetMarkerStyle(23);
-          gs->SetMarkerColor(kRed);
-          gs->SetLineColor(kRed);
-          gs->SetNameTitle(Form("s_%d_%02d", ig, ic), "sigma");
-  
-          aM->AddAt(gm = ig ? (TGraph*)new TGraphErrors() : (TGraph*)new TGraphAsymmErrors(), ic);
-          gm->SetLineColor(kBlack);
-          gm->SetMarkerStyle(7);
-          gm->SetMarkerColor(kBlack);
-          gm->SetNameTitle(Form("m_%d_%02d", ig, ic), "mean");
-        }
+  Int_t  coord[kNdim]; memset(coord, 0, sizeof(Int_t) * kNdim); Double_t v = 0.;
+  TAxis //*abc(H->GetAxis(kBC)),
+        *aphi(H->GetAxis(kPhi)),
+        *aeta(H->GetAxis(kEta)),
+        //*as(H->GetAxis(kSpeciesChgRC)),
+        //*apt(H->GetAxis(kPt)),
+        *ay(H->GetAxis(kYrez)),
+        *az(H->GetAxis(kZrez)),
+        *ap(H->GetAxis(kPrez));
+  Int_t neta(aeta->GetNbins()), nphi(aphi->GetNbins());
+  TH3I *h3[fgNproj[cidx]];
+  h3[0] = new TH3I("h3TI0", Form("r-#phi residuals for neg tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
+  h3[1] = (TH3I*)h3[0]->Clone("h3TI1"); h3[1]->SetTitle("r-#phi residuals for pos tracks");
+  h3[2] = new TH3I("h3TI2", Form("z residuals for row cross;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), az->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            az->GetNbins(), az->GetXmin(), az->GetXmax());
+  h3[3] = new TH3I("h3TI3", Form("angular residuals for neg tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ap->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax(),
+            ap->GetNbins(), ap->GetXmin(), ap->GetXmax());
+  h3[4] = (TH3I*)h3[3]->Clone("h3TI4"); h3[4]->SetTitle("angular residuals for pos tracks");
+  for (Long64_t ib(0); ib < H->GetNbins(); ib++) {
+    v = H->GetBinContent(ib, coord);
+    if(v<1.) continue;
+    if(coord[kBC]>1) continue; // bunch cross cut
+    // species selection
+    if(coord[kSpeciesChgRC]<6){
+      h3[0]->AddBinContent(
+        h3[0]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
+      h3[3]->AddBinContent(
+        h3[3]->GetBin(coord[kEta], coord[kPhi], coord[kPrez]), v);
+    } else if(coord[kSpeciesChgRC]==6) {
+      h3[2]->AddBinContent(
+        h3[2]->GetBin(coord[kEta], coord[kPhi], coord[kZrez]), v);
+    } else if(coord[kSpeciesChgRC]>6) {
+      h3[1]->AddBinContent(
+        h3[1]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
+      h3[4]->AddBinContent(
+        h3[4]->GetBin(coord[kEta], coord[kPhi], coord[kPrez]), v);
+    }
+  }
+  if(!fProj){
+    AliInfo("Building array of projections ...");
+    fProj = new TObjArray(kNclasses); fProj->SetOwner(kTRUE);
+  }
+  TObjArray *arr(NULL);
+  fProj->AddAt(arr = new TObjArray(fgNproj[cidx]), cidx);
+
+  TH2F *h2(NULL);
+  for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++){
+    TAxis *ax(h3[iproj]->GetZaxis());
+    Float_t zm(ax->GetXmin()/3.), zM(ax->GetXmax()/3.), dz=(zM-zm)/50;
+    arr->AddAt(h2 = new TH2F(Form("h2TI%d", iproj),
+            Form("%s;%s;%s;%s", h3[iproj]->GetTitle(), aeta->GetTitle(), aphi->GetTitle(), ax->GetTitle()),
+            neta, aeta->GetXmin(), aeta->GetXmax(),
+            nphi, aphi->GetXmin(), aphi->GetXmax()), iproj);
+    h2->SetContour(50);
+    h2->GetZaxis()->CenterTitle();
+    h2->GetZaxis()->SetRangeUser(zm, zM);
+    zm+=dz; zM-=dz;
+    for(Int_t iphi(1); iphi<=nphi; iphi++){
+      for(Int_t ieta(1); ieta<=neta; ieta++){
+        TH1 *h = h3[iproj]->ProjectionZ(Form("hy%d", iproj), ieta, ieta, iphi, iphi);
+        h2->SetBinContent(ieta, iphi, GetMeanWithBoundary(h, zm, zM, dz));
       }
     }
   }
+//   h2[5] = (TH2F*)h2[0]->Clone("h25");
+//   h2[5]->SetTitle("Systematic shift between neg/pos tracks");
+//   h2[5]->SetZTitle("#Delta(#Delta^{-}y - #Delta^{+}y) [cm]"); h2[5]->Reset();
+//   h2[6] = (TH2F*)h2[1]->Clone("h26");
+//   h2[6]->SetTitle("Average shift of pos&neg tracks");
+//   h2[6]->SetZTitle("<#Delta^{-}y, #Delta^{+}y> [cm]"); h2[6]->Reset();
+//   for(Int_t iphi(1); iphi<=nphi; iphi++){
+//     for(Int_t ieta(1); ieta<=neta; ieta++){
+//       Float_t neg = h2[0]->GetBinContent(ieta, iphi),
+//               pos = h2[1]->GetBinContent(ieta, iphi);
+//       if(neg<-100 || pos<-100){
+//         h2[5]->SetBinContent(ieta, iphi, -999.);
+//         h2[6]->SetBinContent(ieta, iphi, -999.);
+//       } else {
+//         h2[5]->SetBinContent(ieta, iphi, neg-pos);
+//         h2[6]->SetBinContent(ieta, iphi, 0.5*(neg+pos));
+//       }
+//     }
+//   }
+
+  for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++) delete h3[iproj];
+  return kTRUE;
+}
 
-/*  printf("\n\n\n"); fGraphS->ls();
-  printf("\n\n\n"); fGraphM->ls();*/
-  
+
+
+//________________________________________________________
+Bool_t AliTRDresolution::PostProcess()
+{
+// Fit, Project, Combine, Extract values from the containers filled during execution
+
+  if (!fContainer) {
+    AliError("ERROR: list not available");
+    return kFALSE;
+  }
 
   // DEFINE MODELS
   // simple gauss
@@ -2167,32 +1245,17 @@ Bool_t AliTRDresolution::PostProcess()
   TF1 fpt("fPt", "landau", -0.1, 0.2);  
 
   //PROCESS EXPERIMENTAL DISTRIBUTIONS
-  // Charge resolution
-  //Process3DL(kCharge, 0, &fl); 
   // Clusters residuals
-  Process3D(kCluster, 0, &fg, 1.e4); 
-  Process3Dlinked(kCluster, 1, &fg); 
+  if(!MakeProjectionCluster()) return kFALSE;
   fNRefFigures = 3;
   // Tracklet residual/pulls
-  Process3D(kTrack , 0, &fg, 1.e4);
-  Process3Dlinked(kTrack , 1, &fg); 
-  Process3D(kTrack , 2, &fg, 1.e4); 
-  Process3D(kTrack , 3, &fg); 
-  Process2D(kTrack , 4, &fg, 1.e3);
+  if(!MakeProjectionTracklet()) return kFALSE;
   fNRefFigures = 7;
   // TRDin residual/pulls
-  Process3D(kTrackIn, 0, &fg, 1.e4); 
-  Process3Dlinked(kTrackIn, 1, &fg); 
-  Process3D(kTrackIn, 2, &fg, 1.e4); 
-  Process3D(kTrackIn, 3, &fg); 
-  Process2D(kTrackIn, 4, &fg, 1.e3); 
+  if(!MakeProjectionTrackIn()) return kFALSE;
   fNRefFigures = 11;
   // TRDout residual/pulls
-  Process3D(kTrackOut, 0, &fg, 1.e3); // scale to fit - see PlotTrackOut
-  Process3Dlinked(kTrackOut, 1, &fg); 
-  Process3D(kTrackOut, 2, &fg, 1.e4); 
-  Process3D(kTrackOut, 3, &fg); 
-  Process2D(kTrackOut, 4, &fg, 1.e3); 
+//  if(!MakeProjectionTrackOut()) return kFALSE;
   fNRefFigures = 15;
 
   if(!HasMCdata()) return kTRUE;
@@ -2201,20 +1264,15 @@ Bool_t AliTRDresolution::PostProcess()
   //PROCESS MC RESIDUAL DISTRIBUTIONS
 
   // CLUSTER Y RESOLUTION/PULLS
-  Process3D(kMCcluster, 0, &fg, 1.e4);
-  Process3Dlinked(kMCcluster, 1, &fg, 1.);
+//  if(!MakeProjectionClusterMC()) return kFALSE;
   fNRefFigures = 17;
 
   // TRACKLET RESOLUTION/PULLS
-  Process3D(kMCtracklet, 0, &fg, 1.e4); // y
-  Process3Dlinked(kMCtracklet, 1, &fg, 1.);   // y pulls
-  Process3D(kMCtracklet, 2, &fg, 1.e4); // z
-  Process3D(kMCtracklet, 3, &fg, 1.);   // z pulls
-  Process2D(kMCtracklet, 4, &fg, 1.e3); // phi
+//  if(!MakeProjectionTrackletMC()) return kFALSE;
   fNRefFigures = 21;
 
   // TRACK RESOLUTION/PULLS
-  Process3Darray(kMCtrack, 0, &fg, 1.e4);   // y
+/*  Process3Darray(kMCtrack, 0, &fg, 1.e4);   // y
   Process3DlinkedArray(kMCtrack, 1, &fg);   // y PULL
   Process3Darray(kMCtrack, 2, &fg, 1.e4);   // z
   Process3Darray(kMCtrack, 3, &fg);         // z PULL
@@ -2224,35 +1282,16 @@ Bool_t AliTRDresolution::PostProcess()
   Process2Darray(kMCtrack, 7, &fg);         // tgl PULL
   Process3Darray(kMCtrack, 8, &fg, 1.e2);   // pt resolution
   Process3Darray(kMCtrack, 9, &fg);         // 1/pt pulls
-  Process3Darray(kMCtrack, 10, &fg, 1.e2);  // p resolution
+  Process3Darray(kMCtrack, 10, &fg, 1.e2);  // p resolution*/
+//  if(!MakeProjectionTrackMC(kMCtrack)) return kFALSE;
   fNRefFigures+=16;
 
   // TRACK TRDin RESOLUTION/PULLS
-  Process3D(kMCtrackIn, 0, &fg, 1.e4);// y resolution
-  Process3Dlinked(kMCtrackIn, 1, &fg);      // y pulls
-  Process3D(kMCtrackIn, 2, &fg, 1.e4);// z resolution
-  Process3D(kMCtrackIn, 3, &fg);      // z pulls
-  Process2D(kMCtrackIn, 4, &fg, 1.e3);// phi resolution
-  Process2D(kMCtrackIn, 5, &fg);      // snp pulls
-  Process2D(kMCtrackIn, 6, &fg, 1.e3);// theta resolution
-  Process2D(kMCtrackIn, 7, &fg);      // tgl pulls
-  Process3D(kMCtrackIn, 8, &fg, 1.e2);// pt resolution
-  Process3D(kMCtrackIn, 9, &fg);      // 1/pt pulls
-  Process3D(kMCtrackIn, 10, &fg, 1.e2);// p resolution
+//  if(!MakeProjectionTrackMC(kMCtrackIn)) return kFALSE;
   fNRefFigures+=8;
 
   // TRACK TRDout RESOLUTION/PULLS
-  Process3D(kMCtrackOut, 0, &fg, 1.e4);// y resolution
-  Process3Dlinked(kMCtrackOut, 1, &fg);      // y pulls
-  Process3D(kMCtrackOut, 2, &fg, 1.e4);// z resolution
-  Process3D(kMCtrackOut, 3, &fg);      // z pulls
-  Process2D(kMCtrackOut, 4, &fg, 1.e3);// phi resolution
-  Process2D(kMCtrackOut, 5, &fg);      // snp pulls
-  Process2D(kMCtrackOut, 6, &fg, 1.e3);// theta resolution
-  Process2D(kMCtrackOut, 7, &fg);      // tgl pulls
-  Process3D(kMCtrackOut, 8, &fg, 1.e2);// pt resolution
-  Process3D(kMCtrackOut, 9, &fg);      // 1/pt pulls
-  Process3D(kMCtrackOut, 10, &fg, 1.e2);// p resolution
+//  if(!MakeProjectionTrackMC(kMCtrackOut)) return kFALSE;
   fNRefFigures+=8;
 
   return kTRUE;
@@ -2308,10 +1347,10 @@ TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool
 
   // tracklet resolution/pull in y direction
   snprintf(hname, 100, "%s_%s_Y", GetNameId(), name);
-  snprintf(htitle, 300, "Y res for \"%s\" @ %s;tg(#phi);#Delta y [cm];%s", GetNameId(), name, fgkResYsegmName[fSegmentLevel]);
+  snprintf(htitle, 300, "Y res for \"%s\" @ %s;tg(#phi);#Delta y [cm];%s", GetNameId(), name, "Detector");
   Float_t rr = range<0.?fDyRange:range;
   if(!(h = (TH3S*)gROOT->FindObject(hname))){
-    Int_t nybins=fgkNresYsegm[fSegmentLevel];
+    Int_t nybins=50;
     if(expand) nybins*=2;
     h = new TH3S(hname, htitle, 
                  48, -.48, .48,            // phi
@@ -2320,9 +1359,9 @@ TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool
   } else h->Reset();
   arr->AddAt(h, 0);
   snprintf(hname, 100, "%s_%s_YZpull", GetNameId(), name);
-  snprintf(htitle, 300, "YZ pull for \"%s\" @ %s;%s;#Delta y  / #sigma_{y};#Delta z  / #sigma_{z}", GetNameId(), name, fgkResYsegmName[fSegmentLevel]);
+  snprintf(htitle, 300, "YZ pull for \"%s\" @ %s;%s;#Delta y  / #sigma_{y};#Delta z  / #sigma_{z}", GetNameId(), name, "Detector");
   if(!(h = (TH3S*)gROOT->FindObject(hname))){
-    h = new TH3S(hname, htitle, fgkNresYsegm[fSegmentLevel], -0.5, fgkNresYsegm[fSegmentLevel]-0.5, 100, -4.5, 4.5, 100, -4.5, 4.5);
+    h = new TH3S(hname, htitle, 540, -0.5, 540-0.5, 100, -4.5, 4.5, 100, -4.5, 4.5);
   } else h->Reset();
   arr->AddAt(h, 1);
 
@@ -2358,8 +1397,8 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTracklet(const char* name, Boo
 
   // tracklet to track phi resolution
   snprintf(hname, 100, "%s_%s_PHI", GetNameId(), name);
-  snprintf(htitle, 300, "#Phi res for \"%s\" @ %s;tg(#phi);#Delta #phi [rad];%s", GetNameId(), name, fgkResYsegmName[fSegmentLevel]);
-  Int_t nsgms=fgkNresYsegm[fSegmentLevel];
+  snprintf(htitle, 300, "#Phi res for \"%s\" @ %s;tg(#phi);#Delta #phi [rad];%s", GetNameId(), name, "Detector");
+  Int_t nsgms=540;
   if(!(h = (TH3S*)gROOT->FindObject(hname))){
     h = new TH3S(hname, htitle, 48, -.48, .48, 100, -.5, .5, nsgms, -0.5, nsgms-0.5);
   } else h->Reset();
@@ -2406,7 +1445,6 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTrack(const char* name)
   } else h->Reset();
   arr->AddAt(h, 7);
   
-  const Int_t kNpt(14);
   const Int_t kNdpt(150); 
   const Int_t kNspc = 2*AliPID::kSPECIES+1;
   Float_t lPt=0.1, lDPt=-.1, lSpc=-5.5;
@@ -2422,7 +1460,7 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTrack(const char* name)
     h = new TH3S(hname, htitle, 
                  kNpt, binsPt, kNdpt, binsDPt, kNspc, binsSpc);
     ax = h->GetZaxis();
-    for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
+    //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
   } else h->Reset();
   arr->AddAt(h, 8);
   // 1/Pt pulls
@@ -2432,7 +1470,7 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTrack(const char* name)
     h = new TH3S(hname, htitle, 
                  kNpt, 0., 2., 100, -4., 4., kNspc, -5.5, 5.5);
     ax = h->GetZaxis();
-    for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
+    //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
   } else h->Reset();
   arr->AddAt(h, 9);
   // P resolution
@@ -2442,7 +1480,7 @@ TObjArray* AliTRDresolution::BuildMonitorContainerTrack(const char* name)
     h = new TH3S(hname, htitle, 
                  kNpt, binsPt, kNdpt, binsDPt, kNspc, binsSpc);
     ax = h->GetZaxis();
-    for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
+    //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
   } else h->Reset();
   arr->AddAt(h, 10);
 
@@ -2459,36 +1497,45 @@ TObjArray* AliTRDresolution::Histos()
 
   if(fContainer) return fContainer;
 
-  fContainer  = new TObjArray(kNviews);
-  fContainer->SetOwner(kTRUE);
-  TH1 *h(NULL);
-  TObjArray *arr(NULL);
-
-  // binnings for plots containing momentum or pt
-  const Int_t kNpt(14), kNphi(48), kNdy(60);
-  Float_t lPhi=-.48, lDy=-.3, lPt=0.1;
-  Float_t binsPhi[kNphi+1], binsDy[kNdy+1], binsPt[kNpt+1];
-  for(Int_t i=0; i<kNphi+1; i++,lPhi+=.02) binsPhi[i]=lPhi;
-  for(Int_t i=0; i<kNdy+1; i++,lDy+=.01) binsDy[i]=lDy;
-  for(Int_t i=0;i<kNpt+1; i++,lPt=TMath::Exp(i*.15)-1.) binsPt[i]=lPt;
-
-  // cluster to track residuals/pulls
-  fContainer->AddAt(arr = new TObjArray(2), kCharge);
-  arr->SetName("Charge");
-  if(!(h = (TH3S*)gROOT->FindObject("hCharge"))){
-    h = new TH3S("hCharge", "Charge Resolution", 20, 1., 2., 24, 0., 3.6, 100, 0., 500.);
-    h->GetXaxis()->SetTitle("dx/dx_{0}");
-    h->GetYaxis()->SetTitle("x_{d} [cm]");
-    h->GetZaxis()->SetTitle("dq/dx [ADC/cm]");
-  } else h->Reset();
-  arr->AddAt(h, 0);
+  fContainer  = new TObjArray(kNclasses); fContainer->SetOwner(kTRUE);
+  THnSparse *H(NULL);
+  const Int_t nhn(100); Char_t hn[nhn]; TString st;
 
+  //++++++++++++++++++++++
   // cluster to track residuals/pulls
-  fContainer->AddAt(BuildMonitorContainerCluster("Cl"), kCluster);
+  snprintf(hn, nhn, "h%s", fgPerformanceName[kCluster]);
+  if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
+    const Char_t *clTitle[kNdim] = {"layer", fgkTitle[kPhi], fgkTitle[kEta], "chg*Q/vd/angle", "#Phi^{*} - ExB [deg]", fgkTitle[kYrez], "#Deltax [cm]", "Q</Q"};
+    const Int_t clNbins[kNdim]   = {AliTRDgeometry::kNlayer, fgkNbins[kPhi], fgkNbins[kEta], 51, 30, fgkNbins[kYrez], 33, 10};
+    const Double_t clMin[kNdim]  = {-0.5, fgkMin[kPhi], fgkMin[kEta], -102., -30, 0.3*fgkMin[kYrez], 0., 0.1},
+                   clMax[kNdim]  = {AliTRDgeometry::kNlayer-0.5, fgkMax[kPhi], fgkMax[kEta], 102., 30, 0.3*fgkMax[kYrez], 3.3, 2.1};
+    st = "cluster spatial&charge resolution;";
+    for(Int_t idim(0); idim<kNdim; idim++){ st += clTitle[idim]; st+=";";}
+    H = new THnSparseI(hn, st.Data(), kNdim, clNbins, clMin, clMax);
+  } else H->Reset();
+  fContainer->AddAt(H, kCluster);
+  //++++++++++++++++++++++
   // tracklet to TRD track
-  fContainer->AddAt(BuildMonitorContainerTracklet("Trk", kTRUE), kTrack);
+  snprintf(hn, nhn, "h%s", fgPerformanceName[kTracklet]);
+  if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
+    const Char_t *trTitle[kNdim+1] = {"layer", fgkTitle[kPhi], fgkTitle[kEta], fgkTitle[kSpeciesChgRC], fgkTitle[kPt], fgkTitle[kYrez], "#Deltaz [cm]/#Phi^{*} - ExB [rad]", fgkTitle[kPrez], "dq/dl [a.u.]"};
+    const Int_t trNbins[kNdim+1]   = {AliTRDgeometry::kNlayer, fgkNbins[kPhi], fgkNbins[kEta], fgkNbins[kSpeciesChgRC], fgkNbins[kPt], fgkNbins[kYrez], fgkNbins[kZrez], fgkNbins[kPrez], 30};
+    const Double_t trMin[kNdim+1]  = {-0.5, fgkMin[kPhi], fgkMin[kEta], fgkMin[kSpeciesChgRC], fgkMin[kPt], fgkMin[kYrez], fgkMin[kZrez], fgkMin[kPrez], 0.},
+                   trMax[kNdim+1]  = {AliTRDgeometry::kNlayer-0.5, fgkMax[kPhi], fgkMax[kEta], fgkMax[kSpeciesChgRC], fgkMax[kPt], fgkMax[kYrez], fgkMax[kZrez], fgkMax[kPrez], 3000.};
+    st = "tracklet spatial&charge resolution;";
+    for(Int_t idim(0); idim<kNdim+1; idim++){ st += trTitle[idim]; st+=";";}
+    H = new THnSparseI(hn, st.Data(), kNdim+1, trNbins, trMin, trMax);
+  } else H->Reset();
+  fContainer->AddAt(H, kTracklet);
+  //++++++++++++++++++++++
   // tracklet to TRDin
-  fContainer->AddAt(BuildMonitorContainerTracklet("TrkIN", kTRUE), kTrackIn);
+  snprintf(hn, nhn, "h%s", fgPerformanceName[kTrackIn]);
+  if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
+    st = "r-#phi/z/angular residuals @ TRD entry;";
+    for(Int_t idim(0); idim<kNdim; idim++){ st += fgkTitle[idim]; st+=";";}
+    H = new THnSparseI(hn, st.Data(), kNdim, fgkNbins, fgkMin, fgkMax);
+  } else H->Reset();
+  fContainer->AddAt(H, kTrackIn);
   // tracklet to TRDout
   fContainer->AddAt(BuildMonitorContainerTracklet("TrkOUT"), kTrackOut);
 
@@ -2503,12 +1550,13 @@ TObjArray* AliTRDresolution::Histos()
   fContainer->AddAt(BuildMonitorContainerTracklet("MCtracklet"), kMCtracklet);
 
   // track resolution
+  TObjArray *arr(NULL);
   fContainer->AddAt(arr = new TObjArray(AliTRDgeometry::kNlayer), kMCtrack);
   arr->SetName("MCtrk");
   for(Int_t il(0); il<AliTRDgeometry::kNlayer; il++) arr->AddAt(BuildMonitorContainerTrack(Form("MCtrk_Ly%d", il)), il);
 
   // TRDin TRACK RESOLUTION
-  fContainer->AddAt(BuildMonitorContainerTrack("MCtrkIN"), kMCtrackIn);
+  fContainer->AddAt(H, kMCtrackIn);
 
   // TRDout TRACK RESOLUTION
   fContainer->AddAt(BuildMonitorContainerTrack("MCtrkOUT"), kMCtrackOut);
@@ -2517,31 +1565,6 @@ TObjArray* AliTRDresolution::Histos()
 }
 
 //________________________________________________________
-Bool_t AliTRDresolution::Load(const Char_t *file, const Char_t *dir)
-{
-// Custom load function. Used to guess the segmentation level of the data.
-
-  if(!AliTRDrecoTask::Load(file, dir)) return kFALSE;
-
-  // look for cluster residual plot - always available
-  TH3S* h3((TH3S*)((TObjArray*)fContainer->At(kClToTrk))->At(0));
-  Int_t segmentation(h3->GetNbinsZ()/2);
-  if(segmentation==fgkNresYsegm[0]){ // default segmentation. Nothing to do
-    return kTRUE;
-  } else if(segmentation==fgkNresYsegm[1]){ // stack segmentation.
-    SetSegmentationLevel(1);
-  } else if(segmentation==fgkNresYsegm[2]){ // detector segmentation.
-    SetSegmentationLevel(2);
-  } else {
-    AliError(Form("Unknown segmentation [%d].", h3->GetNbinsZ()));
-    return kFALSE;
-  }
-
-  AliDebug(2, Form("Segmentation set to level \"%s\"", fgkResYsegmName[fSegmentLevel]));
-  return kTRUE;
-}
-
-//________________________________________________________
 Bool_t AliTRDresolution::Process(TH2* const h2, TGraphErrors **g, Int_t stat)
 {
 // Robust function to process sigma/mean for 2D plot dy(x)
@@ -2660,444 +1683,6 @@ Bool_t AliTRDresolution::Process(TH2 * const h2, TF1 *f, Float_t k, TGraphErrors
   return kTRUE;
 }
 
-//________________________________________________________
-Bool_t AliTRDresolution::Process2D(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k, Int_t gidx)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-
-  // retrive containers
-  TH2I *h2(NULL);
-  if(idx<0){
-    if(!(h2= (TH2I*)(fContainer->At(plot)))) return kFALSE; 
-  } else{
-    TObjArray *a0(NULL);
-    if(!(a0=(TObjArray*)(fContainer->At(plot)))) return kFALSE;
-    if(!(h2=(TH2I*)a0->At(idx))) return kFALSE;
-  }
-  if(Int_t(h2->GetEntries())){ 
-    AliDebug(2, Form("p[%d] idx[%d] : h[%s] %s", plot, idx, h2->GetName(), h2->GetTitle()));
-  } else {
-    AliDebug(2, Form("p[%d] idx[%d] : Missing entries.", plot, idx));
-    return kFALSE;
-  }
-
-  TGraphErrors *g[2];
-  if(gidx<0) gidx=idx;
-  if(!(g[0] = gidx<0 ? (TGraphErrors*)fGraphM->At(plot) : (TGraphErrors*)((TObjArray*)(fGraphM->At(plot)))->At(gidx))) return kFALSE;
-
-  if(!(g[1] = gidx<0 ? (TGraphErrors*)fGraphS->At(plot) : (TGraphErrors*)((TObjArray*)(fGraphS->At(plot)))->At(gidx))) return kFALSE;
-
-  return Process(h2, f, k, g);
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process3D(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-
-  // retrive containers
-  TH3S *h3(NULL);
-  if(idx<0){
-    if(!(h3= (TH3S*)(fContainer->At(plot)))) return kFALSE; 
-  } else{
-    TObjArray *a0(NULL);
-    if(!(a0=(TObjArray*)(fContainer->At(plot)))) return kFALSE;
-    if(!(h3=(TH3S*)a0->At(idx))) return kFALSE;
-  }
-  if(Int_t(h3->GetEntries())){ 
-    AliDebug(2, Form("p[%d] idx[%d] h[%s] %s", plot, idx, h3->GetName(), h3->GetTitle()));
-  } else {
-    AliDebug(2, Form("p[%d] idx[%d] : Missing entries.", plot, idx));
-    return kFALSE;
-  }
-
-  TObjArray *gm, *gs;
-  if(!(gm = (TObjArray*)((TObjArray*)(fGraphM->At(plot)))->At(idx))) return kFALSE;
-  if(!(gs = (TObjArray*)((TObjArray*)(fGraphS->At(plot)))->At(idx))) return kFALSE;
-  TGraphErrors *g[2];
-
-  TAxis *az = h3->GetZaxis();
-  for(Int_t iz(0); iz<gm->GetEntriesFast(); iz++){
-    if(!(g[0] = (TGraphErrors*)gm->At(iz))) return kFALSE;
-    if(!(g[1] = (TGraphErrors*)gs->At(iz))) return kFALSE;
-    az->SetRange(iz+1, iz+1);
-    if(!Process((TH2*)h3->Project3D("yx"), f, k, g)) return kFALSE;
-  }
-
-  return kTRUE;
-}
-
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process3Dlinked(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-
-  // retrive containers
-  TH3S *h3(NULL);
-  if(idx<0){
-    if(!(h3= (TH3S*)(fContainer->At(plot)))) return kFALSE; 
-  } else{
-    TObjArray *a0(NULL);
-    if(!(a0=(TObjArray*)(fContainer->At(plot)))) return kFALSE;
-    if(!(h3=(TH3S*)a0->At(idx))) return kFALSE;
-  }
-  if(Int_t(h3->GetEntries())){ 
-    AliDebug(2, Form("p[%d] idx[%d] h[%s] %s", plot, idx, h3->GetName(), h3->GetTitle()));
-  } else {
-    AliDebug(2, Form("p[%d] idx[%d] : Missing entries.", plot, idx));
-    return kFALSE;
-  }
-
-  TObjArray *gm, *gs;
-  if(!(gm = (TObjArray*)((TObjArray*)(fGraphM->At(plot)))->At(idx))) return kFALSE;
-  if(!(gs = (TObjArray*)((TObjArray*)(fGraphS->At(plot)))->At(idx))) return kFALSE;
-  TGraphErrors *g[2];
-
-  if(!(g[0] = (TGraphErrors*)gm->At(0))) return kFALSE;
-  if(!(g[1] = (TGraphErrors*)gs->At(0))) return kFALSE;
-  if(!Process((TH2*)h3->Project3D("yx"), f, k, g)) return kFALSE;
-
-  if(!(g[0] = (TGraphErrors*)gm->At(1))) return kFALSE;
-  if(!(g[1] = (TGraphErrors*)gs->At(1))) return kFALSE;
-  if(!Process((TH2*)h3->Project3D("zx"), f, k, g)) return kFALSE;
-
-  return kTRUE;
-}
-
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process3DL(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-
-  // retrive containers
-  TH3S *h3 = (TH3S*)((TObjArray*)fContainer->At(plot))->At(idx);
-  if(!h3) return kFALSE;
-  AliDebug(2, Form("p[%d] idx[%d] h[%s] %s", plot, idx, h3->GetName(), h3->GetTitle()));
-
-  TGraphAsymmErrors *gm; 
-  TGraphErrors *gs;
-  if(!(gm = (TGraphAsymmErrors*)((TObjArray*)fGraphM->At(plot))->At(0))) return kFALSE;
-  if(!(gs = (TGraphErrors*)((TObjArray*)fGraphS->At(plot)))) return kFALSE;
-
-  Float_t x(0.), r(0.), mpv(0.), xM(0.), xm(0.);
-  TAxis *ay = h3->GetYaxis();
-  for(Int_t iy=1; iy<=h3->GetNbinsY(); iy++){
-    ay->SetRange(iy, iy);
-    x = ay->GetBinCenter(iy);
-    TH2F *h2=(TH2F*)h3->Project3D("zx");
-    TAxis *ax = h2->GetXaxis();
-    for(Int_t ix=1; ix<=h2->GetNbinsX(); ix++){
-      r = ax->GetBinCenter(ix);
-      TH1D *h1 = h2->ProjectionY("py", ix, ix);
-      if(h1->Integral()<50) continue;
-      h1->Fit(f, "QN");
-
-      GetLandauMpvFwhm(f, mpv, xm, xM);
-      Int_t ip = gm->GetN();
-      gm->SetPoint(ip, x, k*mpv);
-      gm->SetPointError(ip, 0., 0., k*xm, k*xM);
-      gs->SetPoint(ip, r, k*(xM-xm)/mpv);
-      gs->SetPointError(ip, 0., 0.);
-    }
-  }
-
-  return kTRUE;
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process2Darray(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-
-  // retrive containers
-  TObjArray *arr = (TObjArray*)(fContainer->At(plot));
-  if(!arr) return kFALSE;
-  AliDebug(2, Form("p[%d] idx[%d] arr[%s]", plot, idx, arr->GetName()));
-
-  TObjArray *gm, *gs;
-  if(!(gm = (TObjArray*)((TObjArray*)(fGraphM->At(plot)))->At(idx))) return kFALSE;
-  if(!(gs = (TObjArray*)((TObjArray*)(fGraphS->At(plot)))->At(idx))) return kFALSE;
-
-  TGraphErrors *g[2]; TH2I *h2(NULL); TObjArray *a0(NULL);
-  for(Int_t ia(0); ia<arr->GetEntriesFast(); ia++){
-    if(!(a0 = (TObjArray*)arr->At(ia))) continue;
-
-    if(!(h2 = (TH2I*)a0->At(idx))) return kFALSE;
-    if(Int_t(h2->GetEntries())){ 
-      AliDebug(4, Form("   idx[%d] h[%s] %s", ia, h2->GetName(), h2->GetTitle()));
-    } else {
-      AliDebug(2, Form("   idx[%d] : Missing entries.", ia));
-      continue;
-    }
-
-    if(!(g[0] = (TGraphErrors*)gm->At(ia))) return kFALSE;
-    if(!(g[1] = (TGraphErrors*)gs->At(ia))) return kFALSE;
-    if(!Process(h2, f, k, g)) return kFALSE;
-  }
-
-  return kTRUE;
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process3Darray(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-  //printf("Process4D : processing plot[%d] idx[%d]\n", plot, idx);
-
-  // retrive containers
-  TObjArray *arr = (TObjArray*)(fContainer->At(plot));
-  if(!arr) return kFALSE;
-  AliDebug(2, Form("p[%d] idx[%d] arr[%s]", plot, idx, arr->GetName()));
-
-  TObjArray *gm, *gs;
-  if(!(gm = (TObjArray*)((TObjArray*)(fGraphM->At(plot)))->At(idx))) return kFALSE;
-  if(!(gs = (TObjArray*)((TObjArray*)(fGraphS->At(plot)))->At(idx))) return kFALSE;
-
-  TGraphErrors *g[2]; TH3S *h3(NULL); TObjArray *a0(NULL);
-  Int_t in(0);
-  for(Int_t ia(0); ia<arr->GetEntriesFast(); ia++){
-    if(!(a0 = (TObjArray*)arr->At(ia))) continue;
-
-    if(!(h3 = (TH3S*)a0->At(idx))) return kFALSE;
-     if(Int_t(h3->GetEntries())){ 
-       AliDebug(4, Form("   idx[%d] h[%s] %s", ia, h3->GetName(), h3->GetTitle()));
-    } else {
-      AliDebug(2, Form("   idx[%d] : Missing entries.", ia));
-      continue;
-    }
-    TAxis *az = h3->GetZaxis();
-    for(Int_t iz=1; iz<=az->GetNbins(); iz++, in++){
-      if(in >= gm->GetEntriesFast()) break;
-      if(!(g[0] = (TGraphErrors*)gm->At(in))) return kFALSE;
-      if(!(g[1] = (TGraphErrors*)gs->At(in))) return kFALSE;
-      az->SetRange(iz, iz);
-      if(!Process((TH2*)h3->Project3D("yx"), f, k, g)) return kFALSE;
-    }
-  }
-  AliDebug(2, Form("Projections [%d] from [%d]", in, gs->GetEntriesFast()));
-
-  return kTRUE;
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::Process3DlinkedArray(ETRDresolutionPlot plot, Int_t idx, TF1 *f, Float_t k)
-{
-  //
-  // Do the processing
-  //
-
-  if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
-  //printf("Process4D : processing plot[%d] idx[%d]\n", plot, idx);
-
-  // retrive containers
-  TObjArray *arr = (TObjArray*)(fContainer->At(plot));
-  if(!arr) return kFALSE;
-  AliDebug(2, Form("p[%d] idx[%d] arr[%s]", plot, idx, arr->GetName()));
-
-  TObjArray *gm, *gs;
-  if(!(gm = (TObjArray*)((TObjArray*)(fGraphM->At(plot)))->At(idx))) return kFALSE;
-  if(!(gs = (TObjArray*)((TObjArray*)(fGraphS->At(plot)))->At(idx))) return kFALSE;
-
-  TGraphErrors *g[2]; TH3S *h3(NULL); TObjArray *a0(NULL);
-  Int_t in(0);
-  for(Int_t ia(0); ia<arr->GetEntriesFast(); ia++){
-    if(!(a0 = (TObjArray*)arr->At(ia))) continue;
-    if(!(h3 = (TH3S*)a0->At(idx))) return kFALSE;
-    if(Int_t(h3->GetEntries())){     
-      AliDebug(4, Form("   idx[%d] h[%s] %s", ia, h3->GetName(), h3->GetTitle()));
-    } else {
-      AliDebug(2, Form("   idx[%d] : Missing entries.", ia));
-      continue;
-    }
-    if(!(g[0] = (TGraphErrors*)gm->At(in))) return kFALSE;
-    if(!(g[1] = (TGraphErrors*)gs->At(in))) return kFALSE;
-    if(!Process((TH2*)h3->Project3D("yx"), f, k, g)) return kFALSE;
-    in++;
-
-    if(!(g[0] = (TGraphErrors*)gm->At(in))) return kFALSE;
-    if(!(g[1] = (TGraphErrors*)gs->At(in))) return kFALSE;
-    if(!Process((TH2*)h3->Project3D("zx"), f, k, g)) return kFALSE;
-    in++;
-  }
-  AliDebug(2, Form("Projections [%d] from [%d]", in, gs->GetEntriesFast()));
-
-  return kTRUE;
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::GetGraph(Float_t *bb, ETRDresolutionPlot ip, Int_t idx, Bool_t kLEG, const Char_t *explain)
-{
-  //
-  // Get the graphs
-  //
-
-  if(!fGraphS || !fGraphM) return kFALSE;
-  // axis titles look up
-  Int_t nref = 0;
-  for(Int_t jp=0; jp<(Int_t)ip; jp++) nref+=fgNproj[jp];
-  UChar_t jdx = idx<0?0:idx;
-  for(Int_t jc=0; jc<TMath::Min(jdx,fgNproj[ip]-1); jc++) nref++;
-  Char_t **at = fAxTitle[nref];
-
-  // build legends if requiered
-  TLegend *leg(NULL);
-  if(kLEG){
-    leg=new TLegend(.65, .6, .95, .9);
-    leg->SetBorderSize(0);
-    leg->SetFillStyle(0);
-  }
-  // build frame
-  TH1S *h1(NULL);
-  h1 = new TH1S(Form("h1TF_%02d", fIdxFrame++), Form("%s %s;%s;%s", at[0], explain?explain:"", at[1], at[2]), 2, bb[0], bb[2]);
-  h1->SetMinimum(bb[1]);h1->SetMaximum(bb[3]);
-  h1->SetLineColor(kBlack); h1->SetLineWidth(1);h1->SetLineStyle(2); 
-  // axis range
-  TAxis *ax = h1->GetXaxis();
-  ax->CenterTitle();ax->SetMoreLogLabels();ax->SetTitleOffset(1.2);
-  ax = h1->GetYaxis();
-  ax->SetRangeUser(bb[1], bb[3]);
-  ax->CenterTitle(); ax->SetTitleOffset(1.4);
-  h1->Draw();
-  // bounding box
-  TBox *b = new TBox(-.15, bb[1], .15, bb[3]);
-  b->SetFillStyle(3002);b->SetLineColor(0);
-  b->SetFillColor(ip<=Int_t(kMCcluster)?kGreen:kBlue);
-  b->Draw();
-
-  TGraphErrors *gm = idx<0 ? (TGraphErrors*)fGraphM->At(ip) : (TGraphErrors*)((TObjArray*)(fGraphM->At(ip)))->At(idx);
-  if(!gm) return kFALSE;
-  TGraphErrors *gs = idx<0 ? (TGraphErrors*)fGraphS->At(ip) : (TGraphErrors*)((TObjArray*)(fGraphS->At(ip)))->At(idx);
-  if(!gs) return kFALSE;
-
-  Int_t n(0), nPlots(0);
-  if((n=gm->GetN())) {
-    nPlots++;
-    gm->Draw("pl"); if(leg) leg->AddEntry(gm, gm->GetTitle(), "pl");
-    PutTrendValue(Form("%s_%s", fgPerformanceName[ip], at[0]), gm->GetMean(2));
-    PutTrendValue(Form("%s_%sRMS", fgPerformanceName[ip], at[0]), gm->GetRMS(2));
-  }
-
-  if((n=gs->GetN())){
-    nPlots++;
-    gs->Draw("pl"); if(leg) leg->AddEntry(gs, gs->GetTitle(), "pl");
-    gs->Sort(&TGraph::CompareY);
-    PutTrendValue(Form("%s_%sSigMin", fgPerformanceName[ip], at[0]), gs->GetY()[0]);
-    PutTrendValue(Form("%s_%sSigMax", fgPerformanceName[ip], at[0]), gs->GetY()[n-1]);
-    gs->Sort(&TGraph::CompareX); 
-  }
-  if(!nPlots) return kFALSE;
-  if(leg) leg->Draw();
-  return kTRUE;
-}
-
-//________________________________________________________
-Bool_t AliTRDresolution::GetGraphArray(Float_t *bb, ETRDresolutionPlot ip, Int_t idx, Bool_t kLEG, Int_t n, Int_t *sel, const Char_t *explain)
-{
-  //
-  // Get the graphs
-  //
-
-  if(!fGraphS || !fGraphM) return kFALSE;
-
-  // axis titles look up
-  Int_t nref(0);
-  for(Int_t jp(0); jp<ip; jp++) nref+=fgNproj[jp];
-  nref+=idx;
-  Char_t **at = fAxTitle[nref];
-
-  // build legends if requiered
-  TLegend *legM(NULL), *legS(NULL);
-  if(kLEG){
-    legM=new TLegend(.35, .6, .65, .9);
-    legM->SetHeader("Mean");
-    legM->SetBorderSize(0);
-    legM->SetFillStyle(0);
-    legS=new TLegend(.65, .6, .95, .9);
-    legS->SetHeader("Sigma");
-    legS->SetBorderSize(0);
-    legS->SetFillStyle(0);
-  }
-  // build frame
-  TH1S *h1(NULL);
-  h1 = new TH1S(Form("h1TF_%02d", fIdxFrame++), Form("%s %s;%s;%s", at[0], explain?explain:"", at[1], at[2]), 2, bb[0], bb[2]);
-  h1->SetMinimum(bb[1]);h1->SetMaximum(bb[3]);
-  h1->SetLineColor(kBlack); h1->SetLineWidth(1);h1->SetLineStyle(2); 
-  // axis range
-  TAxis *ax = h1->GetXaxis();
-  ax->CenterTitle();ax->SetMoreLogLabels();ax->SetTitleOffset(1.2);
-  ax = h1->GetYaxis();
-  ax->SetRangeUser(bb[1], bb[3]);
-  ax->CenterTitle(); ax->SetTitleOffset(1.4);
-  h1->Draw();
-
-  TGraphErrors *gm(NULL), *gs(NULL);
-  TObjArray *a0(NULL), *a1(NULL);
-  a0 = (TObjArray*)((TObjArray*)fGraphM->At(ip))->At(idx);
-  a1 = (TObjArray*)((TObjArray*)fGraphS->At(ip))->At(idx);
-  if(!n) n=a0->GetEntriesFast();
-  AliDebug(4, Form("Graph : Ref[%d] Title[%s] Limits{x[%f %f] y[%f %f]} Comp[%d] Selection[%c]", nref, at[0], bb[0], bb[2], bb[1], bb[3], n, sel ? 'y' : 'n'));
-  Int_t nn(0), nPlots(0);
-  for(Int_t is(0), is0(0); is<n; is++){
-    is0 = sel ? sel[is] : is;
-    if(!(gs =  (TGraphErrors*)a1->At(is0))) return kFALSE;
-    if(!(gm =  (TGraphErrors*)a0->At(is0))) return kFALSE;
-
-    if((nn=gs->GetN())){
-      nPlots++;
-      gs->Draw("pc"); 
-      if(legS){ 
-        //printf("LegEntry %s [%s]%s\n", at[0], gs->GetName(), gs->GetTitle());
-        legS->AddEntry(gs, gs->GetTitle(), "pl");
-      }
-      gs->Sort(&TGraph::CompareY);
-      PutTrendValue(Form("%s_%sSigMin", fgPerformanceName[kMCtrack], at[0]), gs->GetY()[0]);
-      PutTrendValue(Form("%s_%sSigMax", fgPerformanceName[kMCtrack], at[0]), gs->GetY()[nn-1]);
-      gs->Sort(&TGraph::CompareX); 
-    }
-    if(gm->GetN()){
-      nPlots++;
-      gm->Draw("pc");
-      if(legM){ 
-        //printf("LegEntry %s [%s]%s\n", at[0], gm->GetName(), gm->GetTitle());
-        legM->AddEntry(gm, gm->GetTitle(), "pl");
-      }
-      PutTrendValue(Form("%s_%s", fgPerformanceName[kMCtrack], at[0]), gm->GetMean(2));
-      PutTrendValue(Form("%s_%sRMS", fgPerformanceName[kMCtrack], at[0]), gm->GetRMS(2));
-    }
-  }
-  if(!nPlots) return kFALSE;
-  if(kLEG){
-    legM->Draw();
-    legS->Draw();
-  }
-  return kTRUE;
-}
 
 //____________________________________________________________________
 Bool_t AliTRDresolution::FitTrack(const Int_t np, AliTrackPoint *points, Float_t param[10])
@@ -3270,146 +1855,59 @@ void AliTRDresolution::GetLandauMpvFwhm(TF1 * const f, Float_t &mpv, Float_t &xm
 }
 
 
-//________________________________________________________
-void AliTRDresolution::SetSegmentationLevel(Int_t l) 
-{
-// Setting the segmentation level to "l"
-  fSegmentLevel = l;
-
-  UShort_t const lNcomp[kNprojs] = {
-    1,  1, //2, 
-    fgkNresYsegm[fSegmentLevel], 2, //2, 
-    2*fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, //5, 
-    2*fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, //5,
-    2*fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, //5,
-  // MC
-    fgkNresYsegm[fSegmentLevel], 2,          //2, 
-    fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, //5, 
-    fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, 1, 1, 1, 11, 11, 11, //11
-    fgkNresYsegm[fSegmentLevel], 2, 2, 2, 1, 1, 1, 1, 11, 11, 11, //11
-    6*fgkNresYsegm[fSegmentLevel], 6*2, 6*2, 6*2, 6, 6, 6, 6, 6*11, 6*11, 6*11  //11
-  };
-  memcpy(fNcomp, lNcomp, kNprojs*sizeof(UShort_t));
-
-  Char_t const *lAxTitle[kNprojs][4] = {
-    // Charge
-    {"Impv", "x [cm]", "I_{mpv}", "x/x_{0}"}
-  ,{"dI/Impv", "x/x_{0}", "#delta I/I_{mpv}", "x[cm]"}
-    // Clusters to Kalman
-  ,{"Cluster2Track residuals", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"Cluster2Track  YZ pulls", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-    // TRD tracklet to Kalman fit
-  ,{"Tracklet2Track Y residuals", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"Tracklet2Track YZ pulls", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"Tracklet2Track Z residuals", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"Tracklet2Track Z pulls", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"Tracklet2Track Phi residuals", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-    // TRDin 2 first TRD tracklet
-  ,{"Tracklet2Track Y residuals @ TRDin", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"Tracklet2Track YZ pulls @ TRDin", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"Tracklet2Track Z residuals @ TRDin", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"Tracklet2Track Z pulls @ TRDin", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"Tracklet2Track Phi residuals @ TRDin", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-    // TRDout 2 first TRD tracklet
-  ,{"Tracklet2Track Y residuals @ TRDout", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"Tracklet2Track YZ pulls @ TRDout", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"Tracklet2Track Z residuals @ TRDout", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"Tracklet2Track Z pulls @ TRDout", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"Tracklet2Track Phi residuals @ TRDout", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-    // MC cluster
-  ,{"MC Cluster Y resolution", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"MC Cluster YZ pulls", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-    // MC tracklet
-  ,{"MC Tracklet Y resolution", "tg(#phi)", "y [#mum]",  "#sigma_{y}[#mum]"}
-  ,{"MC Tracklet YZ pulls", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"MC Tracklet Z resolution", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"MC Tracklet Z pulls", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"MC Tracklet Phi resolution", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-    // MC track TRDin
-  ,{"MC Y resolution @ TRDin", "tg(#phi)", "y [#mum]", "#sigma_{y}[#mum]"}
-  ,{"MC YZ pulls @ TRDin", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"MC Z resolution @ TRDin", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"MC Z pulls @ TRDin", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"MC #Phi resolution @ TRDin", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-  ,{"MC SNP pulls @ TRDin", "tg(#phi)", "SNP", "#sigma_{snp}"}
-  ,{"MC #Theta resolution @ TRDin", "tg(#theta)", "#theta [mrad]", "#sigma_{#theta} [mrad]"}
-  ,{"MC TGL pulls @ TRDin", "tg(#theta)", "TGL", "#sigma_{tgl}"}
-  ,{"MC P_{t} resolution @ TRDin", "p_{t}^{MC} [GeV/c]", "(p_{t}^{REC}-p_{t}^{MC})/p_{t}^{MC} [%]", "MC: #sigma^{TPC}(#Deltap_{t}/p_{t}^{MC}) [%]"}
-  ,{"MC 1/P_{t} pulls @ TRDin", "1/p_{t}^{MC} [c/GeV]", "1/p_{t}^{REC}-1/p_{t}^{MC}", "MC PULL: #sigma_{1/p_{t}}^{TPC}"}
-  ,{"MC P resolution @ TRDin", "p^{MC} [GeV/c]", "(p^{REC}-p^{MC})/p^{MC} [%]", "MC: #sigma^{TPC}(#Deltap/p^{MC}) [%]"}
-    // MC track TRDout
-  ,{"MC Y resolution @ TRDout", "tg(#phi)", "y [#mum]", "#sigma_{y}[#mum]"}
-  ,{"MC YZ pulls @ TRDout", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"MC Z resolution @ TRDout", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"MC Z pulls @ TRDout", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"MC #Phi resolution @ TRDout", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-  ,{"MC SNP pulls @ TRDout", "tg(#phi)", "SNP", "#sigma_{snp}"}
-  ,{"MC #Theta resolution @ TRDout", "tg(#theta)", "#theta [mrad]", "#sigma_{#theta} [mrad]"}
-  ,{"MC TGL pulls @ TRDout", "tg(#theta)", "TGL", "#sigma_{tgl}"}
-  ,{"MC P_{t} resolution @ TRDout", "p_{t}^{MC} [GeV/c]", "(p_{t}^{REC}-p_{t}^{MC})/p_{t}^{MC} [%]", "MC: #sigma^{TPC}(#Deltap_{t}/p_{t}^{MC}) [%]"}
-  ,{"MC 1/P_{t} pulls @ TRDout", "1/p_{t}^{MC} [c/GeV]", "1/p_{t}^{REC}-1/p_{t}^{MC}", "MC PULL: #sigma_{1/p_{t}}^{TPC}"}
-  ,{"MC P resolution @ TRDout", "p^{MC} [GeV/c]", "(p^{REC}-p^{MC})/p^{MC} [%]", "MC: #sigma^{TPC}(#Deltap/p^{MC}) [%]"}
-    // MC track in TRD
-  ,{"MC Track Y resolution", "tg(#phi)", "y [#mum]", "#sigma_{y} [#mum]"}
-  ,{"MC Track YZ pulls", fgkResYsegmName[fSegmentLevel], "y / z", "#sigma_{y}"}
-  ,{"MC Track Z resolution", "tg(#theta)", "z [#mum]", "#sigma_{z} [#mum]"}
-  ,{"MC Track Z pulls", "tg(#theta)", "z", "#sigma_{z}"}
-  ,{"MC Track #Phi resolution", "tg(#phi)", "#phi [mrad]", "#sigma_{#phi} [mrad]"}
-  ,{"MC Track SNP pulls", "tg(#phi)", "SNP", "#sigma_{snp}"}
-  ,{"MC Track #Theta resolution", "tg(#theta)", "#theta [mrad]", "#sigma_{#theta} [mrad]"}
-  ,{"MC Track TGL pulls", "tg(#theta)", "TGL", "#sigma_{tgl}"}
-  ,{"MC P_{t} resolution", "p_{t} [GeV/c]", "(p_{t}^{REC}-p_{t}^{MC})/p_{t}^{MC} [%]", "#sigma(#Deltap_{t}/p_{t}^{MC}) [%]"}
-  ,{"MC 1/P_{t} pulls", "1/p_{t}^{MC} [c/GeV]", "1/p_{t}^{REC} - 1/p_{t}^{MC}", "#sigma_{1/p_{t}}"}
-  ,{"MC P resolution", "p [GeV/c]", "(p^{REC}-p^{MC})/p^{MC} [%]", "#sigma(#Deltap/p^{MC}) [%]"}
-  };
-  memcpy(fAxTitle, lAxTitle, 4*kNprojs*sizeof(Char_t*));
-}
-
-#include "TFile.h"
-//________________________________________________________
-Bool_t AliTRDresolution::LoadCorrection(const Char_t *file)
-{
-  if(!file){
-    AliWarning("Use cluster position as in reconstruction.");
-    SetLoadCorrection();
-    return kTRUE;
-  }
-  TDirectory *cwd(gDirectory);
-  TString fileList;
-  FILE *filePtr = fopen(file, "rt");
-  if(!filePtr){
-    AliWarning(Form("Couldn't open correction list \"%s\". Use cluster position as in reconstruction.", file));
-    SetLoadCorrection();
-    return kFALSE;
-  }
-  TH2 *h2 = new TH2F("h2", ";time [time bins];detector;dx [#mum]", 30, -0.5, 29.5, AliTRDgeometry::kNdet, -0.5, AliTRDgeometry::kNdet-0.5);
-  while(fileList.Gets(filePtr)){
-    if(!TFile::Open(fileList.Data())) {
-      AliWarning(Form("Couldn't open \"%s\"", fileList.Data()));
-      continue;
-    } else AliInfo(Form("\"%s\"", fileList.Data()));
-
-    TTree *tSys = (TTree*)gFile->Get("tSys");
-    h2->SetDirectory(gDirectory); h2->Reset("ICE");
-    tSys->Draw("det:t>>h2", "dx", "goff");
-    for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
-      for(Int_t it(0); it<30; it++) fXcorr[idet][it]+=(1.e-4*h2->GetBinContent(it+1, idet+1));
-    }
-    h2->SetDirectory(cwd);
-    gFile->Close();
-  }
-  cwd->cd();
-
-  if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>=2){
-    for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
-    printf("DET|");for(Int_t it(0); it<30; it++) printf(" tb%02d|", it); printf("\n");
-    for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
-    for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
-      printf("%03d|", idet);
-      for(Int_t it(0); it<30; it++) printf("%+5.0f|", 1.e4*fXcorr[idet][it]);
-      printf("\n");
-    }
-  }
-  SetLoadCorrection();
-  return kTRUE;
-}
+// #include "TFile.h"
+// //________________________________________________________
+// Bool_t AliTRDresolution::LoadCorrection(const Char_t *file)
+// {
+//   if(!file){
+//     AliWarning("Use cluster position as in reconstruction.");
+//     SetLoadCorrection();
+//     return kTRUE;
+//   }
+//   TDirectory *cwd(gDirectory);
+//   TString fileList;
+//   FILE *filePtr = fopen(file, "rt");
+//   if(!filePtr){
+//     AliWarning(Form("Couldn't open correction list \"%s\". Use cluster position as in reconstruction.", file));
+//     SetLoadCorrection();
+//     return kFALSE;
+//   }
+//   TH2 *h2 = new TH2F("h2", ";time [time bins];detector;dx [#mum]", 30, -0.5, 29.5, AliTRDgeometry::kNdet, -0.5, AliTRDgeometry::kNdet-0.5);
+//   while(fileList.Gets(filePtr)){
+//     if(!TFile::Open(fileList.Data())) {
+//       AliWarning(Form("Couldn't open \"%s\"", fileList.Data()));
+//       continue;
+//     } else AliInfo(Form("\"%s\"", fileList.Data()));
+// 
+//     TTree *tSys = (TTree*)gFile->Get("tSys");
+//     h2->SetDirectory(gDirectory); h2->Reset("ICE");
+//     tSys->Draw("det:t>>h2", "dx", "goff");
+//     for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
+//       for(Int_t it(0); it<30; it++) fXcorr[idet][it]+=(1.e-4*h2->GetBinContent(it+1, idet+1));
+//     }
+//     h2->SetDirectory(cwd);
+//     gFile->Close();
+//   }
+//   cwd->cd();
+// 
+//   if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>=2){
+//     for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
+//     printf("DET|");for(Int_t it(0); it<30; it++) printf(" tb%02d|", it); printf("\n");
+//     for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
+//     FILE *fout = fopen("TRD.ClusterCorrection.txt", "at");
+//     fprintf(fout, "  static const Double_t dx[AliTRDgeometry::kNdet][30]={\n");
+//     for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
+//       printf("%03d|", idet);
+//       fprintf(fout, "    {");
+//       for(Int_t it(0); it<30; it++){
+//         printf("%+5.0f|", 1.e4*fXcorr[idet][it]);
+//         fprintf(fout, "%+6.4f%c", fXcorr[idet][it], it==29?' ':',');
+//       }
+//       printf("\n");
+//       fprintf(fout, "}%c\n", idet==AliTRDgeometry::kNdet-1?' ':',');
+//     }
+//     fprintf(fout, "  };\n");
+//   }
+//   SetLoadCorrection();
+//   return kTRUE;
+// }
index c3bcb6a..1be77da 100644 (file)
@@ -32,38 +32,50 @@ class AliTrackPoint;
 class AliTRDresolution : public AliTRDrecoTask
 {
 public:
-  enum ETRDresolutionPlot {
-     kCharge     =  0 // charge resolution
-    ,kCluster    =  1 // cluster - track
-    ,kTrack      =  2 // tracklet - track residuals/pulls
-    ,kTrackIn    =  3 // tracklet - track residuals/pulls at lower TRD entrance 
-    ,kTrackOut   =  4 // tracklet - track residuals/pulls at lower TRD entrance during refit
-    ,kMCcluster  =  5 // cluster-mc resolution/pulls
-    ,kMCtracklet =  6 // tracklet-mc resolution/pulls
-    ,kMCtrackIn  =  7 // TPC track monitor
-    ,kMCtrackOut =  8 // TOF/HMPID track monitor
-    ,kMCtrack    =  9 // TRD track monitor
-    ,kNviews     = 10 // total number of resolution views
-    ,kNprojs     = 70 // total number of projections for all views
-  };
   enum ETRDresolutionSteer {
      kVerbose    = BIT(18) // switch verbosity
     ,kVisual     = BIT(19) // show partial results during processing
     ,kTrackRefit = BIT(20) // steer track refit
     ,kTrackSelect= BIT(21) // steer track selection
-    ,kLoadCorr   = BIT(23) // steer load corrections
+//    ,kLoadCorr   = BIT(23) // steer load corrections
   };
-  enum ETRDresolutionOutSlots {
+  enum ETRDresolutionSlots {
      kClToTrk    = 2
-    ,kClToMC     = 3
-    ,kTrkltToTrk = 4
-    ,kTrkltToMC  = 5
-    ,kNOutSlots  = 4
+    ,kClToMC
+    ,kTrkltToTrk
+    ,kTrkltToMC
+    ,kNSlots     = 4
+  };
+  enum ETRDresolutionClass {
+    kCluster=0        // cluster - track
+    ,kTracklet        // tracklet - track residuals/pulls
+    ,kTrackIn         // tracklet - track residuals/pulls at lower TRD entrance
+    ,kTrackOut        // tracklet - track residuals/pulls at lower TRD entrance during refit
+    ,kMCcluster       // cluster-mc resolution/pulls
+    ,kMCtracklet      // tracklet-mc resolution/pulls
+    ,kMCtrackIn       // TPC track monitor
+    ,kMCtrackOut      // TOF/HMPID track monitor
+    ,kMCtrack         // TRD track monitor
+    ,kNclasses        // total number of resolution classes
+  };
+  enum ETRDresolutionProjs {
+    kBC    = 0 // bunch cross
+    ,kPhi
+    ,kEta
+    ,kSpeciesChgRC
+    ,kPt
+    ,kYrez
+    ,kZrez
+    ,kPrez
+    ,kNdim  // no of dimensions in the THnSparse
   };
   enum ETRDresolutionSegmentation {
      kSector    = 0
     ,kStack
     ,kDetector
+    ,kNbunchCross = 3  // no of classes for bunch crossing
+    ,kNpt         = 24 // no of log bins in pt spectrum
+    ,kNcharge     = 2
   };
 
   AliTRDresolution();
@@ -73,27 +85,29 @@ public:
   static Bool_t  FitTrack(const Int_t np, AliTrackPoint *points, Float_t params[10]);
   static Bool_t  FitTracklet(const Int_t ly, const Int_t np, const AliTrackPoint *points, const Float_t trackPars[10], Float_t trackletPars[3]);
   void    UserCreateOutputObjects();
-  Float_t GetCorrectionX(Int_t det, Int_t tb) const {return fXcorr[det][tb];}
+//  Float_t GetCorrectionX(Int_t det, Int_t tb) const {return fXcorr[det][tb];}
   Float_t GetDyRange() const {return fDyRange;}
+  Float_t GetMeanWithBoundary(TH1 *h, Float_t zm, Float_t zM, Float_t dz) const;
   Float_t GetPtThreshold() const {return fPtThreshold;}
-  Float_t GetSegmentationLevel() const {return fSegmentLevel;}
+  static Int_t GetPtBin(Float_t pt);
   Bool_t  GetRefFigure(Int_t ifig);
+
   TObjArray*  Histos(); 
-  Bool_t  Load(const Char_t *file = "AnalysisResults.root", const Char_t *dir="TRD_Performance");
-  Bool_t  LoadCorrection(const Char_t *file=NULL);
+//  Bool_t  Load(const Char_t *file = "AnalysisResults.root", const Char_t *dir="TRD_Performance");
+//  Bool_t  LoadCorrection(const Char_t *file=NULL);
   void    MakeSummary();
+  static void MakePtSegmentation(Float_t pt0=0.2, Float_t dpt=0.002);
 
-  TObjArray*  Results(Int_t i=0) const {return i ? fGraphS : fGraphM;} 
+  TObjArray*  Results(ETRDresolutionClass c) const {if(!fProj) return NULL; return (TObjArray*)fProj->At(c);}
   void    UserExec(Option_t * opt);
   void    InitExchangeContainers();
-  Bool_t  HasLoadCorrection() const {return TestBit(kLoadCorr);}
+//  Bool_t  HasLoadCorrection() const {return TestBit(kLoadCorr);}
   Bool_t  HasTrackRefit() const {return TestBit(kTrackRefit);}
   Bool_t  HasTrackSelection() const {return TestBit(kTrackSelect);}
   Bool_t  IsVerbose() const {return TestBit(kVerbose);}
   Bool_t  IsVisual() const {return TestBit(kVisual);}
   Bool_t  PostProcess();
 
-  TH1*    PlotCharge(const AliTRDtrackV1 *t=NULL);
   TH1*    PlotCluster(const AliTRDtrackV1 *t=NULL);
   TH1*    PlotTracklet(const AliTRDtrackV1 *t=NULL);
   TH1*    PlotTrackIn(const AliTRDtrackV1 *t=NULL);
@@ -102,18 +116,17 @@ public:
 
   static Bool_t  Process(TH2* const h2, TGraphErrors **g, Int_t stat=100);
   void    SetDyRange(Float_t dy) {fDyRange = dy;}
-  void    SetSegmentationLevel(Int_t l=0);
+//  void    SetSegmentationLevel(Int_t l=0);
   void    SetPtThreshold(Float_t pt) {fPtThreshold = pt;}
-  void    SetLoadCorrection(Bool_t v = kTRUE) {SetBit(kLoadCorr, v);}
+//  void    SetLoadCorrection(Bool_t v = kTRUE) {SetBit(kLoadCorr, v);}
   void    SetVerbose(Bool_t v = kTRUE) {SetBit(kVerbose, v);}
   void    SetVisual(Bool_t v = kTRUE) {SetBit(kVisual, v);}
   void    SetTrackRefit(Bool_t v = kTRUE) {SetBit(kTrackRefit, v);}
   void    SetTrackSelection(Bool_t v = kTRUE) {SetBit(kTrackSelect, v);}
 
   void    Terminate(Option_t * opt);
-  Bool_t  GetGraph(Float_t *bb, ETRDresolutionPlot ip, Int_t idx=-1, Bool_t kLEG=kTRUE, const Char_t *explain=NULL);
-  Bool_t  GetGraphArray(Float_t *bb, ETRDresolutionPlot ip, Int_t idx, Bool_t kLEG=kTRUE, Int_t n=0, Int_t *sel=NULL, const Char_t *explain=NULL);
   static Bool_t  UseTrack(const Int_t np, const AliTrackPoint *points, Float_t params[10]);
+
 private:
   AliTRDresolution(const AliTRDresolution&);
   AliTRDresolution& operator=(const AliTRDresolution&);
@@ -124,40 +137,30 @@ private:
   TObjArray*  BuildMonitorContainerTrack(const char* name);
   void    GetLandauMpvFwhm(TF1 * const f, Float_t &mpv, Float_t &xm, Float_t &xM);
   void    GetRange(TH2 *h2, Char_t mod, Float_t *range);
-  void    MakeSummaryPlot(TObjArray *a, TH2 *h2);
+  Bool_t  MakeProjectionCluster();
+  Bool_t  MakeProjectionTracklet();
+  Bool_t  MakeProjectionTrackIn();
   Bool_t  Process(TH2* const h2, TF1 *f, Float_t k, TGraphErrors **g);
-  Bool_t  Process2D(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1., Int_t gidx=-1);
-  Bool_t  Process2Darray(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
-  Bool_t  Process3D(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
-  Bool_t  Process3Dlinked(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
-  Bool_t  Process3DL(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
-  Bool_t  Process3Darray(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
-  Bool_t  Process3DlinkedArray(ETRDresolutionPlot ip, Int_t idx=-1, TF1 *f=NULL,  Float_t scale=1.);
   Bool_t  Pulls(Double_t dyz[2], Double_t cc[3], Double_t tilt) const;
 
-  UChar_t             fSegmentLevel;    // segmentation level [sector/stack/chamber]
-  UShort_t            fIdxPlot;         // plot counter (internal)
-  UShort_t            fIdxFrame;        // frame counter (internal)
-  UShort_t            fNcomp[kNprojs];  // number of projections per task
-  Char_t              *fAxTitle[kNprojs][4]; //! Title for all ref histos
-  Float_t             fPtThreshold;     // pt threshold for some performance plots
-  Float_t             fDyRange;         // min/max dy
-  Float_t             fXcorr[540][30];  // min/max dy
-  static Char_t const *fgPerformanceName[kNviews]; //! name of performance plot
-  static Char_t const *fgParticle[11];    //! latex name of particles/sign 
-  static UChar_t const fgNproj[kNviews]; //! number of projections per task
-  static Int_t const  fgkNresYsegm[3];   //! number of segments for saving y resolution
-  static Char_t const *fgkResYsegmName[3];//! name of segment for saving y resolution
-  TDatabasePDG        *fDBPDG;          // PDG database
-  TObjArray           *fGraphS;         //! result holder - sigma values
-  TObjArray           *fGraphM;         //! result holder - mean values
+  UShort_t              fIdxPlot;         // plot counter (internal)
+  UShort_t              fIdxFrame;        // frame counter (internal)
+  Float_t               fPtThreshold;     // pt threshold for some performance plots
+  Float_t               fDyRange;         // min/max dy
+  static Char_t const  *fgPerformanceName[kNclasses]; //! name of performance plot
+  static UChar_t const  fgNproj[kNclasses];//! number of projections per task
+  static Int_t const    fgkNbins[kNdim];  //! no of bins/projection
+  static Double_t const fgkMin[kNdim];    //! low limits for projections
+  static Double_t const fgkMax[kNdim];    //! high limits for projections
+  static Char_t const  *fgkTitle[kNdim];  //! title of projection 
+  static Float_t        fgPtBin[kNpt+1];  //! pt segmentation
+  TObjArray            *fProj;            //! result holder - sigma values
+  TDatabasePDG         *fDBPDG;           //! PDG database
 
   // calibration containers
-  TObjArray           *fCl;     //! cluster2track calib
-  TObjArray           *fMCcl;   //! cluster2mc calib
-/*  TObjArray           *fTrklt;  //! tracklet2track calib
-  TObjArray           *fMCtrklt;//! tracklet2mc calib*/
+  TObjArray           *fCl;               //! cluster2track calib
+  TObjArray           *fMCcl;             //! cluster2mc calib
   
-  ClassDef(AliTRDresolution, 9) // TRD tracking resolution task
+  ClassDef(AliTRDresolution, 10) // TRD tracking resolution task
 };
 #endif
index 0444707..73f9b8c 100644 (file)
@@ -45,10 +45,11 @@ AliTRDclusterInfo::AliTRDclusterInfo()
   fCov[2] = 1.;
   fCovCl[0] = 1.; fCovCl[1] = 0.;
   fCovCl[2] = 1.;
+  memset(fSignal, 0, 7*sizeof(Short_t));
 }
 
 //_________________________________________________
-void AliTRDclusterInfo::SetCluster(const AliTRDcluster *c)
+void AliTRDclusterInfo::SetCluster(AliTRDcluster *c)
 {
 // Load rec cluster data
   if(!c) return;
@@ -65,6 +66,7 @@ void AliTRDclusterInfo::SetCluster(const AliTRDcluster *c)
   fCovCl[0] = c->GetSigmaY2();
   fCovCl[1] = 0.;
   fCovCl[2] = c->GetSigmaZ2();
+  memcpy(fSignal, c->GetSignals(), 7*sizeof(Short_t));
 }
 
 //_________________________________________________
index 4c82b90..f698dcf 100644 (file)
@@ -33,13 +33,14 @@ public:
   void      GetCenterPad(Int_t &c, Int_t &r) const {c=fCol; r=fRow;}
   Float_t   GetResolution() const {return fdy;}
   Float_t   GetDriftLength() const {return fXd;}
+  Short_t*  GetSignals() {return fSignal;}
   Float_t   GetYDisplacement() const {return fYd;}
   Float_t   GetTilt() const { return fTilt;}
 
   void      Print(Option_t *opt="") const;
 
   void      SetAnisochronity(Float_t d) {fD = d;}
-  void      SetCluster(const AliTRDcluster *c);
+  void      SetCluster(AliTRDcluster *c);
   void      SetMC(Int_t pdg, Int_t label){
       fPdg  = pdg;
       fLbl  = label;}
@@ -73,6 +74,7 @@ private:
   Float_t  fdy;    // difference in y after tilt correction
   Float_t  fD;     // distance to the anode wire
   Float_t  fTilt;  // pad tilt;
+  Short_t  fSignal[7]; //cluster signals
 
   ClassDef(AliTRDclusterInfo, 3) // extracted cluster2MC information
 };
index b6f6d3e..eec6ed0 100644 (file)
@@ -43,6 +43,7 @@ ClassImp(AliTRDtrackInfo)
 ClassImp(AliTRDtrackInfo::AliMCinfo)
 ClassImp(AliTRDtrackInfo::AliESDinfo)
 Double_t AliTRDtrackInfo::AliMCinfo::fgKalmanStep = 2.;
+Bool_t AliTRDtrackInfo::AliMCinfo::fgKalmanUpdate = kTRUE;
 
 //___________________________________________________
 AliTRDtrackInfo::AliTRDtrackInfo():
@@ -132,6 +133,7 @@ AliTRDtrackInfo::AliESDinfo::AliESDinfo()
   ,fStatus(0)
   ,fKinkIndex(0)
   ,fTPCncls(0)
+  ,fTOFbc(0)
   ,fTRDpidQuality(0)
   ,fTRDnSlices(0)
   ,fTRDslices(NULL)
@@ -152,6 +154,7 @@ AliTRDtrackInfo::AliESDinfo::AliESDinfo(const AliESDinfo &esd)
   ,fStatus(esd.fStatus)
   ,fKinkIndex(esd.fKinkIndex)
   ,fTPCncls(esd.fTPCncls)
+  ,fTOFbc(esd.fTOFbc)
   ,fTRDpidQuality(esd.fTRDpidQuality)
   ,fTRDnSlices(esd.fTRDnSlices)
   ,fTRDslices(NULL)
@@ -446,7 +449,7 @@ void AliTRDtrackInfo::SetSlices(Int_t n, Double32_t *s)
 }
  
 //___________________________________________________
-Bool_t AliTRDtrackInfo::AliMCinfo::GetDirections(Float_t &x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx, Float_t &pt, UChar_t &status) const
+Bool_t AliTRDtrackInfo::AliMCinfo::GetDirections(Float_t &x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx, Float_t &pt, Float_t &eta, UChar_t &status) const
 {
 // Check for 2 track ref for the tracklet defined bythe radial position x0
 // The "status" is a bit map and gives a more informative output in case of failure:
@@ -492,26 +495,31 @@ Bool_t AliTRDtrackInfo::AliMCinfo::GetDirections(Float_t &x0, Float_t &y0, Float
   y0   =  tr[1]->LocalY()/* - dydx*dx0*/;
   z0   =  tr[1]->Z()/* - dzdx*dx0*/;
   x0   =  tr[1]->LocalX();
+  eta  =  -TMath::Log(TMath::Tan(0.5 * tr[1]->Theta()));
   return kTRUE;
 }
 
 //___________________________________________________
-void AliTRDtrackInfo::AliMCinfo::PropagateKalman(TVectorD *dx, TVectorD *dy, TVectorD *dz, TVectorD *pt, TVectorD *dpt, TVectorD *c) const
+Bool_t AliTRDtrackInfo::AliMCinfo::PropagateKalman(
+      TVectorD *x, TVectorD *y, TVectorD *z,
+      TVectorD *dx, TVectorD *dy, TVectorD *dz,
+      TVectorD *pt, TVectorD *dpt, TVectorD *budget, TVectorD *c, Double_t mass) const
 {
 // Propagate Kalman from the first TRD track reference to 
 // last one and save residuals in the y, z and pt.
 // 
 // This is to calibrate the dEdx and MS corrections
 
-  if(!fNTrackRefs) return;
+  if(!fNTrackRefs) return kFALSE;
   for(Int_t itr=kNTrackRefs; itr--;){
+    (*x)[itr] = 0.;(*y)[itr] = 0.;(*z)[itr] = 0.;
     (*dx)[itr] = -1.; (*dy)[itr] = 100.; (*dz)[itr] = 100.; (*dpt)[itr] = 100.;
   }
 
   // Initialize TRD track to the first track reference
   AliTrackReference *tr(NULL);
   Int_t itr(0); while(!(tr = fTrackRefs[itr])) itr++;
-  if(tr->Pt()<1.e-3) return;
+  if(tr->Pt()<1.e-3) return kFALSE;
 
   AliTRDtrackV1 tt;
   Double_t xyz[3]={tr->X(),tr->Y(),tr->Z()};
@@ -529,25 +537,40 @@ void AliTRDtrackInfo::AliMCinfo::PropagateKalman(TVectorD *dx, TVectorD *dy, TVe
   const TParticlePDG *pdg=db.GetParticle(fPDG);
   if(!pdg){
     AliWarningGeneral("AliTRDtrackInfo::AliMCinfo::PropagateKalman()", Form("PDG entry missing for code %d. References for track %d", fPDG, fNTrackRefs));
-    return;
+    return kFALSE;
   }
   tt.Set(xyz, pxyz, cov, Short_t(pdg->Charge()));
-  tt.SetMass(pdg->Mass());
-  
+  if(mass<0){ // mass 0 use PDG
+    tt.SetMass(pdg->Mass());
+  } else { // use rec value
+    tt.SetMass(mass);
+  }
+
+//  Double_t bg(tr->P()/pdg->Mass());
+//  printf("\n\nNEW track PDG[%d] bg[%f] x[%f]\n", fPDG, bg, TMath::Log(bg));
   Double_t x0(tr->LocalX());
   const Double_t *cc(NULL);
   for(Int_t ip=0; itr<fNTrackRefs; itr++){
     if(!(tr = fTrackRefs[itr])) continue;
+//    printf("ip[%d] det[%d]\n", ip, tr->DetectorId());
     if(!AliTRDtrackerV1::PropagateToX(tt, tr->LocalX(), fgKalmanStep)) continue;
 
     //if(update) ...
+    tt.GetXYZ(xyz);
+    (*x)[ip]   = xyz[0];
+    (*y)[ip]   = xyz[1];
+    (*z)[ip]   = xyz[2];
     (*dx)[ip]  = tt.GetX() - x0;
     (*dy)[ip]  = tt.GetY() - tr->LocalY();
     (*dz)[ip]  = tt.GetZ() - tr->Z();
     (*pt)[ip]  = tr->Pt();
     (*dpt)[ip] = tt.Pt()- tr->Pt();
+//    printf("pt : kalman[%e] MC[%e]\n", tt.Pt(), tr->Pt());
+    (*budget)[ip] = tt.GetBudget(0);
     cc = tt.GetCovariance();
-    c->Use(ip*15, (ip+1)*15, cc);
+//    printf("dx[%5.2f] sy[%f]\n", (*dx)[ip], TMath::Sqrt(cc[0]));
+    for(Int_t ic(0), jp(ip*15); ic<15; ic++, jp++) (*c)[jp]=cc[ic];
     ip++;
   }
+  return kTRUE;
 }
index 508fd5a..1c68cb1 100644 (file)
@@ -35,18 +35,19 @@ public:
     virtual ~AliESDinfo();
     AliESDinfo& operator=(const AliESDinfo &esd);
     void Delete(const Option_t *);
-    Bool_t      HasV0() const {return fHasV0;}
-    Int_t       GetId() const {return fId;}
-    ULong_t     GetStatus() const {return fStatus;}
-    Int_t       GetKinkIndex() const {return fKinkIndex;}
-    UShort_t    GetTPCncls() const {return fTPCncls;}
-    UChar_t     GetPidQuality() const {return fTRDpidQuality;}
-    Int_t       GetNSlices() const {return fTRDnSlices;}
-    Double32_t* GetSliceIter() const {return fTRDslices;}
-    const Double32_t* GetResponseIter() const {return &fTRDr[0];}
+    Bool_t      HasV0() const                    { return fHasV0;}
+    Int_t       GetId() const                    { return fId;}
+    ULong_t     GetStatus() const                { return fStatus;}
+    Int_t       GetKinkIndex() const             { return fKinkIndex;}
+    UShort_t    GetTOFbc() const                 { return fTOFbc;}
+    UShort_t    GetTPCncls() const               { return fTPCncls;}
+    UChar_t     GetPidQuality() const            { return fTRDpidQuality;}
+    Int_t       GetNSlices() const               { return fTRDnSlices;}
+    Double32_t* GetSliceIter() const             { return fTRDslices;}
+    const Double32_t* GetResponseIter() const    { return &fTRDr[0];}
     AliExternalTrackParam* GetOuterParam() const { return fOP;}
-    const Int_t* GetV0pid() const {return &fTRDv0pid[0];}
-    Int_t       GetV0pid(Int_t i) const {return fTRDv0pid[i];}
+    const Int_t* GetV0pid() const                { return &fTRDv0pid[0];}
+    Int_t       GetV0pid(Int_t i) const          { return fTRDv0pid[i];}
 
   protected:
     UChar_t     fHasV0;         // v0 bit
@@ -54,6 +55,7 @@ public:
     ULong_t     fStatus;        // ESD track status
     Int_t       fKinkIndex;     // ESD kink index
     UShort_t    fTPCncls;       // Number of Clusters inside TPC
+    UShort_t    fTOFbc;         // TOF bunch crossing index
     Double32_t  fTRDr[AliPID::kSPECIES];  // TRD radial position
     UChar_t     fTRDpidQuality; // TRD PID quality
     Int_t       fTRDnSlices;    // number of slices used for PID
@@ -61,7 +63,7 @@ public:
     AliExternalTrackParam *fOP; // outer param
     Int_t  fTRDv0pid[AliPID::kSPECIES]; // PID from v0s
 
-    ClassDef(AliESDinfo, 3)     // ESD info related to TRD
+    ClassDef(AliESDinfo, 4)     // ESD info related to TRD
   };
 
   class AliMCinfo{
@@ -76,18 +78,22 @@ public:
     Int_t   GetNTrackRefs() const {return fNTrackRefs;}
     Int_t   GetPDG() const {return fPDG;}
     Int_t   GetPID() const ;
-    Bool_t  GetDirections(Float_t &x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx, Float_t &pt, UChar_t &s) const;
+    Bool_t  GetDirections(Float_t &x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx, Float_t &pt, Float_t &eta, UChar_t &s) const;
     AliTrackReference const* GetTrackRef(Int_t ref=0) const {return fTrackRefs[ref];}
     static Double_t GetKalmanStep() {return fgKalmanStep;}
-    void    PropagateKalman(
-        TVectorD *dx, TVectorD *dy, TVectorD *dz, 
-        TVectorD *pt, TVectorD *dpt, TVectorD *c) const;
+    static Bool_t IsKalmanUpdate() {return fgKalmanUpdate;}
+    Bool_t   PropagateKalman(
+        TVectorD *x, TVectorD *y, TVectorD *z,
+        TVectorD *dx, TVectorD *dy, TVectorD *dz,
+        TVectorD *pt, TVectorD *dpt, TVectorD *budget, TVectorD *c, Double_t mass=-1) const;
     static void SetKalmanStep(Double_t s) {fgKalmanStep = s;}
+    static void SetKalmanUpdate(Bool_t s=kTRUE) {fgKalmanUpdate = s;}
   protected:
     Int_t   fLabel;               // MC label  
     Int_t   fPDG;                 // particle code
     Int_t   fNTrackRefs;           // number of track refs
     static Double_t fgKalmanStep; // Kalman step propagation
+    static Bool_t fgKalmanUpdate; // Kalman update with TRD tracklets
     AliTrackReference  *fTrackRefs[kNTrackRefs];       // track refs array
 
     ClassDef(AliMCinfo, 2)      // MC info related to TRD
@@ -101,45 +107,47 @@ public:
   void               Delete(const Option_t *);
   AliTRDtrackInfo&   operator=(const AliTRDtrackInfo &trdInfo);
   void               AddTrackRef(const AliTrackReference *trackRef);
-  Int_t              GetTrackId() const { return fESD.fId;}
-  const AliESDinfo*  GetESDinfo() const { return &fESD; }
-  const AliMCinfo*   GetMCinfo() const { return fMC; }
+  Int_t              GetTrackId() const               { return fESD.fId;}
+  const AliESDinfo*  GetESDinfo() const               { return &fESD; }
+  const AliMCinfo*   GetMCinfo() const                { return fMC; }
   Int_t              GetNumberOfClusters() const;
-  Int_t              GetNumberOfClustersRefit() const {return fNClusters;}
+  Int_t              GetNumberOfClustersRefit() const { return fNClusters;}
   Int_t              GetNTracklets() const;
-  Int_t              GetNTrackRefs() const {return fMC ? fMC->fNTrackRefs:0;} 
-  Int_t              GetLabel() const { return fMC ? fMC->fLabel:0; }
-  Int_t              GetKinkIndex() const { return fESD.fKinkIndex;}
-  UShort_t           GetTPCncls() const { return fESD.fTPCncls;}
-  Int_t              GetPDG() const { return fMC ? fMC->fPDG : 0; }
-  Int_t              GetPID() const { return fMC ? fMC->GetPID() : -1; }
-  ULong_t            GetStatus() const {return fESD.fStatus;}
-  AliTRDtrackV1*     GetTrack() const { return fTRDtrack; }
+  Int_t              GetNTrackRefs() const            { return fMC ? fMC->fNTrackRefs:0;} 
+  Int_t              GetLabel() const                 { return fMC ? fMC->fLabel:0; }
+  Int_t              GetKinkIndex() const             { return fESD.fKinkIndex;}
+  UShort_t           GetTOFbc() const                 { return fESD.fTOFbc;}
+  UShort_t           GetTPCncls() const               { return fESD.fTPCncls;}
+  Int_t              GetPDG() const                   { return fMC ? fMC->fPDG : 0; }
+  Int_t              GetPID() const                   { return fMC ? fMC->GetPID() : -1; }
+  ULong_t            GetStatus() const                { return fESD.fStatus;}
+  AliTRDtrackV1*     GetTrack() const                 { return fTRDtrack; }
   AliTrackReference* GetTrackRef(Int_t entry) const;
   AliTrackReference* GetTrackRef(const AliTRDseedV1* const tracklet) const;
 
-  Bool_t             IsCurved() const {return TestBit(kCurv);}
-  Bool_t             IsPrimary() const {return TestBit(kPrim);}
-  Bool_t             HasESDtrack() const{return ((fTRDtrack != 0x0) ||(fESD.fOP != 0));}
-  Bool_t             HasMCinfo() const { return (Bool_t)fMC; }
+  Bool_t             IsCurved() const                 { return TestBit(kCurv);}
+  Bool_t             IsPrimary() const                { return TestBit(kPrim);}
+  Bool_t             HasESDtrack() const              { return ((fTRDtrack != 0x0) ||(fESD.fOP != 0));}
+  Bool_t             HasMCinfo() const                { return (Bool_t)fMC; }
 
-  void               SetCurved(Bool_t curv = kTRUE) {SetBit(kCurv, curv);}
-  void               SetLabel(Int_t lab) {if(fMC) fMC->fLabel = lab; }
-  void               SetNumberOfClustersRefit(Int_t n) {fNClusters = n;}
+  void               SetCurved(Bool_t curv = kTRUE)   { SetBit(kCurv, curv);}
+  void               SetLabel(Int_t lab)              { if(fMC) fMC->fLabel = lab; }
+  void               SetNumberOfClustersRefit(Int_t n){fNClusters = n;}
   inline void        SetMC();
-  void               SetPDG(Int_t pdg) {if(fMC) fMC->fPDG = pdg; }
-  void               SetPrimary(Bool_t prim = kTRUE) {SetBit(kPrim, prim);}
+  void               SetPDG(Int_t pdg)                { if(fMC) fMC->fPDG = pdg; }
+  void               SetPrimary(Bool_t prim = kTRUE)  {SetBit(kPrim, prim);}
   void               SetOuterParam(const AliExternalTrackParam *op);
-  void               SetStatus(ULong_t stat) {fESD.fStatus = stat;}
-  void               SetKinkIndex(Int_t kinkIndex) {fESD.fKinkIndex = kinkIndex;}
-  void               SetTPCncls(UShort_t TPCncls) {fESD.fTPCncls = TPCncls;}
-  void               SetTrackId(Int_t id) {fESD.fId = id;}
+  void               SetStatus(ULong_t stat)          { fESD.fStatus = stat;}
+  void               SetKinkIndex(Int_t kinkIndex)    { fESD.fKinkIndex = kinkIndex;}
+  void               SetTOFbc(UShort_t bc)            { fESD.fTOFbc = bc;}
+  void               SetTPCncls(UShort_t TPCncls)     { fESD.fTPCncls = TPCncls;}
+  void               SetTrackId(Int_t id)             { fESD.fId = id;}
   void               SetTrack(const AliTRDtrackV1 *track);
-  void               SetESDpidQuality(UChar_t q) { fESD.fTRDpidQuality = q;}
+  void               SetESDpidQuality(UChar_t q)      { fESD.fTRDpidQuality = q;}
   void               SetSlices(Int_t n, Double32_t *s);
   inline void        SetESDpid(Double_t *);
   inline void        SetV0pid(Int_t *);
-  void               SetV0(Bool_t v0=kTRUE) {fESD.fHasV0 = v0;}
+  void               SetV0(Bool_t v0=kTRUE)           { fESD.fHasV0 = v0;}
   
 private:
     enum{
diff --git a/PWG1/TRD/macros/AddTRDcheckTRK.C b/PWG1/TRD/macros/AddTRDcheckTRK.C
new file mode 100644 (file)
index 0000000..838e102
--- /dev/null
@@ -0,0 +1,56 @@
+#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include "TTree.h"
+#include "TError.h"
+#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "TRD/AliTRDtrackerV1.h"
+#include "TRD/AliTRDtransform.h"
+#include "PWG1/TRD/AliTRDcheckTRK.h"
+#endif
+
+void AddTRDcheckTRK(AliAnalysisManager *mgr, Int_t /*map*/, AliAnalysisDataContainer **ci/*, AliAnalysisDataContainer **co*/)
+{
+  Info("AddTRDcheckTRK", Form("[0]=\"%s\" [1]=\"%s\"", ci[0]->GetName(), ci[1]->GetName()));
+
+  //AliLog::SetClassDebugLevel("AliTRDcheckTRK", 3);
+  // global settings for tracking
+  AliTRDcheckTRK::SetKalmanUpdate(kTRUE);
+  AliTRDcheckTRK::SetKalmanStep(0.2);
+  AliTRDcheckTRK::SetClRecalibrate(kTRUE);
+  AliTRDtrackerV1::SetBetheBloch(AliTRDtrackerV1::kGeant);
+/*  AliTRDtransform::SetVd(.2);
+  AliTRDtransform::SetT0(.2);
+  AliTRDtransform::SetExB(.2);*/
+  char bb[10];
+  switch(AliTRDtrackerV1::GetBetheBloch()){
+  case AliTRDtrackerV1::kGeant:
+    snprintf(bb, 10, "Geant"); break;
+  case AliTRDtrackerV1::kSolid:
+    snprintf(bb, 10, "Solid"); break;
+  case AliTRDtrackerV1::kGas:
+    snprintf(bb, 10, "Gas"); break;
+  }
+  Info("AddTRDcheckTRK", Form("Tracking settings:\n"
+    "  BetheBloch    [%s]\n"
+    "  KalmanUpdate  [%c]\n"
+    "  KalmanStep    [%f]\n"
+    "  ClRecalibrate [%c]\n"
+    , bb
+    , AliTRDcheckTRK::HasKalmanUpdate()?'y':'n'
+    , AliTRDcheckTRK::GetKalmanStep()
+    , AliTRDcheckTRK::HasClRecalibrate()?'y':'n'
+  ));
+
+  AliTRDcheckTRK *trk(NULL);;
+  mgr->AddTask(trk = new AliTRDcheckTRK((char*)"TRDcheckTRK"));
+  trk->SetDebugLevel(0);
+  trk->SetMCdata(mgr->GetMCtruthEventHandler());
+  trk->SetFriends(kTRUE);
+  mgr->ConnectInput( trk, 0, mgr->GetCommonInputContainer()); // connect main (ESD) container
+  mgr->ConnectInput( trk, 1, ci[0]);                          // connect barrel tracks container
+  mgr->ConnectInput( trk, 2, ci[1]);                          // connect event info container
+
+  mgr->ConnectOutput(trk, 1, mgr->CreateContainer(trk->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("%s:TRD_Performance",mgr->GetCommonFileName())));
+}
+
index b74a56e..87602ab 100644 (file)
@@ -24,11 +24,11 @@ void AddTRDresolution(AliAnalysisManager *mgr, Int_t map, AliAnalysisDataContain
     mgr->AddTask(res = new AliTRDresolution(Form("TRDresolution%s", suffix[itq])));
     res->SetMCdata(mgr->GetMCtruthEventHandler());
     res->SetPostProcess(kFALSE);
-    res->SetDebugLevel(0);
-    if(itq==0) res->SetSegmentationLevel(AliTRDresolution::kDetector);
+    //res->SetDebugLevel(3);
+    //if(itq==0) res->SetSegmentationLevel(AliTRDresolution::kDetector);
     // use these settings if you know what you are doing !
     //res->SetTrackRefit(); 
-    //res->SetPtThreshold(0.);
+    res->SetPtThreshold(0.2);
     res->SetNameId(suffix[itq]);
     mgr->ConnectInput(res, 0, mgr->GetCommonInputContainer()); // connect main (ESD) container 
     mgr->ConnectInput(res, 1, ci[itq]);                        // conect track info container
index 3c47d66..8944b55 100644 (file)
@@ -69,6 +69,7 @@
 #include "PWG1/TRD/macros/AddTRDefficiency.C"\r
 #include "PWG1/TRD/macros/AddTRDresolution.C"\r
 #include "PWG1/TRD/macros/AddTRDcheckPID.C"\r
+#include "PWG1/TRD/macros/AddTRDcheckTRK.C"\r
 #include "PWG1/TRD/macros/AddTRDv0Monitor.C"\r
 #endif\r
 \r
@@ -132,6 +133,12 @@ Bool_t AddTrainPerformanceTRD(Char_t *trd="ALL", const Char_t *addMacroPath = "$
       ce[2]=ci[AliTRDpwg1Helper::kV0List];\r
       AddTRDcheckPID(mgr, bitmap, ce, &ce[3]);\r
       break;\r
+    case AliTRDpwg1Helper::kCheckTRK:\r
+      // map slots\r
+      ce[0]=ci[AliTRDpwg1Helper::kTracksBarrel];\r
+      ce[1]=ci[AliTRDpwg1Helper::kEventInfo];\r
+      AddTRDcheckTRK(mgr, 0, ce);\r
+      break;\r
     case AliTRDpwg1Helper::kV0Monitor:\r
       // slots already mapped by checkPID\r
       AddTRDv0Monitor(mgr, 0, ce);\r