How to Perform Geant4 Visualization
on Linux
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 compile Geant4 for visualization on Linux with the following setup: (1) CLHEP library version 1.4, 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 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, 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.4, 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:
3. Installation of CLHEP 1.4
You should obtain the CLHEP 1.4 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.4.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.4 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/".
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:
6. Installation of LessTif (a free Motif)
Installation of LessTif (a free Motif) is not mandatory for the setup mentioned in
“1.Introduction”. But you need it if you want to use the OpenGL-X-Motif visualization driver. For more details, 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 mentioned in
“1.Introduction”. But you need it if you want to use the OPACS visualization driver. For more details, 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 mentioned in
“1.Introduction”. But you need them if you want to use the OpenInventor visualization driver. For more details, see the following Web pages: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,
# …, g4_(n-1).prim
# EPS files : g4_00.eps , g4_01.eps , g4_02.eps,
# …, 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:
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
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,
% ../../../bin/Linux-g++/exampleN03
Idle> /control/execute exN03VisX.mac