A trajectory in space reconstructed from hits. More...
#include <Trajectory.h>
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_t & | Positions () const |
Returns reference to stored vector of positions. More... | |
const Momenta_t & | Momenta () const |
Returns reference to stored vector of momenta. More... | |
TrajectoryPoint_t | TrajectoryPoint (size_t i) const |
Returns position and momentum at the specified trajectory point. More... | |
Point_t const & | Vertex () const |
Returns the position of the first point of the trajectory [cm]. More... | |
Point_t const & | Start () const |
Returns the position of the first point of the trajectory [cm]. More... | |
Point_t const & | End () const |
Returns the position of the last point of the trajectory [cm]. More... | |
Point_t const & | LocationAtPoint (size_t i) const |
Returns the position at the specified trajectory point. More... | |
template<typename T > | |
std::pair< T, T > | Extent () const |
Fills the first and last point in the trajectory. More... | |
std::pair< Point_t, Point_t > | Extent () const |
Returns a copy of the first and last point in the trajectory. More... | |
double | Length (size_t startAt=0) const |
Returns the approximate length of the trajectory. More... | |
Access to direction and momentum information | |
Vector_t | VertexDirection () const |
Returns the direction of the trajectory at the first point. More... | |
Vector_t | StartDirection () const |
Returns the direction of the trajectory at the first point. More... | |
Vector_t | EndDirection () const |
Returns the direction of the trajectory at the last point. More... | |
double | Theta (size_t p=0) const |
Trajectory angle at point, with respect to positive z direction. More... | |
double | Phi (size_t p=0) const |
Azimuthal angle at a point on the trajectory, with respect to z. More... | |
double | ZenithAngle (size_t p=0) const |
"Zenith" angle of trajectory, with respect to the vertical axis. More... | |
double | AzimuthAngle (size_t p=0) const |
"Azimuth" angle of trajectory, with respect to the sky. More... | |
Vector_t const & | VertexMomentumVector () const |
Returns the momentum of the trajectory at the first point [GeV/c]. More... | |
Vector_t const & | StartMomentumVector () const |
Returns the momentum of the trajectory at the first point [GeV/c]. More... | |
Vector_t const & | EndMomentumVector () const |
Returns the momentum of the trajectory at the last point [GeV/c]. More... | |
double | VertexMomentum () const |
Computes and returns the modulus of momentum at the first point [GeV/c]. More... | |
double | StartMomentum () const |
Computes and returns the modulus of momentum at the first point [GeV/c]. More... | |
double | EndMomentum () const |
Computes and returns the modulus of momentum at the last point [GeV/c]. More... | |
Vector_t | DirectionAtPoint (size_t i) const |
Computes and returns the direction of the trajectory at a point. More... | |
bool | HasMomentum () const |
Returns whether information about the momentum is available. More... | |
double | MomentumAtPoint (size_t i) const |
Computes and returns the modulus of the momentum at a point. More... | |
Vector_t const & | MomentumVectorAtPoint (size_t i) const |
Returns the momentum vector at a point. More... | |
template<typename T > | |
std::pair< T, T > | Direction () const |
Fills the starting and ending direction of the trajectory. More... | |
std::pair< Vector_t, Vector_t > | Direction () const |
Returns the trajectory directions at first and last point. More... | |
Rotation_t | GlobalToLocalRotationAtPoint (size_t p) const |
Returns a rotation matrix that brings trajectory direction along z. More... | |
Rotation_t | LocalToGlobalRotationAtPoint (size_t p) const |
Returns a rotation matrix bringing relative directions to global. More... | |
Templated version of homonymous functions to access to position, direction, and momentum information. | |
template<typename T > | |
T | Start () const |
Start position. Use e.g. as: More... | |
template<typename T > | |
T | Vertex () const |
Start position. Use e.g. as: More... | |
template<typename T > | |
T | End () const |
End position. Use e.g. as: More... | |
template<typename T > | |
T | LocationAtPoint (unsigned int p) const |
Position at point p. Use e.g. as: More... | |
template<typename T > | |
T | StartDirection () const |
Start direction. Use e.g. as: More... | |
template<typename T > | |
T | VertexDirection () const |
Start direction. Use e.g. as: More... | |
template<typename T > | |
T | EndDirection () const |
End direction. Use e.g. as: More... | |
template<typename T > | |
T | DirectionAtPoint (unsigned int p) const |
Direction at point p. Use e.g. as: More... | |
template<typename T > | |
T | StartMomentumVector () const |
Momentum vector at start point. Use e.g. as: More... | |
template<typename T > | |
T | VertexMomentumVector () const |
Momentum vector at start point. Use e.g. as: More... | |
template<typename T > | |
T | EndMomentumVector () const |
Momentum vector at end point. Use e.g. as: More... | |
template<typename T > | |
T | MomentumVectorAtPoint (unsigned int p) const |
Momentum vector at point p. Use e.g. as: More... | |
template<typename T > | |
T | GlobalToLocalRotationAtPoint (unsigned int p) const |
Returns a rotation matrix that brings trajectory direction along z. Use e.g. as: More... | |
template<typename T > | |
T | LocalToGlobalRotationAtPoint (unsigned int p) const |
Returns a rotation matrix bringing relative directions to global. Use e.g. as: More... | |
Static Public Attributes | |
static constexpr unsigned int | MaxDumpVerbosity = 6 |
Largest verbosity level supported by Dump(). More... | |
Private Attributes | |
Positions_t | fPositions |
List of points the trajectory goes through. More... | |
Momenta_t | fMomenta |
Momentum of each of the points in trajectory. More... | |
bool | fHasMomentum = true |
Whether we have momentum modulus information. More... | |
A trajectory in space reconstructed from hits.
The trajectory class contains a trajectory in 6D space representing the path walked by a particle. A trajectory point is made of a 3D position component (measured in centimeters) and a momentum component (measured in GeV/c); for a discussion on the object type for coordinates see: recob::tracking::Coord_t.
The object contains information about the trajectory, and no uncertainty, as that is considered a fit result (see recob::Track
). By convention the first point is considered "start" (or "vertex") and the last point "end", although this assignment can be arbitrary and should not be relied upon for physics decisions.
The momentum content is in part optional: the trajectory creating algorithm may decide not to provide information about the modulus of the momentum. In that case, Trajectory::HasMomentum()
will return false and every attempt to access the momentum vector will yield only the trajectory direction.
Trajectory::HasMomentum()
reports whether momentum modulus information is available;recob::TrajectoryCollectionMaker
. Definition at line 67 of file Trajectory.h.
Type used for coordinates and values in general.
Definition at line 70 of file Trajectory.h.
Type of momentum list.
Definition at line 82 of file Trajectory.h.
Type for representation of position in physical 3D space.
Definition at line 73 of file Trajectory.h.
Type of trajectory point list.
Definition at line 79 of file Trajectory.h.
Type for representation of space rotations.
Definition at line 97 of file Trajectory.h.
A point in the trajectory, with position and momentum.
Definition at line 94 of file Trajectory.h.
Type for representation of momenta in 3D space.
Definition at line 76 of file Trajectory.h.
Mnemonics for the access to begin and end of trajectory.
Enumerator | |
---|---|
kStart |
Index representing the start of the trajectory. |
kVertex |
Index representing the start of the trajectory. |
kEnd |
Index representing the end of the trajectory. |
NEnds |
Number of ends. |
Definition at line 85 of file Trajectory.h.
|
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.
positions | (moved) trajectory as a sorted list of points |
momenta | (moved) momentum along the trajectory, one per point |
hasMomenta | whether the information on momentum modulus is provided |
std::runtime_error | if the invariants are violated |
The most convenient way to create a recob::Trajectory is to use recob::trackutil::makeTrajectory()
.
Definition at line 24 of file Trajectory.cxx.
|
inline |
Constructor: copies positions and momenta.
positions | trajectory as a sorted list of points |
momenta | momentum along the trajectory, one per point |
hasMomenta | whether the information on momentum modulus is provided |
std::runtime_error | if the invariants are violated |
Definition at line 136 of file Trajectory.h.
double recob::Trajectory::AzimuthAngle | ( | size_t | p = 0 | ) | const |
"Azimuth" angle of trajectory, with respect to the sky.
p | the point index to extract the angle from (default: start) |
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 radians.
If the point number is invalid, the behaviour is undefined.
Definition at line 96 of file Trajectory.cxx.
|
inline |
Fills the starting and ending direction of the trajectory.
start | (output) direction at the beginning of the trajectory |
end | (output) direction at the end of the trajectory |
The two arguments are expected to point each one to an area with room for at least three double
numbers. The two filled vectors have norm 1.
The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.
Definition at line 472 of file Trajectory.h.
Returns the trajectory directions at first and last point.
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.
Definition at line 492 of file Trajectory.h.
recob::Trajectory::Vector_t recob::Trajectory::DirectionAtPoint | ( | size_t | i | ) | const |
Computes and returns the direction of the trajectory at a point.
i | index of the point in the trajectory |
The direction is computed as unit vector parallel to the momentum at that trajectory point. If the index is not contained in the trajectory, the result is undefined.
Definition at line 117 of file Trajectory.cxx.
|
inline |
Direction at point p. Use e.g. as:
.
Definition at line 564 of file Trajectory.h.
void recob::Trajectory::Dump | ( | Stream && | out, |
unsigned int | verbosity, | ||
std::string | indent, | ||
std::string | indentFirst | ||
) | const |
Prints trajectory content into a stream.
Stream | type of the output stream |
out | stream to output the information into |
verbosity | verbosity level (default: 1 ) |
indent | indentation string (default: none) |
indentFirst | indentation 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.
verbosity
argument) 0
: start position, direction, momentum modulus and number of points1
: also end position, direction and momentum modulus2
: also trajectory length3
: also angles at start4
: also 9 intermediate trajectory points5
: also 10 more intermediate trajectory points (19 total)6
: all trajectory points
|
inline |
Prints trajectory content into a stream.
Stream | type of the output stream |
out | stream to output the information into |
verbosity | verbosity level (default: 1 ) |
indent | indentation string (default: none) |
Implementation detail for Dump(Stream&&, unsigned int, std::string).
Definition at line 645 of file Trajectory.h.
|
inline |
Returns the position of the last point of the trajectory [cm].
Definition at line 226 of file Trajectory.h.
|
inline |
End position. Use e.g. as:
.
Definition at line 549 of file Trajectory.h.
|
inline |
Returns the direction of the trajectory at the last point.
Definition at line 303 of file Trajectory.h.
|
inline |
End direction. Use e.g. as:
.
Definition at line 561 of file Trajectory.h.
|
inline |
Computes and returns the modulus of momentum at the last point [GeV/c].
Definition at line 401 of file Trajectory.h.
|
inline |
Returns the momentum of the trajectory at the last point [GeV/c].
Definition at line 388 of file Trajectory.h.
|
inline |
Momentum vector at end point. Use e.g. as:
.
Definition at line 573 of file Trajectory.h.
|
inline |
Fills the first and last point in the trajectory.
start | (output) position of the beginning of the trajectory |
end | (output) position of the end of the trajectory |
The labelling of start and end is consistent within the trajectory but is not guaranteed to be physically correct.
Definition at line 248 of file Trajectory.h.
Returns a copy of 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.
Definition at line 266 of file Trajectory.h.
|
inline |
Returns the index of the first point in the trajectory (yep, it's 0
).
Definition at line 171 of file Trajectory.h.
recob::Trajectory::Rotation_t recob::Trajectory::GlobalToLocalRotationAtPoint | ( | size_t | p | ) | const |
Returns a rotation matrix that brings trajectory direction along z.
p | index of the trajectory point where to apply the rotation |
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:
local will be a Vector_t
object (like the direction at the right side of the product) that points to (0, 0, 1).
While the transformation that yields the rotation matrix is continuous, the direction of the new "local" x and y axes is not defined.
Definition at line 128 of file Trajectory.cxx.
|
inline |
Returns a rotation matrix that brings trajectory direction along z. Use e.g. as:
.
Definition at line 579 of file Trajectory.h.
|
inline |
Returns whether information about the momentum is available.
The trajectory may or may not store valid momentum information. If not, the methods returning momentum information will stick to a modulus 1 GeV/c and the momentum numerically matches the direction.
Definition at line 425 of file Trajectory.h.
|
inline |
Returns whether the specified trajectory point is available.
i | index of the trajectory point |
Definition at line 183 of file Trajectory.h.
|
inline |
Returns the index of the last point in the trajectory.
Definition at line 175 of file Trajectory.h.
double recob::Trajectory::Length | ( | size_t | startAt = 0 | ) | const |
Returns the approximate length of the trajectory.
startAt | (default: 0, from beginning) point to start from |
The residual length from the trajectory point startAt to the end of the trajectory is computed and returned. By default, the whole trajectory length is returned. If a non-existing point is specified, 0 is returned.
The length approximation is just the sum of Euclidean distances between all consecutive trajectory points (starting from the one with index startAt
).
This operation is slow, and the result should be stored in a variable.
Definition at line 63 of file Trajectory.cxx.
recob::Trajectory::Rotation_t recob::Trajectory::LocalToGlobalRotationAtPoint | ( | size_t | p | ) | const |
Returns a rotation matrix bringing relative directions to global.
p | index of the trajectory point where to apply the rotation |
The returned rotation matrix, applied to the unit vector (0, 0, 1) (local z axis direction), will turn it into the trajectory direction at point p
. If p
does not denote a valid trajectory point, the result is undefined.
While the transformation that yields the rotation matrix is continuous, the conversion of the directions orthogonal to the local z is not defined.
Definition at line 136 of file Trajectory.cxx.
|
inline |
Returns a rotation matrix bringing relative directions to global. Use e.g. as:
.
Definition at line 586 of file Trajectory.h.
|
inline |
Returns the position at the specified trajectory point.
i | index of the point in the trajectory |
If the point index is invalid, the result is undefined.
Definition at line 236 of file Trajectory.h.
|
inline |
Position at point p. Use e.g. as:
.
Definition at line 552 of file Trajectory.h.
void recob::Trajectory::LowLevelDump | ( | Stream && | out, |
std::string | indent, | ||
std::string | indentFirst | ||
) | const |
Prints low-level trajectory content into a stream.
Stream | type of the output stream |
out | stream to output the information into |
indent | indentation string (default: none) |
indentFirst | indentation for first output line (default: as indent) |
|
inline |
Returns reference to stored vector of momenta.
Definition at line 196 of file Trajectory.h.
|
inline |
Computes and returns the modulus of the momentum at a point.
i | index of the point in the trajectory |
The modulus of the momentum at the specified trajectory point is computed and returned. If the trajectory does not have momentum information, the value 1 GeV/c is always returned. This can be tested trajectory by trajectory by HasMomentum(). If the index is not valid in the trajectory, the result is undefined.
Definition at line 442 of file Trajectory.h.
|
inline |
Returns the momentum vector at a point.
i | index of the point in the trajectory |
The momentum at the specified trajectory point is returned. If the trajectory does not have momentum information, the returned value will represent the direction, that is a momentum with modulus 1 GeV/c. This can be tested trajectory by trajectory by HasMomentum(). If the index is not valid in the trajectory, the result is undefined.
Definition at line 457 of file Trajectory.h.
|
inline |
Momentum vector at point p. Use e.g. as:
.
Definition at line 576 of file Trajectory.h.
|
inline |
Returns the number of stored trajectory points.
For each point, both position and momentum are available.
Definition at line 167 of file Trajectory.h.
|
inline |
Returns the number of stored trajectory points.
For each point, both position and momentum are available.
Definition at line 156 of file Trajectory.h.
|
inline |
Azimuthal angle at a point on the trajectory, with respect to z.
p | the point index to extract the angle from (default: start) |
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 radians in this system, provided that the standard reference frame with the y axis pointing skyward is chosen.
If the point number is invalid, the behaviour is undefined.
Definition at line 337 of file Trajectory.h.
|
inline |
Returns reference to stored vector of positions.
Definition at line 190 of file Trajectory.h.
|
inline |
Returns the position of the first point of the trajectory [cm].
Definition at line 222 of file Trajectory.h.
|
inline |
Start position. Use e.g. as:
.
Definition at line 543 of file Trajectory.h.
|
inline |
Returns the direction of the trajectory at the first point.
Definition at line 299 of file Trajectory.h.
|
inline |
Start direction. Use e.g. as:
.
Definition at line 555 of file Trajectory.h.
|
inline |
Computes and returns the modulus of momentum at the first point [GeV/c].
Definition at line 397 of file Trajectory.h.
|
inline |
Returns the momentum of the trajectory at the first point [GeV/c].
Definition at line 384 of file Trajectory.h.
|
inline |
Momentum vector at start point. Use e.g. as:
.
Definition at line 567 of file Trajectory.h.
|
inline |
Trajectory angle at point, with respect to positive z direction.
p | the index point to extract the angle from (default: start) |
The reference direction is the positive z axis. Although this usually matches the beam direction, this is not guaranteed and if the explicit angle from beam direction is needed, the scalar product of the beam direction and the direction from StartDirection()
should be used instead.
If the point number is invalid, the behaviour is undefined.
Definition at line 320 of file Trajectory.h.
|
inline |
Returns position and momentum at the specified trajectory point.
i | index of the trajectory point |
Note that this method returns the momentum, not the direction.
If the specified index is not valid, result is undefined.
Definition at line 213 of file Trajectory.h.
|
inline |
Returns the position of the first point of the trajectory [cm].
Definition at line 218 of file Trajectory.h.
|
inline |
Start position. Use e.g. as:
.
Definition at line 546 of file Trajectory.h.
|
inline |
Returns the direction of the trajectory at the first point.
Definition at line 295 of file Trajectory.h.
|
inline |
Start direction. Use e.g. as:
.
Definition at line 558 of file Trajectory.h.
|
inline |
Computes and returns the modulus of momentum at the first point [GeV/c].
Definition at line 393 of file Trajectory.h.
|
inline |
Returns the momentum of the trajectory at the first point [GeV/c].
Definition at line 380 of file Trajectory.h.
|
inline |
Momentum vector at start point. Use e.g. as:
.
Definition at line 570 of file Trajectory.h.
double recob::Trajectory::ZenithAngle | ( | size_t | p = 0 | ) | const |
"Zenith" angle of trajectory, with respect to the vertical axis.
p | the point index to extract the angle from (default: start) |
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 radians, while a trajectory going downward along the negative y direction returns 0.
This is designed so that vertical cosmic rays produce trajectories with angle 0 radians.
If the point number is invalid, the behaviour is undefined.
Definition at line 82 of file Trajectory.cxx.
|
private |
Whether we have momentum modulus information.
Definition at line 672 of file Trajectory.h.
|
private |
Momentum of each of the points in trajectory.
Definition at line 670 of file Trajectory.h.
|
private |
List of points the trajectory goes through.
Definition at line 669 of file Trajectory.h.
|
static |
Largest verbosity level supported by Dump().
Definition at line 662 of file Trajectory.h.