This document describes how to use python to build the volumes described in the Geant4 User Guide
The volumes are built within a system using the python interface.
Each geant4 solid’s constructor is documented below.
G4Box ![]() |
G4Tubs ![]() |
G4Cons ![]() |
G4Trd ![]() |
G4TrapRAW ![]() |
G4TrapG ![]() |
G4Trap8 ![]() |
G4Trap ![]() |
G4Sphere ![]() |
G4Polycone ![]() |
G4Box: Simple Box
Function: make_box(dx, dy, dz, lunit='mm')
Creates a geant4 Box
Parameters:
dx : half length in x
dy : half length in y
dz : half length in z
lunit: length unit (optional; default: mm)
Example:
Creates a box with dx=30mm, dy=40mm, dz=60mm:
> make_box(30, 40, 60)
To print the corresponding code:
> scigTemplate.py -gv G4Box -gvp '30, 40, 60' -silent
To print the generic code:
> scigTemplate.py -gv G4Box

G4Tubs: Cylindrical Section or Tube
Function: make_tube(rin, rout, length, phistart, phitotal, lunit1='mm', lunit2='deg')
Creates a geant4 Cylindrical Section or Tube
Parameters:
rin : inner radius
rout : outer radius
length : tube half length in z
phistart : starting phi angle
phitotal : total phi angle
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)
Example:
Creates a tube with rin=10mm, rout=15mm, length=20mm, phistart=0deg, phitotal=90deg:
> make_tube(10, 15, 20, 0, 90)
To print the corresponding code:
> scigTemplate.py -gv G4Tubs -gvp '10, 15, 20, 0, 90' -silent
To print the generic code:
> scigTemplate.py -gv G4Tubs

G4Cons: Cone or Conical section
Function: make_cone(rin1, rout1, rin2, rout2, length, phi_start, phi_total, lunit1='mm', lunit2='deg')
Creates a geant4 Cone or Conical section
Parameters:
rin1 : inner radius at -dz
rout1 : outer radius at -dz
rin2 : inner radius at +dz
rout2 : outer radius at +dz
length : cone half length in z
phi_start : starting phi angle
phi_total : total phi angle
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)
Example:
Creates a cone with rin1=5mm, rout1=10mm, rin2=20mm, rout2=25mm, length=40mm, phi_start=0deg, phi_total=270deg:
> make_cone(5, 10, 20, 25, 40, 0, 270)
To print the corresponding code:
> scigTemplate.py -gv G4Cons -gvp '5, 10, 20, 25, 40, 0, 270' -silent
To print the generic code:
> scigTemplate.py -gv G4Cons

G4Trd: Trapezoid
Function: make_trapezoid(dx1, dx2, dy1, dy2, z, lunit='mm')
Creates a geant4 Trapezoid
Parameters:
dx1 : half length in x at -dz
dx2 : half-length in x at +dz
dy1 : half-length in y at -dz
dy2 : half-length in y at +dz
z : half-length in z
lunit: length unit (optional; default: mm)
Example:
Creates a trapezoid with dx1=30mm, dx2=10mm, dy1=40mm, dy2=15mm, z=60mm:
> make_trapezoid(30, 10, 40, 15, 60)
To print the corresponding code:
> scigTemplate.py -gv G4Trd -gvp '30, 10, 40, 15, 60' -silent
To print the generic code:
> scigTemplate.py -gv G4Trd

G4TrapRAW: Generic Trapezoid: right Angular Wedge (4 parameters)
Function: make_trap_from_angular_wedges(pz, py, px, pltx, lunit1='mm')
Creates a geant4 Generic Trapezoid: right Angular Wedge (4 parameters)
Parameters:
pz : Length along Z
py : Length along Y
px : Length along X at the wider side
pltx : Length along X at the narrower side (plTX<=pX)
unit: length unit (optional; default: mm)
Example:
TO VERIFY:
Creates a trapezoid with pz=30mm, py=40mm, px=50mm, pltx=20mm:
> make_trap_from_angular_wedges(30, 40, 50, 20)
To print the corresponding code:
> scigTemplate.py -gv G4TrapRAW -gvp '30, 40, 50, 20' -silent
To print the generic code:
> scigTemplate.py -gv G4TrapRAW

