<!-- ******************************************************** -->
<!--                                                          -->
<!--  [History]                                               -->
<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
<!--    Changed by: Gabriele Cosmo, 18-Apr-2005               -->
<!--                                                          -->
<!-- ******************************************************** -->


<!-- ******************* Section (Level#2) ****************** -->
<sect2 id="sect.Geom.ConvGeom">
<title>
Converting Geometries from Geant3.21
</title>

<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.ConvGeom.App">
<title>
Approach
</title>

<para>
<emphasis role="bold">G3toG4</emphasis> is the Geant4 facility to convert 
GEANT 3.21 geometries into Geant4. This is done in two stages:

<orderedlist spacing="compact">
  <listitem><para>
    The user supplies a GEANT 3.21 RZ-file (.rz) containing the
    initialization data structures. An executable <literal>rztog4</literal> reads
    this file and produces an ASCII <emphasis>call list</emphasis> file containing
    instructions on how to build the geometry. The source code of
    <literal>rztog4</literal> is FORTRAN.
  </para></listitem>
  <listitem><para>
    A call list interpreter (<literal>G4BuildGeom.cc</literal>) reads these
    instructions and builds the geometry in the user's client code for
    Geant4.
  </para></listitem>
</orderedlist>
</para>

</sect3>

<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.ConvGeom.Import">
<title>
Importing converted geometries into Geant4
</title>

<para>
Two examples of how to use the call list interpreter are
supplied in the directory <literal>examples/extended/g3tog4</literal>:

<orderedlist spacing="compact">
  <listitem><para>
    <literal>cltog4</literal> is a simple example which simply invokes the
    call list interpreter method <literal>G4BuildGeom</literal> from the
    <literal>G3toG4DetectorConstruction</literal> class, builds the geometry and
    exits.
  </para></listitem>
  <listitem><para>
    <literal>clGeometry</literal>, 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.
  </para></listitem>
</orderedlist>
</para>

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

<informalexample>
<programlisting>
  gmake
</programlisting>
</informalexample>

from the top-level <literal>source/g3tog4</literal> directory.
</para>

<para>
To build the converter executable <literal>rztog4</literal>, simply
type

<informalexample>
<programlisting>
  gmake bin
</programlisting>
</informalexample>
</para>

<para>
To make everything, simply type:

<informalexample>
<programlisting>
  gmake global
</programlisting>
</informalexample>
</para>

<para>
To remove all <literal>G3toG4</literal> libraries, executables and .d files,
simply type

<informalexample>
<programlisting>
  gmake clean
</programlisting>
</informalexample>
</para>

</sect3>

<!-- ******************* Section (Level#3) ****************** -->
<sect3 id="sect.Geom.ConvGeom.Curr">
<title>
Current Status
</title>

<para>
The package has been tested with the geometries from experiments
like: BaBar, CMS, Atlas, Alice, Zeus, L3, and Opal.
</para>

<para>
Here is a comprehensive list of features supported and not
supported or implemented in the current version of the package:

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

    <itemizedlist spacing="compact">
      <listitem><para>
        <literal>BOX</literal>, <literal>TUBE</literal>, 
        <literal>TUBS</literal>, <literal>PARA</literal> - all axes;
      </para></listitem>
      <listitem><para>
        <literal>CONE</literal>, <literal>CONS</literal> - axes 2, 3;
      </para></listitem>
      <listitem><para>
        <literal>TRD1</literal>, <literal>TRD2</literal>, 
        <literal>TRAP</literal> - axis 3;
      </para></listitem>
      <listitem><para>
        <literal>PGON</literal>, <literal>PCON</literal> - axis 2;
      </para></listitem>
      <listitem><para>
        <literal>PARA</literal> -axis 1; axis 2,3 for a special case
      </para></listitem>
    </itemizedlist>
  </para></listitem>
  <listitem><para>
    <literal>GSPOSP</literal> is implemented via individual logical volumes
    for each instantiation.
  </para></listitem>
  <listitem><para>
    <literal>GSROTM</literal> is implemented. Reflections of hierachies based
    on plain CSG solids are implemented through the <literal>G3Division</literal>
    class.
  </para></listitem>
  <listitem><para>
    Hits are not implemented.
  </para></listitem>
  <listitem><para>
    Conversion of GEANT 3.21 magnetic field is currently not
    supported. However, the usage of magnetic field has to be turned on.
  </para></listitem>
</itemizedlist>
</para>


</sect3>
</sect2>
