]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.cxx
totEt updates from Christine
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.cxx
index e8b94b73ff8c42b92a0befc4970fc72c30f78e96..fd53b09399eba2e5a26ae952875a6ee589e188a2 100644 (file)
 
 #include "AliLog.h"
 #include "AliMathBase.h"
+#include "AliRieman.h"
 #include "AliCDBManager.h"
-#include "AliTracker.h"
 
+#include "AliTRDReconstructor.h"
 #include "AliTRDpadPlane.h"
 #include "AliTRDcluster.h"
 #include "AliTRDseedV1.h"
@@ -58,6 +59,8 @@
 #include "Cal/AliTRDCalROC.h"
 #include "Cal/AliTRDCalDet.h"
 
+class AliTracker;
+
 ClassImp(AliTRDseedV1)
 
 //____________________________________________________________________
@@ -90,7 +93,7 @@ AliTRDseedV1::AliTRDseedV1(Int_t det)
   //
   memset(fIndexes,0xFF,kNclusters*sizeof(fIndexes[0]));
   memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
-  memset(fPad, 0, 3*sizeof(Float_t));
+  memset(fPad, 0, 4*sizeof(Float_t));
   fYref[0] = 0.; fYref[1] = 0.; 
   fZref[0] = 0.; fZref[1] = 0.; 
   fYfit[0] = 0.; fYfit[1] = 0.; 
@@ -212,7 +215,7 @@ void AliTRDseedV1::Copy(TObject &ref) const
   
   memcpy(target.fIndexes, fIndexes, kNclusters*sizeof(Int_t));
   memcpy(target.fClusters, fClusters, kNclusters*sizeof(AliTRDcluster*));
-  memcpy(target.fPad, fPad, 3*sizeof(Float_t));
+  memcpy(target.fPad, fPad, 4*sizeof(Float_t));
   target.fYref[0] = fYref[0]; target.fYref[1] = fYref[1]; 
   target.fZref[0] = fZref[0]; target.fZref[1] = fZref[1]; 
   target.fYfit[0] = fYfit[0]; target.fYfit[1] = fYfit[1]; 
@@ -228,6 +231,28 @@ void AliTRDseedV1::Copy(TObject &ref) const
 }
 
 
+//____________________________________________________________
+void AliTRDseedV1::Init(const AliRieman *rieman)
+{
+// Initialize this tracklet using the riemann fit information
+
+
+  fZref[0] = rieman->GetZat(fX0);
+  fZref[1] = rieman->GetDZat(fX0);
+  fYref[0] = rieman->GetYat(fX0);
+  fYref[1] = rieman->GetDYat(fX0);
+  if(fkReconstructor && fkReconstructor->IsHLT()){
+    fRefCov[0] = 1;
+    fRefCov[2] = 10;
+  }else{
+    fRefCov[0] = rieman->GetErrY(fX0);
+    fRefCov[2] = rieman->GetErrZ(fX0);
+  }
+  fC[0]    = rieman->GetC(); 
+  fChi2    = rieman->GetChi2();
+}
+
+
 //____________________________________________________________
 Bool_t AliTRDseedV1::Init(AliTRDtrackV1 *track)
 {
@@ -274,7 +299,7 @@ void AliTRDseedV1::Reset(Option_t *opt)
   fC[0]=0.; fC[1]=0.; 
   fChi2 = 0.;
 
-  memset(fPad, 0, 3*sizeof(Float_t));
+  memset(fPad, 0, 4*sizeof(Float_t));
   fYref[0] = 0.; fYref[1] = 0.; 
   fZref[0] = 0.; fZref[1] = 0.; 
   fYfit[0] = 0.; fYfit[1] = 0.; 
@@ -395,22 +420,22 @@ void AliTRDseedV1::CookdEdx(Int_t nslices)
   for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++){
     if(!(c = fClusters[ic]) && !(c = fClusters[ic+kNtb])) continue;
     Float_t dx = TMath::Abs(fX0 - c->GetX());
-    
+
     // Filter clusters for dE/dx calculation
-    
+
     // 1.consider calibration effects for slice determination
     Int_t slice;
-    if(dx<kDriftLength){ // TODO should be replaced by c->IsInChamber() 
+    if(dx<kDriftLength){ // TODO should be replaced by c->IsInChamber()
       slice = Int_t(dx * nslices / kDriftLength);
     } else slice = c->GetX() < fX0 ? nslices-1 : 0;
 
 
     // 2. take sharing into account
     Float_t w = /*c->IsShared() ? .5 :*/ 1.;
-    
+
     // 3. take into account large clusters TODO
     //w *= c->GetNPads() > 3 ? .8 : 1.;
-    
+
     //CHECK !!!
     fdEdx[slice]   += w * GetdQdl(ic); //fdQdl[ic];
   } // End of loop over clusters
@@ -441,6 +466,36 @@ void AliTRDseedV1::CookLabels()
   if ((fLabels[2]  > 1) && (out[3] > 1)) fLabels[1] = out[2];
 }
 
