Modified to use command line parameters

This commit is contained in:
Gitea 2018-04-03 00:50:20 +02:00
parent 1b640dec8b
commit e59de3c504
2 changed files with 17 additions and 1 deletions

View File

@ -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);

View File

@ -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()