All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KHitBase.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file KHitBase.h
4 ///
5 /// \brief Base class for Kalman filter measurement.
6 ///
7 /// \author H. Greenlee
8 ///
9 /// This class represents a general measurement on a surface.
10 ///
11 /// This class includes the following attribute.
12 ///
13 /// 1. Measurement surface.
14 /// 2. Measurement plane index.
15 /// 3. Prediction surface.
16 /// 4. Prediction distance.
17 /// 5. Unique id.
18 ///
19 /// Each constructor initializes the unique id to zero. Derived classes
20 /// may set the unique id if they wish (the unique id is protected).
21 ///
22 /// This class has the following pure virtual methods.
23 ///
24 /// 1. Prediction method, in which the predicted track object (state
25 /// vector + error matrix) is passed into the measurement to
26 /// generate a prediction in the measurement coordinate system.
27 ///
28 /// 2. Accessor for incremental chisquare.
29 ///
30 /// 3. Update method, in which the track object is passed in and is
31 /// updated according to the Kalman updating formula.
32 ///
33 /// This class does not include in its interface anything having to do
34 /// with concrete measurements, predictions, or residuals, or anything
35 /// with a variable dimension.
36 ///
37 /// This class has two surface data members. Member fMeasSurf is the
38 /// idealized measurement surface, which is set on construction and
39 /// never changes. Member fPredSurf is used to remember the track
40 /// surface used to make a prediction. It is updated (by derived
41 /// class) every time method predict is called.
42 ///
43 /// As with KTrack, the surface attributes are polymorphic, and is held
44 /// via std::shared_ptr type of smart pointer, which handles memory
45 /// management using reference-counted shared ownership.
46 ///
47 ////////////////////////////////////////////////////////////////////////
48 
49 #ifndef KHITBASE_H
50 #define KHITBASE_H
51 
52 #include <iosfwd>
53 #include <memory>
54 
57 
58 namespace trkf {
59 
60  class Propagator;
61 
62  class KHitBase {
63  public:
64  /// Default constructor.
65  KHitBase();
66 
67  /// Initializing Constructor.
68  KHitBase(const std::shared_ptr<const Surface>& psurf, int plane = -1);
69 
70  /// Destructor.
71  virtual ~KHitBase() = default;
72 
73  // Accessors.
74 
75  /// Predition surface.
76  const std::shared_ptr<const Surface>&
78  {
79  return fPredSurf;
80  }
81 
82  /// Prediction distance.
83  double
85  {
86  return fPredDist;
87  }
88 
89  /// Measurement surface.
90  const std::shared_ptr<const Surface>&
92  {
93  return fMeasSurf;
94  }
95 
96  /// Measurement plane index.
97  int
98  getMeasPlane() const
99  {
100  return fMeasPlane;
101  }
102 
103  /// Unique id.
104  int
105  getID() const
106  {
107  return fID;
108  }
109 
110  // Modifiers.
111 
112  /// Measurement surface.
113  void
114  setMeasSurface(const std::shared_ptr<const Surface>& psurf)
115  {
116  fMeasSurf = psurf;
117  }
118 
119  /// Measurement plane.
120  void
121  setMeasPlane(int plane)
122  {
123  fMeasPlane = plane;
124  }
125 
126  // Pure virtual methods.
127 
128  /// Prediction method (return false if fail).
129  virtual bool predict(const KETrack& tre,
130  const Propagator& prop,
131  const KTrack* ref = 0) const = 0;
132 
133  /// Return incremental chisquare.
134  virtual double getChisq() const = 0;
135 
136  /// Update track method.
137  virtual void update(KETrack& tre) const = 0;
138 
139  /// Printout
140  virtual std::ostream& Print(std::ostream& out, bool doTitle = true) const;
141 
142  // Attributes.
143 
144  protected:
145  mutable std::shared_ptr<const Surface> fPredSurf; ///< Prediction surface.
146  mutable double fPredDist; ///< Prediction distance.
147  int fID; ///< Unique id.
148 
149  private:
150  std::shared_ptr<const Surface> fMeasSurf; ///< Measurement surface.
151  int fMeasPlane; ///< Measurement plane index.
152  };
153 
154  /// Output operator.
155  std::ostream& operator<<(std::ostream& out, const KHitBase& trk);
156 }
157 
158 #endif
void setMeasSurface(const std::shared_ptr< const Surface > &psurf)
Measurement surface.
Definition: KHitBase.h:114
virtual double getChisq() const =0
Return incremental chisquare.
virtual void update(KETrack &tre) const =0
Update track method.
double getPredDistance() const
Prediction distance.
Definition: KHitBase.h:84
int getMeasPlane() const
Measurement plane index.
Definition: KHitBase.h:98
std::shared_ptr< const Surface > fMeasSurf
Measurement surface.
Definition: KHitBase.h:150
int getID() const
Unique id.
Definition: KHitBase.h:105
virtual bool predict(const KETrack &tre, const Propagator &prop, const KTrack *ref=0) const =0
Prediction method (return false if fail).
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
Definition: KHitBase.cxx:32
virtual ~KHitBase()=default
Destructor.
std::shared_ptr< const Surface > fPredSurf
Prediction surface.
Definition: KHitBase.h:145
std::ostream & operator<<(std::ostream &out, const KGTrack &trg)
Output operator.
Definition: KGTrack.cxx:309
KHitBase()
Default constructor.
Definition: KHitBase.cxx:18
int fID
Unique id.
Definition: KHitBase.h:147
double fPredDist
Prediction distance.
Definition: KHitBase.h:146
int fMeasPlane
Measurement plane index.
Definition: KHitBase.h:151
void setMeasPlane(int plane)
Measurement plane.
Definition: KHitBase.h:121
Basic Kalman filter track class, with error.
const std::shared_ptr< const Surface > & getMeasSurface() const
Measurement surface.
Definition: KHitBase.h:91
const std::shared_ptr< const Surface > & getPredSurface() const
Predition surface.
Definition: KHitBase.h:77