+//____________________________________________________________
+Float_t AliTRDseedV1::GetAnodeWireOffset(Float_t zt)
+{
+// Find position inside the amplification cell for reading drift velocity map
+
+  Float_t d = fPad[3] - zt;
+  if(d<0.){
+    AliError(Form("Fail AnodeWireOffset calculation z0[%+7.2f] zt[%+7.2f] d[%+7.2f].", fPad[3], zt, d));
+    return 0.125;
+  } 
+  d -= ((Int_t)(2 * d)) / 2.0;
+  if(d > 0.25) d = 0.5 - d;
+  return d;
+}
+
+
+//____________________________________________________________________
+Float_t AliTRDseedV1::GetCharge(Bool_t useOutliers)
+{
+// Computes total charge attached to tracklet. If "useOutliers" is set clusters 
+// which are not in chamber are also used (default false)
+
+  AliTRDcluster *c(NULL); Float_t qt(0.);
+  for(int ic=0; ic<kNclusters; ic++){
+    if(!(c=fClusters[ic])) continue;
+    if(c->IsInChamber() && !useOutliers) continue;
+    qt += TMath::Abs(c->GetQ());
+  }
+  return qt;
+}
 
 //____________________________________________________________________
 Float_t AliTRDseedV1::GetdQdl(Int_t ic, Float_t *dl) const
@@ -471,7 +526,8 @@ Float_t AliTRDseedV1::GetdQdl(Int_t ic, Float_t *dl) const
   if(fClusters[ic] && fClusters[ic]->IsInChamber()){
     hasClusterInChamber = kTRUE;
     dq += TMath::Abs(fClusters[ic]->GetQ());
-  }else if(fClusters[ic+kNtb] && fClusters[ic+kNtb]->IsInChamber()){
+  }
+  if(fClusters[ic+kNtb] && fClusters[ic+kNtb]->IsInChamber()){
     hasClusterInChamber = kTRUE;
     dq += TMath::Abs(fClusters[ic+kNtb]->GetQ());
   }
@@ -682,18 +738,23 @@ void AliTRDseedV1::GetCovAt(Double_t x, Double_t *cov) const
     sy2 += sys[0];
     sz2 += sys[1];
   }
