36 auto particle_table{G4ParticleTable::GetParticleTable()};
38 auto particle{parameters.
get<std::string>(
"particle")};
39 if (
auto particle_def{particle_table->FindParticle(particle)};
42 std::cout <<
"[ ParticleGun ] : Firing particle of type " << particle
45 the_gun_.SetParticleDefinition(particle_def);
48 auto energy{parameters.
get<
double>(
"energy")};
50 std::cout <<
"[ ParticleGun ] : Setting energy to " << energy * GeV
53 the_gun_.SetParticleEnergy(energy * GeV);
55 auto position{parameters.
get<std::vector<double> >(
"position")};
56 if (!position.empty()) {
57 G4ThreeVector p_vec(position[0] * mm, position[1] * mm, position[2] * mm);
59 std::cout <<
"[ ParticleGun ] : position " << p_vec << std::endl;
64 auto time{parameters.get<
double>(
"time")};
65 if (time < 0) time = 0.0;
67 std::cout <<
"[ ParticleGun ] : Setting particle time to " << time
70 the_gun_.SetParticleTime(time * ns);
72 auto direction{parameters.get<std::vector<double> >(
"direction")};
73 if (!direction.empty()) {
74 G4ThreeVector d_vec(direction[0], direction[1], direction[2]);
76 std::cout <<
"[ ParticleGun ] : direction " << d_vec.unit() << std::endl;
78 the_gun_.SetParticleMomentumDirection(d_vec);
91 the_gun_.GetParticleEnergy() / GeV);
93 the_gun_.GetParticleDefinition()->GetParticleName());
98 the_gun_.GetParticleMomentumDirection().x());
100 the_gun_.GetParticleMomentumDirection().y());
102 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.