sandreco  1.0.8
A modular reconstruction software for SAND
EDEPTrajectory Class Reference

Represents a trajectory of a particle through a detector. More...

#include <EDEPTrajectory.h>

Inheritance diagram for EDEPTrajectory:

Public Member Functions

 EDEPTrajectory (const TG4Trajectory &trajectory)
 
 EDEPTrajectory (const EDEPTrajectory &)=default
 
 EDEPTrajectory (EDEPTrajectory &&)=default
 
 ~EDEPTrajectory ()=default
 Destructor for EDEPTrajectory.
 
bool operator== (const EDEPTrajectory &trj) const
 Equality operator for EDEPTrajectory. More...
 
EDEPTrajectory & operator= (const EDEPTrajectory &)=default
 Assignment operator for EDEPTrajectory. More...
 
EDEPTrajectory & operator= (EDEPTrajectory &&)=default
 Move assignment operator for EDEPTrajectory. More...
 
EDEPTrajectory * Get ()
 Get a pointer to this trajectory. More...
 
const EDEPTrajectory * Get () const
 Get a const pointer to this trajectory. More...
 
EDEPTrajectory * GetParent () const
 Get the parent trajectory of this trajectory. More...
 
int GetId () const
 Get the ID of this trajectory. More...
 
int GetDepth () const
 Get the depth of this trajectory. More...
 
int GetInteractionNumber () const
 Get the number of the interaction that generated this trajectory. More...
 
std::string GetReaction () const
 Get the reaction of the interaction that generated this trajectory. More...
 
int GetParentId () const
 Get the parent ID of this trajectory. More...
 
int GetPDGCode () const
 Get the PDG code of this trajectory. More...
 
std::vector< EDEPTrajectoryPoint > & GetFirstPointsInDetector (sand::subdetector_t c)
 
const std::vector< EDEPTrajectoryPoint > & GetFirstPointsInDetector (sand::subdetector_t c) const
 
std::vector< EDEPTrajectoryPoint > & GetLastPointsInDetector (sand::subdetector_t c)
 
const std::vector< EDEPTrajectoryPoint > & GetLastPointsInDetector (sand::subdetector_t c) const
 
sand::vec_4d GetInitialMomentum () const
 Get the initial momentum of this trajectory. More...
 
trajectory_range< EDEPTrajectory > GetChildrenTrajectories ()
 
trajectory_range< const EDEPTrajectory > GetChildrenTrajectories () const
 
const EDEPHitsMap & GetHitMap () const
 Get the hit map associated with this trajectory. More...
 
const EDEPTrajectoryPoints & GetTrajectoryPoints () const
 Get the trajectory points associated with this trajectory. More...
 
std::vector< EDEPTrajectoryPoint > GetTrajectoryPointsVect () const
 Get the trajectory points associated with this trajectory. More...
 
bool HasHits () const
 
bool HasHitWithId (int id) const
 
const EDEPHit & GetHitWithId (int id) const
 Returns the hit in the trajectory with the specified ID. More...
 
bool HasHitInDetector (sand::subdetector_t c) const
 
double GetDepositedEnergy (sand::subdetector_t c) const
 Sum of the secondary deposits in c, 0 if there are no hits there. More...
 
double GetTotalEnergyDeposit (sand::subdetector_t c) const
 Sum of the total energy deposits (EDEPHit::GetEnergyDeposit) of the hits in c [MeV], 0 if there are none. More...
 
double GetTrackLength (sand::subdetector_t c) const
 Sum of the track lengths (EDEPHit::GetTrackLength) of the hits in c [mm], 0 if there are none. More...
 
bool HasHitBeforeTime (double t) const
 Checks if the trajectory has hits before a specified time. More...
 
bool HasHitAfterTime (double t) const
 Checks if the trajectory has hits after a specified time. More...
 
bool HasHitWithEnergySmallerThan (double e) const
 Checks if the trajectory has hits with energy smaller than the specified amount. More...
 
bool HasHitWithEnergyLargerThan (double e) const
 Checks if the trajectory has hits with energy larger than the specified amount. More...
 
bool HasHitInEnergy (double min, double max) const
 Checks if the trajectory has hits within a specified energy range. More...
 
bool HasHitInTimeAndEnergy (double start_time, double stop_time, double min_energy, double max_energy) const
 Checks if the trajectory has hits within a specified energy and time ranges. More...
 
bool IsTrajectorySaturated () const
 True if the trajectory reached the edep-sim limit on the number of stored points. More...
 
bool HasHitInTime (double start_time, double stop_time) const
 Checks if the trajectory has hits within a specified time range. More...
 
