LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
recob::TrackTrajectory Class Reference

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

#include "TrackTrajectory.h"

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

Public Types

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 PointFlags_t = recob::TrajectoryPointFlags
 Type for flags of a point/hit. More...
 
using flag = PointFlags_t::flag
 Flag traits (including the definition of flag mnemonics). 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 Flags_t = std::vector< PointFlags_t >
 Type of point flag list. More...
 
using Ends_t = Trajectory_t::Ends_t
 Mnemonics for the access to begin and end of trajectory. 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

 TrackTrajectory ()=default
 Default constructor; do not use it! it's needed by ROOT I/O. More...
 
 TrackTrajectory (Positions_t &&positions, Momenta_t &&momenta, Flags_t &&flags, bool hasMomenta)
 Constructor: specifies all the data for the trajectory. More...
 
 TrackTrajectory (const Trajectory &traj, Flags_t &&flags)
 Constructor: copies positions and momenta from an existing Trajectory, adds the flags. More...
 
Trajectory_t const & Trajectory () const
 Returns the plain trajectory of this object. More...
 
PointFlags_t const & FlagsAtPoint (size_t i) const
 Returns the flags for the specified trajectory point. More...
 
Flags_t const & Flags () const
 Returns all flags. More...
 
bool HasValidPoint (size_t i) const
 Returns whether the specified point has NoPoint flag unset. More...
 
size_t FirstValidPoint () const
 Returns the index of the first valid point in the trajectory. More...
 
size_t NextValidPoint (size_t index) const
 Returns the index of the next valid point in the trajectory. More...
 
size_t PreviousValidPoint (size_t index) const
 Returns the index of the previous valid point in the trajectory. More...
 
size_t LastValidPoint () const
 Returns the index of the last valid point in the trajectory. More...
 
unsigned int CountValidPoints () const
 Computes and returns the number of points with valid location. More...
 
Point_t const & Vertex () const
 Returns the position of the first valid point of the trajectory [cm]. More...
 
Point_t const & Start () const
 Returns the position of the first valid point of the trajectory [cm]. More...
 
Point_t const & End () const
 Returns the position of the last valid point of the trajectory [cm]. More...
 
template<typename T >
std::pair< T, T > Extent () const
 Fills the first and last valid point in the trajectory. More...
 
std::pair< Point_t, Point_tExtent () const
 Returns a copy of the first and last valid point in the trajectory. More...
 
double Length (size_t startAt=0) const
 Returns the approximate length of the trajectory. 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) const
 Trajectory angle at point, with respect to positive z direction. More...
 
double Theta () const
 Trajectory angle at start, with respect to positive z direction. More...
 
double Phi (size_t p) const
 Azimuthal angle at a point on the trajectory, with respect to z. More...
 
double Phi () const
 Azimuthal angle at a first valid point, with respect to z. More...
 
double ZenithAngle (size_t p) const
 "Zenith" angle of trajectory, with respect to the vertical axis. More...
 
double ZenithAngle () const
 "Zenith" angle of trajectory, with respect to the vertical axis. More...
 
double AzimuthAngle (size_t p) const
 "Azimuth" angle of trajectory, with respect to the sky. More...
 
double AzimuthAngle () 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 valid point [GeV/c]. More...
 
Vector_t const & StartMomentumVector () const
 Returns the momentum of the trajectory at the first valid point [GeV/c]. More...
 
Vector_t const & EndMomentumVector () const
 Returns the momentum of the trajectory at the last valid point [GeV/c]. More...
 
double VertexMomentum () const
 
double StartMomentum () const
 
double EndMomentum () const
 
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 valid points. 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...
 
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 = 7
 Largest verbosity level supported by Dump(). More...
 
static constexpr size_t InvalidIndex = std::numeric_limits<size_t>::max()
 Value returned on failed index queries. More...
 

Private Types

using Trajectory_t = recob::Trajectory
 

Private Member Functions

template<int Dir>
size_t ToValidPoint (size_t index) const
 Returns the index of the first valid point from index on. More...
 
bool AtLeastValidTrajectoryPoints (unsigned int left) const
 Returns whether there are at least min valid points in the trajectory. 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 & LocationAtPoint (size_t i) const
 Returns the position at the specified trajectory point. More...
 
Access to direction and momentum information
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...
 
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...
 

Private Attributes

Flags_t fFlags
 Flags of each of the points in trajectory. More...
 

Detailed Description

A trajectory in space reconstructed from hits.


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

The track 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 associated hits are integral part of the track trajectory. To store additional point-by-point information, the track trajectory augments recob::Trajectory, of which it presents most of the interface, with point metadata called for convenience "flags".

Each point is formally associated to a reconstructed hit, as for recob::Trajectory requirements. One flag set is provided for each point, whose flags describe the point and/or the hit.

The meaning of the flags is documented also in the flags class recob::TrajectoryPointFlagTraits, which can be accessed as typedef flags in this class (e.g. recob::TrackTrajectory::flag::NoPoint).

Invariants

The same as recob::Trajectory, plus:

  • there must be one flag set per trajectory point
  • there must be at least two points with the flag NoPoint not set

Definition at line 60 of file TrackTrajectory.h.

Member Typedef Documentation

Type used for coordinates and values in general.

Definition at line 65 of file TrackTrajectory.h.

