Geant4Customization.h
Go to the documentation of this file.
1 #ifndef _tls_Geant4Customization_h_
2 #define _tls_Geant4Customization_h_
3 
4 #include <tls/G4VPhysicsListCustomization.h>
5 
6 #include <G4VUserDetectorConstruction.hh>
7 #include <G4VUserPrimaryGeneratorAction.hh>
8 #include <G4UserStackingAction.hh>
9 #include <G4UserTrackingAction.hh>
10 #include <G4UserSteppingAction.hh>
11 #include <G4UserEventAction.hh>
12 #include <G4UserRunAction.hh>
13 #include <G4RunManager.hh>
14 
15 #include <boost/shared_ptr.hpp>
16 
17 #include <string>
18 
19 
20 namespace tls {
21 
39  public:
41  Geant4Customization(const std::string& name,
42  G4VUserDetectorConstruction* const construction = nullptr,
43  G4VUserPhysicsList* const physicsList = nullptr,
44  G4VUserPrimaryGeneratorAction* const primaryGenerator = nullptr) :
45  fName(name),
46  fDetectorConstruction(construction),
47  fPhysicsList(physicsList),
48  fPrimaryGenerator(primaryGenerator)
49  { }
50 
51  virtual ~Geant4Customization() = default;
52 
53  std::string GetName() const { return fName; }
54 
55  void SetPhysicsList(G4VUserPhysicsList* const physicsList)
56  { fPhysicsList = physicsList; }
57 
58  void SetDetectorConstruction(G4VUserDetectorConstruction* const construction)
59  { fDetectorConstruction = construction; }
60 
61  void SetStackingAction(G4UserStackingAction* const action)
62  { fStackingAction.reset(action); }
63  void SetTrackingAction(G4UserTrackingAction* const action)
64  { fTrackingAction.reset(action); }
65  void SetSteppingAction(G4UserSteppingAction* const action)
66  { fSteppingAction.reset(action); }
67  void SetEventAction(G4UserEventAction* const action)
68  { fEventAction.reset(action); }
69  void SetRunAction(G4UserRunAction* const action)
70  { fRunAction.reset(action); }
71 
72  void SetPrimaryGenerator(G4VUserPrimaryGeneratorAction* const action)
73  { fPrimaryGenerator.reset(action); }
74 
75  G4VUserDetectorConstruction* GetDetectorConstruction()
76  { return fDetectorConstruction; }
77  G4VUserPhysicsList* GetPhysicsList() { return fPhysicsList; }
79  { return dynamic_cast<G4VPhysicsListCustomization*>(fPhysicsList); }
80 
81  G4UserStackingAction* GetStackingAction()
82  { return fStackingAction.get(); }
83  G4UserTrackingAction* GetTrackingAction()
84  { return fTrackingAction.get(); }
85  G4UserSteppingAction* GetSteppingAction()
86  { return fSteppingAction.get(); }
87  G4UserEventAction* GetEventAction()
88  { return fEventAction.get(); }
89  G4UserRunAction* GetRunAction()
90  { return fRunAction.get(); }
91 
92  G4VUserPrimaryGeneratorAction* GetPrimaryGenerator()
93  { return fPrimaryGenerator.get(); }
94 
95  void SetRunManager(boost::shared_ptr<G4RunManager> action)
96  { fG4RunManager = action; }
97 
98  private:
99  std::string fName;
100 
101  // Can't delete construction neither before nor after run manager
102  // Run manager destructor only seems to call the destructor for
103  // the current construction and they never get deleted as result.
104  G4VUserDetectorConstruction* fDetectorConstruction = nullptr;
105 
106  // Physics list is owned by the global physics list.
107  G4VUserPhysicsList* fPhysicsList = nullptr;
108 
109  boost::shared_ptr<G4VUserPrimaryGeneratorAction> fPrimaryGenerator;
110 
111  boost::shared_ptr<G4UserStackingAction> fStackingAction;
112  boost::shared_ptr<G4UserTrackingAction> fTrackingAction;
113  boost::shared_ptr<G4UserSteppingAction> fSteppingAction;
114  boost::shared_ptr<G4UserEventAction> fEventAction;
115  boost::shared_ptr<G4UserRunAction> fRunAction;
116 
117  boost::shared_ptr<G4RunManager> fG4RunManager;
118 
119  };
120 
121 }
122 
123 
124 #endif
void SetRunAction(G4UserRunAction *const action)
boost::shared_ptr< G4VUserPrimaryGeneratorAction > fPrimaryGenerator
boost::shared_ptr< G4UserSteppingAction > fSteppingAction
void SetPrimaryGenerator(G4VUserPrimaryGeneratorAction *const action)
void SetPhysicsList(G4VUserPhysicsList *const physicsList)
G4UserRunAction * GetRunAction()
void SetStackingAction(G4UserStackingAction *const action)
boost::shared_ptr< G4UserStackingAction > fStackingAction
void SetDetectorConstruction(G4VUserDetectorConstruction *const construction)
boost::shared_ptr< G4RunManager > fG4RunManager
G4UserEventAction * GetEventAction()
void SetRunManager(boost::shared_ptr< G4RunManager > action)
void SetEventAction(G4UserEventAction *const action)
std::string GetName() const
G4VUserPhysicsList * fPhysicsList
boost::shared_ptr< G4UserEventAction > fEventAction
Data structure to hold the different Geant4 global objects required to run a single module...
G4VUserDetectorConstruction * fDetectorConstruction
void SetTrackingAction(G4UserTrackingAction *const action)
G4UserTrackingAction * GetTrackingAction()
G4VUserPhysicsList * GetPhysicsList()
virtual ~Geant4Customization()=default
G4VUserPrimaryGeneratorAction * GetPrimaryGenerator()
G4VUserDetectorConstruction * GetDetectorConstruction()
G4VPhysicsListCustomization * GetPhysicsListCustomization()
Geant4Customization(const std::string &name, G4VUserDetectorConstruction *const construction=nullptr, G4VUserPhysicsList *const physicsList=nullptr, G4VUserPrimaryGeneratorAction *const primaryGenerator=nullptr)
G4UserSteppingAction * GetSteppingAction()
G4UserStackingAction * GetStackingAction()
void SetSteppingAction(G4UserSteppingAction *const action)
boost::shared_ptr< G4UserTrackingAction > fTrackingAction
boost::shared_ptr< G4UserRunAction > fRunAction
Class to specify customization of the standard global PhysicsList that are handled by the Geant4Manag...

, generated on Tue Sep 26 2023.