EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTUserActionDispatcher.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTUserActionDispatcher.hh
1 // ********************************************************************
2 //
3 // eASTUserActionDispatcher.hh
4 // Header file to store component-specific user actions
5 // Please note that this class does not handle the following actions
6 // - G4UserPrimaryGeneratorAction
7 // - G4UserSteppingAction
8 //
9 // History
10 // May 8th, 2021 : first implementation
11 //
12 // ********************************************************************
13 
14 #ifndef eASTUserActionDispatcher_H
15 #define eASTUserActionDispatcher_H 1
16 
17 class G4Region;
18 class G4UserRunAction;
19 class G4UserEventAction;
20 class G4UserStackingAction;
21 class G4UserTrackingAction;
22 
23 #include <map>
24 #include "G4Threading.hh"
25 
27 {
28  public:
29  using RunActions = std::map<G4Region*,G4UserRunAction*>;
30  using EventActions = std::map<G4Region*,G4UserEventAction*>;
31  using StackingActions = std::map<G4Region*,G4UserStackingAction*>;
32  using TrackingActions = std::map<G4Region*,G4UserTrackingAction*>;
33 
34  public:
36 
37  private:
38  static G4ThreadLocal eASTUserActionDispatcher* instance;
39 
40  private:
42  {;}
43 
44  public:
46 
47  public:
49  { return fpRunActions; }
51  { return fpEventActions; }
53  { return fpStackingActions; }
55  { return fpTrackingActions; }
56 
57  public:
58  void RegisterUserAction(G4Region* reg,G4UserRunAction* ua)
59  {
60  if(fpRunActions==nullptr) fpRunActions = new RunActions;
61  (*fpRunActions)[reg] = ua;
62  }
63  void RegisterUserAction(G4Region* reg,G4UserEventAction* ua)
64  {
65  if(fpEventActions==nullptr) fpEventActions = new EventActions;
66  (*fpEventActions)[reg] = ua;
67  }
68  void RegisterUserAction(G4Region* reg,G4UserStackingAction* ua)
69  {
71  (*fpStackingActions)[reg] = ua;
72  }
73  void RegisterUserAction(G4Region* reg,G4UserTrackingAction* ua)
74  {
76  (*fpTrackingActions)[reg] = ua;
77  }
78 
79  private:
84 };
85 
86 #endif
87