diff --git a/include/MedtechPrimaryGeneratorAction.hh b/include/MedtechPrimaryGeneratorAction.hh index 9fddac3..13ec5a6 100644 --- a/include/MedtechPrimaryGeneratorAction.hh +++ b/include/MedtechPrimaryGeneratorAction.hh @@ -15,11 +15,13 @@ #include "G4ParticleGun.hh" #include "G4ParticleTable.hh" #include "G4ThreeVector.hh" +#include "Parameters.hh" class MedtechPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: MedtechPrimaryGeneratorAction(); + MedtechPrimaryGeneratorAction(int energy); virtual ~MedtechPrimaryGeneratorAction(); virtual void GeneratePrimaries(G4Event* anEvent); diff --git a/src/MedtechPrimaryGeneratorAction.cc b/src/MedtechPrimaryGeneratorAction.cc index cefcee1..7fa79ae 100644 --- a/src/MedtechPrimaryGeneratorAction.cc +++ b/src/MedtechPrimaryGeneratorAction.cc @@ -9,6 +9,8 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() { + Parameters *param = Parameters::getInstance(); + G4int numberOfParticles = 1; particleGun = new G4ParticleGun(numberOfParticles); G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); @@ -16,7 +18,19 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() particleGun -> SetParticleDefinition(particle); particleGun -> SetParticlePosition(G4ThreeVector(1,1,1)); particleGun -> SetParticleMomentumDirection(G4ThreeVector(0, 0, 4*m)); - particleGun -> SetParticleEnergy(6*MeV); + particleGun -> SetParticleEnergy(param -> GetParticleEnergy() *MeV); +} + +MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction(int energy) +{ + G4int numberOfParticles = 1; + particleGun = new G4ParticleGun(numberOfParticles); + G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition *particle = particleTable -> FindParticle("e-"); + particleGun -> SetParticleDefinition(particle); + particleGun -> SetParticlePosition(G4ThreeVector(1,1,1)); + particleGun -> SetParticleMomentumDirection(G4ThreeVector(0, 0, 4*m)); + particleGun -> SetParticleEnergy(energy*MeV); } MedtechPrimaryGeneratorAction::~MedtechPrimaryGeneratorAction()