3#include "EDEPTrajectory.h"
19 typedef std::vector<EDEPTrajectory>::iterator child_iterator;
28 typedef EDEPTrajectory value_type;
29 typedef std::forward_iterator_tag iterator_category;
30 typedef ptrdiff_t difference_type;
31 typedef value_type* pointer;
32 typedef value_type& reference;
34 reference operator * () {
return *current_it_;};
35 pointer operator -> () {
return &(*current_it_);};
36 bool operator == (
const iterator& it) {
return (this->parent_trj_ == it.parent_trj_ && this->current_it_ == it.current_it_);};
37 bool operator != (
const iterator& it) {
return (this->parent_trj_ != it.parent_trj_ || this->current_it_ != it.current_it_);};
39 iterator
operator ++ (
int) {iterator tmpIt = *
this; ++*
this;
return tmpIt;};
44 iterator(pointer parent_trj_, child_iterator child_it);
46 pointer parent_trj_ =
nullptr;
47 child_iterator current_it_;
49 friend class EDEPTree;
52 typedef std::vector<EDEPTrajectory>::const_iterator const_child_iterator;
58 class const_iterator {
61 typedef const EDEPTrajectory value_type;
62 typedef std::forward_iterator_tag iterator_category;
63 typedef ptrdiff_t difference_type;
64 typedef value_type* pointer;
65 typedef value_type& reference;
67 reference operator * () {
return *current_it_;};
68 pointer operator -> () {
return &(*current_it_);};
69 bool operator == (
const const_iterator& it) {
return (this->parent_trj_ == it.parent_trj_ && this->current_it_ == it.current_it_);};
70 bool operator != (
const const_iterator& it) {
return (this->parent_trj_ != it.parent_trj_ || this->current_it_ != it.current_it_);};
72 const_iterator
operator ++ (
int) {const_iterator tmpIt = *
this; ++*
this;
return tmpIt;};
77 const_iterator(pointer parent_trj_, const_child_iterator child_it);
79 pointer parent_trj_ =
nullptr;
80 const_child_iterator current_it_;
82 friend class EDEPTree;
109 iterator GetTrajectory(
int trj_id) {
return std::find_if(this->begin(), this->end(), [trj_id](
const EDEPTrajectory& trj){
return trj_id == trj.
GetId();});}
110 const_iterator GetTrajectory(
int trj_id)
const {
return std::find_if(this->begin(), this->end(), [trj_id](
const EDEPTrajectory& trj){
return trj_id == trj.
GetId();});}
154 template <
typename OutputIterator,
typename F>
155 OutputIterator
Filter(OutputIterator out_it, F&& funct) {
156 for (
auto first = this->begin(); first != this->end(); ++first)
158 if (std::forward<F>(funct)(*first))
170 void CreateTree(
const std::vector<EDEPTrajectory>& trajectories_vect);
component
Enum representing different components in the detector.
Definition EDEPUtils.h:12
std::vector< EDEPTrajectory > & GetChildrenTrajectories()
Get the children trajectories of this trajectory.
Definition EDEPTrajectory.h:133
int GetId() const
Get the ID of this trajectory.
Definition EDEPTrajectory.h:87
Const iterator for traversing the tree.
Definition EDEPTree.h:58
const_iterator & operator++()
Prefix increment operator for the const_iterator class.
Definition EDEPTree.cpp:63
Iterator for traversing the tree.
Definition EDEPTree.h:25
iterator & operator++()
Prefix increment operator for the iterator class.
Definition EDEPTree.cpp:20
iterator GetTrajectoryWithHitId(int id)
Returns an iterator to the trajectory containing a hit with the specified ID.
Definition EDEPTree.cpp:324
void RemoveTrajectoryFrom(int trj_id, iterator it)
Removes a trajectory from the tree at a specified position.
Definition EDEPTree.cpp:195
iterator GetTrajectoryWithHitIdInDetector(int id, component component_name)
Retrieves the iterator to the trajectory containing a hit with the given ID in the specified detector...
Definition EDEPTree.cpp:351
void AddTrajectoryTo(const EDEPTrajectory &trajectory, iterator it)
Adds a trajectory to the tree at a specified position.
Definition EDEPTree.cpp:171
void InizializeFromEdep(const TG4Event &edep_event, TGeoManager *geo)
Initializes the tree from a TG4Event and TGeoManager.
Definition EDEPTree.cpp:127
void AddTrajectory(const EDEPTrajectory &trajectory)
Adds a trajectory to the tree.
Definition EDEPTree.cpp:156
bool HasTrajectory(int trj_id) const
Checks if the tree contains a trajectory with the given ID.
Definition EDEPTree.cpp:216
void MoveTrajectoryTo(int id_to_move, int next_parent_id)
Moves a trajectory to a new parent trajectory.
Definition EDEPTree.cpp:204
OutputIterator Filter(OutputIterator out_it, F &&funct)
Filter trajectories based on a custom predicate and copy the results to an output iterator.
Definition EDEPTree.h:155
void InizializeFromTrj(const std::vector< EDEPTrajectory > &trajectories_vect)
Initializes the tree from a vector of trajectories.
Definition EDEPTree.cpp:147
iterator GetParentOf(int trj_id)
Retrieves the parent trajectory of a trajectory with the given ID.
Definition EDEPTree.cpp:250
void RemoveTrajectory(int trj_id)
Removes a trajectory from the tree.
Definition EDEPTree.cpp:186
bool IsTrajectoryIn(int trj_id, iterator it)
Checks if a trajectory is in a specified subtree.
Definition EDEPTree.cpp:227
EDEPTree()
Constructor for the EDEPTree class.
Definition EDEPTree.cpp:95
iterator GetTrajectoryEnd(iterator start)
Retrieves the iterator to the end of the subtree starting from the specified iterator position.
Definition EDEPTree.cpp:374
iterator GetTrajectoryFrom(int trj_id, iterator it)
Retrieves the iterator to the trajectory with the given ID within a specified subtree.
Definition EDEPTree.cpp:297