add post-step momentum direction to Steps ntuple

Pre-step direction was already recorded; post_dx/dy/dz lets students
compare momentum direction before and after each step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 14:40:05 +02:00
parent 26821af188
commit 0adc896bce
3 changed files with 10 additions and 0 deletions
+1
View File
@@ -153,6 +153,7 @@ One row per Geant4 step. Every step of every track of every event is recorded.
| `layer_id` | `int` | Layer index at the pre-step point (-1 = outside all layers) |
| `material` | `string` | Material name at the pre-step point |
| `pre_dx/dy/dz` | `double` | Pre-step momentum unit direction |
| `post_dx/dy/dz` | `double` | Post-step momentum unit direction |
| `Bx/By/Bz` | `double` | Magnetic field at pre-step position [T] |
| `Ex/Ey/Ez` | `double` | Electric field at pre-step position [V/m] |
| `child_track_ids` | `int[]` | Track IDs of all secondaries spawned during this step (empty if none) |
+3
View File
@@ -111,6 +111,9 @@ RunAction::RunAction()
analysisManager->CreateNtupleDColumn("Ey"); // col 24 [V/m]
analysisManager->CreateNtupleDColumn("Ez"); // col 25 [V/m]
analysisManager->CreateNtupleIColumn("child_track_ids", stepChildIds); // col 26 (variable-length array)
analysisManager->CreateNtupleDColumn("post_dx"); // col 27
analysisManager->CreateNtupleDColumn("post_dy"); // col 28
analysisManager->CreateNtupleDColumn("post_dz"); // col 29
analysisManager->FinishNtuple();
// Spawning ntuple (one row per secondary born, ntuple id=2)
+6
View File
@@ -143,6 +143,12 @@ void SteppingAction::UserSteppingAction(const G4Step* step)
analysisManager->FillNtupleDColumn(1, 18, dir.y());
analysisManager->FillNtupleDColumn(1, 19, dir.z());
// G: post-step momentum direction (unit vector)
const auto postDir = post->GetMomentumDirection();
analysisManager->FillNtupleDColumn(1, 27, postDir.x());
analysisManager->FillNtupleDColumn(1, 28, postDir.y());
analysisManager->FillNtupleDColumn(1, 29, postDir.z());
// Field: B [T] and E [V/m] at pre-step position; zero if no field is registered
G4double Bx=0, By=0, Bz=0, Ex=0, Ey=0, Ez=0;
const auto* fm = G4TransportationManager::GetTransportationManager()->GetFieldManager();