Project

General

Profile

Building Geant4 and N02to using fnal ups products

Hints on how to build a version of geant4 (here 10.1.p02)
with Qt using fnal ups products (and bash shell)
(current as of October 2015)

Building Geant4


export PROJECT_DIR=.../geant
export GEANT4_RELEASE="10.1.p02" 
export GEANT4_RELEASE_NAME=geant4.${GEANT4_RELEASE}

export INSTALL_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}/install/${GEANT4_RELEASE_NAME}-qt-prof

export BUILD_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}-qt-prof-build
export SOURCE_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}

# move geant4 tree to its version area

mv -i geant4 ${GEANT4_RELEASE_NAME}

cd    ${PROJECT_DIR}
mkdir ${BUILD_DIR}
mkdir logs
mkdir -p ${INSTALL_DIR}

# doing an out of source build
cd    ${BUILD_DIR}

setup cmake v3_2_1

# clhep sets up gcc  
setup clhep v2_2_0_5 -q e7:prof
setup xerces_c v3_1_1d -q e7:prof
setup qt v5_4_2 -q e7
setup gdb v7_9

/usr/bin/time cmake \
-DGEANT4_USE_SYSTEM_CLHEP=1 \
-DCLHEP_ROOT_DIR=${CLHEP_BASE_DIR} \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_COMPILER="${GCC_FQ_DIR}/bin/gcc" \
-DCMAKE_CXX_COMPILER="${GCC_FQ_DIR}/bin/g++" \
-DGEANT4_BUILD_CXXSTD="c++1y" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g -fno-omit-frame-pointer -Winline" \
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -g -fno-omit-frame-pointer -Winline" \
-DGEANT4_INSTALL_DATA=1 \
-DGEANT4_USE_OPENGL_X11=1 \
-DGEANT4_BUILD_VERBOSE_CODE=1 \
-DGEANT4_USE_QT=1 \
-DGEANT4_USE_GDML=1 \
-DXERCESC_ROOT_DIR=${XERCESCROOT} \
$SOURCE_DIR &> ../logs/cmake_`date +%Y%m%d%H%M%S`.log &

# GEANT4_BUILD_VERBOSE_CODE=1 is the default

/usr/bin/time make -j4 VERBOSE=1 >& ../logs/make_`date +%Y%m%d%H%M%S`.log &
/usr/bin/time make install       >& ../logs/make_install_`date +%Y%m%d%H%M%S`.log &

Building the N02to example

in another session:

setup cmake v3_2_1

setup clhep v2_2_0_5 -q e7:prof
setup xerces_c v3_1_1d -q e7:prof
setup qt v5_4_2 -q e7
setup gdb v7_9

export PROJECT_DIR=.../geant
export GEANT4_RELEASE="10.1.p02" 
export GEANT4_RELEASE_NAME=geant4.${GEANT4_RELEASE}

export INSTALL_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}/install/${GEANT4_RELEASE_NAME}-qt-prof

export BUILD_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}-qt-prof-build
export SOURCE_DIR=${PROJECT_DIR}/${GEANT4_RELEASE_NAME}

export G4_VERSION_STR="Geant4-10.1.2" 

export G4LIB=${INSTALL_DIR}/share/${G4_VERSION_STR}

source ${INSTALL_DIR}/share/${G4_VERSION_STR}/geant4make/geant4make.sh

cd ...
mkdir N02-build-${GEANT4_RELEASE_NAME}
mkdir logs
cd    N02-build-${GEANT4_RELEASE_NAME}

# doing an out of source build

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGeant4_DIR=${G4LIB}/${G4_VERSION_STR} \
-DCMAKE_C_COMPILER="${GCC_FQ_DIR}/bin/gcc" \
-DCMAKE_CXX_COMPILER="${GCC_FQ_DIR}/bin/g++" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g -fno-omit-frame-pointer -Winline" \
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -g -fno-omit-frame-pointer -Winline" \
-DCMAKE_INSTALL_PREFIX=. \
../N02to >& ../logs/cmake_`date +%Y%m%d%H%M%S`.log &

/usr/bin/time make -j4 VERBOSE=1 >& ../logs/make_`date +%Y%m%d%H%M%S`.log &
/usr/bin/time make install       >& ../logs/make_install_`date +%Y%m%d%H%M%S`.log &

# it can be run like:

./exampleN02
./exampleN02 run1.mac