How to Make Environments for
Geant4 Visualization

June 03, 2000 (version 08)
May 31, 2000 (version 07)
May 10, 2000 (version 06)
January 26, 2000 (version 05)
November 02,1999 (version 04)
September 30,1999 (version 03)
September 07,1999 (version 02)
September 02,1999 (version 01)
August 31, 1999 (version 00)

Satoshi Tanaka (Fukui University)

@

1. Introduction

This Web page describes how to make environments for Geant4 visualization on Linux with the following setup: (1) CLHEP library version 1.5, STL library, and Mesa-3.X are used for compiling Geant4 libraries and executables. (2) The DAWNFILE, OpenGL-Xlib and VRMLFILE drivers are used for Geant4 visualization. The description below is checked with RedHat Linux 6.1, and expected to be valid for many other Linux (and other Unix) packages.

How to obtain (and install) graphics packages Mesa (a free OpenGL), DAWN (a PostScript processor), OPACS (a graphics library for HEP), Hepvis (a graphics library for HEP), SoFree (a free OpenInventor), and LessTif (a free Motif), which are available for Geant4 Visualization, is also described below.

Note: For the above-mentioned setup (1) and (2), you only need to install Mesa and DAWN. But we strongly recommend trying other packages, too. Geant4 visualization with each of the above package has its own advantages and sometimes works complementarily.

2. Required C++ compiler

In order to compile Geant4 and CLHEP 1.5, you need the g++ compiler version 1.1 or after. The packages of RedHat Linux 6.X include a right one. If you are using another package of Linux or an older version of RedHat Linux, you may have to update the g++ compiler. You may also have to update related libraries. You can know a version of the g++ compiler with the command "g++ -v". For more details, see the Web page of Naruto University of Education:
http://erpc1.naruto-u.ac.jp/~geant4 .

The STL library is included in the g++ compiler version 1.X.

@

3. Installation of CLHEP 1.5

You should obtain the CLHEP 1.5 source codes first. Detailed information on CLHEP is described at http://wwwinfo.cern.ch/asd/lhc++/clhep/index.html .

The installation of CLHEP is very easy:

% gtar xvzf clhep-1.5.0.0.tar.gz
% cd ./CLHEP
% autoconf
% ./configure
% gmake
% su
# gmake install
# cd /usr/local/lib
# ln -s libCLHEP-g++.a libCLHEP.a

In this default way of installation, CLHEP 1.5 is installed under "/usr/local/", i.e. "/usr/local/lib/" and "/usr/local/include/CLHEP/".

@

4. Installation of Mesa (a free OpenGL)

You need Mesa (a free OpenGL) to use the OpenGL visualization drivers.

4.1 Mesa 3.0

You can obtain the source codes of Mesa-3.0 (a free OpenGL library) from the following Web site: http://www.mesa3d.org . The installation is quite easy. If you want to install Mesa-3.0 under, for example, "/usr/local/Mesa-3.0/", do as follows:

