|
|
# Geant4 Installation on MacOS
|
|
|
|
|
|
we use homebrew to install |
|
|
\ No newline at end of file |
|
|
In this tutorial we will use Geant4 version 10.6.2.
|
|
|
|
|
|
On MacOS we recommend install Geant4 via [Homebrew](https://brew.sh)
|
|
|
|
|
|
## macOS Requirements
|
|
|
|
|
|
* A 64-bit Intel CPU
|
|
|
* macOS High Sierra (10.13) (or higher)
|
|
|
* Command Line Tools (CLT) for Xcode
|
|
|
* A Bourne-compatible shell for installation (e.g. bash or zsh)
|
|
|
|
|
|
## Homebrew Installation
|
|
|
|
|
|
In a macOS Terminal type following command:
|
|
|
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
|
|
|
|
|
|
Visit Homebrew pages for details:
|
|
|
|
|
|
https://brew.sh
|
|
|
https://docs.brew.sh/Installation
|
|
|
|
|
|
## Geant4 installation
|
|
|
|
|
|
First install _cmake_ :
|
|
|
|
|
|
`brew install cmake`
|
|
|
|
|
|
In Terminal window type the command:
|
|
|
|
|
|
`brew install geant4`
|
|
|
|
|
|
This will install _geant4_ 10.6.2 with all dependancies: expat , qt , xerces-c
|
|
|
|
|
|
The giant4 install into /usr/local/Cellar/geant4/10.6.2 by default and
|
|
|
links into /usr/local/{bin, include, lib, share} was made
|
|
|
|
|
|
Geant4 installed with MacOS native Qt interface , no X11 required.
|
|
|
|
|
|
## Installation of Root application ##
|
|
|
|
|
|
The root installation was requaired for some exercise in this tutorial.
|
|
|
|
|
|
The command: `brew install root` will install _root_ 6.22.02.
|
|
|
|
|
|
Homebrew install root in _relocatable_ mode,
|
|
|
before use root you must setup root environment sourcing this root.sh from
|
|
|
root installation directory:
|
|
|
|
|
|
`source /usr/local/bin/thisroot.sh`
|
|
|
|
|
|
Visit http://root.cern.ch for more information about Root.
|
|
|
|
|
|
## Setup développement environment for tutorial
|
|
|
|
|
|
In order to use Geant4 you need define variables pointed to Geant4 datasets locations.
|
|
|
This can be done by sourcing geant4.sh script. For homebrew installation the command is:
|
|
|
|
|
|
`source /usr/local/bin/geant4.sh`
|
|
|
|
|
|
In Attachement you can found bash script *setup_env.sh* with allow setup root and geant4.
|
|
|
|
|
|
The code snippet hire:
|
|
|
|
|
|
```
|
|
|
>>>>>
|
|
|
|
|
|
# Root 6
|
|
|
if [ -x /usr/local/bin/thisroot.sh ]; then
|
|
|
. /usr/local/bin/thisroot.sh
|
|
|
fi
|
|
|
|
|
|
# Geant4
|
|
|
if [ -x /usr/local/bin/geant4.sh ]; then
|
|
|
. /usr/local/bin/geant4.sh
|
|
|
fi
|
|
|
|
|
|
>>>>>
|
|
|
```
|
|
|
|
|
|
You can source this script before start to work with geant4 project or
|
|
|
put the line to .bash_profile to setup environment automatically on each login.
|
|
|
|
|
|
## Testing of installation
|
|
|
|
|
|
### 1. Open New Terminal Window
|
|
|
|
|
|
### 2. Source `setup_env.sh` if not done with `.bash_profile`
|
|
|
- `source ~/setup_env.sh`
|
|
|
|
|
|
### 3. Start Root and type `.demo`
|
|
|
|
|
|
```
|
|
|
$ root
|
|
|
------------------------------------------------------------------
|
|
|
| Welcome to ROOT 6.22/02 https://root.cern |
|
|
|
| (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
|
|
|
| Built for macosx64 on Aug 17 2020, 12:46:52 |
|
|
|
| From tags/v6-22-02@v6-22-02 |
|
|
|
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
root [0] .demo
|
|
|
|
|
|
You will see root demo bar and can run some demos clicking on demo menu.
|
|
|
You need go from up to down in menu , some dome depend from previous demo results.
|
|
|
|
|
|
To quit root type .q on root prompt
|
|
|
|
|
|
root [1] .q
|
|
|
|
|
|
Taking a break from ROOT? Hope to see you back!
|
|
|
|
|
|
$
|
|
|
```
|
|
|
|
|
|
### 4. Test Geant4 installation
|
|
|
|
|
|
You can try to compile and run one of geant4 examples.
|
|
|
|
|
|
E.g. basic B5 example:
|
|
|
|
|
|
```
|
|
|
$ cd ~/tmp
|
|
|
$ mkdir B5-build
|
|
|
$ cd B5-build
|
|
|
$ cmake /usr/local/share/Geant4-10.6.2/examples/basic/B5/
|
|
|
```
|
|
|
|
|
|
You must see something like this and not see a configuration errors
|
|
|
|
|
|
```
|
|
|
-- The C compiler identification is AppleClang 12.0.0.12000032
|
|
|
-- The CXX compiler identification is AppleClang 12.0.0.12000032
|
|
|
-- Detecting C compiler ABI info
|
|
|
-- Detecting C compiler ABI info - done
|
|
|
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
|
|
|
-- Detecting C compile features
|
|
|
-- Detecting C compile features - done
|
|
|
-- Detecting CXX compiler ABI info
|
|
|
-- Detecting CXX compiler ABI info - done
|
|
|
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
|
|
|
-- Detecting CXX compile features
|
|
|
-- Detecting CXX compile features - done
|
|
|
-- Found EXPAT: /usr/local/opt/expat/lib/libexpat.dylib (found suitable version "2.2.10", minimum required is "2.2.9")
|
|
|
-- Found XercesC: /usr/local/lib/libxerces-c.dylib (found suitable version "3.2.3", minimum required is "3.2.3")
|
|
|
-- Found OpenGL: /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework
|
|
|
-- Configuring done
|
|
|
-- Generating done
|
|
|
-- Build files have been written to: /Users/semenjuk/tmp/B5-build
|
|
|
```
|
|
|
Now you can build application wihh `make -j4` where -j4 the number of parallel make processes.
|
|
|
|
|
|
```
|
|
|
$ make
|
|
|
Scanning dependencies of target exampleB5
|
|
|
[ 5%] Building CXX object CMakeFiles/exampleB5.dir/exampleB5.cc.o
|
|
|
[ 11%] Building CXX object CMakeFiles/exampleB5.dir/src/B5ActionInitialization.cc.o
|
|
|
[ 17%] Building CXX object CMakeFiles/exampleB5.dir/src/B5CellParameterisation.cc.o
|
|
|
[ 23%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DetectorConstruction.cc.o
|
|
|
[ 29%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DriftChamberHit.cc.o
|
|
|
[ 35%] Building CXX object CMakeFiles/exampleB5.dir/src/B5DriftChamberSD.cc.o
|
|
|
[ 41%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EmCalorimeterHit.cc.o
|
|
|
[ 47%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EmCalorimeterSD.cc.o
|
|
|
[ 52%] Building CXX object CMakeFiles/exampleB5.dir/src/B5EventAction.cc.o
|
|
|
[ 58%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HadCalorimeterHit.cc.o
|
|
|
[ 64%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HadCalorimeterSD.cc.o
|
|
|
[ 70%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HodoscopeHit.cc.o
|
|
|
[ 76%] Building CXX object CMakeFiles/exampleB5.dir/src/B5HodoscopeSD.cc.o
|
|
|
[ 82%] Building CXX object CMakeFiles/exampleB5.dir/src/B5MagneticField.cc.o
|
|
|
[ 88%] Building CXX object CMakeFiles/exampleB5.dir/src/B5PrimaryGeneratorAction.cc.o
|
|
|
[ 94%] Building CXX object CMakeFiles/exampleB5.dir/src/B5RunAction.cc.o
|
|
|
[100%] Linking CXX executable exampleB5
|
|
|
[100%] Built target exampleB5
|
|
|
|
|
|
The compilation finished successfully
|
|
|
```
|
|
|
|
|
|
Run executable without parameters.
|
|
|
This will open interactive QTGUI window.
|
|
|
|
|
|
You can generate N events typing filed
|
|
|
Session : `/run/beamOn N`
|
|
|
Or use command `exit` to quit application
|
|
|
|
|
|
|
|
|
Below terminal output:
|
|
|
```
|
|
|
$ ./exampleB5
|
|
|
Available UI session types: [ Qt, GAG, tcsh, csh ]
|
|
|
G4WT0 > Using Root
|
|
|
G4WT1 > Using Root
|
|
|
G4WT0 > /control/saveHistory
|
|
|
G4WT1 > /control/saveHistory
|
|
|
G4WT1 > /run/verbose 2
|
|
|
G4WT0 > /run/verbose 2
|
|
|
G4WT1 > /run/initialize
|
|
|
G4WT0 > /run/initialize
|
|
|
G4WT1 > /run/physicsModified
|
|
|
G4WT0 > /run/physicsModified
|
|
|
...
|
|
|
<snip>
|
|
|
...
|
|
|
G4WT0 > ================== Deleting memory pools ===================
|
|
|
G4WT0 > Pool ID '20G4NavigationLevelRep', size : 0.00288 MB
|
|
|
G4WT0 > Pool ID '24G4ReferenceCountedHandleIvE', size : 0.000961 MB
|
|
|
G4WT0 > Pool ID '7G4Event', size : 0.000961 MB
|
|
|
G4WT0 > Pool ID '15G4CountedObjectIvE', size : 0.000961 MB
|
|
|
G4WT0 > Number of memory pools allocated: 4; of which, static: 0
|
|
|
G4WT0 > Dynamic pools deleted: 4 / Total memory freed: 0.0058 MB
|
|
|
G4WT0 > ============================================================
|
|
|
G4WT0 > G4Allocator objects are deleted.
|
|
|
G4WT0 > Thread-local UImanager is to be deleted.
|
|
|
G4WT0 > There should not be any thread-local G4cout/G4cerr hereafter.
|
|
|
G4 kernel has come to Quit state.
|
|
|
UserDetectorConstruction deleted.
|
|
|
UserPhysicsList deleted.
|
|
|
UserActionInitialization deleted.
|
|
|
UserWorkerThreadInitialization deleted.
|
|
|
UserRunAction deleted.
|
|
|
RunManager is deleting RunManagerKernel.
|
|
|
G4SDManager deleted.
|
|
|
EventManager deleted.
|
|
|
Units table cleared.
|
|
|
TransportationManager deleted.
|
|
|
Total navigation history collections cleaned: 3
|
|
|
================== Deleting memory pools ===================
|
|
|
Pool ID '20G4NavigationLevelRep', size : 0.00288 MB
|
|
|
Pool ID '24G4ReferenceCountedHandleIvE', size : 0.000961 MB
|
|
|
Pool ID '15G4CountedObjectIvE', size : 0.000961 MB
|
|
|
Number of memory pools allocated: 3; of which, static: 0
|
|
|
Dynamic pools deleted: 3 / Total memory freed: 0.0048 MB
|
|
|
============================================================
|
|
|
G4Allocator objects are deleted.
|
|
|
UImanager deleted.
|
|
|
StateManager deleted.
|
|
|
RunManagerKernel is deleted. Good bye :)
|
|
|
```
|
|
|
#### You must not see and crash dump !
|
|
|
|
|
|
|
|
|
## Tips ##
|
|
|
|
|
|
- Xcode
|
|
|
- You can install **Xcode** via **App Store** or download **Command Line Tools** from Apple Developer site https://developer.apple.com/downloads/
|
|
|
|
|
|
- geant4
|
|
|
- you can check the geant4 datasets installations using command:
|
|
|
`geant4-config --check-datasets`
|
|
|
- `geant4-config --help` also show geant4 features ( configuration options )
|
|
|
|
|
|
Visit geant4 installation Gide for info:
|
|
|
http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/html/
|
|
|
|
|
|
- zsh
|
|
|
- if you use zsh you need use .zprofile on place of .bash_profile
|
|
|
- use *source* not a *.* to source setup scripts
|
|
|
|
|
|
- bash
|
|
|
- zsh default waring
|
|
|
To suppress waring massage put following line into .bash_profile
|
|
|
`export BASH_SILENCE_DEPRECATION_WARNING=1`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|