Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
recob::Trajectory Class Reference

A trajectory in space reconstructed from hits. More...

#include <Trajectory.h>

Inheritance diagram for recob::Trajectory:
recob::TrackTrajectory

Public Types

enum  Ends_t { kStart, kVertex = kStart, kEnd, NEnds }
 Mnemonics for the access to begin and end of trajectory. More...
 
using Coord_t = tracking::Coord_t
 Type used for coordinates and values in general. More...
 
using Point_t = tracking::Point_t
 Type for representation of position in physical 3D space. More...
 
using Vector_t = tracking::Vector_t
 Type for representation of momenta in 3D space. More...
 
using Positions_t = tracking::Positions_t
 Type of trajectory point list. More...
 
using Momenta_t = tracking::Momenta_t
 Type of momentum list. More...
 
using TrajectoryPoint_t = tracking::TrajectoryPoint_t
 A point in the trajectory, with position and momentum. More...
 
using Rotation_t = tracking::Rotation_t
 Type for representation of space rotations. More...
 

Public Member Functions

 Trajectory ()=default
 Default constructor; do not use it! it's needed by ROOT I/O. More...
 
 Trajectory (Positions_t &&positions, Momenta_t &&momenta, bool hasMomenta)
 Constructor: specifies all the data for the trajectory. More...
 
 Trajectory (Positions_t const &positions, Momenta_t const &momenta, bool hasMomenta)
 Constructor: copies positions and momenta. More...
 
