3.1. opengate

3.1.1. Subpackages

3.1.2. Submodules

3.1.3. Package Contents

3.1.3.1. Classes

UserInfo

A simple dict that contains the list of user parameters.

UserElement

Common class for all types of elements (volume, source or actor)

SourceBase

Base class for all source types.

ActorBase

Store user information about an actor

VolumeBase

Store information about a geometry volume:

UserElement

Common class for all types of elements (volume, source or actor)

Simulation

ExceptionHandler

Geant4 exception handler. Inherit form GateExceptionHandler

EngineBase

SimulationOutput

ExceptionHandler

Geant4 exception handler. Inherit form GateExceptionHandler

BoxVolume

SphereVolume

TrapVolume

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

ImageVolume

Store information about a voxelized volume

TubsVolume

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

ConsVolume

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

PolyhedraVolume

HexagonVolume

TrdVolume

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html?highlight=g4trd

BooleanVolume

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html?highlight=boolean#solids-made-by-boolean-operations

RepeatParametrisedVolume

Allow to repeat a volume with translations

VoxelsSource

Voxels source for 3D distributed activity.

GenericSource

GeneriSource close to the G4 SPS, but a bit simpler.

GANSourceDefaultGenerator

This class manage the base components of a particle generator.

GANSource

GAN source: the Generator produces particles

PencilBeamSource

Pencil Beam source

ARFActor

The ARF Actor is attached to a volume.

ARFTrainingDatasetActor

The ARFTrainingDatasetActor build a root file with energy, angles, positions and energy windows

DigitizerHitsCollectionActor

Build a list of hits in a given volume.

DoseActor

DoseActor: compute a 3D edep/dose map for deposited

DigitizerAdderActor

Equivalent to Gate "adder": gather all hits of an event in the same volume.

DigitizerReadoutActor

This actor is a DigitizerAdderActor + a discretization step:

DigitizerEnergyWindowsActor

Consider a list of hits and arrange them according to energy intervals.

DigitizerProjectionActor

This actor takes as input HitsCollections and performed binning in 2D images.

DigitizerBlurringActor

Digitizer module for blurring an attribute (single value only, not a vector).

DigitizerSpatialBlurringActor

Digitizer module for blurring a (global) spatial position.

MotionVolumeActor

Every run, move a volume according to the given translations and rotations.

PhaseSpaceActor

Similar to HitsCollectionActor : store a list of hits.

SimulationStatisticsActor

Store statistics about a simulation run.

SourceInfoActor

TODO

TestActor

Test actor: only py side (no cpp)

ParticleFilter

Common class for all types of elements (volume, source or actor)

KineticEnergyFilter

Common class for all types of elements (volume, source or actor)

SimulationUserInfo

MaterialBuilder

A description of a material, that will can be build on demand.

ElementBuilder

A description of a G4Element that can be build.

MaterialDatabase

Manage a unique list of Geant4 materials and elements.

MaterialBuilder

A description of a material, that will can be build on demand.

ElementBuilder

A description of a G4Element that can be build.

VolumeManager

Implementation of G4VUserDetectorConstruction.

VolumeEngine

FIXME

SolidBuilderBase

SourceManager

Manage all the sources in the simulation.

SourceEngine

FIXME

GANSourceDefaultGenerator

This class manage the base components of a particle generator.

GANSourceConditionalGenerator

GenericSource

GeneriSource close to the G4 SPS, but a bit simpler.

GANSourceDefaultGenerator

This class manage the base components of a particle generator.

GANSourceConditionalPairsGenerator

Generate pairs of particles with a GAN, considering conditional vectors.

VoxelizedSourceConditionGenerator

VoxelizedSourcePDFSampler

This is an alternative to GateSPSVoxelsPosDistribution (c++)

PencilBeamSource

Pencil Beam source

GenericSource

GeneriSource close to the G4 SPS, but a bit simpler.

FilterManager

Manage all the Filters in the simulation

ActorManager

Manage all the actors in the simulation

ActorEngine

FIXME

ActionEngine

Main object to manage all actions during a simulation.

UIsessionSilent

bcolors

UIsessionVerbose

Print Geant4 Verbose with color

RunAction

User action at begin and end of run.

PhysicsUserInfo

This class is a simple structure that contains all user general options of ths physics list.

PhysicsManager

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

PhysicsEngine

FIXME

3.1.3.2. Functions

fatal(s)

warning(s)

raise_except(s)

assert_equal_dic(d1, d2[, name])

g4_units(→ float)

g4_best_unit(value, unit_type)

assert_key(key, d)

assert_keys(keys, d)

indent(amount, text[, ch])

Prefix the text with indent spaces

assert_unique_element_name(elements, name)

make_builders(class_names)

Consider a list of Classname. For each, it build a key/value, with:

read_mac_file_to_commands(filename)

check_filename_type(filename)

get_random_folder_name([size, create])

import_gaga_phsp()

import_garf()

get_rnd_seed(seed)

DDF()

Debug print current Function name

DD(arg)

Debug print variable name and its value

print_dic(dic)

print_opengate_info()

Print information about OpenGate and the environment

update_image_py_to_cpp(py_img, cpp_img[, copy_data])

itk_dir_to_rotation(dir)

create_3d_image(size, spacing[, pixel_type, allocate, ...])

create_image_like(like_image[, allocate])

create_image_like_info(info[, allocate])

get_info_from_image(image)

read_image_info(filename)

get_translation_between_images_center(img_name1, img_name2)

The two images are considered in the same physical space (coordinate system).

get_origin_wrt_images_g4_position(img_info1, ...)

The two images are considered in the same GATE physical space (coordinate system), so according to the

get_cpp_image(cpp_image)

get_image_center(image)

get_translation_from_iso_center(img_info, rot, ...)

get_physical_volume(volume_engine, vol_name, ...)

attach_image_to_physical_volume(phys_vol_name, image)

create_image_with_volume_extent(sim, vol_name[, ...])

voxelize_volume(se, vol_name, image)

transform_images_point(p, img1, img2)

compute_image_3D_CDF(image)

Compute the three CDF (Cumulative Density Function) for the given image

scale_itk_image(img, scale)

split_spect_projections(input_filenames, nb_ene)

The inputs are filenames of several images containing projections for a given spect head

test_ok([is_ok])

delete_run_manager_if_needed(sim)

read_stat_file(filename)

print_test(b, s)

assert_stats(stat1, stat2[, tolerance, is_ok])

plot_img_axis(ax, img, label[, axis])

plot_img_z(ax, img, label)

plot_img_y(ax, img, label)

plot_img_x(ax, img, label)

assert_images(ref_filename1, filename2[, stats, ...])

exponential_func(x, a, b)

Gauss(x, A, x0, sigma)

fit_exponential_decay(data, start, end)

get_new_key_name(key)

get_keys_correspondence(keys)

rel_diff(a, b)

rel_diff_range(a, b)

get_branch(tree, keys, key)

Return a branch whether it is a numpy or a uproot tree

compare_branches(tree1, keys1, tree2, keys2, key1, key2)

Compare with Wasserstein distance

compare_branches_values(b1, b2, key1, key2[, tol, ax, ...])

Compare with Wasserstein distance

compare_trees(tree1, allkeys1, tree2, allkeys2, keys1, ...)

get_default_test_paths(f[, gate_folder])

compare_root2(root1, root2, branch1, branch2, keys, ...)

compare_root(root1, root2, branch1, branch2, ...)

compare_root3(root1, root2, branch1, branch2, keys1, ...)

dict_compare(d1, d2)

write_gauss_param_to_file(outputdir, planePositionsV)

get_gauss_param_xy(data, spacing, shape[, filepath, ...])

extract_gauss_param_1D(data, length, spacing[, axis, ...])

plot_gauss_fit(positionVec, dose, fit[, show])

create_position_vector(length, spacing)

gaussian_fit(positionVec, dose)

read_mhd(filename)

create_2D_Edep_colorMap(filepath[, show])

compareGaussParamFromFile(sigma, ref[, rel_tol, ...])

compareGaussParamArrays(paramTestV, paramRefV[, ...])

test_weights(expected_ratio, mhd_1, mhd_2[, thresh])

root_compare_param_tree(filename, tree_name, keys)

root_compare_param(keys, fig)

root_compare4(p1, p2, param)

Compare two root trees.

compare_trees4(p1, p2, param)

is_rotation_matrix(R)

https://stackoverflow.com/questions/53808503/how-to-test-if-a-matrix-is-a-rotation-matrix

vec_np_as_g4(v)

vec_g4_as_np(v)

rot_np_as_g4(rot)

rot_g4_as_np(rot)

get_vol_g4_translation(vol)

get_vol_g4_rotation(vol)

get_vol_g4_transform(vol)

get_translation_from_rotation_with_center(rot, center)

get_transform_orbiting(position, axis, angle_deg)

get_transform_world_to_local(vol_name)

repeat_ring(name, start_deg, nb, translation[, axis])

Build a repeater for the given volume name, according to a ring rotation.

repeat_array(name, size, translation)

repeat_array_start(name, start, size, translation)

build_param_repeater(sim, mother_name, ...[, rot])

volume_orbiting_transform(axis, start, end, n, ...)

info_timing(i)

assert_run_timing(run_timing_intervals)

info_run_timing(sim)

range_timing(start, end, n)

Return a list of n time intervals, from start to end

box_add_size(box, thickness)

cons_add_size(cons, thickness)

get_volume_bounding_limits(simulation, volume_name)

Return the min and max 3D points of the bounding box of the given volume

get_volume_bounding_box_size(simulation, volume_name)

Return the size of the bounding box of the given volume

translate_point_to_volume(simulation, volume, top, x)

Consider the point x in the current volume and return the coordinate of x in the top volume

render_tree(tree, geometry)

Print a tree of volume

build_tree(simulation)

add_volume_to_tree(user_info_volumes, already_done, ...)

copy_volume_user_info(ref_volume, target_volume)

solid_union(a, b[, tr, rot])

solid_subtraction(a, b[, tr, rot])

solid_intersection(a, b[, tr, rot])

solid_bool(ope, a, b, tr, rot)

read_voxel_materials(filename[, def_mat])

new_material_weights(name, density, elements[, weights])

new_material_nb_atoms(name, density, elements, nb_atoms)

HU_read_materials_table(file_mat)

HU_read_density_table(file_density)

HU_linear_interpolate_densities(hu, densities)

HU_find_max_density_difference(hu_min, hu_max, d_min, ...)

HounsfieldUnit_to_material(density_tolerance, ...)

Same function than in GateHounsfieldToMaterialsBuilder class.

dump_material_like_Gate(mat)

assert_same_material(m1, m2)

read_next_line(f)

read_tag(s, tag)

read_tag_with_unit(s, tag)

read_beta_plus_spectra(rad_name)

read the file downloaded from LNHB

compute_bins_density(bins)

Given a list of (energy) bins center, compute the width of each bin.

get_rad_yield(rad_name)

compute_cdf_and_total_yield(data, bins)

Compute the CDF (Cumulative Density Function) of a list of non-uniform energy bins

generate_isotropic_directions(n[, min_theta, ...])

like in G4SPSAngDistribution.cc

get_rad_gamma_energy_spectrum(rad)

set_source_rad_energy_spectrum(source, rad)

get_source_skipped_events(output, source_name)

get_source_zero_events(output, source_name)

get_simplified_digitizer_channels_Tc99m(spect_name, ...)

get_simplified_digitizer_channels_Lu177(spect_name, ...)

get_simplified_digitizer_channels_In111(spect_name, ...)

get_simplified_digitizer_channels_I131(spect_name, ...)

get_simplified_digitizer_channels_rad(spect_name, rad, ...)

get_element_class(element_type, type_name)

Return the class of the given type_name (in the element_type list)

get_builder(element_type, type_name)

Return a function that build an element of the class type_name

new_element(user_info[, simulation])

Create a new element (Volume, Source, Actor, Filter), according to the type name

copy_user_info(v1, v2)

Copy all attributes from v1 to v2, except the name.

get_source_skipped_events(output, source_name)

get_source_zero_events(output, source_name)

get_source_skipped_events(output, source_name)

get_source_zero_events(output, source_name)

create_phys_list(physics)

set_cuts_NOT_USED_YET(physics, g4_PhysList)

create_modular_physics_list_class(pl_class)

Create a class (not on object!) which:

modular_physics_list_constructor(self)

Constructor of the above, dynamically created class.

modular_physics_list_destructor(self)

For debug

create_modular_physics_list(pl_name)

Dynamically create a class with the given PhysicList

3.1.3.3. Attributes

__world_name__

formatter

handler

log

NONE

DEBUG

INFO

RUN

EVENT

color_error

color_warning

color_ok

volume_type_names

volume_builders

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html#constructed-solid-geometry-csg-solids

elements_name_symbol

rid

bool_operators

elements_name_symbol

source_type_names

source_builders

gate_source_path

all_beta_plus_radionuclides

actor_type_names

actor_builders

sigma_to_fwhm

fwhm_to_sigma

filter_type_names

filter_builders

element_builders

__world_name__

available_additional_physics_lists

opengate.__world_name__ = 'world'[source]
opengate.formatter[source]
opengate.handler[source]
opengate.log[source]
opengate.NONE = 0[source]
opengate.DEBUG[source]
opengate.INFO[source]
opengate.RUN = 20[source]
opengate.EVENT = 50[source]
opengate.color_error[source]
opengate.color_warning[source]
opengate.color_ok[source]
opengate.fatal(s)[source]
opengate.warning(s)[source]
opengate.raise_except(s)[source]
opengate.assert_equal_dic(d1, d2, name='')[source]
opengate.g4_units(name: str) float[source]
opengate.g4_best_unit(value, unit_type)[source]
opengate.assert_key(key: str, d: box.Box)[source]
opengate.assert_keys(keys: list, d: box.Box)[source]
opengate.indent(amount, text, ch=' ')[source]

Prefix the text with indent spaces https://stackoverflow.com/questions/8234274/how-to-indent-the-contents-of-a-multi-line-string

opengate.assert_unique_element_name(elements, name)[source]
opengate.make_builders(class_names)[source]

Consider a list of Classname. For each, it build a key/value, with: - the type of the class as key - and a lambda function that create an object of this class as value

opengate.read_mac_file_to_commands(filename)[source]
opengate.check_filename_type(filename)[source]
opengate.get_random_folder_name(size=8, create=True)[source]
opengate.import_gaga_phsp()[source]
opengate.import_garf()[source]
opengate.get_rnd_seed(seed)[source]
opengate.DDF()[source]

Debug print current Function name

opengate.DD(arg)[source]

Debug print variable name and its value

opengate.print_dic(dic)[source]
opengate.print_opengate_info()[source]

Print information about OpenGate and the environment

