You can now set the angles in X and Y via command line arguments
This commit is contained in:
parent
db15a03619
commit
0d71b38710
|
@ -21,7 +21,6 @@ class MedtechPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
|||
{
|
||||
public:
|
||||
MedtechPrimaryGeneratorAction();
|
||||
MedtechPrimaryGeneratorAction(int energy);
|
||||
virtual ~MedtechPrimaryGeneratorAction();
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue