16#ifndef _RMG_GENERATOR_GPS_HH_
17#define _RMG_GENERATOR_GPS_HH_
21#include "G4AutoLock.hh"
22#include "G4GeneralParticleSource.hh"
23#include "G4ThreeVector.hh"
25#include "RMGVGenerator.hh"
36class RMGGeneratorGPS :
public RMGVGenerator {
40 RMGGeneratorGPS() : RMGVGenerator(
"GPS") {
41 fParticleSource = std::make_unique<G4GeneralParticleSource>();
44 ~RMGGeneratorGPS() =
default;
48 G4AutoLock lock(&fMutex);
52 if (fVertexPositionSet) {
53 auto n_source = fParticleSource->GetNumberofSource();
54 for (
auto i = 0; i < n_source; i++) {
55 fParticleSource->SetCurrentSourceto(i);
56 fParticleSource->GetCurrentSource()->GetPosDist()->SetCentreCoords(fVertexPosition);
59 fParticleSource->GeneratePrimaryVertex(event);
64 fVertexPosition = vec;
65 fVertexPositionSet =
true;
70 inline static G4Mutex fMutex = G4MUTEX_INITIALIZER;
72 bool fVertexPositionSet =
false;
73 G4ThreeVector fVertexPosition;
75 std::unique_ptr<G4GeneralParticleSource> fParticleSource =
nullptr;
void SetParticlePosition(G4ThreeVector vec) override
Override the centre coordinates of every GPS source for the next primary vertex.
Definition RMGGeneratorGPS.hh:63
void GeneratePrimaries(G4Event *event) override
Generate a primary vertex from the GPS, optionally overriding the vertex position.
Definition RMGGeneratorGPS.hh:47