G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTEventAction.cc
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2// Copyright (C) 2026 G4OCCT Contributors
3
5
7#include "G4OCCTRunAction.hh"
8
9#include <G4AnalysisManager.hh>
10#include <G4Event.hh>
11#include <G4SystemOfUnits.hh>
12
13G4OCCTEventAction::G4OCCTEventAction(const G4OCCTRunAction* runAction) : fRunAction(runAction) {}
14
15void G4OCCTEventAction::BeginOfEventAction(const G4Event* event) {
16 fEventId = event->GetEventID();
17 fTotalEdep = 0.0;
18 fTotalLength = 0.0;
19 fNTracks = 0;
20 fNSteps = 0;
21 fNPrimaries = 0;
22}
23
24void G4OCCTEventAction::EndOfEventAction(const G4Event* event) {
25 const G4int ntId = fRunAction->GetEventsNtupleId();
26 if (ntId < 0)
27 return;
28
29 auto* am = G4AnalysisManager::Instance();
30 G4int col = 0;
31 am->FillNtupleIColumn(ntId, col++, event->GetEventID());
32 am->FillNtupleDColumn(ntId, col++, fTotalEdep / MeV);
33 am->FillNtupleDColumn(ntId, col++, fTotalLength / mm);
34 am->FillNtupleIColumn(ntId, col++, fNPrimaries);
35 am->FillNtupleIColumn(ntId, col++, fNTracks);
36 am->FillNtupleIColumn(ntId, col++, fNSteps);
37 am->AddNtupleRow(ntId);
38}
39
40void G4OCCTEventAction::AddStep(G4double edep, G4double stepLength) {
41 fTotalEdep += edep;
42 fTotalLength += stepLength;
43 ++fNSteps;
44}
45
46void G4OCCTEventAction::AddTrack() { ++fNTracks; }
47
Event action that accumulates per-event totals and fills the events ntuple.
Run action that manages CSV output via G4AnalysisManager.
void EndOfEventAction(const G4Event *event) override
void IncrementPrimaries()
Called from G4OCCTTrackingAction for primary tracks.
void AddTrack()
Called from G4OCCTTrackingAction at the end of each track.
G4OCCTEventAction(const G4OCCTRunAction *runAction)
void BeginOfEventAction(const G4Event *event) override
void AddStep(G4double edep, G4double stepLength)
Called from G4OCCTSteppingAction for each step.
Run action that opens and closes a G4AnalysisManager CSV output file.
G4int GetEventsNtupleId() const