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 "G4ParticleGun.hh"
#include "G4ParticleTable.hh" #include "G4ParticleTable.hh"
#include "G4ThreeVector.hh" #include "G4ThreeVector.hh"
#include "Parameters.hh"
class MedtechPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction class MedtechPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{ {
public: public:
MedtechPrimaryGeneratorAction(); MedtechPrimaryGeneratorAction();
MedtechPrimaryGeneratorAction(int energy);
virtual ~MedtechPrimaryGeneratorAction(); virtual ~MedtechPrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event* anEvent); virtual void GeneratePrimaries(G4Event* anEvent);

View File

@ -9,6 +9,8 @@
MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction()
{ {
Parameters *param = Parameters::getInstance();
G4int numberOfParticles = 1; G4int numberOfParticles = 1;
particleGun = new G4ParticleGun(numberOfParticles); particleGun = new G4ParticleGun(numberOfParticles);
G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
@ -16,7 +18,19 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction()
particleGun -> SetParticleDefinition(particle); particleGun -> SetParticleDefinition(particle);
particleGun -> SetParticlePosition(G4ThreeVector(1,1,1)); particleGun -> SetParticlePosition(G4ThreeVector(1,1,1));
particleGun -> SetParticleMomentumDirection(G4ThreeVector(0, 0, 4*m)); 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() MedtechPrimaryGeneratorAction::~MedtechPrimaryGeneratorAction()