16 auto stl_vertex{parameters.
get<std::vector<double> >(
"vertex")};
17 auto stl_momentum{parameters.
get<std::vector<double> >(
"momentum")};
22 if (stl_vertex.size() != 3 or stl_momentum.size() != 3 or
24 EXCEPTION_RAISE(
"InvalideConfig",
25 "Parameters pass to '" + name_ +
"' are not valid.");
28 mpg_vertex_ = G4ThreeVector(stl_vertex.at(0) * mm, stl_vertex.at(1) * mm,
29 stl_vertex.at(2) * mm);
31 G4ThreeVector(stl_momentum.at(0) * MeV, stl_momentum.at(1) * MeV,
32 stl_momentum.at(2) * MeV);
45 int cur_n_vertices = anEvent->GetNumberOfPrimaryVertex();
48 int n_interactions = n_interactions_input;
51 while (n_interactions == 0) {
53 n_interactions =
random_->Poisson(n_interactions_input);
58 for (
int i = 0; i < (n_interactions - cur_n_vertices); ++i) {
59 G4PrimaryVertex* curvertex =
60 new G4PrimaryVertex(cur_mpg_vertex, 0.);
62 curvertex->SetWeight(1.);
64 G4PrimaryParticle* primary =
65 new G4PrimaryParticle(cur_mpg_pdgid, cur_mpg_momentum.x(),
66 cur_mpg_momentum.y(), cur_mpg_momentum.z());
71 primary->SetUserInformation(primary_info);
73 curvertex->SetPrimary(primary);
74 anEvent->AddPrimaryVertex(curvertex);
81 id +
" Class",
"simcore::generators::MultiParticleGunPrimaryGenerator");
Class for generating an event using multiple particles.
#define DECLARE_GENERATOR(CLASS)
@macro DECLARE_GENERATOR
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.
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 ...