! MAJOR ! update in the TRD tracking
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Jan 2009 11:43:38 +0000 (11:43 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Jan 2009 11:43:38 +0000 (11:43 +0000)
 - cluster error parameterization
 - new clusters to tracklet method - with pad row cross
 - new tracklet fit method. correct covariance matrix calculation and radial
   position estimation
 - tilting pad correction used for updating the Kalman filter and not to
   correct individual clusters

14 files changed:
TRD/AliTRDseed.h
TRD/AliTRDseedV1.cxx
TRD/AliTRDseedV1.h
TRD/AliTRDtrackV1.cxx
TRD/AliTRDtrackerV1.cxx
TRD/AliTRDtrackerV1.h
TRD/qaRec/AliTRDcheckDetector.cxx
TRD/qaRec/AliTRDcheckDetector.h
TRD/qaRec/AliTRDpidChecker.cxx
TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.cxx
TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.h
TRD/qaRec/AliTRDtrackingResolution.cxx
TRD/qaRec/AliTRDtrackingResolution.h
TRD/qaRec/makeResults.C

index e8a85cc..9b4b68b 100644 (file)
@@ -18,7 +18,7 @@ class AliTRDcluster;
 class AliTRDseed : public TObject {
 
  public:
-       enum { knTimebins = 35 };
+       enum { knTimebins = 70/*35*/ };
 
   AliTRDseed(); 
   AliTRDseed(const AliTRDseed &s);
index d2a1367..b01663c 100644 (file)
@@ -187,22 +187,30 @@ Bool_t AliTRDseedV1::Init(AliTRDtrackV1 *track)
 
   Double_t y, z; 
   if(!track->GetProlongation(fX0, y, z)) return kFALSE;
-  fYref[0] = y;
-  fYref[1] = track->GetSnp()/(1. - track->GetSnp()*track->GetSnp());
-  fZref[0] = z;
-  fZref[1] = track->GetTgl();
-  
-  const Double_t *cov = track->GetCovariance();
-  fRefCov[0] = cov[0]; // Var(y)
-  fRefCov[1] = cov[1]; // Cov(yz)
-  fRefCov[2] = cov[5]; // Var(z)
-
-  //printf("Tracklet ref x[%7.3f] y[%7.3f] z[%7.3f], snp[%f] tgl[%f]\n", fX0, fYref[0], fZref[0], track->GetSnp(), track->GetTgl());
+  UpDate(track);
   return kTRUE;
 }
 
 
 //____________________________________________________________________
+void AliTRDseedV1::UpDate(const AliTRDtrackV1 *trk)
+{ 
+  // update tracklet reference position from the TRD track
+  // Funny name to avoid the clash with the function AliTRDseed::Update() (has to be made obselete)
+
+  fSnp = trk->GetSnp();
+  fTgl = trk->GetTgl();
+  fMom = trk->GetP();
+  fYref[1] = fSnp/(1. - fSnp*fSnp);
+  fZref[1] = fTgl;
+  SetCovRef(trk->GetCovariance());
+
+  Double_t dx = trk->GetX() - fX0;
+  fYref[0] = trk->GetY() - dx*fYref[1];
+  fZref[0] = trk->GetZ() - dx*fZref[1];
+}
+
+//____________________________________________________________________
 void AliTRDseedV1::CookdEdx(Int_t nslices)
 {
 // Calculates average dE/dx for all slices and store them in the internal array fdEdx. 
@@ -413,6 +421,8 @@ void AliTRDseedV1::GetCovAt(Double_t x, Double_t *cov) const
 // Alex Bercuci <A.Bercuci@gsi.de> 
 // Date : Jan 8th 2009
 //
+
+
   Double_t xr     = fX0-x; 
   Double_t sy2    = fCov[0] +2.*xr*fCov[1] + xr*xr*fCov[2];
   Double_t sz2    = fPadLength*fPadLength/12.;
@@ -607,16 +617,14 @@ Bool_t    AliTRDseedV1::AttachClustersIter(AliTRDtrackingChamber *chamber, Float_t
 
   if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=1) CookLabels();
 
-  // refit tracklet with errors
-  //SetExB(); Fit(kFALSE, 2);
-
+  // set ExB angle
+  SetExB();
   UpdateUsed();
   return kTRUE;        
 }
 
 //____________________________________________________________________
-Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber
-                                      ,Bool_t kZcorr)
+Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
 {
   //
   // Projective algorithm to attach clusters to seeding tracklets
@@ -633,127 +641,201 @@ Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber
   // 5. purge clusters
   // 6. fit tracklet
   //   
-
+  Bool_t kPRINT = kFALSE;
   if(!fReconstructor->GetRecoParam() ){
     AliError("Seed can not be used without a valid RecoParam.");
     return kFALSE;
   }
+  // Initialize reco params for this tracklet
+  // 1. first time bin in the drift region
+  Int_t t0 = 4;
+  Int_t kClmin = Int_t(fReconstructor->GetRecoParam() ->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins());
 
-  const Int_t kClusterCandidates = 2 * knTimebins;
-  
+  Double_t syRef  = TMath::Sqrt(fRefCov[0]);
   //define roads
-  Double_t kroady = fReconstructor->GetRecoParam() ->GetRoad1y();
+  Double_t kroady = 1.; 
+  //fReconstructor->GetRecoParam() ->GetRoad1y();
   Double_t kroadz = fPadLength * 1.5 + 1.;
-  // correction to y for the tilting angle
-  Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
+  if(kPRINT) printf("AttachClusters() sy[%f] road[%f]\n", syRef, kroady);
 
   // working variables
-  AliTRDcluster *clusters[kClusterCandidates];
-  Double_t cond[4], yexp[knTimebins], zexp[knTimebins],
-    yres[kClusterCandidates], zres[kClusterCandidates];
-  Int_t ncl, *index = 0x0, tboundary[knTimebins];
-  
+  const Int_t kNrows = 16;
+  AliTRDcluster *clst[kNrows][knTimebins];
+  Double_t cond[4], dx, dy, yt, zt,
+    yres[kNrows][knTimebins];
+  Int_t idxs[kNrows][knTimebins], ncl[kNrows], ncls = 0;
+  memset(ncl, 0, kNrows*sizeof(Int_t));
+  memset(clst, 0, kNrows*knTimebins*sizeof(AliTRDcluster*));
+
   // Do cluster projection
+  AliTRDcluster *c = 0x0;
   AliTRDchamberTimeBin *layer = 0x0;
-  Int_t nYclusters = 0; Bool_t kEXIT = kFALSE;
-  for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
-    if(!(layer = chamber->GetTB(iTime))) continue;
+  Bool_t kBUFFER = kFALSE;
+  for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
+    if(!(layer = chamber->GetTB(it))) continue;
     if(!Int_t(*layer)) continue;
     
-    fX[iTime] = layer->GetX() - fX0;
-    zexp[iTime] = fZref[0] + fZref[1] * fX[iTime];
-    yexp[iTime] = fYref[0] + fYref[1] * fX[iTime] - zcorr;
-    
-    // build condition and process clusters
-    cond[0] = yexp[iTime] - kroady; cond[1] = yexp[iTime] + kroady;
-    cond[2] = zexp[iTime] - kroadz; cond[3] = zexp[iTime] + kroadz;
-    layer->GetClusters(cond, index, ncl);
-    for(Int_t ic = 0; ic<ncl; ic++){
-      AliTRDcluster *c = layer->GetCluster(index[ic]);
-      clusters[nYclusters] = c;
-      yres[nYclusters++] = c->GetY() - yexp[iTime];
-      if(nYclusters >= kClusterCandidates) {
-        AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kClusterCandidates));
-        kEXIT = kTRUE;
+    dx   = fX0 - layer->GetX();
+    yt = fYref[0] - fYref[1] * dx;
+    zt = fZref[0] - fZref[1] * dx;
+    if(kPRINT) printf("\t%2d dx[%f] yt[%f] zt[%f]\n", it, dx, yt, zt);
+
+    // select clusters on a 5 sigmaKalman level
+    cond[0] = yt; cond[2] = kroady;
+    cond[1] = zt; cond[3] = kroadz;
+    Int_t n=0, idx[6];
+    layer->GetClusters(cond, idx, n, 6);
+    for(Int_t ic = n; ic--;){
+      c  = (*layer)[idx[ic]];
+      dy = yt - c->GetY();
+      dy += tilt ? fTilt * (c->GetZ() - zt) : 0.;
+      // select clusters on a 3 sigmaKalman level
+/*      if(tilt && TMath::Abs(dy) > 3.*syRef){ 
+        printf("too large !!!\n");
+        continue;
+      }*/
+      Int_t r = c->GetPadRow();
+      if(kPRINT) printf("\t\t%d dy[%f] yc[%f] r[%d]\n", ic, TMath::Abs(dy), c->GetY(), r);
+      clst[r][ncl[r]] = c;
+      idxs[r][ncl[r]] = idx[ic];
+      yres[r][ncl[r]] = dy;
+      ncl[r]++; ncls++;
+
+      if(ncl[r] >= knTimebins) {
+        AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", knTimebins));
+        kBUFFER = kTRUE;
         break;
       }
     }
-    tboundary[iTime] = nYclusters;
-    if(kEXIT) break;
+    if(kBUFFER) break;
   }
-  
-  // Evaluate truncated mean on the y direction
-  Double_t mean, sigma;
-  AliMathBase::EvaluateUni(nYclusters, yres, mean, sigma, Int_t(nYclusters*.8)-2);
-  // purge cluster candidates
-  Int_t nZclusters = 0;
-  for(Int_t ic = 0; ic<nYclusters; ic++){
-    if(yres[ic] - mean > 4. * sigma){
-      clusters[ic] = 0x0;
-      continue;
+  if(kPRINT) printf("Found %d clusters\n", ncls);
+  if(ncls<kClmin) return kFALSE;
+  // analyze each row individualy
+  Double_t mean, syDis;
+  Int_t nrow[] = {0, 0, 0}, nr = 0, lr=-1;
+  for(Int_t ir=kNrows; ir--;){
+    if(!(ncl[ir])) continue;
+    if(lr>0 && lr-ir != 1){
+      if(kPRINT) printf("W - gap in rows attached !!\n"); 
     }
-    zres[nZclusters++] = clusters[ic]->GetZ() - zexp[clusters[ic]->GetLocalTimeBin()];
+    if(kPRINT) printf("\tir[%d] lr[%d] n[%d]\n", ir, lr, ncl[ir]);
+    // Evaluate truncated mean on the y direction
+    if(ncl[ir] > 3) AliMathBase::EvaluateUni(ncl[ir], yres[ir], mean, syDis, Int_t(ncl[ir]*.8));
+    else {
+      mean = 0.; syDis = 0.;
+    } 
+
+    // TODO check mean and sigma agains cluster resolution !!
+    if(kPRINT) printf("\tr[%2d] m[%f %5.3fsigma] s[%f]\n", ir, mean, TMath::Abs(mean/syRef), syDis);
+    // select clusters on a 3 sigmaDistr level
+    Bool_t kFOUND = kFALSE;
+    for(Int_t ic = ncl[ir]; ic--;){
+      if(yres[ir][ic] - mean > 3. * syDis){ 
+        clst[ir][ic] = 0x0; continue;
+      }
+      nrow[nr]++; kFOUND = kTRUE;
+    }
+    // exit loop
+    if(kFOUND) nr++; 
+    lr = ir; if(nr>=3) break;
   }
-  
-  // Evaluate truncated mean on the z direction
-  AliMathBase::EvaluateUni(nZclusters, zres, mean, sigma, Int_t(nZclusters*.8)-2);
-  // purge cluster candidates
-  for(Int_t ic = 0; ic<nZclusters; ic++){
-    if(zres[ic] - mean > 4. * sigma){
-      clusters[ic] = 0x0;
-      continue;
+  if(kPRINT) printf("lr[%d] nr[%d] nrow[0]=%d nrow[1]=%d nrow[2]=%d\n", lr, nr, nrow[0], nrow[1], nrow[2]);
+
+  // classify cluster rows
+  Int_t row = -1;
+  switch(nr){
+  case 1:
+    row = lr;
+    break;
+  case 2:
+    SetBit(kRowCross, kTRUE); // mark pad row crossing
+    if(nrow[0] > nrow[1]){ row = lr+1; lr = -1;}
+    else{ 
+      row = lr; lr = 1;
+      nrow[2] = nrow[1];
+      nrow[1] = nrow[0];
+      nrow[0] = nrow[2];
     }
+    break;
+  case 3:
+    SetBit(kRowCross, kTRUE); // mark pad row crossing
+    break;
   }
+  if(kPRINT) printf("\trow[%d] n[%d]\n\n", row, nrow[0]);
+  if(row<0) return kFALSE;
 
-  
-  // Select only one cluster/TimeBin
-  Int_t lastCluster = 0;
+  // Select and store clusters 
+  // We should consider here :
+  //  1. How far is the chamber boundary
+  //  2. How big is the mean
   fN2 = 0;
-  for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
-    ncl = tboundary[iTime] - lastCluster;
-    if(!ncl) continue;
-    Int_t iptr = lastCluster;
-    if(ncl > 1){
-      Float_t dold = 9999.;
-      for(int ic=lastCluster; ic<tboundary[iTime]; ic++){
-        if(!clusters[ic]) continue;
-        Float_t y = yexp[iTime] - clusters[ic]->GetY();
-        Float_t z = zexp[iTime] - clusters[ic]->GetZ();
-        Float_t d = y * y + z * z;
-        if(d > dold) continue;
-        dold = d;
-        iptr = ic;
-      }
-    }
-    fIndexes[iTime]  = chamber->GetTB(iTime)->GetGlobalIndex(iptr);
-    fClusters[iTime] = clusters[iptr];
-    fY[iTime]        = clusters[iptr]->GetY();
-    fZ[iTime]        = clusters[iptr]->GetZ();
-    lastCluster      = tboundary[iTime];
-    fN2++;
-  }
+  for (Int_t ir = 0; ir < nr; ir++) {
+    Int_t jr = row + ir*lr; 
+    if(kPRINT) printf("\tattach %d clusters for row %d\n", ncl[jr], jr);
+    for (Int_t ic = 0; ic < ncl[jr]; ic++) {
+      if(!(c = clst[jr][ic])) continue;
+      Int_t it = c->GetPadTime();
+      // TODO proper indexing of clusters !!
+      fIndexes[it+35*ir]  = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]);
+      fClusters[it+35*ir] = c;
   
+      //printf("\tid[%2d] it[%d] idx[%d]\n", ic, it, fIndexes[it]);
+  
+      fN2++;
+    }
+  }  
+
   // number of minimum numbers of clusters expected for the tracklet
-  Int_t kClmin = Int_t(fReconstructor->GetRecoParam() ->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins());
   if (fN2 < kClmin){
     AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin));
     fN2 = 0;
     return kFALSE;
   }
 
-  // update used clusters
+  // update used clusters and select
   fNUsed = 0;