opengate.update_image_py_to_cpp(py_img, cpp_img, copy_data=False)[source]
opengate.itk_dir_to_rotation(dir)[source]
opengate.create_3d_image(size, spacing, pixel_type='float', allocate=True, fill_value=0)[source]
opengate.create_image_like(like_image, allocate=True)[source]
opengate.create_image_like_info(info, allocate=True)[source]
opengate.get_info_from_image(image)[source]
opengate.read_image_info(filename)[source]
opengate.get_translation_between_images_center(img_name1, img_name2)[source]

The two images are considered in the same physical space (coordinate system). This function computes the translation between their centers. Warning, the ITK image origin consider the center of the first voxel, we thus consider half a pixel shift for the center.

opengate.get_origin_wrt_images_g4_position(img_info1, img_info2, translation)[source]

The two images are considered in the same GATE physical space (coordinate system), so according to the centers of both images (+translation). This function computes the origin for the second image such as the two images will be in the same physical space of the first image. Warning, the ITK image origin considers the center of the first voxel, we thus consider half a pixel shift for the center.

opengate.get_cpp_image(cpp_image)[source]
opengate.get_image_center(image)[source]
opengate.get_translation_from_iso_center(img_info, rot, iso_center, centered)[source]
opengate.get_physical_volume(volume_engine, vol_name, physical_volume_index)[source]
opengate.attach_image_to_physical_volume(phys_vol_name, image, initial_translation=None, initial_rotation=Rotation.identity())[source]
opengate.create_image_with_volume_extent(sim, vol_name, spacing=[1, 1, 1], margin=0)[source]
opengate.voxelize_volume(se, vol_name, image)[source]
opengate.transform_images_point(p, img1, img2)[source]
opengate.compute_image_3D_CDF(image)[source]

Compute the three CDF (Cumulative Density Function) for the given image Warning; numpy order is ZYX

Parameters:

image – itk image

opengate.scale_itk_image(img, scale)[source]
opengate.split_spect_projections(input_filenames, nb_ene)[source]

The inputs are filenames of several images containing projections for a given spect head Each image is composed of nb_ene energy windows and XX angles. The number of angles is found by looking at the number of slices.

The function computes nb_ene itk image with all angles and all heads merged into a list of projections stored as a 3D image, to make it easy to reconstruct with RTK.

opengate.test_ok(is_ok=False)[source]
opengate.delete_run_manager_if_needed(sim)[source]
opengate.read_stat_file(filename)[source]
opengate.print_test(b, s)[source]
opengate.assert_stats(stat1, stat2, tolerance=0, is_ok=True)[source]
opengate.plot_img_axis(ax, img, label, axis='z')[source]
opengate.plot_img_z(ax, img, label)[source]
opengate.plot_img_y(ax, img, label)[source]
opengate.plot_img_x(ax, img, label)[source]
opengate.assert_images(ref_filename1, filename2, stats=None, tolerance=0, ignore_value=0, axis='z', fig_name=None, sum_tolerance=5)[source]
opengate.exponential_func(x, a, b)[source]
opengate.Gauss(x, A, x0, sigma)[source]
opengate.fit_exponential_decay(data, start, end)[source]
opengate.get_new_key_name(key)[source]
opengate.get_keys_correspondence(keys)[source]
opengate.rel_diff(a, b)[source]
opengate.rel_diff_range(a, b)[source]
opengate.get_branch(tree, keys, key)[source]

Return a branch whether it is a numpy or a uproot tree

opengate.compare_branches(tree1, keys1, tree2, keys2, key1, key2, tol=0.8, scaling1=1, scaling2=1, ax=False, nb_bins=200)[source]

Compare with Wasserstein distance Works well, but not easy to set the tolerance value.

opengate.compare_branches_values(b1, b2, key1, key2, tol=0.8, ax=False, nb_bins=200)[source]

Compare with Wasserstein distance Works well, but not easy to set the tolerance value.

opengate.compare_trees(tree1, allkeys1, tree2, allkeys2, keys1, keys2, tols, scalings1, scalings2, fig=False, nb_bins=200)[source]
opengate.get_default_test_paths(f, gate_folder=None)[source]
opengate.compare_root2(root1, root2, branch1, branch2, keys, img_filename, n_tol=3)[source]
opengate.compare_root(root1, root2, branch1, branch2, checked_keys, img)[source]
opengate.compare_root3(root1, root2, branch1, branch2, keys1, keys2, tols, scalings1, scalings2, img, hits_tol=6, nb_bins=200)[source]
opengate.dict_compare(d1, d2)[source]
opengate.write_gauss_param_to_file(outputdir, planePositionsV, saveFig=False, fNamePrefix='plane', fNameSuffix='a.mhd')[source]
opengate.get_gauss_param_xy(data, spacing, shape, filepath=None, saveFig=False)[source]
opengate.extract_gauss_param_1D(data, length, spacing, axis=1, createFig=False)[source]
opengate.plot_gauss_fit(positionVec, dose, fit, show=False)[source]
opengate.create_position_vector(length, spacing)[source]
opengate.gaussian_fit(positionVec, dose)[source]
opengate.read_mhd(filename)[source]
opengate.create_2D_Edep_colorMap(filepath, show=False)[source]
opengate.compareGaussParamFromFile(sigma, ref, rel_tol=0, abs_tol=0, verb=False)[source]
opengate.compareGaussParamArrays(paramTestV, paramRefV, rel_tol=0, abs_tol=0, verb=False)[source]
opengate.test_weights(expected_ratio, mhd_1, mhd_2, thresh=0.1)[source]
opengate.root_compare_param_tree(filename, tree_name, keys)[source]
opengate.root_compare_param(keys, fig)[source]
opengate.root_compare4(p1, p2, param)[source]

Compare two root trees.

p1 and p2 contain = the root filename, the tree name, a list of branch names (see root_compare_param_tree) Also, each branch can be scaled and clip to a min/max range.

param contains: the tolerance values (for all branches), the fig name, the nb of bins of the histograms, the tolerance for the nb of hits (see root_compare_param)

opengate.compare_trees4(p1, p2, param)[source]
opengate.is_rotation_matrix(R)[source]

https://stackoverflow.com/questions/53808503/how-to-test-if-a-matrix-is-a-rotation-matrix

opengate.vec_np_as_g4(v)[source]
opengate.vec_g4_as_np(v)[source]
opengate.rot_np_as_g4(rot)[source]
opengate.rot_g4_as_np(rot)[source]
opengate.get_vol_g4_translation(vol)[source]
opengate.get_vol_g4_rotation(vol)[source]
opengate.get_vol_g4_transform(vol)[source]
opengate.get_translation_from_rotation_with_center(rot, center)[source]
opengate.get_transform_orbiting(position, axis, angle_deg)[source]
opengate.get_transform_world_to_local(vol_name)[source]
opengate.repeat_ring(name, start_deg, nb, translation, axis=[0, 0, 1])[source]
Build a repeater for the given volume name, according to a ring rotation.

start_deg must be in degrees nb is the number of repeated positions translation is the initial translation of the volume according to the center axis is the rotation axis

The output is a dict (Box) of all positions (name + translation + rotation) than can be set to the ‘repeat’ member of a volume.

opengate.repeat_array(name, size, translation)[source]
opengate.repeat_array_start(name, start, size, translation)[source]
opengate.build_param_repeater(sim, mother_name, repeated_vol_name, size, translation, rot=None)[source]
opengate.volume_orbiting_transform(axis, start, end, n, initial_t, initial_rot)[source]
class opengate.UserInfo(element_type, type_name, name=None)[source]

