]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCATrackParam.cxx
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATrackParam.cxx
index 53340d34b0f4bff07ebd3bf2c6e403ed113d1250..93694dc923885fe4d2442ec8fdd94e0a1b5d3c0d 100644 (file)
@@ -27,7 +27,7 @@
 // Circle in XY:
 //
 // kCLight = 0.000299792458;
-// Kappa = Bz*kCLight*QPt;
+// Kappa = -Bz*kCLight*QPt;
 // R  = 1/TMath::Abs(Kappa);
 // Xc = X - sin(Phi)/Kappa;
 // Yc = Y + cos(Phi)/Kappa;
@@ -111,7 +111,7 @@ GPUd() bool  AliHLTTPCCATrackParam::TransportToX( float x, AliHLTTPCCATrackLinea
 
   float ex = t0.CosPhi();
   float ey = t0.SinPhi();
-  float k   = t0.QPt() * Bz;
+  float k  =-t0.QPt() * Bz;
   float dx = x - X();
 
   float ey1 = k * dx + ey;
@@ -150,9 +150,9 @@ GPUd() bool  AliHLTTPCCATrackParam::TransportToX( float x, AliHLTTPCCATrackLinea
 
   float d[5] = { 0,
                  0,
-                 fP[2] - t0.SinPhi(),
-                 fP[3] - t0.DzDs(),
-                 fP[4] - t0.QPt()
+                 GetPar(2) - t0.SinPhi(),
+                 GetPar(3) - t0.DzDs(),
+                 GetPar(4) - t0.QPt()
                };
 
   //float H0[5] = { 1,0, h2,  0, h4 };
@@ -162,16 +162,16 @@ GPUd() bool  AliHLTTPCCATrackParam::TransportToX( float x, AliHLTTPCCATrackLinea
   //float H4[5] = { 0, 0, 0,  0,  1 };
 
   float h2 = dx * ( 1 + ey * ey1 + ex * ex1 ) * exi * ex1i * cci;
-  float h4 = dx2 * ( cc + ss * ey1 * ex1i ) * cci * cci * Bz;
-  float dxBz = dx * Bz;
+  float h4 = dx2 * ( cc + ss * ey1 * ex1i ) * cci * cci * (-Bz);
+  float dxBz = dx * (-Bz);
 
   t0.SetCosPhi( ex1 );
   t0.SetSinPhi( ey1 );
 
-  fX    = X() + dx;
-  fP[0] = Y() + dy     + h2 * d[2]           +   h4 * d[4];
-  fP[1] = Z() + dz               + dS * d[3];
-  fP[2] = t0.SinPhi() +     d[2]           + dxBz * d[4];
+  SetX(X() + dx);
+  SetPar(0, Y() + dy     + h2 * d[2]           +   h4 * d[4]);
+  SetPar(1, Z() + dz               + dS * d[3]);
+  SetPar(2, t0.SinPhi() +     d[2]           + dxBz * d[4]);
 
   float c00 = fC[0];
   float c10 = fC[1];
@@ -230,7 +230,7 @@ GPUd() bool  AliHLTTPCCATrackParam::TransportToX( float x, float sinPhi0, float
   if ( CAMath::Abs( ex ) < 1.e-4 ) return 0;
   float exi = 1. / ex;
 
-  float dxBz = dx * Bz;
+  float dxBz = dx * (-Bz);
   float dS = dx * exi;
   float h2 = dS * exi * exi;
   float h4 = .5 * h2 * dxBz;
@@ -244,10 +244,10 @@ GPUd() bool  AliHLTTPCCATrackParam::TransportToX( float x, float sinPhi0, float
   float sinPhi = SinPhi() + dxBz * QPt();
   if ( maxSinPhi > 0 && CAMath::Abs( sinPhi ) > maxSinPhi ) return 0;
 
-  fX    = X() + dx;
-  fP[0] += dS * ey + h2 * ( SinPhi() - ey )  +   h4 * QPt();
-  fP[1] += dS * DzDs();
-  fP[2] = sinPhi;
+  SetX(X() + dx);
+  SetPar(0, GetPar(0) + dS * ey + h2 * ( SinPhi() - ey )  +   h4 * QPt());
+  SetPar(1, GetPar(1) + dS * DzDs());
+  SetPar(2, sinPhi);
 
 
   float c00 = fC[0];
@@ -378,8 +378,8 @@ float AliHLTTPCCATrackParam::BetheBlochGeant( float bg2,
 
   //*** Density effect
   float d2 = 0.;
-  const float x = 0.5 * TMath::Log( bg2 );
-  const float lhwI = TMath::Log( 28.816 * 1e-9 * TMath::Sqrt( rho * mZA ) / mI );
+  const float x = 0.5 * AliHLTTPCCAMath::Log( bg2 );
+  const float lhwI = AliHLTTPCCAMath::Log( 28.816 * 1e-9 * AliHLTTPCCAMath::Sqrt( rho * mZA ) / mI );
   if ( x > x1 ) {
     d2 = lhwI + x - 0.5;
   } else if ( x > x0 ) {
@@ -387,7 +387,7 @@ float AliHLTTPCCATrackParam::BetheBlochGeant( float bg2,
     d2 = lhwI + x - 0.5 + ( 0.5 - lhwI - x0 ) * r * r * r;
   }
 
-  return mK*mZA*( 1 + bg2 ) / bg2*( 0.5*TMath::Log( 2*me*bg2*maxT / ( mI*mI ) ) - bg2 / ( 1 + bg2 ) - d2 );
+  return mK*mZA*( 1 + bg2 ) / bg2*( 0.5*AliHLTTPCCAMath::Log( 2*me*bg2*maxT / ( mI*mI ) ) - bg2 / ( 1 + bg2 ) - d2 );
 }
 
 float AliHLTTPCCATrackParam::BetheBlochSolid( float bg )
@@ -442,8 +442,11 @@ GPUd() void AliHLTTPCCATrackParam::CalculateFitParameters( AliHLTTPCCATrackFitPa
 {
   //*!
 
-  float p2 = ( 1. + fP[3] * fP[3] );
-  float k2 = fP[4] * fP[4];
+  float qpt = GetPar(4);
+  if( fC[14]>=1. ) qpt = 1./0.35;
+
+  float p2 = ( 1. + GetPar(3) * GetPar(3) );
+  float k2 = qpt * qpt;
   float mass2 = mass * mass;
   float beta2 = p2 / ( p2 + mass2 * k2 );
 
@@ -458,13 +461,13 @@ GPUd() void AliHLTTPCCATrackParam::CalculateFitParameters( AliHLTTPCCATrackFitPa
   // Approximate energy loss fluctuation (M.Ivanov)
 
   const float knst = 0.07; // To be tuned.
-  par.fSigmadE2 = knst * par.fEP2 * fP[4];
+  par.fSigmadE2 = knst * par.fEP2 * qpt;
   par.fSigmadE2 = par.fSigmadE2 * par.fSigmadE2;
 
-  par.fK22 = ( 1. + fP[3] * fP[3] );
+  par.fK22 = ( 1. + GetPar(3) * GetPar(3) );
   par.fK33 = par.fK22 * par.fK22;
-  par.fK43 = fP[3] * fP[4] * par.fK22;
-  par.fK44 = fP[3] * fP[3] * fP[4] * fP[4];
+  par.fK43 = 0;
+  par.fK44 = GetPar(3) * GetPar(3) * k2;
 
 }
 
@@ -492,7 +495,7 @@ GPUd() bool AliHLTTPCCATrackParam::CorrectForMeanMaterial( float xOverX0,  float
   float corr = ( 1. - par.fEP2 * dE );
   if ( corr < 0.3 || corr > 1.3 ) return 0;
 
-  fP[4] *= corr;
+  SetPar(4, GetPar(4) * corr);
   fC40 *= corr;
   fC41 *= corr;
   fC42 *= corr;
@@ -503,7 +506,7 @@ GPUd() bool AliHLTTPCCATrackParam::CorrectForMeanMaterial( float xOverX0,  float
   //Multiple scattering******************
 
   float theta2 = par.fTheta2 * CAMath::Abs( xOverX0 );
-  fC22 += theta2 * par.fK22 * ( 1. - fP[2] * fP[2] );
+  fC22 += theta2 * par.fK22 * ( 1. - GetPar(2) * GetPar(2) );
   fC33 += theta2 * par.fK33;
   fC43 += theta2 * par.fK43;
   fC44 += theta2 * par.fK44;
@@ -619,8 +622,8 @@ GPUd() bool AliHLTTPCCATrackParam::Filter( float y, float z, float err2Y, float
   err2Z += c11;
 
   float
-  z0 = y - fP[0],
-       z1 = z - fP[1];
+  z0 = y - GetPar(0),
+       z1 = z - GetPar(1);
 
   if ( err2Y < 1.e-8 || err2Z < 1.e-8 ) return 0;
 
@@ -638,18 +641,18 @@ GPUd() bool AliHLTTPCCATrackParam::Filter( float y, float z, float err2Y, float
   k11 = c11 * mS2;
   k31 = c31 * mS2;
 
-  float sinPhi = fP[2] + k20 * z0  ;
+  float sinPhi = GetPar(2) + k20 * z0  ;
 
   if ( maxSinPhi > 0 && CAMath::Abs( sinPhi ) >= maxSinPhi ) return 0;
 
   fNDF  += 2;
   fChi2 += mS0 * z0 * z0 + mS2 * z1 * z1 ;
 
-  fP[ 0] += k00 * z0 ;
-  fP[ 1] += k11 * z1 ;
-  fP[ 2] = sinPhi ;
-  fP[ 3] += k31 * z1 ;
-  fP[ 4] += k40 * z0 ;
+  SetPar(0, GetPar(0) + k00 * z0);
+  SetPar(1, GetPar(1) + k11 * z1);
+  SetPar(2, sinPhi);
+  SetPar(3, GetPar(3) + k31 * z1);
+  SetPar(4, GetPar(4) + k40 * z0);
 
   fC[ 0] -= k00 * c00 ;
   fC[ 3] -= k20 * c00 ;
@@ -669,18 +672,32 @@ GPUd() bool AliHLTTPCCATrackParam::CheckNumericalQuality() const
 {
   //* Check that the track parameters and covariance matrix are reasonable
 
-  bool ok = finite( fX ) && finite( fSignCosPhi ) && finite( fChi2 ) && finite( fNDF );
+  bool ok = AliHLTTPCCAMath::Finite( GetX() ) && AliHLTTPCCAMath::Finite( fSignCosPhi ) && AliHLTTPCCAMath::Finite( fChi2 ) && AliHLTTPCCAMath::Finite( fNDF );
 
   const float *c = Cov();
-  for ( int i = 0; i < 15; i++ ) ok = ok && finite( c[i] );
-  for ( int i = 0; i < 5; i++ ) ok = ok && finite( Par()[i] );
+  for ( int i = 0; i < 15; i++ ) ok = ok && AliHLTTPCCAMath::Finite( c[i] );
+  for ( int i = 0; i < 5; i++ ) ok = ok && AliHLTTPCCAMath::Finite( Par()[i] );
 
   if ( c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0 ) ok = 0;
-  if ( c[0] > 5. || c[2] > 5. || c[5] > 2. || c[9] > 2 || c[14] > 2. ) ok = 0;
+  if ( c[0] > 5. || c[2] > 5. || c[5] > 2. || c[9] > 2 
+       //|| ( CAMath::Abs( QPt() ) > 1.e-2 && c[14] > 2. ) 
+       ) ok = 0;
 
   if ( CAMath::Abs( SinPhi() ) > .99 ) ok = 0;
   if ( CAMath::Abs( QPt() ) > 1. / 0.05 ) ok = 0;
-
+  if( ok ){
+    ok = ok 
+      && ( c[1]*c[1]<=c[2]*c[0] )
+      && ( c[3]*c[3]<=c[5]*c[0] )
+      && ( c[4]*c[4]<=c[5]*c[2] )
+      && ( c[6]*c[6]<=c[9]*c[0] )
+      && ( c[7]*c[7]<=c[9]*c[2] )
+      && ( c[8]*c[8]<=c[9]*c[5] )
+      && ( c[10]*c[10]<=c[14]*c[0] )
+      && ( c[11]*c[11]<=c[14]*c[2] )
+      && ( c[12]*c[12]<=c[14]*c[5] )
+      && ( c[13]*c[13]<=c[14]*c[9] );      
+  }
   return ok;
 }