LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrackingPlane.h
Go to the documentation of this file.
1 #ifndef TRACKINGPLANE_H
2 #define TRACKINGPLANE_H
3 
5 
6 namespace recob {
7  namespace tracking {
8 
36 
37  class Plane {
38 
41  struct TrigCache {
42  public:
43  TrigCache(const Vector_t& planeDir)
44  {
45  const double diryz = std::hypot(planeDir.Y(), planeDir.Z());
46  fCosA = diryz;
47  fSinA = planeDir.X();
48  fCosB = (diryz != 0.0) ? planeDir.Z() / diryz : 1.0;
49  fSinB = (diryz != 0.0) ? -planeDir.Y() / diryz : 0.0;
50  }
51  double fCosA;
52  double fSinA;
53  double fCosB;
54  double fSinB;
55  };
56 
57  public:
60  Plane(const Point_t& planePos, const Vector_t& planeDir)
61  : fPlanePos(planePos), fPlaneDir(planeDir.Unit()), fTrigCache(planeDir.Unit())
62  {}
63 
66  Point_t const& position() const { return fPlanePos; }
67 
70  Vector_t const& direction() const { return fPlaneDir; }
71 
73  inline SVector5 Global6DToLocal5DParameters(const SVector6& par6d) const
75  {
77  }
79  const Point_t& planePos,
80  const Vector_t& planeDir,
81  const TrigCache& trigCache) const;
83 
85  inline SVector6 Local5DToGlobal6DParameters(const SVector5& par5d,
87  bool trackAlongPlaneDir = true) const
88  {
90  par5d, fPlanePos, fPlaneDir, fTrigCache, trackAlongPlaneDir);
91  }
93  const Point_t& planePos,
94  const Vector_t& planeDir,
95  const TrigCache& trigCache,
96  bool trackAlongPlaneDir = true) const;
98 
100  inline SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum,
102  const Vector_t& trackMomOrDir) const
103  {
104  return Local5DToGlobal6DJacobian(hasMomentum, trackMomOrDir, fPlaneDir, fTrigCache);
105  }
106  SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum,
107  const Vector_t& trackMomOrDir,
108  const Vector_t& planeDir,
109  const TrigCache& trigCache) const;
111 
113  inline SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum,
115  const Vector_t& trackMomOrDir) const
116  {
117  return Global6DToLocal5DJacobian(hasMomentum, trackMomOrDir, fPlaneDir, fTrigCache);
118  }
119  SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum,
120  const Vector_t& trackMomOrDir,
121  const Vector_t& planeDir,
122  const TrigCache& trigCache) const;
124 
127  bool hasMomentum,
128  const Vector_t& trackMomOrDir) const
129  {
130  return Local5DToGlobal6DCovariance(cov5d, hasMomentum, trackMomOrDir, fPlaneDir);
131  }
132 
135  bool hasMomentum,
136  const Vector_t& trackMomOrDir) const
137  {
138  return Global6DToLocal5DCovariance(cov6d, hasMomentum, trackMomOrDir, fPlaneDir);
139  }
140 
144  {
146  }
148  const TrigCache& trigCache) const;
150 
154  {
156  }
158  const TrigCache& trigCache) const;
160 
162  double cosAlpha() const { return fTrigCache.fCosA; }
164  double sinAlpha() const { return fTrigCache.fSinA; }
165  double cosBeta() const { return fTrigCache.fCosB; }
166  double sinBeta() const { return fTrigCache.fSinB; }
168 
171  const Point_t& planePos,
172  const Vector_t& planeDir)
173  {
174  Plane p(planePos, planeDir);
175  return p.Global6DToLocal5DParameters(par6d);
176  }
179  const Point_t& planePos,
180  const Vector_t& planeDir,
181  bool trackAlongPlaneDir = true)
182  {
183  Plane p(planePos, planeDir);
184  return p.Local5DToGlobal6DParameters(par5d, trackAlongPlaneDir);
185  }
187  static SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum,
188  const Vector_t& trackMomOrDir,
189  const Vector_t& planeDir)
190  {
191  Plane p(Point_t(), planeDir);
192  return p.Local5DToGlobal6DJacobian(hasMomentum, trackMomOrDir);
193  }
195  static SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum,
196  const SVector6& par6d,
197  const Vector_t& planeDir)
198  {
199  Plane p(Point_t(), planeDir);
200  return p.Local5DToGlobal6DJacobian(hasMomentum, Vector_t(par6d[3], par6d[4], par6d[5]));
201  }
203  static SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum,
204  const Vector_t& trackMomOrDir,
205  const Vector_t& planeDir)
206  {
207  Plane p(Point_t(), planeDir);
208  return p.Global6DToLocal5DJacobian(hasMomentum, trackMomOrDir);
209  }
211  static SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum,
212  const SVector6& par6d,
213  const Vector_t& planeDir)
214  {
215  Plane p(Point_t(), planeDir);
216  return p.Global6DToLocal5DJacobian(hasMomentum, Vector_t(par6d[3], par6d[4], par6d[5]));
217  }
220  bool hasMomentum,
221  const Vector_t& trackMomOrDir,
222  const Vector_t& planeDir)
223  {
224  return ROOT::Math::Similarity(
225  Local5DToGlobal6DJacobian(hasMomentum, trackMomOrDir, planeDir), cov5d);
226  }
229  bool hasMomentum,
230  const Vector_t& trackMomOrDir,
231  const Vector_t& planeDir)
232  {
233  return ROOT::Math::Similarity(
234  Global6DToLocal5DJacobian(hasMomentum, trackMomOrDir, planeDir), cov6d);
235  }
238  {
239  Plane p(Point_t(), planeDir);
240  return p.Global3DToLocal3DRotation();
241  }
244  {
245  Plane p(Point_t(), planeDir);
246  return p.Local3DToGlobal3DRotation();
247  }
248 
249  private:
253  };
254 
255  }
256 }
257 
258 #endif
double cosAlpha() const
Return cached values of trigonometric function for angles defining the plane.
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum, const Vector_t &trackMomOrDir) const
Compute the jacobian to translate track covariance from local to global coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic).
Struct caching trigonometric function results.
Definition: TrackingPlane.h:41
static SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum, const SVector6 &par6d, const Vector_t &planeDir)
Compute the jacobian to translate track covariance from local to global coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic).
Reconstruction base classes.
static SVector6 Local5DToGlobal6DParameters(const SVector5 &par5d, const Point_t &planePos, const Vector_t &planeDir, bool trackAlongPlaneDir=true)
Function to convert parameters from local to global coordinates. Local coordinates are on the plane w...
Point_t fPlanePos
Position of a point on the plane.
Rotation_t Global3DToLocal3DRotation() const
Calculate rotation matrices from global (x,y,z) to local (u,v,w) coordinates.
static SMatrixSym55 Global6DToLocal5DCovariance(SMatrixSym66 cov6d, bool hasMomentum, const Vector_t &trackMomOrDir, const Vector_t &planeDir)
Translate track covariance from global to local coordinates. The track momentum (or direction) is nee...
SVector5 Global6DToLocal5DParameters(const SVector6 &par6d) const
Function to convert parameters from global to local coordinates. Local coordinates are on the plane w...
Definition: TrackingPlane.h:74
Plane(const Point_t &planePos, const Vector_t &planeDir)
Constructor from reference position on the plane and direction orthogonal to the plane.
Definition: TrackingPlane.h:60
ROOT::Math::SMatrix< Double32_t, 6, 5 > SMatrix65
double cosBeta() const
Return cached values of trigonometric function for angles defining the plane.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
ROOT::Math::SMatrix< Double32_t, 6, 6, ROOT::Math::MatRepSym< Double32_t, 6 >> SMatrixSym66
TrigCache fTrigCache
Cached trigonometric function values.
static SVector5 Global6DToLocal5DParameters(const SVector6 &par6d, const Point_t &planePos, const Vector_t &planeDir)
Function to convert parameters from global to local coordinates. Local coordinates are on the plane w...
static SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum, const SVector6 &par6d, const Vector_t &planeDir)
Compute the jacobian to translate track covariance from global to local coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic). Warning: some information may be lost in degenerate cases, e.g. the unceratinty along z position when converting to a x-y plane (fixed z)
Vector_t fPlaneDir
Direction vector othogonal to the plane.
static Rotation_t Local3DToGlobal3DRotation(const Vector_t &planeDir)
Calculate rotation matrices from local (u,v,w) to global (x,y,z) coordinates.
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...
ROOT::Math::SVector< Double32_t, 6 > SVector6
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:31
static SMatrixSym66 Local5DToGlobal6DCovariance(SMatrixSym55 cov5d, bool hasMomentum, const Vector_t &trackMomOrDir, const Vector_t &planeDir)
Translate track covariance from local to global coordinates. The track momentum (or direction) is nee...
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:86
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
ROOT::Math::Rotation3D Rotation_t
Type for representation of space rotations.
Definition: TrackingTypes.h:40
TrigCache(const Vector_t &planeDir)
Definition: TrackingPlane.h:43
static Rotation_t Global3DToLocal3DRotation(const Vector_t &planeDir)
Calculate rotation matrices from global (x,y,z) to local (u,v,w) coordinates.
double sinAlpha() const
Return cached values of trigonometric function for angles defining the plane.
ROOT::Math::SVector< Double32_t, 5 > SVector5
ROOT::Math::SMatrix< Double32_t, 5, 6 > SMatrix56
SMatrixSym55 Global6DToLocal5DCovariance(SMatrixSym66 cov6d, bool hasMomentum, const Vector_t &trackMomOrDir) const
Translate track covariance from global to local coordinates. The track momentum (or direction) is nee...
double sinBeta() const
Return cached values of trigonometric function for angles defining the plane.
static SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum, const Vector_t &trackMomOrDir, const Vector_t &planeDir)
Compute the jacobian to translate track covariance from global to local coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic). Warning: some information may be lost in degenerate cases, e.g. the unceratinty along z position when converting to a x-y plane (fixed z)
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:27
Rotation_t Local3DToGlobal3DRotation() const
Calculate rotation matrices from local (u,v,w) to global (x,y,z) coordinates.
static SMatrix65 Local5DToGlobal6DJacobian(bool hasMomentum, const Vector_t &trackMomOrDir, const Vector_t &planeDir)
Compute the jacobian to translate track covariance from local to global coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic).
SMatrix56 Global6DToLocal5DJacobian(bool hasMomentum, const Vector_t &trackMomOrDir) const
Compute the jacobian to translate track covariance from global to local coordinates. The track momentum (or direction) is needed to compute the jacobian. Local coordinates are on the plane orthogonal to planeDir (it may be the same direction as the momentum, but the function is generic). Warning: some information may be lost in degenerate cases, e.g. the unceratinty along z position when converting to a x-y plane (fixed z)