41 #include "Geant4/G4ParticleTable.hh" 45 , nparticle_(p.
get<G4int>(
"NParticle"))
46 , particleName_(p.
get<
std::string>(
"Name"))
47 , momentumDirection_(p.
get<
std::
vector<double>>(
"Direction"))
48 , energy_(p.
get<double>(
"Energy"))
55 mf::LogInfo(
"myParticleGunAction") <<
"Initializing particle gun.";
56 auto particleGun = std::make_unique<G4ParticleGun>(
nparticle_);
57 particleGun->SetParticleDefinition(
58 G4ParticleTable::GetParticleTable()->FindParticle(
particleName_));
59 particleGun->SetParticleMomentumDirection(
61 particleGun->SetParticleEnergy(
energy_ * CLHEP::GeV);
62 particleGun->SetParticlePosition(
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< G4ParticleGun > particleGun_
void generatePrimaries(G4Event *anEvent) override
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::string particleName_
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
std::vector< double > position_
myParticleGunActionService(fhicl::ParameterSet const &)
void initialize() override
std::vector< double > momentumDirection_