Geant4 Cross Reference |
1 # Prerequisites 2 Opticks requires Geant4 (10.7.p02), nvidia cuda (11.3) and nvidia Optix (6.5) among other libraries. CaTS in addition will require ROOT. If all these libraries and development headers are available on your machine skip directly to (**Building opticks vs. existing libraries**). On a 'blank' computing system it makes sense to build CLHEP, then Geant4 and finally ROOT assuring that all the necessary development libraries and headers are installed. 3 4 # Building CLHEP 5 The current version of Geant4 10.07.p02 is build on clhep 2.4.4.0. 6 CLHEP can be found at: 7 https://proj-clhep.web.cern.ch/proj-clhep/clhep23.html 8 9 to build it from scratch using cmake (used cmake version 3.20.5) 10 11 cd to the directory where you want to build clhep 12 wget https://proj-clhep.web.cern.ch/proj-clhep/dist1/clhep-2.4.4.0.tgz 13 tar xzvf clhep-2.4.4.0.tgz 14 cd 2.4.4.0/ 15 mkdir CLHEP-build 16 cd CLHEP-build 17 cmake -DCMAKE_INSTALL_PREFIX=../CLHEP-install DCLHEP_BUILD_CXXSTD=-std=c++11 ../CLHEP 18 make -j 8 19 make install 20 21 **Note** the default install directory is /usr/local but one needs root privileges to install it there: 22 23 cd to the directory where you want to build clhep 24 wget https://proj-clhep.web.cern.ch/proj-clhep/dist1/clhep-2.4.4.0.tgz 25 tar xzvf clhep-2.4.4.0.tgz 26 cd 2.4.4.0/ 27 mkdir CLHEP-build 28 cd CLHEP-build 29 cmake -DCLHEP_BUILD_CXXSTD=-std=c++11 ../CLHEP 30 make -j 8 31 sudo make install 32 33 # Building Geant4 34 35 Geant4 versions are available at: 36 https://geant4.web.cern.ch/support/download 37 38 39 cd to the directory where you want to install Geant4 40 wget https://geant4-data.web.cern.ch/releases/geant4.10.07.p02.tar.gz 41 mkdir geant4.10.07.p02-build 42 cd geant4.10.07.p02-build 43 cmake -DCMAKE_INSTALL_PREFIX=../geant4.10.07.p02-install -DGEANT4_BUILD_VERBOSE_CODE=OFF -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_SYSTEM_CLHEP=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_SYSTEM_EXPAT=ON -DGEANT4_USE_SYSTEM_ZLIB=ON -DGEANT4_USE_QT=ON -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_OPENGL_X11=ON ../geant4.10.07.p02 44 make -j 8 45 make install 46 . ../geant4.10.07.p02-install/bin/geant4.sh 47 48 49 check the output for any error, install any development packages that might be necessary. 50 51 52 53 54 # Building ROOT 55 Instructions how to build ROOT from ssource can be found at: 56 https://root.cern/install/build_from_source/ 57 58 # cd to the diretory where you want to install root 59 git clone --branch latest-stable https://github.com/root-project/root.git root_src 60 mkdir root-build 61 cd root-build 62 cmake -DCMAKE_INSTALL_PREFIX=../root-install ../root 63 # speed up the make process 64 new=" -j$(($(grep -c ^processor /proc/cpuinfo) - 1))" 65 case ":${MAKEFLAGS:=$new}:" in 66 *:"$new":*) ;; 67 *) MAKEFLAGS="$MAKEFLAGS:$new" ;; 68 esac 69 cmake -DCMAKE_INSTALL_PREFIX=../root-install ../root_src/ 70 cmake --build . --target install 71 72 check the output for any error, install any development packages that might be necessary. 73 74 75 . ../root-install/bin/thisroot.sh 76 root 77 78 79 # Installing CUDA 80 81 cuda (11.3) is available at the NVIDIA web site just follow the instruction depending on the system you are using. 82 83 https://developer.nvidia.com/cuda-downloads 84 85 **Note** this will also install the corresponding NVIDIA graphics driver you might have to reboot. 86 87 Another way to obtain cuda is to install the NVIDIA hpc-sdk kit. Which can be found here. 88 https://developer.nvidia.com/nvidia-hpc-sdk-downloads 89 90 The NVIDIA hpc-sdk kit provides an interesting set of tools e.g. nvc++ which allows offloading of parallel algorithms to NVIDIA GPUs. 91 92 A good way to check that things are working properly is to build the cuda samples and execute them 93 94 # cd to the directory where you want to build the cuda samples. E.g. the commands deviceQueryDrv and deviceQuery provide useful information. 95 mkdir cuda-test 96 cd cuda-test 97 cp -r /usr/local/cuda-11.3/samples . 98 cd samples/ 99 which nvcc 100 make 101 bin/x86_64/linux/release/deviceQuery 102 bin/x86_64/linux/release/deviceQueryDrv 103 104 2 Tools For Monitoring Nvidia GPUs On Linux can be found here: 105 https://www.linuxuprising.com/2019/06/2-tools-for-monitoring-nvidia-gpus-on.html 106 107 # Installing Optix (6.5) 108 109 https://developer.nvidia.com/designworks/optix/download 110 111 Optix comes with precompiled samples and one might want to try them: 112 113 # cd to the Optix installation directory 114 cd SDK-precompiled-samples 115 export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH 116 # execute e.g.: 117 ./optixMDLSphere 118 ./optixSphere 119 ./optixTutorial 120 # etc. 121 122 123 124 125 126 # Building opticks vs. existing libraries 127 128 This are instructions how to build opticks making use of preinstalled libraries available on the system. These libraries include CLHEP, xerces-c, boost and Geant4. 129 For geant 4 we use the current version at the time of writing which is Geant4.10.7.p2. We make use of the fact that the om-cmake function of om.bash is sensitive 130 to CMAKE_PREFIX_PATH envvar so that we can point to the directories where the libraries are installed and void having to rebuild them. In principle just cut and paste the following line to a file change the envars of the different directories to match your system and source the resulting script. 131 132 cd to the directory where you want to install Opticks (the WORK_DIR environmental variable will point to this directory). 133 134 135 Here we are using a tagged snapshot of Opticks which can be found in github: 136 137 git clone https://github.com/simoncblyth/opticks.git 138 cd opticks 139 git checkout tags/v0.1.6 -b v0.1.6-branch 140 git status 141 142 The development version (a. k. a. the latest and greatest) can be found in the following repository 143 144 git clone https://bitbucket.org/simoncblyth/opticks.git 145 146 147 148 change opticks/optickscore/OpticksSwitches.h 149 150 so that: 151 152 #define WITH_SKIPAHEAD 1 153 154 is set. 155 156 cat > setup_opticks.sh << +EOF 157 # ---------------------------------------------------------------------------------------------------------------------- 158 # --- you need to modify the following environmental variables so that point to the specific directories on your system 159 # --- 160 export WORK_DIR=/data2/wenzel/gputest_10.7.p02 161 export OptiX_INSTALL_DIR=/home/wenzel/NVIDIA-OptiX-SDK-6.5.0-linux64 162 export OPTICKS_COMPUTE_CAPABILITY=75 163 export CUDA_INSTALL_DIR=/usr/local/cuda-11.3 164 export CUDA_SAMPLES=${CUDA_INSTALL_DIR}/samples 165 export G4INSTALL=/data2/wenzel/Geant4.10.07.p02_install 166 . ${G4INSTALL}/bin/Geant4.sh 167 export ROOTSYS=/data2/wenzel/root_install 168 . ${ROOTSYS}/bin/thisroot.sh 169 # ---------------------------------------------------------------------------------------------------------------------- 170 export LOCAL_BASE=${WORK_DIR}/local 171 export CMAKE_PREFIX_PATH=${G4INSTALL}:${LOCAL_BASE}/opticks/externals:${OptiX_INSTALL_DIR}:${WORK_DIR}/opticks/cmake/Modules/:${WORK_DIR}/local/opticks:${WORK_DIR}/local/opticks:${WORK_DIR}/local/opticks/externals/ 172 export PYTHONPATH=$WORK_DIR 173 export OPTICKS_HOME=${WORK_DIR}/opticks 174 export PATH=${LOCAL_BASE}/bin:${PATH} 175 export OPTICKS_PREFIX=${WORK_DIR}/local/opticks 176 export OPTICKS_INSTALL_PREFIX=$LOCAL_BASE/opticks 177 export OPTICKS_OPTIX_PREFIX=${OptiX_INSTALL_DIR} 178 export OPTICKS_CUDA_PREFIX=${CUDA_INSTALL_DIR} 179 export OPTICKS_EMBEDDED_COMMANDLINE_EXTRA="--rngmax 10 --rtx 1 --skipaheadstep 10000" 180 opticks-(){ . ${OPTICKS_HOME}/opticks.bash && opticks-env $* ; } 181 op(){ op.sh $* ; } 182 o(){ cd $(opticks-home) ; hg st ; } 183 # make sure to add the compiler options 184 new=" -fPIC" 185 case ":${CXXFLAGS:=$new}:" in 186 *:"$new":*) ;; 187 *) CXXFLAGS="$CXXFLAGS:$new" ;; 188 esac 189 new=" -fPIC" 190 case ":${CFLAGS:=$new}:" in 191 *:"$new":*) ;; 192 *) CFLAGS="$CFLAGS:$new" ;; 193 esac 194 # speed up the make process 195 new=" -j$(($(grep -c ^processor /proc/cpuinfo) - 1))" 196 case ":${MAKEFLAGS:=$new}:" in 197 *:"$new":*) ;; 198 *) MAKEFLAGS="$MAKEFLAGS:$new" ;; 199 esac 200 # deal with the $LD_LIBRARYPATH 201 new=${OptiX_INSTALL_DIR}/lib64/ 202 case ":${LD_LIBRARY_PATH:=$new}:" in 203 *:"$new":*) ;; 204 *) LD_LIBRARY_PATH="$new:$LD_LIBRARY_PATH" ;; 205 esac 206 new=${OPTICKS_HOME}/externals/lib 207 case ":${LD_LIBRARY_PATH:=$new}:" in 208 *:"$new":*) ;; 209 *) LD_LIBRARY_PATH="$new:$LD_LIBRARY_PATH" ;; 210 esac 211 new=${CUDA_INSTALL_DIR}/lib64/ 212 case ":${LD_LIBRARY_PATH:=$new}:" in 213 *:"$new":*) ;; 214 *) LD_LIBRARY_PATH="$new:$LD_LIBRARY_PATH" ;; 215 esac 216 new=${LOCAL_BASE}/opticks/lib/ 217 case ":${LD_LIBRARY_PATH:=$new}:" in 218 *:"$new":*) ;; 219 *) LD_LIBRARY_PATH="$new:$LD_LIBRARY_PATH" ;; 220 esac 221 opticks- 222 new=${CUDA_INSTALL_DIR}/bin 223 case ":${PATH:=$new}:" in 224 *:"$new":*) ;; 225 *) PATH="$new:$PATH" ;; 226 esac 227 new=${OPTICKS_HOME}/bin/ 228 case ":${PATH:=$new}:" in 229 *:"$new":*) ;; 230 *) PATH="$new:$PATH" ;; 231 esac 232 new=${OPTICKS_HOME}/ana/ 233 case ":${PATH:=$new}:" in 234 *:"$new":*) ;; 235 *) PATH="$new:$PATH" ;; 236 esac 237 new=${LOCAL_BASE}/opticks/lib/ 238 case ":${PATH:=$new}:" in 239 *:"$new":*) ;; 240 *) PATH="$new:$PATH" ;; 241 esac 242 new=${CUDA_SAMPLES}/bin/x86_64/linux/release/ 243 case ":${PATH:=$new}:" in 244 *:"$new":*) ;; 245 *) PATH="$new:$PATH" ;; 246 esac 247 oinfo-(){ 248 echo 'LD_LIBRARY_PATH:'; 249 echo '================'; 250 echo ${LD_LIBRARY_PATH}| tr : \\n; 251 echo; 252 echo 'PATH:'; 253 echo '====='; 254 echo ${PATH}| tr : \\n; 255 echo; 256 echo 'CMAKE_PREFIX_PATH:'; 257 echo '=================='; 258 echo ${CMAKE_PREFIX_PATH}| tr : \\n; 259 } 260 dinfo-(){ 261 nvidia-smi; 262 ${CUDA_SAMPLES}/bin/x86_64/linux/release/deviceQuery 263 } 264 +EOF 265 266 source setup_opticks.sh 267 oinfo- 268 dinfo- 269 mkdir -p ${WORK_DIR}/local/opticks/externals/ 270 cd ${WORK_DIR}/local/opticks/externals/ 271 ln -s ${OptiX_INSTALL_DIR} OptiX 272 cd ${WORK_DIR} 273 opticks-externals-install >& install_ext.log & 274 275 scan the log file or any errors and correct them. 276 277 cd ${WORK_DIR} 278 opticks-full >& install_full.log & 279 280 scan the log file or any errors and correct them. Before you run opticks-t you want to to create the geocache using e.g. one of the gdml files provided by CaTS 281 (https://github.com/hanswenzel/CaTS) 282 283 geocache- 284 geocache-create- --gdmlpath ${WORK_DIR}/local/opticks/opticksdata/export/juno1808/g4_00.gdml 285 export OPTICKS_KEY=`output from above command" 286 opticks-t 287 288 if the geocache-create- command doesn't work: 289 290 291 ${WORK_DIR}/local/opticks/lib/OKX4Test --okx4test --g4codegen --deletegeocache --gdmlpath ${WORK_DIR}/CaTS/gdml/simpleLArTPC.gdml 292 export OPTICKS_KEY=`output from above command" 293 opticks-t 294 295 296 297 # Building CaTS 298 299 Instructions for building and running CaTS can be found here: 300 301 https://github.com/hanswenzel/CaTS/blob/master/README.md