Tuesday, December 27, 2011

Geant4 on ubuntu

copied from:
http://conquer-ur-computer.blogspot.com/2011/02/how-to-install-geant4-in-ubuntu-linux.html



Geant4 is a toolkit for the simulation of the passage of particles through matter. Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science. The two main reference papers for Geant4 are published in Nuclear Instruments and Methods in Physics Research A 506 (2003) 250-303, and IEEE Transactions on Nuclear Science 53 No. 1 (2006) 270-278
In Ubuntu you need the following prerequisites... 

build-essential gfortran lesstif2-dev inventor-dev libxaw7-dev freeglut3-dev libxerces-c2-dev

to install them open terminal from Applications --> Accessories --> Terminal

and type in

sudo apt-get install build-essential gfortran lesstif2-dev inventor-dev libxaw7-dev freeglut3-dev libxerces-c2-dev 


 Now download the Geant4***.tar.gz file from  


Download the GNU or Linux tar format from the above page...

for example this...


also download the Clhep***.tar.gz file from 



For example this...


Keep both these files in home directory...

Now in the terminal type in

cd ~
tar -xzvf geant4*.tar.gz
cd geant4*
tar -xzvf ../clhep*.tgz
cd 2.1.*/CLHEP
./configure --prefix /home/user_name/geant4.9.4.p01/2.1.0.1/

Here user name should be the login name... ie; one should specify the total path to CLHEP folder...

now type in

make
make install
cd ../..
./Configure -build


Here are the options that one should select for a single machine installation...

Just hit enter for all default locations specified by the program, except for

CLHEP_BASE_DIR:        where       /home/user_name/geant4.9.4.p01/2.0.4.1/

  should be entered.

Enter "y" (without quotes) for all questions except for the questions on "multiple machines" and "static libraries"

One can refer the following file for details...

http://www.ziddu.com/download/13983033/geant_4_options.txt.html

This will end up with the following output...

##############################
######################
# Your Geant4 installation seems to be successful! 
# To be sure please have a look into the log file: 
# /home/user_name/geant4.9.4.p01/.config/bin/Linux-g++/g4make.log             
####################################################


Now type in 

./Configure -install
./Configure


which will end up in...


                --- Geant4 Toolkit Installation  ---
                  (setting environments for USER )

---------------------------------------------------
The Geant4 toolkit installation was found.
The files env.[c]sh will be copied to your current directory.
For setting Geant4 environments you should make:

source env.csh

or

. env.sh

It will also check G4WORKDIR setting and set it to
your HOME if needed.
You can use these files also for further modifications
(adding your own environments).
---------------------------------------------------


With this installation will be over...

To run an example create a folder where ever you like. Let us say name it as  "work" 

Now copy an example folder A01 from

geant4.9.4.p01/examples/extended/analysis/ to work folder

Now open terminal and enter

export G4WORKDIR=/path_to/Work
 export LD_LIBRARY_PATH=~/geant4.9.4.p01/2.1.0.1/lib/:$LD_LIBRARY_PATH
source ~/geant4.9.4/env.sh

These 3 steps should be done every time you start the program...

As we have copied A01 folder into work folder,

Now in terminal:


cd $G4WORKDIR/A01
make
$G4WORKDIR/bin/Linux-g++/A01app
Now you will see a window with title G4UI SESSION


where you can search for commands in the search box and implement them in the "session" box in the bottom.

for example if one implements the following in the bottom "session" box

/vis/open OGLI
/vis/drawVolume
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1

The final screen will look like below:
http://i52.tinypic.com/2hnmg4l.png

The whole installation will be around 730MB..
Cheers............


1 comment:

Z. Yong said...

there are still many problems after tried all kind of efforts. I give up the installation on Ubuntu. Switch to Mac and Cygwin