系统Ubuntu 12.04 32位版,gcc 4.6,Geant 4.9.5p1,CLHEP
2.1.2.2
参考
Installing Geant4 Release 4.9.4.p02 on Linux
http://geant4.slac.stanford.edu/tutorial/installation/Geant4.9.4.p02/Linux/Geant4_9_4_p02_Linux_Installation.htm#_What_are_the
准备编译环境:
sudo apt-get install build-essential cmake
cmake版本2.8.7
1)安装CLHEP
由于新版CLHEP采用cmake方式编译,原教程不适用,参考cmake/INSTALL安装方法如下:
mkdir ~/build
cd ~/build
cmake /home/tyllr/CLHEP/2.1.2.2/CLHEP
make
make test
sudo make install
在/usr/local/lib下得到编译好的多个库,成功!
2)安装Geant4
添加低能电磁作用数据包,data files for low
energyelectromagnetic processes
解压到Geant4目录新建的 data 文件夹下。
tyllr@tyllr-MXC061:~/geant4_9_5_p01$ mkdir ~/geant4build
tyllr@tyllr-MXC061:~/geant4_9_5_p01$ cd ~/geant4build/
tyllr@tyllr-MXC061:~/geant4build$ cmake ../geant4_9_5_p01
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- setting default compiler flags for CXX
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Could NOT find EXPAT (missing: EXPAT_LIBRARY
EXPAT_INCLUDE_DIR)
-- The following Geant4 features are enabled:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tyllr/geant4build
找不到 EXPAT,尝试:
sudo apt-get install libexpat-dev
cmake ../geant4_9_5_p01
结果如下:
-- setting default compiler flags for CXX
-- Found EXPAT: /usr/lib/i386-linux-gnu/libexpat.so
-- The following Geant4 features are enabled:
GEANT4_USE_SYSTEM_EXPAT: Using system install of EXPAT
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tyllr/geant4build
tyllr@tyllr-MXC061:~/geant4build$ make
-j2
我是core 2
duo的cpu,所以用双核选项。编译很漫长,喝杯咖啡慢慢等。。。
完成后 sudo make
install,结束安装。
3)测试例子
mkdir ~/g4examplebuild
cd ~/g4examplebuild
cmake ../geant4_9_5_p01/examples/novice
make
运行可执行文件:
tyllr@tyllr-MXC061:~/g4examplebuild$ cd N01
tyllr@tyllr-MXC061:~/g4examplebuild/N01$ ./exampleN01
*************************************************************
Geant4 version Name:
geant4-09-05-patch-01 (20-March-2012)
Copyright : Geant4 Collaboration
Reference : NIM A 506 (2003), 250-303
WWW : http://cern.ch/geant4
*************************************************************
========= Table of registered couples
==============================
Index :
0 used in the geometry :
Yes recalculation needed : No
Material : ArgonGas
Range
cuts : gamma 1
mm e- 1
mm e+ 1 mm proton 1 mm
Energy thresholds : gamma -1
MeV e- -1
MeV e+ -1 MeV proton -1 MeV
Region(s) which use this couple :
DefaultRegionForTheWorldIndex :
1 used in the geometry :
Yes recalculation needed : No
Material : Aluminum
Range
cuts : gamma 1
mm e- 1
mm e+ 1 mm proton 1 mm
Energy thresholds : gamma -1
MeV e- -1
MeV e+ -1 MeV proton -1 MeV
Region(s) which use this couple :
DefaultRegionForTheWorldIndex :
2 used in the geometry :
Yes recalculation needed : No
Material : Lead
Range
cuts : gamma 1
mm e- 1
mm e+ 1 mm proton 1 mm
Energy thresholds : gamma -1
MeV e- -1
MeV e+ -1 MeV proton -1 MeV
Region(s) which use this couple :
DefaultRegionForTheWorld====================================================================
Start Run processing.
=====================================
G4EventManager::ProcessOneEvent() =====================================
G4PrimaryTransformer::PrimaryVertex
(-2000(mm),0(mm),0(mm),0(nsec))
1 primaries are passed from G4EventTransformer.
!!!!!!! Now start processing an event !!!!!!!
*********************************************************************************************************
* G4Track Information: Particle
= geantino, Track ID =
1, Parent ID = 0
*********************************************************************************************************
Step# X(mm) Y(mm) Z(mm)
KinE(MeV) dE(MeV) StepLeng
TrackLeng NextVolume ProcName
0 -2e+03 0