All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KHitMulti.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file KHitMulti.h
4 ///
5 /// \brief Compound Kalman Filter measurement.
6 ///
7 /// \author H. Greenlee
8 ///
9 /// This class allows a collection of Kalman Filter measurements to
10 /// function as a single measurement. This class inherits from
11 /// KHitBase and fulfills the KHitBase interface. The following
12 /// attributes are owned by base class KHitBase.
13 ///
14 /// 1. Measurement surface.
15 /// 2. Prediction surface.
16 ///
17 /// This class adds the following attributes of its own.
18 ///
19 /// 1. A collection of underlying measurements.
20 /// 2. Measurement vector.
21 /// 3. Measurement error matrix.
22 /// 4. Prediction vector.
23 /// 5. Prediction error matrix.
24 /// 6. Residual vector.
25 /// 7. Residual error matrix.
26 /// 8. Inverse of residual error matrix.
27 /// 9. Kalman H-matrix.
28 /// 10. Incremental chisquare.
29 ///
30 /// The only supported kind of underlying measurement is KHit<1> (more
31 /// types could be added if needed). The dimension of the measurement
32 /// space is dynamic (potentially large) and specified at run time.
33 ///
34 /// The measurement vector, measurement error matrix, prediction
35 /// vector, and H-matrix are simply the concatenation of the
36 /// corressponding quantities from the underlying measurements. The
37 /// measurement error matrix is block-diagonal with no correlation
38 /// between the underlying measurements. The prediction error matrix
39 /// is calculated from the error matrix of the track hypothesis and
40 /// the full H-matrix (there will be correlations between
41 /// measurements). Residuals and chisquare are calculated in the
42 /// usual way.
43 ///
44 ////////////////////////////////////////////////////////////////////////
45 
46 #ifndef KHITMULTI_H
47 #define KHITMULTI_H
48 
50 
51 namespace trkf {
52 
53  class KHitMulti : public KHitBase {
54  public:
55  /// Default constructor.
56  KHitMulti();
57 
58  /// Initializing Constructor -- measurement surface only.
59  KHitMulti(const std::shared_ptr<const Surface>& psurf);
60 
61  /// Destructor.
62  virtual ~KHitMulti();
63 
64  // Accessors.
65 
66  /// Measurement space dimension.
67  int
68  getMeasDim() const
69  {
70  return fMeasDim;
71  }
72 
73  /// Measurement collection.
74  const std::vector<std::shared_ptr<const KHit<1>>>&
75  getMeasVec() const
76  {
77  return fMeasVec;
78  }
79 
80  /// Measurement vector.
81  const ublas::vector<double>&
82  getMeasVector() const
83  {
84  return fMvec;
85  }
86 
87  /// Measurement error matrix.
88  const ublas::symmetric_matrix<double>&
89  getMeasError() const
90  {
91  return fMerr;
92  }
93 
94  /// Prediction vector.
95  const ublas::vector<double>&
96  getPredVector() const
97  {
98  return fPvec;
99  }
100 
101  /// Prediction matrix.
102  const ublas::symmetric_matrix<double>&
103  getPredError() const
104  {
105  return fPerr;
106  }
107 
108  /// Residual vector.
109  const ublas::vector<double>&
110  getResVector() const
111  {
112  return fRvec;
113  }
114 
115  /// Residual error matrix.
116  const ublas::symmetric_matrix<double>&
117  getResError() const
118  {
119  return fRerr;
120  }
121 
122  /// Residual inv. error matrix.
123  const ublas::symmetric_matrix<double>&
125  {
126  return fRinv;
127  }
128 
129  /// Kalman H-matrix.
130  const ublas::matrix<double>&
131  getH() const
132  {
133  return fH;
134  }
135 
136  /// Incremental chisquare.
137  double
138  getChisq() const
139  {
140  return fChisq;
141  }
142 
143  // Modifiers.
144 
145  /// Add a measurement of unknown type.
146  void addMeas(const std::shared_ptr<const KHitBase>& pmeas);
147 
148  /// Add a one-dimensional measurement.
149  void addMeas(const std::shared_ptr<const KHit<1>>& pmeas);
150 
151  // Overrides.
152 
153  /// Prediction method (return false if fail).
154  bool predict(const KETrack& tre, const Propagator& prop, const KTrack* ref = 0) const;
155 
156  /// Update track method.
157  void update(KETrack& tre) const;
158 
159  /// Printout
160  virtual std::ostream& Print(std::ostream& out, bool doTitle = true) const;
161 
162  private:
163  // Attributes.
164 
165  int fMeasDim; ///< Measurement space dimension.
166  std::vector<std::shared_ptr<const KHit<1>>> fMeasVec; ///< Underlying measurements.
167  mutable ublas::vector<double> fMvec; ///< Measurement vector.
168  mutable ublas::symmetric_matrix<double> fMerr; ///< Measurement error matrix.
169  mutable ublas::vector<double> fPvec; ///< Prediction vector.
170  mutable ublas::symmetric_matrix<double> fPerr; ///< Prediction error matrix.
171  mutable ublas::vector<double> fRvec; ///< Residual vector.
172  mutable ublas::symmetric_matrix<double> fRerr; ///< Residual error matrix.
173  mutable ublas::symmetric_matrix<double> fRinv; ///< Residual inverse error matrix.
174  mutable ublas::matrix<double> fH; ///< Kalman H-matrix.
175  mutable double fChisq; ///< Incremental chisquare.
176  };
177 }
178 
179 #endif
ublas::vector< double > fPvec
Prediction vector.
Definition: KHitMulti.h:169
const ublas::symmetric_matrix< double > & getResError() const
Residual error matrix.
Definition: KHitMulti.h:117
int getMeasDim() const
Measurement space dimension.
Definition: KHitMulti.h:68
const ublas::symmetric_matrix< double > & getPredError() const
Prediction matrix.
Definition: KHitMulti.h:103
const ublas::symmetric_matrix< double > & getMeasError() const
Measurement error matrix.
Definition: KHitMulti.h:89
const ublas::matrix< double > & getH() const
Kalman H-matrix.
Definition: KHitMulti.h:131
std::vector< std::shared_ptr< const KHit< 1 > > > fMeasVec
Underlying measurements.
Definition: KHitMulti.h:166
const ublas::vector< double > & getMeasVector() const
Measurement vector.
Definition: KHitMulti.h:82
Kalman filter measurement class template.
const std::vector< std::shared_ptr< const KHit< 1 > > > & getMeasVec() const
Measurement collection.
Definition: KHitMulti.h:75
void addMeas(const std::shared_ptr< const KHitBase > &pmeas)
Add a measurement of unknown type.
Definition: KHitMulti.cxx:42
ublas::symmetric_matrix< double > fRinv
Residual inverse error matrix.
Definition: KHitMulti.h:173
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
Definition: KHitMulti.cxx:245
KHitMulti()
Default constructor.
Definition: KHitMulti.cxx:17
ublas::symmetric_matrix< double > fPerr
Prediction error matrix.
Definition: KHitMulti.h:170
ublas::vector< double > fRvec
Residual vector.
Definition: KHitMulti.h:171
bool predict(const KETrack &tre, const Propagator &prop, const KTrack *ref=0) const
Prediction method (return false if fail).
Definition: KHitMulti.cxx:95
ublas::matrix< double > fH
Kalman H-matrix.
Definition: KHitMulti.h:174
ublas::symmetric_matrix< double > fRerr
Residual error matrix.
Definition: KHitMulti.h:172
ublas::symmetric_matrix< double > fMerr
Measurement error matrix.
Definition: KHitMulti.h:168
double getChisq() const
Incremental chisquare.
Definition: KHitMulti.h:138
void update(KETrack &tre) const
Update track method.
Definition: KHitMulti.cxx:202
double fChisq
Incremental chisquare.
Definition: KHitMulti.h:175
const ublas::vector< double > & getResVector() const
Residual vector.
Definition: KHitMulti.h:110
ublas::vector< double > fMvec
Measurement vector.
Definition: KHitMulti.h:167
const ublas::vector< double > & getPredVector() const
Prediction vector.
Definition: KHitMulti.h:96
virtual ~KHitMulti()
Destructor.
Definition: KHitMulti.cxx:30
int fMeasDim
Measurement space dimension.
Definition: KHitMulti.h:165
const ublas::symmetric_matrix< double > & getResInvError() const
Residual inv. error matrix.
Definition: KHitMulti.h:124