18 auto stl_vertex{parameters.
get<std::vector<double> >(
"vertex")};
19 auto stl_momentum{parameters.
get<std::vector<double> >(
"momentum")};
24 if (stl_vertex.size() != 3 or stl_momentum.size() != 3 or
26 EXCEPTION_RAISE(
"InvalideConfig",
27 "Parameters pass to '" + name_ +
"' are not valid.");
30 mpg_vertex_ = G4ThreeVector(stl_vertex.at(0) * mm, stl_vertex.at(1) * mm,
31 stl_vertex.at(2) * mm);
33 G4ThreeVector(stl_momentum.at(0) * MeV, stl_momentum.at(1) * MeV,
34 stl_momentum.at(2) * MeV);
47 int cur_n_vertices = anEvent->GetNumberOfPrimaryVertex();
50 int n_interactions = n_interactions_input;
53 while (n_interactions == 0) {
55 n_interactions =
random_->Poisson(n_interactions_input);
60 for (
int i = 0; i < (n_interactions - cur_n_vertices); ++i) {
61 G4PrimaryVertex* curvertex =
62 new G4PrimaryVertex(cur_mpg_vertex, 0.);
64 curvertex->SetWeight(1.);
66 G4PrimaryParticle* primary =
67 new G4PrimaryParticle(cur_mpg_pdgid, cur_mpg_momentum.x(),
68 cur_mpg_momentum.y(), cur_mpg_momentum.z());
73 primary->SetUserInformation(primary_info);
75 curvertex->SetPrimary(primary);
76 anEvent->AddPrimaryVertex(curvertex);
88 id +
" Class",
"simcore::generators::MultiParticleGunPrimaryGenerator");
Class for generating an event using multiple particles.
#define DECLARE_GENERATOR(CLASS)
@macro DECLARE_GENERATOR
Class that provides extra information for Geant4 primary particles.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Interface that defines a simulation primary generator.
bool useBeamspot() const
Check if beam spot smearing is enabled for this generator.
void smearBeamspot(G4PrimaryVertex *primary_vertex)
Apply beam spot smearing to a primary vertex.
Defines extra information attached to a Geant4 primary particle.
void setHepEvtStatus(int hepEvtStatus)
Set the HEP event status (generator status) e.g.
Generates a Geant4 event from particle gun, but can have many particles.
void GeneratePrimaryVertex(G4Event *anEvent) override
Generate vertices in the Geant4 event.
void RecordConfig(const std::string &id, ldmx::RunHeader &rh) override
Record the configuration of the primary generator into the run header.
MultiParticleGunPrimaryGenerator(const std::string &name, const framework::config::Parameters ¶meters)
Constructor.
int mpg_pdg_id_
PDG ID of the particle used by the gun.
double mpg_n_particles_
Number of particles that will be fired by the gun per event.
G4ThreeVector mpg_vertex_
The vertex position from which to fire the particles.
TRandom * random_
Random number generator.
G4ThreeVector mpg_momentum_
The initial momentum of the particles.
bool mpg_enable_poisson_
Flag denoting whether the number of incident particles should be Poisson distributed.
virtual ~MultiParticleGunPrimaryGenerator()
Destructor.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...