Mnemonics for the access to begin and end of trajectory.

Definition at line 89 of file TrackTrajectory.h.

Flag traits (including the definition of flag mnemonics).

Definition at line 77 of file TrackTrajectory.h.

Type of point flag list.

Definition at line 86 of file TrackTrajectory.h.

Type of momentum list.

Definition at line 83 of file TrackTrajectory.h.

Type for representation of position in physical 3D space.

Definition at line 68 of file TrackTrajectory.h.

Type for flags of a point/hit.

Definition at line 74 of file TrackTrajectory.h.

Type of trajectory point list.

Definition at line 80 of file TrackTrajectory.h.

Type for representation of space rotations.

Definition at line 95 of file TrackTrajectory.h.

Definition at line 61 of file TrackTrajectory.h.

A point in the trajectory, with position and momentum.

Definition at line 92 of file TrackTrajectory.h.

Type for representation of momenta in 3D space.

Definition at line 71 of file TrackTrajectory.h.

Constructor & Destructor Documentation

recob::TrackTrajectory::TrackTrajectory ( )
default

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

recob::TrackTrajectory::TrackTrajectory ( Positions_t &&  positions,
Momenta_t &&  momenta,
Flags_t &&  flags,
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
flags(moved) flag sets, one flag set per point
hasMomentawhether the information on momentum modulus is provided
Exceptions
std::runtime_errorif the invariants are violated
See also
recob::trackutil::makeTrackTrajectory()

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

Requirements

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

Definition at line 17 of file TrackTrajectory.cxx.

References AtLeastValidTrajectoryPoints(), CountValidPoints(), fFlags, recob::Trajectory::NPoints(), and util::to_string().

21  : Trajectory_t(std::move(positions), std::move(momenta), hasMomenta), fFlags(std::move(flags))
22 {
23  // additional invariant check
24  if (fFlags.size() != NPoints()) {
25  throw std::runtime_error(
26  "recob::TrackTrajectory constructed with " + std::to_string(NPoints()) + " points " +
27  std::to_string(fFlags.size()) + " point flags! it requires the same number for both.");
28  }
30  throw std::runtime_error("recob::TrackTrajectory constructed with only " +
32  " valid positions! at least 2 are required.");
33  }
34 } // recob::TrackTrajectory::TrackTrajectory()
unsigned int CountValidPoints() const
Computes and returns the number of points with valid location.
Flags_t fFlags
Flags of each of the points in trajectory.
recob::Trajectory Trajectory_t
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
bool AtLeastValidTrajectoryPoints(unsigned int left) const
Returns whether there are at least min valid points in the trajectory.
recob::TrackTrajectory::TrackTrajectory ( const Trajectory traj,
Flags_t &&  flags 
)
inline

Constructor: copies positions and momenta from an existing Trajectory, adds the flags.

Parameters
trajexisting Trajectory
flags(moved) flag sets, one flag set per point
Exceptions
std::runtime_errorif the invariants are violated

Definition at line 129 of file TrackTrajectory.h.

130  : TrackTrajectory(Positions_t(traj.Positions()),
131  Momenta_t(traj.Momenta()),
132  std::move(flags),
133  traj.HasMomentum())
134  {}
TrackTrajectory()=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.
tracking::Momenta_t Momenta_t
Type of momentum list.

Member Function Documentation

bool recob::TrackTrajectory::AtLeastValidTrajectoryPoints ( unsigned int  left) const
private

Returns whether there are at least min valid points in the trajectory.

Definition at line 86 of file TrackTrajectory.cxx.

References HasValidPoint(), art::left(), and recob::Trajectory::NPoints().

Referenced by TrackTrajectory().

87 {
88  if (min == 0) return true;
89  unsigned int left = min;
90  for (size_t i = 0; i < NPoints(); ++i) {
91  if (!HasValidPoint(i)) continue;
92  if (--left == 0) return true;
93  } // for
94  return false;
95 
96 } // moreThanTwoValidTrajectoryPoints()
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
bool HasValidPoint(size_t i) const
Returns whether the specified point has NoPoint flag unset.
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
double recob::TrackTrajectory::AzimuthAngle ( size_t  p) const
inline

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

Parameters
pthe index point to extract the angle from (no default!)
Returns
the azimuth angle, in $ [-\pi,\pi[ $ [radians]
See also
AzimuthAngle(), ZenithAngle(size_t), Phi(size_t)

The azimuth is returned, as defined in recob::Trajectory::Azimuth(), for point with the specified index p.

If the point is invalid, the behaviour is undefined.

Note
This function has no default value for p; if p is not specified at all, the method Azimuth() is called instead.

Definition at line 409 of file TrackTrajectory.h.

References recob::Trajectory::AzimuthAngle(), and Trajectory().

Referenced by recob::Track::AzimuthAngle().

409 { return Trajectory().AzimuthAngle(p); }
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
double AzimuthAngle(size_t p=0) const
"Azimuth" angle of trajectory, with respect to the sky.
Definition: Trajectory.cxx:88
double recob::TrackTrajectory::AzimuthAngle ( ) const
inline

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

Returns
the azimuth angle, in $ [-\pi,\pi[ $ [radians]
See also
AzimuthAngle(size_t), ZenithAngle(), Phi()
Zenith(size_t), Theta()

The azimuth angle is returned, as defined in recob::Trajectory::Azimuth(), for the first valid point in the trajectory.

Note
This is not equivalent to Azimuth(0), but instead to Azimuth(FirstValidPoint()).

Definition at line 424 of file TrackTrajectory.h.

References AzimuthAngle(), and FirstValidPoint().

Referenced by AzimuthAngle().

424 { return AzimuthAngle(FirstValidPoint()); }
double AzimuthAngle() const
"Azimuth" angle of trajectory, with respect to the sky.
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
unsigned int recob::TrackTrajectory::CountValidPoints ( ) const

Computes and returns the number of points with valid location.

Returns
number of points in the trajectory with valid location

This method is slow, taking O(NPoints()) time.

Definition at line 37 of file TrackTrajectory.cxx.

References HasValidPoint(), and recob::Trajectory::NPoints().

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

38 {
39 
40  unsigned int count = 0;
41  for (size_t index = 0; index < NPoints(); ++index) {
42  if (HasValidPoint(index)) ++count;
43  } // for
44  return count;
45 
46 } // recob::TrackTrajectory::CountValidPoints()
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
bool HasValidPoint(size_t i) const
Returns whether the specified point has NoPoint flag unset.
template<typename T >
std::pair<T, T> recob::TrackTrajectory::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 468 of file TrackTrajectory.h.

Referenced by recob::Track::Direction().

469  {
470  return {VertexDirection<T>(), EndDirection<T>()};
471  }
std::pair<Vector_t, Vector_t> recob::TrackTrajectory::Direction ( ) const
inline

Returns the trajectory directions at first and last valid points.

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 490 of file TrackTrajectory.h.

References EndDirection(), recob::Trajectory::GlobalToLocalRotationAtPoint(), recob::Trajectory::LocalToGlobalRotationAtPoint(), and StartDirection().

490 { return {StartDirection(), EndDirection()}; }
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
recob::Trajectory::Vector_t recob::Trajectory::DirectionAtPoint ( size_t  i) const
inherited

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

References recob::Trajectory::HasMomentum(), and recob::Trajectory::MomentumVectorAtPoint().

Referenced by recob::Trajectory::AzimuthAngle(), recob::Trajectory::DirectionAtPoint(), recob::Trajectory::EndDirection(), recob::Trajectory::EndMomentum(), EndMomentum(), recob::Trajectory::GlobalToLocalRotationAtPoint(), recob::Trajectory::LocalToGlobalRotationAtPoint(), trkf::KalmanFilterFinalTrackFitter::restoreInputPoints(), recob::Trajectory::StartDirection(), and recob::Trajectory::ZenithAngle().

110 {
111 
112  auto const& mom = MomentumVectorAtPoint(i);
113  return HasMomentum() ? (mom / mom.R()) : mom;
114 
115 } // recob::Trajectory::DirectionAtPoint()
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:416
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:387
template<typename T >
T recob::TrackTrajectory::DirectionAtPoint ( unsigned int  p) const
inline

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

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

.

Definition at line 557 of file TrackTrajectory.h.

References dir.

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), recob::Track::DirectionAtPoint(), EndDirection(), trkf::TrajectoryMCSFitter::linearRegression(), trkf::KalmanFilterTrajectoryFitter::restoreInputPoints(), and StartDirection().

558  {
559  auto dir = DirectionAtPoint(p);
560  return T(dir.X(), dir.Y(), dir.Z());
561  }
T DirectionAtPoint(unsigned int p) const
Direction at point p. Use e.g. as:
TDirectory * dir
Definition: macro.C:5
template<typename Stream >
void recob::TrackTrajectory::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 valid trajectory points
  • level 5: also 10 more intermediate valid trajectory points (19 total)
  • level 6: all valid trajectory points
  • level 7: all trajectory points

Referenced by Dump(), LocalToGlobalRotationAtPoint(), and recob::operator<<().

template<typename Stream >
void recob::TrackTrajectory::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 665 of file TrackTrajectory.h.

References Dump(), and LowLevelDump().

665  {}) const
666  {
667  Dump(std::forward<Stream>(out), verbosity, indent, indent);
668  }
void Dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints trajectory content into a stream.
std::string indent(std::size_t const i)
Point_t const& recob::TrackTrajectory::End ( ) const
inline

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

Definition at line 239 of file TrackTrajectory.h.

References LastValidPoint(), recob::Trajectory::LocationAtPoint(), and LocationAtPoint().

Referenced by recob::Track::End(), End(), Extent(), trkf::TrackKalmanFitter::fitTrack(), calo::GnocchiCalorimetry::produce(), and trkf::KalmanFilterFinalTrackFitter::setDirFlip().

239 { return LocationAtPoint(LastValidPoint()); }
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
template<typename T >
T recob::TrackTrajectory::End ( ) const
inline

End position. Use e.g. as:

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

.

Definition at line 517 of file TrackTrajectory.h.

References End().

518  {
519  auto& loc = End();
520  return T(loc.X(), loc.Y(), loc.Z());
521  }
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
Vector_t recob::TrackTrajectory::EndDirection ( ) const
inline

Returns the direction of the trajectory at the last point.

Definition at line 302 of file TrackTrajectory.h.

References DirectionAtPoint(), and LastValidPoint().

Referenced by Direction(), recob::Track::EndCovarianceGlobal6D(), recob::Track::EndDirection(), EndDirection(), and trkf::TrackKalmanFitter::fitTrack().

302 { return DirectionAtPoint(LastValidPoint()); }
T DirectionAtPoint(unsigned int p) const
Direction at point p. Use e.g. as:
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
template<typename T >
T recob::TrackTrajectory::EndDirection ( ) const
inline

End direction. Use e.g. as:

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

.

Definition at line 549 of file TrackTrajectory.h.

References dir, and EndDirection().

550  {
551  auto dir = EndDirection();
552  return T(dir.X(), dir.Y(), dir.Z());
553  }
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
TDirectory * dir
Definition: macro.C:5
double recob::TrackTrajectory::EndMomentum ( ) const
inline

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

See also
EndMomentumVector()

Definition at line 445 of file TrackTrajectory.h.

References recob::Trajectory::DirectionAtPoint(), EndMomentumVector(), recob::Trajectory::HasMomentum(), recob::Trajectory::MomentumAtPoint(), and recob::Trajectory::MomentumVectorAtPoint().

Referenced by recob::Track::EndMomentum().

445 { return EndMomentumVector().R(); }
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last valid point [GeV/c].
Vector_t const& recob::TrackTrajectory::EndMomentumVector ( ) const
inline

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

Definition at line 433 of file TrackTrajectory.h.

References LastValidPoint(), and MomentumVectorAtPoint().

Referenced by recob::Track::EndCovarianceGlobal6D(), EndMomentum(), recob::Track::EndMomentumVector(), and EndMomentumVector().

size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
T MomentumVectorAtPoint(unsigned int p) const
Momentum vector at point p. Use e.g. as:
template<typename T >
T recob::TrackTrajectory::EndMomentumVector ( ) const
inline

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

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

.

Definition at line 581 of file TrackTrajectory.h.

References EndMomentumVector().

582  {
583  auto mom = EndMomentumVector();
584  return T(mom.X(), mom.Y(), mom.Z());
585  }
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last valid point [GeV/c].
template<typename T >
std::pair<T, T> recob::TrackTrajectory::Extent ( ) const
inline

Fills the first and last valid 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 252 of file TrackTrajectory.h.

Referenced by recob::Track::EndCovariance(), and recob::Track::Extent().

253  {
254  return {Vertex<T>(), End<T>()};
255  }
std::pair<Point_t, Point_t> recob::TrackTrajectory::Extent ( ) const
inline

Returns a copy of the first and last valid 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 274 of file TrackTrajectory.h.

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

274 { return {Start(), End()}; }
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
size_t recob::Trajectory::FirstPoint ( ) const
inlineinherited

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

Definition at line 156 of file Trajectory.h.

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

156 { return 0U; }
size_t recob::TrackTrajectory::FirstValidPoint ( ) const
inline

Returns the index of the first valid point in the trajectory.

Returns
index of the first point in the trajectory, or InvalidIndex

Returns the index of the first point with the flag NoPoint unset. It never returns InvalidIndex unless the track trajectory is invalid.

Definition at line 185 of file TrackTrajectory.h.

References NextValidPoint().

Referenced by AzimuthAngle(), trkf::TrajectoryMCSFitter::breakTrajInSegments(), recob::Track::FirstValidPoint(), Phi(), Start(), StartDirection(), StartMomentumVector(), Theta(), and ZenithAngle().

185 { return NextValidPoint(0U); }
size_t NextValidPoint(size_t index) const
Returns the index of the next valid point in the trajectory.
Flags_t const& recob::TrackTrajectory::Flags ( ) const
inline

Returns all flags.

Definition at line 161 of file TrackTrajectory.h.

References fFlags.

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

161 { return fFlags; }
Flags_t fFlags
Flags of each of the points in trajectory.
PointFlags_t const& recob::TrackTrajectory::FlagsAtPoint ( size_t  i) const
inline

Returns the flags for the specified trajectory point.

Parameters
iindex of the point in the trajectory
Returns
flags for the specified trajectory point [cm]

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

Definition at line 156 of file TrackTrajectory.h.

References fFlags.

Referenced by recob::Track::FlagsAtPoint(), and HasValidPoint().

156 { return fFlags[i]; }
Flags_t fFlags
Flags of each of the points in trajectory.
recob::Trajectory::Rotation_t recob::Trajectory::GlobalToLocalRotationAtPoint ( size_t  p) const
inherited

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

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

Referenced by recob::Trajectory::Direction(), Direction(), and recob::Trajectory::GlobalToLocalRotationAtPoint().

119 {
121 } // 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:109
template<typename T >
T recob::TrackTrajectory::GlobalToLocalRotationAtPoint ( unsigned int  p) const
inline

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

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

.

Definition at line 597 of file TrackTrajectory.h.

Referenced by recob::Track::GlobalToLocalRotationAtPoint().

598  {
599  T rot(3, 3);
600  GlobalToLocalRotationAtPoint(p).GetRotationMatrix(rot);
601  return rot;
602  }
T GlobalToLocalRotationAtPoint(unsigned int p) const
Returns a rotation matrix that brings trajectory direction along z. Use e.g. as:
bool recob::Trajectory::HasMomentum ( ) const
inlineinherited

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

References recob::Trajectory::fHasMomentum.

Referenced by recob::Track::DirectionAtPoint(), recob::Trajectory::DirectionAtPoint(), EndMomentum(), and trkmkr::KalmanFilterFitTrackMaker::restoreInputPoints().

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

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

References recob::Trajectory::NPoints().

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

166 { return i < NPoints(); }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
bool recob::TrackTrajectory::HasValidPoint ( size_t  i) const
inline

Returns whether the specified point has NoPoint flag unset.

Returns
whether the specified point has NoPoint flag unset

A point with flag NoPoint set is actually an invalid point, that the algorithm could not at all set, but it has still a hit associated with it.

If the point index is invalid, false is returned.

Definition at line 173 of file TrackTrajectory.h.

References FlagsAtPoint(), recob::Trajectory::HasPoint(), recob::TrajectoryPointFlags::isSet(), recob::TrajectoryPointFlagTraits::NoPoint, and Trajectory().

Referenced by AtLeastValidTrajectoryPoints(), CountValidPoints(), and recob::Track::HasValidPoint().

174  {
175  return Trajectory().HasPoint(i) && !FlagsAtPoint(i).isSet(flag::NoPoint);
176  }
bool HasPoint(size_t i) const
Returns whether the specified trajectory point is available.
Definition: Trajectory.h:166
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
bool isSet(Flag_t flag) const
Returns true if the flag exists and is set.
PointFlags_t const & FlagsAtPoint(size_t i) const
Returns the flags for the specified trajectory point.
size_t recob::Trajectory::LastPoint ( ) const
inlineinherited

Returns the index of the last point in the trajectory.

Definition at line 159 of file Trajectory.h.

References recob::Trajectory::NPoints().

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

159 { return NPoints() - 1; }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
size_t recob::TrackTrajectory::LastValidPoint ( ) const
inline

Returns the index of the last valid point in the trajectory.

Returns
index of the last point in the trajectory, or InvalidIndex

Returns the index of the last point with the flag NoPoint unset. It never returns InvalidIndex unless the track trajectory is invalid.

Definition at line 220 of file TrackTrajectory.h.

References CountValidPoints(), recob::Trajectory::LastPoint(), PreviousValidPoint(), and recob::Trajectory::TrajectoryPoint().

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), End(), EndDirection(), EndMomentumVector(), recob::Track::LastValidPoint(), and Length().

220 { return PreviousValidPoint(LastPoint()); }
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:159
size_t PreviousValidPoint(size_t index) const
Returns the index of the previous valid point in the trajectory.
double recob::TrackTrajectory::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. All invalid points are skipped. If after skipping, less than two valid points are left, 0 is returned.

The length approximation is just the sum of Euclidean distances between each valid trajectory point and the next (starting from the first valid one with index startAt or larger).

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

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 65 of file TrackTrajectory.cxx.

References recob::Trajectory::LastPoint(), LastValidPoint(), and LocationAtPoint().

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), recob::Track::Covariances(), Extent(), trkmkr::KalmanFilterFitTrackMaker::getMomentum(), trkmkr::KalmanFilterFitTrackMaker::getParticleID(), and trkf::KalmanFilterTrajectoryFitter::setMomValue().

