LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::KFTrackState Class Reference

Extension of a TrackState to perform KalmanFilter calculations. More...

#include "KFTrackState.h"

Public Member Functions

 KFTrackState (const SVector5 &trackStatePar, const SMatrixSym55 &trackStateCov, const Plane &plane, bool trackAlongPlaneDir, int pid)
 
 KFTrackState (TrackState &&trackState)
 
bool updateWithHitState (const HitState &hitstate)
 Update the TrackState given a HitState (they need to be on the same plane) More...
 
bool combineWithTrackState (const TrackState &trackstate)
 Combine the TrackState given another TrackState (they need to be on the same plane) More...
 
const TrackStatetrackState () const
 Get the (const reference to the) TrackState. More...
 
void setTrackState (TrackState &&s)
 Set the TrackState. More...
 
std::ostream & dump (std::ostream &out=std::cout) const
 Printout information. More...
 
const SVector5parameters () const
 This function calls the homonymous function of the stored TrackState. More...
 
const SMatrixSym55covariance () const
 This function calls the homonymous function of the stored TrackState. More...
 
const Planeplane () const
 This function calls the homonymous function of the stored TrackState. More...
 
const Point_tposition () const
 This function calls the homonymous function of the stored TrackState. More...
 
const Vector_tmomentum () const
 This function calls the homonymous function of the stored TrackState. More...
 
int pID () const
 This function calls the homonymous function of the stored TrackState. More...
 
double mass () const
 This function calls the homonymous function of the stored TrackState. More...
 
const SVector6 parameters6D () const
 This function calls the homonymous function of the stored TrackState. More...
 
bool isTrackAlongPlaneDir () const
 This function calls the homonymous function of the stored TrackState. More...
 
double residual (const HitState &hitstate) const
 This function calls the homonymous function of the stored TrackState. More...
 
double combinedError2 (const HitState &hitstate) const
 This function calls the homonymous function of the stored TrackState. More...
 
double combinedError (const HitState &hitstate) const
 This function calls the homonymous function of the stored TrackState. More...
 
double chi2 (const HitState &hitstate) const
 This function calls the homonymous function of the stored TrackState. More...
 
void setCovariance (const SMatrixSym55 &trackStateCov)
 This function calls the homonymous function of the stored TrackState. More...
 
void setParameters (const SVector5 &trackStatePar)
 This function calls the homonymous function of the stored TrackState. More...
 

Private Attributes

TrackState fTrackState
 

Detailed Description

Extension of a TrackState to perform KalmanFilter calculations.

Author
G. Cerati (FNAL, MicroBooNE)
Date
2017
Version
1.0

This class extends the concept of TrackState, providing functionalities for Kalman Filter-specific calculations such as 'update' and 'combine'. It holds a TrackState by value, which is modified in place when updating or combining.

Definition at line 21 of file KFTrackState.h.

Constructor & Destructor Documentation

trkf::KFTrackState::KFTrackState ( const SVector5 trackStatePar,
const SMatrixSym55 trackStateCov,
const Plane plane,
bool  trackAlongPlaneDir,
int  pid 
)
inline

Definition at line 24 of file KFTrackState.h.

29  : fTrackState(trackStatePar, trackStateCov, plane, trackAlongPlaneDir, pid)
30  {}
TrackState fTrackState
Definition: KFTrackState.h:85
const Plane & plane() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:48
trkf::KFTrackState::KFTrackState ( TrackState &&  trackState)
inline

Definition at line 31 of file KFTrackState.h.

References combineWithTrackState(), and updateWithHitState().

31 : fTrackState(std::move(trackState)) {}
const TrackState & trackState() const
Get the (const reference to the) TrackState.
Definition: KFTrackState.h:40
TrackState fTrackState
Definition: KFTrackState.h:85

Member Function Documentation

double trkf::KFTrackState::chi2 ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 65 of file KFTrackState.h.

References trkf::TrackState::chi2(), and fTrackState.

Referenced by trkf::TrackKalmanFitter::doFitWork().

