LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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...
 
bool TrajectoryAtPoint (size_t i, TVector3 &pos, TVector3 &dir) const
 Fills position and direction at the specified trajectory point. 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...
 
void Extent (std::vector< double > &start, std::vector< double > &end) 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
size_t NumberFitMomentum () const
 Returns the number of stored momenta. More...
 
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...
 
void Direction (double *start, double *end) 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...
 
void GlobalToLocalRotationAtPoint (unsigned int p, TMatrixD &rot) const
 Fills 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...
 
void LocalToGlobalRotationAtPoint (unsigned int p, TMatrixD &rot) const
 Fills a rotation matrix bringing relative directions to global. 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).

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

  • there must be at least two trajectory points;
  • there must be one momentum per position; recob::trackutil::makeTrajectory() can make up a simple momentum vector from the trajectory, for algorithms reconstructing the trajectory which do not estimate momenta; Trajectory::HasMomentum() reports whether momentum modulus information is available;
  • a list of hits associated with the trajectory is considered a mandatory part of the trajectory information; see recob::TrajectoryCollectionMaker.

Definition at line 72 of file Trajectory.h.

Member Typedef Documentation

Type used for coordinates and values in general.

Definition at line 75 of file Trajectory.h.

Type of momentum list.

Definition at line 87 of file Trajectory.h.

Type for representation of position in physical 3D space.

Definition at line 78 of file Trajectory.h.

Type of trajectory point list.

Definition at line 84 of file Trajectory.h.

Type for representation of space rotations.

Definition at line 102 of file Trajectory.h.

A point in the trajectory, with position and momentum.

Definition at line 99 of file Trajectory.h.

Type for representation of momenta in 3D space.

Definition at line 81 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 90 of file Trajectory.h.

90  {
91  kStart,
92  kVertex = kStart,
93  kEnd,
94  NEnds
95  }; // enum Ends_t
Index representing the end of the trajectory.
Definition: Trajectory.h:93
Index representing the start of the trajectory.
Definition: Trajectory.h:91
Index representing the start of the trajectory.
Definition: Trajectory.h:92
Number of ends.
Definition: Trajectory.h:94

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 42 of file Trajectory.cxx.

References util::flags::to_string(), and TrajectoryAtPoint().

43  : fPositions(std::move(positions))
44  , fMomenta(std::move(momenta))
45  , fHasMomentum(hasMomenta)
46 {
47  // invariant check
48  if (fPositions.size() != fMomenta.size()) {
49  throw std::runtime_error("recob::Trajectory constructed with "
50  + std::to_string(fPositions.size()) + " positions and "
51  + std::to_string(fMomenta.size())
52  + " momenta! it requires the same number for both."
53  );
54  }
55  if (fPositions.size() < 2) {
56  throw std::runtime_error("recob::Trajectory constructed with "
57  + std::to_string(fPositions.size())
58  + " trajectory points! it requires at least 2."
59  );
60  }
61 } // recob::Trajectory::Trajectory()
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:674
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:673
bool fHasMomentum
Whether we have momentum modulus information.
Definition: Trajectory.h:676
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
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 141 of file Trajectory.h.

146  : Trajectory(Positions_t(positions), Momenta_t(momenta), hasMomenta)
147  {}
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:84
tracking::Momenta_t Momenta_t
Type of momentum list.
Definition: Trajectory.h:87

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 136 of file Trajectory.cxx.

References DirectionAtPoint().

Referenced by recob::TrackTrajectory::AzimuthAngle(), and Phi().

136  {
137  //
138  // std::atan2(y, x) returns the angle of a point (x,y) respect to x axis.
139  // In our case, the definition of the angle (0 for z axis, pi/2 for x axis)
140  // translates atan2's y into our x, and x into z.
141  //
142  decltype(auto) startDir = DirectionAtPoint(p);
143  return std::atan2(startDir.X(), startDir.Z());
144 } // 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:157
Float_t Z
Definition: plot.C:39
Float_t X
Definition: plot.C:39
void recob::Trajectory::Direction ( double *  start,
double *  end 
) const

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.

Deprecated:
Use physics vectors instead (see Direction())

Definition at line 167 of file Trajectory.cxx.

