Set up GEANT4 and Root Development Environment On 64 bitsUbuntu 8.0.4 AMD 64 bits machine

This article will show you how to set up your Ubuntu machine for GEANT4 and ROOT development.

0.1) Install Ubuntu 8.0.4

Install Ubuntu 8.0.4 and complete basic setup such as networking.

0.2) Install Necessary Package

Install the following packages using “apt-get install” command.

  • libX11-dev
  • g++
  • libxft-dev
  • libxpm-dev
  • libxt-dev
  • freeglut3
  • freeglut3-dev
  • libglut3
  • libglut3-dev
  • libmotif3
  • libmotif-dev
  • x11proto-print-dev
  • libxaw7-dev
  • libmudflap0
  • libmudflap0-dev
  • po-debconf
  • intltool-debian
  • subversion
  • libusb-dev
  • libboost-dev
  • libmysql++-dev
  • autoconf
  • automake
  • libtool
  • libc6-dev-i386
  • graphviz and graphviz-dev for GraphViz software
  • libcxx
  • libxerces28
  • libxerces28-dev
  • cppunit-dev

1) Set up Root

Obtain the latest Root from http://root.cern.ch. I used Root version 5.18.

Unzip the Root package to the location of choice, say ~/mt-sys. After unzipping, there will be a “root” directory in ~/dev. We will come back in the later step to set up root configuration.

To build Root from source, download the source ball, unzip it, then change to the source directory

#cd ~/SetUpZip

#tar -zxvpf <root_src>.tar.gz

#cd <root_src>

#./configure
–-prefix=~/install/root –enable-mysql –enable-opengl –enable-python

# make

# make install

Notes on tar options used above

-z : unzip the file first

-x : extract the files from the tarball

-v : “verbose” (i.e tar tells you what files it’s extracting)

-p : preserves dates, permissions of the original files

-f : use the file in question (if you don’t specify this, tar just sort of sits around doing nothing)

Add the following lines to your ~/.bashrc file

CURCWD=`pwd`

cd ~/dev/root

source bin/thisroot.sh

cd $CURCWD

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ROOTSYS}/lib/root

export PATH=$ROOTSYS/bin:$PATH

2) Set up CLHEP

To build CLHEP, you need gcc-3.2.3 or higher.

Obtain CLHEP source package from http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/clhep.html.

I used version 2.0.3.1 ( http://proj-clhep.web.cern.ch/projclhep/DISTRIBUTION/distributions/clhep-2.0.3.1.tgz)

Save the tar ball in a directory of choice, say ~/install. Then unzip and then do configure, make, and make install in the unzipped directory. Note that by default, the CLHEP is installed in /usr/local. I set the installation path to /home/username/dev/CLHEP by doing “./configure –-prefix=/home/username/dev/CLHEP”.

cd ~/SetUpZip

tar -zxvpf clhep-<version>.tar

cd <version>/CLHEP

./configure –-prefix=/home/username/dev/CLHEP

make

make install

Add the following lines to /home/jessica/.bashrc file

export CLHEP_BASE_DIR=/home/username/dev/CLHEP

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CLHEP_BASE_DIR/lib

3) Set up Geant4

Obtain the source package from Geant4 site http://geant4.web.cern.ch/geant4/. I used Geant4.8.2.p01 (http://geant4.web.cern.ch/geant4/support/source/geant4.8.2.p01.tar.gz).

Unzip the tar ball to your directory of choice, say ~/geant4. Unzip and then change directory to ~/geant4/geant4.8.2.p01 to run the “Configure” script.

cd ~/SetUpZip

tar -zxvpf geant<version>.tar.gz

cd geant<version>

mkdir data

./Configure -build

Extra actions:

Add /home/jessica/SetUpZip/geant4.8.2.p01/data

Entered the CLHEP_BASE_DIR

CLHEP_BASE_DIR: /home/jessica/mt-sys/CLHEP

You will be asked a series of question and most of them can be answered with a default answer. The questions you need to answer carefully are the path to your CLHEP install (from step 2) .

OPTION NAME

VALUE

G4UI_NONE

NO

G4UI_BUILD_XAW

YES

G4UI_USE_XM

YES

G4UI_BUILD_QT

NO

G4VIS_NONE

NO

G4VIS_USE_OPENGLX

YES

G4VIS_USE_OPENGLXM

YES

G4VIS_USE_DAWN

NO

G4VIS_USE_OIX

NO

G4VIS_USE_RAYTRACERX

YES

G4VIS_USE_VRML

NO

G4VIS_BUILD_OPENGLQT

NO

G4LIB_BUILD_GDML

NO

G4LIB_BUILD_G3TOG4

NO

G4LIB_BUILD_ZLIB

YES

G4ANALYSIS_USE (NO)

NO

NOTE: Instead of libX11-devel, use libX11-dev.

Once geant4 has been installed, you need to create a script named “env.sh” to set the Geant4 environment variables. To create “env.sh” automatically:

cd ~/SetUpZip/geant4.8.2.p01

./Configure

cp: overwrite `./env.csh` (enter y)

cp: overwrite `./env.sh`

Two files will be created: “env.sh” and “env.csh”. Next step is to modify the .bashrc script so that this environment variables for CLHEP, Root, and Geant4 will all be set up correctly. I added the following line to ~/.bashrc:

source ~/SetUpZip/geant4.8.2.p01/env.sh

export G4WORKDIR=~/g4work

Log out and log back in to your account, then a slew of log messages from running “env.sh” should be printed to the screen.

4) Install MySQL Databaser Server

sudo apt-get install mysql-server

