SurfPlane.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SurfPlane.cxx
4 ///
5 /// \brief Base class for Kalman filter planar surfaces.
6 ///
7 /// \author H. Greenlee
8 ///
9 ////////////////////////////////////////////////////////////////////////
10 
11 #include <cmath>
13 
14 namespace trkf {
15 
16  /// Default constructor.
18  {}
19 
20  /// Destructor.
22  {}
23 
24  /// Get pointing error of track.
25  ///
26  /// Arguments:
27  ///
28  /// vec - Track parameters.
29  /// err - Track error matrix.
30  ///
31  /// Returns: Pointing error.
32  ///
33  /// This method calculates the track pointing error based on the
34  /// slope track paramers and errors (parameters 2 and 3).
35  ///
36  double SurfPlane::PointingError(const TrackVector& vec, const TrackError& err) const
37  {
38  // Get slope parameters and error matrix.
39 
40  double xp = vec(2);
41  double yp = vec(3);
42  double exx = err(2, 2);
43  double eyy = err(3, 3);
44  double exy = err(3, 2);
45 
46  // Calculate error matrix of pointing unit vector in some coordinate system.
47 
48  double den = 1. + xp*xp + yp*yp;
49  double den3 = den*den*den;
50 
51  double vxx = ( (1.+yp*yp)*(1.+yp*yp) * exx + xp*xp*yp*yp * eyy
52  - 2.*xp*yp*(1. + yp*yp) * exy ) / den3;
53  double vyy = ( xp*xp*yp*yp * exx + (1.+xp*xp)*(1.+xp*xp) * eyy
54  - 2.*xp*yp*(1. + xp*xp) * exy ) / den3;
55  double vzz = ( xp*xp * exx + yp*yp * eyy + 2.*xp*yp * exy ) / den3;
56 
57  double vxy = ( -xp*yp*(1. + yp*yp) * exx - xp*yp*(1. + xp*xp) * eyy
58  + (1. + xp*xp + yp*yp + 2.*xp*xp*yp*yp) * exy ) / den3;
59  double vyz = ( xp*xp*yp * exx - yp*(1. + xp*xp) * eyy - xp*(1. + xp*xp - yp*yp) * exy ) / den3;
60  double vxz = ( -xp*(1. + yp*yp) * exx + xp*yp*yp * eyy - yp*(1. - xp*xp + yp*yp) * exy ) / den3;
61 
62  // Calculate square root of the largest eigenvalue of error matrix.
63 
64  double ddd2 = vxx*vxx + vyy*vyy + vzz*vzz
65  - 2.*vxx*vyy - 2.*vxx*vzz - 2.*vyy*vzz
66  + 4.*vxy*vxy + 4.*vyz*vyz + 4.*vxz*vxz;
67  double ddd = sqrt(ddd2 > 0. ? ddd2 : 0.);
68  double lambda2 = 0.5 * ( vxx + vyy + vzz + ddd);
69  double lambda = sqrt(lambda2 > 0. ? lambda2 : 0.);
70 
71  return lambda;
72  }
73 
74  /// Get starting error matrix for Kalman filter.
75  ///
76  /// Arguments:
77  ///
78  /// err - Error matrix.
79  ///
81  err.resize(5, false);
82  err.clear();
83  err(0, 0) = 1000.;
84  err(1, 1) = 1000.;
85  err(2, 2) = 0.25;
86  err(3, 3) = 0.25;
87  err(4, 4) = 10.;
88  }
89 
90 } // end namespace trkf
void getStartingError(TrackError &err) const
Get starting error matrix for Kalman filter.
Definition: SurfPlane.cxx:80
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
SurfPlane()
Default constructor.
Definition: SurfPlane.cxx:17
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
void err(const char *fmt,...)
Definition: message.cpp:226
double PointingError(const TrackVector &vec, const TrackError &err) const
Get pointing error of track.
Definition: SurfPlane.cxx:36
Base class for Kalman filter planar surfaces.
virtual ~SurfPlane()
Destructor.
Definition: SurfPlane.cxx:21