3 #include <edep_reader/EDEPTrajectory.h>
5 #include <unordered_map>
43 std::size_t
size()
const {
return order_.size(); }
48 bool HasTrajectory(
int trj_id)
const {
return id_to_pos_.find(trj_id) != id_to_pos_.end(); }
49 iterator GetTrajectory(
int trj_id) {
return at_pos(find_pos(trj_id)); }
50 const_iterator GetTrajectory(
int trj_id)
const {
return at_pos(find_pos(trj_id)); }
58 iterator GetTrajectoryWithHitIdInDetector(
int id, sand::subdetector_t c);
59 const_iterator GetTrajectoryWithHitIdInDetector(
int id, sand::subdetector_t c)
const;
62 return (
id >= 0 &&
static_cast<std::size_t
>(
id) < hit_ptr_.size()) ? hit_ptr_.at(
id) :
nullptr;
66 template <
typename OutputIterator,
typename F>
67 OutputIterator
Filter(OutputIterator out_it, F&& funct)
const {
68 for (
const auto& trj : *
this) {
79 unsigned classify(
const TGeoNode* node);
80 void fill_points(
EDEPTrajectory& trj,
const TG4Trajectory& g4trj, TGeoNavigator& nav);
81 void check_in_next(
EDEPTrajectory& trj,
unsigned in,
unsigned next,
const TG4TrajectoryPoint& pt,
82 const TG4TrajectoryPoint& next_pt)
const;
84 int find_pos(
int trj_id)
const {
85 auto it = id_to_pos_.find(trj_id);
86 return it == id_to_pos_.end() ? -1 : it->second;
88 int hit_pos(
int hit_id)
const {
89 return (hit_id >= 0 &&
static_cast<std::size_t
>(hit_id) < hit_to_pos_.size()) ? hit_to_pos_.at(hit_id) : -1;
91 iterator at_pos(
int pos) {
return pos < 0 ? end() : begin() + pos; }
92 const_iterator at_pos(
int pos)
const {
return pos < 0 ? end() : begin() + pos; }
94 std::vector<EDEPTrajectory> nodes_;
95 std::vector<EDEPTrajectory*> order_;
96 std::unordered_map<int, int> id_to_pos_;
97 std::vector<int> hit_to_pos_;
98 std::vector<const EDEPHit*> hit_ptr_;
99 std::unordered_map<const TGeoNode*, unsigned> volume_cache_;
100 std::vector<unsigned> point_volumes_;
Represents a hit in a detector.
Definition: EDEPHit.h:17
Represents a trajectory of a particle through a detector.
Definition: EDEPTrajectory.h:96
Tree of the trajectories of an edep-sim event. The tree itself is the (id -1) root,...
Definition: EDEPTree.h:24
std::size_t size() const
Total number of trajectories in the tree.
Definition: EDEPTree.h:43
iterator GetTrajectoryWithHitId(int id)
Iterator to the trajectory that produced hit id, end() if there is none.
Definition: EDEPTree.h:56
OutputIterator Filter(OutputIterator out_it, F &&funct) const
Copies the trajectories satisfying funct to out_it.
Definition: EDEPTree.h:67
iterator GetParentOf(int trj_id)
Iterator to the parent of trj_id, end() if the trajectory is unknown or a primary.
Definition: EDEPTree.cpp:266
void InizializeFromEdep(const TG4Event &edep_event)
Rebuilds the tree from edep_event, replacing the previous content.
Definition: EDEPTree.cpp:143
const EDEPHit * GetHit(int id) const
The hit with global index id, nullptr if it does not belong to any trajectory.
Definition: EDEPTree.h:61
Definition: EDEPTrajectory.h:21