References EndDirection(), recob::details::legacy::FillTwoVectors(), GlobalToLocalRotationAtPoint(), and StartDirection().

Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
Definition: Trajectory.h:338
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:334
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void FillTwoVectors(SrcVect const &firstSource, SrcVect const &secondSource, DestVect &&firstDest, DestVect &&secondDest)
Converts two vectors into another type of vector using FillVector.
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 529 of file Trajectory.h.

References Dump(), EndDirection(), GlobalToLocalRotationAtPoint(), art::detail::indent(), LocalToGlobalRotationAtPoint(), and StartDirection().

Referenced by MomentumVectorAtPoint().

530  { return { StartDirection(), EndDirection() }; }
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
Definition: Trajectory.h:338
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:334
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 157 of file Trajectory.cxx.

References HasMomentum(), and MomentumVectorAtPoint().

Referenced by AzimuthAngle(), recob::Track::DirectionAtPoint(), recob::TrackTrajectory::EndDirection(), EndDirection(), EndMomentum(), recob::TrackTrajectory::EndMomentum(), trkf::BezierTrack::FillSeedVector(), GlobalToLocalRotationAtPoint(), trkf::TrajectoryMCSFitter::linearRegression(), LocalToGlobalRotationAtPoint(), trkf::KalmanFilterTrajectoryFitter::restoreInputPoints(), trkf::KalmanFilterFinalTrackFitter::restoreInputPoints(), recob::TrackTrajectory::StartDirection(), StartDirection(), and ZenithAngle().

158 {
159 
160  auto const& mom = MomentumVectorAtPoint(i);
161  return HasMomentum()? (mom / mom.R()): mom;
162 
163 } // recob::Trajectory::DirectionAtPoint()
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:460
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

Referenced by Direction(), lar::example::CheatTrack::dump(), and Dump().

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 649 of file Trajectory.h.

References Dump(), and LowLevelDump().

649  {})
650  const
651  { Dump(std::forward<Stream>(out), verbosity, indent, indent); }
std::string indent(std::size_t const i)
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 ( ) const
inline

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

Definition at line 244 of file Trajectory.h.

References LastPoint(), and LocationAtPoint().

Referenced by Extent(), trkf::BezierTrack::GetTrackPoint(), and Length().

245  { return LocationAtPoint(LastPoint()); }
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:180
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:255
Vector_t recob::Trajectory::EndDirection ( ) const
inline

Returns the direction of the trajectory at the last point.

Definition at line 338 of file Trajectory.h.

References DirectionAtPoint(), and LastPoint().

Referenced by Direction().

339  { return DirectionAtPoint(LastPoint()); }
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:180
double recob::Trajectory::EndMomentum ( ) const
inline

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

Definition at line 436 of file Trajectory.h.

References DirectionAtPoint(), and EndMomentumVector().

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

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

Definition at line 423 of file Trajectory.h.

References LastPoint(), and MomentumVectorAtPoint().

Referenced by EndMomentum().

424  { return MomentumVectorAtPoint(LastPoint()); }
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:180
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
void recob::Trajectory::Extent ( std::vector< double > &  start,
std::vector< double > &  end 
) const

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.

Deprecated:
Use physics vectors instead (see Extent())

Definition at line 81 of file Trajectory.cxx.

References recob::details::legacy::FillTwoVectors().

82  { details::legacy::FillTwoVectors(Start(), End(), start, end); }
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
Definition: Trajectory.h:244
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:240
void FillTwoVectors(SrcVect const &firstSource, SrcVect const &secondSource, DestVect &&firstDest, DestVect &&secondDest)
Converts two vectors into another type of vector using FillVector.
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 288 of file Trajectory.h.

References End(), Length(), and Start().

Referenced by LocationAtPoint(), and TrajectoryAtPoint().

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

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

Definition at line 176 of file Trajectory.h.

Referenced by recob::Track::FirstPoint(), Start(), StartDirection(), StartMomentumVector(), and recob::TrackTrajectory::Trajectory().

