EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Example geometries

This page describes the example geometry files included in the distribution and found in $HEN_HOUSE/egs++/geometry/examples.

A hemisphere
A pyramid
An RZ-geometry
Alternative RZ-geometry definitions
A geometry using a set of cones
A cylinder divided into segments
A XYZ-geometry
A mushroom geometry
A brachytherapy seed
An ion chamber with rounded ends
Ion chambers in a box
Brachytherapy seeds in a XYZ geometry
Better implementation of seeds in a XYZ geometry
A car geometry
A linear accelerator geometry

A hemisphere

file: hemisphere.geom

This example geometry file describes a hemisphere from a set of spheres and a set of planes using an N-dimensional geometry. We start by defining the set of spheres to contain a single sphere with a radius of 1 with midpoint at the origin:

:start geometry:
library = egs_spheres
name = sphere
midpoint = 0 0 0
radii = 1
:stop geometry:
We then define a set of planes consisting of a single plane with a normal at 45 degrees with the 3 axis passing through the origin and defining a single region (the region to which the plane normal points to):
:start geometry:
library = egs_planes
type = EGS_Planes
name = planes
normal = 1 1 1
positions = 0 # a second plane at infinity will get defined
# internally, if we input a single position
:stop geometry:
Now we can put the two geometry objects together using an N-dimensional geometry to form the hemisphere
:start geometry:
library = egs_ndgeometry
name = hemisphere
dimensions = planes sphere
and fill the hemisphere with water.
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:

Here is a view of this geometry

hemisphere.png

and this is the complete geometry definition:

###############################################################################
#
# EGSnrc egs++ sample hemisphere geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines a hemisphere as a geometry for egs++. It uses a 2D
# geometry to make the hemisphere out of a set of spheres and planes.
#
###############################################################################
:start geometry definition:
#################################### the spheres
#
# Note: we don't define any media here because the geometry
# will get filled with media in the ND-geometry definition
#
:start geometry:
library = egs_spheres
name = sphere
midpoint = 0 0 0
radii = 1
:stop geometry:
#################################### the planes
#
# Note: we don't define any media here because the geometry
# will get filled with media in the ND-geometry definition
#
:start geometry:
library = egs_planes
type = EGS_Planes
name = planes
normal = 1 1 1
positions = 0 # a second plane at infinity will get defined
# internally, if we input a single position
:stop geometry:
################################### the hemisphere
:start geometry:
library = egs_ndgeometry
name = hemisphere
dimensions = planes sphere
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
simulation geometry = hemisphere
:stop geometry definition:

A pyramid

file: pyramid.geom

This example defines a pyramid with an irregular base that is truncated at the two ends with a set of planes within an N-dimensional geometry. We start by defining the set of planes

:start geometry:
library = egs_planes
type = EGS_Zplanes
positions = -4 4
name = planes
:stop geometry:
We then construct a pyramid with its base in the z-plane at z=0:
:start geometry:
library = egs_pyramid
type = EGS_PyramidZ
name = pyramid
points = -2,-2.05 -1,-1.05, -2,2.05 2,2.05 2,0.05 \
1,0 1,-2.05 -2,-2.05
tip = 0 0 8
:stop geometry:
Because this is a z-pyramid, the input to the points key is interpreted as a list of 2D positions in the z=0 xy-plane. Note also the line continuation using the \ character. Now we can put the two geometry objects together using an N-dimensional geometry to form the truncated pyramid and fill the resulting single region with aluminum:
:start geometry:
library = egs_ndgeometry
name = cut_pyramid
hownear method = 1
dimensions = planes pyramid
:start media input:
media = AL521ICRU
:stop media input:
:stop geometry:

Here is a view of this geometry

pyramid.png

and this is the complete geometry definition:

###############################################################################
#
# EGSnrc egs++ sample pyramid geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# This input file defines a cut pyramid as a geometry for egs++.
#
# It uses a 2D geometry to make the cut a pyramid out of a pyramid and a set
# of planes.
#
###############################################################################
:start geometry definition:
################################# the planes
:start geometry:
library = egs_planes
type = EGS_Zplanes
positions = -4 4
name = planes
:stop geometry:
################################ the pyramid
:start geometry:
library = egs_pyramid
type = EGS_PyramidZ
name = pyramid
points = -2,-2.05 -1,-1.05, -2,2.05 2,2.05 2,0.05 \
1,0 1,-2.05 -2,-2.05
#points = -2,-2.05 -2,2.05 2,2.05 2,-2.05
tip = 0 0 8
:stop geometry:
################################ the final geometry
:start geometry:
library = egs_ndgeometry
name = cut_pyramid
hownear method = 1
dimensions = planes pyramid
:start media input:
media = AL521ICRU
:stop media input:
:stop geometry:
simulation geometry = cut_pyramid
:stop geometry definition:

An RZ-geometry

file: rz.geom

This example geometry file defines an RZ-geometry using an N-dimensional geometry made of a set of cylinders and a set of planes. The geometry defined is the same as in the cavrznrc_template.egsinp file for the CAVRZnrc application (a simple pancake ionization chamber with graphite walls and air cavity).

We start by defining the 2 dimensions of the geometry: first s set of 4 parallel z-planes that define 3 regions

:start geometry:
library = egs_planes
type = EGS_Zplanes
name = the_planes
positions = 0 0.3 0.5 0.8
:stop geometry:
and then a set of 2 concentric z-cylinders that defines 2 regions
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = the_cylinders
radii = 1 1.3
:stop geometry:
The N-dimensional geometry formed from these two geometries will have 3x2=6 regions with the 3 regions that are within the inner cylinder having indeces 0,1 and 2 and the other 3 regions between the inner and outer cylinders having indeces 3,4,5 (see the EGS_NDGeometry documentation for details on regions and region indexing). We therefore use the following
:start geometry:
library = egs_ndgeometry
name = rz
dimensions= the_planes the_cylinders
:start media input:
media = 170C521ICRU AIR521ICRU
set medium = 1 1
:stop media input:
:stop geometry:
to form the N-dimensional geometry and fill the cavity with air.

For the view of this geometry

rz1.png

the walls were made siemi-transparent in the geometry viewer.
Here is the complete geometry definition:

###############################################################################
#
# EGSnrc egs++ sample nd geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for a RZ geometry modeled
# with a N-dimensional geometry. The input file reproduces the geometry
# defined in the cavrznrc_template.egsinp file in the EGSnrc distribution.
#
###############################################################################
:start geometry definition:
################################### The planes
:start geometry:
library = egs_planes
type = EGS_Zplanes
name = the_planes
positions = 0 0.3 0.5 0.8
:stop geometry:
################################### The cylinders
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = the_cylinders
radii = 1 1.3
:stop geometry:
################################### The simulation geometry built from the
# planes and cylinders as a 2D geometry
:start geometry:
library = egs_ndgeometry
name = rz
dimensions= the_planes the_cylinders
:start media input:
media = 170C521ICRU AIR521ICRU
set medium = 1 1
:stop media input:
:stop geometry:
simulation geometry = rz
:stop geometry definition:

Alternative RZ-geometry definitions

file: rz1.geom

This example geometry file defines the same geometry as in the previous example but using an envelope geometry to inscribe a smaller cylinder into a larger one, where both cylinders are made using EGS_ConeStack objects:

################################### The outer cylinder
:start geometry:
library = egs_cones
name = outer_cylinder
axis = 0 0 0 0 0 1
:start layer:
thickness = 0.8
top radii = 1.3
bottom radii = 1.3
media = 170C521ICRU
:stop layer:
:stop geometry:
################################### The inner cylinder
:start geometry:
library = egs_cones
name = inner_cylinder
axis = 0 0 0.3 0 0 1
:start layer:
thickness = 0.2
top radii = 1
bottom radii = 1
media = AIR521ICRU
:stop layer:
:stop geometry:
################################### The simulation geometry
:start geometry:
library = egs_genvelope
name = rz1
base geometry = outer_cylinder
inscribed geometries = inner_cylinder
:stop geometry:

Yet another possibility to define this geometry would be to define the inner and outer cylinders using N-dimensional geometries instead of EGS_ConeStack objects and then still use an envelope to inscribe the inner cylinder into the outer cylinder, e.g.

########################## Define the inner cylinder
:start geometry:
    library = egs_planes
    type    = EGS_Zplanes
    name    = planes1
    positions = 0.3 0.5
:stop geometry:
:start geometry:
    library = egs_cylinders
    type    = EGS_ZCylinders
    name    = cyl1
    radii   = 1
:stop geometry:
:start geometry:
    library = egs_ndgeometry
    name    = inner_cylinder
    dimensions = planes1 cyl1
    :start media input:
        media = AIR521ICRU
    :stop media input:
:stop geometry:
########################## Define the outer cylinder
:start geometry:
    library = egs_planes
    type    = EGS_Zplanes
    name    = planes2
    positions = 0 0.8
:stop geometry:
:start geometry:
    library = egs_cylinders
    type    = EGS_ZCylinders
    name    = cyl2
    radii   = 1.3
:stop geometry:
:start geometry:
    library = egs_ndgeometry
    name    = outer_cylinder
    dimensions = planes2 cyl2
    :start media input:
        media = 170C521ICRU
    :stop media input:
:stop geometry:
############################ The chamber geometry
:start geometry:
    library   = egs_genvelope
    name      = rz1a
    base geometry = outer_cylinder
    inscribed geometries = inner_cylinder
:stop geometry:

This definition requires more typing but it turns out that it provides the fastest simulation with EGSnrc. This is due to the fact that it has the fewest boundaries around which charged particles go into single scattering mode and also the range-rejection (or Russian Roulette) of particles that can not reach the cavity is more efficient. The user is encouraged to study the implementation details of the hownear() methods of the various geometries involved to understand why the last definition results in the best simulation speed.

A geometry using a set of cones

file: cones.geom

This example geometry file demonstrates the use of an EGS_ConeSet object. Because a set of cones is unlimited and therefore not very well suited for viewing, we use an N-dimensional geometry with a sphere forming the second dimension to limit the extent of the geometry. We start by defining a set of 6 cones with the same apex and opening angles between 10 and 60 degrees

:start geometry:
library = egs_cones
type = EGS_ConeSet
name = cone_set
apex = 0 0 0
axis = 0 0 1
opening angles = 10 20 30 40 50 60
flag = 1 # you can also set this to 0 or 2
:stop geometry:
For the sake of brevity we skip the definition of the sphere (see previous examples) and only show the definition of the N-dimensional geometry
:start geometry:
library = egs_ndgeometry
name = cones
dimensions = sphere cone_set
hownear method = 1
:start media input:
media = med1 med2 med3 med4 med5 med6
set medium = 0 0
set medium = 1 1
set medium = 2 2
set medium = 3 3
set medium = 4 4
set medium = 5 5
:stop media input:
:stop geometry:
We repeatedly use the set medium key to fill each region of the cones below the apex with a different medium.

The geometry as defined above looks like this:

cones1.png

If we would set the flag value to 0 in the definition of the cones, the geometry would look like this

cones2.png

and for flag=2 like this

cones3.png

(the red medium was made semi-transparent to be able to see the cones).

Here is the complete geometry file:

###############################################################################
#
# EGSnrc egs++ sample cone set geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file demonstrates the use of a cone set. Play around with the
# flag key in the definition of the cones to see how the geometry changes
# for flag = 0, 1 and 2.
#
##############################################################################
:start geometry definition:
###################################### Define a set of cones
# with the same apex and axis but different
# opening angles.
# A cone set extends to infinity and therefore
# we will use it as part of 2D geometry to limit
# its extend.
:start geometry:
library = egs_cones
type = EGS_ConeSet
name = cone_set
apex = 0 0 0
axis = 0 0 1
opening angles = 10 20 30 40 50 60
flag = 1 # you can also set this to 0 or 2
:stop geometry:
#################################### This sphere will be used to limit
# the size of the conical regions by a rounded end
# as a part of a 2D geometry.
:start geometry:
library = egs_spheres
name = sphere
midpoint = 0 0 0
radii = 5
:stop geometry:
#################################### Now the actual geometry made from the
# set of cones and the above sphere.
:start geometry:
library = egs_ndgeometry
name = cones
dimensions = sphere cone_set
hownear method = 1
:start media input:
media = med1 med2 med3 med4 med5 med6
set medium = 0 0
set medium = 1 1
set medium = 2 2
set medium = 3 3
set medium = 4 4
set medium = 5 5
:stop media input:
:stop geometry:
simulation geometry = cones
:stop geometry definition:

A cylinder divided into segments

file: rz_phi.geom

This example geometry file shows the use of I-planes to divide a cylinder into azimuthal segments. We define a set of concentric z-cylinders consisting of a single cylinder,

:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = rho_coordinates
radii = 2
:stop geometry:
a set of 2 parallel z-planes defining a single region,
:start geometry:
library = egs_planes
type = EGS_Zplanes
positions = -2 2
name = z_coordinates
:stop geometry:
and a set of 6 I-planes defining 12 regions.
:start geometry:
library = egs_iplanes
axis = 0 0 0 0 0 1
angles = 0 30 60 90 120 150
# above angles are in degrees, you can use
# 'angles in radian' to define angles in radians
name = phi_coordinates
:stop geometry:
We then use a N-dimensional geometry made of the cone, the planes and the I-planes to form a geometry with 1x1x12=12 regions and fill each region with a different medium to see the effect of the I-planes:
:start geometry:
library = egs_ndgeometry
name = rho_z_phi
dimensions = rho_coordinates z_coordinates phi_coordinates
:start media input:
media = m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12
set medium = 0 0
set medium = 1 1
set medium = 2 2
set medium = 3 3
set medium = 4 4
set medium = 5 5
set medium = 6 6
set medium = 7 7
set medium = 8 8
set medium = 9 9
set medium = 10 10
set medium = 11 11
:stop media input:
:stop geometry:

Here is how the geometry looks like

rz_phi_a.png

and here is the complete definition

###############################################################################
#
# EGSnrc egs++ sample i-planes geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file demonstrates the use of i-planes to divide a region into
# phi segments. A 3D geometry is made from a cylinder, a set of planes and
# a set of i-planes.
#
###############################################################################
:start geometry definition:
######################################## the cylinder
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = rho_coordinates
radii = 2
:stop geometry:
######################################## the planes
:start geometry:
library = egs_planes
type = EGS_Zplanes
positions = -2 2
name = z_coordinates
:stop geometry:
######################################## the I-planes
:start geometry:
library = egs_iplanes
axis = 0 0 0 0 0 1
angles = 0 30 60 90 120 150
# above angles are in degrees, you can use
# 'angles in radian' to define angles in radians
name = phi_coordinates
:stop geometry:
########################### The final geometry is a N-dimensional geometry
# made from the cylinder, the planes and the I-planes
:start geometry:
library = egs_ndgeometry
name = rho_z_phi
dimensions = rho_coordinates z_coordinates phi_coordinates
:start media input:
media = m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12
set medium = 0 0
set medium = 1 1
set medium = 2 2
set medium = 3 3
set medium = 4 4
set medium = 5 5
set medium = 6 6
set medium = 7 7
set medium = 8 8
set medium = 9 9
set medium = 10 10
set medium = 11 11
:stop media input:
:stop geometry:
simulation geometry = rho_z_phi
:stop geometry definition:

A XYZ-geometry

file: xyz.geom

This example shows a XYZ-geometry filled with water and two inhomogeneities made of air and aluminum. The XYZ-geometry class is in the same library as N-dimensional geometries and therefore we have to specify that we are constructing a XYZ-geometry instead of a N-dimensional geometry (the default):