-  // rotate covariance matrix
-  Double_t t2 = GetTilt()*GetTilt();
-  Double_t correction = 1./(1. + t2);
-  cov[0] = (sy2+t2*sz2)*correction;
-  cov[1] = GetTilt()*(sz2 - sy2)*correction;
-  cov[2] = (t2*sy2+sz2)*correction;
-
-  //printf("C(%6.1f %+6.3f %6.1f)  [%s]\n", 1.e4*TMath::Sqrt(cov[0]), cov[1], 1.e4*TMath::Sqrt(cov[2]), IsRowCross()?" RC ":"-");
+
+  // rotate covariance matrix if no RC
+  if(!IsRowCross()){
+    Double_t t2 = GetTilt()*GetTilt();
+    Double_t correction = 1./(1. + t2);
+    cov[0] = (sy2+t2*sz2)*correction;
+    cov[1] = GetTilt()*(sz2 - sy2)*correction;
+    cov[2] = (t2*sy2+sz2)*correction;
+  } else {
+    cov[0] = sy2; cov[1] = 0.; cov[2] = sy2;
+  }
+
+  AliDebug(4, Form("C(%6.1f %+6.3f %6.1f)  RC[%c]", 1.e4*TMath::Sqrt(cov[0]), cov[1], 1.e4*TMath::Sqrt(cov[2]), IsRowCross()?'y':'n'));
 }
 
 //____________________________________________________________
-Double_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
+Int_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
 {
 // Helper function to calculate the square root of the covariance matrix. 
 // The input matrix is stored in the vector c and the result in the vector d. 
@@ -712,6 +773,7 @@ Double_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
 // Author A.Bercuci <A.Bercuci@gsi.de>
 // Date   Mar 19 2009
 
+  const Double_t kZero(1.e-20);
   Double_t l[2], // eigenvalues
            v[3]; // eigenvectors
   // the secular equation and its solution :
@@ -720,26 +782,33 @@ Double_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
   // L12 = [Tr(c) +- sqrt(Tr(c)^2-4*DET(c))]/2
   Double_t tr = c[0]+c[2],           // trace
           det = c[0]*c[2]-c[1]*c[1]; // determinant
-  if(TMath::Abs(det)<1.e-20) return -1.;
+  if(TMath::Abs(det)<kZero) return 1;
   Double_t dd = TMath::Sqrt(tr*tr - 4*det);
-  l[0] = .5*(tr + dd);
-  l[1] = .5*(tr - dd);
-  if(l[0]<0. || l[1]<0.) return -1.;
-
+  l[0] = .5*(tr + dd*(c[0]>c[2]?-1.:1.));
+  l[1] = .5*(tr + dd*(c[0]>c[2]?1.:-1.));
+  if(l[0]<kZero || l[1]<kZero) return 2;
   // the sym V matrix
   // | v00   v10|
   // | v10   v11|
-  Double_t tmp = (l[0]-c[0])/c[1];
-  v[0] = TMath::Sqrt(1./(tmp*tmp+1));
-  v[1] = tmp*v[0];
-  v[2] = v[1]*c[1]/(l[1]-c[2]);
+  Double_t den = (l[0]-c[0])*(l[0]-c[0])+c[1]*c[1];
+  if(den<kZero){ // almost diagonal
+    v[0] = TMath::Sign(0., c[1]);
+    v[1] = TMath::Sign(1., (l[0]-c[0]));
+    v[2] = TMath::Sign(0., c[1]*(l[0]-c[0])*(l[1]-c[2]));
+  } else {
+    Double_t tmp = 1./TMath::Sqrt(den);
+    v[0] = c[1]* tmp;
+    v[1] = (l[0]-c[0])*tmp;
+    if(TMath::Abs(l[1]-c[2])<kZero) v[2] = TMath::Sign(v[0]*(l[0]-c[0])/kZero, (l[1]-c[2]));
+    else v[2] = v[0]*(l[0]-c[0])/(l[1]-c[2]);
+  }
   // the VD^{1/2}V is: 
   l[0] = TMath::Sqrt(l[0]); l[1] = TMath::Sqrt(l[1]);
   d[0] = v[0]*v[0]*l[0]+v[1]*v[1]*l[1];
   d[1] = v[0]*v[1]*l[0]+v[1]*v[2]*l[1];
   d[2] = v[1]*v[1]*l[0]+v[2]*v[2]*l[1];
 
-  return 1.;
+  return 0;
 }
 
 //____________________________________________________________