G4TrapG: Generic Trapezoid: general trapezoid (11 parameters)
Function: make_general_trapezoid(pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2, lunit1='mm', lunit2='deg')
Creates a geant4 Generic Trapezoid: general trapezoid (11 parameters)
Parameters:
pDz: Half Z length - distance from the origin to the bases
pTheta: Polar angle of the line joining the centres of the bases at -/+pDz
pPhi: Azimuthal angle of the line joining the centre of the base at -pDz to the centre of the base at +pDz
pDy1: Half Y length of the base at -pDz
pDy2: Half Y length of the base at +pDz
pDx1: Half X length at smaller Y of the base at -pDz
pDx2: Half X length at bigger Y of the base at -pDz
pDx3: Half X length at smaller Y of the base at +pDz
pDx4: Half X length at bigger y of the base at +pDz
pAlp1: Angle between the Y-axis and the centre line of the base at -pDz (lower endcap)
pAlp2: Angle between the Y-axis and the centre line of the base at +pDz (upper endcap)
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)
Example:
Creates a trapezoid with pDz=30mm, pTheta=40deg, pPhi=50deg, pDy1=60mm, pDx1=70mm, pDx2=80mm, pAlp1=90deg, pDy2=100mm, pDx3=110mm, pDx4=120mm, pAlp2=130deg:
> make_general_trapezoid(30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130)
To print the corresponding code:
> scigTemplate.py -gv G4TrapG -gvp '30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130' -silent
To print the generic code:
> scigTemplate.py -gv G4TrapG

G4Trap8: Generic Trapezoid: from eight points (24 parameters)
Function: make_trap_from_vertices(v1x, v1y, v1z, v2x, v2y, v2z, v3x, v3y, v3z, v4x, v4y, v4z, v5x, v5y, v5z, v6x, v6y,
v6z, v7x, v7y, v7z, v8x, v8y, v8z, lunit1='mm')
Creates a geant4 Generic Trapezoid: from eight points (24 parameters)
Parameters:
v1x, v1y, v1z: Coordinates of the first vertex
v2x, v2y, v2z: Coordinates of the second vertex
v3x, v3y, v3z: Coordinates of the third vertex
v4x, v4y, v4z: Coordinates of the fourth vertex
v5x, v5y, v5z: Coordinates of the fifth vertex
v6x, v6y, v6z: Coordinates of the sixth vertex
v7x, v7y, v7z: Coordinates of the seventh vertex
v8x, v8y, v8z: Coordinates of the eighth vertex
lunit1: length unit (optional; default: mm)
v1, v2 | Edge with smaller Y of the base at -z
v3, v4 | Edge with bigger Y of the base at -z
v5, v6 | Edge with smaller Y of the base at +z
v7, v8 | Edge with bigger Y of the base at +z
Example:
MISSING, build one

G4Trap: Generic Trapezoid: will call the G4Trap constructor based on the number of parameters
Function: make_trap(params, lunit1='mm', lunit2='deg')
Creates a geant4 Generic Trapezoid: will call the G4Trap constructor based on the number of parameters
Parameters:
params: list of parameters
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)
Example::
MISSING, build one

G4Sphere: Sphere or Spherical Shell Section
Function: make_sphere(rmin, rmax, sphi, dphi, stheta, dtheta, lunit1='mm', lunit2='deg')
Creates a geant4 Sphere or Spherical Shell Section
Parameters:
rmin: inner radius
rmax: outer radius
sphi: starting phi angle
dphi: delta phi angle
stheta: starting theta angle
dtheta: delta theta angle
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)

G4Polycone: Polycons
Function: make_polycone(phiStart, phiTotal, zplane, iradius, oradius, lunit1='mm', lunit2='deg')
Creates a geant4 Polycone
Parameters:
phiStart: starting phi angle
phiTotal: total phi angle
zplane: list of z coordinates
iradius: list of inner radii
oradius: list of outer radii
lunit1: length unit (optional; default: mm)
lunit2: angle unit (optional; default: deg)
Example:
MISSING, build one
