How to use the visualization with B1 example executable

Hello, I’m a new user of Geant4 and trying to do a test run using one of the example executables provided on the Geant4 website, B1. My apologies if this is a naive question, and I’d be grateful for any thoughts or wisdom.

I’ve listed the complete setup process I went through, and afterward is my main question. I’m re-pasting the question right here to save reader time if you just want to know what I’m getting at:

MY QUESTION IS: How do I open and see some graphics once I’ve run the B1 example? Is there a GUI interface where I can interact with this newly installed program to see some graphs and export ASCII files or spreadsheets?

Thanks so much!

Here is the basic install I’ve done of both Geant4 and the subsequent application, B1 found in the source file from Geant4 website:

GEANT4, I followed this install guide:

Here is the code I ran in my terminal:

Daniels-MacBook-Pro:geant4.10.07-build danielbarton$ cmake -DCMAKE_INSTALL_PREFIX=/applications/geant/geant4.10.06-install /applications/geant/geant4.10.07

Then:

cmake -DGEANT4_INSTALL_DATA=ON .

cmake -DGEANT4_USE_QT=ON .

Next, I copied the B1 example from the source folder to the main directory, made a build folder and installed:

mkdir B1-build

cd applications/geant/B1-build

$ cmake -DGeant4_DIR=/Applications/geant/geant4.10.07-install/lib/Geant4-10.7.1 /Applications/geant/B1 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_QT=ON -DWITH_GEANT4_UIVIS=ON

$ make -j2

$ make install

Finally, I executed the newly installed program:

$ ./exampleB1

When it opens in my bash terminal window it looks like this:

geant_exampleB1.pdf (69.2 KB)

I run various commands, such as:

Idle> /run/beamOn 5
Idle> /tracking/verbose 1
Idle> /run/beamOn 1
Idle> /gun/particle mu+
Idle> /gun/energy 10 GeV
Idle> /run/beamOn 1
Idle> /gun/particle proton
Idle> /gun/energy 100 MeV
Idle> /run/beamOn 3
Idle> exit

MY QUESTION IS: What next? i.e. How do I open and see some graphics? Is there a GUI interface where I can interact with this newly installed program?

Geant4 version: 10.7, first released 4 December 2020

UPDATE 4/26/2021:

I wanted to provide an update which perhaps someday may assist someone else. The short version is: now it works! By it works, I mean, I was able to install both Geant4 and the B1 example, and finally get the visualization to work. It was the visualization that didn’t work before. Here are the steps I went through to make it work:

Hint: Basically, the problem is I didn’t have Qt installed, so I installed it, then installed Geant 4 from scratch.

STEPS FOR INSTALLING GEANT4:

Download (from the Qt website) and install Qt version 5.9.9. I chose to download an evaluation version (whose license lasts 10 days) just so I could at least get this software working…for now.
I chose 5.9.9 as noted above because the error when trying to turn on visualization using:

cmake -DGEANT4_USE_QT=ON .

Gave the following error:

CMake Warning at CMakeLists.txt:33 (FIND_PACKAGE):

By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

Therefore, I wanted to play it safe and install version 5. Besides, I installed version 6 first and it did not have the Qt5Core file in it.

Once the installer was open and running on my Mac, I chose these options (I picked as few as possible, to keep the file size smaller). I came up with this list on my own, so you may have different/better choices:

Mac OS # you can also chose to add in stuff for Android, iOS, etc. which I didn’t need.
QT Data Visualization
QT Virtual layout
Debug
Quick compiler

Then point your cmake to this particular folder, which will be needed when calling cmake QT=on (below).

$ export CMAKE_PREFIX_PATH=/Applications/Qt/5.9.9/clang_64/lib/cmake:$CMAKE_PREFIX_PATH

$ cmake -DGEANT4_USE_QT=ON .

$ make -j2 #I have two processors in my Mac

$ make install

STEPS FOR INSTALLING B1 EXAMPLE APPLICATION (DONE AFTER GEANT4 IS SUCCESSFULLY INSTALLED, AS PER ABOVE):

NAVIGATE TO THE MAIN GEANT FOLDER:

FIRST “Source” the geant4.sh file. Do this while in the main install directory where Geant4 was actually installed:

Daniels-MacBook-Pro:geant danielbarton$ cd geant4.10.07-install/bin
Daniels-MacBook-Pro:bin danielbarton$ pwd
/applications/geant/geant4.10.07-install/bin
Daniels-MacBook-Pro:bin danielbarton$ source geant4.sh

NOW, YOU’LL NAVIGATE BACK OUT AND CREATE A FOLDER TO BUILD THE “Application” in:

cd /applications/geant

ls #should show something like this:


mkdir B3-build

cd applications/geant/B3-build

cmake -DGeant4_DIR=/Applications/geant/geant4.10.07-install/lib/Geant4-10.7.1 /Applications/geant/B3

Here:

The first argument: points CMake to our install of Geant4. Specifically, it is the directory holding the Geant4Config.cmake file that Geant4 installs to help CMake find and use Geant4.

Second argument: is the path to the source directory of the application we want to build.

Note: You may be wondering, well, where will “cmake” put/build the actual application. Well, it puts it into whatever directory you are in when you execute “cmake”. That’s why you navigate to “b1-build” above, cause that’s where we want the application to be put.

Next, install the data (like data files from CERN, or something), and the visualization software (here we use something called “QT”).

cmake -DGEANT4_INSTALL_DATA=ON .

cmake -DGEANT4_USE_QT=ON .

cmake -DWITH_GEANT4_UIVIS=ON .   # Did not use in 4/25/21 build.  But, apparently this package is something to do with turning visualizations on

don’t forget the: “space” then period “.”

Then, do another “ls” to see if the thing put files, including the important “Makefile” in your “B1-build” folder:

Next, the next command makes the final “build” files that will be used to create an executable application:

$ make -j2

Here I’ve used “2” because I have 2 processors. If you have only 1, or if you have more, you can put the corresponding number.

Then, create the actual application:

$ make install