EDEpReader
Loading...
Searching...
No Matches
EDEPTrajectory Class Reference

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

#include <EDEPTrajectory.h>

Inheritance diagram for EDEPTrajectory:
EDEPTree

Public Member Functions

 EDEPTrajectory (const TG4Trajectory &trajectory)
 
 EDEPTrajectory (const TG4Trajectory &trajectory, const std::map< int, std::map< component, std::vector< EDEPHit > > > &hit_map, const TG4PrimaryVertexContainer &primaries, TGeoManager *geo)
 Constructs an EDEPTrajectory object from a TG4Trajectory and hit information.
 
 EDEPTrajectory (const EDEPTrajectory &trj)
 Copy constructor for the EDEPTrajectory class.
 
 EDEPTrajectory (EDEPTrajectory &&trj)
 Copy assignment operator for the EDEPTrajectory class.
 
 ~EDEPTrajectory ()
 Destructor for EDEPTrajectory.
 
bool operator== (const EDEPTrajectory &trj)
 Equality operator for EDEPTrajectory.
 
EDEPTrajectoryoperator= (const EDEPTrajectory &trj)
 Assignment operator for EDEPTrajectory.
 
EDEPTrajectoryoperator= (EDEPTrajectory &&trj)
 Move assignment operator for EDEPTrajectory.
 
EDEPTrajectoryGet ()
 Get a pointer to this trajectory.
 
const EDEPTrajectoryGet () const
 Get a const pointer to this trajectory.
 
EDEPTrajectoryGetParent () const
 Get the parent trajectory of this trajectory.
 
int GetId () const
 Get the ID of this trajectory.
 
int GetDepth () const
 Get the depth of this trajectory.
 
int GetInteractionNumber () const
 Get the number of the interaction that generated this trajectory.
 
std::string GetReaction () const
 Get the reaction of the interaction that generated this trajectory.
 
int GetParentId () const
 Get the parent ID of this trajectory.
 
int GetPDGCode () const
 Get the PDG code of this trajectory.
 
std::vector< EDEPTrajectoryPoint > & GetFirstPointsInDetector (component component_name)
 
std::vector< EDEPTrajectoryPoint > & GetLastPointsInDetector (component component_name)
 
TLorentzVector GetInitialMomentum () const
 Get the initial momentum of this trajectory.
 
std::vector< EDEPTrajectory > & GetChildrenTrajectories ()
 Get the children trajectories of this trajectory.
 
const std::vector< EDEPTrajectory > & GetChildrenTrajectories () const
 Get the const children trajectories of this trajectory.
 
const EDEPHitsMap & GetHitMap () const
 Get the hit map associated with this trajectory.
 
const EDEPTrajectoryPoints & GetTrajectoryPoints () const
 Get the trajectory points associated with this trajectory.
 
std::vector< EDEPTrajectoryPointGetTrajectoryPointsVect () const
 Get the trajectory points associated with this trajectory.
 
std::vector< EDEPTrajectoryPointGetTrajectoryPointsInComponentVect (component component_name) const
 Get a time-ordered vector of the trajectory points associated with this trajectory, in the specified component.
 
void SetId (int id)
 Set the ID of this trajectory.
 
void SetDepth (int depth)
 Set the depth of this trajectory.
 
void SetParentId (int parent_id)
 Set the parent ID of this trajectory.
 
void SetParent (EDEPTrajectory *parent_trajectory)
 Set the parent trajectory of this trajectory.
 
void AddChild (const EDEPTrajectory &trajectory)
 Add a child trajectory to this trajectory.
 
bool RemoveChildWithId (int child_id)
 Removes a child trajectory with the given ID.
 
void ComputeDepth ()
 Computes the depth of the trajectory in the tree.
 
bool HasHits () const
 
bool HasHitWithId (int id) const
 Checks if any hit in the trajectory has the specified ID.
 
bool HasHitInDetector (component component_name) const
 Checks if the trajectory has hits in the specified detector component.
 
std::vector< EDEPHitGetHitsInDetector (component component_name) const
 