bool HasHitWithIdInDetector (int id, sand::subdetector_t c) const
 Checks if the trajectory has a hit with the specified ID in the specified detector sand::subdetector_t. More...
 
bool HasHitNearPoint (sand::pos_3d point, double distance) const
 Checks if any hit is within a given distance from a point. More...
 
bool HasHitNear4DPoint (sand::vec_4d point, double distance, double time) const
 Checks if any hit is within a given 4D distance (space and time) from a point. More...
 
const EDEPHit * GetHitNear4DPoint (sand::vec_4d point, double distance, double time) const
 First hit near the 4D point, nullptr if none. More...
 
std::string Print (std::string &full_out, int depth=100, int current_depth=0) const
 
bool IsEntering (sand::subdetector_t c) const
 
bool IsExiting (sand::subdetector_t c) const
 
template<typename Funct >
bool HasHitWhere (Funct &&f) const
 
template<typename Funct >
const EDEPHit * GetHitWhere (Funct &&f) const
 

Static Public Member Functions

static bool Match (std::string_view volume, std::initializer_list< std::string > names)
 True if volume contains any of names as a substring. More...
 

Protected Member Functions

const EDEPHit * FindHit (int id) const
 

Protected Attributes

sand::vec_4d p0_ {0, 0, 0, 0}
 Initial momentum of the trajectory.
 
EDEPHitsMap hit_map_
 Map of hits associated with the trajectory.
 
EDEPTrajectoryPoints trajectory_points_
 Trajectory points.
 
std::vector< EDEPTrajectory * > children_
 Children trajectories.
 
std::array< bool, sand::kNumComponents > exiting_ {}
 Map indicating whether the trajectory is exiting a sand::subdetector_t.
 
std::array< bool, sand::kNumComponents > entering_ {}
 Map indicating whether the trajectory is entering a sand::subdetector_t.
 
std::array< std::vector< EDEPTrajectoryPoint >, sand::kNumComponents > last_points_
 Map of all the first points in each sand::subdetector_t.
 
std::array< std::vector< EDEPTrajectoryPoint >, sand::kNumComponents > first_points_
 Map of all the last points in each sand::subdetector_t.
 
EDEPTrajectory * parent_trajectory_ = nullptr
 Pointer to the parent trajectory.
 
int id_ = -1
 ID of the trajectory.
 
int parent_id_ = -99
 Parent ID of the trajectory.
 
int pdg_code_ = 0
 PDG code of the trajectory.
 
int depth_ = -1
 Depth of the trajectory.
 
int interaction_number_ = -1
 Number of the interaction that generated this trajectory.
 
std::string reaction_
 String corresponding to the reaction that generated this trajectory.
 

Static Protected Attributes

static constexpr std::size_t kMaxPoints = 10000
 

Friends

class EDEPTree
 

Detailed Description

Represents a trajectory of a particle through a detector.

This class encapsulates information about a particle trajectory, including its initial momentum, hits along its path, children trajectories, and various utility functions to query trajectory properties. Trajectories are owned by an EDEPTree, which also fills them. Parent and children are non-owning pointers into the tree's storage, so a trajectory copied out of its tree is only a snapshot: its relations still point into the original tree and are valid only as long as the tree is not rebuilt.

Member Function Documentation

◆ Get() [1/2]

EDEPTrajectory* EDEPTrajectory::Get ( )
inline

Get a pointer to this trajectory.

Returns
Pointer to this trajectory.

◆ Get() [2/2]

const EDEPTrajectory* EDEPTrajectory::Get ( ) const
inline

Get a const pointer to this trajectory.

Returns
Const pointer to this trajectory.

◆ GetDepositedEnergy()

double EDEPTrajectory::GetDepositedEnergy ( sand::subdetector_t  c) const

Sum of the secondary deposits in c, 0 if there are no hits there.

Calculates the total deposited energy in the specified detector sand::subdetector_t.

Parameters
component_nameThe name of the detector sand::subdetector_t.
Returns
The total deposited energy in the specified sand::subdetector_t.

◆ GetDepth()

int EDEPTrajectory::GetDepth ( ) const
inline

Get the depth of this trajectory.

Returns
The depth of this trajectory.

◆ GetHitMap()

const EDEPHitsMap& EDEPTrajectory::GetHitMap ( ) const
inline

Get the hit map associated with this trajectory.

Returns
Const reference to the hit map associated with this trajectory.

◆ GetHitNear4DPoint()

