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

Represents a tree structure of trajectories. More...

#include <EDEPTree.h>

Inheritance diagram for EDEPTree:
EDEPTrajectory

Classes

class  const_iterator
 Const iterator for traversing the tree. More...
 
class  iterator
 Iterator for traversing the tree. More...
 

Public Types

typedef std::vector< EDEPTrajectory >::iterator child_iterator
 
typedef std::vector< EDEPTrajectory >::const_iterator const_child_iterator
 

Public Member Functions

 EDEPTree ()
 Constructor for the EDEPTree class.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void InizializeFromEdep (const TG4Event &edep_event, TGeoManager *geo)
 Initializes the tree from a TG4Event and TGeoManager.
 
void InizializeFromTrj (const std::vector< EDEPTrajectory > &trajectories_vect)
 Initializes the tree from a vector of trajectories.
 
void AddTrajectory (const EDEPTrajectory &trajectory)
 Adds a trajectory to the tree.
 
void AddTrajectoryTo (const EDEPTrajectory &trajectory, iterator it)
 Adds a trajectory to the tree at a specified position.
 
void RemoveTrajectory (int trj_id)
 Removes a trajectory from the tree.
 
void RemoveTrajectoryFrom (int trj_id, iterator it)
 Removes a trajectory from the tree at a specified position.
 
void MoveTrajectoryTo (int id_to_move, int next_parent_id)
 Moves a trajectory to a new parent trajectory.
 
bool HasTrajectory (int trj_id) const
 Checks if the tree contains a trajectory with the given ID.
 
bool IsTrajectoryIn (int trj_id, iterator it)
 Checks if a trajectory is in a specified subtree.
 
bool IsTrajectoryIn (int trj_id, const_iterator it) const
 Checks if a trajectory is in a specified subtree.
 
iterator GetTrajectory (int trj_id)
 
const_iterator GetTrajectory (int trj_id) const
 
iterator GetParentOf (int trj_id)
 Retrieves the parent trajectory of a trajectory with the given ID.
 
const_iterator GetParentOf (int trj_id) const
 Retrieves the parent trajectory of a trajectory with the given ID.
 
iterator GetParentOf (int trj_id, iterator it)
 Retrieves the parent trajectory of a trajectory with the given ID within a specified subtree.
 
const_iterator GetParentOf (int trj_id, const_iterator it) const
 Retrieves the parent trajectory of a trajectory with the given ID within a specified subtree.
 
iterator GetTrajectoryFrom (int trj_id, iterator it)
 Retrieves the iterator to the trajectory with the given ID within a specified subtree.
 
const_iterator GetTrajectoryFrom (int trj_id, const_iterator it) const
 Retrieves the iterator to the trajectory with the given ID within a specified subtree.
 
iterator GetTrajectoryEnd (iterator start)
 Retrieves the iterator to the end of the subtree starting from the specified iterator position.
 
const_iterator GetTrajectoryEnd (const_iterator start) const
 Retrieves the iterator to the end of the subtree starting from the specified iterator position.
 
iterator GetTrajectoryWithHitId (int id)
 Returns an iterator to the trajectory containing a hit with the specified ID.
 
const_iterator GetTrajectoryWithHitId (int id) const
 Returns a const iterator to the trajectory containing a hit with the specified ID.
 
iterator GetTrajectoryWithHitIdInDetector (int id, component component_name)
 Retrieves the iterator to the trajectory containing a hit with the given ID in the specified detector component.
 
const_iterator GetTrajectoryWithHitIdInDetector (int id, component component_name) const
 Retrieves the iterator to the trajectory containing a hit with the given ID in the specified detector component.
 
template<typename OutputIterator, typename F>
OutputIterator Filter (OutputIterator out_it, F &&funct)
 Filter trajectories based on a custom predicate and copy the results to an output iterator.
 
- Public Member Functions inherited from EDEPTrajectory
 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.
 

Detailed Description

Represents a tree structure of trajectories.

This class extends EDEPTrajectory to organize trajectories in a tree structure. It provides iterators for traversing the tree, as well as functions for adding, removing, and manipulating trajectories within the tree.

Constructor & Destructor Documentation

◆ EDEPTree()

EDEPTree::EDEPTree ( )

Constructor for the EDEPTree class.

Initializes the tree with default values.

Member Function Documentation

◆ AddTrajectory()

void EDEPTree::AddTrajectory ( const EDEPTrajectory & trajectory)

Adds a trajectory to the tree.

Parameters
trajectoryThe trajectory to add.

◆ AddTrajectoryTo()

void EDEPTree::AddTrajectoryTo ( const EDEPTrajectory & trajectory,
iterator it )

Adds a trajectory to the tree at a specified position.

Parameters
trajectoryThe trajectory to add.
itIterator pointing to the position where the trajectory should be added.

◆ Filter()

template<typename OutputIterator, typename F>
OutputIterator EDEPTree::Filter ( OutputIterator out_it,
F && funct )
inline

Filter trajectories based on a custom predicate and copy the results to an output iterator.

This function iterates over all trajectories within the tree and applies a custom predicate function to each trajectory. Trajectories that satisfy the filtering condition specified by the predicate function are copied to the provided output iterator.

Template Parameters
OutputIteratorThe type of the output iterator where the filtered trajectories will be copied.
FThe type of the predicate function used for filtering trajectories.
Parameters
out_itThe output iterator where the filtered trajectories will be copied.
functThe predicate function to filter trajectories. It should accept an EDEPTrajectory object as input and return a boolean value indicating whether the trajectory satisfies the filtering condition.
Returns
The output iterator after copying the filtered trajectories. It points to the position after the last copied trajectory in the output container.
Note
The predicate function should have the signature bool funct(const EDEPTrajectory&). It should return true if the given trajectory satisfies the filtering condition, and false otherwise.
Warning
The behavior of this function is undefined if the output iterator is not compatible with the type of trajectories being copied.
See also
EDEPTree

◆ GetParentOf() [1/4]

EDEPTree::iterator EDEPTree::GetParentOf ( int trj_id)

Retrieves the parent trajectory of a trajectory with the given ID.

Parameters
trj_idID of the trajectory.
Returns
Iterator pointing to the parent trajectory.

◆ GetParentOf() [2/4]

EDEPTree::const_iterator EDEPTree::GetParentOf ( int trj_id) const

Retrieves the parent trajectory of a trajectory with the given ID.

Parameters
trj_idID of the trajectory.
Returns
Iterator pointing to the parent trajectory.

◆ GetParentOf() [3/4]

EDEPTree::const_iterator EDEPTree::GetParentOf ( int tid,
const_iterator it ) const

Retrieves the parent trajectory of a trajectory with the given ID within a specified subtree.

Parameters
trj_idID of the trajectory.
itIterator pointing to the subtree.
Returns
Iterator pointing to the parent trajectory.

◆ GetParentOf() [4/4]

EDEPTree::iterator EDEPTree::GetParentOf ( int trj_id,
iterator it )

Retrieves the parent trajectory of a trajectory with the given ID within a specified subtree.

Parameters
trj_idID of the trajectory.
itIterator pointing to the subtree.
Returns
Iterator pointing to the parent trajectory.

◆ GetTrajectoryEnd() [1/2]

EDEPTree::const_iterator EDEPTree::GetTrajectoryEnd ( const_iterator start) const

Retrieves the iterator to the end of the subtree starting from the specified iterator position.

Parameters
startIterator pointing to the start of the subtree.
Returns
Iterator pointing to the end of the subtree.

◆ GetTrajectoryEnd() [2/2]

EDEPTree::iterator EDEPTree::GetTrajectoryEnd ( iterator start)

Retrieves the iterator to the end of the subtree starting from the specified iterator position.

Parameters
startIterator pointing to the start of the subtree.
Returns
Iterator pointing to the end of the subtree.

◆ GetTrajectoryFrom() [1/2]

EDEPTree::const_iterator EDEPTree::GetTrajectoryFrom ( int trj_id,
const_iterator it ) const

Retrieves the iterator to the trajectory with the given ID within a specified subtree.

Parameters
trj_idID of the trajectory.
itIterator pointing to the subtree.
Returns
Iterator pointing to the trajectory with the given ID.

◆ GetTrajectoryFrom() [2/2]

EDEPTree::iterator EDEPTree::GetTrajectoryFrom ( int trj_id,
iterator it )