:start geometry:
library = egs_ndgeometry
name = xyz
We then define the x-planes,
x-planes = -11 -9 -7 -5 -3 -1 1 3 5 7 9 11
the y-planes,
y-planes = -11 -9 -7 -5 -3 -1 1 3 5 7 9 11
and the z-planes
z-planes = 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 \
10 10.5 11 13 14.5 16 17 20
We then define the media for this geometry
:start media input:
media = H2O700ICRU AL700ICRU AIR700ICRU
This fills the entire geometry with the first medium (medium 0). We then use set medium keys to define the inhomogeneities:
set medium = 4 5 4 5 4 10 1
set medium = 5 6 5 6 4 10 2
This fills all regions with x-indeces 4 or 5, y-indeces 4 or 5 and z-indeces between 4 and 10 with medium 1 (AL700ICRU) and then all regions with x-indeces 5 or 6, y-indeces 5 or 6 and z-indeces between 4 and 10 with medium 2 (AIR700ICRU) (i.e. some of the regions originally set to aluminum get refilled with air by the second set medium key).

Here is a view of this geometry

xyz_a.png

Despite the fact that the water has been made semi-transparent, one does not see the inhomogeneities. This is due to the fact that there are many boundaries (corresponding to reflection/transmission surfaces) crossed by the rays used to render the image before they reach the inhomogeneities. At each such boundary the ray becomes weaker due to reflection and absorption and is essentially completely absorbed by the time it reaches the inhomogeneities. Unless, of course, one makes the water completely transparent, in which case one sees the aluminum- and air-filled regions only:

xyz_b.png

Here is the complete geometry definition

###############################################################################
#
# EGSnrc egs++ sample xyz geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for a simple xyz-geometry filled
# with water and two inhomogeneities
#
###############################################################################
:start geometry definition:
:start geometry:
library = egs_ndgeometry
name = xyz
x-planes = -11 -9 -7 -5 -3 -1 1 3 5 7 9 11
y-planes = -11 -9 -7 -5 -3 -1 1 3 5 7 9 11
z-planes = 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 \
10 10.5 11 13 14.5 16 17 20
:start media input:
media = H2O700ICRU AL700ICRU AIR700ICRU
set medium = 4 5 4 5 4 10 1
# the above sets the medium to AL700ICRU in all voxels with
# ix=4,5 iy=4,5 iz=4,10
set medium = 5 6 5 6 4 10 2
# the above sets the medium to AIR700ICRU in all voxels with
# ix=5,6 iy=5,6 iz=4,10 (i.e., some of the voxels previously
# set to AL700ICRU get refilled with air).
:stop media input:
:stop geometry:
simulation geometry = xyz
:stop geometry definition:

A mushroom geometry

file: mushroom.geom

This example geometry file defines a mushroom-like geometrical structure using a CD-geometry with a set of planes as a base and spheres and cylinders inscribed into the two regions defined by the planes. We first define a set of parallel z-planes,

:start geometry:
library = egs_planes
type = EGS_Zplanes
name = the_planes
positions = 0 4.0 5
:stop geometry:
a sphere filled with medium1,
:start geometry:
library = egs_spheres
midpoint = 0 0 -1
radii = 6
name = the_sphere
:start media input:
media = medium1
:stop media input:
:stop geometry:
and a z-cylinder filled with medium2
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = the_cylinder
radii = 1
:start media input:
media = medium2
:stop media input:
:stop geometry:
We then use CD-geometry formed by the two regions of the planes as a base and the sphere inscribed into region 1 and the cylinder into region 0:
:start geometry:
library = egs_cdgeometry
name = mushroom
base geometry = the_planes
set geometry = 1 the_sphere
set geometry = 0 the_cylinder
:stop geometry:

The resulting geometry looks like this

mushroom.png

and the complete definition is here:

###############################################################################
#
# EGSnrc egs++ sample mushroom geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# This input file defines a geometry that looks like a mushroom.
#
# The geometry is made from a set of planes, a sphere and a cylinder put
# into the two regions defined by the planes as a CD geometry.
#
##############################################################################
:start geometry definition:
################################### The planes
:start geometry:
library = egs_planes
type = EGS_Zplanes
name = the_planes
positions = 0 4.0 5
:stop geometry:
################################### The sphere
:start geometry:
library = egs_spheres
midpoint = 0 0 -1
radii = 6
name = the_sphere
:start media input:
media = medium1
:stop media input:
:stop geometry:
################################### The cylinder
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = the_cylinder
radii = 1
:start media input:
media = medium2
:stop media input:
:stop geometry:
################################### The CD geometry:
:start geometry:
library = egs_cdgeometry
name = mushroom
base geometry = the_planes
set geometry = 1 the_sphere
set geometry = 0 the_cylinder
:stop geometry:
simulation geometry = mushroom
:stop geometry definition:

A brachytherapy seed

file: I6702.inp

This example geometry file defines a $^{125}$I model 6702 brachytherapy seed using a CD-geometry . The base geometry of the CD-geometry is a set of planes that defines 3 regions:

:start geometry:
library = egs_planes
name = planes
type = EGS_Zplanes
positions = -0.225 -0.175 0.175 0.225
:stop geometry:
The top region (between the planes at -0.225 and -0.175) will be limited by inscribing a sphere filled with titanium:
:start geometry:
library = egs_spheres
name = seed_top
midpoint = 0 0 -0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
Because the sphere only applies between the planes of region 0 of the set of planes, it becomes a hemisphere that is the top rounded end of the seed. The geometry that we will inscribe into the middle region of the set of planes (between the planes at -0.175 and 0.175) will have the 3 radiactive resin spheres and the titanium walls. To form this geometry, we start by constructing a set of 2 cylinders filling the inner region with air and the outer region with titanium:
:start geometry:
library = egs_cylinders
name = cladding
midpoint = 0 0 0
type = EGS_ZCylinders
radii = 0.044 0.05
:start media input:
media = air titanium
set medium = 0 1 0
set medium = 1 2 1
:stop media input:
:stop geometry:
We then make the 3 radiactive spheres
##################################### the first radioactive sphere
#
:start geometry:
library = egs_spheres
name = first_sphere
midpoint = 0 0 -0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the second radioactive sphere
#
:start geometry:
library = egs_spheres
name = second_sphere
midpoint = 0 0 0
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the third radioactive sphere
#
:start geometry:
library = egs_spheres
name = third_sphere
midpoint = 0 0 0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
and then inscribe the 3 spheres into the set of cylinders named cladding using an envelope geometry:
:start geometry:
library = egs_genvelope
name = seed_center
base geometry = cladding
inscribed geometries = first_sphere second_sphere third_sphere
:stop geometry:
The bottom region of the set of planes (between 0.175 and 0.225) will be filled with another titanium sphere in a way similar to the top region:
:start geometry:
library = egs_spheres
name = seed_bottom
midpoint = 0 0 0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
We now have all geometries to be inscribed into the set of planes as a CD-geometry:
:start geometry:
library = egs_cdgeometry
name = seed
base geometry = planes
set geometry = 0 seed_top
set geometry = 1 seed_center
set geometry = 2 seed_bottom
:stop geometry:

This is a view of the resulting brachytherapy seed with the titanium and air media made semi-transparent:

I6702b.png

and here is an alternative view with 2 clipping planes with normals along the z- and x-axis passing through the origin used to remove 3/4 of the geometry for better viewing the inside:

I6702c.png

This is the complete geometry definition file, which has been created by Ernesto Mainegra (Note the view control input at the end. Without this input the viewer is not able to automatically find the geometry because it is too small):

