00001 // $Id: KalmanFilter.h,v 1.3 2005/05/25 09:29:22 hernando Exp $ 00002 #ifndef KALMANFILTER_H 00003 #define KALMANFILTER_H 1 00004 00005 // Include files 00006 // from Gaudi 00007 #include "GaudiAlg/GaudiTool.h" 00008 #include "Event/Track.h" 00009 #include "Event/FitNode.h" 00010 00011 #include "TrackInterfaces/ITrackExtrapolator.h" 00012 #include "TrackInterfaces/ITrackProjector.h" 00013 #include "TrackInterfaces/ITrackFitter.h" 00014 00025 class KalmanFilter : public GaudiTool, public ITrackFitter { 00026 public: 00028 KalmanFilter( const std::string& type, 00029 const std::string& name, 00030 const IInterface* parent); 00031 00033 virtual ~KalmanFilter( ); 00034 00035 StatusCode initialize(); 00036 00038 StatusCode fit(Track& track){ 00039 info() << " not implemented yet!" << track.nMeasurements() << endreq; 00040 return StatusCode::SUCCESS; 00041 } 00042 00044 StatusCode fit(Track& track, const State& seed); 00045 00047 StatusCode filter(Track& track, const State& seed); 00048 00050 StatusCode filter(State& state, Measurement& meas); 00051 00052 protected: 00053 00055 StatusCode iniKalman(Track& track); 00056 00058 StatusCode predict(FitNode& node, State& state); 00059 00061 StatusCode filter(FitNode& node); 00062 00064 StatusCode smoother(Track& track); 00065 00067 StatusCode smooth(FitNode& node0, FitNode& node1); 00068 00070 void computeChiSq(Track& track); 00071 00072 protected: 00073 00075 StatusCode failure(const std::string& comment); 00076 00077 // ! check that the contents of the cov matrix are fine 00078 StatusCode checkInvertMatrix(HepSymMatrix& mat); 00079 00080 // ! check that the contents of the cov matrix are fine 00081 StatusCode checkPositiveMatrix(HepSymMatrix& mat); 00082 00083 // ! invert this matrix 00084 StatusCode invertMatrix(HepSymMatrix& mat); 00085 00087 StatusCode cToG3(HepSymMatrix& C); 00088 00090 StatusCode cToG4(HepSymMatrix& invC); 00091 00092 protected: 00093 00095 State* m_state; 00096 00097 // internal copy of the nodes of the track (track owns them) 00098 std::vector<FitNode*> m_nodes; 00099 00100 // internal copy of the gain matrix in the filter of a state 00101 HepVector m_K; 00102 00103 protected: 00104 00106 ITrackExtrapolator* m_extrapolator; 00107 00109 ITrackProjector* m_projector; 00110 00112 std::string m_extrapolatorName; 00113 00115 std::string m_projectorName; 00116 00117 }; 00118 #endif // KALMANFILTER_H