177  { 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 173 of file Trajectory.cxx.

References DirectionAtPoint(), and recob::tracking::Plane::Global3DToLocal3DRotation().

Referenced by Direction(), recob::TrackTrajectory::Direction(), recob::Track::GlobalToLocalRotationAtPoint(), and GlobalToLocalRotationAtPoint().

174 {
176 } // 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:157
void recob::Trajectory::GlobalToLocalRotationAtPoint ( unsigned int  p,
TMatrixD &  rot 
) const

Fills a rotation matrix that brings trajectory direction along z.

Parameters
pindex of the trajectory point where to apply the rotation
rot(output) the rotation matrix to be filled
Deprecated:
Use GlobalToLocalRotationAtPoint(size_t) instead.

Definition at line 181 of file Trajectory.cxx.

References GlobalToLocalRotationAtPoint(), and LocalToGlobalRotationAtPoint().

182 {
183  auto trackRot = GlobalToLocalRotationAtPoint(p);
184  fillTMatrixD(trackRot, rot);
185 } // recob::Trajectory::GlobalToLocalRotationAtPoint(TMatrixD)
Rotation_t GlobalToLocalRotationAtPoint(size_t p) const
Returns a rotation matrix that brings trajectory direction along z.
Definition: Trajectory.cxx:173
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 460 of file Trajectory.h.

References fHasMomentum.

Referenced by DirectionAtPoint(), recob::TrackTrajectory::EndMomentum(), recob::Track::FlagsAtPoint(), recob::TrackTrajectory::NumberFitMomentum(), NumberFitMomentum(), and trkmkr::KalmanFilterFitTrackMaker::restoreInputPoints().

461  { return fHasMomentum; }
bool fHasMomentum
Whether we have momentum modulus information.
Definition: Trajectory.h:676
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 188 of file Trajectory.h.

References NPoints().

Referenced by recob::Track::HasPoint(), recob::TrackTrajectory::HasValidPoint(), and recob::TrackTrajectory::Trajectory().

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

Returns the index of the last point in the trajectory.

Definition at line 180 of file Trajectory.h.

References NPoints().

Referenced by End(), EndDirection(), EndMomentumVector(), recob::Track::LastPoint(), recob::TrackTrajectory::LastValidPoint(), Length(), recob::TrackTrajectory::Length(), and recob::TrackTrajectory::Trajectory().

181  { return NPoints() - 1; }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:172
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 103 of file Trajectory.cxx.

References End(), LastPoint(), LocationAtPoint(), and R.

Referenced by Extent(), and opdet::TrackTimeAssoc::ScanMIPHypotheses().

103  {
104 
105  // sanity check
106  if (startAt >= LastPoint()) return 0.;
107 
108  // just sum the distance between all locations in the trajectory
109  Point_t const* curr = &(LocationAtPoint(startAt));
110  Point_t const* next = curr;
111  Point_t const* last = &(End());
112  Coord_t length = 0.0;
113  while (next++ != last) {
114  length += (*next - *curr).R();
115  curr = next;
116  } // while
117  return length;
118 } // recob::Trajectory::Length()
tracking::Coord_t Coord_t
Type used for coordinates and values in general.
Definition: Trajectory.h:75
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
Definition: Trajectory.h:244
recob::tracking::Point_t Point_t
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:180
Double_t R
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:255
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 190 of file Trajectory.cxx.

References DirectionAtPoint(), and recob::tracking::Plane::Local3DToGlobal3DRotation().

Referenced by Direction(), recob::TrackTrajectory::Direction(), GlobalToLocalRotationAtPoint(), recob::Track::LocalToGlobalRotationAtPoint(), and LocalToGlobalRotationAtPoint().

191 {
193 } // recob::Trajectory::GlobalToLocalRotationAtPoint()
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157
Rotation_t Local3DToGlobal3DRotation() const
Calculate rotation matrices from local (u,v,w) to global (x,y,z) coordinates.
void recob::Trajectory::LocalToGlobalRotationAtPoint ( unsigned int  p,
TMatrixD &  rot 
) const

Fills a rotation matrix bringing relative directions to global.

Parameters
pindex of the trajectory point where to apply the rotation
rot(output) the rotation matrix to be filled
Deprecated:
Use LocalToGlobalRotationAtPoint(size_t) instead.

Definition at line 198 of file Trajectory.cxx.

References LocalToGlobalRotationAtPoint().

199 {
200  auto trackRot = LocalToGlobalRotationAtPoint(p);
201  fillTMatrixD(trackRot, rot);
202 } // recob::Trajectory::LocalToGlobalRotationAtPoint(TMatrixD)
Rotation_t LocalToGlobalRotationAtPoint(size_t p) const
Returns a rotation matrix bringing relative directions to global.
Definition: Trajectory.cxx:190
Point_t const& recob::Trajectory::LocationAtPoint ( size_t  i) const
inline
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)

Referenced by Dump().

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 201 of file Trajectory.h.

References dir, fMomenta, and TrajectoryAtPoint().

201 { return fMomenta; }
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:674
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 477 of file Trajectory.h.

References MomentumVectorAtPoint().

Referenced by recob::TrackTrajectory::EndMomentum(), and recob::Track::MomentumAtPoint().

478  { return MomentumVectorAtPoint(i).R(); }
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
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 492 of file Trajectory.h.

References Direction(), and fMomenta.

Referenced by DirectionAtPoint(), recob::TrackTrajectory::EndMomentum(), EndMomentumVector(), recob::TrackTrajectory::EndMomentumVector(), MomentumAtPoint(), recob::Track::MomentumVectorAtPoint(), Phi(), trkmkr::KalmanFilterFitTrackMaker::restoreInputPoints(), StartMomentumVector(), recob::TrackTrajectory::StartMomentumVector(), Theta(), and TrajectoryPoint().

493  { return fMomenta[i]; }
Momenta_t fMomenta
Momentum of each of the points in trajectory.
Definition: Trajectory.h:674
size_t recob::Trajectory::NPoints ( ) const
inline

Returns the number of stored trajectory points.

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

For each point, both position and momentum are available.

Definition at line 172 of file Trajectory.h.

References fPositions.

Referenced by recob::TrackTrajectory::AtLeastValidTrajectoryPoints(), recob::TrackTrajectory::CountValidPoints(), trkf::TrajectoryMCSFitter::fitMcs(), HasPoint(), trkmkr::TrackMaker::initEvent(), LastPoint(), trkmkr::TrackMaker::makeTrack(), recob::Track::NPoints(), recob::TrackTrajectory::NumberFitMomentum(), NumberFitMomentum(), NumberTrajectoryPoints(), recob::TrackTrajectory::TrackTrajectory(), and recob::TrackTrajectory::Trajectory().

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

Returns the number of stored momenta.

It's the same as trajectory points, unless there is no momentum (then it's 0).

Deprecated:
Use NumberTrajectoryPoints() instead

Definition at line 325 of file Trajectory.h.

References HasMomentum(), and NPoints().

326  { return HasMomentum()? NPoints(): 0U; }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:172
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:460
size_t recob::Trajectory::NumberTrajectoryPoints ( ) const
inline

Returns the number of stored trajectory points.

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

For each point, both position and momentum are available.

Definition at line 161 of file Trajectory.h.

References NPoints().

Referenced by trkf::BezierTrack::NSegments(), recob::Track::Trajectory(), and recob::TrackTrajectory::Trajectory().

162  { return NPoints(); }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:172
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 372 of file Trajectory.h.

References AzimuthAngle(), MomentumVectorAtPoint(), and ZenithAngle().

Referenced by recob::TrackTrajectory::Phi().

373  { return MomentumVectorAtPoint(p).Phi(); }
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
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 195 of file Trajectory.h.

References fPositions.

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

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

Definition at line 240 of file Trajectory.h.

References FirstPoint(), and LocationAtPoint().

Referenced by Extent(), trkf::BezierTrack::GetTrackPoint(), opdet::TrackTimeAssoc::ScanMIPHypotheses(), and Vertex().

241  { return LocationAtPoint(FirstPoint()); }
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:255
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:176
Vector_t recob::Trajectory::StartDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 334 of file Trajectory.h.

References DirectionAtPoint(), and FirstPoint().

Referenced by Direction(), and VertexDirection().

335  { return DirectionAtPoint(FirstPoint()); }
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:176
double recob::Trajectory::StartMomentum ( ) const
inline

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

Definition at line 432 of file Trajectory.h.

