LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TrackState.h
Go to the documentation of this file.
1 #ifndef TRACKSTATE_H
2 #define TRACKSTATE_H
3 
9 
10 namespace trkf {
11 
20 
21  namespace {
22  const double elmass = 0.000510998; // Electron
23  const double mumass = 0.105658367; // Muon
24  const double pimass = 0.13957; // Charged pion
25  const double kmass = 0.493677; // Charged kaon
26  const double pmass = 0.938272; // Proton
27  }
28 
41 
42  class HitState {
43  public:
44  HitState(double hitMeas, double hitMeasErr2, geo::WireID& wireId, const geo::WireGeo& wgeom)
45  : fHitMeas(hitMeas),fHitMeasErr2(hitMeasErr2), fWireId(wireId),fPlane(recob::tracking::makePlane(wgeom)) {}
46  HitState(double hitMeas, double hitMeasErr2, geo::WireID&& wireId, const geo::WireGeo& wgeom)
47  : fHitMeas(hitMeas),fHitMeasErr2(hitMeasErr2), fWireId(std::move(wireId)),fPlane(recob::tracking::makePlane(wgeom)) {}
48  double hitMeas() const { return fHitMeas; }
49  double hitMeasErr2() const { return fHitMeasErr2; }
50  const Plane& plane() const { return fPlane; }
51  const geo::WireID& wireId() const { return fWireId; }
52  std::ostream& dump(std::ostream& out = std::cout) const {
53  out << "HitState with meas=" << hitMeas() << " err2=" << hitMeasErr2()
54  << " plane=" << wireId().Plane << " wire=" << wireId().Wire
55  << " on plane with pos=" << plane().position() << " and dir=" << plane().direction() << "\n";
56  return out;
57  }
58  private:
59  double fHitMeas;
60  double fHitMeasErr2;
63  };
64 
78 
79  class TrackState {
80  public:
81  TrackState(const SVector5& trackStatePar, const SMatrixSym55& trackStateCov, const Plane& plane, bool trackAlongPlaneDir, int pid)
82  :fTrackStatePar(trackStatePar), fTrackStateCov(trackStateCov), fPlane(plane), fPid(pid)
83  {
84  SVector6 par6d = fPlane.Local5DToGlobal6DParameters(fTrackStatePar,trackAlongPlaneDir);
85  fPos = Point_t(par6d[0],par6d[1],par6d[2]);
86  fMom = Point_t(par6d[3],par6d[4],par6d[5]);
87  }
88  //
90  const SVector5& parameters() const { return fTrackStatePar; }
92  const SMatrixSym55& covariance() const { return fTrackStateCov; }
94  const Plane& plane() const { return fPlane; }
96  const Point_t& position() const { return fPos; }
98  const Vector_t& momentum() const { return fMom; }
100  int pID() const { return fPid; }
102  double mass() const {
103  if (abs(fPid)==11) { return elmass; }
104  if (abs(fPid)==13) { return mumass; }
105  if (abs(fPid)==211) { return pimass; }
106  if (abs(fPid)==321) { return kmass; }
107  if (abs(fPid)==2212) { return pmass; }
108  return util::kBogusD;
109  }
111  SVector6 parameters6D() const { return SVector6(fPos.X(),fPos.Y(),fPos.Z(),fMom.X(),fMom.Y(),fMom.Z()); }
113  SMatrixSym66 covariance6D() const { return fPlane.Local5DToGlobal6DCovariance(fTrackStateCov, true, fMom); }
114  //
116  bool isTrackAlongPlaneDir() const { return fMom.Dot(fPlane.direction())>0; }
117  //
119  std::ostream& dump(std::ostream& out = std::cout) const {
120  out << "TrackState with pID=" << pID() << " mass=" << mass()
121  << "\npars=" << parameters() << " position=" << position() << " momentum=" << momentum()
122  << "\ncov=\n" << covariance()
123  << "\non plane with pos=" << plane().position() << " and dir=" << plane().direction() << " along=" << isTrackAlongPlaneDir() << "\n";
124  return out;
125  }
126  //
128  inline double residual (const HitState& hitstate) const { return hitstate.hitMeas()-fTrackStatePar(0); }
129 
131  inline double combinedError2(const HitState& hitstate) const { return hitstate.hitMeasErr2()+fTrackStateCov(0,0); }
132 
134  inline double combinedError (const HitState& hitstate) const { return sqrt(combinedError2(hitstate)); }
135 
137  inline double chi2 (const HitState& hitstate) const { return residual(hitstate)*residual(hitstate)/combinedError2(hitstate); }
138 
140  void setCovariance(const SMatrixSym55& trackStateCov) { fTrackStateCov = trackStateCov; }
141 
143  void setParameters(const SVector5& trackStatePar) {
144  fTrackStatePar = trackStatePar;
145  SVector6 par6d = fPlane.Local5DToGlobal6DParameters(trackStatePar,isTrackAlongPlaneDir());
146  fPos = Point_t(par6d[0],par6d[1],par6d[2]);
147  fMom = Vector_t(par6d[3],par6d[4],par6d[5]);
148  }
149  //
150  private:
154  int fPid;
157  };
158 
159 }
160 
161 #endif
int fPid
particle id hypthesis of the track
Definition: TrackState.h:154
Plane fPlane
plane where the parameters are defined
Definition: TrackState.h:153
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:61
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
double fHitMeas
Definition: TrackState.h:59
const geo::WireID & wireId() const
Definition: TrackState.h:51
ROOT::Math::SMatrix< Double32_t, 5, 5 > SMatrix55
Definition: TrackingTypes.h:89
Reconstruction base classes.
void setCovariance(const SMatrixSym55 &trackStateCov)
Set the covariance matrix of the TrackState.
Definition: TrackState.h:140
recob::tracking::Point_t Point_t
Definition: TrackState.h:18
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Definition: TrackingTypes.h:85
recob::tracking::Vector_t Vector_t
Definition: TrackState.h:19
const Vector_t & momentum() const
momentum of the track
Definition: TrackState.h:98
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
STL namespace.
SMatrixSym66 covariance6D() const
track parameter covariance matrix in global cartesian coordinates
Definition: TrackState.h:113
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
recob::tracking::SMatrix55 SMatrix55
Definition: TrackState.h:14
double mass() const
mass hypthesis of the track
Definition: TrackState.h:102
ROOT::Math::SVector< Double32_t, 5 > SVector5
Definition: TrackingTypes.h:92
const Point_t & position() const
position of the track
Definition: TrackState.h:96
double hitMeasErr2() const
Definition: TrackState.h:49
const Plane & plane() const
Definition: TrackState.h:50
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Definition: TrackingTypes.h:29
double fHitMeasErr2
Definition: TrackState.h:60
bool isTrackAlongPlaneDir() const
is the track momentum along the plane direction?
Definition: TrackState.h:116
recob::tracking::SVector5 SVector5
Definition: TrackState.h:12
int pID() const
particle id hypthesis of the track
Definition: TrackState.h:100
Vector_t fMom
momentum of the track (cached)
Definition: TrackState.h:156
Point_t const & position() const
Reference position on the plane.
Definition: TrackingPlane.h:66
SMatrixSym66 Local5DToGlobal6DCovariance(SMatrixSym55 cov5d, bool hasMomentum, const Vector_t &trackMomOrDir) const
Translate track covariance from local to global coordinates. The track momentum (or direction) is nee...
Definition: TrackingPlane.h:97
void setParameters(const SVector5 &trackStatePar)
Set the parameters of the TrackState; also update the global position and momentum accordingly...
Definition: TrackState.h:143
Plane makePlane(recob::tracking::Point_t const &pos, recob::tracking::Vector_t const &dir)
helper function to construct a recob::tracking::Plane from a Point_t and a Vector_t; the point is on ...
SMatrixSym55 fTrackStateCov
track parameter covariance matrix on the plane
Definition: TrackState.h:152
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Definition of data types for geometry description.
SVector6 Local5DToGlobal6DParameters(const SVector5 &par5d, bool trackAlongPlaneDir=true) const
Function to convert parameters from local to global coordinates. Local coordinates are on the plane w...
Definition: TrackingPlane.h:80
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
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 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
ROOT::Math::SMatrix< Double32_t, 6, 6, ROOT::Math::MatRepSym< Double32_t, 6 > > SMatrixSym66
Definition: TrackingTypes.h:86
SVector6 parameters6D() const
track parameters in global cartesian coordinates
Definition: TrackState.h:111
const geo::WireID fWireId
Definition: TrackState.h:61
std::ostream & dump(std::ostream &out=std::cout) const
Definition: TrackState.h:52
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
Definition: TrackState.h:92
recob::tracking::SMatrixSym66 SMatrixSym66
Definition: TrackState.h:16
std::ostream & dump(std::ostream &out=std::cout) const
Printout information.
Definition: TrackState.h:119
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
recob::tracking::SVector6 SVector6
Definition: TrackState.h:13
constexpr double kBogusD
obviously bogus double value
ROOT::Math::SVector< Double32_t, 6 > SVector6
Definition: TrackingTypes.h:91
Class for a measurement on a recob::tracking::Plane (plane defined by a wire and the drift direction)...
Definition: TrackState.h:42
HitState(double hitMeas, double hitMeasErr2, geo::WireID &wireId, const geo::WireGeo &wgeom)
Definition: TrackState.h:44
Point_t fPos
position of the track (cached)
Definition: TrackState.h:155
const Plane & plane() const
plane where the parameters are defined
Definition: TrackState.h:94
recob::tracking::Plane Plane
Definition: TrackState.h:17
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
TrackState(const SVector5 &trackStatePar, const SMatrixSym55 &trackStateCov, const Plane &plane, bool trackAlongPlaneDir, int pid)
Definition: TrackState.h:81
SVector5 fTrackStatePar
track parameters defined on the plane
Definition: TrackState.h:151
HitState(double hitMeas, double hitMeasErr2, geo::WireID &&wireId, const geo::WireGeo &wgeom)
Definition: TrackState.h:46
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