LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
UserActionManager.h
Go to the documentation of this file.
1 
36 #ifndef G4BASE_UserActionManager_H
37 #define G4BASE_UserActionManager_H
38 
39 #include "nug4/G4Base/UserAction.h"
40 
41 #include "Geant4/G4UserRunAction.hh"
42 #include "Geant4/G4UserEventAction.hh"
43 #include "Geant4/G4UserTrackingAction.hh"
44 #include "Geant4/G4UserSteppingAction.hh"
45 #include "Geant4/G4UserStackingAction.hh"
46 
47 #include "Geant4/G4Run.hh"
48 #include "Geant4/G4Event.hh"
49 #include "Geant4/G4Track.hh"
50 #include "Geant4/G4Step.hh"
51 
52 #include "Geant4/G4EventManager.hh"
53 #include "Geant4/G4TrackingManager.hh"
54 #include "Geant4/G4SteppingManager.hh"
55 
56 #include <vector>
57 
58 namespace g4b {
59 
60  class UserActionManager : public G4UserRunAction
61  , public G4UserEventAction
62  , public G4UserTrackingAction
63  , public G4UserSteppingAction
64  , public G4UserStackingAction {
65  public:
66 
67  // Access to instance:
68  static UserActionManager* Instance();
69 
70  virtual ~UserActionManager();
71 
72  // Delete all the UserAction classes we manage.
73  void Close();
74 
75  G4int GetSize() const { return fuserActions.size(); }
76  UserAction* GetAction(G4int i) const { return fuserActions[i]; }
77  UserAction* GetAction(std::string const& name) const;
78  G4int GetIndex(std::string const& name) const;
79 
80  void PrintActionList(std::string const& opt) const;
81 
82  static void AddAndAdoptAction(UserAction* a){ fuserActions.push_back(a); }
83 
84  // G4UserRunAction interfaces
85  virtual void BeginOfRunAction (const G4Run* );
86  virtual void EndOfRunAction (const G4Run* );
87  // G4UserEventAction interfaces
88  virtual void BeginOfEventAction (const G4Event*);
89  virtual void EndOfEventAction (const G4Event*);
90  // G4UserTrackingAction interfaces
91  virtual void PreUserTrackingAction (const G4Track*);
92  virtual void PostUserTrackingAction(const G4Track*);
93  // G4UserSteppingAction interface
94  virtual void UserSteppingAction (const G4Step* );
95  // G4UserStackingAction interfaces
96  virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*);
97  virtual void NewStage();
98  virtual void PrepareNewEvent();
99  virtual bool DoesAnyActionProvideStacking(); // do any managed UserActions do stacking
100 
101  // "Mysterious accessors": Where do the pointers to these managers
102  // come from? They are all defined in the G4User*Action classes.
103  // Use care when calling these accessors; for example, the
104  // SteppingManager is probably not available in a TrackingAction
105  // method. Keep the heirarchy in mind: Run > Event > Track > Step.
106  G4EventManager* GetEventManager() const { return fpEventManager; }
107  G4TrackingManager* GetTrackingManager() const { return fpTrackingManager; }
108  G4SteppingManager* GetSteppingManager() const { return fpSteppingManager; }
109 
110  private:
111  typedef std::vector<UserAction*> fuserActions_t;
113  static fuserActions_t fuserActions;
114 
115  protected:
116  // The constructor is protected according to the standard
117  // singleton pattern.
119 
120  };
121 
122 } // namespace g4b
123 
124 #endif // G4BASE_UserActionManager_H
UserAction * GetAction(G4int i) const
virtual bool DoesAnyActionProvideStacking()
intermediate_table::const_iterator const_iterator
virtual void UserSteppingAction(const G4Step *)
G4EventManager * GetEventManager() const
virtual void BeginOfEventAction(const G4Event *)
virtual void EndOfEventAction(const G4Event *)
G4int GetIndex(std::string const &name) const
see below
static void AddAndAdoptAction(UserAction *a)
G4TrackingManager * GetTrackingManager() const
virtual void BeginOfRunAction(const G4Run *)
fuserActions_t::const_iterator fuserActions_ptr_t
basic interface to Geant4 for ART-based software
std::vector< UserAction * > fuserActions_t
void PrintActionList(std::string const &opt) const
static UserActionManager * Instance()
virtual void EndOfRunAction(const G4Run *)
static fuserActions_t fuserActions
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *)
virtual void PostUserTrackingAction(const G4Track *)
G4SteppingManager * GetSteppingManager() const
virtual void PreUserTrackingAction(const G4Track *)