Retrieves the iterator to the trajectory with the given ID within a specified subtree.

Parameters
trj_idID of the trajectory.
itIterator pointing to the subtree.
Returns
Iterator pointing to the trajectory with the given ID.

◆ GetTrajectoryWithHitId() [1/2]

EDEPTree::iterator EDEPTree::GetTrajectoryWithHitId ( int id)

Returns an iterator to the trajectory containing a hit with the specified ID.

This function searches through the tree for a trajectory that contains a hit with the given ID and returns an iterator to the matching trajectory.

Parameters
idThe ID of the hit to search for.
Returns
An iterator to the trajectory containing the hit, or the end iterator if no match is found.

◆ GetTrajectoryWithHitId() [2/2]

EDEPTree::const_iterator EDEPTree::GetTrajectoryWithHitId ( int id) const

Returns a const iterator to the trajectory containing a hit with the specified ID.

This function searches through the tree for a trajectory that contains a hit with the given ID and returns a const iterator to the matching trajectory.

Parameters
idThe ID of the hit to search for.
Returns
A const iterator to the trajectory containing the hit, or the end iterator if no match is found.

◆ GetTrajectoryWithHitIdInDetector() [1/2]

EDEPTree::iterator EDEPTree::GetTrajectoryWithHitIdInDetector ( int id,
component component_name )

Retrieves the iterator to the trajectory containing a hit with the given ID in the specified detector component.

Parameters
idID of the hit.
component_nameName of the detector component.
Returns
Iterator pointing to the trajectory containing the hit.

◆ GetTrajectoryWithHitIdInDetector() [2/2]

EDEPTree::const_iterator EDEPTree::GetTrajectoryWithHitIdInDetector ( int id,
component component_name ) const

Retrieves the iterator to the trajectory containing a hit with the given ID in the specified detector component.

Parameters
idID of the hit.
component_nameName of the detector component.
Returns
Iterator pointing to the trajectory containing the hit.

◆ HasTrajectory()

bool EDEPTree::HasTrajectory ( int trj_id) const

Checks if the tree contains a trajectory with the given ID.

Parameters
trj_idID of the trajectory to check.
Returns
True if the trajectory is found, otherwise false.

◆ InizializeFromEdep()

void EDEPTree::InizializeFromEdep ( const TG4Event & edep_event,
TGeoManager * geo )

Initializes the tree from a TG4Event and TGeoManager.

Parameters
edep_eventTG4Event object.
geoTGeoManager object.

◆ InizializeFromTrj()

void EDEPTree::InizializeFromTrj ( const std::vector< EDEPTrajectory > & trajectories_vect)

Initializes the tree from a vector of trajectories.

Parameters
trajectories_vectVector of trajectories.

◆ IsTrajectoryIn() [1/2]

bool EDEPTree::IsTrajectoryIn ( int trj_id,
const_iterator it ) const

Checks if a trajectory is in a specified subtree.

Parameters
trj_idID of the trajectory to check.
itIterator pointing to the subtree.
Returns
True if the trajectory is found in the subtree, otherwise false.

◆ IsTrajectoryIn() [2/2]

bool EDEPTree::IsTrajectoryIn ( int trj_id,
iterator it )

Checks if a trajectory is in a specified subtree.

Parameters
trj_idID of the trajectory to check.
itIterator pointing to the subtree.
Returns
True if the trajectory is found in the subtree, otherwise false.

◆ MoveTrajectoryTo()

void EDEPTree::MoveTrajectoryTo ( int id_to_move,
int next_parent_id )

Moves a trajectory to a new parent trajectory.

Parameters
id_to_moveID of the trajectory to move.
next_parent_idID of the new parent trajectory.

◆ RemoveTrajectory()

void EDEPTree::RemoveTrajectory ( int trj_id)

Removes a trajectory from the tree.

Parameters
trj_idID of the trajectory to remove.

◆ RemoveTrajectoryFrom()

void EDEPTree::RemoveTrajectoryFrom ( int trj_id,
iterator it )

Removes a trajectory from the tree at a specified position.

Parameters
trj_idID of the trajectory to remove.
itIterator pointing to the position of the trajectory to remove.

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