LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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.

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

Definition at line 26 of file KFTrackState.h.

References combineWithTrackState(), and updateWithHitState().

27  : fTrackState(std::move(trackState)) { }
const TrackState & trackState() const
Get the (const reference to the) TrackState.
Definition: KFTrackState.h:36
TrackState fTrackState
Definition: KFTrackState.h:71

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 55 of file KFTrackState.h.

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

55 { return fTrackState.chi2(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:71
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:137
double trkf::KFTrackState::combinedError ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 54 of file KFTrackState.h.

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

54 { return fTrackState.combinedError(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:71
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:134
double trkf::KFTrackState::combinedError2 ( const HitState hitstate) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 53 of file KFTrackState.h.

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

53 { return fTrackState.combinedError2(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:71
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:131
bool KFTrackState::combineWithTrackState ( const TrackState trackstate)

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

Definition at line 17 of file KFTrackState.cxx.

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

Referenced by KFTrackState().

17  {
18  // if tracks not on same plane do not update and return false
19  if ( (trackstate.plane().position()-fTrackState.plane().position()).Mag2()>10e-6 ) return false;
20  if ( (trackstate.plane().direction()-fTrackState.plane().direction()).Mag2()>10e-6 ) return false;
21  // compute the weighted average of the two states
22  const SVector5& par1 = fTrackState.parameters();
23  const SVector5& par2 = trackstate.parameters();
24  const SMatrixSym55& cov1 = fTrackState.covariance();
25  const SMatrixSym55& cov2 = trackstate.covariance();
26  SMatrixSym55&& cov = cov1 + cov2;
27  bool success = cov.Invert();
28  if (!success) return false;
29  SMatrix55 K = cov1 * cov;
30  fTrackState.setParameters( par1 + K*(par2 - par1) );
31  K = K*cov2;
32  fTrackState.setCovariance( K.LowerBlock() );
33  return true;
34 }
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:140
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:90
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
TrackState fTrackState
Definition: KFTrackState.h:71
recob::tracking::SMatrix55 SMatrix55
Definition: TrackState.h:14
Double_t K
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:143
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:92
Float_t e
Definition: plot.C:34
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:94
const SMatrixSym55& trkf::KFTrackState::covariance ( ) const
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 43 of file KFTrackState.h.

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

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

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

Printout information.

Definition at line 62 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().

62  {
63  out << "KFTrackState with pID=" << pID() << " mass=" << mass()
64  << "\npars=" << parameters() << " position=" << position() << " momentum=" << momentum()
65  << "\ncov=\n" << covariance()
66  << "\non plane with pos=" << plane().position() << " and dir=" << plane().direction() << " along=" << isTrackAlongPlaneDir() << "\n";
67  return out;
68  }
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:50
const SVector5 & parameters() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:42
double mass() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:48
const Point_t & position() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:45
const SMatrixSym55 & covariance() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:43
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:44
const Vector_t & momentum() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:46
int pID() const
This function calls the homonymous function of the stored TrackState.
Definition: KFTrackState.h:47
bool trkf::KFTrackState::isTrackAlongPlaneDir ( ) 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::isTrackAlongPlaneDir().

Referenced by dump().

TrackState fTrackState
Definition: KFTrackState.h:71
bool isTrackAlongPlaneDir() const
is the track momentum along the plane direction?
Definition: TrackState.h:116
double trkf::KFTrackState::mass ( ) 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::mass().

Referenced by dump().

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

This function calls the homonymous function of the stored TrackState.

Definition at line 46 of file KFTrackState.h.

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

Referenced by dump().

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

This function calls the homonymous function of the stored TrackState.

Definition at line 42 of file KFTrackState.h.

Referenced by dump(), and setTrackState().

42 { return fTrackState.parameters(); }
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:90
TrackState fTrackState
Definition: KFTrackState.h:71
const SVector6 trkf::KFTrackState::parameters6D ( ) 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::parameters6D().

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

This function calls the homonymous function of the stored TrackState.

Definition at line 47 of file KFTrackState.h.

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

Referenced by dump().

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

This function calls the homonymous function of the stored TrackState.

Definition at line 44 of file KFTrackState.h.

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

Referenced by dump().

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

This function calls the homonymous function of the stored TrackState.

Definition at line 45 of file KFTrackState.h.

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

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

45 { return fTrackState.position(); }
TrackState fTrackState
Definition: KFTrackState.h:71
const Point_t & position() const
position of the track
Definition: TrackState.h:96
double trkf::KFTrackState::residual ( const HitState hitstate) 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::residual().

52 { return fTrackState.residual(hitstate); }
TrackState fTrackState
Definition: KFTrackState.h:71
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:128
void trkf::KFTrackState::setCovariance ( const SMatrixSym55 trackStateCov)
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 57 of file KFTrackState.h.

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

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

57 { fTrackState.setCovariance(trackStateCov); }
void setCovariance(const SMatrixSym55 &trackStateCov)
Set the covariance matrix of the TrackState.
Definition: TrackState.h:140
TrackState fTrackState
Definition: KFTrackState.h:71
void trkf::KFTrackState::setParameters ( const SVector5 trackStatePar)
inline

This function calls the homonymous function of the stored TrackState.

Definition at line 58 of file KFTrackState.h.

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

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

Set the TrackState.

Definition at line 38 of file KFTrackState.h.

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

38 { fTrackState = std::move(s); }
Float_t s
Definition: plot.C:23
TrackState fTrackState
Definition: KFTrackState.h:71
const TrackState& trkf::KFTrackState::trackState ( ) const
inline

Get the (const reference to the) TrackState.

Definition at line 36 of file KFTrackState.h.

References fTrackState.

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

36 { return fTrackState; }
TrackState fTrackState
Definition: KFTrackState.h:71
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().

5  {
6  // if track and hit not on same plane do not update and return false
7  if ( (hitstate.plane().position()-fTrackState.plane().position()).Mag2()>10e-6 ) return false;
8  if ( (hitstate.plane().direction()-fTrackState.plane().direction()).Mag2()>10e-6 ) return false;
9  // Kalman Filter update (simplified case: 1D measurement along the same coordinate as element 0 of the track parameters)
11  tmp(0,0) = 1./(hitstate.hitMeasErr2()+fTrackState.covariance()(0,0));
13  fTrackState.setCovariance( (fTrackState.covariance()-ROOT::Math::Similarity(fTrackState.covariance(),tmp)) );
14  return true;
15 }
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:140
const SVector5 & parameters() const
track parameters defined on the plane
Definition: TrackState.h:90
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
double hitMeas() const
Definition: TrackState.h:48
TrackState fTrackState
Definition: KFTrackState.h:71
Float_t tmp
Definition: plot.C:37
double hitMeasErr2() const
Definition: TrackState.h:49
const Plane & plane() const
Definition: TrackState.h:50
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:143
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:92
Float_t e
Definition: plot.C:34
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:94

Member Data Documentation


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