-  for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
-    if(!fClusters[iTime]) continue;
-    if((fClusters[iTime]->IsUsed())) fNUsed++;
+  for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
+    if(fClusters[it] && fClusters[it]->IsUsed()) fNUsed++;
+    if(fClusters[it+35] && fClusters[it+35]->IsUsed()) fNUsed++;
   }
-
   if (fN2-fNUsed < kClmin){
-    AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2));
+    //AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2));
     fN2 = 0;
     return kFALSE;
   }
-  
+
+  // set the Lorentz angle for this tracklet  
+  SetExB();
+
+  // calculate dx for time bins in the drift region (calibration aware)
+  Int_t irp = 0; Float_t x[2]; Int_t tb[2];
+  for (Int_t it = t0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
+    if(!fClusters[it]) continue;
+    x[irp]  = fClusters[it]->GetX();
+    tb[irp] = it;
+    irp++;
+    if(irp==2) break;
+  } 
+  fdX = (x[1] - x[0]) / (tb[0] - tb[1]);
+
+  // update X0 from the clusters (calibration/alignment aware) TODO remove dependence on x0 !!
+  for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
+    if(!(layer = chamber->GetTB(it))) continue;
+    if(!layer->IsT0()) continue;
+    if(fClusters[it]){ 
+      fX0 = fClusters[it]->GetX();
+      break;
+    } else { // we have to infere the position of the anode wire from the other clusters
+      for (Int_t jt = it+1; jt < AliTRDtrackerV1::GetNTimeBins(); jt++) {
+        if(!fClusters[jt]) continue;
+        fX0 = fClusters[jt]->GetX() + fdX * (jt - it);
+        break;
+      }
+    }
+  }    
+
   return kTRUE;
 }
 
@@ -851,25 +933,25 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
   Double_t yt, zt;
 
   const Int_t kNtb = AliTRDtrackerV1::GetNTimeBins();
-  AliTRDtrackerV1::AliTRDLeastSquare fitterZ;
+  //AliTRDtrackerV1::AliTRDLeastSquare fitterZ;
   TLinearFitter  fitterY(1, "pol1");
   // convertion factor from square to gauss distribution for sigma
-  Double_t convert = 1./TMath::Sqrt(12.);
+  //Double_t convert = 1./TMath::Sqrt(12.);
   
   // book cluster information
-  Double_t q, xc[knTimebins], yc[knTimebins], zc[knTimebins], sy[knTimebins], sz[knTimebins];
-  Int_t zRow[knTimebins];
+  Double_t q, xc[knTimebins], yc[knTimebins], zc[knTimebins], sy[knTimebins]/*, sz[knTimebins]*/;
+//   Int_t zRow[knTimebins];
   
   Int_t ily = AliTRDgeometry::GetLayer(fDet);
-  fN = 0; fXref = 0.; Double_t ssx = 0.;
+  fN = 0; //fXref = 0.; Double_t ssx = 0.;
   AliTRDcluster *c=0x0, **jc = &fClusters[0];
   for (Int_t ic=0; ic<kNtb; ic++, ++jc) {
-    zRow[ic] = -1;
+    //zRow[ic] = -1;
     xc[ic]  = -1.;
     yc[ic]  = 999.;
     zc[ic]  = 999.;
     sy[ic]  = 0.;
-    sz[ic]  = 0.;
+    //sz[ic]  = 0.;
     if(!(c = (*jc))) continue;
     if(!c->IsInChamber()) continue;
 
@@ -877,7 +959,7 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
     if(c->GetNPads()>4) w = .5;
     if(c->GetNPads()>5) w = .2;
 
-    zRow[fN] = c->GetPadRow();
+    //zRow[fN] = c->GetPadRow();
     // correct cluster position for PRF and v drift
     Double_t x, y; GetClusterXY(c, x, y);
     xc[fN]   = fX0 - x;
@@ -915,7 +997,7 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
     //sx += sxd0 + sxd1*d + sxd2*d*d;
     sx *= sx; // square sx
     // update xref
-    fXref += xc[fN]/sx; ssx+=1./sx;
+    //fXref += xc[fN]/sx; ssx+=1./sx;
 
     // add error from ExB 
     if(errors>0) sy[fN] += fExB*fExB*sx;
@@ -931,9 +1013,6 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
 
     sy[fN]  = TMath::Sqrt(sy[fN]);
     fitterY.AddPoint(&xc[fN], yc[fN]/*-yt*/, sy[fN]);
-
-    sz[fN]   = fPadLength*convert;
-    fitterZ.AddPoint(&xc[fN], zc[fN], sz[fN]);
     fN++;
   }
   // to few clusters
@@ -948,62 +1027,61 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
   fCov[0] = p[0]; // variance of y0
   fCov[1] = p[1]; // covariance of y0, dydx
   fCov[2] = p[3]; // variance of dydx
-  // store ref radial position.
-  fXref /= ssx; fXref = fX0 - fXref;
-
-  // check par row crossing
-  Int_t zN[2*AliTRDseed::knTimebins];
-  Int_t nz = AliTRDtrackerV1::Freq(fN, zRow, zN, kFALSE);
-  // more than one pad row crossing
-  if(nz>2) return kFALSE; 
-
-
-  // determine z offset of the fit
-  Float_t zslope = 0.;
-  Int_t nchanges = 0, nCross = 0;
-  if(nz==2){ // tracklet is crossing pad row
-    // Find the break time allowing one chage on pad-rows
-    // with maximal number of accepted clusters
-    Int_t padRef = zRow[0];
-    for (Int_t ic=1; ic<fN; ic++) {
-      if(zRow[ic] == padRef) continue;
-      
-      // debug
-      if(zRow[ic-1] == zRow[ic]){
-        printf("ERROR in pad row change!!!\n");
-      }
-    
-      // evaluate parameters of the crossing point
-      Float_t sx = (xc[ic-1] - xc[ic])*convert;
-      fCross[0] = .5 * (xc[ic-1] + xc[ic]);
-      fCross[2] = .5 * (zc[ic-1] + zc[ic]);
-      fCross[3] = TMath::Max(dzdx * sx, .01);
-      zslope    = zc[ic-1] > zc[ic] ? 1. : -1.;
-      padRef    = zRow[ic];
-      nCross    = ic;
-      nchanges++;
-    }
+  // the ref radial position is set at the minimum of 
+  // the y variance of the tracklet
+  fXref = -fCov[1]/fCov[2]; //fXref = fX0 - fXref;
+
+  // fit XZ
+  if(IsRowCross()){ 
+    // TODO pad row cross position estimation !!!
+    //AliInfo(Form("Padrow cross in detector %d", fDet));
+    fZfit[0] = .5*(zc[0]+zc[fN-1]); fZfit[1] = 0.;
+  } else {
+    fZfit[0] = zc[0]; fZfit[1] = 0.;
   }
 
-  // condition on nCross and reset nchanges TODO
 
-  if(nchanges==1){
-    if(dzdx * zslope < 0.){
-      AliInfo("tracklet direction does not correspond to the track direction. TODO.");
-    }
-    SetBit(kRowCross, kTRUE); // mark pad row crossing
-    fitterZ.AddPoint(&fCross[0], fCross[2], fCross[3]);
-    fitterZ.Eval();
-    //zc[nc] = fitterZ.GetFunctionParameter(0); 
-    fCross[1] = fYfit[0] - fCross[0] * fYfit[1];
-    fCross[0] = fX0 - fCross[0];
-  } else if(nchanges > 1){ // debug
-    AliError("N pad row crossing > 1.");
-    return kFALSE;
-  }
+//   // determine z offset of the fit
+//   Float_t zslope = 0.;
+//   Int_t nchanges = 0, nCross = 0;
+//   if(nz==2){ // tracklet is crossing pad row
+//     // Find the break time allowing one chage on pad-rows
+//     // with maximal number of accepted clusters
+//     Int_t padRef = zRow[0];
+//     for (Int_t ic=1; ic<fN; ic++) {
+//       if(zRow[ic] == padRef) continue;
+//       
+//       // debug
+//       if(zRow[ic-1] == zRow[ic]){
+//         printf("ERROR in pad row change!!!\n");
+//       }
+//     
+//       // evaluate parameters of the crossing point
+//       Float_t sx = (xc[ic-1] - xc[ic])*convert;
+//       fCross[0] = .5 * (xc[ic-1] + xc[ic]);
+//       fCross[2] = .5 * (zc[ic-1] + zc[ic]);
+//       fCross[3] = TMath::Max(dzdx * sx, .01);
+//       zslope    = zc[ic-1] > zc[ic] ? 1. : -1.;
+//       padRef    = zRow[ic];
+//       nCross    = ic;
+//       nchanges++;
+//     }
+//   }
+// 
+//   // condition on nCross and reset nchanges TODO
+// 
+//   if(nchanges==1){
+//     if(dzdx * zslope < 0.){
+//       AliInfo("Tracklet-Track mismatch in dzdx. TODO.");
+//     }
+// 
+// 
+//     //zc[nc] = fitterZ.GetFunctionParameter(0); 
+//     fCross[1] = fYfit[0] - fCross[0] * fYfit[1];
+//     fCross[0] = fX0 - fCross[0];
+//   }
 
   UpdateUsed();
-
   return kTRUE;
 }
 
index f22c546..a9fa408 100644 (file)
@@ -58,7 +58,7 @@ class AliTRDseedV1 : public AliTRDseed
               AliTRDtrackingChamber *chamber, Float_t quality, 
               Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);
   Bool_t         AttachClusters(
-              AliTRDtrackingChamber *chamber, Bool_t kZcorr = kFALSE);
+              AliTRDtrackingChamber *chamber, Bool_t tilt = kFALSE);
   void      Bootstrap(const AliTRDReconstructor *rec);
   void      CookdEdx(Int_t nslices);
   Bool_t    Fit(Bool_t tilt=kTRUE, Int_t errors = 2);
@@ -90,9 +90,9 @@ class AliTRDseedV1 : public AliTRDseed
   Double_t* GetProbability();
   Double_t  GetSnp() const           { return fSnp;}
   Double_t  GetTgl() const           { return fTgl;}
-  Float_t   GetXref() const          { return fXref;}
-  Double_t  GetYat(Double_t x) const { return fYfit[0] + fYfit[1] * (fX0-x);}
-  Double_t  GetZat(Double_t x) const { return fZfit[0] + fZfit[1] * (fX0-x);}
+  Float_t   GetXref() const          { return fX0 - fXref;}
+  Double_t  GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
+  Double_t  GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
   
   inline AliTRDcluster* NextCluster();
   inline AliTRDcluster* PrevCluster();
@@ -107,6 +107,7 @@ class AliTRDseedV1 : public AliTRDseed
   void      SetSnp(Double_t snp)     { fSnp = snp;}
   void      SetTgl(Double_t tgl)     { fTgl = tgl;}
   void      SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
+  void      UpDate(const AliTRDtrackV1* trk);
 
 protected:
   void Copy(TObject &ref) const;
index 38c954a..16294af 100644 (file)
@@ -730,35 +730,39 @@ Bool_t  AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq)
   // Update track and tracklet parameters 
   //
   
-  Double_t x      = trklt->GetX0();
+  Double_t x      = GetX();
   Double_t p[2]   = { trklt->GetYat(x)
                     , trklt->GetZat(x) };
-  Double_t cov[3];
-  trklt->GetCovAt(x, cov);
-  
+  Double_t cov[3], covR[3], cov0[3];
+
+//   printf("\tD[%3d] Ly[%d] Trk: x[%f] y[%f] z[%f]\n", trklt->GetDetector(), trklt->GetPlane(), GetX(), GetY(), GetZ());
+// //   
+//   Double_t xref = trklt->GetXref();
+//   trklt->GetCovAt(xref, covR);
+//   printf("xr=%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", xref, trklt->GetYat(xref), TMath::Sqrt(covR[0]), trklt->GetZat(xref), TMath::Sqrt(covR[2]), covR[1]);
+// 
+//   Double_t x0 = trklt->GetX0();
+//   trklt->GetCovAt(x0, cov0);
+//   printf("x0=%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", x0, trklt->GetYat(x0), TMath::Sqrt(cov0[0]), trklt->GetZat(x0), TMath::Sqrt(cov0[2]), cov0[1]);
+// 
+//   trklt->GetCovAt(x, cov);
+//   printf("x =%5.3f y=%f+-%f z=%f+-%f (covYZ=%f)\n", x, p[0], TMath::Sqrt(cov[0]), p[1], TMath::Sqrt(cov[2]), cov[1]);
+// 
+//   const Double_t *cc = GetCovariance();
+//   printf("yklm[0] = %f +- %f\n", GetY(), TMath::Sqrt(cc[0]));
+
+  trklt->GetCovAt(x, cov); 
   if(!AliExternalTrackParam::Update(p, cov)) return kFALSE;
-  
+//   cc = GetCovariance();
+//   printf("yklm[1] = %f +- %f\n", GetY(), TMath::Sqrt(cc[0]));
+
   AliTRDcluster *c = 0x0;
   Int_t ic = 0; while(!(c = trklt->GetClusters(ic))) ic++;
   AliTracker::FillResiduals(this, p, cov, c->GetVolumeId());
   
-  
   // Register info to track
   SetNumberOfClusters();
   SetChi2(GetChi2() + chisq);
-  
-  // update tracklet
-  Float_t snp = GetSnp();
-  Float_t tgl = GetTgl();
-  trklt->SetMomentum(GetP());
-  trklt->SetYref(0, GetY());
-  trklt->SetYref(1, snp/(1. - snp*snp));
-  trklt->SetZref(0,  GetZ());
-  trklt->SetZref(1, tgl);
-  const Double_t *cc = GetCovariance();
-  trklt->SetCovRef(cc);
-  trklt->SetSnp(snp);
-  trklt->SetTgl(tgl);
   return kTRUE;
 }
 
index f28fe59..c24a1f3 100644 (file)
@@ -263,7 +263,7 @@ Int_t AliTRDtrackerV1::PropagateBack(AliESDEvent *event)
       quality[iSeed] = covariance[0] + covariance[2];
     }
     // Sort tracks according to covariance of local Y and Z
-    TMath::Sort(nSeed,quality,index,kFALSE);
+    TMath::Sort(nSeed, quality, index,kFALSE);
   }
   
   // Backpropagate all seeds
@@ -607,7 +607,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
   //
 
   Int_t nClustersExpected = 0;
-  Double_t clength = AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick();
+  Double_t clength = .5*AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick();
   AliTRDtrackingChamber *chamber = 0x0;
   
   AliTRDseedV1 tracklet, *ptrTracklet = 0x0;
