3.1.2.10. opengate.managers

3.1.2.10.1. Module Contents

3.1.2.10.1.1. Classes

FilterManager

Manage all the Filters in the simulation

SourceManager

Manage all the sources in the simulation.

ActorManager

Manage all the actors in the simulation

PhysicsListManager

PhysicsManager

Everything related to the physics (lists, cuts, etc.) should be here.

VolumeManager

Store and manage a hierarchical list of geometrical volumes and associated materials.

Simulation

Main class that store a simulation.

3.1.2.10.1.2. Functions

retrieve_g4_physics_constructor_class(...)

Dynamically create a class with the given PhysicList

create_modular_physics_list_class(...)

Create a class (not on object!) which:

init_method(self, verbosity)

Init method of the dynamically created physics list class.

setter_hook_verbose_level(self, verbose_level)

3.1.2.10.1.3. Attributes

particle_names_Gate_to_G4

opengate.managers.particle_names_Gate_to_G4[source]
opengate.managers.retrieve_g4_physics_constructor_class(g4_physics_constructor_class_name)[source]

Dynamically create a class with the given PhysicList Only possible if the class exist in g4

opengate.managers.create_modular_physics_list_class(g4_physics_constructor_class_name)[source]

Create a class (not on object!) which: - inherit from g4.G4VModularPhysicsList - register a single G4 PhysicsConstructor (inherited from G4VPhysicsConstructor) - has the same name as this PhysicsConstructor

opengate.managers.init_method(self, verbosity)[source]

Init method of the dynamically created physics list class. - call the init method of the super class (G4VModularPhysicsList) - Create and register the physics constructor (G4VPhysicsConstructor)

class opengate.managers.FilterManager(simulation)[source]

Manage all the Filters in the simulation

__str__()[source]

Return str(self).

dump()[source]
get_filter(name)[source]
add_filter(filter_type, name)[source]
initialize()[source]
class opengate.managers.SourceManager(simulation)[source]

Manage all the sources in the simulation. The function prepare_generate_primaries will be called during the main run loop to set the current time and source.

__str__()[source]

str only dump the user info on a single line

dump_source_types()[source]
dump_sources()[source]
get_source_info(name)[source]
add_source(source_type, name)[source]
initialize_before_g4_engine()[source]
class opengate.managers.ActorManager(simulation)[source]

Manage all the actors in the simulation

__str__()[source]

Return str(self).

dump_actors()[source]
dump_actor_types()[source]
get_actor_user_info(name)[source]
add_actor(actor_type, name)[source]
class opengate.managers.PhysicsListManager(physics_manager, *args, **kwargs)[source]

Bases: opengate.base.GateObject

