add per-step kinematics ntuple ("Steps") to ROOT output
Adds a second ntuple alongside the existing "Hits" ntuple with one row per Geant4 step. Records event_id, track_id, step_no, PDG code, and pre/post position + kinetic energy for every step in the simulation. Also extends run_batch() with return_steps=False; when True, returns (hits_mf, steps_mf) instead of just hits_mf. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-4
@@ -334,7 +334,8 @@ def run_batch(
|
||||
maxEnergy_GeV: float = -1.0,
|
||||
filename: str = "",
|
||||
no_mp: bool = False,
|
||||
manual_seed : int = -1):
|
||||
manual_seed : int = -1,
|
||||
return_steps: bool = False):
|
||||
"""
|
||||
Run a full Geant4 simulation batch with automatic parallelisation.
|
||||
|
||||
@@ -361,12 +362,17 @@ no_mp : bool, optional
|
||||
Disable multiprocessing (run single-threaded) for debugging.
|
||||
manual_seed : int, optional
|
||||
Optional random seed. If < 0, seeds are generated automatically.
|
||||
return_steps : bool, optional
|
||||
If True, also return a MiniFrame of step-level data (one row per
|
||||
Geant4 step across all events). Returns a tuple (hits, steps).
|
||||
|
||||
Returns
|
||||
-------
|
||||
MiniFrame
|
||||
Table-like structure with one row per event, containing both scalar
|
||||
values and fixed-size sensor arrays.
|
||||
MiniFrame or tuple[MiniFrame, MiniFrame]
|
||||
If return_steps is False (default): event-level MiniFrame with one
|
||||
row per event. If return_steps is True: (hits, steps) where steps
|
||||
has one row per Geant4 step with columns event_id, track_id,
|
||||
step_no, pdg, pre_x/y/z, pre_E, post_x/y/z, post_E.
|
||||
|
||||
Notes
|
||||
-----
|
||||
@@ -463,6 +469,9 @@ Example
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
print('G4Calo: concatenation finished after {:.2f} seconds'.format(sw.elapsed()))
|
||||
if return_steps:
|
||||
steps_df = _assemble_results_to_mini_df(rp, tree_name="Steps")
|
||||
return df, steps_df
|
||||
return df
|
||||
|
||||
def _fill_event(gd : GeometryDescriptor,
|
||||
|
||||
Reference in New Issue
Block a user