13#include <G4ParticleGun.hh>
14#include <G4ParticleTable.hh>
15#include <G4SystemOfUnits.hh>
16#include <G4VUserPrimaryGeneratorAction.hh>
21class DefaultPrimaryGeneratorAction :
public G4VUserPrimaryGeneratorAction {
23 DefaultPrimaryGeneratorAction() : fGun(std::make_unique<G4ParticleGun>(1)) {
24 auto* proton = G4ParticleTable::GetParticleTable()->FindParticle(
"proton");
25 fGun->SetParticleDefinition(proton);
26 fGun->SetParticleEnergy(1.0 * GeV);
27 fGun->SetParticleMomentumDirection(G4ThreeVector(0, 0, 1));
28 fGun->SetParticlePosition(G4ThreeVector(0, 0, 0));
31 void GeneratePrimaries(G4Event* event)
override { fGun->GeneratePrimaryVertex(event); }
34 std::unique_ptr<G4ParticleGun> fGun;
44 SetUserAction(
new DefaultPrimaryGeneratorAction);
47 SetUserAction(runAction);
50 SetUserAction(eventAction);
53 SetUserAction(trackingAction);
Minimal user action initialisation for the g4occt executable.
Event action that accumulates per-event totals and fills the events ntuple.
Run action that manages CSV output via G4AnalysisManager.
Stepping action that fills the per-step ntuple.
Tracking action that fills the per-track ntuple.
void Build() const override
void BuildForMaster() const override
Event action that accumulates per-event quantities.
Run action that opens and closes a G4AnalysisManager CSV output file.
Stepping action that records one row per G4Step into the "steps" ntuple.
Tracking action that records one row per G4Track into the "tracks" ntuple.