###############################################################################
#
# EGSnrc egs++ sample brachytherapy seed geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for a I-6702 brachytherapy seed.
# The seed is modeled as a CD geometry. The base geometry for the CD geometry
# is a set of 4 parallel planes defining 3 regions.
#
# Spheres are inscribed into regions 0 and 2 of the CD geometry to form the
# rounded ends of the seed.
#
# The middle region of the CD geometry is filled with an envelope geometry.
#
# The envelope geometry is made of a set of 2 cylinders as the base and 3
# inscribed spheres thus forming the seed wall and the radiocative
# material in the middle.
#
##############################################################################
:start geometry definition:
##################################### the set of planes needed for the
# CD geometry
:start geometry:
library = egs_planes
name = planes
type = EGS_Zplanes
positions = -0.225 -0.175 0.175 0.225
:stop geometry:
##################################### the top sphere
# (which will turn into a hemisphere
# after being put into region 0 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_top
midpoint = 0 0 -0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
##################################### the set of cylinders
:start geometry:
library = egs_cylinders
name = cladding
midpoint = 0 0 0
type = EGS_ZCylinders
radii = 0.044 0.05
:start media input:
media = air titanium
set medium = 0 1 0
set medium = 1 2 1
:stop media input:
:stop geometry:
##################################### the first radioactive sphere
#
:start geometry:
library = egs_spheres
name = first_sphere
midpoint = 0 0 -0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the second radioactive sphere
#
:start geometry:
library = egs_spheres
name = second_sphere
midpoint = 0 0 0
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the third radioactive sphere
#
:start geometry:
library = egs_spheres
name = third_sphere
midpoint = 0 0 0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the envelope geometry for the
# middle region
:start geometry:
library = egs_genvelope
name = seed_center
base geometry = cladding
inscribed geometries = first_sphere second_sphere third_sphere
:stop geometry:
##################################### the bottom sphere
# (which will turn into a hemisphere
# after being put into region 2 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_bottom
midpoint = 0 0 0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
########################################## And now the actual geometry
# which is a CD geometry made of the set of planes as
# the base geometry and spheres and the cylinder
# envelope as inscribed geometries for the 3 regions.
#
:start geometry:
library = egs_cdgeometry
name = seed
base geometry = planes
set geometry = 0 seed_top
set geometry = 1 seed_center
set geometry = 2 seed_bottom
:stop geometry:
simulation geometry = seed
:stop geometry definition:
###################### The following view control input helps the viewer
# to find the seed geometry.
# It will fail without it as the geometry is too small
# for the position grid used in the initial search for
# the optimum viewing position.
#
:start view control:
xmin = -0.5
xmax = 0.5
ymin = -0.5
ymax = 0.5
zmin = -0.5
zmax = 0.5
:stop view control:

An ion chamber with rounded ends

file: rounded_ionchamber.geom

The file rounded_ionchamber.geom defines an ionization chamber geometry that has rounded ends using a CD-geometry. We use a set of 4 planes that defines 3 regions for the base of the CD-geometry:

:start geometry:
library = egs_planes
type = EGS_Zplanes
name = base_planes
positions = -2 -1 1 2
:stop geometry:
In the bottom part (between the planes at -2 and -1) we will be inscribing a N-dimensional geometry that is made from a set of spheres and a set of cylinders. Here are the spheres:
:start geometry:
library = egs_spheres
name = top_spheres
midpoint = 0 0 -1
radii = 0.7 1
:stop geometry:
and here the cylinders:
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = top_cylinders
radii = 0.3 0.7 1
:stop geometry:
When combined into a N-dimensional geometry they will form a geometry with 2x3=6 regions. Regions 0 is within the innermost cylinder and the inner sphere, region 1 within the innermost cylinder and the spherical shell between the outer and inner spheres. These two regions are filled with aluminum to describe the central electrode of the chamber in the bottom part. Region 2 is between the second and first cylinders but within the inner sphere. This region belongs to the air cavity. All other regions are part of the chamber wall. The definition of the N-dimensional geometry describing the top part of the chamber therefore looks like this:
:start geometry:
library = egs_ndgeometry
name = top_chamber_part
dimensions = top_spheres top_cylinders
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 5 0
set medium = 0 2
set medium = 1 2
set medium = 2 1
:stop media input:
:stop geometry:
(note that I was confused about top and bottom when making this geometry file and therefore the geometry names suggest that the top part is the bottom and vice versa). In the top part of the chamber there is no central electrode. It is therefore sufficient to inscribe the following set of spheres into the bottom region of the planes (the region between the planes at 1 and 2):
:start geometry:
library = egs_spheres
name = bottom_chamber_part
midpoint = 0 0 1
radii = 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU
set medium = 0 1
set medium = 1 0
:stop media input:
:stop geometry:
The middle portion of the chamber is simply made from a set of 3 cylinders for the central electrode, the air cavity and the wall:
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = middle_chamber_part
radii = 0.3 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 2
set medium = 1 1
set medium = 2 0
:stop media input:
:stop geometry:
The final geometry is then formed as a CD-geometry with the first set of planes as a base and the N-dimensional geometry put into region 0, the set of cylinders into region 1 and the set of spheres into region 2:
:start geometry:
library = egs_cdgeometry
name = chamber
base geometry = base_planes
set geometry = 0 top_chamber_part
set geometry = 1 middle_chamber_part
set geometry = 2 bottom_chamber_part
:stop geometry:

Here are different views of the chamber

rounded1.png
rounded2.png

and here is the complete definition file

###############################################################################
#
# EGSnrc egs++ sample ionization chamber geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for an ionization chamber with
# rounded ends, graphite walls and a central electrode made of aluminum.
#
# The chamber is modeled as a CD geometry. The base geometry of the CD
# geometry is a set of 4 parallel planes forming 3 regions. The bottom
# rounded end of the chamber is a set of spheres put into region 2 of the
# planes. The top rounded end of the chamber is a 2D geometry made of set
# of spheres and a set of cones put into region 0 of the planes. The middle
# portion of the chamber is made by inscribing a set of cylinders into
# region 1 of the planes.
#
###############################################################################
:start geometry definition:
################################## the set of planes used as the base
# of the CD geometry
:start geometry:
library = egs_planes
type = EGS_Zplanes
name = base_planes
positions = -2 -1 1 2
:stop geometry:
################################# the set of spheres needed for the top
# we don't set the media here as media
# will be set in the 2D geometry below
#
:start geometry:
library = egs_spheres
name = top_spheres
midpoint = 0 0 -1
radii = 0.7 1
:stop geometry:
################################# the set of cylinders needed for the top
# we don't set the media here as media
# will be set in the 2D geometry below
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = top_cylinders
radii = 0.3 0.7 1
:stop geometry:
################################# the 2D geometry for the top chamber end
# It is made from the sets of spheres
# and cylinders defined above to form
# a geometry with 2x3=6 regions
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_ndgeometry
name = top_chamber_part
dimensions = top_spheres top_cylinders
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 5 0
set medium = 0 2
set medium = 1 2
set medium = 2 1
:stop media input:
:stop geometry:
################################# the set of spheres needed for the bottom
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_spheres
name = bottom_chamber_part
midpoint = 0 0 1
radii = 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU
set medium = 0 1
set medium = 1 0
:stop media input:
:stop geometry:
################################# the set of cylinders needed for the middle
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = middle_chamber_part
radii = 0.3 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 2
set medium = 1 1
set medium = 2 0
:stop media input:
:stop geometry:
################################# the final chamber geometry
#
:start geometry:
library = egs_cdgeometry
name = chamber
base geometry = base_planes
set geometry = 0 top_chamber_part
set geometry = 1 middle_chamber_part
set geometry = 2 bottom_chamber_part
:stop geometry:
simulation geometry = chamber
:stop geometry definition:

Ion chambers in a box

file: chambers_in_box.geom

This example file puts 3 transformed copies of the same chamber geometry as in the previous example into a box of water using the functionality provided by envelope geometries and transformed geometries. After defining the complete chamber geometry (named chamber and its definition not shown here for the sake of brevity), we define a 10x10x10 box filled with water