A simple dict that contains the list of user parameters. Note that the dict is a Box, allowing simpler access to the keys with a dot (rather than brackets)

The default elements are set with set_default_user_info according to the class found thanks to element_type and type_name

property name[source]
__str__()[source]

Return str(self).

class opengate.UserElement(user_info)[source]

Common class for all types of elements (volume, source or actor) Manager a dict (Box) for user parameters: user_info Check that all the required keys are provided

static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]

Return str(self).

set_simulation(simulation)[source]
check_user_info()[source]
class opengate.SourceBase(user_info)[source]

Bases: opengate.UserElement

Base class for all source types.

static set_default_user_info(user_info)[source]
__str__()[source]

Return str(self).

__getstate__()[source]
dump()[source]
__del__()[source]
create_g4_source()[source]
initialize(run_timing_intervals)[source]
prepare_output()[source]
get_estimated_number_of_events(run_timing_interval)[source]
class opengate.ActorBase(user_info)[source]

Bases: opengate.UserElement

Store user information about an actor

static set_default_user_info(user_info)[source]
__del__()[source]
__getstate__()[source]

This is important : to get actor’s outputs from a simulation run in a separate process, the class must be serializable (pickle). The engines (volume, actor, etc.) and G4 objects are also removed if exists.

initialize(simulation_engine_wr=None)[source]
__str__()[source]

Return str(self).

class opengate.VolumeBase(user_info)[source]

Bases: opengate.UserElement.UserElement

Store information about a geometry volume: - G4 objects: Solid, LogicalVolume, PhysicalVolume - user parameters: user_info - additional data such as: mother, material etc

static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]

Return str(self).

build_solid()[source]
construct(volume_engine)[source]
construct_solid()[source]
construct_material(volume_engine)[source]
construct_logical_volume()[source]
construct_physical_volume()[source]
construct_physical_volume_repeat(mother_logical)[source]
construct_region()[source]
class opengate.UserElement(user_info)[source]

Common class for all types of elements (volume, source or actor) Manager a dict (Box) for user parameters: user_info Check that all the required keys are provided

static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]

Return str(self).

set_simulation(simulation)[source]
check_user_info()[source]
class opengate.Simulation(name='simulation')[source]

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 world[source]
__del__()[source]
__str__()[source]

Return str(self).

_default_parameters()[source]

Internal use. Build default elements: verbose, World, seed, physics, etc.

dump_sources()[source]
dump_source_types()[source]
dump_volumes()[source]
dump_tree_of_volumes()[source]
dump_volume_types()[source]
dump_actors()[source]
dump_actor_types()[source]
dump_material_database_names()[source]
apply_g4_command(command)[source]

For the moment, only use it after runManager.Initialize

get_volume_user_info(name)[source]
get_all_volumes_user_info()[source]
get_solid_info(user_info)[source]
get_source_user_info(name)[source]
get_actor_user_info(name)[source]
get_physics_user_info()[source]
set_cut(volume_name, particle, value)[source]
set_physics_list(pl)[source]
new_solid(solid_type, name)[source]
add_volume(solid_type, name)[source]
add_volume_from_solid(solid, name)[source]
add_source(source_type, name)[source]
add_actor(actor_type, name)[source]
add_filter(filter_type, name)[source]
add_material_database(filename)[source]
check_geometry()[source]
initialize()[source]
start(start_new_process=False)[source]
class opengate.ExceptionHandler[source]

Bases: opengate_core.GateExceptionHandler

Geant4 exception handler. Inherit form GateExceptionHandler The function ‘Notify’ will be called by G4 when an exception occurs. Should be created after initialization. Will be automatically stoed in the G4 stateManager

Notify(originOfException, exceptionCode, severity, description)[source]
class opengate.EngineBase[source]

Base class for all engines (SimulationEngine, VolumeEngine, etc.)

__del__()[source]
class opengate.SimulationOutput[source]

FIXME

__del__()[source]
store_actors(simulation_engine)[source]
store_sources(simulation_engine)[source]
get_actor(name)[source]
get_source(name)[source]
get_source_MT(name, thread)[source]
class opengate.ExceptionHandler[source]

Bases: opengate_core.GateExceptionHandler

Geant4 exception handler. Inherit form GateExceptionHandler The function ‘Notify’ will be called by G4 when an exception occurs. Should be created after initialization. Will be automatically stoed in the G4 stateManager

Notify(originOfException, exceptionCode, severity, description)[source]
opengate.info_timing(i)[source]
opengate.assert_run_timing(run_timing_intervals)[source]
opengate.info_run_timing(sim: opengate.Simulation)[source]
opengate.range_timing(start, end, n)[source]

Return a list of n time intervals, from start to end e.g. range_timing(0, 1, 10) => [0, 0.1], [0.1, 0.2], [0.2, 0.3], [0.3, 0.4], [0.4, 0.5], [0.5, 0.6], [0.6, 0.7], [0.7, 0.8], [0.8, 0.9], [0.9, 1.0]]

opengate.volume_type_names[source]
opengate.volume_builders[source]

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html#constructed-solid-geometry-csg-solids

opengate.box_add_size(box, thickness)[source]
opengate.cons_add_size(cons, thickness)[source]
opengate.get_volume_bounding_limits(simulation, volume_name)[source]

Return the min and max 3D points of the bounding box of the given volume

opengate.get_volume_bounding_box_size(simulation, volume_name)[source]

Return the size of the bounding box of the given volume

opengate.translate_point_to_volume(simulation, volume, top, x)[source]

Consider the point x in the current volume and return the coordinate of x in the top volume (that must be an ancestor). Translation only, do not consider rotation.

opengate.elements_name_symbol[source]
opengate.render_tree(tree, geometry)[source]

Print a tree of volume

opengate.build_tree(simulation)[source]
opengate.add_volume_to_tree(user_info_volumes, already_done, tree, vol)[source]
opengate.copy_volume_user_info(ref_volume, target_volume)[source]
class opengate.BoxVolume[source]

Bases: opengate.VolumeBase

type_name = 'Box'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.SphereVolume[source]

Bases: opengate.VolumeBase

type_name = 'Sphere'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.TrapVolume[source]

Bases: opengate.VolumeBase

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html dx1 Half x length of the side at y=-pdy1 of the face at -pdz dx2 Half x length of the side at y=+pdy1 of the face at -pdz dz Half z length theta Polar angle of the line joining the centres of the faces at -/+pdz phi Azimuthal angle of the line joining the centre of the face at -pdz to the centre of the face at +pdz dy1 Half y length at -pdz dy2 Half y length at +pdz dx3 Half x length of the side at y=-pdy2 of the face at +pdz dx4 Half x length of the side at y=+pdy2 of the face at +pdz alp1 Angle with respect to the y axis from the centre of the side (lower endcap) alp2 Angle with respect to the y axis from the centre of the side (upper endcap)

type_name = 'Trap'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.ImageVolume(user_info)[source]

Bases: opengate.VolumeBase

Store information about a voxelized volume

type_name = 'Image'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
construct(volume_engine)[source]
add_region(lv)[source]
initialize_image_parameterisation()[source]

From the input image, a label image is computed with each label associated with a material. The label image is initialized with label 0, corresponding to the first material Correspondence from voxel value to material is given by a list of interval [min_value, max_value, material_name] all pixels with values between min (included) and max (non included) will be associated with the given material

