Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:05:25

0001 // ********************************************************************
0002 //
0003 // eASTUserActionDispatcher.hh
0004 //   Header file to store component-specific user actions
0005 //   Please note that this class does not handle the following actions
0006 //     - G4UserPrimaryGeneratorAction
0007 //     - G4UserSteppingAction
0008 //
0009 // History
0010 //   May 8th, 2021 : first implementation
0011 //
0012 // ********************************************************************
0013 
0014 #ifndef eASTUserActionDispatcher_H 
0015 #define eASTUserActionDispatcher_H 1
0016 
0017 class G4Region;
0018 class G4UserRunAction;
0019 class G4UserEventAction;
0020 class G4UserStackingAction;
0021 class G4UserTrackingAction;
0022 
0023 #include <map>
0024 #include "G4Threading.hh"
0025 
0026 class eASTUserActionDispatcher
0027 {
0028   public:
0029     using RunActions = std::map<G4Region*,G4UserRunAction*>;
0030     using EventActions = std::map<G4Region*,G4UserEventAction*>;
0031     using StackingActions = std::map<G4Region*,G4UserStackingAction*>;
0032     using TrackingActions = std::map<G4Region*,G4UserTrackingAction*>;
0033 
0034   public:
0035     static eASTUserActionDispatcher* Instance();
0036 
0037   private:
0038     static G4ThreadLocal eASTUserActionDispatcher* instance;
0039 
0040   private:
0041     eASTUserActionDispatcher()
0042     {;}
0043 
0044   public:
0045     ~eASTUserActionDispatcher();
0046 
0047   public:
0048     RunActions* GetRunActions() 
0049     { return fpRunActions; }
0050     EventActions* GetEventActions()
0051     { return fpEventActions; }
0052     StackingActions* GetStackingActions()
0053     { return fpStackingActions; }
0054     TrackingActions* GetTrackingActions()
0055     { return fpTrackingActions; }
0056 
0057   public:
0058     void RegisterUserAction(G4Region* reg,G4UserRunAction* ua)
0059     {
0060       if(fpRunActions==nullptr) fpRunActions = new RunActions;
0061       (*fpRunActions)[reg] = ua;
0062     }
0063     void RegisterUserAction(G4Region* reg,G4UserEventAction* ua)
0064     { 
0065       if(fpEventActions==nullptr) fpEventActions = new EventActions;
0066       (*fpEventActions)[reg] = ua; 
0067     }
0068     void RegisterUserAction(G4Region* reg,G4UserStackingAction* ua)
0069     { 
0070       if(fpStackingActions==nullptr) fpStackingActions = new StackingActions;
0071       (*fpStackingActions)[reg] = ua; 
0072     }
0073     void RegisterUserAction(G4Region* reg,G4UserTrackingAction* ua)
0074     { 
0075       if(fpTrackingActions==nullptr) fpTrackingActions = new TrackingActions;
0076       (*fpTrackingActions)[reg] = ua; 
0077     }
0078 
0079   private:
0080     RunActions* fpRunActions = nullptr;
0081     EventActions* fpEventActions = nullptr;
0082     StackingActions* fpStackingActions = nullptr;
0083     TrackingActions* fpTrackingActions = nullptr;
0084 };
0085 
0086 #endif
0087