Gate icon indicating copy to clipboard operation
Gate copied to clipboard

Visualisation bug with Geant4 v11

Open tbaudier opened this issue 2 years ago • 3 comments

Describe the bug With Geant4 v11, the visualisation is not correct: eg: the world wireframes are not display

Desktop (please complete the following information):

  • OS: MacOs 12.3.1 and Linux
  • Gate version or commit hash: develop branch
  • Geant4 version: 11.0.0
  • Root version: 6.24.06
  • compiler version: clang 13.1.6

Minimal example main.mac:

## visu
/vis/open                     OGLI
/vis/drawVolume
/vis/viewer/flush
/tracking/storeTrajectory     1
/vis/scene/add/trajectories
/vis/scene/endOfEventAction   accumulate

/vis/scene/add/axes            0 0 0 500 mm
/vis/scene/add/text            10 0 0 cm  20 0 0   X
/vis/scene/add/text            0 10 0 cm  20 0 0   Y
/vis/scene/add/text            0 0 10 cm  20 0 0   Z


## verbose
/control/verbose 0
/run/verbose 0
/event/verbose 0
/tracking/verbose 0
/gate/application/verbose 0
/gate/generator/verbose   0
/gate/source/verbose      0
/gate/random/verbose      0
/gate/output/verbose      0
/gate/verbose Physic      0
/gate/verbose Cuts        1
/gate/verbose SD          0
/gate/verbose Actions     0
/gate/verbose Actor       0
/gate/verbose Step        0
/gate/verbose Error       0
/gate/verbose Warning     0
/gate/verbose Output      0
/gate/verbose Beam        1
/gate/verbose Volume      1
/gate/verbose Image       0
/gate/verbose Geometry    1
/gate/verbose Core        1


## world
/gate/geometry/setMaterialDatabase GateMaterials.db
/gate/world/geometry/setXLength 2 m
/gate/world/geometry/setYLength 2 m
/gate/world/geometry/setZLength 2 m
/gate/world/vis/setColor white
/gate/world/vis/forceWireframe
/gate/world/setMaterial Air

## initialize
/gate/run/initialize

Expected behavior With Geant4 10.7, we can see the world wireframe: Screenshot 2022-04-20 at 12 58 06

With Geant4 v11.0, we cannot see the wireframe anymore: Screenshot 2022-04-20 at 13 00 09

Moreover with Geant4 v11.0, we can see a warning:

...
[Core-0] Initialization of geometry

-------- 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_phys:0 BasePath: TOP" is no longer valid - being removed
  from scene "scene-0"
[Core-0] Initialization of physics
...

Additional context It seems the bug come from that function in Geant4: https://github.com/Geant4/geant4/blob/master/source/visualization/modeling/src/G4PhysicalVolumeModel.cc#L835

With Geant4 v11, this part of the code is new https://github.com/Geant4/geant4/blob/v11.0.0/source/visualization/modeling/src/G4PhysicalVolumeModel.cc#L837-L854 Before, with Geant4 v10.7, it was that part of the code that was used: https://github.com/Geant4/geant4/blob/v10.7.3/source/visualization/modeling/src/G4PhysicalVolumeModel.cc#L792-L841

Maybe the world is not added to G4PhysicalVolumeStore

tbaudier avatar Apr 20 '22 11:04 tbaudier

To complete, I found that the pointer in Geant4 "fpTopPV" is initialized in Gate and deleted and created again in Gate when you execute "/gate/run/initialize" here without be updated in Geant4.

A workaroud is to write the visualization part after "/gate/run/initialize" in the macro. For example: main.mac:

## verbose
/control/verbose 0
/run/verbose 0
/event/verbose 0
/tracking/verbose 0
/gate/application/verbose 0
/gate/generator/verbose   0
/gate/source/verbose      0
/gate/random/verbose      0
/gate/output/verbose      0
/gate/verbose Physic      0
/gate/verbose Cuts        1
/gate/verbose SD          0
/gate/verbose Actions     0
/gate/verbose Actor       0
/gate/verbose Step        0
/gate/verbose Error       0
/gate/verbose Warning     0
/gate/verbose Output      0
/gate/verbose Beam        1
/gate/verbose Volume      1
/gate/verbose Image       0
/gate/verbose Geometry    1
/gate/verbose Core        1


## world
/gate/geometry/setMaterialDatabase GateMaterials.db
/gate/world/geometry/setXLength 2 m
/gate/world/geometry/setYLength 2 m
/gate/world/geometry/setZLength 2 m
/gate/world/vis/setColor white
/gate/world/vis/forceWireframe
/gate/world/setMaterial Air

## initialize
/gate/run/initialize

## visu
/vis/open                     OGLI
/vis/drawVolume
/vis/viewer/flush
/tracking/storeTrajectory     1
/vis/scene/add/trajectories
/vis/scene/endOfEventAction   accumulate

/vis/scene/add/axes            0 0 0 500 mm
/vis/scene/add/text            10 0 0 cm  20 0 0   X
/vis/scene/add/text            0 10 0 cm  20 0 0   Y
/vis/scene/add/text            0 0 10 cm  20 0 0   Z


tbaudier avatar Apr 22 '22 14:04 tbaudier

Visu must be after initialize

  • to put in docs
  • check bench and contrib to modify the visu line (to put after the init)

dsarrut avatar May 03 '22 12:05 dsarrut

The bug still exist with CT image. But with visu before initialize and without the axis:

#/vis/scene/add/axes            0 0 0 500 mm
#/vis/scene/add/text            10 0 0 cm  20 0 0   X
#/vis/scene/add/text            0 10 0 cm  20 0 0   Y
#/vis/scene/add/text            0 0 10 cm  20 0 0   Z

Everything works

tbaudier avatar Jul 05 '22 13:07 tbaudier