class opengate.TubsVolume[source]

Bases: opengate.VolumeBase

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html prmin SetInnerRadius prmax SetOuterRadius pdz SetZHalfLength psphi SetStartPhiAngle pdphi SetDeltaPhiAngle

type_name = 'Tubs'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.ConsVolume[source]

Bases: opengate.VolumeBase

http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

type_name = 'Cons'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.PolyhedraVolume[source]

Bases: opengate.VolumeBase

type_name = 'Polyhedra'[source]

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.HexagonVolume[source]

Bases: opengate.VolumeBase

type_name = 'Hexagon'[source]

This is a special case of a polyhedra https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html

static set_default_user_info(user_info)[source]
build_solid()[source]
class opengate.TrdVolume[source]

Bases: opengate.VolumeBase

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html?highlight=g4trd

dx1 Half-length along X at the surface positioned at -dz dx2 Half-length along X at the surface positioned at +dz dy1 Half-length along Y at the surface positioned at -dz dy2 Half-length along Y at the surface positioned at +dz zdz Half-length along Z axis

type_name = 'Trd'[source]
static set_default_user_info(user_info)[source]
build_solid()[source]
opengate.rid[source]
opengate.bool_operators = ['union', 'subtraction', 'intersection'][source]
opengate.solid_union(a, b, tr=None, rot=rid)[source]
opengate.solid_subtraction(a, b, tr=None, rot=rid)[source]
opengate.solid_intersection(a, b, tr=None, rot=rid)[source]
opengate.solid_bool(ope, a, b, tr, rot)[source]
class opengate.BooleanVolume(name)[source]

Bases: opengate.VolumeBase

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html?highlight=boolean#solids-made-by-boolean-operations

type_name = 'Boolean'[source]
set_solid(solid)[source]
add_node(solid, translation=None, rotation_matrix=rid)[source]
build_solid()[source]
_build_one_solid(solid)[source]
_build_solid_bool(name, op, s)[source]
class opengate.RepeatParametrisedVolume(user_info)[source]

Bases: opengate.VolumeBase

Allow to repeat a volume with translations

type_name = 'RepeatParametrised'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
construct_solid()[source]
construct_logical_volume()[source]
construct_physical_volume()[source]
opengate.read_voxel_materials(filename, def_mat='G4_AIR')[source]
opengate.new_material_weights(name, density, elements, weights=[1])[source]
opengate.new_material_nb_atoms(name, density, elements, nb_atoms)[source]
opengate.HU_read_materials_table(file_mat)[source]
opengate.HU_read_density_table(file_density)[source]
opengate.HU_linear_interpolate_densities(hu, densities)[source]
opengate.HU_find_max_density_difference(hu_min, hu_max, d_min, d_max, densities)[source]
opengate.elements_name_symbol[source]
opengate.HounsfieldUnit_to_material(density_tolerance, file_mat, file_density)[source]

Same function than in GateHounsfieldToMaterialsBuilder class. Probably far from optimal, put we keep the compatibility

opengate.dump_material_like_Gate(mat)[source]
opengate.assert_same_material(m1, m2)[source]
opengate.read_next_line(f)[source]
opengate.read_tag(s, tag)[source]
opengate.read_tag_with_unit(s, tag)[source]
opengate.source_type_names[source]
opengate.source_builders[source]
opengate.gate_source_path[source]
opengate.all_beta_plus_radionuclides = ['F18', 'Ga68', 'Zr89', 'Na22', 'C11', 'N13', 'O15', 'Rb82'][source]
opengate.read_beta_plus_spectra(rad_name)[source]

read the file downloaded from LNHB there are 15 lines-long header to skip first column is E(keV) second column is dNtot/dE b+ WARNING : bins width is not uniform (need to scale for density)

opengate.compute_bins_density(bins)[source]

Given a list of (energy) bins center, compute the width of each bin.

opengate.get_rad_yield(rad_name)[source]
opengate.compute_cdf_and_total_yield(data, bins)[source]

Compute the CDF (Cumulative Density Function) of a list of non-uniform energy bins with associated probability. Also return the total probability.

opengate.generate_isotropic_directions(n, min_theta=0, max_theta=np.pi, min_phi=0, max_phi=2 * np.pi, rs=np.random)[source]

like in G4SPSAngDistribution.cc

Later : do a version with torch (gpu) instead of np (cpu) ?

opengate.get_rad_gamma_energy_spectrum(rad)[source]
opengate.set_source_rad_energy_spectrum(source, rad)[source]
class opengate.VoxelsSource(user_info)[source]

Bases: opengate.source.GenericSource.GenericSource

Voxels source for 3D distributed activity. Sampled with cumulative distribution functions.

type_name = 'Voxels'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__getstate__()[source]
create_g4_source()[source]
set_transform_from_user_info()[source]
cumulative_distribution_functions()[source]

Compute the Cumulative Distribution Function of the image Composed of: CDF_Z = 1D, CDF_Y = 2D, CDF_X = 3D

initialize(run_timing_intervals)[source]
class opengate.GenericSource(user_info)[source]

Bases: opengate.SourceBase

GeneriSource close to the G4 SPS, but a bit simpler.

type_name = 'Generic'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
initialize(run_timing_intervals)[source]
prepare_output()[source]
opengate.get_source_skipped_events(output, source_name)[source]
opengate.get_source_zero_events(output, source_name)[source]
class opengate.GANSourceDefaultGenerator(user_info)[source]

This class manage the base components of a particle generator.

  • In the constructor, the module ‘gaga’ is imported. It is only imported in the constructor to only required

this module if it is used

  • ‘initialize’ function: the GAN is loaded and the list of keys is initialized

  • ‘generator’ function: default generator

  • ‘get_output_keys’ function: map the user defined keys to the ones of the generator. There are two usages, either

with on single primary (3 values for position, direction), or paired primary (6 values).

  • ‘move_backward’ function: consider all particles positions and move their backward according to their direction,

using the factor provided by the user in ‘user_info.backward_distance’. This is useful to allow generating particles that do not intersect with the detector.

  • ‘copy_generated_particle_to_g4’ function: copy all the particles (pos, dir, time, energy) to the cpp part.

__getstate__()[source]
initialize()[source]
initialize_with_lock()[source]
get_output_keys()[source]
get_output_keys_with_lock()[source]
get_key_generated_values(k, pk, n, dim=3)[source]
generator(source)[source]

Main function that will be called from the cpp side every time a batch of particles should be created. Once created here, the particles are copied to cpp. (Yes maybe the copy could be avoided, but I did not manage to do it)

copy_generated_particle_to_g4(source, g, fake)[source]
move_backward(g, fake)[source]
class opengate.GANSource(user_info)[source]

Bases: opengate.source.GenericSource.GenericSource

GAN source: the Generator produces particles Input is a neural network Generator trained with a GAN

type_name = 'GAN'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
initialize(run_timing_intervals)[source]
class opengate.PencilBeamSource(user_info)[source]

Bases: opengate.source.GenericSource.GenericSource

Pencil Beam source

type_name = 'PencilBeam'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
__check_phSpace_params(paramV)[source]
opengate.actor_type_names[source]
opengate.actor_builders[source]
opengate.get_simplified_digitizer_channels_Tc99m(spect_name, scatter_flag)[source]
opengate.get_simplified_digitizer_channels_Lu177(spect_name, scatter_flag)[source]
opengate.get_simplified_digitizer_channels_In111(spect_name, scatter_flag)[source]
opengate.get_simplified_digitizer_channels_I131(spect_name, scatter_flag)[source]
opengate.get_simplified_digitizer_channels_rad(spect_name, rad, scatter_flag)[source]
class opengate.ARFActor(user_info)[source]

