Setting up Geant4 Virtual Monte Carlo (VMC) on Snow Leopard

Using ROOT’s Virtual Monte-Carlo (VMC) interface allows a high energy physics simulation to be built (almost) independently of the transport package used. One can write a single simulation and alter which Monte-Carlo transport package (Geant3, Geant4, FLUKA) is utilized in the simulation by altering a single line of code. This allows one to test a simulation’s results against other transport packages in a hassle-free and dependable manner. I first adopted this approach while at CERN, working on a simulation intended to verify Geant3’s treatment of delta-rays and found anomalous behaviour. A quick change to the Geant4 transport package resulted in correct behaviour, leaving me to wonder just how this might affect ALICE’s inner tracking system (More on that later). After getting ROOT, geant3, FLUKA, geant4 and the relevant VMC packages to compile and run nicely on Scientific Linux and Ubuntu, I decided to have another go at setting up the VMC environment in MacOS 10.6 (Snow Leopard) on my home machine. Snow Leopard is a genuine 64-bit operating system (uname -m reports x86_64, system type is macosx64) so one might expect some troubles in the compilation process. Fortunately the process was relatively simple in the end. One must install the developer tools (or XCode) that come with the Snow Leopard install DVD, as well as gfortran.
The order in which packages should be compiled is (with tested version numbers): pythia6(6416), CLHEP(2.0.4.3), Geant4(4.9.2-02), ROOT(5.25-02), the Virtual Geometry Model (svn revision 659) and finally Geant321(1.1.1) and Geant4 VMC(svn revision 416). Pythia6 compiles easily using the makePythia6.macosx64 script included. Geant4 requires the OpenGL visualizations and g3to34 modules to be built, shared libraries and a copy of header files to be installed to the include folder. This can all be specified by running the included Config script. ROOT’s configure required the following arguments to build nicely:
--enable-g4root --with-g4-incdir=$G4INSTALL/include \
--with-g4-libdir=${G4INSTALL}/lib/${platform} \
--with-clhep-incdir=${CLHEP_BASE_DIR}/include\
--disable-xrootd --with-f77=gfortran\
--with-pythia6-libdir=$ALICE/pythia6
This assumes you have declared a number of environmental variables. Here is the section of .bashrc with my definitions (works for linux or darwin):
# .bashrc
if [ "$(uname)" = 'Linux' ]; then
platform-compiler=linux-g++
platform=Linux
elif [ "$(uname)" = 'Darwin' ]; then
platform-compiler=darwin-g++
platform=Darwin
fi
# ROOT
export ROOTSYS=$ALICE/root
export PATH=$PATH:$ROOTSYS/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
export ALICE_TARGET=`root-config --arch`
#pythia
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ALICE/pythia6
#VGM
export VGM_INSTALL=$ALICE/vgm
export VGM_SYSTEM=$platform
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$VGM_INSTALL/lib/$VGM_SYSTEM
export USE_VGM=1
# GEANT 3
export PLATFORM=`root-config --arch`
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ALICE/geant3/lib/tgt_${ALICE_TARGET}
# Geant4
export CLHEP_BASE_DIR=$ALICE/CLHEP
export G4INSTALL=$ALICE/geant4.9.2.p02
export G4SYSTEM=$platform-compiler
export G4VMC=$ALICE/geant4_vmc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ALICE/CLHEP/lib
The only other tricky thing is that enabling g4root via configure results in the include files (found in montecarlo/g4root/inc) not being copied to ROOT’s include directory. Simply copy these files over manually before compiling the Geant4 VMC and the problem is solved!