You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨ Issue: Export Geant4 Simulation Events to JSON for 3D Web Visualization
🎯 Goal
Enable the visualization of selected Geant4 simulation events (including full secondary particle showers) in a modern 3D web environment (e.g., using three.js).
This requires exporting complete event-level tracking data (trajectory points per particle) from ROOT trees into a single structured JSON file.
📋 Current State
Event data is stored in TTree structures, using G4AnalysisManager.
Per-step data (position, energy, time, track info) is already collected in vectors:
e.g., m_VoxelHitsTrkId, m_VoxelHitsTrkEnergy, m_VoxelHitsTrkPosX/Y/Z, etc.
However, ParentID information is missing, which is needed to reconstruct particle shower trees (γ → e⁻/e⁺ → ...).
📦 Task Overview
🔧 [C++] Extend Tracking and NTuple Output
In SteppingAction or hit creation logic, capture G4Track::GetParentID() for each step.
Add a new vector (e.g., m_VoxelHitsParentTrkId) and include it in the NTuple output.
Optionally, capture G4Track::GetDefinition()->GetPDGEncoding() and/or name for particle typing.
🧪 [Python] Write PyROOT-based Export Script
Use PyROOT to load the .root file and access TTrees.
Group all hits/steps by (G4EvtId, TrackId) to form trajectories.
For each trajectory:
Store ordered 3D positions and times.
Include TrackId, ParentId, ParticleType.
Dump all selected events into a single events.json file with a structure like:
✨ Issue: Export Geant4 Simulation Events to JSON for 3D Web Visualization
🎯 Goal
Enable the visualization of selected Geant4 simulation events (including full secondary particle showers) in a modern 3D web environment (e.g., using
three.js).This requires exporting complete event-level tracking data (trajectory points per particle) from ROOT trees into a single structured JSON file.
📋 Current State
Event data is stored in
TTreestructures, usingG4AnalysisManager.Per-step data (position, energy, time, track info) is already collected in vectors:
m_VoxelHitsTrkId,m_VoxelHitsTrkEnergy,m_VoxelHitsTrkPosX/Y/Z, etc.However, ParentID information is missing, which is needed to reconstruct particle shower trees (γ → e⁻/e⁺ → ...).
📦 Task Overview
🔧 [C++] Extend Tracking and NTuple Output
SteppingActionor hit creation logic, captureG4Track::GetParentID()for each step.m_VoxelHitsParentTrkId) and include it in the NTuple output.G4Track::GetDefinition()->GetPDGEncoding()and/or name for particle typing.🧪 [Python] Write PyROOT-based Export Script
Use
PyROOTto load the.rootfile and access TTrees.Group all hits/steps by
(G4EvtId, TrackId)to form trajectories.For each trajectory:
TrackId,ParentId,ParticleType.Dump all selected events into a single
events.jsonfile with a structure like:{ "event_id": 42, "particles": [ { "track_id": 1, "parent_id": 0, "pdg": 22, "name": "gamma", "trajectory": [ { "x": ..., "y": ..., "z": ..., "t": ... }, ... ] }, ... ] }🌐 [Frontend] Basic
three.jsRenderer (later step)events.jsonand render each particle as a colored trajectory line.parent_idrelations as shower trees or via color-coding.process_type_idand 'electron_origin_type_id'/'particle_origin_type_id' in shower trees or via color-coding. (📁 Output Format (Single File)
Output will be a JSON file:
all_events.json(list of events with particle trajectories)🧠 Notes / Considerations
TrackId == 1hasParentId == 0, we assume it's a primary.🛠 Tools
G4AnalysisManager)three.js