35 auto particle_table{G4ParticleTable::GetParticleTable()};
37 auto particle{parameters.
get<std::string>(
"particle")};
38 if (
auto particle_def{particle_table->FindParticle(particle)};
41 std::cout <<
"[ ParticleGun ] : Firing particle of type " << particle
44 the_gun_.SetParticleDefinition(particle_def);
47 auto energy{parameters.
get<
double>(
"energy")};
49 std::cout <<
"[ ParticleGun ] : Setting energy to " << energy * GeV
52 the_gun_.SetParticleEnergy(energy * GeV);
54 auto position{parameters.
get<std::vector<double> >(
"position")};
55 if (!position.empty()) {
56 G4ThreeVector p_vec(position[0] * mm, position[1] * mm, position[2] * mm);
58 std::cout <<
"[ ParticleGun ] : position " << p_vec << std::endl;
63 auto time{parameters.get<
double>(
"time")};
64 if (time < 0) time = 0.0;
66 std::cout <<
"[ ParticleGun ] : Setting particle time to " << time
69 the_gun_.SetParticleTime(time * ns);
71 auto direction{parameters.get<std::vector<double> >(
"direction")};
72 if (!direction.empty()) {
73 G4ThreeVector d_vec(direction[0], direction[1], direction[2]);
75 std::cout <<
"[ ParticleGun ] : direction " << d_vec.unit() << std::endl;
77 the_gun_.SetParticleMomentumDirection(d_vec);
96 the_gun_.GetParticleEnergy() / GeV);
98 the_gun_.GetParticleDefinition()->GetParticleName());
103 the_gun_.GetParticleMomentumDirection().x());
105 the_gun_.GetParticleMomentumDirection().y());
107 the_gun_.GetParticleMomentumDirection().z());
Extension of G4ParticleGun.
Class that extends the functionality of G4ParticleGun.
int verbosity_
LDMX Verbosity for this generator.
ParticleGun(const std::string &name, const framework::config::Parameters ¶meters)
Constructor.
G4ParticleGun the_gun_
The actual Geant4 implementation of the ParticleGun.