| Geant4 User's Guide For Application Developers Geometry

## 4.1.10 Converting Geometries from Geant 3.21

Approach

G3toG4 is the Geant4 facility to convert GEANT 3.21 geometries into Geant4. This is done in two stages:

1. The user supplies a GEANT 3.21 RZ-file (.rz) containing the initialization data structures. An executable `rztog4` reads this file and produces an ASCII call list file containing instructions on how to build the geometry. The source code of `rztog4` is FORTRAN.
2. A call list interpreter (`G4BuildGeom.cc`) reads these instructions and builds the geometry in the user's client code for Geant4.

Importing converted geometries into Geant4

Two examples of how to use the call list interpreter are supplied in the directory `examples/extended/g3tog4`:

1. `cltog4` is a simple example which simply invokes the call list interpreter method `G4BuildGeom` from the `G3toG4DetectorConstruction` class, builds the geometry and exits.
2. `clGeometry`, is more complete and is patterned as for the novice Geant4 examples. It also invokes the call list interpreter, but in addition, allows the geometry to be visualized and particles to be tracked.

To compile and build the G3toG4 libraries, you need to have set in your environment the variable `G4LIB_BUILD_G3TOG4` at the time of installation. The G3toG4 libraries are not built by default. Then, simply type

      gmake

from the top-level `source/g3tog4` directory.

To build the converter executable `rztog4`, simply type

      gmake bin

To make everything, simply type:

      gmake global

To remove all `G3toG4` libraries, executables and .d files, simply type

      gmake clean

Current Status

The package has been tested with the geometries from experiments like: BaBar, CMS, Atlas, Alice, Zeus, L3, and Opal.
Here is a comprehensive list of features supported and not supported or implemented in the current version of the package:

- Supported shapes: all GEANT 3.21 shapes except for `GTRA`, `CTUB`.
- `PGON`, `PCON` are built using the specific solids `G4Polycone` and `G4Polyhedra`.
- GEANT 3.21 `MANY` feature is only partially supported.
  `MANY` positions are resolved in the `G3toG4MANY()` function, which has to be processed before `G3toG4BuildTree()` (it is not called by default).
  In order to resolve `MANY`, the user code has to provide additional info using `G4gsbool(G4String volName, G4String manyVolName)` function for all the overlapping volumes. Daughters of overlapping volumes are then resolved automatically and should not be specified via `Gsbool`.
  Limitation: a volume with a `MANY` position can have only this one position; if more than one position is needed a new volume has to be defined (`gsvolu()`) for each position.
- `GSDV*` routines for dividing volumes are implemented, using `G4PVReplica`s, for shapes:

- `BOX`, `TUBE`, `TUBS`, `PARA` - all axes;
- `CONE`, `CONS` - axes 2, 3;
- `TRD1`, `TRD2`, `TRAP` - axis 3;
- `PGON`, `PCON` - axis 2;
- `PARA` -axis 1; axis 2,3 for a special case

- `GSPOSP` is implemented via individual logical volumes for each instantiation.
- `GSROTM` is implemented. Reflections of hierachies based on plain CSG solids are implemented through the `G3Division` class.
- Hits are not implemented.
- Conversion of GEANT 3.21 magnetic field is currently not supported. However, the usage of magnetic field has to be turned on.

About the authors