SurfLine.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SurfLine.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 SurfLine::PointingError(const TrackVector& vec, const TrackError& err) const
37  {
38  // Get slope parameters and error matrix.
39 
40  double phi = vec(2);
41  double eta = vec(3);
42  double epp = err(2, 2); // sigma^2(phi,phi)
43  double ehh = err(3, 3); // sigma^2(eta,eta)
44  double ehp = err(3, 2); // sigma^2(eta,phi)
45 
46  // Calculate error matrix of pointing unit vector in some coordinate system.
47 
48  double sh = 1./std::cosh(eta); // sech(eta)
49  double sh2 = sh*sh;
50  double sh3 = sh*sh2;
51  double sh4 = sh*sh3;
52 
53  double th = std::tanh(eta);
54  double th2 = th*th;
55 
56  double cphi = std::cos(phi);
57  double cphi2 = cphi*cphi;
58 
59  double sphi = std::sin(phi);
60  double sphi2 = sphi*sphi;
61 
62  double vxx = sh2*th2*cphi2 * ehh + sh2*sphi2 * epp + 2.*sh2*th*sphi*cphi * ehp;
63  double vyy = sh2*th2*sphi2 * ehh + sh2*cphi2 * epp - 2.*sh2*th*sphi*cphi * ehp;
64  double vzz = sh4 * epp;
65 
66  double vxy = sh2*th2*sphi*cphi * ehh - sh2*sphi*cphi * epp - sh2*th*(cphi2-sphi2) * ehp;
67  double vyz = -sh3*th*sphi * ehh + sh3*cphi * ehp;
68  double vxz = -sh3*th*cphi * ehh - sh3*sphi * ehp;
69 
70  // For debugging. The determinant of the error matrix should be zero.
71 
72  // double det = vxx*vyy*vzz + 2.*vxy*vyz*vxz - vxx*vyz*vyz - vyy*vxz*vxz - vzz*vxy*vxy;
73 
74  // Calculate square root of the largest eigenvalue of error matrix.
75 
76  double ddd2 = vxx*vxx + vyy*vyy + vzz*vzz
77  - 2.*vxx*vyy - 2.*vxx*vzz - 2.*vyy*vzz
78  + 4.*vxy*vxy + 4.*vyz*vyz + 4.*vxz*vxz;
79  double ddd = sqrt(ddd2 > 0. ? ddd2 : 0.);
80  double lambda2 = 0.5 * ( vxx + vyy + vzz + ddd);
81  double lambda = sqrt(lambda2 > 0. ? lambda2 : 0.);
82 
83  return lambda;
84  }
85 
86  /// Get starting error matrix for Kalman filter.
87  ///
88  /// Arguments:
89  ///
90  /// err - Error matrix.
91  ///
93  err.resize(5, false);
94  err.clear();
95  err(0, 0) = 1000.;
96  err(1, 1) = 1000.;
97  err(2, 2) = 10.;
98  err(3, 3) = 10.;
99  err(4, 4) = 10.;
100  }
101 
102 } // end namespace trkf
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
void getStartingError(TrackError &err) const
Get starting error matrix for Kalman filter.
Definition: SurfLine.cxx:92
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
double PointingError(const TrackVector &vec, const TrackError &err) const
Get pointing error of track.
Definition: SurfLine.cxx:36
void err(const char *fmt,...)
Definition: message.cpp:226
Base class for Kalman filter line surfaces.
SurfLine()
Default constructor.
Definition: SurfLine.cxx:17
virtual ~SurfLine()
Destructor.
Definition: SurfLine.cxx:21