66 {
67 
68  // sanity check
69  if (startAt >= LastPoint()) return 0.;
70 
71  // just sum the distance between all locations in the trajectory
72  size_t iCurr = ToValidPoint<+1>(startAt);
73  size_t iNext = iCurr;
74  size_t iLast = LastValidPoint();
75  Point_t const* curr = &(LocationAtPoint(iCurr));
76  Coord_t length = 0.0;
77  while ((iNext = ToValidPoint<+1>(++iNext)) <= iLast) {
78  Point_t const* next = &LocationAtPoint(iNext);
79  length += (*next - *curr).R();
80  curr = next;
81  } // while
82  return length;
83 } // recob::TrackTrajectory::Length()
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
recob::tracking::Point_t Point_t
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:159
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
tracking::Coord_t Coord_t
Type used for coordinates and values in general.
recob::Trajectory::Rotation_t recob::Trajectory::LocalToGlobalRotationAtPoint ( size_t  p) const
inherited

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

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

Referenced by recob::Trajectory::Direction(), Direction(), and recob::Trajectory::LocalToGlobalRotationAtPoint().

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

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

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

.

Definition at line 606 of file TrackTrajectory.h.

References Dump(), and art::detail::indent().

Referenced by recob::Track::LocalToGlobalRotationAtPoint().

607  {
608  T rot(3, 3);
609  LocalToGlobalRotationAtPoint(p).GetRotationMatrix(rot);
610  return rot;
611  }
T LocalToGlobalRotationAtPoint(unsigned int p) const
Returns a rotation matrix bringing relative directions to global. Use e.g. as:
Point_t const& recob::Trajectory::LocationAtPoint ( size_t  i) const
inlineinherited

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

References recob::Trajectory::fPositions.

Referenced by recob::Trajectory::End(), End(), recob::Trajectory::Length(), recob::Trajectory::LocationAtPoint(), trkf::KalmanFilterFinalTrackFitter::restoreInputPoints(), recob::Trajectory::Start(), and recob::Trajectory::TrajectoryPoint().

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

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

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

.

Definition at line 525 of file TrackTrajectory.h.

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), End(), Length(), trkf::TrajectoryMCSFitter::linearRegression(), recob::Track::LocationAtPoint(), TrackProducerFromTrack::produce(), TrackProducerFromTrackTrajectory::produce(), trkf::KalmanFilterTrajectoryFitter::restoreInputPoints(), trkmkr::KalmanFilterFitTrackMaker::restoreInputPoints(), and Start().

526  {
527  auto& loc = LocationAtPoint(p);
528  return T(loc.X(), loc.Y(), loc.Z());
529  }
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
template<typename Stream >
void recob::TrackTrajectory::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
inlineinherited

