actions
Loading...
Searching...
No Matches
GPrimaryGeneratorAction Class Reference

Generates the primary vertices for each Geant4 event. More...

#include <gPrimaryGeneratorAction.h>

Public Member Functions

 GPrimaryGeneratorAction (std::shared_ptr< GOptions > gopts)
 Constructs the primary-generator action.
 
 GPrimaryGeneratorAction (std::shared_ptr< GOptions > gopts, std::shared_ptr< std::vector< GparticlePtr > > particles)
 Construct with a pre-populated shared particle list (used by GAction so all worker-thread instances share the same GparticlePtr objects as the GUI).
 
 ~GPrimaryGeneratorAction () override=default
 
 GPrimaryGeneratorAction (const GPrimaryGeneratorAction &)=delete
 
GPrimaryGeneratorActionoperator= (const GPrimaryGeneratorAction &)=delete
 
 GPrimaryGeneratorAction (GPrimaryGeneratorAction &&)=delete
 
GPrimaryGeneratorActionoperator= (GPrimaryGeneratorAction &&)=delete
 
void GeneratePrimaries (G4Event *event) override
 Generates the primary content for one event.
 
- Public Member Functions inherited from GBase< GPrimaryGeneratorAction >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Static Public Member Functions

static const GParticleEventcurrentGeneratedParticles ()
 Returns the current event's Geant4-propagated generated particles.
 
static const GParticleEventcurrentGeneratedTrackedParticles ()
 Returns the current event's Geant4-tracked generated particles.
 
static const GParticleRecordEventcurrentGeneratedParticleRecords ()
 Returns the current event's full generated-particle records.
 
static const GParticleRecordEventcurrentGeneratedTrackedParticleRecords ()
 Returns the current event's Geant4-tracked generated-particle records.
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GPrimaryGeneratorAction >
std::shared_ptr< GLoggerlog
 

Detailed Description

This class is the GEMC implementation of the Geant4 primary-generator action. It owns a G4ParticleGun and a list of configured Gparticle objects. Inline particles from -gparticle are generated for every event, while -gparticlefile sources are indexed by Geant4 event id.

For every event, GeneratePrimaries() iterates over the configured particle definitions and delegates the actual shooting operation to each Gparticle instance. This allows the generator configuration to be data-driven while still using the Geant4 particle-gun mechanism underneath.

If no particle definitions are found in the configuration, the constructor creates a default particle so the simulation still has a valid primary source.

The class also exposes thread-local generated-particle snapshots for event output. The generated snapshot contains runtime records for particles propagated in Geant4 plus source-only file rows that are not propagated. The generated_tracked snapshot contains only the runtime records propagated in Geant4.

Definition at line 74 of file gPrimaryGeneratorAction.h.

Constructor & Destructor Documentation

◆ GPrimaryGeneratorAction() [1/4]

GPrimaryGeneratorAction::GPrimaryGeneratorAction ( std::shared_ptr< GOptions > gopts)
explicit

Construction performs the following steps:

  • allocate the G4ParticleGun instance used for emission;
  • read the configured particle definitions through gparticle support helpers;
  • create a default particle if no explicit particle definition is available.
Parameters
goptsShared configuration object used to retrieve generator settings and logging controls.

Definition at line 48 of file gPrimaryGeneratorAction.cc.

◆ GPrimaryGeneratorAction() [2/4]

GPrimaryGeneratorAction::GPrimaryGeneratorAction ( std::shared_ptr< GOptions > gopts,
std::shared_ptr< std::vector< GparticlePtr > > particles )

Definition at line 63 of file gPrimaryGeneratorAction.cc.

◆ ~GPrimaryGeneratorAction()

GPrimaryGeneratorAction::~GPrimaryGeneratorAction ( )
overridedefault

◆ GPrimaryGeneratorAction() [3/4]

GPrimaryGeneratorAction::GPrimaryGeneratorAction ( const GPrimaryGeneratorAction & )
delete

◆ GPrimaryGeneratorAction() [4/4]

GPrimaryGeneratorAction::GPrimaryGeneratorAction ( GPrimaryGeneratorAction && )
delete

Member Function Documentation

◆ currentGeneratedParticleRecords()

const GParticleRecordEvent & GPrimaryGeneratorAction::currentGeneratedParticleRecords ( )
static

This is the source for the generated output bank. It includes runtime records for propagated particles and source-only records for file-backed rows not propagated in Geant4.

Returns
Thread-local generated-particle records for the active event.

Definition at line 135 of file gPrimaryGeneratorAction.cc.

◆ currentGeneratedParticles()

const GParticleEvent & GPrimaryGeneratorAction::currentGeneratedParticles ( )
static
Returns
Thread-local generated particles for the active event.

Definition at line 127 of file gPrimaryGeneratorAction.cc.

◆ currentGeneratedTrackedParticleRecords()

const GParticleRecordEvent & GPrimaryGeneratorAction::currentGeneratedTrackedParticleRecords ( )
static

This is the source for the generated_tracked output bank. It includes only runtime records for particles propagated in Geant4.

Returns
Thread-local tracked generated-particle records for the active event.

Definition at line 139 of file gPrimaryGeneratorAction.cc.

◆ currentGeneratedTrackedParticles()

const GParticleEvent & GPrimaryGeneratorAction::currentGeneratedTrackedParticles ( )
static

This view contains inline particles and file-backed particles propagated in Geant4.

Returns
Thread-local tracked generated particles for the active event.

Definition at line 131 of file gPrimaryGeneratorAction.cc.

◆ GeneratePrimaries()

void GPrimaryGeneratorAction::GeneratePrimaries ( G4Event * event)
override

The method loops over all configured Gparticle objects. For each non-null entry, it asks the particle object to configure the internal G4ParticleGun and to inject the resulting primary information into the supplied event.

This design allows multiple configured particle definitions to contribute to a single Geant4 event.

Parameters
eventThe event that will receive the generated primary vertices and particles.

Definition at line 81 of file gPrimaryGeneratorAction.cc.

◆ operator=() [1/2]

GPrimaryGeneratorAction & GPrimaryGeneratorAction::operator= ( const GPrimaryGeneratorAction & )
delete

◆ operator=() [2/2]

GPrimaryGeneratorAction & GPrimaryGeneratorAction::operator= ( GPrimaryGeneratorAction && )
delete

The documentation for this class was generated from the following files: