LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TrackTrajectory.h
Go to the documentation of this file.
1 
15 #ifndef LARDATAOBJ_RECOBASE_TRACKTRAJECTORY_H
16 #define LARDATAOBJ_RECOBASE_TRACKTRAJECTORY_H
17 
18 // ROOT libraries
21 
22 // C/C++ standard libraries
23 #include <vector>
24 #include <iosfwd> // std::ostream
25 #include <limits> // std::numeric_limits<>
26 
27 
28 namespace recob {
29 
30 
64 
65  public:
68 
71 
74 
77 
80 
83 
86 
88  using Flags_t = std::vector<PointFlags_t>;
89 
92 
95 
98 
99 
101  TrackTrajectory() = default;
102 
103 
126  Positions_t&& positions,
127  Momenta_t&& momenta,
128  Flags_t&& flags,
129  bool hasMomenta
130  );
131 
132 
139  TrackTrajectory(const Trajectory& traj, Flags_t&& flags)
140  : TrackTrajectory(Positions_t(traj.Positions()),Momenta_t(traj.Momenta()),std::move(flags),traj.HasMomentum()) {}
141 
142 
144  Trajectory_t const& Trajectory() const
145  { return static_cast<Trajectory_t const&>(*this); }
146 
147 
149 
150  using Trajectory_t::NPoints;
151 
153 
155 
157 
159 
167  PointFlags_t const& FlagsAtPoint(size_t i) const
168  { return fFlags[i]; }
169 
173  Flags_t const& Flags() const
174  { return fFlags; }
175 
186  bool HasValidPoint(size_t i) const
187  {
188  return Trajectory().HasPoint(i)
190  }
191 
199  size_t FirstValidPoint() const
200  { return NextValidPoint(0U); }
201 
213  size_t NextValidPoint(size_t index) const
214  { return ToValidPoint<+1>(index); }
215 
227  size_t PreviousValidPoint(size_t index) const
228  { return ToValidPoint<-1>(index); }
229 
237  size_t LastValidPoint() const
238  { return PreviousValidPoint(LastPoint()); }
239 
246  unsigned int CountValidPoints() const;
247 
248 
250 
252  Point_t const& Vertex() const
253  { return Start(); }
254 
256  Point_t const& Start() const
257  { return LocationAtPoint(FirstValidPoint()); }
258 
260  Point_t const& End() const
261  { return LocationAtPoint(LastValidPoint()); }
262 
264 
275  [[deprecated("Use point interface instead")]]
276  void Extent(std::vector<double>& start, std::vector<double>& end) const;
277 
295  std::pair<Point_t, Point_t> Extent() const
296  { return { Start(), End() }; }
297 
298 
316  double Length (size_t startAt = 0) const;
317 
318 
319  [[deprecated("Use NumberTrajectoryPoints() instead")]]
320  size_t NumberFitMomentum() const
321  { return HasMomentum()? NPoints(): 0U; }
322 
325  { return StartDirection(); }
326 
329  { return DirectionAtPoint(FirstValidPoint()); }
330 
333  { return DirectionAtPoint(LastValidPoint()); }
334 
335 
350  double Theta(size_t p) const
351  { return Trajectory().Theta(p); }
352 
364  double Theta() const
365  { return Theta(FirstValidPoint()); }
366 
382  double Phi(size_t p) const
383  { return Trajectory().Phi(p); }
384 
396  double Phi() const
397  { return Phi(FirstValidPoint()); }
398 
399 
415  double ZenithAngle(size_t p) const
416  { return Trajectory().ZenithAngle(p); }
417 
430  double ZenithAngle() const
431  { return ZenithAngle(FirstValidPoint()); }
432 
448  double AzimuthAngle(size_t p) const
449  { return Trajectory().AzimuthAngle(p); }
450 
464  double AzimuthAngle() const
465  { return AzimuthAngle(FirstValidPoint()); }
466 
467 
470  { return StartMomentumVector(); }
471 
475 
479 
480 
483  double VertexMomentum() const
484  { return StartMomentum(); }
485 
488  double StartMomentum() const
489  { return StartMomentumVector().R(); }
490 
493  double EndMomentum() const
494  { return EndMomentumVector().R(); }
495 
496 
498 
500 
502 
504 
519  void Direction(double* start, double* end) const;
520 
521 
539  std::pair<Vector_t, Vector_t> Direction() const
540  { return { StartDirection(), EndDirection() }; }
541 
542 
544 
546 
547 
582  template <typename Stream>
583  void Dump(
584  Stream&& out,
585  unsigned int verbosity,
586  std::string indent, std::string indentFirst
587  ) const;
588 
599  template <typename Stream>
600  void Dump
601  (Stream&& out, unsigned int verbosity = 1, std::string indent = {})
602  const
603  { Dump(std::forward<Stream>(out), verbosity, indent, indent); }
604 
612  template <typename Stream>
613  void LowLevelDump
614  (Stream&& out, std::string indent, std::string indentFirst) const;
615 
616 
618  static constexpr unsigned int MaxDumpVerbosity = 7;
619 
621  static constexpr size_t InvalidIndex = std::numeric_limits<size_t>::max();
622 
623  private:
624 
626 
627 
647  template <int Dir>
648  size_t ToValidPoint(size_t index) const;
649 
651  bool AtLeastValidTrajectoryPoints(unsigned int left) const;
652 
653  }; // class TrackTrajectory
654 
655 
665  std::ostream& operator << (std::ostream&& out, TrackTrajectory const& traj);
666 
667 
668 } // namespace recob
669 
670 
671 //------------------------------------------------------------------------------
672 //--- Inline implementation
673 //---
674 
675 //------------------------------------------------------------------------------
676 //--- Template implementation
677 //---
678 #include "TrackTrajectory.tcc"
679 
680 //------------------------------------------------------------------------------
681 
682 
683 #endif // LARDATAOBJ_RECOBASE_TRACKTRAJECTORY_H
void Dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints trajectory content into a stream.
double Phi(size_t p=0) const
Azimuthal angle at a point on the trajectory, with respect to z.
Definition: Trajectory.h:372
Data product for reconstructed trajectory in space.
bool HasPoint(size_t i) const
Returns whether the specified trajectory point is available.
Definition: Trajectory.h:188
A point in the trajectory, with position and momentum.
Definition: TrackingTypes.h:35
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
TrajectoryPointFlagTraits flag
Type of flag traits (indices and meaning of flags).
Reconstruction base classes.
TrackTrajectory()=default
Default constructor; do not use it! it&#39;s needed by ROOT I/O.
Flags_t const & Flags() const
Returns all flags.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
geo::Point_t Point_t
Type for representation of position in physical 3D space.
Definition: TrackingTypes.h:20
bool isSet(Flag_t flag) const
Returns true if the flag exists and is set.
size_t LastValidPoint() const
Returns the index of the last valid point in the trajectory.
Ends_t
Mnemonics for the access to begin and end of trajectory.
Definition: Trajectory.h:90
tracking::Positions_t Positions_t
Type of trajectory point list.
double ZenithAngle(size_t p) const
"Zenith" angle of trajectory, with respect to the vertical axis.
Vector_t const & StartMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
Vector_t const & VertexMomentumVector() const
Returns the momentum of the trajectory at the first valid point [GeV/c].
bool TrajectoryAtPoint(size_t i, TVector3 &pos, TVector3 &dir) const
Fills position and direction at the specified trajectory point.
Definition: Trajectory.cxx:66
Namespace for the trajectory point flags.
double AzimuthAngle(size_t p=0) const
"Azimuth" angle of trajectory, with respect to the sky.
Definition: Trajectory.cxx:136
STL namespace.
size_t NumberFitMomentum() const
double ZenithAngle(size_t p=0) const
"Zenith" angle of trajectory, with respect to the vertical axis.
Definition: Trajectory.cxx:122
double EndMomentum() const
Rotation_t LocalToGlobalRotationAtPoint(size_t p) const
Returns a rotation matrix bringing relative directions to global.
Definition: Trajectory.cxx:190
unsigned int CountValidPoints() const
Computes and returns the number of points with valid location.
tracking::Momenta_t Momenta_t
Type of momentum list.
Flags_t fFlags
Flags of each of the points in trajectory.
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
Definition: Trajectory.cxx:157
Rotation_t GlobalToLocalRotationAtPoint(size_t p) const
Returns a rotation matrix that brings trajectory direction along z.
Definition: Trajectory.cxx:173
double AzimuthAngle() const
"Azimuth" angle of trajectory, with respect to the sky.
Vector_t VertexDirection() const
Returns the direction of the trajectory at the first point.
Int_t max
Definition: plot.C:27
double Length(size_t startAt=0) const
Returns the approximate length of the trajectory.
size_t LastPoint() const
Returns the index of the last point in the trajectory.
Definition: Trajectory.h:180
size_t PreviousValidPoint(size_t index) const
Returns the index of the previous valid point in the trajectory.
const Positions_t & Positions() const
Returns reference to stored vector of positions.
Definition: Trajectory.h:195
TrajectoryPoint_t TrajectoryPoint(size_t i) const
Returns position and momentum at the specified trajectory point.
Definition: Trajectory.h:231
PointFlags_t const & FlagsAtPoint(size_t i) const
Returns the flags for the specified trajectory point.
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:172
A trajectory in space reconstructed from hits.
std::string indent(std::size_t const i)
double MomentumAtPoint(size_t i) const
Computes and returns the modulus of the momentum at a point.
Definition: Trajectory.h:477
bool HasValidPoint(size_t i) const
Returns whether the specified point has NoPoint flag unset.
geo::Vector_t Vector_t
Type for representation of momenta in 3D space.
Definition: TrackingTypes.h:23
std::pair< Vector_t, Vector_t > Direction() const
Returns the trajectory directions at first and last valid points.
double StartMomentum() const
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
Definition: Trajectory.h:255
tracking::Rotation_t Rotation_t
Type for representation of space rotations.
std::vector< Vector_t > Momenta_t
Type of momentum list.
Definition: TrackingTypes.h:29
double ZenithAngle() const
"Zenith" angle of trajectory, with respect to the vertical axis.
tracking::Vector_t Vector_t
Type for representation of momenta in 3D space.
std::vector< PointFlags_t > Flags_t
Type of point flag list.
size_t FirstPoint() const
Returns the index of the first point in the trajectory (yep, it&#39;s 0).
Definition: Trajectory.h:176
double Coord_t
Type used for coordinates and values in general.
Definition: TrackingTypes.h:17
size_t NumberTrajectoryPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:161
Set of flags pertaining a point of the track.
double Phi(size_t p) const
Azimuthal angle at a point on the trajectory, with respect to z.
Point_t const & Vertex() const
Returns the position of the first valid point of the trajectory [cm].
ROOT::Math::Rotation3D Rotation_t
Type for representation of space rotations.
Definition: TrackingTypes.h:32
Vector_t const & MomentumVectorAtPoint(size_t i) const
Returns the momentum vector at a point.
Definition: Trajectory.h:492
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
tracking::Coord_t Coord_t
Type used for coordinates and values in general.
A trajectory in space reconstructed from hits.
Definition: Trajectory.h:72
double Theta(size_t p) const
Trajectory angle at point, with respect to positive z direction.
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
size_t ToValidPoint(size_t index) const
Returns the index of the first valid point from index on.
std::vector< Point_t > Positions_t
Type of trajectory point list.
Definition: TrackingTypes.h:26
size_t FirstValidPoint() const
Returns the index of the first valid point in the trajectory.
static constexpr size_t InvalidIndex
Value returned on failed index queries.
bool HasMomentum() const
Returns whether information about the momentum is available.
Definition: Trajectory.h:460
Vector_t const & EndMomentumVector() const
Returns the momentum of the trajectory at the last valid point [GeV/c].
static constexpr unsigned int MaxDumpVerbosity
Largest verbosity level supported by Dump().
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
TrackTrajectory(const Trajectory &traj, Flags_t &&flags)
Constructor: copies positions and momenta from an existing Trajecotry, adds the flags.
const Momenta_t & Momenta() const
Returns reference to stored vector of momenta.
Definition: Trajectory.h:201
size_t NextValidPoint(size_t index) const
Returns the index of the next valid point in the trajectory.
double Phi() const
Azimuthal angle at a first valid point, with respect to z.
double AzimuthAngle(size_t p) const
"Azimuth" angle of trajectory, with respect to the sky.
bool AtLeastValidTrajectoryPoints(unsigned int left) const
Returns whether there are at least min valid points in the trajectory.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
double Theta(size_t p=0) const
Trajectory angle at point, with respect to positive z direction.
Definition: Trajectory.h:355
tracking::Point_t Point_t
Type for representation of position in physical 3D space.
double VertexMomentum() const
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
std::pair< Point_t, Point_t > Extent() const
Returns a copy of the first and last valid point in the trajectory.
double Theta() const
Trajectory angle at start, with respect to positive z direction.
Set of flags pertaining a point of the track.
void LowLevelDump(Stream &&out, std::string indent, std::string indentFirst) const
Prints low-level trajectory content into a stream.
std::ostream & operator<<(std::ostream &o, Cluster const &c)
Definition: Cluster.cxx:173