Hi everyone:
I’m a master student who is focus on medical physics. I wanna install Geant4 in my MacBook 19’ , does it work ? Do I need other packages installed in my Mac? Does anyone can help me? Thanks a lot
Hi everyone:
I’m a master student who is focus on medical physics. I wanna install Geant4 in my MacBook 19’ , does it work ? Do I need other packages installed in my Mac? Does anyone can help me? Thanks a lot
Geant4 is supported on macOS, so yes. The easiest way to install to begin using it is through the Homebrew or Conda package managers:
Hi Bmorgan:
Thanks for your reply and help so soon.
so you mean I can donwload homebrew or conda to install the g4?
which one is better fit both( GEANT4 AND PTSIM?)
thanks
Yes, just follow the instructions in the links! Homebrew is the easiest as once installed you just need to do brew install geant4
. That will provide an install of 10.6.2 with multithreading, Qt and GDML support.
I don’t know about “PTSIM”, so you might want to contact the developers of that to see if they have recommendations.
I still can’t use brew to install . could you help me install G4? thanks
I use HOMEBREW but its can’t work
Do I download Xcode?
Yes, you should follow the instructions and install the command line tools. That’s the minimum needed to build code, including Geant4 applications. It’s up to you whether then to also install the full Xcode IDE from the App Store, though I’d recommend it as it’s a good development environment.
Dear Ben,
Quick question regarding brew: is the version available compatible with Catalina 10.15.7?
I tried to install Geant4 via brew with brew install geant4
, but I cannot find the formula in brew.sh, but do in brewsci:
https://github.com/brewsci/homebrew-science/blob/master/Formula/geant4.rb
While trying to install it with brew install brewsci/science/geant4
I get the error below, and the git repo above shows only high_sierra among the bottles.
Is there a different direction to follow for this installation step?
Cheers Gustavo
(home path replaced by $HOME)
$ brew install brewsci/science/geant4
==> Installing geant4 from brewsci/science
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.20.1
Already downloaded: $HOME/Library/Caches/Homebrew/downloads/374a6e8b44a45140803d162f1f24b6ea2d62e699e665193cb35f787abbcc7ff7--cmake-3.20.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:1875ab07ed5843cdc06368
Already downloaded: $HOME/Library/Caches/Homebrew/downloads/d8c345011c71dfe2fb736da470c638521f90e7ca8196bdaeafe055bfe74e126e--cmake--3.20.1.catalina.bottle.tar.gz
==> Downloading https://archive.org/download/brewsci/bottles-science/geant4-10.3.3.high_si
==> Downloading from https://ia801805.us.archive.org/0/items/brewsci/bottles-science/geant
#=#=-# #
curl: (22) The requested URL returned error: 404
Error: Failed to download resource "geant4"
Download failed: https://archive.org/download/brewsci/bottles-science/geant4-10.3.3.high_sierra.bottle.tar.gz
Unfortunately, Homebrew removed Geant4 as our licence isn’t considered Debian-compatible. We’re looking at adding a custom tap to allow install through brew
, but this is still WIP.
The documentation should have been updated, but looks like it hasn’t been deployed yet - I’ll chase that up.
You could try the following as a temporary solution:
brew create --set-name geant4 --no-fetch https://geant4-data.web.cern.ch/geant4-data/releases/source/geant4.10.07.p01.tar.gz
paste this code into the editor (replace everything that was automatically created)
class Geant4 < Formula
desc "Simulation toolkit for particle transport through matter"
homepage "https://geant4.web.cern.ch"
url "https://geant4-data.web.cern.ch/geant4-data/releases/source/geant4.10.07.p01.tar.gz"
version "10.7.1"
sha256 "525161753a3d9c2ad19b25f2eabc8bbede91c236120771bd9c3f4aaac8412e1e"
depends_on "cmake" => [:build, :test]
depends_on "expat"
depends_on "qt@5"
depends_on "xerces-c"
# Check for updates in cmake/Modules/Geant4DatasetDefinitions.cmake
resource "G4NDL" do
url "https://cern.ch/geant4-data/datasets/G4NDL.4.6.tar.gz"
sha256 "9d287cf2ae0fb887a2adce801ee74fb9be21b0d166dab49bcbee9408a5145408"
end
resource "G4EMLOW" do
url "https://cern.ch/geant4-data/datasets/G4EMLOW.7.13.tar.gz"
sha256 "374896b649be776c6c10fea80abe6cf32f9136df0b6ab7c7236d571d49fb8c69"
end
resource "PhotonEvaporation" do
url "https://cern.ch/geant4-data/datasets/G4PhotonEvaporation.5.7.tar.gz"
sha256 "761e42e56ffdde3d9839f9f9d8102607c6b4c0329151ee518206f4ee9e77e7e5"
end
resource "RadioactiveDecay" do
url "https://cern.ch/geant4-data/datasets/G4RadioactiveDecay.5.6.tar.gz"
sha256 "3886077c9c8e5a98783e6718e1c32567899eeb2dbb33e402d4476bc2fe4f0df1"
end
resource "G4SAIDDATA" do
url "https://cern.ch/geant4-data/datasets/G4SAIDDATA.2.0.tar.gz"
sha256 "1d26a8e79baa71e44d5759b9f55a67e8b7ede31751316a9e9037d80090c72e91"
end
resource "G4PARTICLEXS" do
url "https://cern.ch/geant4-data/datasets/G4PARTICLEXS.3.1.1.tar.gz"
sha256 "66c17edd6cb6967375d0497add84c2201907a25e33db782ebc26051d38f2afda"
end
resource "G4ABLA" do
url "https://cern.ch/geant4-data/datasets/G4ABLA.3.1.tar.gz"
sha256 "7698b052b58bf1b9886beacdbd6af607adc1e099fc730ab6b21cf7f090c027ed"
end
resource "G4INCL" do
url "https://cern.ch/geant4-data/datasets/G4INCL.1.0.tar.gz"
sha256 "716161821ae9f3d0565fbf3c2cf34f4e02e3e519eb419a82236eef22c2c4367d"
end
resource "G4PII" do
url "https://cern.ch/geant4-data/datasets/G4PII.1.3.tar.gz"
sha256 "6225ad902675f4381c98c6ba25fc5a06ce87549aa979634d3d03491d6616e926"
end
resource "G4ENSDFSTATE" do
url "https://cern.ch/geant4-data/datasets/G4ENSDFSTATE.2.3.tar.gz"
sha256 "9444c5e0820791abd3ccaace105b0e47790fadce286e11149834e79c4a8e9203"
end
resource "RealSurface" do
url "https://cern.ch/geant4-data/datasets/G4RealSurface.2.2.tar.gz"
sha256 "9954dee0012f5331267f783690e912e72db5bf52ea9babecd12ea22282176820"
end
resource "G4TENDL" do
url "https://cern.ch/geant4-data/datasets/G4TENDL.1.3.2.tar.gz"
sha256 ""
end
def install
mkdir "geant-build" do
args = std_cmake_args + %w[
../
-DGEANT4_USE_GDML=ON
-DGEANT4_BUILD_MULTITHREADED=ON
-DGEANT4_USE_QT=ON
]
system "cmake", *args
system "make", "install"
end
resources.each do |r|
(share/"Geant4-#{version}/data/#{r.name}#{r.version}").install r
end
end
def caveats
<<~EOS
Because Geant4 expects a set of environment variables for
datafiles, you should source:
. #{HOMEBREW_PREFIX}/bin/geant4.sh (or .csh)
before running an application built with Geant4.
EOS
end
test do
system "cmake", share/"Geant4-#{version}/examples/basic/B1"
system "make"
(testpath/"test.sh").write <<~EOS
. #{bin}/geant4.sh
./exampleB1 run2.mac
EOS
assert_match "Number of events processed : 1000",
shell_output("/bin/bash test.sh")
end
end
if you need to correct things:
brew edit geant4
afterwards, fire up (edit:)
brew install --build-from-source geant4
If you don’t want to interfere with “official” formula names etc, replace geant4 in the brew commands with something else, e.g. mygeant4
expert move: update the datasets to current versions by simply changing the version number in the url. this will throw an error message when installing where you can copy the updated sha256, and place into the formula (brew edit geant4). repeat until no more error messages…
note: this is simply the content I get when I display the content of the geant4 formula on my machine. I have manually changed the file to get the newest version, probably back when it was still available(?). Don’t know if that works… let me know if it does
Dear weller,
Thanks a lot. It indeed works after minor corrections. I leave it here in case someone tries to install Geant4 via brew 3.1.2. Since brew requires a license, I took the liberty to set it to “public domain” in case you don’t mind
Cheers, Gustavo
class Mygeant4 < Formula
desc "Simulation toolkit for particle transport through matter"
homepage "https://geant4.web.cern.ch"
url "https://geant4-data.web.cern.ch/geant4-data/releases/source/geant4.10.07.p01.tar.gz"
version "10.7.1"
sha256 "525161753a3d9c2ad19b25f2eabc8bbede91c236120771bd9c3f4aaac8412e1e"
license :public_domain
depends_on "cmake" => [:build, :test]
depends_on "qt@5"
depends_on "xerces-c"
uses_from_macos "expat"
resource "G4NDL" do
url "https://cern.ch/geant4-data/datasets/G4NDL.4.6.tar.gz"
sha256 "9d287cf2ae0fb887a2adce801ee74fb9be21b0d166dab49bcbee9408a5145408"
end
resource "G4EMLOW" do
url "https://cern.ch/geant4-data/datasets/G4EMLOW.7.13.tar.gz"
sha256 "374896b649be776c6c10fea80abe6cf32f9136df0b6ab7c7236d571d49fb8c69"
end
resource "PhotonEvaporation" do
url "https://cern.ch/geant4-data/datasets/G4PhotonEvaporation.5.7.tar.gz"
sha256 "761e42e56ffdde3d9839f9f9d8102607c6b4c0329151ee518206f4ee9e77e7e5"
end
resource "RadioactiveDecay" do
url "https://cern.ch/geant4-data/datasets/G4RadioactiveDecay.5.6.tar.gz"
sha256 "3886077c9c8e5a98783e6718e1c32567899eeb2dbb33e402d4476bc2fe4f0df1"
end
resource "G4SAIDDATA" do
url "https://cern.ch/geant4-data/datasets/G4SAIDDATA.2.0.tar.gz"
sha256 "1d26a8e79baa71e44d5759b9f55a67e8b7ede31751316a9e9037d80090c72e91"
end
resource "G4PARTICLEXS" do
url "https://cern.ch/geant4-data/datasets/G4PARTICLEXS.3.1.1.tar.gz"
sha256 "66c17edd6cb6967375d0497add84c2201907a25e33db782ebc26051d38f2afda"
end
resource "G4ABLA" do
url "https://cern.ch/geant4-data/datasets/G4ABLA.3.1.tar.gz"
sha256 "7698b052b58bf1b9886beacdbd6af607adc1e099fc730ab6b21cf7f090c027ed"
end
resource "G4INCL" do
url "https://cern.ch/geant4-data/datasets/G4INCL.1.0.tar.gz"
sha256 "716161821ae9f3d0565fbf3c2cf34f4e02e3e519eb419a82236eef22c2c4367d"
end
resource "G4PII" do
url "https://cern.ch/geant4-data/datasets/G4PII.1.3.tar.gz"
sha256 "6225ad902675f4381c98c6ba25fc5a06ce87549aa979634d3d03491d6616e926"
end
resource "G4ENSDFSTATE" do
url "https://cern.ch/geant4-data/datasets/G4ENSDFSTATE.2.3.tar.gz"
sha256 "9444c5e0820791abd3ccaace105b0e47790fadce286e11149834e79c4a8e9203"
end
resource "RealSurface" do
url "https://cern.ch/geant4-data/datasets/G4RealSurface.2.2.tar.gz"
sha256 "9954dee0012f5331267f783690e912e72db5bf52ea9babecd12ea22282176820"
end
resource "G4TENDL" do
url "https://cern.ch/geant4-data/datasets/G4TENDL.1.3.2.tar.gz"
sha256 "3b2987c6e3bee74197e3bd39e25e1cc756bb866c26d21a70f647959fc7afb849"
end
def install
mkdir "geant-build" do
args = std_cmake_args + %w[
../
-DGEANT4_USE_GDML=ON
-DGEANT4_BUILD_MULTITHREADED=ON
-DGEANT4_USE_QT=ON
]
system "cmake", *args
system "make", "install"
end
resources.each do |r|
(share/"Geant4-#{version}/data/#{r.name}#{r.version}").install r
end
end
def caveats
<<~EOS
Because Geant4 expects a set of environment variables for
datafiles, you should source:
. #{HOMEBREW_PREFIX}/bin/geant4.sh (or .csh)
before running an application built with Geant4.
EOS
end
test do
system "cmake", share/"Geant4-#{version}/examples/basic/B1"
system "make"
(testpath/"test.sh").write <<~EOS
. #{bin}/geant4.sh
./exampleB1 run2.mac
EOS
assert_match "Number of events processed : 1000",
shell_output("/bin/bash test.sh")
end
end
I am not sure if that license rather refers to the software that is installed with the formula (and I also think it is only relevant for uploading the formula to “Homebrew/homebrew-core”: Formula Cookbook — Homebrew Documentation)
Glad it works
Sure, it only relies for your local formula, but I’m clarifying it in respect to your code posted here
my humble contribution was only the minor change from geant4.10.06 to 4.10.07.p01 and some updated sha256 hash values and dataset urls.
I think the real heroes are the developers & maintainers from geant4, such as @bmorgan
One more tip: set the environment vars