Geant4 per Laboratorio di Fisica Nucleare
Pagina con il materiale della lezione sul Monte Carlo e Geant4 nel corso di Laboratorio di Fisica Subnucleare del Prof. Cavoto
Slides
Useful links
Esempi:
- Calcolo di un integrale con metodo MC
- Calcolo di π con metodo MC
- Esempio Geant4 (versione modificata di examples/extended/analysis/AnaEx01)
- Esempio C++ (inheritance e polymorphism)
Scaricare e compilare l'esempio di Geant4
Dopo aver scaricato ed installato Geant4 eseguire i seguenti comandi da una directory di lavoro:
git clone https://github.com/carlomt/AnaEx01.git
mkdir anaEx01build
cd anaEx01build
cmake -DGeant4_DIR=G4INSTALLDIR ../AnaEx01
make
Gli altri esempi
Gli altri esempi sono scritti in python. Python è un linguaggio interpretato, quindi per eseguirli:
python NOMESCRIPT.py
Suggerimenti per installare Geant4
wget http://cern.ch/geant4/support/source/geant4.10.04.p01.tar.gz
wget http://cern.ch/geant4-data/releases/geant4.10.04.p01.tar.gz
tar -xvzf geant4.10.04.p01.tar.gz
this will create geant4.10.04.p01/
mkdir geant4.10.04.p01-build
mkdir geant4.10.04.p01-install
mkdir geant4-data
cd geant4.10.04.p01-build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGEANT4_INSTALL_DATA=ON -DGEANT4_INSTALL_DATADIR=../geant4-data -DGEANT4_BUILD_MULTITHREADED=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON -DGEANT4_BUILD_CXXSTD=c++11 -DCMAKE_INSTALL_PREFIX=../geant4.10.04.p01-install ../geant4.10.04.p01
make -j `nproc`
make install
Add to your .bashrc (~/.bash_profile on a Mac):
export G4DIR=~/geant4.10.04.p01-install
. $G4DIR/bin/geant4.sh
alias g4make='cmake -DGeant4_DIR=$G4DIR'
Prerequisiti per compilare Geant4 su CentOS7:
sudo yum update
sudo yum groupinstall “Development Tools”
sudo yum install xerces-c xerces-c-devel
sudo yum install centos-release-scl-rh
sudo yum install qt qt-x11 qt-devel
sudo yum install emacs
sudo yum install python27 python27-pyhton-pip python27-pyhton-tools python27-numpy
Add to your ~/.barshrc the line:
. /opt/rh/python27/enable
Suggerimenti per compilare cmake su CentOS7
wget https://cmake.org/files/v3.10/cmake-3.10.3.tar.gz
tar -xvzf cmake-3.10.3.tar.gz
cd cmake-3.10.3
./bootstrap && make && make install
Add to ~/.bashrc the line:
export PATH=/home/soft/cmake-3.10.3/bin:$PATH
Prerequisiti per compilare Geant4 su MacOS:
install XCode (https://developer.apple.com/xcode/) and type in a terminal:
xcode-select —install
install XQuartz (https://www.xquartz.org/)
install brew (https://brew.sh/) and the required libraries:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew install cmake qt@4 xerces-c
As some students had problems in installing the Qt and Geant4 I prepared a brew receipe to install it.
To use it:
brew install cmake carlomt/repo/qt@4 xerces-c wget
Experimentally:
brew install -v carlomt/repo/geant4
the -v option is to check the compiling, as it is quite long.When it ends add the line:
. /usr/local/bin/geant4.sh
to the ".bash_profile" in you home.
With this method Geant4 will be installed in:
/usr/local/Cellar/geant4/4.10.04.p01
Search
Server Time
- Fri 28 March 2025
- 14:17:59
- Timezone: Europe/Rome