Example B1 doesn't show trajectory and dies after /run/beamOn

Hello! Geant4 newbie here. I am trying to run example B1 by executing the following in my B1-build folder.

cmake ../B1
make -j6
./B1

It seems to be successfully built and I can open the executable and see the UI. I can play around with some features (viewer settings, make it print/list things, etc), but when I input /run/beamOn, no trajectory shows up no matter what number I put after that. Here’s what I see in the terminal after /run/beamOn 5:

### Run 0 starts.
G4WT1 > /tracking/storeTrajectory 2
G4WT1 > /material/g4/printMaterial [<pmat>]
G4WT1 > /material/g4/printMaterial all
G4WT0 > /tracking/storeTrajectory 2
G4WT0 > /material/g4/printMaterial [<pmat>]
G4WT0 > /material/g4/printMaterial all
G4WT0 > ### Run 0 starts on worker thread 0.
G4WT1 > ### Run 0 starts on worker thread 1.
G4WT1 > Thread-local run terminated.
G4WT1 > Run Summary
G4WT1 >   Number of events processed : 2
G4WT1 >   User=0.000000s Real=0.002086s Sys=0.000000s [Cpu=0.0%]
G4WT1 > 
G4WT1 > --------------------End of Local Run------------------------
G4WT1 >  The run consists of 2 gamma of 6 MeV
G4WT1 >  Cumulated dose per run, in scoring volume : 0.0124597 picoGy  rms = 0.00881034 picoGy 
G4WT1 > ------------------------------------------------------------
G4WT0 > Thread-local run terminated.
G4WT1 > 
G4WT0 > Run Summary
G4WT0 >   Number of events processed : 3
G4WT0 >   User=0.010000s Real=0.013829s Sys=0.000000s [Cpu=72.3%]
G4WT0 > 
G4WT0 > --------------------End of Local Run------------------------
G4WT0 >  The run consists of 3 gamma of 6 MeV
G4WT0 >  Cumulated dose per run, in scoring volume : 0 picoGy  rms = 0 picoGy 
G4WT0 > ------------------------------------------------------------
G4WT0 > 
 Run terminated.
Run Summary
  Number of events processed : 5
  User=0.060000s Real=0.095087s Sys=0.010000s [Cpu=73.6%]

--------------------End of Global Run-----------------------
 The run consists of 5 
 Cumulated dose per run, in scoring volume : 0.0124597 picoGy  rms = 0.0111443 picoGy 
------------------------------------------------------------

The UI would simply freeze:

I don’t get an error message so I’m not sure where to look at. I would really appreciate your help!

P.S. here are my build options if relevant:
-DGEANT4_USE_GDML=ON -DCMAKE_BUILD_TYPE=Debug -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_XM=ON -DGEANT4_USE_QT=ON -DGEANT4_BUILD_MULTITHREADED=ON

Thanks again!
Chloe

Hi Chloe

It looks like you are doing everything right, but maybe your graphics driver needs updating. Search for updates to your graphics driver for your hardware for your Operating System.

John

Hi John, thank you for your reply!

I’m running Geant4 on a Ubuntu virtualbox and my host OS is windows 10. I just reinstalled the virtualbox guest additions and made sure that the graphic drivers on my windows are up to date. Unfortunately the UI still dies after /run/beamOn :disappointed_relieved:

Is there anything else I could look at? Thanks again!

Hi Chloe

Our experience with Ubuntu virtualbox is good. Normally no problem. I see you build in Debug mode - great. Can you get a traceback with a debugger (e.g., gdb), to find out where it dies? Instead of ./B1, type gdb ./B1 and when it dies, type where.

John

Hi John,

Thanks again for your reply! I used the debugger and terminated the run when the UI froze. I then checked info threads and where. Here’s what I got (sorry for the length of the result :face_with_hand_over_mouth:).

The last line suggests that it died at line 96 of exampleB1.cc, which says ui->SessionStart(); . Is the problem from my UI?

^C
Thread 1 "exampleB1" received signal SIGINT, Interrupt.
__pthread_clockjoin_ex (threadid=140736546375424, thread_return=0x0,
	clockid=<optimised out>, abstime=<optimised out>, block=<optimised out>)
	at pthread_join_common.c:145
145    pthread_join_common.c: No such file or directory.
(gdb) info threads
  Id   Target Id                                      	Frame