% gtar xvzf MesaLib-3.0.tar.gz
% cd Mesa-3.0
% gmake
(# Excecuting "gmake" without an argument displays list of supported platform.)
% gmake linux
% su
# mkdir /usr/local/Mesa-3.0
# cp -r ./lib /usr/local/Mesa-3.0
# cp -r ./include /usr/local/Mesa-3.0
# cd /usr/local/Mesa-3.0
# ln -s libMesaGL.a libGL.a
# ln -s libMesaGLU.a libGLU.a

If you have the RPM package of Mesa-3.0, you can install it as follows:

% su
# rpm -i Mesa-devel-3.0-X.i386.rpm

In this case, Mesa is installed under the directory "/usr/".

@

4.2 Mesa 3.1

WARNING: Do not use Mesa 3.1 with the OpenGL visualization driver.

@

4.3 Mesa 3.2

You can obtain the source codes of Mesa-3.2 (a free OpenGL library) from the following Web site: http://www.mesa3d.org . The installation is quite easy. If you want to install Mesa-3.2 under, for example, "/usr/local/Mesa-3.2/", do as follows:

% gtar xvzf MesaLib-3.2.tar.gz
% cd Mesa-3.2
% ./configure --prefix=/usr/local/Mesa-3.2
% gmake
% gmake strip
% su
# gmake install

For more details, read Mesa-3.2/docs/INSTALL.

If you have the RPM package of Mesa, you can install it as follows:

% su
# rpm -i Mesa-devel-3.2-X.i386.rpm

In this case, Mesa is installed under the directory "/usr/".

NOTE
: In some Linux distributions, Mesa 3.2 is already installed. You can check it as follows:
% rpm -q -a | less

5. Installation of Fukui Renderer DAWN (a PostScript processor)

You need Fukui Renderer DAWN (a technical-high-quality PostScript processor) to use the DAWNFILE visualization driver. You can obtain the source codes of DAWN from the following Web site: http://geant4.kek.jp/~tanaka . The installation is quite easy. Do as follows:

(Case 1) In case you want to use OpenGL mode:
% gtar xvzf dawn_VERSION.tar.gz
% cd dawn_VERSION
% gmake clean
% gmake guiclean
% configure
(* Answer all questions properly.)
% gmake
% su
# gmake install

(Case 2) In case you do NOT want to use OpenGL mode,
and only want to use X-Window and PostScript-file-generation modes:
% gtar xvzf dawn_VERSION.tar.gz
% cd dawn_VERSION
% gmake clean
% gmake guiclean
% configure_xwin
(* Answer all questions properly.)
% gmake
% su
# gmake install

In both of the cases, the final step "gmake install" installs DAWN to the directory specified in running the configure script.

WARNING :You must use DAWN 3.80 or after for the DAWNFILE visualization driver.

Note: Tcl/Tk, Ghostscript, and gv, which are required for DAWN is included
in most of the Linux packages.
Tcl/:
http://dev.scriptics.com/software/tcltk
gv:
http://wwwthep.physik.uni-mainz.de/~plass/gv ,
Ghostspript:
http://www.cs.wisc.edu/~ghost/index.html

6. Installation of LessTif (a free Motif)

Installation of LessTif (a free Motif) is not mandatory for the setup (1),(2) mentioned in g1.Introductionh. But you need it if you want to use the OpenGL-X-Motif visualization driver. For details on LessTif, see the following Web page: http://www.lesstif.org .

@

7. Installation of OPACS (a graphics library for HEP)

Installation of OPACS (a graphics library for HEP) is not mandatory for the setup (1),(2) mentioned in g1.Introductionh. But you need it if you want to use the OPACS visualization driver. For details on OPACS, see the following Web page: http://www.lal.in2p3.fr/OPACS

@

8. Installation of Hepvis (a graphics library for HEP) and
SoFree (a free OpenInventor)

Installation of Hepvis (a graphics library for HEP) and SoFree (a free OpenInventor) is not mandatory for the setup (1),(2) mentioned in g1.Introductionh. But you need them if you want to use the OpenInventor visualization driver. For details on Hepvis and SoFree, see the following Web pages:
http://cactus.phyast.pitt.edu/~joe/hepvis/hepvis.html
http://www.lal.in2p3.fr/Inventor

9a. Setting environmental variables (1)

In order to compile Geant4 for visualization, you have to set several environmental variables beforehand. (Equivalently, you can also edit macros of GNUmakefile's in the directory "geant4/config/".).

Adding the following to your ".cshrc" allows you to perform Geant4 visualization with the DAWNFILE, OpenGL, and VRMLFILE drivers:
(You may have to do some customization for your own environment, of course.)

#####################################################
# Sample .cshrc for Geant4 visualization on Linux
#####################################################

###### 1. General setting
setenv G4SYSTEM Linux-g++
setenv CLHEP_BASE_DIR /usr/local
#setenv CLHEP_BASE_DIR /usr/local/CLHEP

###### 2. UI

############ 2-1. Selection of (G)UI in installation of libraries
setenv G4UI_BUILD_TERMINAL_SESSION 1
#setenv G4UI_BUILD_GAG_SESSION 1

############ 2-2. Selection of (G)UI in compiling executables
setenv G4UI_USE_TERMINAL 1
#setenv G4UI_USE_GAG 1

###### 3. Visualization

############ 3-1. Home directory of Mesa
setenv OGLHOME /usr/local/Mesa-3.0

############ 3-2. Selection of visualization drivers
# in installation of libraries
setenv G4VIS_BUILD_DAWNFILE_DRIVER 1
setenv G4VIS_BUILD_OPENGLX_DRIVER 1
setenv G4VIS_BUILD_VRMLFILE_DRIVER 1
# setenv G4VIS_BUILD_DAWN_DRIVER 1
# setenv G4VIS_BUILD_OPACS_DRIVER 1
# setenv G4VIS_BUILD_OPENGLXM_DRIVER 1
# setenv G4VIS_BUILD_OPENINVENTOR_DRIVER 1
# setenv G4VIS_BUILD_RAYTRACER_DRIVER 1
# setenv G4VIS_BUILD_VRML_DRIVER 1

############ 3-3. Selection of visualization drivers
# in compiling executables
setenv G4VIS_USE_DAWNFILE 1
setenv G4VIS_USE_OPENGLX 1
setenv G4VIS_USE_VRMLFILE 1
# setenv G4VIS_USE_DAWN 1
# setenv G4VIS_USE_OPACS 1
# setenv G4VIS_USE_OPENGLXM 1
# setenv G4VIS_USE_OPENINVENTOR 1
# setenv G4VIS_USE_RAYTRACER 1
# setenv G4VIS_USE_VRML 1

9b. Setting environmental variables (2)

The followings are templates for customizing the Geant4 DAWNFILE visualization driver.

############################################################
# Customization of the Geant4 DAWNFILE visualization driver
############################################################

###### 4. Customization of the DAWNFILE driver and renderer DAWN
# Note: For renderer DAWN, "dawn -H" displays all available
# environmental variables.

############ 4.1 On-line use of DAVID (a volume-overlapping debugger)
#
# setenv G4DAWNFILE_VIEWER david

############ 4.2 Off-line visualization
# with the batch mode of renderer DAWN
# 1: batch mode
# a: batch-append mode (multi-page g4.eps file)
#
# setenv DAWN_BATCH a

############ 4.3 Selection of a PostScript viewer
# in on-line and off-line visualization
# with renderer DAWN (The default is "gv")
#
# For on-line visualization:
# setenv G4DAWNFILE_PS_VIEWER gv
#
# For off-line visualization of a generated "g4_XX.prim" file
# with renderer DAWN:
# setenv DAWN_PS_PREVIEWER gv

############ 4.4 Making the multiple X-window mode default
# 0: PostScript file generation mode(default)
# 1: multiple X-windows mode
#
# setenv G4DAWNFILE_MULTI_WINDOW 0

############ 4.5 Output directory of "g4_XX.prim" and
# "g4_XX.eps" files
# Note 1: The default is the current directory.
# Note 2: Do not forget to append "/" at the end.
#
# setenv G4DAWNFILE_DEST_DIR /home/username/tmp/

############ 4.6 Automatic increment of output file names
# USAGE: setenv G4DAWNFILE_MAX_FILE_NUM n
# (n: a positive integer)
# DAWN-format files: g4_00.prim, g4_01.prim, g4_02.prim,
# c, g4_(n-1).prim
# EPS files : g4_00.eps , g4_01.eps , g4_02.eps,
# c, g4_(n-1).eps
# Note: The default value of n is 100.
#
# setenv G4DAWNFILE_MAX_FILE_NUM 100

####################################### END

Note: As for environmental variables to customize Fukui Renderer DAWN, see
the following page:
http://geant4.kek.jp/~tanaka/DAWN/DAWN_ENV.html

9c. Setting environmental variables (3)
(This section has not been completed yet.)

The followings are templates for customizing the Geant4 VRMLFILE visualization driver.

###### 5. Customization of the VRMLFILE driver

############ 5.1 On-line visualization of VRML files and
# selection a VRML viewer
#
# setenv G4VRMLFILE_VIEWER vrweb

10. Installation, compilation, and execution of Geant4
You can install Geant4 libraries, compile the official example placed under geant4/examples/novice/N03, and perform Geant4 visualization as follows:

Installation of Geant4 libraries:
% cd geant4/source
% gmake

Compilation of the official example:
% cd geant4/examples/novice/N03
% gmake

Execution of Geant4 visualization:
(Edit "prerunN03.mac" beforehand to choose a default visualization driver, if necessary.)
% ../../../bin/Linux-g++/exampleN03
Idle> /run/beamOn

Sample macros for visualization:
Macro files exN03VisX.mac (X = 0,1,2,c) are sample macro files for Geant4 visualization. Most of frequently-used visualization commands are described there. Please read and try to execute them. You can execute each macro file as follows:

% ../../../bin/Linux-g++/exampleN03
Idle> /control/execute exN03VisX.mac

@