Optionally, for remote access, install PHPMYADMIN, a web-based MySQL query browser, as followed:

sudo apt-get install apache2

sudo apt-get install php5 libapache2-mod-php5

sudo apt-get install phpmyadmin

The phpmyadmin is installed under /var/www, and we need to set phpmyadmin as the default document root in Apache2. To do so

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/phpmyadmin

sudo vi /etc/apache2/sites-available/phpmyadmin

Then search for “DocumentRoot” in “/etc/apache2/sites/available/phpmyadmin”, when found, change those two lines to be consistent with the phpmyadmin site path.

Original:

DocumentRoot /var/www

<Directory /var/www/>

Changed to:

DocumentRoot /usr/share/phpmyadmin

Ser…

<Directory /usr/share/phpmyadmin/>

Then disable default site and enable phpmyadmin site as followed:

sudo a2dissite default

sudo a2ensite phpmyadmin

sudo /etc/init.d/apache2 restart

Now you should be able to browse phpmyadmin site by opening http://<ip-of-this-server>.

Also, to have Apache2 recognize a host name, instead of just IP,

sudo vi /etc/apache2/apache2.conf

Then add the following line at the top of apache2.conf.

ServerName server-name

Restart Apache2 HTTP server

sudo /etc/init.d/apache2 restart

Now you should be able to browse phpmyadmin site by opening http://server-name.

To enabled remote access to the MySQL Database server, read this nixCraft page.

But the essence is to add a line to my.cnf (in Ubuntu, /etc/mysql/my.cnf), and make sure “skip-networking” line is commented out.

#skip-networking

ServerName server-name or IP

Also, to set the firewall so the server can accept remote connections, follow this Ubuntu doc.

5) Install VTKViewer (Optional)

First we need to install VTK (The Visualization Toolkit) from source.

Install cmake if not already installed:

sudo apt-get install cmake

Go to VTK site (http://www.vtk.org/index.php) and download

  • VTK source tar ball, vtk-<version>.tar.gz
  • VTK data tar ball, vtkdata-<version>.tar.gz
  • VTK MPeg encoder, vtkmpeg2encode.tar.gz

Extract the all three tar ball:

cd ~/SetUpZip

tar xvf vtk-<version>.tar.gz

tar xvf vtkdata-<version>.tar.gz

tar xvf vtkmpeg2encode.tar.gz

cd ~/mt-sys

First build and install vtkmpeg2encode. NOTE: Please build vtkmpeg2encode BEFORE building VTK, so that the VTK’s configure script can detect vtkmpeg2encode, which is required for a successful VTK source build.

cd vtkmpeg2encode

ccmake .

You would see the selection as followed:

CMAKE_BACKWARDS_COMPATIBILITY 2.4

Leave it unchanged and enter [c] to configure. Then you would see:

CMAKE_BUILD_TYPE *

CMAKE_INSTAL_PREFIX */usr/local

EXECUTABLE_OUTPUT_PATH /home/jessica/mt-sys/vtk/bin

LIBRARY_OUTPUT_PATH /home/jessica/mt-sys/vtk/lib

CMAKE_BACKWARDS_COMPATIBILITY 2.4

Toggle ‘t’ to turn on the Advanced mode and add “-fPIC” at both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS flags

CMAKE_CXX_FLAGS -fPIC

CMAKE_C_FLAGS -fPIC

Then press ‘c’ to configure, and ‘g’ to generate make file. After makefile is generated, make vtkmpeg2encode.

Make

To build Visual Tool Kit SDK from source,

cd ~/SetUpZip

cd VTK

ccmake .

BUILD_EXAMPLES ON

BUILD_SHARED_LIBS ON

vtkMPEG2Encode_INCLUDE_PATH /home/jessica/SetUpZip/vtkmpeg2encode

vtkMPEG2Encode_LIBRARIES /home/jessica/SetUpZip/vtkmpeg2encode/libvtkMPEG2Encode.a

Press [c] to configure and [g] to generate makefile.

make

Press ‘g’ to generate and exit. Then “make” to compile. I’ve added a VOXViewer folder under VTK/Examples, modified VTK/Examples/CMakeLists.txt to include VOXViewer in the build. Therefore, when the build completes, there should be a “voxview” binary in VTK/bin. The voxview needs to read from a vox file, which is located in VTK/Examples/VOXViewer. To run voxviewer and read from a vox file:

#bin/voxview Examples/VOXViewer/mutom_vansim_Wobj_medreg_1m.vox

cd ${TRUNK}/vtkviewer

ccmake .

Move blinking box to the VTK_DIR line, then hit enter. Enter the path to the VTK directory. Then hit enter, and click ‘g’ to regenerate the build script.

make

7) Set up Python Development Environment

The list of python modules to install (use apt-get)

  • python2.5
  • python2.5-dev
  • python-glade2
  • python-gtk2
  • python-gtkmvc
  • python-imaging
  • python-mysqldb
  • python-paramiko
  • python-reportlab
  • python-vtk
  • python-vte

I am using Netbean6.5 and for most of my back-end python development and Glade Interface Designer for front-end development. I also like IDLE because it provides python session and can easily indent and dedent but occasionally it crashes.

5 thoughts on “Set up GEANT4 and Root Development Environment On 64 bitsUbuntu 8.0.4 AMD 64 bits machine”

  1. Do you know how to build and install geant4.10.02 in ubuntu 16.04? Could you give me a hand, namely with build and install of geant4py?! Thanks!

    • I have not tried that myself but I could give it a try when time allows. Were you having problem using the instruction on this post?

Leave a Comment