Returns reference to stored vector of momenta.

Returns
reference to stored vector of momenta

Definition at line 178 of file Trajectory.h.

References recob::Trajectory::fMomenta.

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

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

References recob::Trajectory::MomentumVectorAtPoint().

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

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

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

References recob::Trajectory::fMomenta.

Referenced by recob::Trajectory::DirectionAtPoint(), EndMomentum(), recob::Trajectory::EndMomentumVector(), recob::Trajectory::MomentumAtPoint(), recob::Trajectory::MomentumVectorAtPoint(), recob::Trajectory::Phi(), recob::Trajectory::StartMomentumVector(), recob::Trajectory::Theta(), and recob::Trajectory::TrajectoryPoint().

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

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

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

.

Definition at line 589 of file TrackTrajectory.h.

Referenced by EndMomentumVector(), recob::Track::MomentumVectorAtPoint(), trkmkr::KalmanFilterFitTrackMaker::restoreInputPoints(), and StartMomentumVector().

590  {
591  auto mom = MomentumVectorAtPoint(p);
592  return T(mom.X(), mom.Y(), mom.Z());
593  }
T MomentumVectorAtPoint(unsigned int p) const
Momentum vector at point p. Use e.g. as:
size_t recob::TrackTrajectory::NextValidPoint ( size_t  index) const
inline

Returns the index of the next valid point in the trajectory.

Parameters
indexstarting index
Returns
index of next valid point in the trajectory, or InvalidIndex

Returns the index of the first point with the flag NoPoint unset, starting with the point with the specified index (included), and moving forward toward the end of the trajectory. It returns InvalidIndex if point at index is invalid and there are no valid points left after it.

Definition at line 198 of file TrackTrajectory.h.

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), FirstValidPoint(), trkf::TrajectoryMCSFitter::linearRegression(), and recob::Track::NextValidPoint().

198 { return ToValidPoint<+1>(index); }
size_t recob::Trajectory::NPoints ( ) const
inlineinherited

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

References recob::Trajectory::fPositions.

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

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

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

References recob::Trajectory::NPoints().

Referenced by recob::Track::Trajectory(), and Trajectory().

143 { return NPoints(); }
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:153
double recob::TrackTrajectory::Phi ( size_t  p) const
inline

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

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

The angle $ \phi $ is returned, as defined in recob::Trajectory::Phi(), for point with the specified index p.

If the point is invalid, the behaviour is undefined.

Note
This function has no default value for p; if p is not specified at all, the method Phi() is called instead.

Definition at line 348 of file TrackTrajectory.h.

References recob::Trajectory::Phi(), and Trajectory().

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

348 { return Trajectory().Phi(p); }
double Phi(size_t p=0) const
Azimuthal angle at a point on the trajectory, with respect to z.
Definition: Trajectory.h:311
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
double recob::TrackTrajectory::Phi ( ) const
inline

Azimuthal angle at a first valid point, with respect to z.

Returns
angle with respect to positive z, in $ [0,\pi] $ [radians]
See also
Phi(size_t), Theta(), ZenithAngle()

The angle $ \phi $ is returned, as defined in recob::Trajectory::Phi(), for the first valid point in the trajectory.

Note
This is not equivalent to Phi(0), but instead to Phi(FirstValidPoint()).

Definition at line 361 of file TrackTrajectory.h.

References FirstValidPoint(), and Phi().

Referenced by Phi().

361 { return Phi(FirstValidPoint()); }
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
double Phi() const
Azimuthal angle at a first valid point, with respect to z.
const Positions_t& recob::Trajectory::Positions ( ) const
inlineinherited

Returns reference to stored vector of positions.

Returns
reference to stored vector of positions

Definition at line 172 of file Trajectory.h.

References recob::Trajectory::fPositions.

172 { return fPositions; }
Positions_t fPositions
List of points the trajectory goes through.
Definition: Trajectory.h:685
size_t recob::TrackTrajectory::PreviousValidPoint ( size_t  index) const
inline

Returns the index of the previous valid point in the trajectory.

Parameters
indexstarting index
Returns
index of previous valid point in trajectory, or InvalidIndex

Returns the index of the first point with the flag NoPoint unset, starting with the point with the specified index (included), and moving backward toward the start of the trajectory. It returns InvalidIndex if point at index is invalid and there are no valid points before it.

Definition at line 211 of file TrackTrajectory.h.

References ToValidPoint().

Referenced by LastValidPoint(), and recob::Track::PreviousValidPoint().

211 { return ToValidPoint<-1>(index); }
size_t ToValidPoint(size_t index) const
Returns the index of the first valid point from index on.
Point_t const& recob::TrackTrajectory::Start ( ) const
inline

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

Definition at line 236 of file TrackTrajectory.h.

References FirstValidPoint(), and LocationAtPoint().

Referenced by trkf::Geometric3DVertexFitter::closestPointAlongTrack(), Extent(), trkf::Geometric3DVertexFitter::fitTwoTracks(), recob::Track::FlagsAtPoint(), trkf::Geometric3DVertexFitter::getParsCovsOnPlane(), trkf::Geometric3DVertexFitter::pDist(), calo::GnocchiCalorimetry::produce(), recob::Track::Start(), Start(), and Vertex().

236 { return LocationAtPoint(FirstValidPoint()); }
T LocationAtPoint(unsigned int p) const
Position at point p. Use e.g. as:
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
template<typename T >
T recob::TrackTrajectory::Start ( ) const
inline

Start position. Use e.g. as:

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

.

Definition at line 501 of file TrackTrajectory.h.

References Start().

502  {
503  auto& loc = Start();
504  return T(loc.X(), loc.Y(), loc.Z());
505  }
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
Vector_t recob::TrackTrajectory::StartDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 299 of file TrackTrajectory.h.

References DirectionAtPoint(), and FirstValidPoint().

Referenced by trkf::Geometric3DVertexFitter::closestPointAlongTrack(), Direction(), trkf::TrajectoryMCSFitter::fitMcs(), trkf::Geometric3DVertexFitter::fitTwoTracks(), trkf::Geometric3DVertexFitter::getParsCovsOnPlane(), recob::Track::LocationAtPoint(), trkf::Geometric3DVertexFitter::pDist(), recob::Track::StartDirection(), StartDirection(), and VertexDirection().

299 { return DirectionAtPoint(FirstValidPoint()); }
T DirectionAtPoint(unsigned int p) const
Direction at point p. Use e.g. as:
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
template<typename T >
T recob::TrackTrajectory::StartDirection ( ) const
inline

Start direction. Use e.g. as:

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

.

Definition at line 533 of file TrackTrajectory.h.

References dir, and StartDirection().

534  {
535  auto dir = StartDirection();
536  return T(dir.X(), dir.Y(), dir.Z());
537  }
TDirectory * dir
Definition: macro.C:5
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
double recob::TrackTrajectory::StartMomentum ( ) const
inline

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

See also
StartMomentumVector()

Definition at line 441 of file TrackTrajectory.h.

References StartMomentumVector().

Referenced by trkmkr::KalmanFilterFitTrackMaker::getMomentum(), recob::Track::StartMomentum(), and VertexMomentum().

441 { return StartMomentumVector().R(); }
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
Vector_t const& recob::TrackTrajectory::StartMomentumVector ( ) const
inline

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

Definition at line 430 of file TrackTrajectory.h.

References FirstValidPoint(), and MomentumVectorAtPoint().

Referenced by StartMomentum(), recob::Track::StartMomentumVector(), StartMomentumVector(), and VertexMomentumVector().

size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
T MomentumVectorAtPoint(unsigned int p) const
Momentum vector at point p. Use e.g. as:
template<typename T >
T recob::TrackTrajectory::StartMomentumVector ( ) const
inline

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

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

.

Definition at line 565 of file TrackTrajectory.h.

References StartMomentumVector().

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

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

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

The angle $ \vartheta $ is returned, as defined in recob::Trajectory::Theta(), for point with the specified index p.

If the point is invalid, the behaviour is undefined.

Note
This function has no default value for p; if p is not specified at all, the method Theta() is called instead.

Definition at line 318 of file TrackTrajectory.h.

References recob::Trajectory::Theta(), and Trajectory().

Referenced by recob::Track::ParticleId(), and recob::Track::Theta().

318 { return Trajectory().Theta(p); }
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
double Theta(size_t p=0) const
Trajectory angle at point, with respect to positive z direction.
Definition: Trajectory.h:295
double recob::TrackTrajectory::Theta ( ) const
inline

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

Returns
angle with respect to positive z, in $ [0,\pi] $ [radians]

The angle $ \vartheta $ is returned, as defined in recob::Trajectory::Theta(), for the first valid point in the trajectory.

Note
This is not equivalent to Theta(0), but instead to Theta(FirstValidPoint()).

Definition at line 331 of file TrackTrajectory.h.

References FirstValidPoint(), and Theta().

Referenced by Theta().

331 { return Theta(FirstValidPoint()); }
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
double Theta() const
Trajectory angle at start, with respect to positive z direction.
template<int Dir>
size_t recob::TrackTrajectory::ToValidPoint ( size_t  index) const
private

Returns the index of the first valid point from index on.

Template Parameters
Dirthe direction to move when an index has an invalid point
Parameters
indexthe starting index
Returns
index of the first valid point from index on (or InvalidIndex)

The valid direction Dir values are only +1 and -1. The first point considered is always the one at index. If no valid point is found, InvalidIndex is returned. The invariant guarantees that all these calls return a valid index:

if (!(
(ToValidPoint<+1>(0) != InvalidIndex) // FirstValidPoint()
&& (ToValidPoint<-1>(LastPoint()) != InvalidIndex) // LastValidPoint()
&& (ToValidPoint<+1>(FirstValidPoint()) != InvalidIndex) // LastValidPoint()
&& (ToValidPoint<-1>(LastValidPoint()) != InvalidIndex) // FirstValidPoint()
)) throw std::logic_error("Invalid TrackTrajectory!");

