actions
Loading...
Searching...
No Matches
gPrimaryGeneratorAction.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6// gemc
7#include <gemc/goptions/goptions.h>
8#include <gemc/gbase/gbase.h>
9#include <gemc/gparticle/gparticle_options.h>
10#include <gemc/gparticle/gparticle_reader.h>
11
12// geant4
13#include "G4VUserPrimaryGeneratorAction.hh"
14#include "G4ParticleGun.hh"
15
23constexpr const char* GPRIMARYGENERATORACTION_LOGGER = "generator";
24
30namespace gprimaryaction {
31
45
46} // namespace gprimaryaction
47
48
74class GPrimaryGeneratorAction : public GBase<GPrimaryGeneratorAction>, public G4VUserPrimaryGeneratorAction {
75public:
86 explicit GPrimaryGeneratorAction(std::shared_ptr<GOptions> gopts);
87
90 GPrimaryGeneratorAction(std::shared_ptr<GOptions> gopts,
91 std::shared_ptr<std::vector<GparticlePtr>> particles);
92
93 ~GPrimaryGeneratorAction() override = default;
94
99
112 void GeneratePrimaries(G4Event* event) override;
113
120
130
141
151
152private:
159 std::unique_ptr<G4ParticleGun> gparticleGun;
160
168 std::shared_ptr<std::vector<GparticlePtr>> gparticles;
169
177 GParticleEvents gparticleFileEvents;
178
185 GParticleRecordEvents allGparticleFileRecordEvents;
186
188 static thread_local GParticleEvent current_generated_particles;
189
191 static thread_local GParticleEvent current_generated_tracked_particles;
192
194 static thread_local GParticleRecordEvent current_generated_particle_records;
195
197 static thread_local GParticleRecordEvent current_generated_tracked_particle_records;
198};
Generates the primary vertices for each Geant4 event.
static const GParticleRecordEvent & currentGeneratedParticleRecords()
Returns the current event's full generated-particle records.
static const GParticleEvent & currentGeneratedParticles()
Returns the current event's Geant4-propagated generated particles.
static const GParticleEvent & currentGeneratedTrackedParticles()
Returns the current event's Geant4-tracked generated particles.
static const GParticleRecordEvent & currentGeneratedTrackedParticleRecords()
Returns the current event's Geant4-tracked generated-particle records.
~GPrimaryGeneratorAction() override=default
void GeneratePrimaries(G4Event *event) override
Generates the primary content for one event.
GPrimaryGeneratorAction & operator=(GPrimaryGeneratorAction &&)=delete
GPrimaryGeneratorAction(GPrimaryGeneratorAction &&)=delete
GPrimaryGeneratorAction(const GPrimaryGeneratorAction &)=delete
GPrimaryGeneratorAction(std::shared_ptr< GOptions > gopts)
Constructs the primary-generator action.
GPrimaryGeneratorAction & operator=(const GPrimaryGeneratorAction &)=delete
constexpr const char * GPRIMARYGENERATORACTION_LOGGER
std::vector< GParticleEvent > GParticleEvents
std::vector< GparticlePtr > GParticleEvent
std::vector< GParticleRecordEvent > GParticleRecordEvents
std::vector< GParticleRecord > GParticleRecordEvent
Namespace containing helpers related to primary-generator configuration.
GOptions defineOptions()
Returns the options associated with the primary-generator action scope.