References StartMomentumVector().

Referenced by lar::example::CheatTrack::momentum(), and VertexMomentum().

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

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

Definition at line 419 of file Trajectory.h.

References FirstPoint(), and MomentumVectorAtPoint().

Referenced by StartMomentum(), and VertexMomentumVector().

420  { 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:176
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
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 355 of file Trajectory.h.

References MomentumVectorAtPoint().

Referenced by recob::TrackTrajectory::Theta().

356  { return MomentumVectorAtPoint(p).Theta(); }
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
bool recob::Trajectory::TrajectoryAtPoint ( size_t  i,
TVector3 &  pos,
TVector3 &  dir 
) const

Fills position and direction at the specified trajectory point.

Parameters
iindex of the trajectory point
pos(output) filled with the position at the given point [cm]
dir(output) filled with the direction at the given point
Returns
false if the specified point was invalid
Deprecated:
Use TrajectoryPoint() instead (and note that it returns momentum, not direction!)

Definition at line 66 of file Trajectory.cxx.

References Extent().

Referenced by Momenta(), Trajectory(), recob::TrackTrajectory::Trajectory(), and recob::Track::TrajectoryAtPoint().

67 {
68  if (!HasPoint(i)) return false;
69 
70  auto const& origPos = LocationAtPoint(i);
71  decltype(auto) origDir = DirectionAtPoint(i);
72 
73  pos.SetXYZ(origPos.X(), origPos.Y(), origPos.Z());
74  dir.SetXYZ(origDir.X(), origDir.Y(), origDir.Z());
75  return true;
76 } // recob::Trajectory::TrajectoryAtPoint(TVector&)
bool HasPoint(size_t i) const
Returns whether the specified trajectory point is available.
Definition: Trajectory.h:188
Float_t Y
Definition: plot.C:39
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157
Float_t Z
Definition: plot.C:39
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:255
TDirectory * dir
Definition: macro.C:5
Float_t X
Definition: plot.C:39
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"
<< std::endl;

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

Definition at line 231 of file Trajectory.h.

References LocationAtPoint(), and MomentumVectorAtPoint().

Referenced by recob::Track::CountValidPoints(), and recob::TrackTrajectory::LastValidPoint().

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

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

Definition at line 236 of file Trajectory.h.

References Start().

237  { return Start(); }
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Definition: Trajectory.h:240
Vector_t recob::Trajectory::VertexDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 330 of file Trajectory.h.

References StartDirection().

331  { return StartDirection(); }
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Definition: Trajectory.h:334
double recob::Trajectory::VertexMomentum ( ) const
inline

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

Definition at line 428 of file Trajectory.h.

References StartMomentum().

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

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

Definition at line 415 of file Trajectory.h.

References StartMomentumVector().

416  { return StartMomentumVector(); }
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first point [GeV/c].
Definition: Trajectory.h:419
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 122 of file Trajectory.cxx.

References DirectionAtPoint().

Referenced by Phi(), and recob::TrackTrajectory::ZenithAngle().

122  {
123 
124  // The zenith angle is defined by the angle between the track starting
125  // direction and the y axis.
126  // The y component of the starting direction is in fact the cosine of that
127  // angle (and std::acos() conveniently returns a value in [0;pi]).
128  // Our convention has the zenith angle the supplemental of the standard one.
129 
130  return util::pi<Coord_t>() - std::acos(DirectionAtPoint(p).Y());
131 
132 } // recob::Trajectory::ZenithAngle()
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157

Member Data Documentation

bool recob::Trajectory::fHasMomentum = true
private

Whether we have momentum modulus information.

Definition at line 676 of file Trajectory.h.

Referenced by HasMomentum().

Momenta_t recob::Trajectory::fMomenta
private

Momentum of each of the points in trajectory.

Definition at line 674 of file Trajectory.h.

Referenced by Momenta(), and MomentumVectorAtPoint().

Positions_t recob::Trajectory::fPositions
private

List of points the trajectory goes through.

Definition at line 673 of file Trajectory.h.

Referenced by LocationAtPoint(), NPoints(), and Positions().

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

Largest verbosity level supported by Dump().

Definition at line 666 of file Trajectory.h.


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