const EDEPHit * EDEPTrajectory::GetHitNear4DPoint ( sand::vec_4d  point,
double  distance,
double  time 
) const

First hit near the 4D point, nullptr if none.

Returns an iterator to the hit near a given 4D point (space and time).

This function searches for a hit whose midpoint is within the specified spatial distance and time difference from the given 4D point. It returns an iterator to the first hit that matches the criteria.

Parameters
pointThe reference 4D point as a sand::vec_4d (includes space and time components).
distanceThe maximum allowed spatial distance.
timeThe maximum allowed time difference.
Returns
An iterator to the first hit that is near the specified 4D point, or the end iterator if no hit matches.

◆ GetHitWithId()

const EDEPHit & EDEPTrajectory::GetHitWithId ( int  id) const

Returns the hit in the trajectory with the specified ID.

This function searches through all hits in the trajectory and returns the one that has a matching ID.

Parameters
idThe ID to search for.
Returns
the hit with the specified ID.

◆ GetId()

int EDEPTrajectory::GetId ( ) const
inline

Get the ID of this trajectory.

Returns
The ID of this trajectory.

◆ GetInitialMomentum()

sand::vec_4d EDEPTrajectory::GetInitialMomentum ( ) const
inline

Get the initial momentum of this trajectory.

Returns
The initial momentum of this trajectory.

◆ GetInteractionNumber()

int EDEPTrajectory::GetInteractionNumber ( ) const
inline

Get the number of the interaction that generated this trajectory.

Returns
The number of the interaction.

◆ GetParent()

EDEPTrajectory* EDEPTrajectory::GetParent ( ) const
inline

Get the parent trajectory of this trajectory.

Returns
Pointer to the parent trajectory.

◆ GetParentId()

int EDEPTrajectory::GetParentId ( ) const
inline

Get the parent ID of this trajectory.

Returns
The parent ID of this trajectory.

◆ GetPDGCode()

int EDEPTrajectory::GetPDGCode ( ) const
inline

Get the PDG code of this trajectory.

Returns
The PDG code of this trajectory.

◆ GetReaction()

std::string EDEPTrajectory::GetReaction ( ) const
inline

Get the reaction of the interaction that generated this trajectory.

Returns
The string corresponding to the reaction.

◆ GetTotalEnergyDeposit()

double EDEPTrajectory::GetTotalEnergyDeposit ( sand::subdetector_t  c) const

Sum of the total energy deposits (EDEPHit::GetEnergyDeposit) of the hits in c [MeV], 0 if there are none.

Calculates the total energy deposited by the trajectory in the specified detector sand::subdetector_t, as the sum of EDEPHit::GetEnergyDeposit over its hits there.

Parameters
cThe detector sand::subdetector_t.
Returns
The total energy deposit in the specified sand::subdetector_t [MeV], 0 if there are no hits there.

◆ GetTrackLength()

double EDEPTrajectory::GetTrackLength ( sand::subdetector_t  c) const

Sum of the track lengths (EDEPHit::GetTrackLength) of the hits in c [mm], 0 if there are none.

Calculates the length of the trajectory in the specified detector sand::subdetector_t, as the sum of EDEPHit::GetTrackLength over its hits there.

Parameters
cThe detector sand::subdetector_t.
Returns
The track length in the specified sand::subdetector_t [mm], 0 if there are no hits there.

◆ GetTrajectoryPoints()

const EDEPTrajectoryPoints& EDEPTrajectory::GetTrajectoryPoints ( ) const
inline

Get the trajectory points associated with this trajectory.

Returns
Const reference to the trajectory points associated with this trajectory.

◆ GetTrajectoryPointsVect()

std::vector< EDEPTrajectoryPoint > EDEPTrajectory::GetTrajectoryPointsVect ( ) const

Get the trajectory points associated with this trajectory.

Returns
All trajectory points associated with this trajectory ordered by increasing times.

◆ HasHitAfterTime()

bool EDEPTrajectory::HasHitAfterTime ( double  t) const

Checks if the trajectory has hits after a specified time.

Parameters
timeThe time threshold.
Returns
True if the trajectory has hits after the specified time, otherwise false.

◆ HasHitBeforeTime()

bool EDEPTrajectory::HasHitBeforeTime ( double  t) const

Checks if the trajectory has hits before a specified time.

Parameters
timeThe time threshold.
Returns
True if the trajectory has hits before the specified time, otherwise false.

◆ HasHitInEnergy()

bool EDEPTrajectory::HasHitInEnergy ( double  min,
double  max 
) const

Checks if the trajectory has hits within a specified energy range.