double GetPrimaryDepositedEnergy (component component_name)
 
double GetDepositedEnergy (component component_name)
 Calculates the total deposited energy in the specified detector component.
 
double GetTotalDepositedEnergy ()
 Calculates the total deposited energy ove all components.
 
double GetRecursivePrimaryDepositedEnergy (component component_name)
 Calculates the total (scintillation + other) deposited energy in the specified detector component by a trajectory and all its children.
 
double GetRecursiveDepositedEnergy (component component_name)
 Calculates the deposited energy from scintillation in the specified detector component by a trajectory and all its children.
 
double GetTotalRecursiveDepositedEnergy ()
 Calculates the deposited energy from scintillation over all components.
 
bool HasHitBeforeTime (double start_time) const
 Checks if the trajectory has hits before a specified time.
 
bool HasHitAfterTime (double stop_time) const
 Checks if the trajectory has hits after a specified time.
 
bool IsTrajectorySaturated () const
 Checks if the trajectory is saturated (i.e., has reached the maximum number of points).
 
bool HasHitInTime (double start_time, double stop_time) const
 Checks if the trajectory has hits within a specified time range.
 
bool HasHitWithIdInDetector (int id, component component_name) const
 Checks if the trajectory has a hit with the specified ID in the specified detector component.
 
bool HasHitNearPoint (TVector3 point, double distance) const
 Checks if any hit is within a given distance from a point.
 
bool HasHitNear4DPoint (TLorentzVector point, double distance, double time) const
 Checks if any hit is within a given 4D distance (space and time) from a point.
 
std::vector< EDEPHit >::iterator GetHitNear4DPoint (TLorentzVector point, double distance, double time)
 Returns an iterator to the hit near a given 4D point (space and time).
 
std::string Print (std::string &full_out, int depth=100, int current_depth=0) const
 Prints the trajectory information to stdout and stores it in a string.
 
bool IsEntering (component component_name) const
 Checks if the trajectory is entering the specified detector component.
 
bool IsExiting (component component_name) const
 Checks if the trajectory is exiting the specified detector component.
 
component GetStartDetector () const
 Retrieves the component containing the first point of the trajectory.
 
bool StartsInDetector (component component_name) const
 Checks if the trajectory has its first TrajectoryPoint in the specified component.
 
template<typename Funct>
bool HasHitWhere (Funct &&f) const
 
template<typename Funct>
std::vector< EDEPHit >::iterator GetHitWhere (Funct &&f)
 
bool Match (std::string volume, std::initializer_list< std::string > names) const
 Matches a given volume name against a list of names.
 
void CheckInNext (bool *in, bool *next, TG4TrajectoryPoint it, TG4TrajectoryPoint next_it)
 Checks for transitions between detector components in a particle trajectory.
 

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.

Constructor & Destructor Documentation

◆ EDEPTrajectory() [1/3]

EDEPTrajectory::EDEPTrajectory ( const TG4Trajectory & trajectory,
const std::map< int, std::map< component, std::vector< EDEPHit > > > & hit_map,
const TG4PrimaryVertexContainer & primaries,
TGeoManager * geo )

Constructs an EDEPTrajectory object from a TG4Trajectory and hit information.

This constructor converts a TG4Trajectory object into an EDEPTrajectory, categorizing the trajectory points into different components based on geometry and associating hits with the trajectory. It also handles entering and exiting of different volume regions and maps hits to their respective components.

Parameters
trajectoryThe TG4Trajectory object to be converted.
hitsA map of hit segment detectors, containing hits associated with different components.
primariesA container for primary vertex information to track interaction number and reaction type.
geoThe TGeoManager object representing the detector geometry for identifying volume regions.

◆ EDEPTrajectory() [2/3]

EDEPTrajectory::EDEPTrajectory ( const EDEPTrajectory & trj)

Copy constructor for the EDEPTrajectory class.

Parameters
trjThe EDEPTrajectory object to copy.

◆ EDEPTrajectory() [3/3]

EDEPTrajectory::EDEPTrajectory ( EDEPTrajectory && trj)

Copy assignment operator for the EDEPTrajectory class.

Parameters
trjThe EDEPTrajectory object to copy.
Returns
Reference to the copied EDEPTrajectory object.

Member Function Documentation

◆ AddChild()

void EDEPTrajectory::AddChild ( const EDEPTrajectory & trajectory)
inline

Add a child trajectory to this trajectory.

Parameters
trajectoryThe child trajectory to add.

◆ CheckInNext()

void EDEPTrajectory::CheckInNext ( bool * in,
bool * next,
TG4TrajectoryPoint it,
TG4TrajectoryPoint next_it )

Checks for transitions between detector components in a particle trajectory.

This function examines the current and next trajectory points to determine if a transition occurs from one detector component to another. If a transition is detected, it updates the entering and exiting state of the respective components and stores the associated trajectory points.

The in and next arrays should reflect the following order of components:

  • 0: GRAIN
  • 1: STRAW
  • 2: DRIFT
  • 3: ECAL
  • 4: MAGNET
  • 5: WORLD
Parameters
inPointer to a boolean array indicating the components the current trajectory point is inside.
nextPointer to a boolean array indicating the components the next trajectory point is inside.
itThe current trajectory point being checked.
next_itThe next trajectory point being checked.

◆ 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.

◆ GetChildrenTrajectories() [1/2]

std::vector< EDEPTrajectory > & EDEPTrajectory::GetChildrenTrajectories ( )
inline

Get the children trajectories of this trajectory.

Returns
Reference to the vector of children trajectories.

◆ GetChildrenTrajectories() [2/2]

const std::vector< EDEPTrajectory > & EDEPTrajectory::GetChildrenTrajectories ( ) const
inline

Get the const children trajectories of this trajectory.

Returns
Const reference to the vector of children trajectories.

◆ GetDepositedEnergy()

double EDEPTrajectory::GetDepositedEnergy ( component component_name)

Calculates the total deposited energy in the specified detector component.

Parameters
component_nameThe name of the detector component.
Returns
The total deposited energy in the specified component.

◆ 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()

std::vector< EDEPHit >::iterator EDEPTrajectory::GetHitNear4DPoint ( TLorentzVector point,
double distance,
double time )

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 TLorentzVector (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.

◆ GetId()

int EDEPTrajectory::GetId ( ) const
inline

Get the ID of this trajectory.

Returns
The ID of this trajectory.

◆ GetInitialMomentum()

TLorentzVector 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.

◆ GetRecursiveDepositedEnergy()

double EDEPTrajectory::GetRecursiveDepositedEnergy ( component component_name)

Calculates the deposited energy from scintillation in the specified detector component by a trajectory and all its children.

Parameters
component_nameThe name of the detector component.
Returns
The total deposited energy in the specified component.

◆ GetRecursivePrimaryDepositedEnergy()

double EDEPTrajectory::GetRecursivePrimaryDepositedEnergy ( component component_name)

Calculates the total (scintillation + other) deposited energy in the specified detector component by a trajectory and all its children.

Parameters
component_nameThe name of the detector component.
Returns
The total deposited energy in the specified component.

◆ GetStartDetector()

component EDEPTrajectory::GetStartDetector ( ) const

Retrieves the component containing the first point of the trajectory.

Returns
The component containing the first (time-wise) point of the trajectory.

◆ GetTotalDepositedEnergy()

double EDEPTrajectory::GetTotalDepositedEnergy ( )

Calculates the total deposited energy ove all components.

Parameters

return The total deposited energy in the specified component.

◆ GetTotalRecursiveDepositedEnergy()

double EDEPTrajectory::GetTotalRecursiveDepositedEnergy ( )

Calculates the deposited energy from scintillation over all components.

Parameters
component_nameThe name of the detector component.
Returns
The total deposited energy in the specified component.

◆ 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.

◆ GetTrajectoryPointsInComponentVect()

std::vector< EDEPTrajectoryPoint > EDEPTrajectory::GetTrajectoryPointsInComponentVect ( component component_name) const

Get a time-ordered vector of the trajectory points associated with this trajectory, in the specified component.

Returns
All trajectory points associated with this trajectory in the given component, ordered by increasing times.

◆ 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 time) 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 time) 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.

◆ HasHitInDetector()

bool EDEPTrajectory::HasHitInDetector ( component component_name) const

Checks if the trajectory has hits in the specified detector component.

Parameters
component_nameThe name of the detector component.
Returns
True if the trajectory has hits in the specified component, otherwise false.

◆ HasHitInTime()

bool EDEPTrajectory::HasHitInTime ( double start_time,
double stop_time ) 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.

◆ HasHitNear4DPoint()

bool EDEPTrajectory::HasHitNear4DPoint ( TLorentzVector 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 TLorentzVector (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 ( TVector3 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 TVector3.
distanceThe maximum distance to consider.
Returns
true if a hit is within the specified distance from the point, false otherwise.

◆ HasHitWithId()

bool EDEPTrajectory::HasHitWithId ( int id) const

Checks if any hit in the trajectory has the specified ID.

This function searches through all hits in the trajectory and returns true if any hit has a matching ID.

Parameters
idThe ID to search for.
Returns
true if a hit with the specified ID is found, false otherwise.

◆ HasHitWithIdInDetector()

bool EDEPTrajectory::HasHitWithIdInDetector ( int id,
component component_name ) const

Checks if the trajectory has a hit with the specified ID in the specified detector component.

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

◆ IsEntering()

bool EDEPTrajectory::IsEntering ( component component_name) const

Checks if the trajectory is entering the specified detector component.

Parameters
component_nameThe name of the detector component.
Returns
True if the trajectory is entering the specified component, otherwise false.

◆ IsExiting()

bool EDEPTrajectory::IsExiting ( component component_name) const

Checks if the trajectory is exiting the specified detector component.

Parameters
component_nameThe name of the detector component.
Returns
True if the trajectory is exiting the specified component, otherwise false.

◆ IsTrajectorySaturated()

bool EDEPTrajectory::IsTrajectorySaturated ( ) const

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 volume,
std::initializer_list< std::string > names ) const

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 & trj)

Assignment operator for EDEPTrajectory.

Copy assignment operator for the EDEPTrajectory class.

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

◆ operator=() [2/2]

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

Move assignment operator for EDEPTrajectory.

Move assignment operator for the EDEPTrajectory class.

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

◆ operator==()

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

Equality operator for EDEPTrajectory.

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

◆ Print()

std::string EDEPTrajectory::Print ( std::string & full_out,
int depth = 100,
int current_depth = 0 ) const

Prints the trajectory information to stdout and stores it in a string.

Parameters
full_outReference to a string to store the trajectory information.
depthMaximum depth to print.
current_depthCurrent depth in the tree.
Returns
String containing the trajectory information.

◆ RemoveChildWithId()

bool EDEPTrajectory::RemoveChildWithId ( int child_id)

Removes a child trajectory with the given ID.

Parameters
child_idID of the child trajectory to remove.
Returns
True if a child with the given ID was removed, otherwise false.

◆ SetDepth()

void EDEPTrajectory::SetDepth ( int depth)
inline

Set the depth of this trajectory.

Parameters
depthThe depth to set.

◆ SetId()

void EDEPTrajectory::SetId ( int id)
inline

Set the ID of this trajectory.

Parameters
idThe ID to set.

◆ SetParent()

void EDEPTrajectory::SetParent ( EDEPTrajectory * parent_trajectory)
inline

Set the parent trajectory of this trajectory.

Parameters
parent_trajectoryThe parent trajectory to set.

◆ SetParentId()

void EDEPTrajectory::SetParentId ( int parent_id)
inline

Set the parent ID of this trajectory.

Parameters
parent_idThe parent ID to set.

◆ StartsInDetector()

bool EDEPTrajectory::StartsInDetector ( component component_name) const

Checks if the trajectory has its first TrajectoryPoint in the specified component.

Parameters
component_nameThe name of the detector component.
Returns
True if the trajectory has its first Trajectory point within the specified component.

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