template<typename Stream >
void Dump (Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
 Prints trajectory content into a stream. More...
 
template<typename Stream >
void Dump (Stream &&out, unsigned int verbosity=1, std::string indent={}) const
 Prints trajectory content into a stream. More...
 
template<typename Stream >
void LowLevelDump (Stream &&out, std::string indent, std::string indentFirst) const
 Prints low-level trajectory content into a stream. More...
 
Access to trajectory information
size_t NumberTrajectoryPoints () const
 Returns the number of stored trajectory points. More...
 
size_t NPoints () const
 Returns the number of stored trajectory points. More...
 
size_t FirstPoint () const
 Returns the index of the first point in the trajectory (yep, it's 0). More...
 
size_t LastPoint () const
 Returns the index of the last point in the trajectory. More...
 
bool HasPoint (size_t i) const
 Returns whether the specified trajectory point is available. More...
 
const Positions_tPositions () const
 Returns reference to stored vector of positions. More...
 
const Momenta_tMomenta () const
 Returns reference to stored vector of momenta. More...
 
TrajectoryPoint_t TrajectoryPoint (size_t i) const
 Returns position and momentum at the specified trajectory point. More...
 
Point_t const & Vertex () const
 Returns the position of the first point of the trajectory [cm]. More...
 
Point_t const & Start () const
 Returns the position of the first point of the trajectory [cm]. More...
 
Point_t const & End () const
 Returns the position of the last point of the trajectory [cm]. More...
 
Point_t const & LocationAtPoint (size_t i) const
 Returns the position at the specified trajectory point. More...
 
template<typename T >
std::pair< T, T > Extent () const
 Fills the first and last point in the trajectory. More...
 
std::pair< Point_t, Point_tExtent () const
 Returns a copy of the first and last point in the trajectory. More...
 
double Length (size_t startAt=0) const
 Returns the approximate length of the trajectory. More...
 
Access to direction and momentum information
Vector_t VertexDirection () const
 Returns the direction of the trajectory at the first point. More...
 
Vector_t StartDirection () const
 Returns the direction of the trajectory at the first point. More...
 
Vector_t EndDirection () const
 Returns the direction of the trajectory at the last point. More...
 
double Theta (size_t p=0) const
 Trajectory angle at point, with respect to positive z direction. More...
 
double Phi (size_t p=0) const
 Azimuthal angle at a point on the trajectory, with respect to z. More...
 
double ZenithAngle (size_t p=0) const
 "Zenith" angle of trajectory, with respect to the vertical axis. More...
 
double AzimuthAngle (size_t p=0) const
 "Azimuth" angle of trajectory, with respect to the sky. More...
 
Vector_t const & VertexMomentumVector () const
 Returns the momentum of the trajectory at the first point [GeV/c]. More...
 
Vector_t const & StartMomentumVector () const
 Returns the momentum of the trajectory at the first point [GeV/c]. More...
 
Vector_t const & EndMomentumVector () const
 Returns the momentum of the trajectory at the last point [GeV/c]. More...
 
double VertexMomentum () const
 Computes and returns the modulus of momentum at the first point [GeV/c]. More...
 
double StartMomentum () const
 Computes and returns the modulus of momentum at the first point [GeV/c]. More...
 
double EndMomentum () const
 Computes and returns the modulus of momentum at the last point [GeV/c]. More...
 
Vector_t DirectionAtPoint (size_t i) const
 Computes and returns the direction of the trajectory at a point. More...
 
bool HasMomentum () const
 Returns whether information about the momentum is available. More...
 
double MomentumAtPoint (size_t i) const
 Computes and returns the modulus of the momentum at a point. More...
 
Vector_t const & MomentumVectorAtPoint (size_t i) const
 Returns the momentum vector at a point. More...
 
template<typename T >
std::pair< T, T > Direction () const
 Fills the starting and ending direction of the trajectory. More...
 
std::pair< Vector_t, Vector_tDirection () const
 Returns the trajectory directions at first and last point. More...
 
Rotation_t GlobalToLocalRotationAtPoint (size_t p) const
 Returns a rotation matrix that brings trajectory direction along z. More...
 
Rotation_t LocalToGlobalRotationAtPoint (size_t p) const
 Returns a rotation matrix bringing relative directions to global. More...
 
Templated version of homonymous functions to access to position, direction, and momentum information.
template<typename T >
Start () const
 Start position. Use e.g. as: More...
 
template<typename T >
Vertex () const
 Start position. Use e.g. as: More...
 
template<typename T >
End () const
 End position. Use e.g. as: More...
 
template<typename T >
LocationAtPoint (unsigned int p) const
 Position at point p. Use e.g. as: More...
 
template<typename T >
StartDirection () const
 Start direction. Use e.g. as: More...
 
template<typename T >
VertexDirection () const
 Start direction. Use e.g. as: More...
 
template<typename T >
EndDirection () const
 End direction. Use e.g. as: More...
 
template<typename T >
DirectionAtPoint (unsigned int p) const
 Direction at point p. Use e.g. as: More...
 
template<typename T >
StartMomentumVector () const
 Momentum vector at start point. Use e.g. as: More...
 
template<typename T >
VertexMomentumVector () const
 Momentum vector at start point. Use e.g. as: More...
 
template<typename T >
EndMomentumVector () const
 Momentum vector at end point. Use e.g. as: More...
 
template<typename T >
MomentumVectorAtPoint (unsigned int p) const
 Momentum vector at point p. Use e.g. as: More...
 
template<typename T >
GlobalToLocalRotationAtPoint (unsigned int p) const
 Returns a rotation matrix that brings trajectory direction along z. Use e.g. as: More...
 
template<typename T >
LocalToGlobalRotationAtPoint (unsigned int p) const
 Returns a rotation matrix bringing relative directions to global. Use e.g. as: More...
 

Static Public Attributes

static constexpr unsigned int MaxDumpVerbosity = 6
 Largest verbosity level supported by Dump(). More...
 

Private Attributes

Positions_t fPositions
 List of points the trajectory goes through. More...
 
Momenta_t fMomenta
 Momentum of each of the points in trajectory. More...
 
bool fHasMomentum = true
 Whether we have momentum modulus information. More...
 

Detailed Description

A trajectory in space reconstructed from hits.


See also
recob::Track, recob::trackutil::makeTrajectory()

The trajectory class contains a trajectory in 6D space representing the path walked by a particle. A trajectory point is made of a 3D position component (measured in centimeters) and a momentum component (measured in GeV/c); for a discussion on the object type for coordinates see: recob::tracking::Coord_t.

The object contains information about the trajectory, and no uncertainty, as that is considered a fit result (see recob::Track). By convention the first point is considered "start" (or "vertex") and the last point "end", although this assignment can be arbitrary and should not be relied upon for physics decisions.

The momentum content is in part optional: the trajectory creating algorithm may decide not to provide information about the modulus of the momentum. In that case, Trajectory::HasMomentum() will return false and every attempt to access the momentum vector will yield only the trajectory direction.

Invariants

Definition at line 67 of file Trajectory.h.

Member Typedef Documentation

Type used for coordinates and values in general.

Definition at line 70 of file Trajectory.h.

Type of momentum list.

Definition at line 82 of file Trajectory.h.

Type for representation of position in physical 3D space.

Definition at line 73 of file Trajectory.h.

Type of trajectory point list.

Definition at line 79 of file Trajectory.h.

Type for representation of space rotations.

Definition at line 97 of file Trajectory.h.

A point in the trajectory, with position and momentum.

Definition at line 94 of file Trajectory.h.

Type for representation of momenta in 3D space.

Definition at line 76 of file Trajectory.h.

Member Enumeration Documentation

Mnemonics for the access to begin and end of trajectory.

Enumerator
kStart 

Index representing the start of the trajectory.

kVertex 

Index representing the start of the trajectory.

kEnd 

Index representing the end of the trajectory.

NEnds 

Number of ends.

Definition at line 85 of file Trajectory.h.

85  {
86  kStart, ///< Index representing the start of the trajectory.
87  kVertex = kStart, ///< Index representing the start of the trajectory.
88  kEnd, ///< Index representing the end of the trajectory.
89  NEnds ///< Number of ends.
90  }; // enum Ends_t
Index representing the end of the trajectory.
Definition: Trajectory.h:88
Index representing the start of the trajectory.
Definition: Trajectory.h:86
Index representing the start of the trajectory.
Definition: Trajectory.h:87
Number of ends.
Definition: Trajectory.h:89

Constructor & Destructor Documentation

recob::Trajectory::Trajectory ( )
default

Default constructor; do not use it! it's needed by ROOT I/O.

recob::Trajectory::Trajectory ( Positions_t &&  positions,
Momenta_t &&  momenta,
bool  hasMomenta 
)

Constructor: specifies all the data for the trajectory.

Parameters
positions(moved) trajectory as a sorted list of points
momenta(moved) momentum along the trajectory, one per point
hasMomentawhether the information on momentum modulus is provided
Exceptions
std::runtime_errorif the invariants are violated
See also
recob::trackutil::makeTrajectory()

The most convenient way to create a recob::Trajectory is to use recob::trackutil::makeTrajectory().

Requirements

  • one momentum is required for each trajectory point
  • at least two points must be provided

Definition at line 24 of file Trajectory.cxx.

25  : fPositions(std::move(positions))
26  , fMomenta(std::move(momenta))
27  , fHasMomentum(hasMomenta)
28 {
29  // invariant check
30  if (fPositions.size() != fMomenta.size()) {
31  throw std::runtime_error("recob::Trajectory constructed with "
32  + std::to_string(fPositions.size()) + " positions and "
33  + std::to_string(fMomenta.size())
34  + " momenta! it requires the same number for both."
35  );
36  }
37  if (fPositions.size() < 2) {
38  throw std::runtime_error("recob::Trajectory constructed with "
39  + std::to_string(fPositions.size())
40  + " trajectory points! it requires at least 2."
41  );
42  }
43 } // recob::Trajectory::Trajectory()
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:670
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:669
def move(depos, offset)
Definition: depos.py:107
bool fHasMomentum
Whether we have momentum modulus information.
Definition: Trajectory.h:672
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
recob::Trajectory::Trajectory ( Positions_t const &  positions,
Momenta_t const &  momenta,
bool  hasMomenta 
)
inline

Constructor: copies positions and momenta.

Parameters
positionstrajectory as a sorted list of points
momentamomentum along the trajectory, one per point
hasMomentawhether the information on momentum modulus is provided
Exceptions
std::runtime_errorif the invariants are violated

Definition at line 136 of file Trajectory.h.

141  : Trajectory(Positions_t(positions), Momenta_t(momenta), hasMomenta)
142  {}
Trajectory()=default
Default constructor; do not use it! it&#39;s needed by ROOT I/O.
tracking::Positions_t Positions_t
Type of trajectory point list.
Definition: Trajectory.h:79
tracking::Momenta_t Momenta_t
Type of momentum list.
Definition: Trajectory.h:82

Member Function Documentation

double recob::Trajectory::AzimuthAngle ( size_t  p = 0) const

"Azimuth" angle of trajectory, with respect to the sky.

Parameters
pthe point index to extract the angle from (default: start)
Returns
the azimuth angle, in $ [-\pi,\pi[ $ [radians]
See also
ZenithAngle()

The angle is defined on the plane orthogonal to the y direction. It describes the angle of the trajectory at the specified point. The angle is measured starting from the positive z direction, counterclockwise. Therefore, a trajectory start lying on the demiplane of y axis and positive z axis returns 0 radians, while one lying on the demiplane of y axis and positive x axis returns $ +\pi/2 $ radians.

If the point number is invalid, the behaviour is undefined.

Definition at line 96 of file Trajectory.cxx.

96  {
97  //
98  // std::atan2(y, x) returns the angle of a point (x,y) respect to x axis.
99  // In our case, the definition of the angle (0 for z axis, pi/2 for x axis)
100  // translates atan2's y into our x, and x into z.
101  //
102  decltype(auto) startDir = DirectionAtPoint(p);
103  return std::atan2(startDir.X(), startDir.Z());
104 } // recob::Trajectory::AzimuthAngle()
STL namespace.
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
p
Definition: test.py:223
template<typename T >
std::pair<T,T> recob::Trajectory::Direction ( ) const
inline

Fills the starting and ending direction of the trajectory.

Parameters
start(output) direction at the beginning of the trajectory
end(output) direction at the end of the trajectory

The two arguments are expected to point each one to an area with room for at least three double numbers. The two filled vectors have norm 1.

The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.

Definition at line 472 of file Trajectory.h.

472 { return { VertexDirection<T>(),EndDirection<T>() }; }
std::pair<Vector_t, Vector_t> recob::Trajectory::Direction ( ) const
inline

Returns the trajectory directions at first and last point.

Returns
a pair with the first and last direction

The two returned vectors have norm 1. The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.

Example:

recob::Trajectory::Vector_t startDir, endDir;
std::tie(startDir, endDir) = traj.Direction(); // assign start and end

Definition at line 492 of file Trajectory.h.

493  { return { StartDirection(), EndDirection() }; }
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
Definition: Trajectory.h:303
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:299
recob::Trajectory::Vector_t recob::Trajectory::DirectionAtPoint ( size_t  i) const

Computes and returns the direction of the trajectory at a point.

Parameters
iindex of the point in the trajectory
Returns
the direction at that point

The direction is computed as unit vector parallel to the momentum at that trajectory point. If the index is not contained in the trajectory, the result is undefined.

Definition at line 117 of file Trajectory.cxx.

118 {
119 
120  auto const& mom = MomentumVectorAtPoint(i);
121  return HasMomentum()? (mom / mom.R()): mom;
122 
123 } // recob::Trajectory::DirectionAtPoint()
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:425
template<typename T >
T recob::Trajectory::DirectionAtPoint ( unsigned int  p) const
inline

Direction at point p. Use e.g. as:

TVector3 dir = traj.DirectionAtPoint<TVector3>(p);

.

Definition at line 564 of file Trajectory.h.

564 { auto dir = DirectionAtPoint(p); return T(dir.X(),dir.Y(),dir.Z()); }
string dir
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
p
Definition: test.py:223
template<typename Stream >
void recob::Trajectory::Dump ( Stream &&  out,
unsigned int  verbosity,
std::string  indent,
std::string  indentFirst 
) const

Prints trajectory content into a stream.

Template Parameters
Streamtype of the output stream
Parameters
outstream to output the information into
verbosityverbosity level (default: 1)
indentindentation string (default: none)
indentFirstindentation for first output line (default: as indent)

The amount of information dumped to screen is regulated by the Indentation string is prepended to each line, and the first line has its own special indentation string (indentFirst).

The output can be multi-line, it ends with no end-of-line and it does not inserts an end-of-line at its beginning (unless that is explicitly inside indentFirst). The lowest verbosity is guaranteed to be on a single line.

Information printed out (verbosity argument)

  • level 0: start position, direction, momentum modulus and number of points
  • level 1: also end position, direction and momentum modulus
  • level 2: also trajectory length
  • level 3: also angles at start
  • level 4: also 9 intermediate trajectory points
  • level 5: also 10 more intermediate trajectory points (19 total)
  • level 6: all trajectory points
template<typename Stream >
void recob::Trajectory::Dump ( Stream &&  out,
unsigned int  verbosity = 1,
std::string  indent = {} 
) const
inline

Prints trajectory content into a stream.

Template Parameters
Streamtype of the output stream
Parameters
outstream to output the information into
verbosityverbosity level (default: 1)
indentindentation string (default: none)
See also
Dump(Stream&&, unsigned int, std::string, std::string)

Implementation detail for Dump(Stream&&, unsigned int, std::string).

Definition at line 645 of file Trajectory.h.

645  {})
646  const
647  { Dump(std::forward<Stream>(out), verbosity, indent, indent); }
void Dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints trajectory content into a stream.
Point_t const& recob::Trajectory::End ( void  ) const
inline

Returns the position of the last point of the trajectory [cm].

Definition at line 226 of file Trajectory.h.

227  { return LocationAtPoint(LastPoint()); }
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:175
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:236
template<typename T >
T recob::Trajectory::End ( void  ) const
inline

End position. Use e.g. as:

TVector3 end = traj.End<TVector3>();

.

Definition at line 549 of file Trajectory.h.

549 { auto& loc = End(); return T(loc.X(),loc.Y(),loc.Z()); }
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
Definition: Trajectory.h:226
Vector_t recob::Trajectory::EndDirection ( ) const
inline

Returns the direction of the trajectory at the last point.

Definition at line 303 of file Trajectory.h.

304  { return DirectionAtPoint(LastPoint()); }
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:175
template<typename T >
T recob::Trajectory::EndDirection ( ) const
inline

End direction. Use e.g. as:

TVector3 enddir = traj.EndDirection<TVector3>();

.

Definition at line 561 of file Trajectory.h.

561 { auto dir = EndDirection(); return T(dir.X(),dir.Y(),dir.Z()); }
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
Definition: Trajectory.h:303
string dir
double recob::Trajectory::EndMomentum ( ) const
inline

Computes and returns the modulus of momentum at the last point [GeV/c].

Definition at line 401 of file Trajectory.h.

402  { return EndMomentumVector().R(); }
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last point [GeV/c].
Definition: Trajectory.h:388
Vector_t const& recob::Trajectory::EndMomentumVector ( ) const
inline

Returns the momentum of the trajectory at the last point [GeV/c].

Definition at line 388 of file Trajectory.h.

389  { return MomentumVectorAtPoint(LastPoint()); }
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:175
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
template<typename T >
T recob::Trajectory::EndMomentumVector ( ) const
inline

Momentum vector at end point. Use e.g. as:

TVector3 endmom = traj.EndMomentumVector<TVector3>();

.

Definition at line 573 of file Trajectory.h.

573 { auto mom = EndMomentumVector(); return T(mom.X(),mom.Y(),mom.Z()); }
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last point [GeV/c].
Definition: Trajectory.h:388
template<typename T >
std::pair<T,T> recob::Trajectory::Extent ( ) const
inline

Fills the first and last point in the trajectory.

Parameters
start(output) position of the beginning of the trajectory
end(output) position of the end of the trajectory

The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.

Definition at line 248 of file Trajectory.h.

248 { return { Vertex<T>(),End<T>() }; }
std::pair<Point_t, Point_t> recob::Trajectory::Extent ( ) const
inline

Returns a copy of the first and last point in the trajectory.

Returns
a pair: the first and last point in the trajectory

The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.

Example:

std::tie(start, end) = traj.Extent(); // assign both start and end

Definition at line 266 of file Trajectory.h.

267  { return { Start(), End() }; }
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
Definition: Trajectory.h:226
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:222
size_t recob::Trajectory::FirstPoint ( ) const
inline

Returns the index of the first point in the trajectory (yep, it's 0).

Definition at line 171 of file Trajectory.h.

172  { return 0U; }
recob::Trajectory::Rotation_t recob::Trajectory::GlobalToLocalRotationAtPoint ( size_t  p) const

Returns a rotation matrix that brings trajectory direction along z.

Parameters
pindex of the trajectory point where to apply the rotation
Returns
a rotation matrix suitable to point the trajectory along z

The returned rotation matrix, applied to the direction vector of the trajectory at point p, will make that direction point toward the positive z axis direction, in a sort of "first person view" of the trajectory at that point. If p does not denote a valid trajectory point, the result is undefined.

The return value can be used on a Vector_t to rotate it. For example:

auto rot = traj.GlobalToLocalRotationAtPoint(0);
auto local = rot * traj.DirectionAtPoint(0);

local will be a Vector_t object (like the direction at the right side of the product) that points to (0, 0, 1).

While the transformation that yields the rotation matrix is continuous, the direction of the new "local" x and y axes is not defined.

Definition at line 128 of file Trajectory.cxx.

129 {
131 } // recob::Trajectory::GlobalToLocalRotationAtPoint()
Rotation_t Global3DToLocal3DRotation() const
Calculate rotation matrices from global (x,y,z) to local (u,v,w) coordinates.
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
p
Definition: test.py:223
template<typename T >
T recob::Trajectory::GlobalToLocalRotationAtPoint ( unsigned int  p) const
inline

Returns a rotation matrix that brings trajectory direction along z. Use e.g. as:

TMatrixD rot = traj.GlobalToLocalRotationAtPoint<TMatrixD>(p);

.

Definition at line 579 of file Trajectory.h.

579  {
580  T rot(3,3);
581  GlobalToLocalRotationAtPoint(p).GetRotationMatrix(rot);
582  return rot;
583  }
Rotation_t GlobalToLocalRotationAtPoint(size_t p) const
Returns a rotation matrix that brings trajectory direction along z.
Definition: Trajectory.cxx:128
p
Definition: test.py:223
bool recob::Trajectory::HasMomentum ( ) const
inline

Returns whether information about the momentum is available.

Returns
whether information about the momentum is available

The trajectory may or may not store valid momentum information. If not, the methods returning momentum information will stick to a modulus 1 GeV/c and the momentum numerically matches the direction.

Definition at line 425 of file Trajectory.h.

426  { return fHasMomentum; }
bool fHasMomentum
Whether we have momentum modulus information.
Definition: Trajectory.h:672
bool recob::Trajectory::HasPoint ( size_t  i) const
inline

Returns whether the specified trajectory point is available.

Parameters
iindex of the trajectory point
Returns
whether the specified trajectory point is available.

Definition at line 183 of file Trajectory.h.

184  { return i < NPoints(); }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:167
size_t recob::Trajectory::LastPoint ( ) const
inline

Returns the index of the last point in the trajectory.

Definition at line 175 of file Trajectory.h.

176  { return NPoints() - 1; }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:167
double recob::Trajectory::Length ( size_t  startAt = 0) const

Returns the approximate length of the trajectory.

Parameters
startAt(default: 0, from beginning) point to start from
Returns
the approximate length of the trajectory [cm]

The residual length from the trajectory point startAt to the end of the trajectory is computed and returned. By default, the whole trajectory length is returned. If a non-existing point is specified, 0 is returned.

The length approximation is just the sum of Euclidean distances between all consecutive trajectory points (starting from the one with index startAt).

This operation is slow, and the result should be stored in a variable.

Definition at line 63 of file Trajectory.cxx.

63  {
64 
65  // sanity check
66  if (startAt >= LastPoint()) return 0.;
67 
68  // just sum the distance between all locations in the trajectory
69  Point_t const* curr = &(LocationAtPoint(startAt));
70  Point_t const* next = curr;
71  Point_t const* last = &(End());
72  Coord_t length = 0.0;
73  while (next++ != last) {
74  length += (*next - *curr).R();
75  curr = next;
76  } // while
77  return length;
78 } // recob::Trajectory::Length()
tracking::Coord_t Coord_t
Type used for coordinates and values in general.
Definition: Trajectory.h:70
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> Point_t
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
Definition: Trajectory.h:226
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:175
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:236
recob::Trajectory::Rotation_t recob::Trajectory::LocalToGlobalRotationAtPoint ( size_t  p) const

Returns a rotation matrix bringing relative directions to global.

Parameters
pindex of the trajectory point where to apply the rotation
Returns
a rotation matrix suitable to convert directions to global

The returned rotation matrix, applied to the unit vector (0, 0, 1) (local z axis direction), will turn it into the trajectory direction at point p. If p does not denote a valid trajectory point, the result is undefined.

While the transformation that yields the rotation matrix is continuous, the conversion of the directions orthogonal to the local z is not defined.

Definition at line 136 of file Trajectory.cxx.

137 {
139 } // recob::Trajectory::GlobalToLocalRotationAtPoint()
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
p
Definition: test.py:223
Rotation_t Local3DToGlobal3DRotation() const
Calculate rotation matrices from local (u,v,w) to global (x,y,z) coordinates.
template<typename T >
T recob::Trajectory::LocalToGlobalRotationAtPoint ( unsigned int  p) const
inline

Returns a rotation matrix bringing relative directions to global. Use e.g. as:

TMatrixD rot = traj.LocalToGlobalRotationAtPoint<TMatrixD>(p);

.

Definition at line 586 of file Trajectory.h.

586  {
587  T rot(3,3);
588  LocalToGlobalRotationAtPoint(p).GetRotationMatrix(rot);
589  return rot;
590  }
Rotation_t LocalToGlobalRotationAtPoint(size_t p) const
Returns a rotation matrix bringing relative directions to global.
Definition: Trajectory.cxx:136
p
Definition: test.py:223
Point_t const& recob::Trajectory::LocationAtPoint ( size_t  i) const
inline

Returns the position at the specified trajectory point.

Parameters
iindex of the point in the trajectory
Returns
position at the specified trajectory point [cm]

If the point index is invalid, the result is undefined.

Definition at line 236 of file Trajectory.h.

237  { return fPositions[i]; }
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:669
template<typename T >
T recob::Trajectory::LocationAtPoint ( unsigned int  p) const
inline

Position at point p. Use e.g. as:

TVector3 pos = traj.LocationAtPoint<TVector3>(p);

.

Definition at line 552 of file Trajectory.h.

552 { auto& loc = LocationAtPoint(p); return T(loc.X(),loc.Y(),loc.Z()); }
p
Definition: test.py:223
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:236
template<typename Stream >
void recob::Trajectory::LowLevelDump ( Stream &&  out,
std::string  indent,
std::string  indentFirst 
) const

Prints low-level trajectory content into a stream.

Template Parameters
Streamtype of the output stream
Parameters
outstream to output the information into
indentindentation string (default: none)
indentFirstindentation for first output line (default: as indent)
const Momenta_t& recob::Trajectory::Momenta ( ) const
inline

Returns reference to stored vector of momenta.

Returns
reference to stored vector of momenta

Definition at line 196 of file Trajectory.h.

196 { return fMomenta; }
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:670
double recob::Trajectory::MomentumAtPoint ( size_t  i) const
inline

Computes and returns the modulus of the momentum at a point.

Parameters
iindex of the point in the trajectory
Returns
modulus of the momentum at that point [GeV/c]
See also
HasMomentum()

The modulus of the momentum at the specified trajectory point is computed and returned. If the trajectory does not have momentum information, the value 1 GeV/c is always returned. This can be tested trajectory by trajectory by HasMomentum(). If the index is not valid in the trajectory, the result is undefined.

Definition at line 442 of file Trajectory.h.

443  { return MomentumVectorAtPoint(i).R(); }
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
Vector_t const& recob::Trajectory::MomentumVectorAtPoint ( size_t  i) const
inline

Returns the momentum vector at a point.

Parameters
iindex of the point in the trajectory
Returns
the momentum at that point [GeV/c]
See also
HasMomentum(), MomentumAtPoint(), DirectionAtPoint()

The momentum at the specified trajectory point is returned. If the trajectory does not have momentum information, the returned value will represent the direction, that is a momentum with modulus 1 GeV/c. This can be tested trajectory by trajectory by HasMomentum(). If the index is not valid in the trajectory, the result is undefined.

Definition at line 457 of file Trajectory.h.

458  { return fMomenta[i]; }
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:670
template<typename T >
T recob::Trajectory::MomentumVectorAtPoint ( unsigned int  p) const
inline

Momentum vector at point p. Use e.g. as:

TVector3 mom = traj.MomentumVectorAtPoint<TVector3>(p);

.

Definition at line 576 of file Trajectory.h.

576 { auto mom = MomentumVectorAtPoint(p); return T(mom.X(),mom.Y(),mom.Z()); }
p
Definition: test.py:223
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
size_t recob::Trajectory::NPoints ( ) const
inline

Returns the number of stored trajectory points.

Returns
the number of stored trajectory points
See also
PositionAtPoint(), MomentumVectorAtPoint(), DirectionAtPoint()

For each point, both position and momentum are available.

Definition at line 167 of file Trajectory.h.

168  { return fPositions.size(); }
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:669
size_t recob::Trajectory::NumberTrajectoryPoints ( ) const
inline

Returns the number of stored trajectory points.

Returns
the number of stored trajectory points
See also
PositionAtPoint(), MomentumVectorAtPoint(), DirectionAtPoint()

For each point, both position and momentum are available.

Definition at line 156 of file Trajectory.h.

157  { return NPoints(); }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:167
double recob::Trajectory::Phi ( size_t  p = 0) const
inline

Azimuthal angle at a point on the trajectory, with respect to z.

Parameters
pthe point index to extract the angle from (default: start)
Returns
the azimuthal angle, in $ [-\pi,\pi[ $ [radians]
See also
Theta(), ZenithAngle()

The angle is measured on the plane orthogonal to the z axis, in the same reference where Theta() is measured. The angle is measured counterclockwise from the x axis. Skyward direction is expected to be $ +\pi/2 $ radians in this system, provided that the standard reference frame with the y axis pointing skyward is chosen.

If the point number is invalid, the behaviour is undefined.

Definition at line 337 of file Trajectory.h.

338  { return MomentumVectorAtPoint(p).Phi(); }
p
Definition: test.py:223
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
const Positions_t& recob::Trajectory::Positions ( ) const
inline

Returns reference to stored vector of positions.

Returns
reference to stored vector of positions

Definition at line 190 of file Trajectory.h.

190 { return fPositions; }
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:669
Point_t const& recob::Trajectory::Start ( ) const
inline

Returns the position of the first point of the trajectory [cm].

Definition at line 222 of file Trajectory.h.

223  { return LocationAtPoint(FirstPoint()); }
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:236
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:171
template<typename T >
T recob::Trajectory::Start ( ) const
inline

Start position. Use e.g. as:

TVector3 start = traj.Start<TVector3>();

.

Definition at line 543 of file Trajectory.h.

543 { auto& loc = Start(); return T(loc.X(),loc.Y(),loc.Z()); }
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:222
Vector_t recob::Trajectory::StartDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 299 of file Trajectory.h.

300  { return DirectionAtPoint(FirstPoint()); }
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:171
template<typename T >
T recob::Trajectory::StartDirection ( ) const
inline

Start direction. Use e.g. as:

TVector3 startdir = traj.StartDirection<TVector3>();

.

Definition at line 555 of file Trajectory.h.

555 { auto dir = StartDirection(); return T(dir.X(),dir.Y(),dir.Z()); }
string dir
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:299
double recob::Trajectory::StartMomentum ( ) const
inline

Computes and returns the modulus of momentum at the first point [GeV/c].

Definition at line 397 of file Trajectory.h.

398  { return StartMomentumVector().R(); }
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first point [GeV/c].
Definition: Trajectory.h:384
Vector_t const& recob::Trajectory::StartMomentumVector ( ) const
inline

Returns the momentum of the trajectory at the first point [GeV/c].

Definition at line 384 of file Trajectory.h.

385  { return MomentumVectorAtPoint(FirstPoint()); }
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:171
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
template<typename T >
T recob::Trajectory::StartMomentumVector ( ) const
inline

Momentum vector at start point. Use e.g. as:

TVector3 startmom = traj.StartMomentumVector<TVector3>();

.

Definition at line 567 of file Trajectory.h.

567 { auto mom = StartMomentumVector(); return T(mom.X(),mom.Y(),mom.Z()); }
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first point [GeV/c].
Definition: Trajectory.h:384
double recob::Trajectory::Theta ( size_t  p = 0) const
inline

Trajectory angle at point, with respect to positive z direction.

Parameters
pthe index point to extract the angle from (default: start)
Returns
angle with respect to positive z, in $ [0,\pi] $ [radians]

The reference direction is the positive z axis. Although this usually matches the beam direction, this is not guaranteed and if the explicit angle from beam direction is needed, the scalar product of the beam direction and the direction from StartDirection() should be used instead.

If the point number is invalid, the behaviour is undefined.

Definition at line 320 of file Trajectory.h.

321  { return MomentumVectorAtPoint(p).Theta(); }
p
Definition: test.py:223
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
TrajectoryPoint_t recob::Trajectory::TrajectoryPoint ( size_t  i) const
inline

Returns position and momentum at the specified trajectory point.

Parameters
iindex of the trajectory point
Returns
the information at the specified trajectory point

Note that this method returns the momentum, not the direction.

auto trajPoint = traj.TrajectoryPoint(0);
std::cout << "Start of trajectory at " << trajPoint.position
<< " cm, with momentum " << trajPoint.momentum << " GeV/c"

If the specified index is not valid, result is undefined.

Definition at line 213 of file Trajectory.h.

214  { return { LocationAtPoint(i), MomentumVectorAtPoint(i) }; }
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:236
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:457
Point_t const& recob::Trajectory::Vertex ( void  ) const
inline

Returns the position of the first point of the trajectory [cm].

Definition at line 218 of file Trajectory.h.

219  { return Start(); }
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:222
template<typename T >
T recob::Trajectory::Vertex ( void  ) const
inline

Start position. Use e.g. as:

TVector3 vertex = traj.Vertex<TVector3>();

.

Definition at line 546 of file Trajectory.h.

546 { auto& loc = Vertex(); return T(loc.X(),loc.Y(),loc.Z()); }
Point_t const & Vertex() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:218
Vector_t recob::Trajectory::VertexDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 295 of file Trajectory.h.

296  { return StartDirection(); }
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:299
template<typename T >
T recob::Trajectory::VertexDirection ( ) const
inline

Start direction. Use e.g. as:

TVector3 vertexdir = traj.VertexDirection<TVector3>();

.

Definition at line 558 of file Trajectory.h.

558 { auto dir = VertexDirection(); return T(dir.X(),dir.Y(),dir.Z()); }
string dir
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:295
double recob::Trajectory::VertexMomentum ( ) const
inline

Computes and returns the modulus of momentum at the first point [GeV/c].

Definition at line 393 of file Trajectory.h.

394  { return StartMomentum(); }
double StartMomentum() const
Computes and returns the modulus of momentum at the first point [GeV/c].
Definition: Trajectory.h:397
Vector_t const& recob::Trajectory::VertexMomentumVector ( ) const
inline

Returns the momentum of the trajectory at the first point [GeV/c].

Definition at line 380 of file Trajectory.h.

381  { return StartMomentumVector(); }
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first point [GeV/c].
Definition: Trajectory.h:384
template<typename T >
T recob::Trajectory::VertexMomentumVector ( ) const
inline

Momentum vector at start point. Use e.g. as:

TVector3 vertexmom = traj.VertexMomentumVector<TVector3>();

.

Definition at line 570 of file Trajectory.h.

570 { auto mom = VertexMomentumVector(); return T(mom.X(),mom.Y(),mom.Z()); }
Vector_t const & VertexMomentumVector() const
Returns the momentum of the trajectory at the first point [GeV/c].
Definition: Trajectory.h:380
double recob::Trajectory::ZenithAngle ( size_t  p = 0) const

"Zenith" angle of trajectory, with respect to the vertical axis.

Parameters
pthe point index to extract the angle from (default: start)
Returns
opposite of the actual zenith angle, in $ [0,\pi] $ [radians]
See also
AzimuthAngle()

The angle is defined with respect to the negative y direction. It describes the angle at the specified point on the trajectory. Therefore, a trajectory starting along the positive y direction returns $ \pi $ radians, while a trajectory going downward along the negative y direction returns 0.

This is designed so that vertical cosmic rays produce trajectories with angle 0 radians.

If the point number is invalid, the behaviour is undefined.

Definition at line 82 of file Trajectory.cxx.

82  {
83 
84  // The zenith angle is defined by the angle between the track starting
85  // direction and the y axis.
86  // The y component of the starting direction is in fact the cosine of that
87  // angle (and std::acos() conveniently returns a value in [0;pi]).
88  // Our convention has the zenith angle the supplemental of the standard one.
89 
90  return util::pi<Coord_t>() - std::acos(DirectionAtPoint(p).Y());
91 
92 } // recob::Trajectory::ZenithAngle()
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:117
p
Definition: test.py:223

Member Data Documentation

bool recob::Trajectory::fHasMomentum = true
private

Whether we have momentum modulus information.

Definition at line 672 of file Trajectory.h.

Momenta_t recob::Trajectory::fMomenta
private

Momentum of each of the points in trajectory.

Definition at line 670 of file Trajectory.h.

Positions_t recob::Trajectory::fPositions
private

List of points the trajectory goes through.

Definition at line 669 of file Trajectory.h.

constexpr unsigned int recob::Trajectory::MaxDumpVerbosity = 6
static

Largest verbosity level supported by Dump().

Definition at line 662 of file Trajectory.h.


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