Referenced by PreviousValidPoint().

Trajectory_t const& recob::TrackTrajectory::Trajectory ( ) const
inline
TrajectoryPoint_t recob::Trajectory::TrajectoryPoint ( size_t  i) const
inlineinherited

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

References recob::Trajectory::LocationAtPoint(), and recob::Trajectory::MomentumVectorAtPoint().

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

196  {
197  return {LocationAtPoint(i), MomentumVectorAtPoint(i)};
198  }
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:216
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:416
Point_t const& recob::TrackTrajectory::Vertex ( ) const
inline

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

Definition at line 233 of file TrackTrajectory.h.

References Start().

Referenced by trkf::TrackKalmanFitter::fitTrack(), trkf::KalmanFilterFinalTrackFitter::setDirFlip(), recob::Track::Vertex(), and Vertex().

233 { return Start(); }
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
template<typename T >
T recob::TrackTrajectory::Vertex ( ) const
inline

Start position. Use e.g. as:

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

.

Definition at line 509 of file TrackTrajectory.h.

References Vertex().

510  {
511  auto& loc = Vertex();
512  return T(loc.X(), loc.Y(), loc.Z());
513  }
Point_t const & Vertex() const
Returns the position of the first valid point of the trajectory [cm].
Vector_t recob::TrackTrajectory::VertexDirection ( ) const
inline

Returns the direction of the trajectory at the first point.

Definition at line 296 of file TrackTrajectory.h.

References StartDirection().

Referenced by trkf::TrackKalmanFitter::fitTrack(), trkmkr::KalmanFilterFitTrackMaker::isFlipDirection(), trkf::KalmanFilterTrajectoryFitter::setDirFlip(), recob::Track::VertexCovarianceGlobal6D(), recob::Track::VertexDirection(), and VertexDirection().

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

Start direction. Use e.g. as:

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

.

Definition at line 541 of file TrackTrajectory.h.

References dir, and VertexDirection().

542  {
543  auto dir = VertexDirection();
544  return T(dir.X(), dir.Y(), dir.Z());
545  }
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
TDirectory * dir
Definition: macro.C:5
double recob::TrackTrajectory::VertexMomentum ( ) const
inline

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

See also
StartMomentum()

Definition at line 437 of file TrackTrajectory.h.

References StartMomentum().

Referenced by recob::Track::VertexMomentum().

437 { return StartMomentum(); }
double StartMomentum() const
Vector_t const& recob::TrackTrajectory::VertexMomentumVector ( ) const
inline

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

Definition at line 427 of file TrackTrajectory.h.

References StartMomentumVector().

Referenced by recob::Track::VertexCovarianceGlobal6D(), recob::Track::VertexMomentumVector(), and VertexMomentumVector().

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

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

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

.

Definition at line 573 of file TrackTrajectory.h.

References VertexMomentumVector().

574  {
575  auto mom = VertexMomentumVector();
576  return T(mom.X(), mom.Y(), mom.Z());
577  }
Vector_t const & VertexMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
double recob::TrackTrajectory::ZenithAngle ( size_t  p) const
inline

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

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

The zenith is returned, as defined in recob::Trajectory::Zenith(), for point with the specified index p.

If the point is invalid, the behaviour is undefined.

Note
This function has no default value for p; if p is not specified at all, the method Zenith() is called instead.

Definition at line 378 of file TrackTrajectory.h.

References Trajectory(), and recob::Trajectory::ZenithAngle().

Referenced by recob::Track::ZenithAngle().

378 { return Trajectory().ZenithAngle(p); }
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
double ZenithAngle(size_t p=0) const
"Zenith" angle of trajectory, with respect to the vertical axis.
Definition: Trajectory.cxx:74
double recob::TrackTrajectory::ZenithAngle ( ) const
inline

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

Returns
opposite of the actual zenith angle, in $ [0,\pi] $ [radians]
See also
Zenith(size_t), Theta()

The zenith angle is returned, as defined in recob::Trajectory::Zenith(), for the first valid point in the trajectory.

Note
This is not equivalent to Zenith(0), but instead to Zenith(FirstValidPoint()).

Definition at line 392 of file TrackTrajectory.h.

References FirstValidPoint(), and ZenithAngle().

Referenced by ZenithAngle().

392 { return ZenithAngle(FirstValidPoint()); }
double ZenithAngle() const
"Zenith" angle of trajectory, with respect to the vertical axis.
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.

Member Data Documentation

Flags_t recob::TrackTrajectory::fFlags
private

Flags of each of the points in trajectory.

Definition at line 687 of file TrackTrajectory.h.

Referenced by Flags(), FlagsAtPoint(), and TrackTrajectory().

constexpr size_t recob::TrackTrajectory::InvalidIndex = std::numeric_limits<size_t>::max()
static

Value returned on failed index queries.

Definition at line 684 of file TrackTrajectory.h.

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments().

constexpr unsigned int recob::TrackTrajectory::MaxDumpVerbosity = 7
static

Largest verbosity level supported by Dump().

Definition at line 681 of file TrackTrajectory.h.


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