From 0d71b38710636ef13e05ef3a5ef30b8d3af9f7cf Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 3 Apr 2018 01:32:56 +0200 Subject: [PATCH] You can now set the angles in X and Y via command line arguments --- include/MedtechPrimaryGeneratorAction.hh | 1 - include/Parameters.hh | 14 ++++++++--- medtech.cc | 9 +++++-- src/MedtechPrimaryGeneratorAction.cc | 16 ++---------- src/Parameters.cc | 32 +++++++++++++++++++----- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/include/MedtechPrimaryGeneratorAction.hh b/include/MedtechPrimaryGeneratorAction.hh index 13ec5a6..df68eff 100644 --- a/include/MedtechPrimaryGeneratorAction.hh +++ b/include/MedtechPrimaryGeneratorAction.hh @@ -21,7 +21,6 @@ class MedtechPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction { public: MedtechPrimaryGeneratorAction(); - MedtechPrimaryGeneratorAction(int energy); virtual ~MedtechPrimaryGeneratorAction(); virtual void GeneratePrimaries(G4Event* anEvent); diff --git a/include/Parameters.hh b/include/Parameters.hh index cecabf6..818914a 100644 --- a/include/Parameters.hh +++ b/include/Parameters.hh @@ -20,17 +20,23 @@ private: Parameters(); int ParticleEnergy; - int pgundegree; + int hdegree; + int vdegree; public: /* Static access method. */ static Parameters* getInstance(); - int GetParticleEnergy(); - int GetDegree(); + double GetParticleEnergy(); + double GetHDegree(); + double GetVDegree(); + + double GetHShift(); + double GetVShift(); void SetParticleEnergy(int); - void SetDegree(int); + void SetHDegree(int); + void SetVDegree(int); }; #endif /* Parameters_hh */ diff --git a/medtech.cc b/medtech.cc index 1e7e439..650453d 100644 --- a/medtech.cc +++ b/medtech.cc @@ -38,9 +38,14 @@ int main(int argc,char** argv) 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 diff --git a/src/MedtechPrimaryGeneratorAction.cc b/src/MedtechPrimaryGeneratorAction.cc index 7fa79ae..5bd883d 100644 --- a/src/MedtechPrimaryGeneratorAction.cc +++ b/src/MedtechPrimaryGeneratorAction.cc @@ -16,23 +16,11 @@ MedtechPrimaryGeneratorAction::MedtechPrimaryGeneratorAction() 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 -> SetParticlePosition(G4ThreeVector(0,0,0)); + particleGun -> SetParticleMomentumDirection(G4ThreeVector(param -> GetHDegree(), param -> GetVDegree(), 1)); 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() { delete particleGun; diff --git a/src/Parameters.cc b/src/Parameters.cc index d041e5d..3e4abcb 100644 --- a/src/Parameters.cc +++ b/src/Parameters.cc @@ -17,7 +17,7 @@ Parameters* Parameters::getInstance() 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. */ Parameters* Parameters::instance = 0; -int Parameters::GetParticleEnergy() +double Parameters::GetParticleEnergy() { 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)