opengate.managers ================= .. py:module:: opengate.managers Attributes ---------- .. autoapisummary:: opengate.managers.particle_names_Gate_to_G4 Classes ------- .. autoapisummary:: opengate.managers.FilterManager opengate.managers.SourceManager opengate.managers.ActorManager opengate.managers.PhysicsListManager opengate.managers.PhysicsManager opengate.managers.VolumeManager opengate.managers.Simulation Functions --------- .. autoapisummary:: opengate.managers.retrieve_g4_physics_constructor_class opengate.managers.create_modular_physics_list_class opengate.managers.init_method opengate.managers.setter_hook_verbose_level Module Contents --------------- .. py:data:: particle_names_Gate_to_G4 .. py:function:: retrieve_g4_physics_constructor_class(g4_physics_constructor_class_name) Dynamically create a class with the given PhysicList Only possible if the class exist in g4 .. py:function:: create_modular_physics_list_class(g4_physics_constructor_class_name) 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 .. py:function:: init_method(self, verbosity) 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) .. py:class:: FilterManager(simulation) Manage all the Filters in the simulation .. py:attribute:: simulation .. py:attribute:: user_info_filters .. py:attribute:: filters .. py:method:: __str__() .. py:method:: dump() .. py:method:: get_filter(name) .. py:method:: add_filter(filter_type, name) .. py:method:: initialize() .. py:class:: SourceManager(simulation) 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. .. py:attribute:: simulation .. py:attribute:: run_timing_intervals :value: None .. py:attribute:: current_run_interval :value: None .. py:attribute:: user_info_sources .. py:method:: __str__() str only dump the user info on a single line .. py:method:: dump_source_types() .. py:method:: dump_sources() .. py:method:: get_source_info(name) .. py:method:: add_source(source_type, name) .. py:method:: initialize_before_g4_engine() .. py:class:: ActorManager(simulation) Manage all the actors in the simulation .. py:attribute:: simulation .. py:attribute:: user_info_actors .. py:method:: __str__() .. py:method:: dump_actors() .. py:method:: dump_actor_types() .. py:method:: get_actor_user_info(name) .. py:method:: add_actor(actor_type, name) .. py:class:: PhysicsListManager(physics_manager, *args, **kwargs) Bases: :py:obj:`opengate.base.GateObject` .. py:attribute:: available_g4_physics_constructors :value: ['G4EmStandardPhysics', 'G4EmStandardPhysics_option1', 'G4EmStandardPhysics_option2',... .. py:attribute:: special_physics_constructor_classes .. py:attribute:: physics_manager .. py:attribute:: created_physics_list_classes :value: None .. py:attribute:: particle_with_biased_process_dictionary .. py:method:: __getstate__() .. py:method:: __setstate__(d) .. py:method:: create_physics_list_classes() .. py:method:: get_physics_list(physics_list_name) .. py:method:: dump_info_physics_lists() .. py:class:: PhysicsManager(simulation, *args, **kwargs) Bases: :py:obj:`opengate.base.GateObject` Everything related to the physics (lists, cuts, etc.) should be here. .. py:attribute:: user_info_defaults .. py:attribute:: simulation .. py:attribute:: physics_list_manager .. py:attribute:: regions .. py:attribute:: volumes_regions_lut .. py:attribute:: optical_surfaces .. py:method:: reset() .. py:method:: to_dictionary() .. py:method:: from_dictionary(d) .. py:method:: __str__() .. py:method:: __getstate__() .. py:method:: __setstate__(d) .. py:method:: _simulation_engine_closing() This function should be called from the simulation engine when it is closing to make sure that G4 references are set to None. .. py:method:: dump_available_physics_lists() .. py:method:: dump_info_physics_lists() .. py:method:: dump_production_cuts() .. py:method:: dump_optical_surfaces() Prints each volume's name and its associated surfaces' details (surface name and connected volumes) from the `volume_surfaces` dictionary in a readable format. .. py:property:: enable_decay 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. .. py:method:: add_optical_surface(volume_from, volume_to, g4_surface_name) Creates an object of class OpticalSurface with surface info. :param volume_from: Name of the first volume (str) :param volume_to: Name of the second volume (str) :param g4_surface_name: Name of the surface between volumes (str) .. py:method:: add_region(name) .. py:method:: find_or_create_region(volume_name) .. py:method:: set_production_cut(volume_name, particle_name, value) .. py:method:: add_physics_bias() .. py:method:: set_max_step_size(volume_name, max_step_size) .. py:method:: set_max_track_length(volume_name, max_track_length) .. py:method:: set_min_ekine(volume_name, min_ekine) .. py:method:: set_max_time(volume_name, max_time) .. py:method:: set_min_range(volume_name, min_range) .. py:method:: set_user_limits_particles(particle_names) .. py:class:: VolumeManager(simulation, *args, **kwargs) Bases: :py:obj:`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 .. py:attribute:: volume_types .. py:attribute:: simulation .. py:attribute:: volume_tree_root .. py:attribute:: volumes .. py:attribute:: parallel_world_volumes .. py:attribute:: _need_tree_update :value: True .. py:attribute:: material_database .. py:method:: reset() .. py:method:: __str__() .. py:method:: to_dictionary() .. py:method:: from_dictionary(d) .. py:property:: world_volume .. py:property:: all_world_volumes List of all world volumes, including the mass world volume. .. py:property:: volume_names .. py:property:: parallel_world_names .. py:property:: all_volume_names .. py:property:: dynamic_volumes .. py:method:: get_volume(volume_name) .. py:method:: update_volume_tree_if_needed() .. py:method:: update_volume_tree() .. py:method:: add_volume(volume, name=None) .. py:method:: create_volume(volume_type, name) .. py:method:: add_parallel_world(name) .. py:method:: _simulation_engine_closing() This function should be called from the simulation engine when it is closing to make sure that G4 references are set to None. .. py:method:: add_material_database(filename) .. py:method:: find_or_build_material(material) .. py:method:: dump_volumes() .. py:method:: dump_volume_tree() .. py:method:: dump_volume_types() .. py:method:: dump_material_database_names() .. py:function:: setter_hook_verbose_level(self, verbose_level) .. py:class:: Simulation(name='simulation') Bases: :py:obj:`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. .. py:attribute:: user_info_defaults .. py:attribute:: verbose_getstate :value: False .. py:attribute:: verbose_close :value: False .. py:attribute:: volume_manager .. py:attribute:: source_manager .. py:attribute:: actor_manager .. py:attribute:: physics_manager .. py:attribute:: filter_manager .. py:attribute:: output :value: None .. py:attribute:: user_hook_after_init :value: None .. py:attribute:: user_hook_after_run :value: None .. py:method:: __str__() .. py:property:: use_multithread .. py:property:: world .. py:method:: to_dictionary() .. py:method:: from_dictionary(d) .. py:method:: to_json_string() .. py:method:: to_json_file(directory=None, filename=None) .. py:method:: from_json_string(json_string) .. py:method:: from_json_file(path) .. py:method:: copy_input_files(directory=None, dct=None) .. py:method:: get_output_path(path=None, is_file_or_directory='file', suffix='') .. py:method:: add_g4_command_after_init(command) For the moment, only use it *after* runManager.Initialize .. py:method:: add_g4_command_before_init(command) For the moment, only use it *after* runManager.Initialize .. py:method:: get_source_user_info(name) .. py:method:: get_actor_user_info(name) .. py:method:: add_volume(volume, name=None) .. py:method:: add_surface(volume_1, volume_2, surface_name) .. py:method:: add_parallel_world(name) .. py:method:: add_source(source_type, name) .. py:method:: add_actor(actor_type, name) .. py:method:: add_filter(filter_type, name) .. py:property:: multithreaded .. py:method:: _run_simulation_engine(start_new_process) 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. .. py:method:: run(start_new_process=False) .. py:method:: voxelize_geometry(extent='auto', spacing=(3, 3, 3), margin=0, filename=None, return_path=False) 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: extent : By 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. .. py:method:: initialize_source_before_g4_engine() 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. .. py:method:: _get_voxelized_geometry(extent, spacing, margin) 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.