LDMX Software
TrackMap.h
1#ifndef SIMCORE_TRACKMAP_H_
2#define SIMCORE_TRACKMAP_H_
3
4// STL
5#include <unordered_map>
6
7// Geant4
8#include "G4Track.hh"
9
10// LDMX
11#include "SimCore/Event/SimParticle.h"
12
13namespace simcore {
14
25class TrackMap {
26 public:
31 void insert(const G4Track* track);
32
37 inline bool contains(const G4Track* track) const {
38 return ancestry_.find(track->GetTrackID()) != ancestry_.end();
39 }
40
45 bool isDescendant(int trackID, int ancestorID, int maximum_depth) const;
46
56 int findIncident(int trackID) const;
57
65 inline bool isSaved(int trackID) const {
66 return particle_map_.find(trackID) != particle_map_.end();
67 }
68
76 void save(const G4Track* track);
77
84 void traceAncestry();
85
93 void clear();
94
98 std::map<int, ldmx::SimParticle>& getParticleMap() { return particle_map_; }
99
100 private:
108 bool isInCalorimeterRegion(const G4Track* track) const;
109
110 private:
129 std::unordered_map<int, std::pair<int, bool>> ancestry_;
130
132 std::unordered_map<int, std::vector<int>> descendents_;
133
135 std::map<int, ldmx::SimParticle> particle_map_;
136};
137
138} // namespace simcore
139
140#endif
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:25
void clear()
Clear the internal maps.
Definition TrackMap.cxx:128
bool contains(const G4Track *track) const
Check if the passed track has already been inserted into the track map.
Definition TrackMap.h:37
std::map< int, ldmx::SimParticle > & getParticleMap()
Get the map of particles to be stored in output event.
Definition TrackMap.h:98
std::unordered_map< int, std::pair< int, bool > > ancestry_
ancestry map of particles in event (child -> parent)
Definition TrackMap.h:129
bool isSaved(int trackID) const
Return true if the given track ID is saved i.e.
Definition TrackMap.h:65
std::unordered_map< int, std::vector< int > > descendents_
descendents map of particles in event (parent -> children)
Definition TrackMap.h:132
bool isDescendant(int trackID, int ancestorID, int maximum_depth) const
Check if the track with the given ID is a descendant of the track with the given ancestor ID up to a ...
Definition TrackMap.cxx:10
void save(const G4Track *track)
Add a track to be stored into output map.
Definition TrackMap.cxx:54
std::map< int, ldmx::SimParticle > particle_map_
map of SimParticles that will be stored
Definition TrackMap.h:135
bool isInCalorimeterRegion(const G4Track *track) const
Was the input track generated inside the calorimeter region?
Definition TrackMap.cxx:134
void traceAncestry()
Trace the ancestry for the particles that will be stored.
Definition TrackMap.cxx:112
void insert(const G4Track *track)
Add a record in the map for the input track.
Definition TrackMap.cxx:30
int findIncident(int trackID) const
Find a trajectory's nearest parent that is incident on the calorimeter region.
Definition TrackMap.cxx:36
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...