Skip to content

Commit 0f64271

Browse files
committed
several changes to address geometry reload and run
1 parent 1ca2aac commit 0f64271

2 files changed

Lines changed: 103 additions & 2 deletions

File tree

dbselect/examples/simple_flux.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
# Creates the simple_flux system used by test_reload_sequence.
3+
# World half-size = 150 mm so the proton gun at z = -100 mm is inside.
4+
from pygemc import autogeometry, GVolume
5+
6+
cfg = autogeometry("examples", "simple_flux")
7+
8+
gvolume = GVolume('root')
9+
gvolume.description = 'World'
10+
gvolume.make_box(150.0, 150.0, 150.0)
11+
gvolume.material = 'G4_AIR'
12+
gvolume.color = 'ghostwhite'
13+
gvolume.style = 0
14+
gvolume.publish(cfg)
15+
16+
gvolume = GVolume('FluxPlane')
17+
gvolume.mother = 'root'
18+
gvolume.description = 'Flux Scoring Plane'
19+
gvolume.make_box(120.0, 120.0, 0.5)
20+
gvolume.material = 'G4_AIR'
21+
gvolume.color = 'FAFAD2'
22+
gvolume.set_position(0, 0, 50)
23+
gvolume.digitization = 'flux'
24+
gvolume.set_identifier('flux_plane', 1)
25+
gvolume.publish(cfg)