:start geometry:
library = egs_box
name = water_box
box size = 10 # i.e. a 10x10x10 box
:start media input:
media = H2O521ICRU
:stop media input:
:stop geometry:
and then use a transformed geometry to create 2 replicas of the original chamber
:start geometry:
library = egs_gtransformed
my geometry = chamber
name = left_chamber
:start transformation:
translation = -3 0 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
my geometry = chamber
name = other_chamber
:start transformation:
rotation vector = 1 1 1
translation = 1 2 1
:stop transformation:
:stop geometry:
With the help of an envelope geometry we then inscribe the original chamber and the 2 transformed copies into the water box:
:start geometry:
library = egs_genvelope
name = box_with_chambers
base geometry = water_box
inscribed geometries = chamber left_chamber other_chamber
:stop geometry:

A view of this geometry with semi-transparencies is shown here

c_in_box.png

An alternative view can be seen on the main page. The complete definition is here

###############################################################################
#
# EGSnrc egs++ sample ionization chambers in a box geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for 3 ionization chambers with
# rounded ends put into a box filled with water. For details of the
# definition of the chamber geometry, see rounded_chamber.geom.
#
# This input file demonstrates the use of a transformed geometry
# to easily create replicas of the same geometry and place
# these at different locations.
#
##############################################################################
:start geometry definition:
######################### chamber definition ###########################
################################## the set of planes used as the base
# of the CD geometry
:start geometry:
library = egs_planes
type = EGS_Zplanes
name = base_planes
positions = -2 -1 1 2
:stop geometry:
################################# the set of spheres needed for the top
# we don't set the media here as media
# will be set in the 2D geometry below
#
:start geometry:
library = egs_spheres
name = top_spheres
midpoint = 0 0 -1
radii = 0.7 1
:stop geometry:
################################# the set of cylinders needed for the top
# we don't set the media here as media
# will be set in the 2D geometry below
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = top_cylinders
radii = 0.3 0.7 1
:stop geometry:
################################# the 2D geometry for the top chamber end
# It is made from the sets of spheres
# and cylinders defined above to form
# a geometry with 2x3=6 regions
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_ndgeometry
name = top_chamber_part
dimensions = top_spheres top_cylinders
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 5 0
set medium = 0 2
set medium = 1 2
set medium = 2 1
:stop media input:
:stop geometry:
################################# the set of spheres needed for the bottom
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_spheres
name = bottom_chamber_part
midpoint = 0 0 1
radii = 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU
set medium = 0 1
set medium = 1 0
:stop media input:
:stop geometry:
################################# the set of cylinders needed for the middle
# this geometry is inscribed directly into
# the set of planes and therefore we
# define its media
#
:start geometry:
library = egs_cylinders
type = EGS_ZCylinders
name = middle_chamber_part
radii = 0.3 0.7 1
:start media input:
media = 170C521ICRU AIR521ICRU AL521ICRU
set medium = 0 2
set medium = 1 1
set medium = 2 0
:stop media input:
:stop geometry:
################################# the final chamber geometry
#
:start geometry:
library = egs_cdgeometry
name = chamber
base geometry = base_planes
set geometry = 0 top_chamber_part
set geometry = 1 middle_chamber_part
set geometry = 2 bottom_chamber_part
:stop geometry:
############################## end of chamber definition ################
############################### The box filled with water
:start geometry:
library = egs_box
name = water_box
box size = 10 # i.e. a 10x10x10 box
:start media input:
media = H2O521ICRU
:stop media input:
:stop geometry:
############################## now make replicas of the chamber
#
############################## a replica translated along the x axis
:start geometry:
library = egs_gtransformed
my geometry = chamber
name = left_chamber
:start transformation:
translation = -3 0 0
:stop transformation:
:stop geometry:
############################## a rotated and translated replica
:start geometry:
library = egs_gtransformed
my geometry = chamber
name = other_chamber
:start transformation:
rotation vector = 1 1 1
translation = 1 2 1
:stop transformation:
:stop geometry:
############################# The simulation geometry, which is an
# envelope geometry with the box as the
# envelope and the 3 copies of the chamber
# as the inscribed geometries.
:start geometry:
library = egs_genvelope
name = box_with_chambers
base geometry = water_box
inscribed geometries = chamber left_chamber other_chamber
:stop geometry:
simulation geometry = box_with_chambers
:stop geometry definition:

Brachytherapy seeds in a XYZ geometry

file: seeds_in_xyz.geom

This file demonstrates that one can inscribe a complex geometry into another complex geometry using an envelope geometry. We use the brachytherapy seed geometry discussed in this example as the complex geometry to be inscribed. For the sake of brevity the definition is not shown here. We then construct another complex geometry. In this example we use a homogeneous XYZ-geometry, but the XYZ-geometry could also have been heterogeneous:

:start geometry:
library = egs_ndgeometry
name = xyz
x-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
y-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
z-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
We then create 12 copies of the seed geometry named seed (only the first 2 definitions are shown) using a transformed geometry:
:start geometry:
library = egs_gtransformed
name = seed_1
my geometry = seed
:start transformation:
translation = -3 -3 0
rotation vector = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_2
my geometry = seed
:start transformation:
translation = -2 -2 0
:stop transformation:
:stop geometry:
and then inscribe these 12 copies into the XYZ geometry:
:start geometry:
library = egs_genvelope
base geometry = xyz
name = seeds_in_box
inscribed geometries = seed seed_1 seed_2 seed_3 seed_4 seed_5 seed_6 \
seed_7 seed_8 seed_9 seed_10 seed_11 seed_12
:stop geometry:

A view of the geometry where the water has been made transparent and a strong zoom factor has been applied so that only a few of the seeds are seen (the seeds are very small compared to the overal geometry size) is shown here:

seeds_in_xyz.png

The complete definition is here:

###############################################################################
#
# EGSnrc egs++ sample brachytherapy seeds geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for a series of brachytherapy
# seeds put into a xyz-geometry filled with water.
#
# It demonstrates the use of a transformed geometry to easily create replicas
# of the same geometry and place them at different locations and orientations.
#
# It also demonstrates that the envelope of an envelope geometry may have
# more than one region. This type of geometry would be useful to calculate
# for instance interseed effects (although, one should use much smaller voxels
# than in this example).
#
###############################################################################
:start geometry definition:
######################## begin of seed definition #######################
##################################### the set of planes needed for the
# CD geometry
:start geometry:
library = egs_planes
name = planes
type = EGS_Zplanes
positions = -0.225 -0.175 0.175 0.225
:stop geometry:
##################################### the top sphere
# (which will turn into a hemisphere
# after being put into region 0 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_top
midpoint = 0 0 -0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
##################################### the set of cylinders
:start geometry:
library = egs_cylinders
name = cladding
midpoint = 0 0 0
type = EGS_ZCylinders
radii = 0.044 0.05
:start media input:
media = air titanium
set medium = 0 1 0
set medium = 1 2 1
:stop media input:
:stop geometry:
##################################### the first radioactive sphere
#
:start geometry:
library = egs_spheres
name = first_sphere
midpoint = 0 0 -0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the second radioactive sphere
#
:start geometry:
library = egs_spheres
name = second_sphere
midpoint = 0 0 0
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the third radioactive sphere
#
:start geometry:
library = egs_spheres
name = third_sphere
midpoint = 0 0 0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the envelope geometry for the
# middle region
:start geometry:
library = egs_genvelope
name = seed_center
base geometry = cladding
inscribed geometries = first_sphere second_sphere third_sphere
:stop geometry:
##################################### the bottom sphere
# (which will turn into a hemisphere
# after being put into region 2 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_bottom
midpoint = 0 0 0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
########################################## And now the actual geometry
# which is a CD geometry made of the set of planes as
# the base geometry and spheres and the cylinder
# envelope as inscribed geometries for the 3 regions.
#
:start geometry:
library = egs_cdgeometry
name = seed
base geometry = planes
set geometry = 0 seed_top
set geometry = 1 seed_center
set geometry = 2 seed_bottom
:stop geometry:
######################## end of seed definition #######################
######################## now define a XYZ-geometry to serve as the
# envelope
:start geometry:
library = egs_ndgeometry
name = xyz
x-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
y-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
z-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
######################### make copies of the seed
:start geometry:
library = egs_gtransformed
name = seed_1
my geometry = seed
:start transformation:
translation = -3 -3 0
rotation vector = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_2
my geometry = seed
:start transformation:
translation = -2 -2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_3
my geometry = seed
:start transformation:
translation = -1 -1 0
rotation vector = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_4
my geometry = seed
:start transformation:
translation = 1 1 0
rotation vector = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_5
my geometry = seed
:start transformation:
translation = 2 2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_6
my geometry = seed
:start transformation:
translation = 3 3 0
rotation vector = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_7
my geometry = seed
:start transformation:
translation = 3 -3 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_8
my geometry = seed
:start transformation:
translation = 2 -2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_9
my geometry = seed
:start transformation:
translation = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_10
my geometry = seed
:start transformation:
translation = -1 1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_11
my geometry = seed
:start transformation:
translation = -2 2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_12
my geometry = seed
:start transformation:
translation = -3 3 0
:stop transformation:
:stop geometry:
########################### now define the final geometry
:start geometry:
library = egs_genvelope
base geometry = xyz
name = seeds_in_box
inscribed geometries = seed seed_1 seed_2 seed_3 seed_4 seed_5 seed_6 \
seed_7 seed_8 seed_9 seed_10 seed_11 seed_12
:stop geometry:
simulation geometry = seeds_in_box
:stop geometry definition:

Better implementation of seeds in a XYZ geometry

file: seeds_in_xyz1.geom

When trying to view the geometry of the previous example one quickly notices that the rendering of the image is quite slow. This is due to the fact that by using an envelope geometry all 12 seeds must be checked for intersections when tracing the light rays through the geometry and because the seed geometry is quite complex this process is slow. A better way of defining this geometry is to use a CD-geometry with the XYZ-geometry as its base geometry and to then inscribe each seed into the XYZ region corresponding to its position. In this way a given seed will only be checked for intersections if the light ray (or a particle trajectory) enters the XYZ region in which the seed is placed. To realize this idea we create the seed (not shown) and the XYZ geometry (not shown). We then create a space geometry that fills the entire space and use envelope geometries to inscribe the transformed seed copies into the space geometry (only the first 2 are shown):

:start geometry:
library = egs_space
name = space
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_1
name = s1
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_2
name = s2
:stop geometry:
We then inscribe the seeds surounded by the space geometry into the corresponding regions of the XYZ-geometry forming a CD-geometry:
########################### now define the final geometry
# the annoing part here is that we have to calculate the region
# numbers ourself
:start geometry:
library = egs_cdgeometry
base geometry = xyz
name = seeds_in_box
set geometry = 629 s1
set geometry = 641 s2
set geometry = 653 s3
set geometry = 665 s0
set geometry = 677 s4
set geometry = 689 s5
set geometry = 701 s6
set geometry = 635 s7
set geometry = 645 s8
set geometry = 655 s9
set geometry = 675 s10
set geometry = 685 s11
set geometry = 695 s12
:stop geometry:
It is necessary to first put the seeds into an infinite envelope because otherwise the XYZ-regions in which the seeds are inscribed will vecome void outside of the seeds. This results from the logic used to implement the geometry methods of a CD geometry (see the EGS_CDGeometry class documentation).

The much better speed is noticable when rendering the image in the viewer. No image is shown as it is the same as in the previous example.

The complete definition is here:

###############################################################################
#
# EGSnrc egs++ sample brachytherapy seeds geometry, using a cd geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for a series of brachytherapy
# seeds put into a xyz-geometry filled with water. It is very similar to the
# seeds_in_xyz.geom file but now the seeds are inscribed in a xyz geometry
# using a CD geometry instead of an envelope.
#
###############################################################################
:start geometry definition:
######################## begin of seed definition #######################
##################################### the set of planes needed for the
# CD geometry
:start geometry:
library = egs_planes
name = planes
type = EGS_Zplanes
positions = -0.225 -0.175 0.175 0.225
:stop geometry:
##################################### the top sphere
# (which will turn into a hemisphere
# after being put into region 0 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_top
midpoint = 0 0 -0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
##################################### the set of cylinders
:start geometry:
library = egs_cylinders
name = cladding
midpoint = 0 0 0
type = EGS_ZCylinders
radii = 0.044 0.05
:start media input:
media = air titanium
set medium = 0 1 0
set medium = 1 2 1
:stop media input:
:stop geometry:
##################################### the first radioactive sphere
#
:start geometry:
library = egs_spheres
name = first_sphere
midpoint = 0 0 -0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the second radioactive sphere
#
:start geometry:
library = egs_spheres
name = second_sphere
midpoint = 0 0 0
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the third radioactive sphere
#
:start geometry:
library = egs_spheres
name = third_sphere
midpoint = 0 0 0.11
radii = 0.03
:start media input:
media = resin
:stop media input:
:stop geometry:
##################################### the envelope geometry for the
# middle region
:start geometry:
library = egs_genvelope
name = seed_center
base geometry = cladding
inscribed geometries = first_sphere second_sphere third_sphere
:stop geometry:
##################################### the bottom sphere
# (which will turn into a hemisphere
# after being put into region 2 of
# the set of planes geometry above
:start geometry:
library = egs_spheres
name = seed_bottom
midpoint = 0 0 0.175
radii = 0.05
:start media input:
media = titanium
:stop media input:
:stop geometry:
########################################## And now the actual geometry
# which is a CD geometry made of the set of planes as
# the base geometry and spheres and the cylinder
# envelope as inscribed geometries for the 3 regions.
#
:start geometry:
library = egs_cdgeometry
name = seed
base geometry = planes
set geometry = 0 seed_top
set geometry = 1 seed_center
set geometry = 2 seed_bottom
:stop geometry:
######################## end of seed definition #######################
######################## now define a XYZ-geometry to serve as the
# envelope
:start geometry:
library = egs_ndgeometry
name = xyz
x-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
y-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
z-planes = -5.5 -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 5.5
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
######################### make copies of the seed
:start geometry:
library = egs_gtransformed
name = seed_1
my geometry = seed
:start transformation:
translation = -3 -3 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_2
my geometry = seed
:start transformation:
translation = -2 -2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_3
my geometry = seed
:start transformation:
translation = -1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_4
my geometry = seed
:start transformation:
translation = 1 1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_5
my geometry = seed
:start transformation:
translation = 2 2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_6
my geometry = seed
:start transformation:
translation = 3 3 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_7
my geometry = seed
:start transformation:
translation = 3 -3 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_8
my geometry = seed
:start transformation:
translation = 2 -2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_9
my geometry = seed
:start transformation:
translation = 1 -1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_10
my geometry = seed
:start transformation:
translation = -1 1 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_11
my geometry = seed
:start transformation:
translation = -2 2 0
:stop transformation:
:stop geometry:
:start geometry:
library = egs_gtransformed
name = seed_12
my geometry = seed
:start transformation:
translation = -3 3 0
:stop transformation:
:stop geometry:
########################### a space geometry to use as an envelope
:start geometry:
library = egs_space
name = space
:start media input:
media = H2O700ICRU
:stop media input:
:stop geometry:
################# the above transformed seeds put into a space envelope
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_1
name = s1
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_2
name = s2
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_3
name = s3
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_4
name = s4
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_5
name = s5
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_6
name = s6
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_7
name = s7
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_8
name = s8
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_9
name = s9
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_10
name = s10
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_11
name = s11
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed_12
name = s12
:stop geometry:
:start geometry:
library = egs_genvelope
base geometry = space
inscribed geometries = seed
name = s0
:stop geometry:
########################### now define the final geometry
# the annoing part here is that we have to calculate the region
# numbers ourself
:start geometry:
library = egs_cdgeometry
base geometry = xyz
name = seeds_in_box
set geometry = 629 s1
set geometry = 641 s2
set geometry = 653 s3
set geometry = 665 s0
set geometry = 677 s4
set geometry = 689 s5
set geometry = 701 s6
set geometry = 635 s7
set geometry = 645 s8
set geometry = 655 s9
set geometry = 675 s10
set geometry = 685 s11
set geometry = 695 s12
:stop geometry:
simulation geometry = seeds_in_box
:stop geometry definition:

