GH2ROOT: the Geant3 to ROOT Conversion Tool

Gh2root generates C++ classes to read/convert Geant3 hits

Gh2root is a small Fortran program that generates automatically C++ code corresponding to the Geant3 structures JSET, JVERTX, JKINE, JHITS and JDIGI.

The input to gh2root can be a Geant3/RZ file containing the detector definition data structures generated at initialisation time of Geant or a Zebra/FZ file with these data structures. Instead of using gh2root as a program, one can also call directly the subroutine Convert in a program using Geant at the end of the initialisation phase. When using gh2root as a program, the invokation is:

       gh2root  geantfile.geom  [prefix] [lrecl]
where geantfile.geom is the Geant3/RZ or FZfile. If the file is an FZ file, the parameters prefix and lrecl are mandatory. In this case, lrecl is the record length in machine words (eg 900) of the FZ file.

gh2root generates C++ classes (both header files and implementation). All generated classes start by the chain of characters specified in the optional argument prefix. By default prefix is 'X'. The following classes are generated (assuming X is the prefix):

The generated classes can be compiled into a shared library. gh2root generates the Makefile to compile and make the library for several machines (see later). Once the library called has been generated, it can be dynamically linked to a running Root program.

gh2root generates also Root macros to invoke these classes

The macros above typically invoke service functions from the XGRun class to:

Linking gh2root

gh2root.f is the Fortran file that must be compiled to generate the gh2root executable module. gh2root requires the Zebra package only, not Geant3 itself. The following command illustrates how to compile and link on an hpux system.
        f77 -o gh2root -g +ppu gh2root.f /cern/pro/lib/libpacklib.a

Using the generated Makefiles

The following makefiles are generated: When you install gh2root on your system, create a link to the Makefile corresponding to your system (eg on hpux):
    ln -s Makefile.hpux  makefile
To compile and generate the library, do:
   gmake depend
   gmake groot


We use the Geant3 RZ file from the STAR experiment at RHIC.
           gh2root star.geom Star
This generates the STAR classes:

We have also generated the ALICE classes:

Using the generated macros

The generated classes can be tested without any Geant3 input file using the kine/hits/digits simulator in the macro fake.C. In an interactive Root session, do: Root > .x fake.C You can edit this macro to change the number of tracks and hits per track.

An existing Geant3 Zebra/FZ file containing kinematics, hits and digits can be automatically converted to a Root Tree with the macro run.C.

  Root > .x run.C
Edit this macro to specify the right file name (input and output). Probably, you will have to specify a value for lrecl. The generated file contains 3 Root Trees: You can browse through the generated Root file using the macro browse.C. The following picture shows the browser pointing to a hit.

You can click in the browser on the hit with the right mouse button and select the Inspect item. This will open the ROOT inspector to display the internal structure of this hit as shown in the picture below.

The macro analyze.C is an example of analysis code, looping on all generated events and tracks. An histogram is created, filled with some track parameters and displayed.

Viewing Hits

You can now use the standard ROOT utilities to naviguate inside the event objects. For example, the macro stardisp.C produces the following picture:
Rene Brun

Last update 22/01/98 by RB