@@ -765,6 +834,8 @@ Double_t AliTRDseedV1::GetCovInv(const Double_t * const c, Double_t *d)
 //____________________________________________________________________
 UShort_t AliTRDseedV1::GetVolumeId() const
 {
+// Returns geometry volume id by delegation 
+
   for(Int_t ic(0);ic<kNclusters; ic++){
     if(fClusters[ic]) return fClusters[ic]->GetVolumeId();
   }
@@ -842,13 +913,13 @@ void AliTRDseedV1::SetOwner()
 }
 
 //____________________________________________________________
-void AliTRDseedV1::SetPadPlane(AliTRDpadPlane *p)
+void AliTRDseedV1::SetPadPlane(AliTRDpadPlane * const p)
 {
 // Shortcut method to initialize pad geometry.
-  if(!p) return;
-  SetTilt(TMath::Tan(TMath::DegToRad()*p->GetTiltingAngle()));
-  SetPadLength(p->GetLengthIPad());
-  SetPadWidth(p->GetWidthIPad());
+  fPad[0] = p->GetLengthIPad();
+  fPad[1] = p->GetWidthIPad();
+  fPad[2] = TMath::Tan(TMath::DegToRad()*p->GetTiltingAngle());
+  fPad[3] = p->GetRow0() + p->GetAnodeWireOffset();
 }
 
 
@@ -1171,10 +1242,8 @@ void AliTRDseedV1::Bootstrap(const AliTRDReconstructor *rec)
 //
   fkReconstructor = rec;
   AliTRDgeometry g;
-  AliTRDpadPlane *pp = g.GetPadPlane(fDet);
-  fPad[0] = pp->GetLengthIPad();
-  fPad[1] = pp->GetWidthIPad();
-  fPad[2] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle());
+  SetPadPlane(g.GetPadPlane(fDet));
+
   //fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
   //fTgl = fZref[1];
   Int_t n = 0, nshare = 0, nused = 0;
@@ -1193,16 +1262,17 @@ void AliTRDseedV1::Bootstrap(const AliTRDReconstructor *rec)
 
 
 //____________________________________________________________________
-Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
+Bool_t AliTRDseedV1::Fit(UChar_t opt)
 {
 //
 // Linear fit of the clusters attached to the tracklet
 //
 // Parameters :
-//   - tilt : switch for tilt pad correction of cluster y position based on 
-//            the z, dzdx info from outside [default false].
-//   - zcorr : switch for using z information to correct for anisochronity 
-//            and a finner error parameterization estimation [default false]  
+//   - opt : switch for tilt pad correction of cluster y position. Options are
+//           0 no correction [default]
+//           1 full tilt correction [dz/dx and z0]
+//           2 pseudo tilt correction [dz/dx from pad-chamber geometry]
+//
 // Output :
 //  True if successful
 //
@@ -1292,15 +1362,18 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
     return kFALSE;
   }
   if(!IsCalibrated()) Calibrate();
+  if(opt>2){
+    AliWarning(Form("Option [%d] outside range [0, 2]. Using default",opt));
+    opt=0;
+  }
 
   const Int_t kClmin = 8;
-
+  const Float_t kScalePulls = 10.; // factor to scale y pulls - NOT UNDERSTOOD
   // get track direction
   Double_t y0   = fYref[0];
   Double_t dydx = fYref[1]; 
   Double_t z0   = fZref[0];
   Double_t dzdx = fZref[1];
-  Double_t yt, zt;
 
   AliTRDtrackerV1::AliTRDLeastSquare fitterY;
   AliTRDtrackerV1::AliTRDLeastSquare fitterZ;
@@ -1308,16 +1381,39 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
   // book cluster information
   Double_t qc[kNclusters], xc[kNclusters], yc[kNclusters], zc[kNclusters], sy[kNclusters];
 
-  Int_t n = 0;
-  AliTRDcluster *c=NULL, **jc = &fClusters[0];
+  Bool_t tilt(opt==1)       // full tilt correction
+        ,pseudo(opt==2)     // pseudo tilt correction
+        ,rc(IsRowCross())   // row cross candidate 
+        ,kDZDX(IsPrimary());// switch dzdx calculation for barrel primary tracks
+  Int_t n(0);   // clusters used in fit 
+  AliTRDcluster *c(NULL), *cc(NULL), **jc = &fClusters[0];
   const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam(); //the dynamic cast in GetRecoParam is slow, so caching the pointer to it
-  for (Int_t ic=0; ic<kNtb; ic++, ++jc) {
-    xc[ic]  = -1.;
-    yc[ic]  = 999.;
-    zc[ic]  = 999.;
-    sy[ic]  = 0.;
+
+  const Char_t *tcName[]={"NONE", "FULL", "HALF"};
+  AliDebug(2, Form("Options : TC[%s] dzdx[%c]", tcName[opt], kDZDX?'Y':'N'));
+
+  for (Int_t ic=0; ic<kNclusters; ic++, ++jc) {
+    xc[ic]  = -1.; yc[ic]  = 999.; zc[ic]  = 999.; sy[ic]  = 0.;
     if(!(c = (*jc))) continue;
     if(!c->IsInChamber()) continue;
+    // compute pseudo tilt correction
+    if(kDZDX){ 
+      fZfit[0] = c->GetZ();
+      if(rc){
+        for(Int_t kc=AliTRDseedV1::kNtb; kc<AliTRDseedV1::kNclusters; kc++){
+          if(!(cc=fClusters[kc])) continue;
+          if(!cc->IsInChamber()) continue;
+          fZfit[0] += cc->GetZ(); fZfit[0] *= 0.5;
+          break;
+        }
+      }
+      fZfit[1] = fZfit[0]/fX0;
+      if(rc){
+        fZfit[0] += fZfit[1]*0.5*AliTRDgeometry::CdrHght();
+        fZfit[1] = fZfit[0]/fX0;
+      }
+      kDZDX=kFALSE;
+    }
 
     Float_t w = 1.;
     if(c->GetNPads()>4) w = .5;
@@ -1327,37 +1423,41 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
     qc[n]   = TMath::Abs(c->GetQ());
     // pad row of leading 
 
-    // Radial cluster position
-    //Int_t jc = TMath::Max(fN-3, 0);
-    //xc[fN]   = c->GetXloc(fT0, fVD, &qc[jc], &xc[jc]/*, z0 - c->GetX()*dzdx*/);
     xc[n]   = fX0 - c->GetX();
 
-    // extrapolated track to cluster position
-    yt = y0 - xc[n]*dydx; 
-    zt = z0 - xc[n]*dzdx; 
-
     // Recalculate cluster error based on tracking information
-    c->SetSigmaY2(fS2PRF, fDiffT, fExB, xc[n], zcorr?zt:-1., dydx);
+    c->SetSigmaY2(fS2PRF, fDiffT, fExB, xc[n], -1./*zcorr?zt:-1.*/, dydx);
+    c->SetSigmaZ2(fPad[0]*fPad[0]/12.); // for HLT
     sy[n]  = TMath::Sqrt(c->GetSigmaY2());
 
     yc[n]  = recoParam->UseGAUS() ? 
       c->GetYloc(y0, sy[n], GetPadWidth()): c->GetY();
     zc[n]   = c->GetZ();
-    //optional tilt correction
-    if(tilt) yc[n] -= (GetTilt()*(zc[n] - zt)); 
+
+    //optional r-phi correction
+    //printf("   n[%2d] yc[%7.5f] ", n, yc[n]);
+    Float_t correction(0.);
+    if(tilt) correction = fPad[2]*(xc[n]*dzdx + zc[n] - z0);
+    else if(pseudo) correction = fPad[2]*(xc[n]*fZfit[1] + zc[n]-fZfit[0]);
+    yc[n]-=correction;
+    //printf("corr(%s%s)[%7.5f] yc1[%7.5f]\n", (tilt?"TC":""), (zcorr?"PC":""), correction, yc[n]);
 
     AliDebug(5, Form("  tb[%2d] dx[%6.3f] y[%6.2f+-%6.3f]", c->GetLocalTimeBin(), xc[n], yc[n], sy[n]));
     fitterY.AddPoint(&xc[n], yc[n], sy[n]);
-    if(IsRowCross()) fitterZ.AddPoint(&xc[n], qc[n], 1.);
+    if(rc) fitterZ.AddPoint(&xc[n], qc[n]*(ic<kNtb?1.:-1.), 1.);
     n++;
   }
 
   // to few clusters
-  if (n < kClmin) return kFALSE; 
-
+  if (n < kClmin){ 
+    AliDebug(1, Form("Not enough clusters to fit. Clusters: Attached[%d] Fit[%d].", GetN(), n));
+    SetErrorMsg(kFitCl);
+    return kFALSE; 
+  }
   // fit XY
   if(!fitterY.Eval()){
-    SetErrorMsg(kFitFailed);
+    AliDebug(1, "Fit Y failed.");
+    SetErrorMsg(kFitFailedY);
     return kFALSE;
   }
   fYfit[0] = fitterY.GetFunctionParameter(0);
@@ -1365,23 +1465,22 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
   // store covariance
   Double_t p[3];
   fitterY.GetCovarianceMatrix(p);
-  fCov[0] = p[1]; // variance of y0
-  fCov[1] = p[2]; // covariance of y0, dydx
-  fCov[2] = p[0]; // variance of dydx
+  fCov[0] = kScalePulls*p[1]; // variance of y0
+  fCov[1] = kScalePulls*p[2]; // covariance of y0, dydx
+  fCov[2] = kScalePulls*p[0]; // variance of dydx
   // the ref radial position is set at the minimum of 
   // the y variance of the tracklet
   fX   = -fCov[1]/fCov[2];
+  fS2Y = fCov[0] +2.*fX*fCov[1] + fX*fX*fCov[2];
+
   Float_t xs=fX+.5*AliTRDgeometry::CamHght();
   if(xs < 0. || xs > AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght()){
     AliDebug(1, Form("Ref radial position ouside chamber x[%5.2f].", fX));
-    SetErrorMsg(kFitOutside);
+    SetErrorMsg(kFitFailedY);
     return kFALSE;
   }
 
-  // collect second row clusters
-  Int_t m(0);
-  if(IsRowCross()){
-/*    // THE LEADING CLUSTER METHOD
+/*    // THE LEADING CLUSTER METHOD for z fit
     Float_t xMin = fX0;
     Int_t ic=n=kNclusters-1; jc = &fClusters[ic];
     AliTRDcluster *c0 =0x0, **kc = &fClusters[kNtb-1];
@@ -1397,42 +1496,26 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
     fS2Z     = fdX*fZref[1];
     fS2Z    *= fS2Z; fS2Z    *= 0.2887; //  1/sqrt(12)*/
 
-    // THE FIT X-Q PLANE METHOD 
-    Int_t ic=n=kNclusters-1; jc = &fClusters[ic];
-    for(; ic>kNtb; ic--, --jc){
-      if(!(c = (*jc))) continue;
-      if(!c->IsInChamber()) continue;
-      qc[n]   = TMath::Abs(c->GetQ());
-      xc[n]   = fX0 - c->GetX();
-      zc[n]   = c->GetZ();
-      fitterZ.AddPoint(&xc[n], -qc[n], 1.);
-      n--;m++;
-    }
-  }
-  // fit XZ
-  if(m && IsRowCross()){
-    fitterZ.Eval();
-    if(fitterZ.GetFunctionParameter(1)!=0.){ 
-      fX = -fitterZ.GetFunctionParameter(0)/fitterZ.GetFunctionParameter(1);
-      fX=(fX<0.)?0.:fX;
-      Float_t dl = .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght();
-      fX=(fX> dl)?dl:fX;
-      fX-=.055; // TODO to be understood
+  // fit QZ
+  if(opt!=1 && IsRowCross()){
+    if(!fitterZ.Eval()) SetErrorMsg(kFitFailedZ);
+    if(!HasError(kFitFailedZ) && TMath::Abs(fitterZ.GetFunctionParameter(1))>1.e-10){ 
+      // TODO - one has to recalculate xy fit based on
+      // better knowledge of z position
+//       Double_t x = -fitterZ.GetFunctionParameter(0)/fitterZ.GetFunctionParameter(1);
+//       Double_t z0 = .5*(zc[0]+zc[n-1]);
+//       fZfit[0] = z0 + fZfit[1]*x; 
+//       fZfit[1] = fZfit[0]/fX0; 
+//       redo fit on xy plane
     }
-
-    fZfit[0] = .5*(zc[0]+zc[kNclusters-1]); fZfit[1] = 0.;
     // temporary external error parameterization
     fS2Z     = 0.05+0.4*TMath::Abs(fZref[1]); fS2Z *= fS2Z;
     // TODO correct formula
     //fS2Z     = sigma_x*TMath::Abs(fZref[1]);
   } else {
-    if(IsRowCross() && !m){
-      AliDebug(1, "Tracklet crossed row but no clusters found in neighbor row.");
-    }
-    fZfit[0] = zc[0]; fZfit[1] = 0.;
+    //fZfit[0] = zc[0] + dzdx*0.5*AliTRDgeometry::CdrHght();
     fS2Z     = GetPadLength()*GetPadLength()/12.;
   }
-  fS2Y = fCov[0] +2.*fX*fCov[1] + fX*fX*fCov[2];
   return kTRUE;
 }
 
@@ -1736,9 +1819,9 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
     if ( fZref[i] != inTracklet->fZref[i] ) return kFALSE;
   }
   
-  if ( fS2Y != inTracklet->fS2Y ) return kFALSE;
-  if ( GetTilt() != inTracklet->GetTilt() ) return kFALSE;
-  if ( GetPadLength() != inTracklet->GetPadLength() ) return kFALSE;
+  if ( TMath::Abs(fS2Y - inTracklet->fS2Y)>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(GetTilt() - inTracklet->GetTilt())>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(GetPadLength() - inTracklet->GetPadLength())>1.e-10 ) return kFALSE;
   
   for (Int_t i = 0; i < kNclusters; i++){
 //     if ( fX[i] != inTracklet->GetX(i) ) return kFALSE;
@@ -1761,14 +1844,14 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
   //if ( fFreq != inTracklet->GetFreq() ) return kFALSE;
   //if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
    
-  if ( fC != inTracklet->fC ) return kFALSE;
+  if ( TMath::Abs(fC[0] - inTracklet->fC[0])>1.e-10 ) return kFALSE;
   //if ( fCC != inTracklet->GetCC() ) return kFALSE;
-  if ( fChi2 != inTracklet->fChi2 ) return kFALSE;
+  if ( TMath::Abs(fChi2 - inTracklet->fChi2)>1.e-10 ) return kFALSE;
   //  if ( fChi2Z != inTracklet->GetChi2Z() ) return kFALSE;
 
   if ( fDet != inTracklet->fDet ) return kFALSE;
-  if ( fPt != inTracklet->fPt ) return kFALSE;
-  if ( fdX != inTracklet->fdX ) return kFALSE;
+  if ( TMath::Abs(fPt - inTracklet->fPt)>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(fdX - inTracklet->fdX)>1.e-10 ) return kFALSE;
   
   for (Int_t iCluster = 0; iCluster < kNclusters; iCluster++){
     AliTRDcluster *curCluster = fClusters[iCluster];