@@ -622,7 +622,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
   // Loop through the TRD layers
   for (Int_t ilayer = 0; ilayer < AliTRDgeometry::Nlayer(); ilayer++) {
     // BUILD TRACKLET IF NOT ALREADY BUILT
-    Double_t x = 0., y, z, alpha;
+    Double_t x = 0., x0, y, z, alpha;
     ptrTracklet  = tracklets[ilayer];
     if(!ptrTracklet){
       ptrTracklet = new(&tracklet) AliTRDseedV1(ilayer);
@@ -634,6 +634,12 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
       
       if((x = fTrSec[sector].GetX(ilayer)) < 1.) continue;
     
+      // Propagate closer to the current layer
+      x0 = x - 1.5*clength;
+      if (x0 > (fgkMaxStep + t.GetX()) && !PropagateToX(t, x0-fgkMaxStep, fgkMaxStep)) return -1/*nClustersExpected*/;
+      if (!AdjustSector(&t)) return -1/*nClustersExpected*/;
+      if (TMath::Abs(t.GetSnp()) > fgkMaxSnp) return -1/*nClustersExpected*/;
+
       if (!t.GetProlongation(x, y, z)) return -1/*nClustersExpected*/;
       Int_t stack = fGeom->GetStack(z, ilayer);
       Int_t nCandidates = stack >= 0 ? 1 : 2;
@@ -653,19 +659,21 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
         tracklet.SetPadLength(pp->GetLengthIPad());
         tracklet.SetDetector(chamber->GetDetector());
         tracklet.SetX0(x);
-        if(!tracklet.Init(&t)){
-          t.SetStopped(kTRUE);
-          return nClustersExpected;
-        }
-        if(!tracklet.AttachClustersIter(chamber, 1000./*, kTRUE*/)) continue;
-        tracklet.Init(&t);
+        tracklet.UpDate(&t);
+//         if(!tracklet.Init(&t)){
+//           t.SetStopped(kTRUE);
+//           return nClustersExpected;
+//         }
+        if(!tracklet.AttachClusters(chamber, kTRUE)) continue;
+        //if(!tracklet.AttachClustersIter(chamber, 1000.)) continue;
+        //tracklet.Init(&t);
         
         if(tracklet.GetN() < fgNTimeBins*fReconstructor->GetRecoParam() ->GetFindableClusters()) continue;
       
         break;
       }
       //ptrTracklet->UseClusters();
-    } else ptrTracklet->Init(&t);
+    }// else ptrTracklet->Init(&t);
     if(!ptrTracklet->IsOK()){
       if(x < 1.) continue; //temporary
       if(!PropagateToX(t, x-fgkMaxStep, fgkMaxStep)) return -1/*nClustersExpected*/;
@@ -681,6 +689,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
     if (TMath::Abs(t.GetSnp()) > fgkMaxSnp) return -1/*nClustersExpected*/;
     
     // load tracklet to the tracker and the track
+    ptrTracklet->Fit(kFALSE); // no tilt correction
     ptrTracklet = SetTracklet(ptrTracklet);
     t.SetTracklet(ptrTracklet, fTracklets->GetEntriesFast()-1);
   
@@ -690,7 +699,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
     Double_t xyz0[3]; // entry point 
     t.GetXYZ(xyz0);
     alpha = t.GetAlpha();
-    x = ptrTracklet->GetX0();
+    x = ptrTracklet->GetXref(); //GetX0();
     if (!t.GetProlongation(x, y, z)) return -1/*nClustersExpected*/;
     Double_t xyz1[3]; // exit point
     xyz1[0] =  x * TMath::Cos(alpha) - y * TMath::Sin(alpha); 
@@ -707,6 +716,8 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
     if (!AdjustSector(&t)) return -1/*nClustersExpected*/;
     Double_t maxChi2 = t.GetPredictedChi2(ptrTracklet);
     if (!t.Update(ptrTracklet, maxChi2)) return -1/*nClustersExpected*/;
+    ptrTracklet->UpDate(&t);
+
     if (maxChi2<1e+10) { 
       nClustersExpected += ptrTracklet->GetN();
       //t.SetTracklet(&tracklet, index);
@@ -1670,6 +1681,24 @@ void AliTRDtrackerV1::UnloadClusters()
   AliTRDtrackerDebug::SetEventNumber(AliTRDtrackerDebug::GetEventNumber()  + 1);
 }
 
+//____________________________________________________________________
+void AliTRDtrackerV1::UseClusters(const AliKalmanTrack *t, Int_t) const
+{
+  const AliTRDtrackV1 *track = dynamic_cast<const AliTRDtrackV1*>(t);
+  if(!track) return;
+
+  AliTRDseedV1 *tracklet = 0x0;
+  for(Int_t ily=AliTRDgeometry::kNlayer; ily--;){
+    if(!(tracklet = track->GetTracklet(ily))) continue;
+    AliTRDcluster *c = 0x0;
+    for(Int_t ic=AliTRDseed::knTimebins; ic--;){
+      if(!(c=tracklet->GetClusters(ic))) continue;
+      c->Use();
+    }
+  }
+}
+
+
 //_____________________________________________________________________________
 Bool_t AliTRDtrackerV1::AdjustSector(AliTRDtrackV1 *track) 
 {
index b560d7c..1dee8f0 100644 (file)
@@ -104,6 +104,7 @@ public:
   static void     SetNTimeBins(Int_t nTimeBins){fgNTimeBins = nTimeBins; }
   void            SetReconstructor(const AliTRDReconstructor *rec){ fReconstructor = rec; }
   void            UnloadClusters();
+  void            UseClusters(const AliKalmanTrack *t, Int_t from = 0) const;
   
   static Int_t    Freq(Int_t n, const Int_t *inlist, Int_t *outlist, Bool_t down); // to be removed 
 
index c92857f..290c946 100644 (file)
@@ -109,7 +109,7 @@ void AliTRDcheckDetector::Exec(Option_t *opt){
   Int_t triggermask = fEventInfo->GetEventHeader()->GetTriggerMask();
   TString triggername =  fEventInfo->GetRunInfo()->GetFiredTriggerClasses(triggermask);
   if(fDebugLevel > 6)printf("Trigger cluster: %d, Trigger class: %s\n", triggermask, triggername.Data());
-  dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger))->Fill(triggermask);
+  dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTrigger))->Fill(triggermask);
   for(Int_t iti = 0; iti < fTracks->GetEntriesFast(); iti++){
     if(!fTracks->UncheckedAt(iti)) continue;
     AliTRDtrackInfo *fTrackInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iti));
@@ -117,15 +117,15 @@ void AliTRDcheckDetector::Exec(Option_t *opt){
     nTracks++;
   }
   if(nTracks){
-    dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks))->Fill(triggermask);
-    dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist))->Fill(nTracks);
+    dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks))->Fill(triggermask);
+    dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtracksEvent))->Fill(nTracks);
   }
   if(triggermask <= 20 && !fTriggerNames->FindObject(Form("%d", triggermask))){
     fTriggerNames->Add(new TObjString(Form("%d", triggermask)), new TObjString(triggername));
     // also set the label for both histograms
-    TH1 *histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks));
+    TH1 *histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks));
     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
-    histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger));
+    histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTrigger));
     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
   }
   PostData(0, fContainer);
@@ -144,64 +144,41 @@ Bool_t AliTRDcheckDetector::PostProcess(){
   // Do Postprocessing (for the moment set the number of Reference histograms)
   //
   
-  TH1 * histo = 0x0;
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist));
-  histo->GetXaxis()->SetTitle("Number of Tracks");
-  histo->GetYaxis()->SetTitle("Events");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist));
-  histo->GetXaxis()->SetTitle("Number of Clusters");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist));
-  histo->GetXaxis()->SetTitle("Number of Tracklets");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTrackletsVsFindable));
-  histo->GetXaxis()->SetTitle("Ratio Found/Findable Tracklets");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist));
-  histo->GetXaxis()->SetTitle("Number of Clusters");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2));
-  histo->GetXaxis()->SetTitle("#chi^2");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist));
-  histo->GetXaxis()->SetTitle("Sector");
-  histo->GetYaxis()->SetTitle("Number of Tracks");
-  histo = dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight));
-  histo->GetXaxis()->SetTitle("Time / 100ns");
-  histo->GetYaxis()->SetTitle("Average Pulse Height (a. u.)");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge));
-  histo->GetXaxis()->SetTitle("Cluster Charge (a.u.)");
-  histo->GetYaxis()->SetTitle("Entries");
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit));
-  histo->GetXaxis()->SetTitle("Charge Deposit (a.u.)");
-  histo->GetYaxis()->SetTitle("Entries");
+  TH1 * h = 0x0;
+  h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsTrack));
+  if(h->GetEntries()) h->Scale(100./h->Integral());
+
+  h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsCross));
+  if(h->GetEntries()) h->Scale(100./h->Integral());
+
+  h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtracksSector));
+  if(h->GetEntries()) h->Scale(100./h->Integral());
   
-  // Calculate the purity of the trigger clusters
-  histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger));
-  TH1F *histoTracks = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks));
-  histoTracks->Divide(histo);
+  // Calculate of the trigger clusters purity
+  h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTrigger));
+  TH1F *h1 = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks));
+  h1->Divide(h);
   Float_t purities[20], val = 0;
   TString triggernames[20];
   Int_t nTriggerClasses = 0;
-  for(Int_t ibin = 1; ibin <= histo->GetNbinsX(); ibin++){
-    if((val = histoTracks->GetBinContent(ibin))){
+  for(Int_t ibin = 1; ibin <= h->GetNbinsX(); ibin++){
+    if((val = h1->GetBinContent(ibin))){
       purities[nTriggerClasses] = val;
-      triggernames[nTriggerClasses] = histoTracks->GetXaxis()->GetBinLabel(ibin);
+      triggernames[nTriggerClasses] = h1->GetXaxis()->GetBinLabel(ibin);
       nTriggerClasses++;
     }
   }
-  TH1F *hTriggerInf = new TH1F("fTriggerInf", "Trigger Information", TMath::Max(nTriggerClasses, 1), 0, TMath::Max(nTriggerClasses, 1));
-  for(Int_t ibin = 1; ibin <= nTriggerClasses; ibin++){
-    hTriggerInf->SetBinContent(ibin, purities[ibin-1]);
-    hTriggerInf->GetXaxis()->SetBinLabel(ibin, triggernames[ibin-1].Data());
-  }
-  hTriggerInf->GetXaxis()->SetTitle("Trigger Cluster");
-  hTriggerInf->GetYaxis()->SetTitle("Ratio");
-  hTriggerInf->GetYaxis()->SetRangeUser(0,1);
-//     hTriggerInf->SetMarkerColor(kBlue);
-//     hTriggerInf->SetMarkerStyle(22);
-  fContainer->Add(hTriggerInf);
+  h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kTriggerPurity));
+  TAxis *ax = h->GetXaxis();
+  for(Int_t itrg = 0; itrg < nTriggerClasses; itrg++){
+    h->Fill(itrg, purities[itrg]);
+    ax->SetBinLabel(itrg+1, triggernames[itrg].Data());
+  }
+  ax->SetRangeUser(-0.5, nTriggerClasses+.5);
+  h->GetYaxis()->SetRangeUser(0,1);
+
   fNRefFigures = 11;
+
   return kTRUE;
 }
 
@@ -210,58 +187,64 @@ Bool_t AliTRDcheckDetector::GetRefFigure(Int_t ifig){
   //
   // Setting Reference Figures
   //
+  TObjArray *arr = 0x0;
   TH1 *h = 0x0, *h1 = 0x0, *h2 = 0x0;
   TGaxis *axis = 0x0;
   switch(ifig){
-  case 0:      
-    ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl");
-    break;
-  case 1:
-    ((TH1F*)fContainer->At(kNclustersHist))->Draw("pl");
-    break;
-  case 2:
-    h = (TH1F*)fContainer->At(kNtrackletsHist);
+  case kNclustersTrack:
+    ((TH1F*)fContainer->At(kNclustersTrack))->Draw("pl");
+    return kTRUE;
+  case kNclustersTracklet:
+    ((TH1F*)fContainer->At(kNclustersTracklet))->Draw("pc");
+    return kTRUE;
+  case kNtrackletsTrack:
+    h = (TH1F*)fContainer->At(kNtrackletsTrack);
     if(!h->GetEntries()) break;
-    h->Scale(100./h->Integral());
-    h->GetXaxis()->SetRangeUser(.5, 6.5);
     h->SetFillColor(kGreen);
     h->SetBarOffset(.2);
     h->SetBarWidth(.6);
     h->Draw("bar1");
-    break;
-  case 3:
-    h = (TH1F*)fContainer->At(kNTrackletsVsFindable);
+    return kTRUE;
+  case kNtrackletsCross:
+    h = (TH1F*)fContainer->At(kNtrackletsCross);
+    if(!h->GetEntries()) break;
+    h->SetFillColor(kRed);
+    h->SetBarOffset(.2);
+    h->SetBarWidth(.6);
+    h->Draw("bar1");
+    return kTRUE;
+  case kNtrackletsFindable:
+    h = (TH1F*)fContainer->At(kNtrackletsFindable);
     if(!h->GetEntries()) break;
     h->Scale(100./h->Integral());
-    h->GetXaxis()->SetRangeUser(0.005, 1.005);
     h->SetFillColor(kGreen);
     h->SetBarOffset(.2);
     h->SetBarWidth(.6);
     h->Draw("bar1");
-    break;
-  case 4:
-    ((TH1F*)fContainer->At(kNclusterTrackletHist))->Draw("pc");
-    break;
-  case 5:
-    ((TH1F*)fContainer->At(kChi2))->Draw("");
-    break;
-  case 6:
-    h = (TH1F*)fContainer->At(kNTracksSectorHist);
+    return kTRUE;
+  case kNtracksEvent:
+    ((TH1F*)fContainer->At(kNtracksEvent))->Draw("pl");
+    return kTRUE;
+  case kNtracksSector:
+    h = (TH1F*)fContainer->At(kNtracksSector);
     if(!h->GetEntries()) break;
-    h->Scale(100./h->Integral());
     h->SetFillColor(kGreen);
     h->SetBarOffset(.2);
     h->SetBarWidth(.6);
     h->Draw("bar1");
-    break;
-  case 7:
-    h = (TH1F*)fContainer->At(kPulseHeight);
+    return kTRUE;
+  case kChi2:
+    ((TH1F*)((TObjArray*)fContainer->At(kChi2))->At(0))->Draw("");
+    return kTRUE;
+  case kPH:
+    arr = (TObjArray*)fContainer->At(kPH);
+    h = (TH1F*)arr->At(0);
     h->SetMarkerStyle(24);
     h->SetMarkerColor(kBlack);
     h->SetLineColor(kBlack);
     h->Draw("e1");
     // copy the second histogram in a new one with the same x-dimension as the phs with respect to time
-    h1 = (TH1F *)fContainer->At(kPulseHeightDistance);
+    h1 = (TH1F *)arr->At(1);
     h2 = new TH1F("hphs1","Average PH", 31, -0.5, 30.5);
     for(Int_t ibin = h1->GetXaxis()->GetFirst(); ibin < h1->GetNbinsX(); ibin++) 
       h2->SetBinContent(ibin, h1->GetBinContent(ibin));
@@ -279,27 +262,33 @@ Bool_t AliTRDcheckDetector::GetRefFigure(Int_t ifig){
     axis->SetLineColor(kBlue);
     axis->SetLabelColor(kBlue);
     axis->SetTextColor(kBlue);
-    axis->SetTitle("x_{c}-x_{0} / cm");
+    axis->SetTitle("x_{0}-x_{c} [cm]");
     axis->Draw();
-    break;
-  case 8:
-    ((TH1F*)fContainer->At(kClusterCharge))->Draw("c");
-    break;
-  case 9:
-    ((TH1F*)fContainer->At(kChargeDeposit))->Draw("c");
-    break;
-  case 10: 
-    h=(TH1F*)fContainer->At(kPurity);
+    return kTRUE;
+  case kChargeCluster:
+    ((TH1F*)fContainer->At(kChargeCluster))->Draw("c");
+    return kTRUE;
+  case kChargeTracklet:
+    ((TH1F*)fContainer->At(kChargeTracklet))->Draw("c");
+    return kTRUE;
+  case kNeventsTrigger:
+    ((TH1F*)fContainer->At(kNeventsTrigger))->Draw("");
+    return kTRUE;
+  case kNeventsTriggerTracks:
+    ((TH1F*)fContainer->At(kNeventsTriggerTracks))->Draw("");
+    return kTRUE;
+  case kTriggerPurity: 
+    h=(TH1F*)fContainer->At(kTriggerPurity);
     h->SetBarOffset(.2);
     h->SetBarWidth(.6);
     h->SetFillColor(kGreen);
     h->Draw("bar1");
     break;
   default:
-    ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl");
     break;
   }
-  return kTRUE;
+  AliInfo(Form("Reference plot [%d] missing result", ifig));
+  return kFALSE;
 }
 
 //_______________________________________________________
@@ -309,67 +298,121 @@ TObjArray *AliTRDcheckDetector::Histos(){
   //
   if(fContainer) return fContainer;
   
-  fContainer = new TObjArray(25);
+  fContainer = new TObjArray(14);
   //fContainer->SetOwner(kTRUE);
 
   // Register Histograms
-  TH1 * histptr = 0x0;
-  if(!(histptr = (TH1F *)gROOT->FindObject("hNtrks")))
-    histptr = new TH1F("hNtrks", "N_{tracks} / event", 100, 0, 100);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNTracksEventHist);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hEventsTriggerTracks")))
-    histptr = new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNEventsTriggerTracks);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hNcls")))
-    histptr = new TH1F("hNcls", "N_{clusters} / track", 181, -0.5, 180.5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNclustersHist);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hNtls")))
-    histptr = new TH1F("hNtls", "N_{tracklets} / track", 7, -0.5, 6.5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNtrackletsHist);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hNtlsFindable")))
-    histptr = new TH1F("hNtlsFindable", "Ratio of found/findable Tracklets" , 101, -0.005, 1.005);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNTrackletsVsFindable);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hNclTls")))
-    histptr = new TH1F("hNclTls","N_{clusters} / tracklet", 51, -0.5, 50.5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNclusterTrackletHist);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hChi2")))
-    histptr = new TH1F("hChi2", "Chi2", 200, 0, 20);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kChi2);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hChi2n")))
-    histptr = new TH1F("hChi2n", "Norm. Chi2 (tracklets)", 50, 0, 5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kChi2Normalized);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hChi2n")))
-    histptr = new TH1F("hSM", "N_{tracks} / sector", 18, -0.5, 17.5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNTracksSectorHist);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hPHdetector")))
-    histptr = new TProfile("hPHdetector", "<PH>", 31, -0.5, 30.5);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kPulseHeight);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hPHdistance")))
-    histptr = new TProfile("hPHdistance", "<PH>", 31, -0.08, 4.88);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kPulseHeightDistance);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hQclDetector")))
-    histptr = new TH1F("hQclDetector", "Q_{cluster}", 200, 0, 1200);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kClusterCharge);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hQTdetector")))
-    histptr = new TH1F("hQTdetector", "#sum Q/chamber", 6000, 0, 6000);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kChargeDeposit);
-  if(!(histptr = (TH1F *)gROOT->FindObject("hEventsTrigger")))
-    histptr = new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100);
-  else histptr->Reset();
-  fContainer->AddAt(histptr, kNEventsTrigger);
+  TH1 * h = 0x0;
+  if(!(h = (TH1F *)gROOT->FindObject("hNcls"))){
+    h = new TH1F("hNcls", "N_{clusters} / track", 181, -0.5, 180.5);
+    h->GetXaxis()->SetTitle("N_{clusters}");
+    h->GetYaxis()->SetTitle("Entries");
+  } else h->Reset();
+  fContainer->AddAt(h, kNclustersTrack);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hNclTls"))){
+    h = new TH1F("hNclTls","N_{clusters} / tracklet", 51, -0.5, 50.5);
+    h->GetXaxis()->SetTitle("N_{clusters}");
+    h->GetYaxis()->SetTitle("Entries");
+  } else h->Reset();
+  fContainer->AddAt(h, kNclustersTracklet);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hNtls"))){
+    h = new TH1F("hNtls", "N_{tracklets} / track", AliTRDgeometry::kNlayer, 0.5, 6.5);
+    h->GetXaxis()->SetTitle("N^{tracklet}");
+    h->GetYaxis()->SetTitle("freq. [%]");
+  } else h->Reset();
+  fContainer->AddAt(h, kNtrackletsTrack);
+
+  // 
+  if(!(h = (TH1F *)gROOT->FindObject("hNtlsCross"))){
+    h = new TH1F("hNtlsCross", "N_{tracklets}^{cross} / track", 7, -0.5, 6.5);
+    h->GetXaxis()->SetTitle("n_{row cross}");
+    h->GetYaxis()->SetTitle("freq. [%]");
+  } else h->Reset();
+  fContainer->AddAt(h, kNtrackletsCross);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hNtlsFindable"))){
+    h = new TH1F("hNtlsFindable", "Found/Findable Tracklets" , 101, -0.005, 1.005);
+    h->GetXaxis()->SetTitle("r [a.u]");
+    h->GetYaxis()->SetTitle("Entries");
+  } else h->Reset();
+  fContainer->AddAt(h, kNtrackletsFindable);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hNtrks"))){
+    h = new TH1F("hNtrks", "N_{tracks} / event", 100, 0, 100);
+    h->GetXaxis()->SetTitle("N_{tracks}");
+    h->GetYaxis()->SetTitle("Entries");
+  } else h->Reset();
+  fContainer->AddAt(h, kNtracksEvent);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hNtrksSector"))){
+    h = new TH1F("hNtrksSector", "N_{tracks} / sector", AliTRDgeometry::kNsector, -0.5, 17.5);
+    h->GetXaxis()->SetTitle("sector");
+    h->GetYaxis()->SetTitle("freq. [%]");
+  } else h->Reset();
+  fContainer->AddAt(h, kNtracksSector);
+
+  // <PH> histos
+  TObjArray *arr = new TObjArray(2);
+  arr->SetOwner(kTRUE);  arr->SetName("<PH>");
+  fContainer->AddAt(arr, kPH);
+  if(!(h = (TH1F *)gROOT->FindObject("hPHt"))){
+    h = new TProfile("hPHt", "<PH>", 31, -0.5, 30.5);
+    h->GetXaxis()->SetTitle("Time / 100ns");
+    h->GetYaxis()->SetTitle("<PH> [a.u]");
+  } else h->Reset();
+  arr->AddAt(h, 0);
+  if(!(h = (TH1F *)gROOT->FindObject("hPHx")))
+    h = new TProfile("hPHx", "<PH>", 31, -0.08, 4.88);
+  else h->Reset();
+  arr->AddAt(h, 1);
+
+  // Chi2 histos
+  arr = new TObjArray(2);
+  arr->SetOwner(kTRUE); arr->SetName("Chi2");
+  fContainer->AddAt(arr, kChi2);
+  if(!(h = (TH1F *)gROOT->FindObject("hChi2")))
+    h = new TH1F("hChi2", "#Chi2", 200, 0, 20);
+  else h->Reset();
+  arr->AddAt(h, 0);
+  if(!(h = (TH1F *)gROOT->FindObject("hChi2n")))
+    h = new TH1F("hChi2n", "Norm. Chi2 (tracklets)", 50, 0, 5);
+  else h->Reset();
+  arr->AddAt(h, 1);
+
+
+  if(!(h = (TH1F *)gROOT->FindObject("hQcl"))){
+    h = new TH1F("hQcl", "Q_{cluster}", 200, 0, 1200);
+    h->GetXaxis()->SetTitle("Q_{cluster} [a.u.]");
+    h->GetYaxis()->SetTitle("Entries");
+  }else h->Reset();
+  fContainer->AddAt(h, kChargeCluster);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hQtrklt"))){
+    h = new TH1F("hQtrklt", "Q_{tracklet}", 6000, 0, 6000);
+    h->GetXaxis()->SetTitle("Q_{tracklet} [a.u.]");
+    h->GetYaxis()->SetTitle("Entries");
+  }else h->Reset();
+  fContainer->AddAt(h, kChargeTracklet);
+
+
+  if(!(h = (TH1F *)gROOT->FindObject("hEventsTrigger")))
+    h = new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100);
+  else h->Reset();
+  fContainer->AddAt(h, kNeventsTrigger);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hEventsTriggerTracks")))
+    h = new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100);
+  else h->Reset();
+  fContainer->AddAt(h, kNeventsTriggerTracks);
+
+  if(!(h = (TH1F *)gROOT->FindObject("hTriggerPurity"))){
+    h = new TH1F("hTriggerPurity", "Trigger Purity", 10, -0.5, 9.5);
+    h->GetXaxis()->SetTitle("Trigger Cluster");
+    h->GetYaxis()->SetTitle("freq.");
+  } else h->Reset();
+  fContainer->AddAt(h, kTriggerPurity);
 
   return fContainer;
 }
@@ -389,7 +432,7 @@ TH1 *AliTRDcheckDetector::PlotNClustersTracklet(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclusterTrackletHist)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTracklet)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -412,7 +455,7 @@ TH1 *AliTRDcheckDetector::PlotNClustersTrack(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersHist)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTrack)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -435,7 +478,7 @@ TH1 *AliTRDcheckDetector::PlotNClustersTrack(const AliTRDtrackV1 *track){
         if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
         pdg = fMC->GetPDG();
       }
-      (*fDebugStream) << "NClusters"
+      (*fDebugStream) << "NClustersTrack"
         << "Detector="  << detector
         << "crossing="  << crossing
         << "momentum=" << momentum
@@ -452,29 +495,11 @@ TH1 *AliTRDcheckDetector::PlotNClustersTrack(const AliTRDtrackV1 *track){
   return h;
 }
 
-//_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotChi2(const AliTRDtrackV1 *track){
-  //
-  // Plot the chi2 of the track
-  //
-  if(track) fTrack = track;
-  if(!fTrack){
-    AliWarning("No Track defined.");
-    return 0x0;
-  }
-  TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChi2)))){
-    AliWarning("No Histogram defined.");
-    return 0x0;
-  }
-  h->Fill(fTrack->GetChi2());
-  return h;
-}
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotNormalizedChi2(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotNTrackletsTrack(const AliTRDtrackV1 *track){
   //
-  // Plot the chi2 of the track
+  // Plot the number of tracklets
   //
   if(track) fTrack = track;
   if(!fTrack){
@@ -482,23 +507,31 @@ TH1 *AliTRDcheckDetector::PlotNormalizedChi2(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChi2Normalized)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsTrack)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
-  Int_t nTracklets = 0;
-  AliTRDseedV1 *tracklet = 0x0;
-  for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
-    if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
-    nTracklets++;
+  Int_t nTracklets = fTrack->GetNumberOfTracklets();
+  h->Fill(nTracklets);
+  if(fDebugLevel > 3){
+    if(nTracklets == 1){
+      // If we have one Tracklet, check in which layer this happens
+      Int_t layer = -1;
+      AliTRDseedV1 *tracklet = 0x0;
+      for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
+        if((tracklet = fTrack->GetTracklet(il)) && tracklet->IsOK()){layer =  il; break;}
+      }
+      (*fDebugStream) << "NTrackletsTrack"
+        << "Layer=" << layer
+        << "\n";
+    }
   }
-  h->Fill(fTrack->GetChi2()/nTracklets);
   return h;
 }
 
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotNTracklets(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotNTrackletsRowCross(const AliTRDtrackV1 *track){
   //
   // Plot the number of tracklets
   //
@@ -508,30 +541,24 @@ TH1 *AliTRDcheckDetector::PlotNTracklets(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsHist)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsCross)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
-  Int_t nTracklets = GetNTracklets(fTrack);
-  h->Fill(nTracklets);
-  if(fDebugLevel > 3){
-    if(nTracklets == 1){
-      // If we have one Tracklet, check in which layer this happens
-      Int_t layer = -1;
-      AliTRDseedV1 *tracklet = 0x0;
-      for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
-        if((tracklet = fTrack->GetTracklet(il)) && tracklet->IsOK()){layer =  il; break;}
-      }
-      (*fDebugStream) << "PlotNTracklets"
-        << "Layer=" << layer
-        << "\n";
-    }
+
+  Int_t ncross = 0;
+  AliTRDseedV1 *tracklet = 0x0;
+  for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
+    if(!(tracklet = fTrack->GetTracklet(il)) || !tracklet->IsOK()) continue;
+
+    if(tracklet->IsRowCross()) ncross++;
   }