Bases: opengate_core.GateARFActor, opengate.ActorBase

The ARF Actor is attached to a volume. Every time a particle enter, it considers the energy and the direction of the particle. It runs the neural network model to provide the probability of detection in all energy windows.

Output is an (FIXME itk ?numpy ?) image that can be retrieved with self.output_image

type_name = 'ARFActor'[source]
set_default_user_info()[source]
__str__()[source]
__getstate__()[source]
initialize(volume_engine=None)[source]
apply(actor)[source]
EndSimulationAction()[source]
class opengate.ARFTrainingDatasetActor(user_info)[source]

Bases: g4.GateARFTrainingDatasetActor, gate.ActorBase

The ARFTrainingDatasetActor build a root file with energy, angles, positions and energy windows of a spect detector. To be used by garf_train to train a ARF neural network.

Note: Must inherit from ActorBase not from HitsCollectionActor, even if the cpp part inherit from HitsCollectionActor

type_name = 'ARFTrainingDatasetActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
class opengate.DigitizerHitsCollectionActor(user_info)[source]

Bases: opengate_core.GateDigitizerHitsCollectionActor, opengate.ActorBase

Build a list of hits in a given volume. - the list of attributes to be stored is given in the ‘attributes’ options - output as root

type_name = 'DigitizerHitsCollectionActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.DoseActor(user_info)[source]

Bases: opengate_core.GateDoseActor, opengate.ActorBase

DoseActor: compute a 3D edep/dose map for deposited energy/absorbed dose in the attached volume

The dose map is parameterized with:
  • size (number of voxels)

  • spacing (voxel size)

  • translation (according to the coordinate system of the “attachedTo” volume)

  • no rotation

Position: - by default: centered according to the “attachedTo” volume center - if the attachedTo volume is an Image AND the option “img_coord_system” is True:

the origin of the attachedTo image is used for the output dose. Hence, the dose can be superimposed with the attachedTo volume

Options
  • edep only for the moment

  • later: add dose, uncertainty, squared etc

type_name = 'DoseActor'[source]
set_default_user_info()[source]
__str__()[source]
__getstate__()[source]
initialize(volume_engine=None)[source]

At the start of the run, the image is centered according to the coordinate system of the mother volume. This function computes the correct origin = center + translation. Note that there is a half-pixel shift to align according to the center of the pixel, like in ITK.

StartSimulationAction()[source]
EndSimulationAction()[source]
compute_uncertainty()[source]
class opengate.DigitizerAdderActor(user_info)[source]

Bases: opengate_core.GateDigitizerAdderActor, opengate.ActorBase

Equivalent to Gate “adder”: gather all hits of an event in the same volume. Input: a HitsCollection, need aat least TotalEnergyDeposit and PostPosition attributes Output: a Single collections

Policies: - EnergyWinnerPosition: consider position and energy of the hit with the max energy

for all other attributes (Time, etc.): the value of the winner is used.

  • EnergyWeightedCentroidPosition: computed the energy-weighted centroid position

    for all other attributes (Time, etc.): the value the last seen hit is used.

type_name = 'DigitizerAdderActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
set_group_by_depth()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.DigitizerReadoutActor(user_info)[source]

Bases: opengate_core.GateDigitizerReadoutActor, opengate.ActorBase

This actor is a DigitizerAdderActor + a discretization step: the final position is the center of the volume

type_name = 'DigitizerReadoutActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.DigitizerEnergyWindowsActor(user_info)[source]

Bases: opengate_core.GateDigitizerEnergyWindowsActor, opengate.ActorBase

Consider a list of hits and arrange them according to energy intervals. Input: one DigiCollection Output: as many DigiCollections as the number of energy windows

type_name = 'DigitizerEnergyWindowsActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.DigitizerProjectionActor(user_info)[source]

Bases: opengate_core.GateDigitizerProjectionActor, opengate.ActorBase

This actor takes as input HitsCollections and performed binning in 2D images. If there are several HitsCollection as input, the slices will correspond to each HC. If there are several runs, images will also be slice-stacked.

type_name = 'HitsProjectionActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
__getstate__()[source]
compute_thickness(volume, channels)[source]

Get the thickness of the detector volume, in the correct direction. By default, it is Z. We use the ‘projection_orientation’ to get the correct one.

StartSimulationAction()[source]
EndSimulationAction()[source]
opengate.sigma_to_fwhm[source]
opengate.fwhm_to_sigma[source]
class opengate.DigitizerBlurringActor(user_info)[source]

Bases: opengate_core.GateDigitizerBlurringActor, opengate.ActorBase

Digitizer module for blurring an attribute (single value only, not a vector). Usually for energy or time.