65 { return fTrackState.chi2(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:85
double chi2(const HitState &hitstate) const
Chi2 of the TrackState with respect to a HitState. The two states must be on the same plane; it is re...
Definition: TrackState.h:172
double trkf::KFTrackState::combinedError ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 61 of file KFTrackState.h.

References trkf::TrackState::combinedError(), and fTrackState.

62  {
63  return fTrackState.combinedError(hitstate);
64  }
TrackState fTrackState
Definition: KFTrackState.h:85
double combinedError(const HitState &hitstate) const
Combined error of the TrackState with respect to a HitState. The two states must be on the same plane...
Definition: TrackState.h:166
double trkf::KFTrackState::combinedError2 ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 57 of file KFTrackState.h.

References trkf::TrackState::combinedError2(), and fTrackState.

58  {
59  return fTrackState.combinedError2(hitstate);
60  }
TrackState fTrackState
Definition: KFTrackState.h:85
double combinedError2(const HitState &hitstate) const
Combined squared error of the TrackState with respect to a HitState. The two states must be on the sa...
Definition: TrackState.h:160
bool KFTrackState::combineWithTrackState ( const TrackState trackstate)

Combine the TrackState given another TrackState (they need to be on the same plane)

Definition at line 21 of file KFTrackState.cxx.

References trkf::TrackState::covariance(), recob::tracking::Plane::direction(), e, fTrackState, trkf::TrackState::parameters(), trkf::TrackState::plane(), recob::tracking::Plane::position(), trkf::TrackState::setCovariance(), and trkf::TrackState::setParameters().

Referenced by KFTrackState().

22 {
23  // if tracks not on same plane do not update and return false
24  if ((trackstate.plane().position() - fTrackState.plane().position()).Mag2() > 10e-6) return false;
25  if ((trackstate.plane().direction() - fTrackState.plane().direction()).Mag2() > 10e-6)
26  return false;
27  // compute the weighted average of the two states
28  const SVector5& par1 = fTrackState.parameters();
29  const SVector5& par2 = trackstate.parameters();
30  const SMatrixSym55& cov1 = fTrackState.covariance();
31  const SMatrixSym55& cov2 = trackstate.covariance();
32  SMatrixSym55&& cov = cov1 + cov2;
33  bool success = cov.Invert();
34  if (!success) return false;
35  SMatrix55 K = cov1 * cov;
36  fTrackState.setParameters(par1 + K * (par2 - par1));
37  K = K * cov2;
38  fTrackState.setCovariance(K.LowerBlock());
39  return true;
40 }
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
void setCovariance(const SMatrixSym55 &trackStateCov)
Set the covariance matrix of the TrackState.
Definition: TrackState.h:178
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:108
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
TrackState fTrackState
Definition: KFTrackState.h:85
recob::tracking::SMatrix55 SMatrix55
Definition: TrackState.h:14
recob::tracking::SVector5 SVector5
Definition: TrackState.h:12
Point_t const & position() const
Reference position on the plane.
Definition: TrackingPlane.h:66
void setParameters(const SVector5 &trackStatePar)
Set the parameters of the TrackState; also update the global position and momentum accordingly...
Definition: TrackState.h:181
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:110
Float_t e
Definition: plot.C:35
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:112
const SMatrixSym55& trkf::KFTrackState::covariance ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 47 of file KFTrackState.h.

References trkf::TrackState::covariance(), and fTrackState.

Referenced by trkf::TrackKalmanFitter::doFitWork(), dump(), and trkf::TrackKalmanFitter::fillResult().

47 { return fTrackState.covariance(); }
TrackState fTrackState
Definition: KFTrackState.h:85
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:110
std::ostream& trkf::KFTrackState::dump ( std::ostream &  out = std::cout) const
inline

Printout information.

Definition at line 75 of file KFTrackState.h.

References covariance(), recob::tracking::Plane::direction(), isTrackAlongPlaneDir(), mass(), momentum(), parameters(), pID(), plane(), position(), and recob::tracking::Plane::position().

Referenced by trkf::TrackKalmanFitter::doFitWork().

76  {
77  out << "KFTrackState with pID=" << pID() << " mass=" << mass() << "\npars=" << parameters()
78  << " position=" << position() << " momentum=" << momentum() << "\ncov=\n"
79  << covariance() << "\non plane with pos=" << plane().position()
80  << " and dir=" << plane().direction() << " along=" << isTrackAlongPlaneDir() << "\n";
81  return out;
82  }
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
bool isTrackAlongPlaneDir() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:54
const SVector5 & parameters() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:46
double mass() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:52
const Point_t & position() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:49
const SMatrixSym55 & covariance() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:47
Point_t const & position() const
Reference position on the plane.
Definition: TrackingPlane.h:66
const Plane & plane() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:48
const Vector_t & momentum() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:50
int pID() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:51
bool trkf::KFTrackState::isTrackAlongPlaneDir ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 54 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::isTrackAlongPlaneDir().

Referenced by dump().

TrackState fTrackState
Definition: KFTrackState.h:85
bool isTrackAlongPlaneDir() const
is the track momentum along the plane direction?
Definition: TrackState.h:141
double trkf::KFTrackState::mass ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 52 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::mass().

Referenced by dump().

52 { return fTrackState.mass(); }
TrackState fTrackState
Definition: KFTrackState.h:85
double mass() const
mass hypthesis of the track
Definition: TrackState.h:120
const Vector_t& trkf::KFTrackState::momentum ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 50 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::momentum().

Referenced by trkf::TrackKalmanFitter::doFitWork(), and dump().

50 { return fTrackState.momentum(); }
const Vector_t & momentum() const
momentum of the track
Definition: TrackState.h:116
TrackState fTrackState
Definition: KFTrackState.h:85
const SVector5& trkf::KFTrackState::parameters ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 46 of file KFTrackState.h.

Referenced by dump(), and setTrackState().

46 { return fTrackState.parameters(); }
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:108
TrackState fTrackState
Definition: KFTrackState.h:85
const SVector6 trkf::KFTrackState::parameters6D ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 53 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::parameters6D().

53 { return fTrackState.parameters6D(); }
TrackState fTrackState
Definition: KFTrackState.h:85
SVector6 parameters6D() const
track parameters in global cartesian coordinates
Definition: TrackState.h:130
int trkf::KFTrackState::pID ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 51 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::pID().

Referenced by dump().

51 { return fTrackState.pID(); }
TrackState fTrackState
Definition: KFTrackState.h:85
int pID() const
particle id hypthesis of the track
Definition: TrackState.h:118
const Plane& trkf::KFTrackState::plane ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 48 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::plane().

Referenced by dump().

48 { return fTrackState.plane(); }
TrackState fTrackState
Definition: KFTrackState.h:85
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:112
const Point_t& trkf::KFTrackState::position ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 49 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::position().

Referenced by trkf::TrackKalmanFitter::doFitWork(), and dump().

49 { return fTrackState.position(); }
TrackState fTrackState
Definition: KFTrackState.h:85
const Point_t & position() const
position of the track
Definition: TrackState.h:114
double trkf::KFTrackState::residual ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 56 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::residual().

Referenced by trkf::TrackKalmanFitter::doFitWork().

56 { return fTrackState.residual(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:85
double residual(const HitState &hitstate) const
Residual of the TrackState with respect to a HitState. The two states must be on the same plane; it i...
Definition: TrackState.h:154
void trkf::KFTrackState::setCovariance ( const SMatrixSym55 trackStateCov)
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 67 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::setCovariance().

Referenced by trkf::TrackKalmanFitter::doFitWork().

68  {
69  fTrackState.setCovariance(trackStateCov);
70  }
void setCovariance(const SMatrixSym55 &trackStateCov)
Set the covariance matrix of the TrackState.
Definition: TrackState.h:178
TrackState fTrackState
Definition: KFTrackState.h:85
void trkf::KFTrackState::setParameters ( const SVector5 trackStatePar)
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 71 of file KFTrackState.h.

References fTrackState, and trkf::TrackState::setParameters().

71 { fTrackState.setParameters(trackStatePar); }
TrackState fTrackState
Definition: KFTrackState.h:85
void setParameters(const SVector5 &trackStatePar)
Set the parameters of the TrackState; also update the global position and momentum accordingly...
Definition: TrackState.h:181
void trkf::KFTrackState::setTrackState ( TrackState &&  s)
inline

Set the TrackState.

Definition at line 42 of file KFTrackState.h.

References fTrackState, parameters(), and trkf::TrackState::parameters().

42 { fTrackState = std::move(s); }
TrackState fTrackState
Definition: KFTrackState.h:85
const TrackState& trkf::KFTrackState::trackState ( ) const
inline

Get the (const reference to the) TrackState.

Definition at line 40 of file KFTrackState.h.

References fTrackState.

Referenced by trkf::TrackKalmanFitter::doFitWork().

40 { return fTrackState; }
TrackState fTrackState
Definition: KFTrackState.h:85
bool KFTrackState::updateWithHitState ( const HitState hitstate)

Update the TrackState given a HitState (they need to be on the same plane)

Definition at line 5 of file KFTrackState.cxx.

References trkf::TrackState::covariance(), recob::tracking::Plane::direction(), e, fTrackState, trkf::HitState::hitMeas(), trkf::HitState::hitMeasErr2(), trkf::TrackState::parameters(), trkf::HitState::plane(), trkf::TrackState::plane(), recob::tracking::Plane::position(), trkf::TrackState::setCovariance(), trkf::TrackState::setParameters(), and tmp.

Referenced by trkf::TrackKalmanFitter::doFitWork(), and KFTrackState().

6 {
7  // if track and hit not on same plane do not update and return false
8  if ((hitstate.plane().position() - fTrackState.plane().position()).Mag2() > 10e-6) return false;
9  if ((hitstate.plane().direction() - fTrackState.plane().direction()).Mag2() > 10e-6) return false;
10  // Kalman Filter update (simplified case: 1D measurement along the same coordinate as element 0 of the track parameters)
12  tmp(0, 0) = 1. / (hitstate.hitMeasErr2() + fTrackState.covariance()(0, 0));
14  fTrackState.covariance() * tmp.Col(0) *
15  (hitstate.hitMeas() - fTrackState.parameters()(0)));
17  (fTrackState.covariance() - ROOT::Math::Similarity(fTrackState.covariance(), tmp)));
18  return true;
19 }
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
void setCovariance(const SMatrixSym55 &trackStateCov)
Set the covariance matrix of the TrackState.
Definition: TrackState.h:178
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:108
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
double hitMeas() const
Definition: TrackState.h:59
TrackState fTrackState
Definition: KFTrackState.h:85
Float_t tmp
Definition: plot.C:35
double hitMeasErr2() const
Definition: TrackState.h:60
const Plane & plane() const
Definition: TrackState.h:61
Point_t const & position() const
Reference position on the plane.
Definition: TrackingPlane.h:66
void setParameters(const SVector5 &trackStatePar)
Set the parameters of the TrackState; also update the global position and momentum accordingly...
Definition: TrackState.h:181
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:110
Float_t e
Definition: plot.C:35
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:112

Member Data Documentation


The documentation for this class was generated from the following files: