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):
-
XRun: This class controls all the other classes
-
GParticle: A combined vertex/particle handling class. This class
will be used to convert a JVERTX/JKINE Zebra structure into a TClonesArray
of GParticle objects pointed by the data member fParticles in the class
XGRun.
-
XMaker: This is the base class for all Makers. This class provides
the basic functions to convert the Geant3 JHITS structures.
-
A Maker class is generated for each set/detector. The name of the
Maker class is XSetDetMaker where Set/Det are the names of the Geant
set and det (created via GSDET). The XSetDetMaker class is the manager
for hits/digits produced by a given Geant3 set and det. All hits are stored
in a TClonesArray pointed by the member fHits. All digits are stored
in a TClonesArray pointed by fDigits.
-
A hit class named XSetDethit. A hit object has data members corresponding
to the information specified by the Geant routines GSDET and GSDETH. (track
number, volumes numbers and hits).
-
A digit class named XSetDetdigit. A digit object has data members
corresponding to the information specified by the Geant routines GSDET
and GSDETD. (track numbers, volumes numbers and digits).
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 libghlib.so has been generated,
it can be dynamically linked to a running Root program.
gh2root generates also Root macros to invoke these classes
-
fake.C
: to generate random particles and hits.
-
run.C
: to convert a Geant FZ file into a Root Tree.
-
browse.C
: to browse a Root file with hits.
-
analyze.C
: example of analysis code to loop on generated events and make histograms.
The macros above typically invoke service functions from the XGRun class
to:
-
Initialize Root and all detector makers.
-
Control the processing of one event.
-
Simulate random tracks and hits.
-
Import a Zebra KINE,HITS and DIGI structures from FZ.
-
Create and Fill the Root Trees with particles/hits/digits.
-
Browse the generated Root file.
-
Control functions for graphics (DistancetoPrimitive and Paint)
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:
-
Makefile.aix for AIX with the xlC compiler
-
Makefile.alpha for Dec/Alpha with the CXX compiler
-
Makefile.hpux for hp-ux10.20 with the CC compiler
-
Makefile.hpuxacc for hpux10.20 withe the aCC compiler
-
Makefile.linux for Intel/Linux with g++
-
Makefile.sgi for SGI/Irix with the CC compiler
-
Makefile.solaris for Sun/Solaris with the CC compiler
-
Makefile.win for WindowsNT with VisualC++
-
Make-macros common to all systems. This file specifies rules and dependencies.
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 libghlib.so library, do:
gmake depend
gmake
gmake groot
Examples
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:
-
TK: with the kinematics.
-
TH: with the hits.
-
TD: with the digits.
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