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 "G4Event.hh"
9#include "G4Track.hh"
10
11// LDMX
12#include "SimCore/Event/SimParticle.h"
14#include "SimCore/UserTrackInformation.h"
15
16namespace simcore {
17
28class TrackMap {
29 public:
34 void insert(const G4Track* track);
35
40 inline bool contains(const G4Track* track) const {
41 return ancestry_.find(track->GetTrackID()) != ancestry_.end();
42 }
43
48 bool isDescendant(int trackID, int ancestorID, int maximum_depth) const;
49
59 int findIncident(int trackID) const;
60
68 inline bool isSaved(int trackID) const {
69 return particle_map_.find(trackID) != particle_map_.end();
70 }
71
79 void save(const G4Track* track);
80
87 void traceAncestry();
88
96 void clear();
97
101 std::map<int, ldmx::SimParticle>& getParticleMap() { return particle_map_; }
102
103 private:
111 bool isInCalorimeterRegion(const G4Track* track) const;
112
113 private:
132 std::unordered_map<int, std::pair<int, bool>> ancestry_;
133
135 std::unordered_map<int, std::vector<int>> descendents_;
136
138 std::map<int, ldmx::SimParticle> particle_map_;
139};
140
141} // namespace simcore
142
143#endif
Class that provides extra information for Geant4 primary particles.
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:28
void clear()
Clear the internal maps.
Definition TrackMap.cxx:126
bool contains(const G4Track *track) const
Check if the passed track has already been inserted into the track map.
Definition TrackMap.h:40
std::map< int, ldmx::SimParticle > & getParticleMap()
Get the map of particles to be stored in output event.
Definition TrackMap.h:101
std::unordered_map< int, std::pair< int, bool > > ancestry_
ancestry map of particles in event (child -> parent)
Definition TrackMap.h:132
bool isSaved(int trackID) const
Return true if the given track ID is saved i.e.
Definition TrackMap.h:68
std::unordered_map< int, std::vector< int > > descendents_
descendents map of particles in event (parent -> children)
Definition TrackMap.h:135
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:9
void save(const G4Track *track)
Add a track to be stored into output map.
Definition TrackMap.cxx:53
std::map< int, ldmx::SimParticle > particle_map_
map of SimParticles that will be stored
Definition TrackMap.h:138
bool isInCalorimeterRegion(const G4Track *track) const
Was the input track generated inside the calorimeter region?
Definition TrackMap.cxx:132
void traceAncestry()
Trace the ancestry for the particles that will be stored.
Definition TrackMap.cxx:110
void insert(const G4Track *track)
Add a record in the map for the input track.
Definition TrackMap.cxx:29
int findIncident(int trackID) const
Find a trajectory's nearest parent that is incident on the calorimeter region.
Definition TrackMap.cxx:35