+  h->Fill(ncross);
   return h;
 }
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotTrackletsVsFindable(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotFindableTracklets(const AliTRDtrackV1 *track){
   //
   // Plots the ratio of number of tracklets vs.
   // number of findable tracklets
@@ -566,7 +593,7 @@ TH1 *AliTRDcheckDetector::PlotTrackletsVsFindable(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNTrackletsVsFindable)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsFindable)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -636,7 +663,7 @@ TH1 *AliTRDcheckDetector::PlotTrackletsVsFindable(const AliTRDtrackV1 *track){
       if(fDebugLevel > 3){
         Double_t pos_tracklet[2] = {tracklet ? tracklet->GetYfit(0) : 0, tracklet ? tracklet->GetMeanz() : 0};
         Int_t hasTracklet = tracklet ? 1 : 0;
-        (*fDebugStream)   << "GetFindableTracklets"
+        (*fDebugStream)   << "FindableTracklets"
           << "layer="     << il
           << "ytracklet=" << pos_tracklet[0]
           << "ytrack="    << y
@@ -652,8 +679,54 @@ TH1 *AliTRDcheckDetector::PlotTrackletsVsFindable(const AliTRDtrackV1 *track){
   return h;
 }
 
+
+//_______________________________________________________
+TH1 *AliTRDcheckDetector::PlotChi2(const AliTRDtrackV1 *track){
+  //
+  // Plot the chi2 of the track
+  //
+  if(track) fTrack = track;
+  if(!fTrack){
+    AliWarning("No Track defined.");
+    return 0x0;
+  }
+  TH1 *h = 0x0;
+  if(!(h = dynamic_cast<TH1F *>(((TObjArray*)(fContainer->At(kChi2)))->At(0)))){
+    AliWarning("No Histogram defined.");
+    return 0x0;
+  }
+  h->Fill(fTrack->GetChi2());
+  return h;
+}
+
+//_______________________________________________________
+TH1 *AliTRDcheckDetector::PlotChi2Norm(const AliTRDtrackV1 *track){
+  //
+  // Plot the chi2 of the track
+  //
+  if(track) fTrack = track;
+  if(!fTrack){
+    AliWarning("No Track defined.");
+    return 0x0;
+  }
+  TH1 *h = 0x0;
+  if(!(h = dynamic_cast<TH1F *>(((TObjArray*)(fContainer->At(kChi2)))->At(1)))){
+    AliWarning("No Histogram defined.");
+    return 0x0;
+  }
+  Int_t nTracklets = 0;
+  AliTRDseedV1 *tracklet = 0x0;
+  for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
+    if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
+    nTracklets++;
+  }
+  h->Fill(fTrack->GetChi2()/nTracklets);
+  return h;
+}
+
+
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotPulseHeight(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotPHt(const AliTRDtrackV1 *track){
   //
   // Plot the average pulse height
   //
@@ -663,7 +736,7 @@ TH1 *AliTRDcheckDetector::PlotPulseHeight(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TProfile *h = 0x0;
-  if(!(h = dynamic_cast<TProfile *>(fContainer->At(kPulseHeight)))){
+  if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(0)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -691,7 +764,7 @@ TH1 *AliTRDcheckDetector::PlotPulseHeight(const AliTRDtrackV1 *track){
           if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
           pdg = fMC->GetPDG();
         }
-        (*fDebugStream) << "PulseHeight"
+        (*fDebugStream) << "PHt"
           << "Detector="       << detector
           << "crossing="       << crossing
           << "Timebin="                << localtime
@@ -713,7 +786,7 @@ TH1 *AliTRDcheckDetector::PlotPulseHeight(const AliTRDtrackV1 *track){
 }
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotPHSdistance(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotPHx(const AliTRDtrackV1 *track){
   //
   // Plots the average pulse height vs the distance from the anode wire
   // (plus const anode wire offset)
@@ -724,7 +797,7 @@ TH1 *AliTRDcheckDetector::PlotPHSdistance(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TProfile *h = 0x0;
-  if(!(h = dynamic_cast<TProfile *>(fContainer->At(kPulseHeightDistance)))){
+  if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(1)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -744,7 +817,7 @@ TH1 *AliTRDcheckDetector::PlotPHSdistance(const AliTRDtrackV1 *track){
 }
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotClusterCharge(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotChargeCluster(const AliTRDtrackV1 *track){
   //
   // Plot the cluster charge
   //
@@ -754,7 +827,7 @@ TH1 *AliTRDcheckDetector::PlotClusterCharge(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kClusterCharge)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeCluster)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -771,7 +844,7 @@ TH1 *AliTRDcheckDetector::PlotClusterCharge(const AliTRDtrackV1 *track){
 }
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotChargeDeposit(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotChargeTracklet(const AliTRDtrackV1 *track){
   //
   // Plot the charge deposit per chamber
   //
@@ -781,14 +854,14 @@ TH1 *AliTRDcheckDetector::PlotChargeDeposit(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeDeposit)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeTracklet)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
   AliTRDseedV1 *tracklet = 0x0;
   AliTRDcluster *c = 0x0;
   Double_t Qtot = 0;
-  Int_t nTracklets =GetNTracklets(fTrack);
+  Int_t nTracklets =fTrack->GetNumberOfTracklets();
   for(Int_t itl = 0x0; itl < AliTRDgeometry::kNlayer; itl++){
     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
     Qtot = 0.;
@@ -810,7 +883,7 @@ TH1 *AliTRDcheckDetector::PlotChargeDeposit(const AliTRDtrackV1 *track){
              if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
         pdg = fMC->GetPDG();
       }
-      (*fDebugStream) << "ChargeDeposit"
+      (*fDebugStream) << "ChargeTracklet"
         << "Detector="  << detector
         << "crossing="  << crossing
         << "momentum=" << momentum
@@ -828,7 +901,7 @@ TH1 *AliTRDcheckDetector::PlotChargeDeposit(const AliTRDtrackV1 *track){
 }
 
 //_______________________________________________________
-TH1 *AliTRDcheckDetector::PlotTracksSector(const AliTRDtrackV1 *track){
+TH1 *AliTRDcheckDetector::PlotNTracksSector(const AliTRDtrackV1 *track){
   //
   // Plot the number of tracks per Sector
   //
@@ -838,7 +911,7 @@ TH1 *AliTRDcheckDetector::PlotTracksSector(const AliTRDtrackV1 *track){
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNTracksSectorHist)))){
+  if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtracksSector)))){
     AliWarning("No Histogram defined.");
     return 0x0;
   }
@@ -857,22 +930,6 @@ TH1 *AliTRDcheckDetector::PlotTracksSector(const AliTRDtrackV1 *track){
   return h;
 }
 
-//_______________________________________________________
-Int_t AliTRDcheckDetector::GetNTracklets(const AliTRDtrackV1 *track){
-  //
-  // Count the number of tracklets per track
-  //
-  if(!track){
-    AliError("No track");
-    return 0;
-  }
-  Int_t nTracklets = 0;
-  AliTRDseedV1 *tracklet = 0x0;
-  for(Int_t il = AliTRDgeometry::kNlayer; il--;){
-    if((tracklet = track->GetTracklet(il)) && tracklet->IsOK()) nTracklets++;
-  }
-  return nTracklets;
-}
 
 //________________________________________________________
 void AliTRDcheckDetector::SetRecoParam(AliTRDrecoParam *r)
@@ -882,7 +939,9 @@ void AliTRDcheckDetector::SetRecoParam(AliTRDrecoParam *r)
 }
 
 //________________________________________________________
-void AliTRDcheckDetector::GetDistanceToTracklet(Double_t *dist, AliTRDseedV1 *tracklet, AliTRDcluster *c){
-  dist[0] = c->GetY() - (tracklet->GetYfit(0) + tracklet->GetYfit(1)*(c->GetX() - tracklet->GetX0()));
-  dist[1] = c->GetZ() - tracklet->GetMeanz();
+void AliTRDcheckDetector::GetDistanceToTracklet(Double_t *dist, AliTRDseedV1 *tracklet, AliTRDcluster *c)
+{
+  Float_t x = c->GetX();
+  dist[0] = c->GetY() - tracklet->GetYat(x);
+  dist[1] = c->GetZ() - tracklet->GetZat(x);
 }
index c5a5af8..a1b7520 100644 (file)
@@ -17,25 +17,25 @@ class AliTRDrecoParam;
 class AliTRDeventInfo;
 
 class AliTRDcheckDetector : public AliTRDrecoTask{
-// The Histogram number
-typedef enum{
-  kNTracksEventHist=0,
-  kNEventsTriggerTracks=1,
-  kNclustersHist=2,
-  kNtrackletsHist=3,
-  kNTrackletsVsFindable = 4,
-  kNclusterTrackletHist=5,
-  kChi2=6, 
-  kChi2Normalized=7,
-  kNTracksSectorHist=8,
-  kPulseHeight=9,
-  kPulseHeightDistance=10,
-  kClusterCharge=11,
-  kChargeDeposit=12,
-  kNEventsTrigger=13,
-  kPurity = 14
-}HistType_t;
 public:
+  // The Histogram number
+  enum  HistType_t {
+    kNclustersTrack     = 0,
+    kNclustersTracklet   = 1,
+    kNtrackletsTrack    = 2,
+    kNtrackletsCross    = 3,
+    kNtrackletsFindable = 4,
+    kNtracksEvent       = 5,
+    kNtracksSector      = 6,
+    kPH                 = 7,
+    kChi2               = 8,
+    kChargeCluster      = 9,
+    kChargeTracklet     = 10,
+    kNeventsTrigger     = 11,
+    kNeventsTriggerTracks=12,
+    kTriggerPurity      = 13
+  };
+
   AliTRDcheckDetector();
   virtual ~AliTRDcheckDetector();
 
@@ -49,15 +49,16 @@ public:
   // Plotting Functions:
   TH1 *PlotNClustersTracklet(const AliTRDtrackV1 *t = 0x0);
   TH1 *PlotNClustersTrack(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotNTracklets(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotTrackletsVsFindable(const AliTRDtrackV1 *track = 0x0);
-  TH1 *PlotTracksSector(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotPulseHeight(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotPHSdistance(const AliTRDtrackV1 *track = 0x0);
+  TH1 *PlotNTrackletsTrack(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotNTrackletsRowCross(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotFindableTracklets(const AliTRDtrackV1 *track = 0x0);
+  TH1 *PlotNTracksSector(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotPHt(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotPHx(const AliTRDtrackV1 *track = 0x0);
   TH1 *PlotChi2(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotNormalizedChi2(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotClusterCharge(const AliTRDtrackV1 *t = 0x0);
-  TH1 *PlotChargeDeposit(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotChi2Norm(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotChargeCluster(const AliTRDtrackV1 *t = 0x0);
+  TH1 *PlotChargeTracklet(const AliTRDtrackV1 *t = 0x0);
 
   virtual Bool_t PostProcess();
   virtual Bool_t GetRefFigure(Int_t ifig);
@@ -67,7 +68,6 @@ public:
 private:
   AliTRDcheckDetector(const AliTRDcheckDetector &);
   AliTRDcheckDetector& operator=(const AliTRDcheckDetector &);
-  Int_t GetNTracklets(const AliTRDtrackV1 *track);
   void GetDistanceToTracklet(Double_t *dist, AliTRDseedV1 *tracklet, AliTRDcluster *c);
   AliTRDeventInfo *fEventInfo;         //! ESD Header
   TMap *fTriggerNames;                 //! Containing trigger class names
index 8b6ce96..a0de839 100644 (file)
@@ -91,7 +91,8 @@ TObjArray * AliTRDpidChecker::Histos(){
   const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1));     // get nice histos with bin center at 0 and 1
 
   // histos of the electron probability of all 5 particle species and 11 momenta for the 2-dim LQ method 
-  fEfficiency = new TObjArray(); fEfficiency->Expand(3);
+  fEfficiency = new TObjArray(3);
+  fEfficiency->SetOwner(); fEfficiency->SetName("Efficiency");
   fContainer->AddAt(fEfficiency, kEfficiency);
   
   TH1 *h = 0x0;
@@ -1054,32 +1055,33 @@ Bool_t AliTRDpidChecker::PostProcess()
     fGraph = new TObjArray(6);
     fGraph->SetOwner();
 
-    fGraph->AddAt(g = new TGraphErrors(), kLQ);
+    // efficiency graphs
+    TObjArray *arr = new TObjArray(3); arr->SetOwner();
+    fGraph->AddAt(arr, 0);
+    arr->AddAt(g = new TGraphErrors(), kLQ);
     g->SetLineColor(kBlue);
     g->SetMarkerColor(kBlue);
     g->SetMarkerStyle(7);
-  
-    fGraph->AddAt(g = new TGraphErrors(), kNN);
+    arr->AddAt(g = new TGraphErrors(), kNN);
     g->SetLineColor(kGreen);
     g->SetMarkerColor(kGreen);
     g->SetMarkerStyle(7);
-  
-    fGraph -> AddAt(g = new TGraphErrors(), kESD);
+    arr -> AddAt(g = new TGraphErrors(), kESD);
     g->SetLineColor(kRed);
     g->SetMarkerColor(kRed);
     g->SetMarkerStyle(24);
 
-    fGraph->AddAt(g = new TGraphErrors(), 3+kLQ);
+    arr = new TObjArray(3); arr->SetOwner();
+    fGraph->AddAt(arr, 1);
+    arr->AddAt(g = new TGraphErrors(), kLQ);
     g->SetLineColor(kBlue);
     g->SetMarkerColor(kBlue);
     g->SetMarkerStyle(7);
-  
-    fGraph->AddAt(g = new TGraphErrors(), 3+kNN);
+    arr->AddAt(g = new TGraphErrors(), kNN);
     g->SetLineColor(kGreen);
     g->SetMarkerColor(kGreen);
     g->SetMarkerStyle(7);
-  
-    fGraph -> AddAt(g = new TGraphErrors(), 3+kESD);
+    arr -> AddAt(g = new TGraphErrors(), kESD);
     g->SetLineColor(kRed);
     g->SetMarkerColor(kRed);
     g->SetMarkerStyle(24);
index dc07d20..2a13c99 100644 (file)
@@ -348,7 +348,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, 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, 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:
@@ -390,6 +390,7 @@ 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();
+  pt   =  tr[1]->Pt();
   return kTRUE;
 }
 
index fced22f..8de816c 100644 (file)
@@ -71,7 +71,7 @@ public:
     Int_t   GetLabel() const {return fLabel;}
     Int_t   GetNTrackRefs() const {return fNTrackRefs;}
     Int_t   GetPDG() const {return fPDG;}
-    Bool_t  GetDirections(Float_t &x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx, 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, UChar_t &s) const;
     AliTrackReference const* GetTrackRef(Int_t ref=0) const {return fTrackRefs[ref];}
 
   protected:
index 9720eb1..2c3c1dc 100644 (file)
@@ -105,11 +105,11 @@ AliTRDtrackingResolution::AliTRDtrackingResolution()
 
   InitFunctorList();
 
-  DefineOutput(1+kClusterResidual, TObjArray::Class());
-  DefineOutput(1+kTrackletYResidual, TObjArray::Class());
-  DefineOutput(1+kTrackletPhiResidual, TObjArray::Class());
-  DefineOutput(1+kClusterResolution, TObjArray::Class());
-  DefineOutput(1+kTrackletYResolution, TObjArray::Class());
+  DefineOutput(1+kCluster, TObjArray::Class());
+  DefineOutput(1+kTrackletY, TObjArray::Class());
+  DefineOutput(1+kTrackletPhi, TObjArray::Class());
+  DefineOutput(1+kMCcluster, TObjArray::Class());
+  DefineOutput(1+kMCtrackletY, TObjArray::Class());
 }
 
 //________________________________________________________
@@ -162,15 +162,15 @@ void AliTRDtrackingResolution::Exec(Option_t *opt)
 
   AliTRDrecoTask::Exec(opt);
 
-  PostData(1+kClusterResidual, fClResiduals);
-  PostData(1+kTrackletYResidual, fTrkltResiduals);
-  PostData(1+kTrackletPhiResidual, fTrkltPhiResiduals);
-  PostData(1+kClusterResolution, fClResolution);
-  PostData(1+kTrackletYResolution, fTrkltResolution);
+  PostData(1+kCluster, fClResiduals);
+  PostData(1+kTrackletY, fTrkltResiduals);
+  PostData(1+kTrackletPhi, fTrkltPhiResiduals);
+  PostData(1+kMCcluster, fClResolution);
+  PostData(1+kMCtrackletY, fTrkltResolution);
 }
 
 //________________________________________________________
-TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
+TH1* AliTRDtrackingResolution::PlotCluster(const AliTRDtrackV1 *track)
 {
   if(track) fTrack = track;
   if(!fTrack){
@@ -178,11 +178,12 @@ TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = ((TH2I*)fContainer->At(kClusterResidual)))){
+  if(!(h = ((TH2I*)fContainer->At(kCluster)))){
     AliWarning("No output histogram defined.");
     return 0x0;
   }
 
+  Double_t cov[3];
   Float_t x0, y0, z0, dy, dydx, dzdx;
   AliTRDseedV1 *fTracklet = 0x0;  
   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
@@ -195,6 +196,7 @@ TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
     z0   = fTracklet->GetZref(0);
     dydx = fTracklet->GetYref(1);
     dzdx = fTracklet->GetZref(1);
+    fTracklet->GetCovRef(cov);
     Float_t tilt = fTracklet->GetTilt();
     AliTRDcluster *c = 0x0;
     fTracklet->ResetClusterIter(kFALSE);
@@ -205,10 +207,10 @@ TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
       Float_t dx = x0 - xc; 
       Float_t yt = y0 - dx*dydx;
       Float_t zt = z0 - dx*dzdx; 
-      dy = yt - (yc - tilt*(zc-zt));
+      yc -= tilt*(zc-zt); // tilt correction
+      dy = yt - yc;
 
-      //dy = trklt.GetYat(c->GetX()) - c->GetY();
-      h->Fill(dydx, dy);
+      h->Fill(dydx, dy/TMath::Sqrt(cov[0] + c->GetSigmaY2()));
   
       if(fDebugLevel>=1){
         // Get z-position with respect to anode wire
@@ -238,7 +240,7 @@ TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
 
 
 //________________________________________________________
-TH1* AliTRDtrackingResolution::PlotTrackletResiduals(const AliTRDtrackV1 *track)
+TH1* AliTRDtrackingResolution::PlotTracklet(const AliTRDtrackV1 *track)
 {
   if(track) fTrack = track;
   if(!fTrack){
@@ -246,65 +248,31 @@ TH1* AliTRDtrackingResolution::PlotTrackletResiduals(const AliTRDtrackV1 *track)
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = ((TH2I*)fContainer->At(kTrackletYResidual)))){
+  if(!(h = ((TH2I*)fContainer->At(kTrackletY)))){
     AliWarning("No output histogram defined.");
     return 0x0;
   }
 
-  AliTRDseedV1 *tracklet = 0x0;
-  for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
-    if(!(tracklet = fTrack->GetTracklet(il))) continue;
-    if(!tracklet->IsOK()) continue;
-    h->Fill(tracklet->GetYref(1), tracklet->GetYref(0)-tracklet->GetYfit(0));
+  Double_t cov[3], covR[3];
+  Float_t xref, y0, dx, dy, dydx;
+  AliTRDseedV1 *fTracklet = 0x0;  
+  for(Int_t il=AliTRDgeometry::kNlayer; il--;){
+    if(!(fTracklet = fTrack->GetTracklet(il))) continue;
+    if(!fTracklet->IsOK()) continue;
+    y0   = fTracklet->GetYref(0);
+    dydx = fTracklet->GetYref(1);
+    xref = fTracklet->GetXref();
+    dx   = fTracklet->GetX0() - xref;
+    dy   = y0-dx*dydx - fTracklet->GetYat(xref);
+    fTracklet->GetCovAt(xref, cov);
+    fTracklet->GetCovRef(covR);
+    h->Fill(dydx, dy/TMath::Sqrt(cov[0] + covR[0]));
   }
   return h;
-
-  // refit the track
-//   AliRieman fRim(fTrack->GetNumberOfClusters());
-//   Float_t x[AliTRDgeometry::kNlayer] = {-1., -1., -1., -1., -1., -1.}, y[AliTRDgeometry::kNlayer], dydx[AliTRDgeometry::kNlayer];
-
-//     AliTRDcluster *c = 0x0;
-//     tracklet->ResetClusterIter(kFALSE);
-//     while((c = tracklet->PrevCluster())){
-//       Float_t xc = c->GetX();
-//       Float_t yc = c->GetY();
-//       Float_t zc = c->GetZ();
-//       Float_t zt = tracklet->GetZref(0) - (tracklet->GetX0()-xc)*tracklet->GetZref(1); 
-//       yc -= tracklet->GetTilt()*(zc-zt);
-//       fRim.AddPoint(xc, yc, zc, 1, 10);
-//     }
-//     tracklet->Fit(kTRUE);
-// 
-//     x[il] = tracklet->GetX0();
-//     y[il] = tracklet->GetYfit(0)-tracklet->GetYfit(1)*(tracklet->GetX0()-x[il]);
-//     dydx[il] = tracklet->GetYref(1);
-
-
-//   fRim.Update();
-
-//   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
-//     if(x[il] < 0.) continue;
-//     Float_t dy = y[il]-fRim.GetYat(x[il])/*/sigma_track*/;
-//     h->Fill(dydx[il], dy);
-// 
-//     if(fDebugLevel>=1){
-//       Double_t sigmay = fRim.GetErrY(x[il]);
-//       Float_t yt = fRim.GetYat(x[il]);
-//       (*fDebugStream) << "TrkltResiduals"
-//         << "layer="  << il
-//         << "x="      << x[il]
-//         << "y="      << y[il]
-//         << "yt="     << yt
-//         << "dydx="   << dydx[il]
-//         << "dy="     << dy
-//         << "sigmay=" << sigmay
-//         << "\n";
-//     }
-//   }
 }
 
 //________________________________________________________
-TH1* AliTRDtrackingResolution::PlotTrackletPhiResiduals(const AliTRDtrackV1 *track)
+TH1* AliTRDtrackingResolution::PlotTrackletPhi(const AliTRDtrackV1 *track)
 {
   if(track) fTrack = track;
   if(!fTrack){
@@ -312,7 +280,7 @@ TH1* AliTRDtrackingResolution::PlotTrackletPhiResiduals(const AliTRDtrackV1 *tra
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = ((TH2I*)fContainer->At(kTrackletPhiResidual)))){
+  if(!(h = ((TH2I*)fContainer->At(kTrackletPhi)))){
     AliWarning("No output histogram defined.");
     return 0x0;
   }
@@ -324,60 +292,6 @@ TH1* AliTRDtrackingResolution::PlotTrackletPhiResiduals(const AliTRDtrackV1 *tra
     h->Fill(tracklet->GetYref(1), TMath::ATan(tracklet->GetYref(1))-TMath::ATan(tracklet->GetYfit(1)));
   }
   return h;
-
-//   // refit the track
-//   AliRieman fRim(fTrack->GetNumberOfClusters());
-//   Float_t x[AliTRDgeometry::kNlayer] = {-1., -1., -1., -1., -1., -1.}, y[AliTRDgeometry::kNlayer], dydx[AliTRDgeometry::kNlayer];
-//   Float_t dydx_ref=0, dydx_fit=0, phiref=0, phifit=0, phidiff=0;
-//   AliTRDseedV1 *tracklet = 0x0;
-//   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
-//     if(!(tracklet = fTrack->GetTracklet(il))) continue;
-//     if(!tracklet->IsOK()) continue;
-//     AliTRDcluster *c = 0x0;
-//     tracklet->ResetClusterIter(kFALSE);
-//     while((c = tracklet->PrevCluster())){
-//       Float_t xc = c->GetX();
-//       Float_t yc = c->GetY();
-//       Float_t zc = c->GetZ();
-//       Float_t zt = tracklet->GetZref(0) - (tracklet->GetX0()-xc)*tracklet->GetZref(1); 
-//       yc -= tracklet->GetTilt()*(zc-zt);
-//       fRim.AddPoint(xc, yc, zc, 1, 10);
-//     }
-//     tracklet->Fit(kTRUE);
-// 
-//     x[il] = tracklet->GetX0();
-//     y[il] = tracklet->GetYfit(0)-tracklet->GetYfit(1)*(tracklet->GetX0()-x[il]);
-//     dydx[il] = tracklet->GetYref(1);
-//   }
-//   fRim.Update();
-// 
-//   for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
-//     if(x[il] < 0.) continue;
-//     if(!(tracklet = fTrack->GetTracklet(il))) continue;
-//     if(!tracklet->IsOK()) continue;
-// 
-//     dydx_ref = fRim.GetDYat(x[il]); 
-//     dydx_fit = tracklet->GetYfit(1);
-// 
-//     phiref = TMath::ATan(dydx_ref);//*TMath::RadToDeg();
-//     phifit = TMath::ATan(dydx_fit);//*TMath::RadToDeg();
-//     
-//     phidiff = phiref-phifit; /*/sigma_phi*/;
-// 
-//     h->Fill(dydx_ref, phidiff);
-// 
-// 
-//     if(fDebugLevel>=1){
-//       (*fDebugStream) << "TrkltPhiResiduals"
-//         << "layer="  << il
-//         << "dydx_fit="   << dydx_fit
-//         << "dydx_ref="   << dydx_ref
-//         << "phiref="     << phiref
-//         << "phifit="     << phifit
-//         << "phidiff="     << phidiff
-//         << "\n";
-//     }
-//   }
 }
 
 
@@ -394,85 +308,92 @@ TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
     return 0x0;
   }
   TH1 *h = 0x0;
-  if(!(h = ((TH2I*)fContainer->At(kClusterResolution)))){
-    AliWarning("No output histogram defined.");
-    return 0x0;
-  }
-  if(!(h = ((TH2I*)fContainer->At(kTrackletYResolution)))){
-    AliWarning("No output histogram defined.");
-    return 0x0;
-  }
-  if(!(h = ((TH2I*)fContainer->At(kTrackletZResolution)))){
-    AliWarning("No output histogram defined.");
-    return 0x0;
-  }
-  if(!(h = ((TH2I*)fContainer->At(kTrackletAngleResolution)))){
-    AliWarning("No output histogram defined.");
-    return 0x0;
-  }
-  //printf("called for %d tracklets ... \n", fTrack->GetNumberOfTracklets());
   UChar_t s;
   Int_t pdg = fMC->GetPDG(), det=-1;
   Int_t label = fMC->GetLabel();
-  Float_t x0, y0, z0, dx, dy, dydx, dzdx;
+  Float_t p, x0, y0, z0, dx, dy, dz, dydx, dzdx;
+
   AliTRDseedV1 *fTracklet = 0x0;  
   for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
-    if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
-    if(!fTracklet->IsOK()) continue;
-    //printf("process layer[%d]\n", ily);
-    // retrive the track position and direction within the chamber
+    if(!(fTracklet = fTrack->GetTracklet(ily)) ||
+       !fTracklet->IsOK()) continue;
+
     det = fTracklet->GetDetector();
     x0  = fTracklet->GetX0();
-    dx = 0.;//radial shift with respect to the MC reference (radial position of the pad plane)
-    if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, s)) continue; 
+    //radial shift with respect to the MC reference (radial position of the pad plane)
+    dx  = x0 - fTracklet->GetXref();
+    if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, p, s)) continue; 
+    // MC track position at reference radial position
     Float_t yt = y0 - dx*dydx;
     Float_t zt = z0 - dx*dzdx;
-
-    // calculate position of Kalman fit at reference radial position
-    Float_t yr = fTracklet->GetYref(0) - (fTracklet->GetX0() - x0 + dx)*dydx;
-    Float_t zr = fTracklet->GetZref(0) - (fTracklet->GetX0() - x0 + dx)*dzdx;
-    // Fill Histograms
-    ((TH2I*)fContainer->At(kTrackYResolution))->Fill(dydx, yt-yr);
-    ((TH2I*)fContainer->At(kTrackZResolution))->Fill(dzdx, zt-zr);
-
+    p *= 1.+dzdx*dzdx; // pt -> p
+
+    // add Kalman residuals for y and z
+    Float_t dxr= fTracklet->GetX0() - x0 + dx; 
+    Float_t yr = fTracklet->GetYref(0) - dxr*fTracklet->GetYref(1);
+    dy = yt - yr;
+    Float_t zr = fTracklet->GetZref(0) - dxr*fTracklet->GetZref(1);
+    dz = zt - zr;
+    ((TH2I*)fContainer->At(kMCtrackY))->Fill(dydx, dy);
+    ((TH2I*)fContainer->At(kMCtrackZ))->Fill(dzdx, dz);
+    // Fill Debug stream for Kalman track
+    if(fDebugLevel>=1){
+      Float_t pr    = fTracklet->GetMomentum();
+      Float_t dydxr = fTracklet->GetYref(1);
+      Float_t dzdxr = fTracklet->GetZref(1);
+      (*fDebugStream) << "MCtrack"
+        << "det="     << det
+        << "pdg="     << pdg
+        << "p="       << p
+        << "yt="      << yt
+        << "zt="      << zt
+        << "dydx="    << dydx
+        << "dzdx="    << dzdx
+        << "pr="      << pr
+        << "dy="      << dy
+        << "dz="      << dz
+        << "dydxr="   << dydxr
+        << "dzdxr="   << dzdxr
+        << "\n";
+    }
 
     // recalculate tracklet based on the MC info
     AliTRDseedV1 tt(*fTracklet);
     tt.SetZref(0, z0);
     tt.SetZref(1, dzdx); 
     if(!tt.Fit(kTRUE)) continue;
-    //tt.Update();
 
-    Float_t yf = tt.GetYfit(0) - (fTracklet->GetX0() - x0 + dx)*dydx;
-    dy = yf-yt;
-    Float_t dphi   = TMath::ATan(tt.GetYfit(1)) - TMath::ATan(dydx);
+    // add tracklet residuals for y and dydx
+    Float_t yf = tt.GetYfit(0) - dxr*tt.GetYfit(1);
+    dy = yt - yf;
+    Float_t dphi   = (tt.GetYfit(1) - dydx);
+    dphi /= 1.- tt.GetYfit(1)*dydx;
+    ((TH2I*)fContainer->At(kMCtrackletY))->Fill(dydx, dy);
+    ((TH2I*)fContainer->At(kMCtrackletPhi))->Fill(dydx, dphi*TMath::RadToDeg());
+
     Float_t dz = 100.;
-    Bool_t  cross = fTracklet->GetNChange();
-    if(cross){
+    Bool_t rc = fTracklet->IsRowCross(); 
+    if(rc){
+      // add tracklet residuals for z
       Double_t *xyz = tt.GetCrossXYZ();
       dz = xyz[2] - (z0 - (x0 - xyz[0])*dzdx) ;
-      ((TH2I*)fContainer->At(kTrackletZResolution))->Fill(dzdx, dz);
+      ((TH2I*)fContainer->At(kMCtrackletZ))->Fill(dzdx, dz);
     }
   
-    // Fill Histograms
-    ((TH2I*)fContainer->At(kTrackletYResolution))->Fill(dydx, dy);
-    ((TH2I*)fContainer->At(kTrackletAngleResolution))->Fill(dydx, dphi*TMath::RadToDeg());
-
-    // Fill Debug stream
+    // Fill Debug stream for tracklet
     if(fDebugLevel>=1){
-      Float_t p = fMC->GetTrackRef() ? fMC->GetTrackRef()->P() : -1.;
-      (*fDebugStream) << "TrkltResolution"
-        << "det="                << det
+      (*fDebugStream) << "MCtracklet"
+        << "det="     << det
         << "pdg="     << pdg
         << "p="       << p
-        << "ymc="     << y0
-        << "zmc="     << z0
+        << "yt="      << yt
+        << "zt="      << zt
         << "dydx="    << dydx
         << "dzdx="    << dzdx
-        << "cross="   << cross
-        << "dy="                 << dy
-        << "dz="                 << dz
-        << "dphi="             << dphi
+        << "rowc="    << rc
+        << "dy="      << dy
+        << "dz="      << dz
+        << "dphi="    << dphi
         << "\n";
     }
 
@@ -486,7 +407,8 @@ TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
     fTracklet->ResetClusterIter(kFALSE);
     while((c = fTracklet->PrevCluster())){
       Float_t  q = TMath::Abs(c->GetQ());
-      AliTRDseedV1::GetClusterXY(c,x,y);
+      //AliTRDseedV1::GetClusterXY(c,x,y);
+      x = c->GetX(); y = c->GetY();
       Float_t xc = x;
       Float_t yc = y;
       Float_t zc = c->GetZ();
@@ -496,25 +418,26 @@ TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
       dy = yt - (yc - tilt*(zc-zt));
 
       // Fill Histograms
-      if(q>20. && q<250.) ((TH2I*)fContainer->At(kClusterResolution))->Fill(dydx, dy);
-      
-      // Fill Debug Tree
-      if(fDebugLevel>=1){
-        Float_t d = zr0 - zt;
-        d -= ((Int_t)(2 * d)) / 2.0;
-        if (d > 0.25) d  = 0.5 - d;
+      if(q>20. && q<250.) ((TH2I*)fContainer->At(kMCcluster))->Fill(dydx, dy);
+
+      // Fill calibration container
+      Float_t d = zr0 - zt;
+      d -= ((Int_t)(2 * d)) / 2.0;
+      if (d > 0.25) d  = 0.5 - d;
+      AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
+      fClResolution->Add(clInfo);
+      clInfo->SetCluster(c);
+      clInfo->SetMC(pdg, label);
+      clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
+      clInfo->SetResolution(dy);
+      clInfo->SetAnisochronity(d);
+      clInfo->SetDriftLength(dx);
+      clInfo->SetTilt(tilt);
 
-        AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
-        fClResolution->Add(clInfo);
-        clInfo->SetCluster(c);
-        clInfo->SetMC(pdg, label);
-        clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
-        clInfo->SetResolution(dy);
-        clInfo->SetAnisochronity(d);
-        clInfo->SetDriftLength(dx);
-        clInfo->SetTilt(tilt);
+      // Fill Debug Tree
+      if(fDebugLevel>=2){
         //clInfo->Print();
-        (*fDebugStream) << "ClusterResolution"
+        (*fDebugStream) << "MCcluster"
           <<"clInfo.=" << clInfo
           << "\n";
       }
@@ -527,106 +450,133 @@ TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
 //________________________________________________________
 Bool_t AliTRDtrackingResolution::GetRefFigure(Int_t ifig)
 {
+  Float_t y[2] = {0., 0.};
   TBox *b = 0x0;
   TAxis *ax = 0x0;
   TGraphErrors *g = 0x0;
   switch(ifig){
-  case kClusterResidual:
+  case kCluster:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     g->Draw("apl");
     ax = g->GetHistogram()->GetYaxis();
-    ax->SetRangeUser(-.5, 2.5);
-    ax->SetTitle("Clusters Y Residuals #sigma/#mu [mm]");
+    y[0] = -0.5; y[1] = 2.5;
+    ax->SetRangeUser(y[0], y[1]);
+    ax->SetTitle("Cluster-Track Pools #sigma/#mu [mm]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
-    b = new TBox(-.15, -.5, .15, 1.);
+    b = new TBox(-.15, y[0], .15, y[1]);
     b->SetFillStyle(3002);b->SetFillColor(kGreen);
     b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kTrackletYResidual:
+  case kTrackletY:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     g->Draw("apl");
     ax = g->GetHistogram()->GetYaxis();
     ax->SetRangeUser(-.5, 3.);
-    ax->SetTitle("Tracklet Y Residuals #sigma/#mu [mm]");
+    ax->SetTitle("Tracklet-Track Y-Pools #sigma/#mu [mm]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
-    b = new TBox(-.15, -.5, .15, 1.);
+    b = new TBox(-.15, y[0], .15, y[1]);
     b->SetFillStyle(3002);b->SetFillColor(kGreen);
     b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kTrackletPhiResidual:
+  case kTrackletPhi:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     g->Draw("apl");
     ax = g->GetHistogram()->GetYaxis();
     ax->SetRangeUser(-.5, 2.);
-    ax->SetTitle("Tracklet Phi Residuals #sigma/#mu [rad]");
+    ax->SetTitle("Tracklet-Track Phi-Residuals #sigma/#mu [rad]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
-    b = new TBox(-.15, -.5, .15, 1.);
+    b = new TBox(-.15, y[0], .15, y[1]);
     b->SetFillStyle(3002);b->SetFillColor(kGreen);
     b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kClusterResolution:
+  case kMCcluster:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     ax = g->GetHistogram()->GetYaxis();
-    ax->SetRangeUser(-.5, 1.);
-    ax->SetTitle("Cluster Y Resolution #sigma/#mu [mm]");
+    y[0] = -.1; y[1] = 1.5;
+    ax->SetRangeUser(y[0], y[1]);
+    ax->SetTitle("Y_{cluster} #sigma/#mu [mm]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     g->Draw("apl");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
-    b = new TBox(-.15, -.5, .15, 1.);
-    b->SetFillStyle(3002);b->SetFillColor(kGreen);
+    b = new TBox(-.15, y[0], .15, y[1]);
+    b->SetFillStyle(3002);b->SetFillColor(kBlue);
     b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kTrackletYResolution:
+  case kMCtrackletY:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     ax = g->GetHistogram()->GetYaxis();
-    ax->SetRangeUser(-.5, 1.);
-    ax->SetTitle("Tracklet Y Resolution #sigma/#mu [mm]");
+    y[0] = -.05; y[1] = 0.3;
+    ax->SetRangeUser(y[0], y[1]);
+    ax->SetTitle("Y_{tracklet} #sigma/#mu [mm]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     g->Draw("apl");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
+    b = new TBox(-.15, y[0], .15, y[1]);
+    b->SetFillStyle(3002);b->SetFillColor(kBlue);
+    b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kTrackletZResolution:
+  case kMCtrackletZ:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     ax = g->GetHistogram()->GetYaxis();
     ax->SetRangeUser(-.5, 1.);
-    ax->SetTitle("Tracklet Z Resolution #sigma/#mu [mm]");
+    ax->SetTitle("Z_{tracklet} #sigma/#mu [mm]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#theta)");
     g->Draw("apl");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
     return kTRUE;
-  case kTrackletAngleResolution:
+  case kMCtrackletPhi:
     if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
     ax = g->GetHistogram()->GetYaxis();
-    ax->SetRangeUser(-.05, .2);
-    ax->SetTitle("Tracklet Angular Resolution #sigma/#mu [deg]");
+    y[0] = -.05; y[1] = .2;
+    ax->SetRangeUser(y[0], y[1]);
+    ax->SetTitle("#Phi_{tracklet} #sigma/#mu [deg]");
     ax = g->GetHistogram()->GetXaxis();
     ax->SetTitle("tg(#phi)");
     g->Draw("apl");
     if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
     g->Draw("pl");
     return kTRUE;
-  case kTrackYResolution:
+  case kMCtrackY:
+    if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
+    ax = g->GetHistogram()->GetYaxis();
+    y[0] = -.05; y[1] = 0.2;
+    ax->SetRangeUser(y[0], y[1]);
+    ax->SetTitle("Y_{track} #sigma/#mu [mm]");
+    ax = g->GetHistogram()->GetXaxis();
+    ax->SetTitle("tg(#phi)");
+    g->Draw("apl");
+    if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
+    g->Draw("pl");
+    b = new TBox(-.15, y[0], .15, y[1]);
+    b->SetFillStyle(3002);b->SetFillColor(kBlue);
+    b->SetLineColor(0); b->Draw();
     return kTRUE;
-  case kTrackZResolution:
+  case kMCtrackZ:
+    if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
+    ax = g->GetHistogram()->GetYaxis();
+    ax->SetRangeUser(-.5, 2.);
+    ax->SetTitle("Z_{track} #sigma/#mu [mm]");
+    ax = g->GetHistogram()->GetXaxis();
+    ax->SetTitle("tg(#theta)");
+    g->Draw("apl");
+    if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
+    g->Draw("pl");
     return kTRUE;
-  default:
-    AliInfo(Form("Reference plot [%d] not implemented yet", ifig));
-    return kFALSE;
   }
   AliInfo(Form("Reference plot [%d] missing result", ifig));
   return kFALSE;
@@ -642,18 +592,34 @@ Bool_t AliTRDtrackingResolution::PostProcess()
     return kFALSE;
   }
   fNRefFigures = fContainer->GetEntriesFast();
+  TGraphErrors *gm = 0x0, *gs = 0x0;
   if(!fGraphS){ 
     fGraphS = new TObjArray(fNRefFigures);
     fGraphS->SetOwner();
+    for(Int_t ig=0; ig<fNRefFigures; ig++){
+      gs = new TGraphErrors();
+      gs->SetLineColor(kRed);
+      gs->SetMarkerStyle(23);
+      gs->SetMarkerColor(kRed);
+      gs->SetNameTitle(Form("s_%d", ig), "");
+      fGraphS->AddAt(gs, ig);
+    }
   }
   if(!fGraphM){ 
     fGraphM = new TObjArray(fNRefFigures);
     fGraphM->SetOwner();
+    for(Int_t ig=0; ig<fNRefFigures; ig++){
+      gm = new TGraphErrors();
+      gm->SetLineColor(kBlue);
+      gm->SetMarkerStyle(7);
+      gm->SetMarkerColor(kBlue);
+      gm->SetNameTitle(Form("m_%d", ig), "");
+      fGraphM->AddAt(gm, ig);
+    }
   }
 
   TH2I *h2 = 0x0;
   TH1D *h = 0x0;
-  TGraphErrors *gm = 0x0, *gs = 0x0;
 
   // define models
   TF1 f("f1", "gaus", -.5, .5);  
@@ -671,19 +637,9 @@ Bool_t AliTRDtrackingResolution::PostProcess()
   //PROCESS RESIDUAL DISTRIBUTIONS
 
   // Clusters residuals
-  h2 = (TH2I *)(fContainer->At(kClusterResidual));
-  gm = new TGraphErrors();
-  gm->SetLineColor(kBlue);
-  gm->SetMarkerStyle(7);
-  gm->SetMarkerColor(kBlue);
-  gm->SetNameTitle("clm", "");
-  fGraphM->AddAt(gm, kClusterResidual);
-  gs = new TGraphErrors();
-  gs->SetLineColor(kRed);
-  gs->SetMarkerStyle(23);
-  gs->SetMarkerColor(kRed);
-  gs->SetNameTitle("cls", "");
-  fGraphS->AddAt(gs, kClusterResidual);
+  h2 = (TH2I *)(fContainer->At(kCluster));
+  gm = (TGraphErrors*)fGraphM->At(kCluster);
+  gs = (TGraphErrors*)fGraphS->At(kCluster);
   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
     h = h2->ProjectionY("py", ibin, ibin);
@@ -702,19 +658,9 @@ Bool_t AliTRDtrackingResolution::PostProcess()
   }
 
   // Tracklet y residuals
-  h2 = (TH2I *)(fContainer->At(kTrackletYResidual));
-  gm = new TGraphErrors();
-  gm->SetLineColor(kBlue);
-  gm->SetMarkerStyle(7);
-  gm->SetMarkerColor(kBlue);
-  gm->SetNameTitle("tktm", "");
-  fGraphM->AddAt(gm, kTrackletYResidual);
-  gs = new TGraphErrors();
-  gs->SetLineColor(kRed);
-  gs->SetMarkerStyle(23);
-  gs->SetMarkerColor(kRed);
-  gs->SetNameTitle("tkts", "");
-  fGraphS->AddAt(gs, kTrackletYResidual);
+  h2 = (TH2I *)(fContainer->At(kTrackletY));
+  gm = (TGraphErrors*)fGraphM->At(kTrackletY);
+  gs = (TGraphErrors*)fGraphS->At(kTrackletY);
   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
     h = h2->ProjectionY("py", ibin, ibin);
@@ -733,19 +679,9 @@ Bool_t AliTRDtrackingResolution::PostProcess()
   }
 
   // Tracklet phi residuals
-  h2 = (TH2I *)(fContainer->At(kTrackletPhiResidual));
-  gm = new TGraphErrors();
-  gm->SetLineColor(kBlue);
-  gm->SetMarkerStyle(7);
-  gm->SetMarkerColor(kBlue);
-  gm->SetNameTitle("tktphim", "");
-  fGraphM->AddAt(gm, kTrackletPhiResidual);
-  gs = new TGraphErrors();
-  gs->SetLineColor(kRed);
-  gs->SetMarkerStyle(23);
-  gs->SetMarkerColor(kRed);
-  gs->SetNameTitle("tktphis", "");
-  fGraphS->AddAt(gs, kTrackletPhiResidual);
+  h2 = (TH2I *)(fContainer->At(kTrackletPhi));
+  gm = (TGraphErrors*)fGraphM->At(kTrackletPhi);
+  gs = (TGraphErrors*)fGraphS->At(kTrackletPhi);
   for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
     Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
     h = h2->ProjectionY("py", ibin, ibin);
@@ -763,138 +699,143 @@ Bool_t AliTRDtrackingResolution::PostProcess()
     gs->SetPointError(ip, 0., 10.*f.GetParError(2));
   }
 
+  if(!HasMCdata()){
+    if(c) delete c;
+    return kTRUE;
+  }
 
-  //PROCESS RESOLUTION DISTRIBUTIONS
-
-  if(HasMCdata()){
-    // cluster y resolution
-    h2 = (TH2I*)fContainer->At(kClusterResolution);
-    gm = new TGraphErrors();
-    gm->SetLineColor(kBlue);
-    gm->SetMarkerStyle(7);
-    gm->SetMarkerColor(kBlue);
-    gm->SetNameTitle("clym", "");
-    fGraphM->AddAt(gm, kClusterResolution);
-    gs = new TGraphErrors();
-    gs->SetLineColor(kRed);
-    gs->SetMarkerStyle(23);
-    gs->SetMarkerColor(kRed);
-    gs->SetNameTitle("clys", "");
-    fGraphS->AddAt(gs, kClusterResolution);
-    for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
-      h = h2->ProjectionY("py", iphi, iphi);
-      if(h->GetEntries()<100) continue;
-      AdjustF1(h, &f);
-
-      if(IsVisual()){c->cd(); c->SetLogy();}
-      h->Fit(&f, opt, "", -0.5, 0.5);
-      if(IsVerbose()){
-        printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
-      }
-      if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
-
-      Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
-      Int_t ip = gm->GetN();
-      gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
-      gm->SetPointError(ip, 0., 10.*f.GetParError(1));
-      gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
-      gs->SetPointError(ip, 0., 10.*f.GetParError(2));
-    }
-  
-    // tracklet y resolution
-    h2 = (TH2I*)fContainer->At(kTrackletYResolution);
-    gm = new TGraphErrors();
-    gm->SetLineColor(kBlue);
-    gm->SetMarkerStyle(7);
-    gm->SetMarkerColor(kBlue);
-    gm->SetNameTitle("trkltym", "");
-    fGraphM->AddAt(gm, kTrackletYResolution);
-    gs = new TGraphErrors();
-    gs->SetLineColor(kRed);
-    gs->SetMarkerStyle(23);
-    gs->SetMarkerColor(kRed);
-    gs->SetNameTitle("trkltys", "");
-    fGraphS->AddAt(gs, kTrackletYResolution);
-    for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
-      h = h2->ProjectionY("py", iphi, iphi);
-      if(h->GetEntries()<100) continue;
-      AdjustF1(h, &f);
-
-      if(IsVisual()){c->cd(); c->SetLogy();}
-      h->Fit(&f, opt, "", -0.5, 0.5);
-      if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
-
-      Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
-      Int_t ip = gm->GetN();
-      gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
-      gm->SetPointError(ip, 0., 10.*f.GetParError(1));
-      gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
-      gs->SetPointError(ip, 0., 10.*f.GetParError(2));
-    }
-  
-    // tracklet z resolution
-    h2 = (TH2I*)fContainer->At(kTrackletZResolution);
-    gm = new TGraphErrors();
-    gm->SetLineColor(kBlue);
-    gm->SetMarkerStyle(7);
-    gm->SetMarkerColor(kBlue);
-    gm->SetNameTitle("trkltzm", "");
-    fGraphM->AddAt(gm, kTrackletZResolution);
-    gs = new TGraphErrors();
-    gs->SetLineColor(kRed);
-    gs->SetMarkerStyle(23);
-    gs->SetMarkerColor(kRed);
-    gs->SetNameTitle("trkltzs", "");
-    fGraphS->AddAt(gs, kTrackletZResolution);
-    for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
-      h = h2->ProjectionY("py", iphi, iphi);
-      if(h->GetEntries()<100) continue;
-      AdjustF1(h, &fb);
-
-      if(IsVisual()){c->cd(); c->SetLogy();}
-      h->Fit(&fb, opt, "", -0.5, 0.5);
-      if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
-
-      Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
-      Int_t ip = gm->GetN();
-      gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
-      gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
-      gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
-      gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
-    }
-  
-    //tracklet phi resolution
-    h2 = (TH2I*)fContainer->At(kTrackletAngleResolution);
-    gm = new TGraphErrors();
-    gm->SetLineColor(kBlue);
-    gm->SetMarkerStyle(7);
-    gm->SetMarkerColor(kBlue);
-    gm->SetNameTitle("trkltym", "");
-    fGraphM->AddAt(gm, kTrackletAngleResolution);
-    gs = new TGraphErrors();
-    gs->SetLineColor(kRed);
-    gs->SetMarkerStyle(23);
-    gs->SetMarkerColor(kRed);
-    gs->SetNameTitle("trkltys", "");
-    fGraphS->AddAt(gs, kTrackletAngleResolution);
-    for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
-      h = h2->ProjectionY("py", iphi, iphi);
-      if(h->GetEntries()<100) continue;
-
-      if(IsVisual()){c->cd(); c->SetLogy();}
-      h->Fit(&f, opt, "", -0.5, 0.5);
-      if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
-
-      Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
-      Int_t ip = gm->GetN();
-      gm->SetPoint(ip, phi, f.GetParameter(1));
-      gm->SetPointError(ip, 0., f.GetParError(1));
-      gs->SetPoint(ip, phi, f.GetParameter(2));
-      gs->SetPointError(ip, 0., f.GetParError(2));
+  //PROCESS MC RESIDUAL DISTRIBUTIONS
+
+  // cluster y resolution
+  h2 = (TH2I*)fContainer->At(kMCcluster);
+  gm = (TGraphErrors*)fGraphM->At(kMCcluster);
+  gs = (TGraphErrors*)fGraphS->At(kMCcluster);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("py", iphi, iphi);
+    if(h->GetEntries()<100) continue;
+    AdjustF1(h, &f);
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&f, opt, "", -0.5, 0.5);
+    if(IsVerbose()){
+      printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
     }
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
+    gm->SetPointError(ip, 0., 10.*f.GetParError(1));
+    gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
+    gs->SetPointError(ip, 0., 10.*f.GetParError(2));
+  }
+
+  // tracklet y resolution
+  h2 = (TH2I*)fContainer->At(kMCtrackletY);
+  gm = (TGraphErrors*)fGraphM->At(kMCtrackletY);
+  gs = (TGraphErrors*)fGraphS->At(kMCtrackletY);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("py", iphi, iphi);
+    if(h->GetEntries()<100) continue;
+    AdjustF1(h, &f);
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&f, opt, "", -0.5, 0.5);
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
+    gm->SetPointError(ip, 0., 10.*f.GetParError(1));
+    gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
+    gs->SetPointError(ip, 0., 10.*f.GetParError(2));
+  }
+
+  // tracklet z resolution
+  h2 = (TH2I*)fContainer->At(kMCtrackletZ);
+  gm = (TGraphErrors*)fGraphM->At(kMCtrackletZ);
+  gs = (TGraphErrors*)fGraphS->At(kMCtrackletZ);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("py", iphi, iphi);
+    if(h->GetEntries()<100) continue;
+    AdjustF1(h, &fb);
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&fb, opt, "", -0.5, 0.5);
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
+    gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
+    gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
+    gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
+  }
+
+  //tracklet phi resolution
+  h2 = (TH2I*)fContainer->At(kMCtrackletPhi);
+  gm = (TGraphErrors*)fGraphM->At(kMCtrackletPhi);
+  gs = (TGraphErrors*)fGraphS->At(kMCtrackletPhi);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("py", iphi, iphi);
+    if(h->GetEntries()<100) continue;
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&f, opt, "", -0.5, 0.5);
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, f.GetParameter(1));
+    gm->SetPointError(ip, 0., f.GetParError(1));
+    gs->SetPoint(ip, phi, f.GetParameter(2));
+    gs->SetPointError(ip, 0., f.GetParError(2));
+  }
+
+  // track y resolution
+  h2 = (TH2I*)fContainer->At(kMCtrackY);
+  gm = (TGraphErrors*)fGraphM->At(kMCtrackY);
+  gs = (TGraphErrors*)fGraphS->At(kMCtrackY);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("py", iphi, iphi);
+    if(h->GetEntries()<100) continue;
+    AdjustF1(h, &f);
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&f, opt, "", -0.5, 0.5);
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
+    gm->SetPointError(ip, 0., 10.*f.GetParError(1));
+    gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
+    gs->SetPointError(ip, 0., 10.*f.GetParError(2));
   }
-  if(c) delete c;
 
+  // track z resolution
+  h2 = (TH2I*)fContainer->At(kMCtrackZ);
+  gm = (TGraphErrors*)fGraphM->At(kMCtrackZ);
+  gs = (TGraphErrors*)fGraphS->At(kMCtrackZ);
+  for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
+    h = h2->ProjectionY("pz", iphi, iphi);
+    if(h->GetEntries()<70) continue;
+    AdjustF1(h, &f);
+
+    if(IsVisual()){c->cd(); c->SetLogy();}
+    h->Fit(&f, opt, "", -0.5, 0.5);
+    if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
+
+    Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
+    Int_t ip = gm->GetN();
+    gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
+    gm->SetPointError(ip, 0., 10.*f.GetParError(1));
+    gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
+    gs->SetPointError(ip, 0., 10.*f.GetParError(2));
+  }
+
+
+  if(c) delete c;
   return kTRUE;
 }
 
@@ -950,89 +891,89 @@ TObjArray* AliTRDtrackingResolution::Histos()
 
   TH1 *h = 0x0;
   // cluster to tracklet residuals [2]
-  if(!(h = (TH2I*)gROOT->FindObject("fYCl"))){
-    h = new TH2I("fYCl", "Clusters Residuals", 21, -.33, .33, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hCl"))){
+    h = new TH2I("hCl", "Clusters-Track Residuals", 21, -.33, .33, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta y [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kClusterResidual);
+  fContainer->AddAt(h, kCluster);
 
   // tracklet to track residuals [2]
-  if(!(h = (TH2I*)gROOT->FindObject("hTrkltYRez"))){ 
-    h = new TH2I("hTrkltYRez", "Tracklets", 21, -.33, .33, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hTrkltY"))){
+    h = new TH2I("hTrkltY", "Tracklets-Track Residuals (Y)", 21, -.33, .33, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta y [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackletYResidual);
+  fContainer->AddAt(h, kTrackletY);
 
   // tracklet to track residuals angular [2]
-  if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhiRez"))){ 
-    h = new TH2I("hTrkltPhiRez", "Tracklets", 21, -.33, .33, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhi"))){
+    h = new TH2I("hTrkltPhi", "Tracklets-Track Residuals (#Phi)", 21, -.33, .33, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta phi [#circ]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackletPhiResidual);
+  fContainer->AddAt(h, kTrackletPhi);
 
 
   // Resolution histos
   if(!HasMCdata()) return fContainer;
 
   // cluster y resolution [0]
-  if(!(h = (TH2I*)gROOT->FindObject("fYClMC"))){
-    h = new TH2I("fYClMC", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCcl"))){
+    h = new TH2I("hMCcl", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta y [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kClusterResolution);
+  fContainer->AddAt(h, kMCcluster);
 
   // tracklet y resolution [0]
-  if(!(h = (TH2I*)gROOT->FindObject("fYTrkltMC"))){
-    h = new TH2I("fYTrkltMC", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltY"))){
+    h = new TH2I("hMCtrkltY", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta y [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackletYResolution);
+  fContainer->AddAt(h, kMCtrackletY);
 
   // tracklet y resolution [0]
-  if(!(h = (TH2I*)gROOT->FindObject("fZTrkltMC"))){
-    h = new TH2I("fZTrkltMC", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZ"))){
+    h = new TH2I("hMCtrkltZ", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#theta)");
     h->GetYaxis()->SetTitle("#Delta z [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackletZResolution);
+  fContainer->AddAt(h, kMCtrackletZ);
 
   // tracklet angular resolution [1]
-  if(!(h = (TH2I*)gROOT->FindObject("fPhiTrkltMC"))){
-    h = new TH2I("fPhiTrkltMC", "Tracklet Resolution (Angular)", 31, -.48, .48, 100, -10., 10.);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltPhi"))){
+    h = new TH2I("hMCtrkltPhi", "Tracklet Resolution (#Phi)", 31, -.48, .48, 100, -10., 10.);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta #phi [deg]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackletAngleResolution);
+  fContainer->AddAt(h, kMCtrackletPhi);
 
   // Kalman track y resolution
-  if(!(h = (TH2I*)gROOT->FindObject("fYTrkMC"))){
-    h = new TH2I("fYTrkMC", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCtrkY"))){
+    h = new TH2I("hMCtrkY", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
     h->GetXaxis()->SetTitle("tg(#phi)");
     h->GetYaxis()->SetTitle("#Delta y [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackYResolution);
+  fContainer->AddAt(h, kMCtrackY);
 
   // Kalman track Z resolution
-  if(!(h = (TH2I*)gROOT->FindObject("fZTrkMC"))){
-    h = new TH2I("fZTrkMC", "Kalman Track Resolution (Z)", 20, -1., 1., 100, -1.5, 1.5);
+  if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZ"))){
+    h = new TH2I("hMCtrkZ", "Kalman Track Resolution (Z)", 20, -1., 1., 100, -1.5, 1.5);
     h->GetXaxis()->SetTitle("tg(#theta)");
     h->GetYaxis()->SetTitle("#Delta z [cm]");
     h->GetZaxis()->SetTitle("entries");
   } else h->Reset();
-  fContainer->AddAt(h, kTrackZResolution);
+  fContainer->AddAt(h, kMCtrackZ);
 
   return fContainer;
 }
index 2c49481..348f0c1 100644 (file)
@@ -27,21 +27,15 @@ class AliTRDtrackingResolution : public AliTRDrecoTask
 {
 public:
   enum{
-    kClusterResidual         = 0
-    ,kTrackletYResidual      = 1 // tracklet - track residuals
-    ,kTrackletPhiResidual    = 2 // tracklet - track angular residuals
-//     ,kTrackletKalmanYResidual = 3 // Kalman track model
-//     ,kTrackletKalmanAngleResidual = 4
-    ,kClusterResolution      = 3/*5*/
-    ,kTrackletYResolution    = 4/*6*/
-    ,kTrackletZResolution    = 5/*6*/
-    ,kTrackletAngleResolution= 6/*7*/
-    ,kTrackYResolution       = 7 // Kalman Y resolution
-    ,kTrackZResolution       = 8 // Kalman Z resolution
-//     ,kTrackRAngleResolution   = 10
-//     ,kTrackKYResolution       = 11 // Kalman track model
-//     ,kTrackKZResolution       = 12
-//     ,kTrackKAngleResolution   = 13
+    kCluster        = 0
+    ,kTrackletY     = 1 // tracklet - track y pools
+    ,kTrackletPhi   = 2 // tracklet - track angular pools residuals
+    ,kMCcluster     = 3/*5*/
+    ,kMCtrackletY   = 4/*6*/
+    ,kMCtrackletZ   = 5/*6*/
+    ,kMCtrackletPhi = 6/*7*/
+    ,kMCtrackY      = 7 // Kalman Y resolution
+    ,kMCtrackZ      = 8 // Kalman Z resolution
   };
   enum{
     kVerbose  = 0
@@ -59,9 +53,9 @@ public:
   Bool_t  IsVisual() const {return TESTBIT(fStatus, kVisual);}
   Bool_t  PostProcess();
 
-  TH1*    PlotClusterResiduals(const AliTRDtrackV1 *t=0x0);
-  TH1*    PlotTrackletResiduals(const AliTRDtrackV1 *t=0x0);
-  TH1*    PlotTrackletPhiResiduals(const AliTRDtrackV1 *t=0x0);
+  TH1*    PlotCluster(const AliTRDtrackV1 *t=0x0);
+  TH1*    PlotTracklet(const AliTRDtrackV1 *t=0x0);
+  TH1*    PlotTrackletPhi(const AliTRDtrackV1 *t=0x0);
   TH1*    PlotResolution(const AliTRDtrackV1 *t=0x0);
 
   void    SetRecoParam(AliTRDrecoParam *r);
index 9047fab..6c7def6 100644 (file)
@@ -162,7 +162,7 @@ void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0)
     task->PostProcess();
     TCanvas *c=new TCanvas();
     for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
-      if(!task->GetRefFigure(ipic)) return;
+      if(!task->GetRefFigure(ipic)) continue;
       c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
       c->Clear();
     }