A car geometry

file: car.geom

This example geometry file models a car that looks like this:

car1.png

We start by creating the front wheels of the car using a cone stack with the wheel axis along the x-axis:

:start geometry:
library = egs_cones
name = front_wheels
axis = -3.5 -3 -1 1 0 0
:start layer:
thickness = 0.5
top radii = 2
bottom radii = 2
media = wheel_medium
:stop layer:
:start layer:
thickness = 6
top radii = 0.5 2
bottom radii = 0.5 2
media = axis_medium vacuum
:stop layer:
:start layer:
thickness = 0.5
top radii = 2
bottom radii = 2
media = wheel_medium
:stop layer:
:stop geometry:
The first and last layers are the wheels and the second layer the wheel axis. We crfeate the rear wheels as a transformed copy of the front wheels:
:start geometry:
library = egs_gtransformed
my geometry = front_wheels
:start transformation:
translation = 0 6 0
:stop transformation:
name = rear_wheels
:stop geometry:
We will model the car body as two boxes:
######################################## the lower car body
:start geometry:
library = egs_box
box size = 5 14 3
name = lower_car_body
:start media input:
media = body_medium
:stop media input:
:start transformation:
translation = 0 -1 0
:stop transformation:
:stop geometry:
####################################### the upper car body
:start geometry:
library = egs_box
box size = 5 6 2
name = upper_car_body
:start transformation:
translation = 0 0 2.5
:stop transformation:
:start media input:
media = body_medium
:stop media input:
:stop geometry:
The lights are modeled as cone stacks and not shown here for the sake of brevity. The complete car is the union of the front and rear wheels, the car body and the lights:
:start geometry:
library = egs_gunion
name = the_car
geometries = upper_car_body lower_car_body front_wheels rear_wheels ,
left_light right_light
:stop geometry:
We then put the whole car into a vacuum box using an envelope geometry.

The complete geometry definition file is here

###############################################################################
#
# EGSnrc egs++ sample car geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines a geometry that looks like a car. The geometry
# is made from various geometry objects put into a geometry union.
#
##############################################################################
:start geometry definition:
######################################## the front wheels
:start geometry:
library = egs_cones
name = front_wheels
axis = -3.5 -3 -1 1 0 0
:start layer:
thickness = 0.5
top radii = 2
bottom radii = 2
media = wheel_medium
:stop layer:
:start layer:
thickness = 6
top radii = 0.5 2
bottom radii = 0.5 2
media = axis_medium vacuum
:stop layer:
:start layer:
thickness = 0.5
top radii = 2
bottom radii = 2
media = wheel_medium
:stop layer:
:stop geometry:
######################################## the rear wheels
# modeled using a transformed geometry of the front wheels
:start geometry:
library = egs_gtransformed
my geometry = front_wheels
:start transformation:
translation = 0 6 0
:stop transformation:
name = rear_wheels
:stop geometry:
######################################## the lower car body
:start geometry:
library = egs_box
box size = 5 14 3
name = lower_car_body
:start media input:
media = body_medium
:stop media input:
:start transformation:
translation = 0 -1 0
:stop transformation:
:stop geometry:
####################################### the upper car body
:start geometry:
library = egs_box
box size = 5 6 2
name = upper_car_body
:start transformation:
translation = 0 0 2.5
:stop transformation:
:start media input:
media = body_medium
:stop media input:
:stop geometry:
####################################### the lights
:start geometry:
library = egs_cones
axis = -1.5 -8.2 0 0 1 0
:start layer:
thickness = 0.25
top radii = 0.75
bottom radii = 0.75
media = lights_medium
:stop layer:
name = left_light
:stop geometry:
:start geometry:
library = egs_gtransformed
my geometry = left_light
name = right_light
:start transformation:
translation = 3.0 0 0
:stop transformation:
:stop geometry:
######################################## combine everything into a union
:start geometry:
library = egs_gunion
name = the_car
geometries = upper_car_body lower_car_body front_wheels rear_wheels ,
left_light right_light
:stop geometry:
:start geometry:
library = egs_box
name = the_box
box size = 18
:start media input:
media = vacuum
:stop media input:
:stop geometry:
:start geometry:
library = egs_genvelope
name = car_in_box
base geometry = the_box
inscribed geometries = the_car
:stop geometry:
simulation geometry = car_in_box
:stop geometry definition:

A linear accelerator geometry

file: photon_linac.geom

This example demonstrate how the egspp geometry package can be used to model a complex geometry such as the treatment head of a medical linear accelerator (linac). The linac geometry, which is the same as the geometry defined in the EX16MVp.egsinp example input file distributed with BEAMnrc, is modeled as a CD-Geometry. The base geometry of the CD-Geometry is a cone stack. The cone stack can be used to define most of the linac geometry. After specifying that we are using a cone stack from the egs_cones geometry DSO, the axis and the name of the cone stack

:start geometry:
library = egs_cones # this is the geometry library
type = EGS_ConeStack # this is the object type that we need
# from the geometry library egs_cones
axis = 0 0 0 0 0 1 # we use the z-axis as the axis of
# the cone stack
name = linac # and give it the very original name 'linac'
we start adding the various layers that make up the linac geometry: the bremsstrahlung target,
:start layer:
thickness = 0.5
top radii = 2.5 9.11111
bottom radii = 2.5 9.11111
media = W700ICRU AIR700ICRU
:stop layer:
the air between the target and the primary collimator,
:start layer:
thickness = 0.4
bottom radii = 2.5 9.11111
media = AIR700ICRU AIR700ICRU
:stop layer:
the primary collimator,
:start layer:
thickness = 5
top radii = 0.5 9.11111
bottom radii = 3.0 9.11111
media = AIR700ICRU W700ICRU
:stop layer:
etc., until we reach the layer for the mirror. At this point we simply define it as an air cylinder but will later inscribe two planes into this region to create the mirror when defining the CD-geometry
:start layer:
thickness = 2
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
In a similar fashion we define placeholder layers for the x- and y-jaws. After finishing the cone stack definition, we define the mirror planes:
:start geometry:
library = egs_planes
type = EGS_Planes
name = mirror_planes
normal = 0.316227766017 0 0.948683298051
#positions = -100 20.8709325571 20.8710325571 20.8775325571 120
#
# Let's use a single, slightly ticker layer for better
# visibility
#
positions = -100 20.8 21 120
:start media input:
media = AIR700ICRU AL700ICRU PMMA700ICRU
set medium = 1 1
:stop media input:
:stop geometry:
We use a set of 4 parallel planes that defines 3 regions. We make the left and right regions very large but after inscribing this geometry into the placeholder region of the cone stack within a CD-geometry, the air left and right of the mirror will be restricted to the radius of the placeholder region. Note that the mirror is made much ticker for better visibility, the actual thickness is defined in the commented out positions key.

The jaws can be modeled as a plane collection. We use 4 planes to define the 3 regions (left jaw, air, right jaw). As with the mirror, we make the left and right regions very large but they will be restricted to the proper size by the radius of the placeholder cone stack layer when inscribed into it. Here is the definition of the x-jaws:

:start geometry:
library = egs_planes
name = x_jaws
normals = 1,0,0 0.99875,0,0.049938, 0.99875,0,-0.049938, 1,0,0
positions = -50 0 0 50
:start media input:
media = W700ICRU AIR700ICRU
set medium = 0 2 0
set medium = 1 1
:stop media input:
:stop geometry:
The definition of the y-jaws is very similar and not shown.

