Problem in exampleB1 visualization

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version: 11.2.2
Operating System: MacOS Sonoma14.2
Compiler/Version: clang-1500.1.0.2.5
CMake Version: 3.29.5


I can run exampleB1 in terminal but cannot visualize it with a direct run of

Here is how I configure to build g4:

cmake -DCMAKE_INSTALL_PREFIX=/Users/liling/geant4/install_11.2.2 -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=OFF -DGEANT4_USE_QT=ON -DGEANT4_USE_QT_QT6=ON -DGEANT4_USE_VTK=ON -DGEANT4_USE_SYSTEM_EXPAT=OFF ../geant4-11.2.2

and configure to build exampleB1:

cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 ..

Here is what I got after running

./exampleB1

:

# Visualization setting
  /control/execute vis.mac
# Macro file for the visualization setting in the initialization phase
# of the B1 example when running in interactive mode
#
# Use these open statements to open selected visualization
#
# Use this open statement to create an OpenGL view:
  /vis/open OGL 600x600-0+0
  /vis/sceneHandler/create OGL
parameter value (OGL) is not listed in the candidate List.
  Candidates are: ASCIITree ATree DAWNFILE G4HepRepFile HepRepFile RayTracer VRML2FILE gMocrenFile TOOLSSG_OFFSCREEN TSG_OFFSCREEN TOOLSSG_OFFSCREEN TSG_OFFSCREEN TSG_FILE Qt3D TOOLSSG_QT_ZB TSG_QT_ZB TSGQtZB TSG VtkNative VTKN VtkOffscreen VTK_OFFSCREEN VtkQt VTKQt VTKQt Vtk VTK
sub-command "/vis/sceneHandler/create" failed.
Registered graphics systems are:
  ASCIITree (ATree)
  DAWNFILE (DAWNFILE)
  G4HepRepFile (HepRepFile)
  RayTracer (RayTracer)
  VRML2FILE (VRML2FILE)
  gMocrenFile (gMocrenFile)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)
  Qt3D (Qt3D)
  TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB, TSG)
  VtkNative (VTKN, VTKQt_FALLBACK)
  VtkOffscreen (VTK_OFFSCREEN)
  VtkQt (VTKQt, VTKQt, Vtk, VTK)
Default graphics system is: Vtk (based on build flags).
Default window size hint is: 600x600-0+0 (based on G4VisManager initialisation).
Note: Parameters specified on the command line will override these defaults.
      Use "vis/open" without parameters to get these defaults.

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
      issued by : G4UImanager::ApplyCommand
Invoked command has failed - see above.
Error code : 500
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

***** Illegal parameter (0) </vis/open OGL 600x600-0+0> *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
      issued by : G4UImanager::ApplyCommand
Command aborted (500)
Error code : 500
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

***** Illegal parameter (0) </control/execute vis.mac> *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
      issued by : G4UImanager::ApplyCommand
Command aborted (500)
Error code : 500
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

I also tried Qt3D (/vis/open Qt3D) and it just crashed and said

qt.qpa.fonts: Populating font family aliases took 423 ms. Replace uses of missing font family "Garamond" with one that exists to avoid this cost.
2025-01-12 22:55:22.284 exampleB1[69829:22699347] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
/vis/open Qt3D
/vis/sceneHandler/create Qt3D
/vis/viewer/create ! ! 600x600-0+0
Qt3D.Renderer.RHI.Backend: Initializing RHI with Metal backend
/vis/viewer/refresh
[1]    69829 segmentation fault  ./exampleB1

I also tried vtkqt but there was only pure black:

I want to know how I can visualize it. I used to use g4 v10 before and it worked but now I cannot build that version.

I

Hi Yingtian Liu

You have been unlucky…you were nearly there. Sometimes VTK needs some interaction, perhaps rotation, perhaps zooming, before it draws something. It is still somewhat under development. Try it again. I would really encourage you try VTK because we want to develop it further.

Qt3D too is still under development, and seems to be unstable with Qt6.

If you build with VTK, the OpenGL drivers are suppressed because of incompatibility. If you want to try OpenGL, build with GEANT4_USE_QT=ON and GEANT4_USE_QT_QT6=ON but without VTK.

Let us know how you get on. Does it work?

John

Thank you for your answer. I tried to interact with vtk, but it does not seem to work. So I plan to rebuild g4 with opengl. Besides the option you mentioned, should I set

-DGEANT4_USE_OPENGL_X11=OFF or ON

? I thought the X11 suffix means it is related to linux only but I am not sure.

And I noticed that in a previous version of g4, it works with qt5. So I am not sure whether the problem is because I build g4 with qt6 but build the exampleB1 with qt5. Anyway, I will try to rebuild g4 for the next step.

Hi Yingtian Liu

Ah, yes. VTK is not supported with Qt5.

Since you are working on Mac, maybe best to avoid X11. (It is possible, but I have experienced interference with Qt in the past.) For Qt5, GEANT4_USE_QT=ON should be enough. It will bring in OGLSQt (provided you do not switch on VTK), and TSG_QT.

John