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