List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
tls::Geant4Manager Class Reference

class that handles multiple Geant4 runs in one offline session More...

#include <Geant4Manager.h>

Inheritance diagram for tls::Geant4Manager:
Inheritance graph
[legend]

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 ()
 
Geant4Manageroperator= (const Geant4Manager &)
 
void SetVerbosity (int verbosity)
 
 ~Geant4Manager ()
 

Private Attributes

unsigned int fClosedModules = 0
 
std::string fCurrentCustomization
 
std::map< std::string,
Geant4Customization
fCustomizations
 
GlobalPhysicsListfMasterPhysicsList = nullptr
 
bool fPhysicsInitialized = false
 
G4RunManager * fRunManager = nullptr
 
unsigned int fVerboseLevel = 0
 
G4VisManager * fVisManager = nullptr
 

Friends

class utl::Singleton< Geant4Manager >
 

Detailed Description

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.

Author
Martin Maur
Javier Gonzalez
Date
04 May 2012

Definition at line 52 of file Geant4Manager.h.

Constructor & Destructor Documentation

tls::Geant4Manager::Geant4Manager ( )
private
tls::Geant4Manager::~Geant4Manager ( )
inlineprivate

Definition at line 84 of file Geant4Manager.h.

tls::Geant4Manager::Geant4Manager ( const Geant4Manager )
private

Member Function Documentation

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().

G4RunManager* tls::Geant4Manager::GetRunManager ( )
inline

Definition at line 55 of file Geant4Manager.h.

References fRunManager.

void tls::Geant4Manager::InitPhysics ( )
private
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.

Geant4Manager& tls::Geant4Manager::operator= ( const Geant4Manager )
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().

void tls::Geant4Manager::SetVerbosity ( int  verbosity)
private

Definition at line 246 of file Geant4Manager.cc.

References fVerboseLevel, INFO, and particle.

Friends And Related Function Documentation

friend class utl::Singleton< Geant4Manager >
friend

Definition at line 106 of file Geant4Manager.h.

Member Data Documentation

unsigned int tls::Geant4Manager::fClosedModules = 0
private

Definition at line 99 of file Geant4Manager.h.

Referenced by NotifyDelete().

std::string tls::Geant4Manager::fCurrentCustomization
private

Definition at line 104 of file Geant4Manager.h.

Referenced by Customize(), and Reset().

std::map<std::string, Geant4Customization> tls::Geant4Manager::fCustomizations
private
GlobalPhysicsList* tls::Geant4Manager::fMasterPhysicsList = nullptr
private

Definition at line 96 of file Geant4Manager.h.

Referenced by AddCustomization(), Geant4Manager(), Reset(), and SetDefaultPhysicsList().

bool tls::Geant4Manager::fPhysicsInitialized = false
private

Definition at line 98 of file Geant4Manager.h.

Referenced by Customize(), InitPhysics(), and SetDefaultPhysicsList().

G4RunManager* tls::Geant4Manager::fRunManager = nullptr
private
unsigned int tls::Geant4Manager::fVerboseLevel = 0
private

Definition at line 100 of file Geant4Manager.h.

Referenced by Customize(), and SetVerbosity().

G4VisManager* tls::Geant4Manager::fVisManager = nullptr
private

Definition at line 97 of file Geant4Manager.h.

Referenced by AddVisManager(), and NotifyDelete().

template<typename T>
T& return utl::Singleton< T >::instance
inherited
Initial value:
{
static T instance

Definition at line 44 of file Singleton.h.


The documentation for this class was generated from the following files:

, generated on Tue Sep 26 2023.