From e59de3c504a5f2281aa3be44d6dcfe2b59250e9d Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 3 Apr 2018 00:50:20 +0200 Subject: [PATCH] Modified to use command line parameters --- include/MedtechPrimaryGeneratorAction.hh | 2 ++ src/MedtechPrimaryGeneratorAction.cc | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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()