The final linac geometry is a CD-Geometry with the cone stack as a base and the mirror, x-jaws and y-jaws geometries inscribed into the appropriate regions:

:start geometry:
library = egs_cdgeometry
name = final_linac
base geometry = linac
set geometry = 27 mirror_planes # define the mirror
set geometry = 33 x_jaws # define the x-jaws
set geometry = 39 y_jaws # define the y-jaws
:stop geometry:
The $i$'th region in the $j$'th layer of a cone stack has a region index $i + j n_{\rm max}$, where $n_{\rm max}$ is the maximum number of regions from all layers in the cone stack. In our example the maximum number of regions in any layer is 3 (see e.g. layer 4 of the complete definition below). The mirror is inscribed into the 9'th cone stack layer, which consists of a single region and therefore the region index to inscribe the mirror is 27. In the same way the x-jaws are inscribed into the 11'th layer and the j-jaws into the 13'th and therefore the corresponding region indeces are 33 and 39.

This is a view of this linac geometry after the air has been made completely transparent.

linac_s1.png

One can of course zoom-in and use clipping planes to better view just portions of the geometry as shown in this close-up of the flattening filter

linac_s2.png

The complete definitions is here:

###############################################################################
#
# EGSnrc egs++ sample linear accelerator treatment head geometry
# Copyright (C) 2015 National Research Council Canada
#
# This file is part of EGSnrc.
#
# EGSnrc is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
#
# Author: Iwan Kawrakow, 2005
#
# Contributors:
#
###############################################################################
#
# An example geometry input file for the egs++ geometry package.
#
# This input file defines an egs++ geometry for the treatment head of a
# medical linear accelerator in photon mode. It is based on the EX16MVp
# example geometry that is included in BEAMnrc (except that the monitor
# chamber is not modeled for the sake of simplicity).
#
# The accelerator is modeled as a CD geometry (EGS_CDGeometry) where the
# mirror and the two pairs of jaws are put into the appropriate regions of
# the base linac geometry, which is a cone stack (EGS_ConeStack). The cone
# stack defines most of the accelerator geometry (bremsstrahlung target,
# primary collimator and flattening filter) and provides placeholder regions
# for the mirror and the two pairs of jaws.
#
###############################################################################
:start geometry definition:
:start geometry:
library = egs_cones # this is the geometry library
type = EGS_ConeStack # this is the object type that we need
# from the geometry library egs_cones
axis = 0 0 0 0 0 1 # we use the z-axis as the axis of
# the cone stack
name = linac # and give it the very original name 'linac'
######################### the target
:start layer:
thickness = 0.5
top radii = 2.5 9.11111
bottom radii = 2.5 9.11111
media = W700ICRU AIR700ICRU
:stop layer:
# ends at z = 0.5 regions 0...2
######################### air between target and primary collimator
:start layer:
thickness = 0.4
bottom radii = 2.5 9.11111
media = AIR700ICRU AIR700ICRU
:stop layer:
# ends at z = 0.9 regions 3...5
######################### the primary collimator
:start layer:
thickness = 5
top radii = 0.5 9.11111
bottom radii = 3.0 9.11111
media = AIR700ICRU W700ICRU
:stop layer:
# ends at z = 5.9 regions 6...8
######################### air between primary collimator and
# flattening filter
:start layer:
thickness = 2.1
top radii = 9.11111
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
# ends at z = 8 regions 9...11
######################## start of flattening filter (ff)
#
#----------------------- layer 1
:start layer:
thickness = 0.3
top radii = 0 9.11111
bottom radii = 0.5 9.11111
media = FE700ICRU AIR700ICRU
:stop layer:
# ends at z = 8.3 regions 12...14
#----------------------- layer 2
:start layer:
thickness = 0.7
bottom radii = 0.8 9.11111
media = FE700ICRU AIR700ICRU
:stop layer:
# ends at z = 9.0 regions 15...17
#----------------------- layer 3
:start layer:
thickness = 1.0
top radii = 0 0.8 9.11111
bottom radii = 0.4 1.7 9.11111
media = W700ICRU FE700ICRU AIR700ICRU
:stop layer:
# ends at z = 9.11111 regions 18...20
#----------------------- layer 4
:start layer:
thickness = 1.2
bottom radii = 1.2 3.0 9.11111
media = W700ICRU FE700ICRU AIR700ICRU
:stop layer:
# ends at z = 11.2 regions 21...23
#
############################ end of flattening filter
##################### we skip the monitor chamber
# (too lazy to input so many layers)
#
##################### air between ff and mirror
:start layer:
thickness = 9.8
top radii = 9.11111
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
# ends at z = 21.0 regions 24...26
##################### placeholder for the mirror
# it is left empty for now, it will be
# divided into regions later on
# when this geometry becomes the base geometry
# of a CD geometry used to model the final linac
#
:start layer:
thickness = 2
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
# ends at z = 23.0 regions 27...29
##################### air between mirror and jaws
:start layer:
thickness = 6
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
# ends at z = 29.0 regions 30...32
##################### placeholder for the x-jaws
# same comments as for the mirror layer.
#
:start layer:
thickness = 9
bottom radii = 9.11111
media = W700ICRU
:stop layer:
# ends at z = 38.0 regions 33...35
##################### air between x- and y-jaws
:start layer:
thickness = 0.5
bottom radii = 9.11111
media = AIR700ICRU
:stop layer:
# ends at z = 38.5 regions 36...38
##################### placeholder for the y-jaws
# same comments as for the mirror layer.
#
:start layer:
thickness = 9
bottom radii = 9.11111
media = W700ICRU
:stop layer:
# ends at z = 47.5 regions 39...41
:stop geometry:
################################### end of the cone stack named 'linac'
################################### the mirror planes
# we make them extend to infinity
# but they will be cut to the desired
# size when put into the linac
:start geometry:
library = egs_planes
type = EGS_Planes
name = mirror_planes
normal = 0.316227766017 0 0.948683298051
#positions = -100 20.8709325571 20.8710325571 20.8775325571 120
#
# Let's use a single, slightly ticker layer for better
# visibility
#
positions = -100 20.8 21 120
:start media input:
media = AIR700ICRU AL700ICRU PMMA700ICRU
set medium = 1 1
:stop media input:
:stop geometry:
################################### the x-jaws planes
# We use a plane collection which will be cut
# to the proper size in the z-direction when
# put into the x-jaws placeholder in the linac geometry
# We make the left- and right-most regions very large
# These regions will be cut by the bounding cylinder of
# the base linac geometry
#
:start geometry:
library = egs_planes
name = x_jaws
normals = 1,0,0 0.99875,0,0.049938, 0.99875,0,-0.049938, 1,0,0
positions = -50 0 0 50
:start media input:
media = W700ICRU AIR700ICRU
set medium = 0 2 0
set medium = 1 1
:stop media input:
:stop geometry:
################################### the y-jaws planes
# We use a plane collection which will be cut
# to the proper size in the z-direction when
# put into the x-jaws placeholder in the linac geometry
# We make the left- and right-most regions very large
# These regions will be cut by the bounding cylinder of
# the base linac geometry
#
:start geometry:
library = egs_planes
name = y_jaws
normals = 0,1,0 0,0.99875,0.049938, 0,0.99875,-0.049938, 0,1,0
positions = -50 0 0 50
:start media input:
media = W700ICRU AIR700ICRU
set medium = 0 2 0
set medium = 1 1
:stop media input:
:stop geometry:
################################## the final accelerator
:start geometry:
library = egs_cdgeometry
name = final_linac
base geometry = linac
set geometry = 27 mirror_planes # define the mirror
set geometry = 33 x_jaws # define the x-jaws
set geometry = 39 y_jaws # define the y-jaws
:stop geometry:
simulation geometry = final_linac
#simulation geometry = linac
:stop geometry definition: