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/TrackMap.h"
17
18// Geant4
19#include "G4RunManager.hh"
20#include "G4UserTrackingAction.hh"
21
22/*~~~~~~~~~~~~~*/
23/* SimCore */
24/*~~~~~~~~~~~~~*/
25#include "SimCore/UserAction.h"
26
27namespace simcore::g4user {
28
36class TrackingAction : public G4UserTrackingAction {
37 public:
42
46 virtual ~TrackingAction() {}
47
85 void PreUserTrackingAction(const G4Track* aTrack);
86
104 void PostUserTrackingAction(const G4Track* aTrack);
105
111
116 static TrackingAction* get() {
117 return static_cast<TrackingAction*>(const_cast<G4UserTrackingAction*>(
118 G4RunManager::GetRunManager()->GetUserTrackingAction()));
119 }
120
126 void registerAction(UserAction* trackingAction) {
127 trackingActions_.push_back(trackingAction);
128 }
129
130 private:
132 std::vector<UserAction*> trackingActions_;
133
136}; // TrackingAction
137
138} // namespace simcore::g4user
139
140#endif
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:28
Interface that defines a user action.
Definition UserAction.h:42
Implementation of user tracking action.
void PostUserTrackingAction(const G4Track *aTrack)
Implementation of post-tracking action.
void registerAction(UserAction *trackingAction)
Register a user action of type RunAction with this class.
TrackingAction()
Class constructor.
TrackMap & getTrackMap()
Get a handle to the current TrackMap for the event.
void PreUserTrackingAction(const G4Track *aTrack)
Implementation of pre-tracking action.
TrackMap trackMap_
Stores parentage information for all tracks in the event.
static TrackingAction * get()
Get a pointer to the current UserTrackingAction from the G4RunManager.
virtual ~TrackingAction()
Class destructor.
std::vector< UserAction * > trackingActions_
custom user actions to be called before and after processing a track