Weird GUI display after modifying geometry with UI commands in Geant4 11

Similar problem to GUI crashed after modifying geometry with UI commands in Geant4 11 example AnaEx01

When running a macro, the geometry in the visualisation disappears (but not particle paths) if the macro contains any lines that modify the geometry. The following warning occurs in the output

QObject::connect: No such signal QTabWidget::tabCloseRequested(G4int)
QObject::connect: No such signal QTabWidget::currentChanged(G4int)
QObject::connect: No such signal QTabWidget::currentChanged(G4int)
QObject::connect: No such signal QComboBox::activated(G4int)


WARNING: Trajectory storing has been requested.  This action may be
  reversed with "/tracking/storeTrajectory 0".
 Changing export format to "jpg"

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : modeling0015
      issued by : G4PhysicalVolumeModel::Validate
Attempt to validate a volume that is no longer in the physical volume store.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

WARNING: Model "G4PhysicalVolumeModel World:0 BasePath: TOP" is no longer valid - being removed
  from scene "scene-0"

Removing the lines


from the Construct method in DetectorConstruction stops the geometry from disappearing. However then the displayed geometry doesn’t seem to match the geometry that the photons are interacting with.

This is after running a macro that increases the length of the fibre I am simulating. The displayed geometry is the default, but the photons are propagating through the longer fibre that is set by the macro.

Note: When I run the macro in batch mode the warning does not appear.

This problem was occurring with Geant4-11.1.0, I tried upgrading to 11.1.1 (Release Geant4 11.1.1 · Geant4/geant4 · GitHub) as the post I referred to above said this problem would be fixed in the next release, however it is still occurring.

Hi Josh

Quick response…

It will take me a little time to look into this again, but may I just check you have followed the “rules” about changing geometry between runs - Dynamic Geometry Setups — Book For Application Developers 11.1 documentation? In particular, after changing the geometry, do you call


Sorry to ask such basic questions. I will take another look tomorrow.


Hey John,

Yep, I do. Here’s the function that is called by the build line in my macro:

G4VPhysicalVolume *DetectorConstruction::Construct() {


    fMaterials = Materials::GetInstance();


    auto newGeom = ConstructDetector();

    return newGeom;

Thanks for the quick response!

I am having the same problem with the exact same error messages from Qt.
I am however not changing the geometry on the fly, so the overall problem might be unrelated to that or my problem might be a different one.
I am using a simulation that used to run on 10.7.3. I updated to 11.01.01 with minimal modifications and now run into this error.

Mmm, Puzzling. What version of Qt are you using?

I am using Qt 5.15.3

OK, I’ll try downloading 11.1.1, perhaps from GitHub just in case there’s a problem there. Can either of you let me have a set of macro that display the problem in a Geant4 example? But I’m afraid this will not be before the weekend.

Otherwise, I’m out of ideas. I’m happy for anyone else to come in with ideas.

Hi and thank you.
I did not get it from GitHub directly but from the download page. More precisely this file or the tar.gz one.

Here is a simulation that exhibit the problem : Nextcloud
Just compile and launch ./SpectrumShaper and the error will show.
This simulation is not currently working in batch mode, but for totally unrelated reasons and only if you start to track a particle, as I am still in the process of having it to work on the newest Geant4.
I will update the file as soon as I have a working version.

BTW, I do not know if those are useful information but examples are working and Qt Viewer is working fine with them (for example B4c), and I compiled Geant4 with the c++17 standard as my version of ROOT requires it.

Hi Rodolphe

Still looking into it, but here are some comments so far.

  • It takes over 30 mins to initialise. What is it doing? If I pause, it always seems to be at
  return std::norm(2 * std::sqrt(costheta2) /
                   (std::sqrt(costheta2) + std::sqrt(std::complex<G4double>(costheta2 - klk2))));

Why do you need std::complex here?

  • gui.mac executes vis.mac, so vis.mac is executed twice. Not a serious problem.
  • To write a root file you don’t need ROOT. So I removed it from CMakeLists.txt:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29 +29 @@ include(${Geant4_USE_FILE})
-find_package(ROOT REQUIRED)
+#find_package(ROOT REQUIRED)
@@ -47 +47 @@ add_executable(SpectrumShaper ${sources} ${headers})
-target_link_libraries(SpectrumShaper ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
+target_link_libraries(SpectrumShaper ${Geant4_LIBRARIES} )

I also had to remove a couple of unnecessary #include statements:

--- a/include/SpectrumShaperActionInitialization.hh
+++ b/include/SpectrumShaperActionInitialization.hh
@@ -34 +34 @@
-#include <TFile.h>
+// #include <TFile.h>
--- a/src/
+++ b/src/
@@ -67 +67 @@
-#include <TMath.h>
+//#include <TMath.h>
  • The view looks fine, but if I /run/beamOn, I get a crash at
	analysisManager->FillNtupleDColumn(0, pv->GetX0());

I’m looking into this. Any thoughts?


OK, you can’t have ntuples without linking to ROOT, it seems. I don’t have ROOT, so I simply commented out the analysisManager->FillNtupleDColumn statements.

Then /control/execute iso.mac and /run/beamOn 100 gives attached image. Looks OK?

So…what exactly am I looking for? When you say

how exactly do I do that? I don’t see any such commands in the supplied macros, and I don’t see any geometry-modifying commands in the commands create (of course, I may have missed them).

So that’s where it stands at the moment. Over to you.


Hi John,

I don’t have ROOT

Usually makes life easier…

how exactly do I do that? I don’t see any such commands in the supplied macros, and I don’t see any geometry-modifying commands in the commands create (of course, I may have missed them).

The command is user defined, the definition is

void DetectorConstruction::updateGeom() {
	/// reset geometry

	/// update LS properties

	/// issue flag to re-optimize geometry and physics before to run
	/// debug: check the material associated to LS logical volume
	G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
	G4int                nLV       = pLVStore->size();
	G4int                iLV       = 0;
	G4LogicalVolume      *pLV      = nullptr;

Thank you for getting back to me!


How do I get the app to call DetectorConstruction::updateGeom?

Hi Allison,
thank you for working on that.
Sorry for answering so late, I was blocked by the 3-reply limit for new users
Following the same steps as you (commenting everything ROOT related and unnecessary includes), I still run in the same exact Qt problem.

However, I noticed today a warning during cmake: “Disabling Geant4 Qt3D driver, missing Qt packages: Qt53DCore;Qt53DExtras;Qt53DRender”.
I think this is the cause of my problem. I will install those and keep you informed.
This may also be the answer to JCCPort problem.

It takes over 30 mins to initialise. What is it doing? If I pause, it always seems to be at

I do not know what it is doing, but MicroRoughness model indeed take a long time to initialise.

Here is an update.
I installed some additional libraries and the “Disabling Geant4 Qt3D driver, missing Qt packages: Qt53DCore;Qt53DExtras;Qt53DRender” warning disappeared, but I still have the same Qt Error.

Hi Rodolfe

Have you rebuilt Geant4? You need to rebuild from scratch.


Yes I emptied my build folder, redid the cmake, recompiled and reinstalled. I do not have the warning anymore but still the same error.
I will do it again just in case.

I got the same Qt errors.
Would you be interested in a copy of the Geant4 and application cmake and make logs?

Are the “Qt errors” preventing the good/correct running of your app?

No, it only prevents me from opening a viewer.
The simulation runs correctly if I run in batch mode.