* 1	Thread 0x7fffee1f7b80 (LWP 2239) "exampleB1"   	__pthread_clockjoin_ex (threadid=140736546375424, thread_return=0x0, clockid=<optimised out>,
	abstime=<optimised out>, block=<optimised out>)
	at pthread_join_common.c:145
  2	Thread 0x7fffec899700 (LWP 2240) "QXcbEventQueue"  0x00007ffff5412aff in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
  3	Thread 0x7fffe6d01700 (LWP 2241) "gmain"       	0x00007ffff5412aff in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
  4	Thread 0x7fffe6500700 (LWP 2242) "gdbus"       	0x00007ffff5412aff in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
  5	Thread 0x7fffe5a9a700 (LWP 2243) "QDBusConnection" 0x00007ffff5412aff in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
  6	Thread 0x7fffe514c700 (LWP 2246) "exampleB1"   	futex_wait_cancelable
	(private=<optimised out>, expected=0, futex_word=0x55555584c750)
	at ../sysdeps/nptl/futex-internal.h:183
  7	Thread 0x7fffe494b700 (LWP 2247) "exampleB1"   	futex_wait_cancelable
	(private=<optimised out>, expected=0, futex_word=0x55555584c750)
	at ../sysdeps/nptl/futex-internal.h:183
  8	Thread 0x7fffc7da8700 (LWP 2251) "exampleB1"   	futex_wait_cancelable
	(private=<optimised out>, expected=0,
	futex_word=0x7ffff7c75688 <(anonymous namespace)::c2_VisSubThreadQtOpenGLContextMoved+40>) at ../sysdeps/nptl/futex-internal.h:183
(gdb) where
#0  __pthread_clockjoin_ex (threadid=140736546375424, thread_return=0x0,
	clockid=<optimised out>, abstime=<optimised out>, block=<optimised out>)
	at pthread_join_common.c:145
#1  0x00007ffff5731fe7 in std::thread::join() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007ffff7a7dcf5 in G4VisManager::EndOfRun (this=0x555555ef13b0)
	at /home/chloe/geant4/geant4.10.07/source/visualization/management/src/G4VisManager.cc:2202
#3  0x00007ffff7a9c67d in G4VisStateDependent::Notify (this=0x555555ef10f0,
	requestedState=G4State_Idle)
	at /home/chloe/geant4/geant4.10.07/source/visualization/management/src/G4VisStateDependent.cc:49
#4  0x00007ffff5ae9ec8 in G4StateManager::SetNewState (this=0x5555555ef5e0,
	requestedState=@0x7fffffffbf64: G4State_Idle, msg=0x0)
	at /home/chloe/geant4/geant4.10.07/source/global/management/src/G4StateManager.cc:164
#5  0x00007ffff5ae9dc8 in G4StateManager::SetNewState (this=0x5555555ef5e0,
	requestedState=@0x7fffffffbf64: G4State_Idle)
	at /home/chloe/geant4/geant4.10.07/source/global/management/src/G4StateManager.cc:138
#6  0x00007ffff714dea4 in G4RunManagerKernel::RunTermination (
	this=0x555555941030)
	at /home/chloe/geant4/geant4.10.07/source/run/src/G4RunManagerKernel.cc:872
#7  0x00007ffff713ab1a in G4RunManager::RunTermination (this=0x55555584c370)
	at /home/chloe/geant4/geant4.10.07/source/run/src/G4RunManager.cc:630
#8  0x00007ffff7141d39 in G4MTRunManager::RunTermination (this=0x55555584c370)
	at /home/chloe/geant4/geant4.10.07/source/run/src/G4MTRunManager.cc:496
#9  0x00007ffff71397be in G4RunManager::BeamOn (this=0x55555584c370,
	n_event=10, macroFile=0x0, n_select=-1)
	at /home/chloe/geant4/geant4.10.07/source/run/src/G4RunManager.cc:344
#10 0x00007ffff7155d1e in G4RunMessenger::SetNewValue (this=0x555555d00bc0,
	command=0x555555d01050, newValue=...)
	at /home/chloe/geant4/geant4.10.07/source/run/src/G4RunMessenger.cc:460
#11 0x00007ffff5b92d9b in G4UIcommand::DoIt (this=0x555555d01050,
	parameterList=...)
--Type <RET> for more, q to quit, c to continue without paging--RET
   4UIcommand.cc:262
#12 0x00007ffff5baa494 in G4UImanager::ApplyCommand (this=0x5555555ef2c0,
	aCmd=0x7fffffffc9e0 "/run/beamOn 10")
	at /home/chloe/geant4/geant4.10.07/source/intercoms/src/G4UImanager.cc:584
#13 0x00007ffff5ba9baa in G4UImanager::ApplyCommand (this=0x5555555ef2c0,
	aCmd=...)
	at /home/chloe/geant4/geant4.10.07/source/intercoms/src/G4UImanager.cc:481
#14 0x00007ffff762f870 in G4VBasicShell::ExecuteCommand (this=0x5555555eebb0,
	aCommand=...)
	at /home/chloe/geant4/geant4.10.07/source/interfaces/common/src/G4VBasicShell.cc:213