available_g4_physics_constructors = ['G4EmStandardPhysics', 'G4EmStandardPhysics_option1', 'G4EmStandardPhysics_option2',...[source]
special_physics_constructor_classes[source]
__getstate__()[source]
__setstate__(d)[source]
create_physics_list_classes()[source]
get_physics_list(physics_list_name)[source]
dump_info_physics_lists()[source]
class opengate.managers.PhysicsManager(simulation, *args, **kwargs)[source]

Bases: opengate.base.GateObject

Everything related to the physics (lists, cuts, etc.) should be here.

property enable_decay[source]

Properties to quickly enable decay.

Note that setting enable_decay to False means that the physics list default is used, i.e. it does not forcefully remove G4DecayPhysics from the physics list.

user_info_defaults[source]
reset()[source]
to_dictionary()[source]
from_dictionary(d)[source]
__str__()[source]

Return str(self).

__getstate__()[source]
__setstate__(d)[source]
_simulation_engine_closing()[source]

This function should be called from the simulation engine when it is closing to make sure that G4 references are set to None.

dump_available_physics_lists()[source]
dump_info_physics_lists()[source]
dump_production_cuts()[source]
dump_optical_surfaces()[source]

Prints each volume’s name and its associated surfaces’ details (surface name and connected volumes) from the volume_surfaces dictionary in a readable format.

add_optical_surface(volume_from, volume_to, g4_surface_name)[source]

Creates an object of class OpticalSurface with surface info.

Parameters:
  • volume_from – Name of the first volume (str)

  • volume_to – Name of the second volume (str)

  • g4_surface_name – Name of the surface between volumes (str)

add_region(name)[source]
find_or_create_region(volume_name)[source]
set_production_cut(volume_name, particle_name, value)[source]
add_physics_bias()[source]
set_max_step_size(volume_name, max_step_size)[source]
set_max_track_length(volume_name, max_track_length)[source]
set_min_ekine(volume_name, min_ekine)[source]
set_max_time(volume_name, max_time)[source]
set_min_range(volume_name, min_range)[source]
set_user_limits_particles(particle_names)[source]
class opengate.managers.VolumeManager(simulation, *args, **kwargs)[source]

Bases: opengate.base.GateObject

Store and manage a hierarchical list of geometrical volumes and associated materials. This tree will be converted into Geant4 Solid/PhysicalVolume/LogicalVolumes

property world_volume[source]
property all_world_volumes[source]

List of all world volumes, including the mass world volume.

property volume_names[source]
property parallel_world_names[source]
property all_volume_names[source]
property dynamic_volumes[source]
volume_types[source]
reset()[source]
__str__()[source]

Return str(self).

to_dictionary()[source]
from_dictionary(d)[source]
get_volume(volume_name)[source]
update_volume_tree_if_needed()[source]
update_volume_tree()[source]
add_volume(volume, name=None)[source]
create_volume(volume_type, name)[source]
add_parallel_world(name)[source]
_simulation_engine_closing()[source]

This function should be called from the simulation engine when it is closing to make sure that G4 references are set to None.

add_material_database(filename)[source]
find_or_build_material(material)[source]
dump_volumes()[source]
dump_volume_tree()[source]
dump_volume_types()[source]
dump_material_database_names()[source]
opengate.managers.setter_hook_verbose_level(self, verbose_level)[source]
class opengate.managers.Simulation(name='simulation')[source]

Bases: opengate.base.GateObject

Main class that store a simulation. It contains: - a set of global user parameters (SimulationUserInfo) - user parameters for Volume, Source, Actors and Filters, Physics - a list of g4 commands that will be set to G4 engine after the initialization

There is NO Geant4 engine here, it is only a set of parameters and options.

property use_multithread[source]
property world[source]
property multithreaded[source]
user_info_defaults[source]
__str__()[source]

Return str(self).

to_dictionary()[source]
from_dictionary(d)[source]
to_json_string()[source]
to_json_file(directory=None, filename=None)[source]
from_json_string(json_string)[source]
from_json_file(path)[source]
copy_input_files(directory=None, dct=None)[source]
get_output_path(path=None, is_file_or_directory='file', suffix='')[source]
add_g4_command_after_init(command)[source]

For the moment, only use it after runManager.Initialize

add_g4_command_before_init(command)[source]

For the moment, only use it after runManager.Initialize

get_source_user_info(name)[source]
get_actor_user_info(name)[source]
add_volume(volume, name=None)[source]
add_surface(volume_1, volume_2, surface_name)[source]
add_parallel_world(name)[source]
add_source(source_type, name)[source]
add_actor(actor_type, name)[source]
add_filter(filter_type, name)[source]
_run_simulation_engine(start_new_process)[source]

Method that creates a simulation engine in a context (with …) and runs a simulation.

Args:
q (:obj: queue, optional)A queue object to which simulation output can be added if run in a subprocess.

The dispatching function needs to extract the output from the queue.

start_new_process (bool, optional)A flag passed to the engine

so it knows if it is running in a subprocess.

Returns:

:obj:SimulationOutput : The output of the simulation run.

run(start_new_process=False)[source]
voxelize_geometry(extent='auto', spacing=(3, 3, 3), margin=0, filename=None, return_path=False)[source]

Create a voxelized three-dimensional representation of the simulation geometry.

The user can specify the sub-portion (a rectangular box) of the simulation which is to be extracted.

Args:
extentBy default (‘auto’), GATE automatically determines the sub-portion

to contain all volumes of the simulation. Alternatively, extent can be either a tuple of 3-vectors indicating the two diagonally opposite corners of the box-shaped sub-portion of the geometry to be extracted, or a volume or list volumes. In the latter case, the box is automatically determined to contain the volume(s).

spacing (tuple) : The voxel spacing in x-, y-, z-direction. margin : Width (in voxels) of the additional margin around the extracted box-shaped sub-portion

indicated by extent.

filename (str, optional)The filename/path to which the voxelized image and labels are written.

Suffix added automatically. Path can be relative to the global output directory of the simulation.

return_path (bool) : Return the absolute path where the voxelixed image was written?

Returns:
dict, itk image, (path)A dictionary containing the label to volume LUT; the voxelized geoemtry;

optionally: the absolute path where the image was written, if applicable.

initialize_source_before_g4_engine()[source]

Some sources need to perform computation once everything is defined in user_info but before the initialization of the G4 engine starts. This can be done via this function.

_get_voxelized_geometry(extent, spacing, margin)[source]

Private method which returns a voxelized image of the simulation geometry given the extent, spacing and margin.

The voxelization does not check which volume is voxelized. Every voxel will be assigned an ID corresponding to the material at this position in the world.