Parameters
minThe min of the energy range.
maxThe max of the energy range.
Returns
True if the trajectory has hits within the specified energy range, otherwise false.

◆ HasHitInTime()

bool EDEPTrajectory::HasHitInTime ( double  t0,
double  t1 
) const

Checks if the trajectory has hits within a specified time range.

Parameters
start_timeThe start of the time range.
stop_timeThe end of the time range.
Returns
True if the trajectory has hits within the specified time range, otherwise false.

◆ HasHitInTimeAndEnergy()

bool EDEPTrajectory::HasHitInTimeAndEnergy ( double  t0,
double  t1,
double  emin,
double  emax 
) const

Checks if the trajectory has hits within a specified energy and time ranges.

Parameters
start_timeThe start of the time range.
stop_timeThe stop of the time range.
min_energyThe min of the energy range.
max_energyThe max of the energy range.
Returns
True if the trajectory has hits within the specified energy range, otherwise false.

◆ HasHitNear4DPoint()

bool EDEPTrajectory::HasHitNear4DPoint ( sand::vec_4d  point,
double  distance,
double  time 
) const

Checks if any hit is within a given 4D distance (space and time) from a point.

This function checks if the midpoint of any hit is within the specified spatial distance and time difference from a given 4D point.

Parameters
pointThe reference 4D point as a sand::vec_4d (includes both space and time).
distanceThe maximum spatial distance to consider.
timeThe maximum time difference to consider.
Returns
true if a hit is within the specified space and time distance from the point, false otherwise.

◆ HasHitNearPoint()

bool EDEPTrajectory::HasHitNearPoint ( sand::pos_3d  point,
double  distance 
) const

Checks if any hit is within a given distance from a point.

This function determines if the midpoint of any hit is closer than the specified distance to the given point.

Parameters
pointThe reference point as a sand::pos_3d.
distanceThe maximum distance to consider.
Returns
true if a hit is within the specified distance from the point, false otherwise.

◆ HasHitWithEnergyLargerThan()

bool EDEPTrajectory::HasHitWithEnergyLargerThan ( double  e) const

Checks if the trajectory has hits with energy larger than the specified amount.

Parameters
timeThe energy threshold.
Returns
True if the trajectory has hits with energy larger than the specified amount, otherwise false.

◆ HasHitWithEnergySmallerThan()

bool EDEPTrajectory::HasHitWithEnergySmallerThan ( double  e) const

Checks if the trajectory has hits with energy smaller than the specified amount.

Parameters
timeThe energy threshold.
Returns
True if the trajectory has hits with energy smaller than the specified amount, otherwise false.

◆ HasHitWithIdInDetector()

bool EDEPTrajectory::HasHitWithIdInDetector ( int  id,
sand::subdetector_t  c 
) const

Checks if the trajectory has a hit with the specified ID in the specified detector sand::subdetector_t.

Parameters
idThe ID of the hit.
component_nameThe name of the detector sand::subdetector_t.
Returns
True if the trajectory has a hit with the specified ID in the specified sand::subdetector_t, otherwise false.

◆ IsTrajectorySaturated()

bool EDEPTrajectory::IsTrajectorySaturated ( ) const

True if the trajectory reached the edep-sim limit on the number of stored points.

Checks if the trajectory is saturated (i.e., has reached the maximum number of points).

Returns
True if the trajectory is saturated, otherwise false.

◆ Match()

bool EDEPTrajectory::Match ( std::string_view  volume,
std::initializer_list< std::string >  names 
)
static

True if volume contains any of names as a substring.

Matches a given volume name against a list of names.

Parameters
volumeThe volume name to match.
namesAn initializer list of names to match against.
Returns
True if the volume name matches any of the names in the list, otherwise false.

◆ operator=() [1/2]

EDEPTrajectory& EDEPTrajectory::operator= ( const EDEPTrajectory &  )
default

Assignment operator for EDEPTrajectory.

Parameters
trjThe EDEPTrajectory object to assign.
Returns
Reference to the assigned EDEPTrajectory object.

◆ operator=() [2/2]

EDEPTrajectory& EDEPTrajectory::operator= ( EDEPTrajectory &&  )
default

Move assignment operator for EDEPTrajectory.

Parameters
trjThe EDEPTrajectory object to move.
Returns
Reference to the moved EDEPTrajectory object.

◆ operator==()

bool EDEPTrajectory::operator== ( const EDEPTrajectory &  trj) const

Equality operator for EDEPTrajectory.

Parameters
trjThe EDEPTrajectory object to compare.
Returns
True if the trajectories are equal, false otherwise.

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