releases/0.3.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,60 @@ This version includes:
2323
startup splash to remain visible briefly before closing.
2424
- Fixed setup-tab geometry reloads so the Volumes tab is rebuilt from the
2525
reloaded detector geometry.
26-
- Suppressed empty-scene Geant4 visualization warnings when starting `gemc -gui`
27-
without a selected system.
26+
- Reopened the Geant4 GUI scene during setup-tab reloads so reloaded geometry is
27+
displayed before running events.
28+
- Rebuilt setup-tab geometry immediately for display/Volumes updates, then
29+
reinitialized through Geant4 before Run so MT workers use a fresh world.
30+
- Synchronized setup-tab system selection back into runtime options so pressing
31+
Run after Reload uses the same geometry shown in the display.
32+
- Deferred Geant4 initialization when starting `gemc -gui` without a selected
33+
system, preventing synthetic ROOT-world visualization state before setup-tab
34+
reloads.
35+
- Fixed GUI Geant4 output splitting by normalizing line endings before board
36+
logging instead of using a newline regular expression.
37+
- Allowed `gemc -gui` to open with an empty setup tab when the default
38+
`gemc.db` is not present, instead of exiting with SQLite error code 209.
39+
- Allowed the Volumes tab to start empty when no Geant4 world has been built,
40+
avoiding a fatal pre-window geometry-map lookup.
41+
- Generated the installed examples SQLite database during `meson install` so
42+
the GUI setup tab is populated after a normal install.
43+
- Initialized the Geant4 run manager during the GUI pre-run geometry handoff so
44+
`BeamOn` is not ignored after setup-tab reloads.
45+
- Rebuilt setup-tab run geometry from fresh system descriptors so preview
46+
reloads do not leave factory-populated systems that duplicate ROOT volumes at
47+
`BeamOn`.
2848
- Isolated ROOT linkage to the ROOT gstreamer plugin so the main `gemc`
2949
executable can run without ROOT shared libraries.
50+
- Fixed GUI crash (SIGABRT in `G4ToolsSGSceneHandler::GetOrCreateNode`) when
51+
reloading geometry after running events: `refreshGeometryTree` now tracks
52+
whether a viewer already exists and skips `/vis/open` on subsequent reloads,
53+
avoiding a second viewer creation that triggers a synchronous ToolsSG refresh
54+
before the Qt widget is ready.
55+
- Fixed hits not recorded after GUI setup-tab reload or on the second and
56+
subsequent BeamOn calls: introduced a `digiplugins_need_reload` flag in
57+
`GDetectorConstruction` so `loadDigitizationPlugins()` (which clears the
58+
shared digitization-routines map) runs only when geometry actually changed,
59+
not on every `ConstructSDandField()` invocation during routine BeamOn
60+
re-initialization. In Geant4 task-parallel MT, `RunInitialization()` can
61+
overlap with workers already in their event loop; the previous code cleared
62+
the shared map while workers were between `BeginOfRunAction` (which saw the
63+
map populated and opened streamers) and `EndOfEventAction` (which then found
64+
the map empty), causing a fatal "no digitization routine registered" error.
65+
The flag is reset to `true` by `reload_geometry()` and
66+
`prepare_geometry_for_run()` so that the next `ConstructSDandField()` on the
67+
master thread refreshes the map exactly once per geometry change.
68+
- Fixed crash ("no digitization routine registered for collection X") when
69+
running events after switching geometries in the GUI setup tab: Geant4's
70+
`G4SDManager` accumulates sensitive detectors across geometry reloads and
71+
fires `Initialize()` on all of them at the start of every event, even those
72+
no longer attached to any volume in the current geometry. These stale
73+
detectors create empty hit collections that appear in `G4HCofThisEvent`.
74+
`EndOfEventAction` now skips any collection whose SD name is not in the
75+
current digitization-routines map with a non-fatal warning instead of
76+
terminating the process, so current-geometry hits are still processed
77+
correctly.
78+
- Cleared the digitization-routines map at the start of `loadDigitizationPlugins()` so that
79+
`emplace()` cannot silently reuse stale plugin objects from a prior load.
3080
- Removed the need for GEMC-specific environment variables in Python example
3181
workflows: the API runs through the `pygemc` module, and users only need the
3282
executable in `PATH`.
@@ -123,8 +173,34 @@ Both x86_64 and ARM64 platforms are supported.
123173
0.2-second startup splash duration from `gemc.cc`.
124174
- Emitted a setup-view geometry reload signal and used it to recreate the GUI
125175
volume tree page from `GDetectorConstruction::get_g4volumes_map()`.
176+
- Split setup-tab reload handling into an immediate GUI preview rebuild and a
177+
one-time non-propagating `G4RunManager::ReinitializeGeometry(true, false)`
178+
before `BeamOn`, avoiding stale world pointers during MT worker startup.
179+
- Removed stale Geant4 visualization models before pre-run geometry
180+
reinitialization.
181+
- Temporarily detached the concrete Geant4 visualization manager during pre-run
182+
geometry reinitialization so stale preview-world models are not dereferenced.
183+
- Updated the `gdetector` example to register detector construction with the
184+
Geant4 run manager before reload, matching the main executable setup.
185+
- Added a runtime option update helper and used it to keep the `gsystem` and
186+
`runno` options aligned with setup-tab reload selections.
126187
- Deferred visualization scene setup until startup or reloaded geometry contains
127188
displayable volumes.
189+
- Skipped the initial `/run/initialize` in GUI sessions that start without a
190+
`gsystem`, so setup-tab reloads install the first initialized geometry.
191+
- Replaced the GUI board newline regular expression with explicit line-ending
192+
normalization to avoid invalid `QRegularExpression` warnings.
193+
- Made setup-tab database discovery non-fatal at GUI construction time, leaving
194+
the setup view empty when the configured SQLite file is unavailable.
195+
- Added a detector-construction geometry-state check and used it to avoid
196+
querying Geant4 volumes before startup or setup reload has built a world.
197+
- Added an install script that rebuilds `examples/gemc.db` from the installed
198+
example geometry scripts using the installed `python_env`.
199+
- Made the GUI pre-run handoff remove stale visualization models, rebuild
200+
geometry, and call `G4RunManager::Initialize()` before event processing.
201+
- Kept GUI reload system selections descriptor-only and cloned fresh systems for
202+
each Geant4 construction, avoiding duplicate `root` volumes when running after
203+
a setup-tab reload.
128204
- Better generator statistics for some examples
129205
- Api and analyzer moved to pygemc module
130206
- Examples and tests adapted to use pygemc

0 commit comments

Comments
 (0)