You can now set the angles in X and Y via command line arguments

This commit is contained in:
Gitea 2018-04-03 01:32:56 +02:00
parent db15a03619
commit 0d71b38710
5 changed files with 45 additions and 27 deletions

View File

@ -21,7 +21,6 @@ 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

@ -20,17 +20,23 @@ private:
Parameters(); Parameters();
int ParticleEnergy; int ParticleEnergy;
int pgundegree; int hdegree;
int vdegree;
public: public:
/* Static access method. */ /* Static access method. */
static Parameters* getInstance(); static Parameters* getInstance();
int GetParticleEnergy(); double GetParticleEnergy();
int GetDegree(); double GetHDegree();
double GetVDegree();
double GetHShift();
double GetVShift();
void SetParticleEnergy(int); void SetParticleEnergy(int);
void SetDegree(int); void SetHDegree(int);
void SetVDegree(int);
}; };
#endif /* Parameters_hh */ #endif /* Parameters_hh */

View File

@ -38,9 +38,14 @@ int main(int argc,char** argv)
param -> SetParticleEnergy(atoi(argv[i+1])); param -> SetParticleEnergy(atoi(argv[i+1]));
} }
else if(!strcmp("-d", argv[i])) else if(!strcmp("-h", argv[i]))
{ {
param -> SetDegree(atoi(argv[i+1])); param -> SetHDegree(atoi(argv[i+1]));
}
else if(!strcmp("-v", argv[i]))
{
param -> SetVDegree(atoi(argv[i+1]));
} }
} }
//parameters from command line //parameters from command line

View File

@ -16,23 +16,11 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction()
G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable(); G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition *particle = particleTable -> FindParticle("e-"); G4ParticleDefinition *particle = particleTable -> FindParticle("e-");
particleGun -> SetParticleDefinition(particle); particleGun -> SetParticleDefinition(particle);
particleGun -> SetParticlePosition(G4ThreeVector(1,1,1)); particleGun -> SetParticlePosition(G4ThreeVector(0,0,0));
particleGun -> SetParticleMomentumDirection(G4ThreeVector(0, 0, 4*m)); particleGun -> SetParticleMomentumDirection(G4ThreeVector(param -> GetHDegree(), param -> GetVDegree(), 1));
particleGun -> SetParticleEnergy(param -> GetParticleEnergy() *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()
{ {
delete particleGun; delete particleGun;

View File

@ -17,7 +17,7 @@ Parameters* Parameters::getInstance()
return instance; return instance;
} }
Parameters::Parameters() : ParticleEnergy(6), pgundegree(90) Parameters::Parameters() : ParticleEnergy(6), hdegree(0), vdegree(0)
{ {
} }
@ -25,19 +25,39 @@ Parameters::Parameters() : ParticleEnergy(6), pgundegree(90)
/* Null, because instance will be initialized on demand. */ /* Null, because instance will be initialized on demand. */
Parameters* Parameters::instance = 0; Parameters* Parameters::instance = 0;
int Parameters::GetParticleEnergy() double Parameters::GetParticleEnergy()
{ {
return ParticleEnergy; return ParticleEnergy;
} }
int Parameters::GetDegree() double Parameters::GetHDegree()
{ {
return pgundegree; return (1./45.)*(double)hdegree;
} }
void Parameters::SetDegree(int d) void Parameters::SetHDegree(int d)
{ {
pgundegree = d; hdegree = d;
}
double Parameters::GetHShift()
{
return hdegree;
}
double Parameters::GetVDegree()
{
return (1./45.)*(double)vdegree;
}
void Parameters::SetVDegree(int d)
{
vdegree = d;
}
double Parameters::GetVShift()
{
return vdegree;
} }
void Parameters::SetParticleEnergy(int p) void Parameters::SetParticleEnergy(int p)