class that handles multiple Geant4 runs in one offline session More...
#include <Geant4Manager.h>
Public Member Functions | |
void | AddCustomization (Geant4Customization &custom) |
void | AddVisManager (G4VisManager *visManager) |
Add a visualization manager. Only one visualization manager is accepted. More... | |
void | Customize (const std::string &name) |
void | DumpProcesses () |
G4RunManager * | GetRunManager () |
void | NotifyDelete () |
Book-keeping method. Call this to let the manager know your module does not need Geant4 anymore. More... | |
void | Reset () |
Undo the customizations introduced by the current configuration. More... | |
void | SetDefaultPhysicsList (G4VUserPhysicsList *physicsList) |
Set the default physics list. This will throw an exception if the run manager has been initialized already. More... | |
Public Attributes | |
static T &return | instance |
Private Member Functions | |
Geant4Manager () | |
Geant4Manager (const Geant4Manager &) | |
void | InitPhysics () |
Geant4Manager & | operator= (const Geant4Manager &) |
void | SetVerbosity (int verbosity) |
~Geant4Manager () | |
Private Attributes | |
unsigned int | fClosedModules = 0 |
std::string | fCurrentCustomization |
std::map< std::string, Geant4Customization > | fCustomizations |
GlobalPhysicsList * | fMasterPhysicsList = nullptr |
bool | fPhysicsInitialized = false |
G4RunManager * | fRunManager = nullptr |
unsigned int | fVerboseLevel = 0 |
G4VisManager * | fVisManager = nullptr |
Friends | |
class | utl::Singleton< Geant4Manager > |
class that handles multiple Geant4 runs in one offline session
The Geant4Manager class is the main class in the Geant4 tools group. It handles (as best as we can) the switching between different sets of Geant4 configurations. It also initializes the run manager, sets the seed in CLHEPs random engine, and redirects Geant4 output through the framework's error logger.
To run a Geant4 module in the same sequence as another Geant4 module, each module has to provide a class derived from Geant4Customization. This will contain a G4VPhysicsListCustomization, a G4VUserDetectorConstruction, a G4VUserPrimaryGeneratorAction, and optionally some user actions.
An attempt was made to automate the memory handling. This did not work because the singleton instance is deleted at exit but it seems to happen after something else in Geant4 is already deleted, giving a segmentation fault at exit. Haven't checked this further. As a result, each module that registers a customization has to call the NotifyDelete method. After this method is called as many times as the AddCustomization method, Geant4's run manager is deleted.
Definition at line 52 of file Geant4Manager.h.
|
private |
Definition at line 32 of file Geant4Manager.cc.
References AddCustomization(), fwk::RandomEngineRegistry::eDetector, fMasterPhysicsList, fRunManager, fwk::CoordinateSystemRegistry::Get(), and INFO.
|
inlineprivate |
Definition at line 84 of file Geant4Manager.h.
|
private |
void tls::Geant4Manager::AddCustomization | ( | Geant4Customization & | custom | ) |
This is the main method a Geant4 module needs to call. It should be called in the module's Init method, to give chance to all modules to provide their own customization before doing any actual simulation.
Definition at line 138 of file Geant4Manager.cc.
References fCustomizations, fMasterPhysicsList, tls::Geant4Customization::GetDetectorConstruction(), tls::Geant4Customization::GetName(), tls::Geant4Customization::GetPhysicsList(), and tls::GlobalPhysicsList::RegisterPhysics().
Referenced by Geant4Manager().
void tls::Geant4Manager::AddVisManager | ( | G4VisManager * | visManager | ) |
Add a visualization manager. Only one visualization manager is accepted.
Definition at line 127 of file Geant4Manager.cc.
References fVisManager.
void tls::Geant4Manager::Customize | ( | const std::string & | name | ) |
Method to switch to one particular configuration. This method should be called from the Run method, right before calling beamOn.
Definition at line 148 of file Geant4Manager.cc.
References tls::G4VPhysicsListCustomization::ActivateCustomProcesses(), DumpProcesses(), fCurrentCustomization, fCustomizations, fPhysicsInitialized, fRunManager, fVerboseLevel, INFO, InitPhysics(), Reset(), and tls::G4VPhysicsListCustomization::SetCustomCuts().
void tls::Geant4Manager::DumpProcesses | ( | ) |
Definition at line 225 of file Geant4Manager.cc.
References ERROR, INFO, and particle.
Referenced by Customize().
|
inline |
Definition at line 55 of file Geant4Manager.h.
References fRunManager.
|
private |
Definition at line 77 of file Geant4Manager.cc.
References RdGeoCeLDFFitter::c, fCustomizations, fPhysicsInitialized, fRunManager, tls::G4VPhysicsListCustomization::InactivateCustomProcesses(), and INFO.
Referenced by Customize().
void tls::Geant4Manager::NotifyDelete | ( | ) |
Book-keeping method. Call this to let the manager know your module does not need Geant4 anymore.
Definition at line 98 of file Geant4Manager.cc.
References ERROR, fClosedModules, fCustomizations, fRunManager, fVisManager, INFO, Reset(), and WARNING.
|
private |
void tls::Geant4Manager::Reset | ( | ) |
Undo the customizations introduced by the current configuration.
Definition at line 199 of file Geant4Manager.cc.
References fCurrentCustomization, fCustomizations, fMasterPhysicsList, fRunManager, tls::G4VPhysicsListCustomization::InactivateCustomProcesses(), INFO, and tls::GlobalPhysicsList::SetCuts().
Referenced by Customize(), and NotifyDelete().
void tls::Geant4Manager::SetDefaultPhysicsList | ( | G4VUserPhysicsList * | physicsList | ) |
Set the default physics list. This will throw an exception if the run manager has been initialized already.
Definition at line 66 of file Geant4Manager.cc.
References fCustomizations, fMasterPhysicsList, fPhysicsInitialized, and tls::GlobalPhysicsList::RegisterPhysics().
|
private |
Definition at line 246 of file Geant4Manager.cc.
References fVerboseLevel, INFO, and particle.
|
friend |
Definition at line 106 of file Geant4Manager.h.
|
private |
Definition at line 99 of file Geant4Manager.h.
Referenced by NotifyDelete().
|
private |
Definition at line 104 of file Geant4Manager.h.
Referenced by Customize(), and Reset().
|
private |
Definition at line 102 of file Geant4Manager.h.
Referenced by AddCustomization(), Customize(), InitPhysics(), NotifyDelete(), Reset(), and SetDefaultPhysicsList().
|
private |
Definition at line 96 of file Geant4Manager.h.
Referenced by AddCustomization(), Geant4Manager(), Reset(), and SetDefaultPhysicsList().
|
private |
Definition at line 98 of file Geant4Manager.h.
Referenced by Customize(), InitPhysics(), and SetDefaultPhysicsList().
|
private |
Definition at line 94 of file Geant4Manager.h.
Referenced by Customize(), Geant4Manager(), GetRunManager(), InitPhysics(), NotifyDelete(), and Reset().
|
private |
Definition at line 100 of file Geant4Manager.h.
Referenced by Customize(), and SetVerbosity().
|
private |
Definition at line 97 of file Geant4Manager.h.
Referenced by AddVisManager(), and NotifyDelete().
|
inherited |
Definition at line 44 of file Singleton.h.