GEANT4 Visualization on MacOs

_Geant4 Version: 11.2.0
_Operating System: Mac OS Sonoma 14
_CMake Version: 3.28.3

Hello all, I hope you have been well.

I am new to Geant4 and I am trying to install it on my Intel-based Macbook.

I am installing it successfully and following the steps here: Geant4 System/Software Prerequisites — Geant4 Installation Guide 11.2 documentation

But after trying to run the examples I am running through issues.

I successfully make the simulation and produce the executable file. But when running it I don’t get a pop-up window with the visuals.

I read somewhere that I need to make Geant4 with: -DGEANT4_USE_OPENGL_X11=ON

So I did that and I am getting the following error:

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

***** Illegal parameter (1) </vis/open> *****

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

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

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

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

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

I tried to also put /vis/open OGL, OGLQT, RayTrace, OGLI, but none of them worked.

I have also installed all the required packages like QT5 VTK, and XQuarts. The XQuarts application opens up when running the executable file. But it doesn’t show any window.

I am not sure if anyone has had similar issues and can help me. I am thinking of just downloading a virtual box and running Geant4 on Ubuntu.

If anyone was able to successfully run Geant4 on MacOS and is able to help, I would greatly appreciate it.

Thank you,

Khalil

Did you rebuild? When you change a cmake option you have to do a complete rebuild.

I mean a rebuild of Geant4, not just your app.

Yes, I repeated the installation process from the beginning.

Mmm. Strange. Can you let us have some more details - cmake options, all warnings and error message. What is your app - exampleB1? Let us see your main program. Did you run the app in the same (sub-)directory as the macro vis.mac?

Yes I am running Example B1 and I am running the program in a build directory inside the GEANT4/geant4-v11.2.1-install/share/Geant4/examples/basic/B1 directory.
The only error message I get is when the visualization starts, XQuarts opens up and I get this error message:
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Invoked command has failed - see above.
Error code : 1
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

***** Illegal parameter (1) </vis/open> *****

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

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

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

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

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

I am not sure what should be done to fix it. I have all the required packages.

Thank you for the help.

Hi. Let us have a look at your main program, and what Geant4 prints at startup, particularly what graphics systems are registered.

This is what I get once I run the program:

khalilelachi@wifi-student23-nat-inside-591 build % ./exampleB1
Available UI session types: [ tcsh, csh ]


Geant4 version Name: geant4-11-02-patch-01 [MT] (16-February-2024)
<< in Multi-threaded mode >>
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/


<<< Reference Physics List QBBC
Visualization Manager instantiating with verbosity “warnings (3)”…
Visualization Manager initialising…
Registering graphics systems…

You have successfully registered the following graphics systems.
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)
OpenGLImmediateX (OGLIX, OGLI)
OpenGLStoredX (OGLSX, OGL, OGLS)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG)
Default graphics system is: OGL (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.

Registering model factories…

You have successfully registered the following model factories.
Registered model factories:
generic
drawByAttribute
drawByCharge
drawByOriginVolume
drawByParticleID
drawByEncounteredVolume

Registered models:
None

Registered filter factories:
attributeFilter
chargeFilter
originVolumeFilter
particleFilter
encounteredVolumeFilter

Registered filters:
None

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
“/vis/list” to see available colours.
/control/saveHistory
/run/verbose 2

Change the default number of threads (in multi-threaded mode)

#/run/numberOfThreads 4

Initialize kernel

/run/initialize

==========================================================================================
G4TaskRunManager :: Using G4ThreadPool…

It doesn’t say that any graphics system is registered. I tried doing it again with OLG, OLGS, OLGIX, RayTracer, but neither one worked.

Apologies it does say that multiple graphics systems are registered but not one in particular.

Now during the build of Geant4 I did the following:
cmake -DGEANT4_USE_OPENGL_X11=ON -DCMAKE_INSTALL_PREFIX=/path/to/geant4-v11.2.0-install /path/to/geant4-v11.2.0 …

But I read somewhere that I should also add:
cmake -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON -DCMAKE_INSTALL_PREFIX=/path/to/geant4-v11.2.0-install /path/to/geant4-v11.2.0

would that help? Should I repeat the process again with these turned on?

Yes, indeed. So, for example, /vis/open OGL, or even /vis/open (without any parameters), should open an OpenGLStoredX window. So I cannot explain - indeed it is outright strange - that
***** Illegal parameter (1) </vis/open> *****

What parameter are you supplying to /vis/open? Have you edited the vis.mac file?

Well, yes - if you want Qt. But we have not explained why OpenGLStoredX does not work.

John

I have kept the vis.mac file as it is. but nothing worked. The XQuarts app opens up but shows nothing. Then I tried to edit it using /vis/open and tried all the options listed above individually but neither one of them works. Some doesn’t give any errors, it runs normally like RayTracer, but the XQuarts app doesn’t launch. Whilst others like the OGL ones open the XQuarts app but it gives the error listed above. Each time, I empty the build directory, cmake, make, and …/exampleB1
But unfortunately, it doesn’t work. Now I have installed a Virtual Box and am currently running geant4 on it using micromamba. But would like to work on geant4 on my mac instead. So if you still have any suggestions, I’d appreciate it.

Thank you

OK. That shows me it’s an X problem. I too am on macOS Sonoma 14. I build with Quartz (-DGEANT4_USE_OPENGL_X11=ON) but also with Qt (-DGEANT4_USE_QT=ON), so I have not tried the X11 option. When I do, I get

  /vis/open OGLSX
  /vis/sceneHandler/create OGLSX
  /vis/sceneHandler/attach
  /vis/viewer/create ! ! 600x600-0+0
G4OpenGLXViewer::G4OpenGLXViewer: unable to get a single buffer visual.
G4OpenGLXViewer::G4OpenGLXViewer: unable to get a double buffer visual.
G4OpenGLXViewer::G4OpenGLXViewer: unable to get required visuals.
G4OpenGLStoredX::CreateViewer: error flagged by negative view id in G4OpenGLStoredXViewer creation.
 Destroying view and returning null pointer.
ERROR in G4VisManager::CreateViewer: null pointer during OpenGLStoredX viewer creation.
  No action taken.

So, definitely, there’s an X11 (Quartz) problem in Sonoma.

OK. So, like me, try Qt (-DGEANT4_USE_QT=ON). Then use /vis/open (without parameters).

I installed QT with homebrew:

brew install qt@5

If you want to move to Qt6 (add -DGEANT4_USE_QT_QT6=ON), OpenGL is not currently available and you should use TOOLSSG. But /vis/open (without parameters should handle that).

Hope that’s helpful
John

Alright so I will remove X11 from the cmake, does that mean I have to build (cmake, and make) Geant4 from the start?

I rebuild Geant4 from the start with -DGEANT4_USE_QT=ON, and when I run the executable file, it opens up and a graphics app opens. But I get this error:

Have you ever encountered this? Is there a way to fix it? It appears on all examples. I have tried 4 of them already all show the same error.

OK, that’s progress.

That G4Exception shows you have not set GEANT4_DATA_DIR or not downloaded the database files. Let me refer you back to the Installation Guide, Environment Variables for Datasets, Postinstall Setup — Geant4 Installation Guide 11.2 documentation.

John

Hello, just would like to let you know that it worked fully.
I repeated the process again with the updates source file version 11.2.1 and it worked fully.

Thank you for the help, I appreciate it!

:+1: You’re welcome.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.