Search This Blog

Thursday, December 26, 2013

Tips for installing Geant4.10.00

Hello Friends,

1. Introduction

You must have already had a look at the Geant4-Installation-Guide  -

       1.   http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/fo/BookInstalGuide.pdf

 on Geant4 webpage -

       2.   http://geant4.web.cern.ch/geant4/

While installing on my system, sure enough I realized that I need more help with my installation to overcome some of the problems faced. Therefore I am creating this help-page for my own future reference and also to help people with similar platform installing for the first time.

NOTE: This help-page is NOT self-sufficient and just a supplementary to the above Installation-Guide document.

2. Specifications of my OS/Machine

  1. MacBook pro 13" (mid-2009): 2.26 GHz Intel Core 2 Duo,    Ram 4 GB, DDR3, 1067 MHz
  2. OS X: 10.9.1 (13B42)  Mavericks
  3. Command line terminal: Bashrc 
 3. Basic necessary Pre-installations
(IMPORTANT FOR GEANT4 INSTALLATION)

  • Xcode and command line tools : 
    1. From the installation disk/CD or
    2. Apple App-store or
    3. Macports webpage - http://www.macports.org/install.php
    4. If you have already installed Xcode but not the command line tools, install it by running following command from a terminal => xcode-select --install
  • XQuartz/X11 : 
    1. From the installation disk/CD or
    2. Apple App-store
  • Cmake -GUI (Optional): This provides a GUI to build and install the Geant4 source code. Basically for the steps mentioned in Chapter 2 of the Geant4-Installation-Guide.
  • Macports (Darwin ports) : Obtain a .dmg file from - http://www.macports.org/install.php.  Using Mac ports install the following ports from command line terminal (e.g. sudo port install packagename) -
    1. Qt4-mac
    2. Cmake
    3. Clang
    4. Xercesc
    5. Openmotif
    6. Boost
4. Installation of Geant4

  • Under a general name Geant4-all, create 3 different directories.
    1. Geant4-all/Geant4_10_00 (This contains Source code)
    2. Geant4-all/Geant4_10_00-Build (This will contain build, unix executable makefiles)
    3. Geant4-all/Geant4_10_00-Install (This will contain the installation files - bin, lib, share etc.)
  • Along with these folders also create a text file named as mySettings.cmake (i.e. at location Geant4-all/mySettings.cmake) containing following lines
set(CMAKE_INSTALL_PREFIX /Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install CACHE STRING "")
set(CMAKE_INSTALL_BINDIR /Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/bin CACHE STRING "")
set(CMAKE_INSTALL_INCLUDEDIR /Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/include CACHE STRING "")
set(CMAKE_INSTALL_LIBDIR /Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/lib CACHE STRING "")
set(CMAKE_INSTALL_DATAROOTDIR /Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/share CACHE STRING "")
set(MOTIF_INCLUDE_DIR /opt/local/include CACHE STRING "")
set(MOTIF_LIBRARIES /opt/local/lib/libXm.dylib CACHE STRING "")
set(OPENGL_X11_INCLUDE_DIR /opt/X11/include/GL CACHE STRING "")
set(OPENGL_X11_gl_LIBRARY /opt/X11/lib/libGL.dylib CACHE STRING "")
set(OPENGL_X11_glu_LIBRARY /opt/X11/lib/libGLU.dylib CACHE STRING "")
set(GEANT4_USE_XM ON CACHE BOOL "")
set(GEANT4_USE_OPENGL_X11 ON CACHE BOOL "")
set(GEANT4_USE_RAYTRACER_X11 ON CACHE BOOL "")
set(GEANT4_INSTALL_DATA ON CACHE BOOL "")
set(GEANT4_USE_GDML ON CACHE BOOL "")
set(GEANT4_USE_QT ON CACHE BOOL "")
set(GEANT4_USE_USOLIDS ON CACHE BOOL "")
set(GEANT4_BUILD_EXAMPLES OFF CACHE BOOL "")
  • Save and close this file.
  • From terminal goto the Build directory
cd  Geant4-all/Geant4_10_00-Build
  • and run cmake command as below. This will create the Unix executable files for installation.
cmake -C /Users/jaydeep/activity/GEANT4-all/mySettings.cmake /Users/jaydeep/activity/GEANT4-all/Geant4_10_00
  • then run-   make -j1 VERBOSE=1
  • then run-   make install
  • This should install the Geant4 with the above specified options without error. 
  • You can also perform above steps using a graphical user interface for Cmake i.e. Cmake -GUI, if you have it installed.                     
====================================================================
***** NOTE the variable declared ***** 
  • Cmake vaiables
    • INSTALL variables (are explicitly declared to avoid mess with other system packages):
      1. CMAKE_INSTALL_PREFIX=/Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install 
      2. CMAKE_INSTALL_BINDIR=/Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/bin
      3. CMAKE_INSTALL_INCLUDEDIR=/Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/include
      4. CMAKE_INSTALL_LIBDIR=/Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/lib
      5. CMAKE_INSTALL_DATAROOTDIR=/Users/jaydeep/activity/GEANT4-all/Geant4_10_00-Install/share
    • FOR Motif (these variables declared because usual Geant4 installation failed to locate the files. Find the correct location on your system and replace it below):
      1. MOTIF_INCLUDE_DIR=/opt/local/include (contains - /Xm/Xm.h)
      2. MOTIF_LIBRARIES=/opt/local/lib/libXm.dylib
    • FOR OpenGL (these variables declared because usual Geant4 installation failed to locate the files. Find the correct location on your system and replace it below):
      1. OPENGL_X11_INCLUDE_DIR=/opt/X11/include/GL (contains gl.h)
      2. OPENGL_X11_gl_LIBRARY=/opt/X11/lib/libGL.dylib
      3. OPENGL_X11_glu_LIBRARY=/opt/X11/lib/libGLU.dylib
  • Geant4 variables
    1. GEANT4_USE_XM=ON
    2. GEANT4_USE_OPENGL_X11=ON
    3. GEANT4_USE_RAYTRACER_X11=ON
    4. GEANT4_INSTALL_DATA=ON 
    5. GEANT4_USE_GDML=ON
    6. GEANT4_USE_QT=ON
    7. GEANT4_USE_USOLIDS=ON
    8. GEANT4_BUILD_EXAMPLES=OFF
  • Done! See Chapter 3 of the Geant4-Installation-Guide for further procedure.

These variables are declared because the 'cmake' command without these variables failed to find - (1) OpenGL dir and lib (2) Motif dir and lib, which are necessary for GEANT4_USE_XM=ON and GEANT4_USE_OPENGL_X11=ON.
 ====================================================================



5.  Setting up the environment

Once the installation is done successfully, we can go ahead to run a basic test example. But before that we need to initialise Geant4 environment.

Purely for a personal choice of having an uncluttered, clean and tidy environment for Geant4 work projects, I created another folder under Geant4-All called G4-WorkDIR.
Then my geant4 parent directory Geant4-All looks like this - 

> cd Geant4-All
> ls
G4-WorkDIR/
Geant4_10_00/
Geant4_10_00-Build/
Geant4_10_00-Install/
mySettings.cmake


**** THIS SECTION IS INCOMPLETE......