Geant4 Usage at CERN

Location of Releases

At CERN, Geant4 installations are located in the CVMFS directories of the Geant4 project under:

/cvmfs/geant4.cern.ch/geant4/

We provide libraries and source code for releases and patch releases. Reference versions are also available without support and without full source code. For release 11.1 and centos9 compiled using gcc-12 we have two versions:

/cvmfs/geant4.cern.ch/geant4/11.1/x86_64-centos9-gcc12-optdeb
/cvmfs/geant4.cern.ch/geant4/11.1/x86_64-centos9-gcc12-optdeb-MT

And similarly named directories for centos8, and/or other compiler versions. We currently build versions for sequential and multithreading, as marked by the extension -MT, code is optimised, yet debug information is kept. Users have to choose the correct OS and use a compatible compiler to compile user code. For each architecture the are setup scripts for use with either CMake or GNUmake, CMake-setup or GNUmake-setup. These scripts set all required environment variables used to run an application based on libraries provided, including those for required datasets.

Geant4 data sets are available from:

/cvmfs/geant4.cern.ch/share/data

Scripts to Set-up Environment

In each version available, there are scripts to set up the environment to use. For example, to use Geant4 release 11.1; based on on centos9 and gcc-12, you can use the following commands depending on the shell you use:

For sh or bash:

source /cvmfs/sft.cern.ch/lcg/contrib/gcc/12/x86_64-centos9/setup.sh #set up compiler
source /cvmfs/geant4.cern.ch/geant4/11.1/x86_64-centos9-gcc12-optdeb-MT/CMake-setup.sh #set up environment for Geant4
export CXX=`which g++` #tell CMake about compiler used
export CC=`which gcc`

For csh or tcsh:

source /cvmfs/sft.cern.ch/lcg/contrib/gcc/12/x86_64-centos9/setup.csh #set up compiler
source /cvmfs/geant4.cern.ch/geant4/11.1/x86_64-centos9-gcc12-optdeb-MT/CMake-setup.csh #set up environment for Geant4
setenv CXX `which g++` #tell CMake about compiler used
setenv CC `which gcc`

Examples

Geant4 examples are available as source code in the directories under:

/cvmfs/geant4.cern.ch/geant4/G4VERSION/ARCHITECTURE/share/examples

where G4VERSION and ARCHITECTURE stand for the Geant4 version you want to use and for the OS/compiler version. Each example has a README file with specific details and options. To build and execute one of the examples, for example basic B1, set the environment using the recipe above, and then copy the example, compile and execute:

cp -R /cvmfs/geant4.cern.ch/geant4/11.1/share/examples/basic/B1 $HOME # copy example
mkdir $HOME/B1_build # create directory to compile
cd $HOME/B1_build
cmake -DCMAKE_PREFIX_PATH=/cvmfs/geant4.cern.ch/geant4/11.1/x86_64-centos9-gcc12-optdeb-MT $HOME/B1 # create MakeFiles
make # compile/build using make
./exampleB1 exampleB1.in # run the example, using exampleB1.in as input file