type_name = 'DigitizerBlurringActor'[source]
static set_default_user_info(user_info)[source]
set_param(user_info)[source]
set_param_gauss(user_info)[source]
set_param_inverse_square(user_info)[source]
set_param_linear(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.DigitizerSpatialBlurringActor(user_info)[source]

Bases: opengate_core.GateDigitizerSpatialBlurringActor, opengate.ActorBase

Digitizer module for blurring a (global) spatial position.

type_name = 'DigitizerSpatialBlurringActor'[source]
static set_default_user_info(user_info)[source]
set_param(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.MotionVolumeActor(user_info)[source]

Bases: opengate_core.GateMotionVolumeActor, opengate.ActorBase

Every run, move a volume according to the given translations and rotations.

type_name = 'MotionVolumeActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
__getstate__()[source]
initialize(volume_engine=None)[source]
class opengate.PhaseSpaceActor(user_info)[source]

Bases: opengate_core.GatePhaseSpaceActor, opengate.ActorBase

Similar to HitsCollectionActor : store a list of hits. However only the first hit of given event is stored here.

type_name = 'PhaseSpaceActor'[source]
static set_default_user_info(user_info)[source]
__getstate__()[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
EndSimulationAction()[source]
class opengate.SimulationStatisticsActor(user_info=None)[source]

Bases: opengate_core.GateSimulationStatisticsActor, opengate.ActorBase

Store statistics about a simulation run.

property pps[source]
property tps[source]
property sps[source]
property nb_thread[source]
property simu_start_time[source]
property simu_end_time[source]
type_name = 'SimulationStatisticsActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
EndSimulationAction()[source]
write(filename)[source]

Attempt to be mostly compatible to previous Gate stat output file

class opengate.SourceInfoActor(name)[source]

Bases: opengate_core.GateVActor, opengate.ActorBase

TODO

type_name = 'SourceInfoActor'[source]
initialize(volume_engine=None)[source]
BeginOfRunAction(run)[source]
EndOfRunAction(run)[source]
BeginOfEventAction(event)[source]
class opengate.TestActor(user_info=None)[source]

Bases: opengate_core.GateVActor, opengate.ActorBase

Test actor: only py side (no cpp) For prototyping (slow)

property pps[source]
property tps[source]
property sps[source]
type_name = 'TestActor'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
__str__()[source]
StartSimulationAction()[source]
BeginOfEventAction(event)[source]
PreUserTrackingAction(track)[source]
EndOfRunAction(run)[source]
SteppingAction(step, touchable)[source]
EndSimulationAction()[source]
write(filename)[source]
class opengate.ParticleFilter(user_info)[source]

Bases: opengate_core.GateParticleFilter, opengate.UserElement

Common class for all types of elements (volume, source or actor) Manager a dict (Box) for user parameters: user_info Check that all the required keys are provided

type_name = 'ParticleFilter'[source]
set_default_user_info()[source]
__getstate__()[source]
class opengate.KineticEnergyFilter(user_info)[source]

Bases: opengate_core.GateKineticEnergyFilter, opengate.UserElement

Common class for all types of elements (volume, source or actor) Manager a dict (Box) for user parameters: user_info Check that all the required keys are provided

type_name = 'KineticEnergyFilter'[source]
set_default_user_info()[source]
__getstate__()[source]
opengate.filter_type_names[source]
opengate.filter_builders[source]
class opengate.SimulationUserInfo(simulation)[source]

This class is a simple structure that contains all user general options of a simulation.

property verbose_level[source]
__del__()[source]
__str__()[source]

Return str(self).

opengate.element_builders[source]
opengate.get_element_class(element_type, type_name)[source]

Return the class of the given type_name (in the element_type list)

opengate.get_builder(element_type, type_name)[source]

Return a function that build an element of the class type_name Check everything first.

opengate.new_element(user_info, simulation=None)[source]

Create a new element (Volume, Source, Actor, Filter), according to the type name - use the element_builders to find the class to build - create a new element, with the name as parameter to the constructor - initialize the default list of keys in the user_info - set a pointer to the Simulation object

opengate.copy_user_info(v1, v2)[source]

Copy all attributes from v1 to v2, except the name. v1 is assumed to be a UserInfo object with several attribute members. v2 must have the (at least) the same set of attributes. Values are (deep) copied.

class opengate.MaterialBuilder(material_database)[source]

A description of a material, that will can be build on demand. A material is described by a list of components that can be elements or sub-materials.

__del__()[source]
__repr__()[source]

Return repr(self).

read(f, line)[source]
read_one_element(line)[source]
read_one_submat(line)[source]
build()[source]
add_element_to_material(mat, elem)[source]
add_submat_to_material(mat, elem)[source]
class opengate.ElementBuilder(material_database)[source]

A description of a G4Element that can be build.

__del__()[source]
__repr__()[source]

Return repr(self).

read(line)[source]
build()[source]
class opengate.MaterialDatabase[source]

Manage a unique list of Geant4 materials and elements. The materials/elements are read in a DB txt file or in NIST. They are only build on demand, during the geometry Construct

__del__()[source]
read_from_file(filename)[source]
read_one_item(f, line)[source]
init_NIST()[source]
FindOrBuildMaterial(material_name)[source]
FindOrBuildElement(element_name)[source]
get_database_material_names(db=None)[source]
class opengate.MaterialBuilder(material_database)[source]

A description of a material, that will can be build on demand. A material is described by a list of components that can be elements or sub-materials.

__del__()[source]
__repr__()[source]

Return repr(self).

read(f, line)[source]
read_one_element(line)[source]
read_one_submat(line)[source]
build()[source]
add_element_to_material(mat, elem)[source]
add_submat_to_material(mat, elem)[source]
class opengate.ElementBuilder(material_database)[source]

A description of a G4Element that can be build.

__del__()[source]
__repr__()[source]

Return repr(self).

read(line)[source]
build()[source]
opengate.__world_name__ = 'world'[source]
class opengate.VolumeManager(simulation)[source]

Implementation of G4VUserDetectorConstruction. In ‘Construct’ function, build all volumes in the scene. Keep a list of solid, logical volumes, physical volumes, materials.

__del__()[source]
__str__()[source]

Return str(self).

__getstate__()[source]

This is important : to get actor’s outputs from a simulation run in a separate process, the class must be serializable (pickle). The g4 material databases and the info_volume containing volume from solid have to be removed first.

get_volume_user_info(name)[source]
new_solid(solid_type, name)[source]
get_solid_info(user_info)[source]

Temporary build a solid from the user info, in order to retrieve information (volume etc). Can be used before initialization

get_volume_depth(volume_name)[source]
_pop_keys_unused_by_solid()[source]
add_volume(vol_type, name)[source]
add_volume_from_solid(solid, name)[source]
add_material_database(filename)[source]
dump_volumes()[source]
dump_tree_of_volumes()[source]
_add_volume_to_tree(already_done, tree, vol)[source]
class opengate.VolumeEngine(simulation)[source]

Bases: opengate_core.G4VUserDetectorConstruction, opengate.EngineBase

FIXME

__del__()[source]
Construct()[source]

G4 overloaded. Override the Construct method from G4VUserDetectorConstruction

check_overlaps(verbose)[source]
find_or_build_material(material)[source]
build_g4_volumes()[source]
set_actor_engine(actor_engine)[source]
ConstructSDandField()[source]

G4 overloaded

get_volume(name, check_initialization=True)[source]
get_database_material_names(db=None)[source]
dump_build_materials(level=0)[source]
class opengate.SolidBuilderBase[source]
init_user_info(user_info)[source]
Build(user_info)[source]
class opengate.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

__del__()[source]
dump()[source]
get_source_info(name)[source]
add_source(source_type, name)[source]
class opengate.SourceEngine(source_manager)[source]

Bases: opengate.EngineBase

FIXME

max_int = 2147483647[source]
__del__()[source]
initialize(run_timing_intervals)[source]
initialize_actors(actors)[source]
create_master_source_manager()[source]
create_g4_source_manager(append=True)[source]

This is called by all threads This object is needed here, because it can only be created after physics initialization

start()[source]
class opengate.GANSourceDefaultGenerator(user_info)[source]

This class manage the base components of a particle generator.

  • In the constructor, the module ‘gaga’ is imported. It is only imported in the constructor to only required

this module if it is used

  • ‘initialize’ function: the GAN is loaded and the list of keys is initialized

  • ‘generator’ function: default generator

  • ‘get_output_keys’ function: map the user defined keys to the ones of the generator. There are two usages, either

with on single primary (3 values for position, direction), or paired primary (6 values).

  • ‘move_backward’ function: consider all particles positions and move their backward according to their direction,

using the factor provided by the user in ‘user_info.backward_distance’. This is useful to allow generating particles that do not intersect with the detector.

  • ‘copy_generated_particle_to_g4’ function: copy all the particles (pos, dir, time, energy) to the cpp part.

__getstate__()[source]
initialize()[source]
initialize_with_lock()[source]
get_output_keys()[source]
get_output_keys_with_lock()[source]
get_key_generated_values(k, pk, n, dim=3)[source]
generator(source)[source]

Main function that will be called from the cpp side every time a batch of particles should be created. Once created here, the particles are copied to cpp. (Yes maybe the copy could be avoided, but I did not manage to do it)

copy_generated_particle_to_g4(source, g, fake)[source]
move_backward(g, fake)[source]
class opengate.GANSourceConditionalGenerator(user_info, generate_condition_function)[source]

Bases: opengate.source.GANSourceDefaultGenerator.GANSourceDefaultGenerator

__getstate__()[source]
generate_condition(n)[source]
generator(source)[source]

Generate particles with a GAN, considering conditional vectors.

class opengate.GenericSource(user_info)[source]

Bases: opengate.SourceBase

GeneriSource close to the G4 SPS, but a bit simpler.

type_name = 'Generic'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
initialize(run_timing_intervals)[source]
prepare_output()[source]
opengate.get_source_skipped_events(output, source_name)[source]
opengate.get_source_zero_events(output, source_name)[source]
class opengate.GANSourceDefaultGenerator(user_info)[source]

This class manage the base components of a particle generator.

  • In the constructor, the module ‘gaga’ is imported. It is only imported in the constructor to only required

this module if it is used

  • ‘initialize’ function: the GAN is loaded and the list of keys is initialized

  • ‘generator’ function: default generator

  • ‘get_output_keys’ function: map the user defined keys to the ones of the generator. There are two usages, either

with on single primary (3 values for position, direction), or paired primary (6 values).

  • ‘move_backward’ function: consider all particles positions and move their backward according to their direction,

using the factor provided by the user in ‘user_info.backward_distance’. This is useful to allow generating particles that do not intersect with the detector.

  • ‘copy_generated_particle_to_g4’ function: copy all the particles (pos, dir, time, energy) to the cpp part.

__getstate__()[source]
initialize()[source]
initialize_with_lock()[source]
get_output_keys()[source]
get_output_keys_with_lock()[source]
get_key_generated_values(k, pk, n, dim=3)[source]
generator(source)[source]

Main function that will be called from the cpp side every time a batch of particles should be created. Once created here, the particles are copied to cpp. (Yes maybe the copy could be avoided, but I did not manage to do it)

copy_generated_particle_to_g4(source, g, fake)[source]
move_backward(g, fake)[source]
class opengate.GANSourceConditionalPairsGenerator(user_info, sphere_radius, generate_condition_function)[source]

Bases: opengate.source.GANSourceDefaultGenerator.GANSourceDefaultGenerator

Generate pairs of particles with a GAN, considering conditional vectors.

The parameter sphere_radius is required : it is the radius of the sphere that surround the source during the training.

__getstate__()[source]
generate_condition(n)[source]
generator(source)[source]

Main function that will be called from the cpp side every time a batch of particles should be created. Once created here, the particles are copied to cpp. (Yes maybe the copy could be avoided, but I did not manage to do it)

class opengate.VoxelizedSourceConditionGenerator(activity_source_filename, rs=np.random)[source]
initialize_source()[source]
generate_condition(n)[source]
class opengate.VoxelizedSourcePDFSampler(itk_image, version=1)[source]

This is an alternative to GateSPSVoxelsPosDistribution (c++) It is needed because the cond voxel source is used on python side.

There are two versions, version 2 is much slower (do not use)

init_cdf()[source]
searchsorted2d(a, b)[source]
sample_indices_slower(n, rs=np.random)[source]

This version seems slower than the other version with np random choice

samples_g4(n)[source]
sample_indices(n, rs=np.random)[source]
sample_indices_phys(n, rs=np.random)[source]
class opengate.PencilBeamSource(user_info)[source]

Bases: opengate.source.GenericSource.GenericSource

Pencil Beam source

type_name = 'PencilBeam'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
__check_phSpace_params(paramV)[source]
class opengate.GenericSource(user_info)[source]

Bases: opengate.SourceBase

GeneriSource close to the G4 SPS, but a bit simpler.

type_name = 'Generic'[source]
static set_default_user_info(user_info)[source]
__del__()[source]
create_g4_source()[source]
initialize(run_timing_intervals)[source]
prepare_output()[source]
opengate.get_source_skipped_events(output, source_name)[source]
opengate.get_source_zero_events(output, source_name)[source]
opengate.create_phys_list(physics)[source]
opengate.set_cuts_NOT_USED_YET(physics, g4_PhysList)[source]
opengate.available_additional_physics_lists = ['G4EmStandardPhysics_option1', 'G4EmStandardPhysics_option2', 'G4EmStandardPhysics_option3',...[source]
opengate.create_modular_physics_list_class(pl_class)[source]

Create a class (not on object!) which: - inherit from g4.G4VModularPhysicsList - register a single G4 PhysicList (G4VPhysicsConstructor) - is named with the name of this PhysicList

opengate.modular_physics_list_constructor(self)[source]

Constructor of the above, dynamically created class. - call the constructor of the super class (G4VModularPhysicsList) - Create and register the physic list (G4VPhysicsConstructor)

opengate.modular_physics_list_destructor(self)[source]

For debug

opengate.create_modular_physics_list(pl_name)[source]

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

class opengate.FilterManager(simulation)[source]

Manage all the Filters in the simulation

__str__()[source]

Return str(self).

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

Manage all the actors in the simulation

__str__()[source]

Return str(self).

__del__()[source]
__getstate__()[source]
dump()[source]
get_actor_user_info(name)[source]
add_actor(actor_type, name)[source]
class opengate.ActorEngine(actor_manager, simulation_engine)[source]

Bases: opengate.EngineBase

FIXME

__del__()[source]
get_actor(name)[source]
create_actors()[source]
initialize(volume_engine=None)[source]
register_all_actions(actor)[source]
register_sensitive_detector_propagate(actor, vol)[source]
register_sensitive_detectors(tree)[source]
register_sensitive_detector_to_child(actor, lv)[source]
start_simulation()[source]
stop_simulation()[source]
class opengate.ActionEngine(source)[source]

Bases: opengate_core.G4VUserActionInitialization, opengate.EngineBase

Main object to manage all actions during a simulation.

__del__()[source]
BuildForMaster()[source]
Build()[source]
class opengate.UIsessionSilent[source]

Bases: opengate_core.G4UIsession

TODO

__del__()[source]
ReceiveG4cout(coutString)[source]
ReceiveG4cerr(cerrString)[source]
class opengate.bcolors[source]
HEADER = '\x1b[95m'[source]
OKBLUE = '\x1b[94m'[source]
OKCYAN = '\x1b[96m'[source]
OKGREEN = '\x1b[92m'[source]
WARNING = '\x1b[93m'[source]
FAIL = '\x1b[91m'[source]
ENDC = '\x1b[0m'[source]
BOLD = '\x1b[1m'[source]
UNDERLINE = '\x1b[4m'[source]
class opengate.UIsessionVerbose[source]

Bases: opengate_core.G4UIsession

Print Geant4 Verbose with color

__del__()[source]
ReceiveG4cout(coutString)[source]
ReceiveG4cerr(cerrString)[source]
class opengate.RunAction[source]

Bases: opengate_core.G4UserRunAction

User action at begin and end of run. Every time a run begin/end, the G4 engine call BeginOfRunAction and EndOfRunAction. The callback is then forwarded to all actors that need it.

__del__()[source]
register_actor(actor)[source]
BeginOfRunAction(run)[source]
EndOfRunAction(run)[source]
class opengate.PhysicsUserInfo(simulation)[source]

This class is a simple structure that contains all user general options of ths physics list.

__del__()[source]
__str__()[source]

Return str(self).

class opengate.PhysicsManager(simulation)[source]

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

__del__()[source]
__str__()[source]

Return str(self).

_default_parameters()[source]
dump_available_physics_lists()[source]
dump_cuts()[source]
set_cut(volume_name, particle_name, value)[source]
class opengate.PhysicsEngine(physics_manager)[source]

Bases: opengate.EngineBase

FIXME

__del__()[source]
initialize()[source]
initialize_physics_list()[source]

Create a Physic List from the Factory

initialize_decay()[source]

G4DecayPhysics - defines all particles and their decay processes G4RadioactiveDecayPhysics - defines radioactiveDecay for GenericIon

initialize_em_options()[source]
initialize_cuts(tree)[source]
propagate_cuts_to_child(tree)[source]
set_region_cut(region)[source]