LDMX Software
TrackingAction.h
Go to the documentation of this file.
1
7#ifndef SIMCORE_G4USER_USERTRACKINGACTION_H_
8#define SIMCORE_G4USER_USERTRACKINGACTION_H_
9
10/*~~~~~~~~~~~~~~~~*/
11/* C++ StdLib */
12/*~~~~~~~~~~~~~~~~*/
13#include <vector>
14
15// LDMX
16#include "SimCore/G4User/TrackMap.h"
17
18// Geant4
19#include "G4RunManager.hh"
20#include "G4UserTrackingAction.hh"
21
22/*~~~~~~~~~~~~~*/
23/* SimCore */
24/*~~~~~~~~~~~~~*/
26
27namespace simcore::g4user {
28
36class TrackingAction : public G4UserTrackingAction {
37 public:
75 void PreUserTrackingAction(const G4Track* aTrack) override;
76
94 void PostUserTrackingAction(const G4Track* aTrack) override;
95
101
106 static TrackingAction* get() {
107 return static_cast<TrackingAction*>(const_cast<G4UserTrackingAction*>(
108 G4RunManager::GetRunManager()->GetUserTrackingAction()));
109 }
110
116 void registerAction(std::shared_ptr<UserAction> trackingAction) {
117 tracking_actions_.push_back(trackingAction);
118 }
119
120 private:
122 std::vector<std::shared_ptr<UserAction>> tracking_actions_;
123
126}; // TrackingAction
127
128} // namespace simcore::g4user
129
130#endif
File holding UserAction prototype and supporting macro.
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:28
Implementation of user tracking action.
TrackMap & getTrackMap()
Get a handle to the current TrackMap for the event.
void PreUserTrackingAction(const G4Track *aTrack) override
Implementation of pre-tracking action.
void PostUserTrackingAction(const G4Track *aTrack) override
Implementation of post-tracking action.
void registerAction(std::shared_ptr< UserAction > trackingAction)
Register a user action of type RunAction with this class.
std::vector< std::shared_ptr< UserAction > > tracking_actions_
custom user actions to be called before and after processing a track
static TrackingAction * get()
Get a pointer to the current UserTrackingAction from the G4RunManager.
TrackMap track_map_
Stores parentage information for all tracks in the event.