#15 0x00007ffff763027b in G4VBasicShell::ApplyShellCommand (
	this=0x5555555eebb0, a_string=..., exitSession=@0x7ffff76604c0: false,
	exitPause=@0x7ffff76604c1: true)
	at /home/chloe/geant4/geant4.10.07/source/interfaces/common/src/G4VBasicShell.cc:308
#16 0x00007ffff761370f in G4UIQt::CommandEnteredCallback (this=0x5555555eeba0)
	at /home/chloe/geant4/geant4.10.07/source/interfaces/basic/src/G4UIQt.cc:3820
#17 0x00007ffff75ffc50 in G4UIQt::qt_static_metacall (_o=0x5555555eeba0,
	_c=QMetaObject::InvokeMetaMethod, _id=3, _a=0x7fffffffcd20)
	at /home/chloe/geant4/geant4.10.07-build/source/G4interfaces_autogen/include/moc_G4UIQt.cpp:162
#18 0x00007ffff0dff300 in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff21be4a9 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff0dff300 in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007ffff21c4c85 in QWidgetLineControl::processKeyEvent(QKeyEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007ffff21b799f in QLineEdit::keyPressEvent(QKeyEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007ffff20b477d in QWidget::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff21bdd32 in QLineEdit::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff2071a66 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
	() from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#26 0x00007ffff207b81e in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#27 0x00007ffff0dd393a in QCoreApplication::notifyInternal2(QObject*, QEvent*)
	() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007ffff20d3216 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
--Type <RET> for more, q to quit, c to continue without paging--RET
#29 0x00007ffff2071a66 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
	() from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#30 0x00007ffff207b0f0 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#31 0x00007ffff0dd393a in QCoreApplication::notifyInternal2(QObject*, QEvent*)
	() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007ffff11bab2b in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#33 0x00007ffff11c00f1 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#34 0x00007ffff119a35b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#35 0x00007fffed13c32e in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#36 0x00007ffff00b117d in g_main_context_dispatch ()
   from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007ffff00b1400 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007ffff00b14a3 in g_main_context_iteration ()
   from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#39 0x00007ffff0e2b565 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#40 0x00007ffff0dd24db in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#41 0x00007ffff0dda246 in QCoreApplication::exec() ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#42 0x00007ffff760508b in G4UIQt::SessionStart (this=0x5555555eeba0)
	at /home/chloe/geant4/geant4.10.07/source/interfaces/basic/src/G4UIQt.cc:1922
#43 0x00007ffff75f6d73 in G4UIExecutive::SessionStart (this=0x5555555ee500)
	at /home/chloe/geant4/geant4.10.07/source/interfaces/basic/src/G4UIExecutive.cc:309
#44 0x000055555555d3c7 in main (argc=1, argv=0x7fffffffdb78)
	at /home/chloe/workspace/G4WORK/B1/exampleB1.cc:96

Hi Chloe

Interesting. Not seen anything like this before. L.96 of exampleB1.cc is where the thread of control starts - where it ends is what we’re interested in.

So you had to hot CTRL-C get stop it. When you said the program died, it wasn’t a crash, it was “hanging”. At G4VisManager.cc:2202 the vis manager waits for the vis sub-thread to finish drawing the event(s). But in you original posting, it looks like the run terminated normally.

Could you try to run without Qt. No need to rebuild. Just
G4UI_USE_TCSH=1 ./B1
That should open an OpenGL Xm window.

If that works OK, I suspect something wrong with the Qt installation. I see you are using Qt5 - fine. Do not use Qt6. But make sure you have the latest version of Qt5.

Sorry not to be more helpful.

John

Hi John,

Running without Qt works (although I needed to set G4UI_USE_XM=1 first)! I can see the beams now and the code runs successfully . Thank you so much! You’ve been super helpful.

I have the latest version of Qt5. Do I need additional development tools and libraries for it? I also have Qt4 installed - could it somehow mess things up? I’m happy with using OpenGL Xm for now, but if I want to use Qt, and if I have its installation sorted out, do I need to reinstall Geant4 to see if it has worked?

Hi Chloe

Glad you got something working. Ah, yes. G4UI_USE_XM=1 gets you the Xm GUI, which was an early attempt at a GUI before Qt came along.

Re Qt5, the Installation Guide says, “See the CMAKE_PREFIX_PATH variable under Advanced Options if CMake has trouble locating Qt.” I have

-DQT_QMAKE_EXECUTABLE=~/Qt/5.15.0/clang_64/bin/qmake \
-DCMAKE_PREFIX_PATH="~/Qt/5.15.0/clang_64" \

to make sure I pick out the right installation.

Having Qt4 around shouldn’t be a issue - but it would not hurt to remove it. Install Qt5 - I think no other tools needed. On a general point, whenever you change the CMake arguments, or re-install libraries on which Geant4 depends, you should run cmake again and make -j8 (or whatever) again.

John