12 #include "G4SystemOfUnits.hh"
17 _gunGenerator(gunGenerator) {
19 G4String gunDir(
"/GGS/generatorActions/gun/");
22 _gunDir =
new G4UIdirectory(gunDir.data());
23 _gunDir->SetGuidance(
"Gun primary generator control");
25 _checkAcceptance =
new G4UIcmdWithAString((gunDir +
"checkAcceptance").data(),
this);
26 _checkAcceptance->SetGuidance(
27 "When random ON, shoot randomly inside detector volume (true) or in all random directions (false)");
28 _checkAcceptance->SetGuidance(
" Choice : true (default), false");
29 _checkAcceptance->SetParameterName(
"insideAcceptance",
true);
30 _checkAcceptance->SetDefaultValue(
"true");
31 _checkAcceptance->SetCandidates(
"true false");
32 _checkAcceptance->AvailableForStates(G4State_PreInit, G4State_Idle);
34 _positionCmd =
new G4UIcmdWith3VectorAndUnit((gunDir +
"position").data(),
this);
35 _positionCmd->SetGuidance(
"If rndm off, starting position of the particle. Default units:[cm]");
36 _positionCmd->SetParameterName(
"x0",
"y0",
"z0",
false);
37 _positionCmd->SetUnitCategory(
"Length");
38 _positionCmd->SetDefaultUnit(
"cm");
39 _positionCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
41 _minPositionCmd =
new G4UIcmdWith3VectorAndUnit((gunDir +
"minPosition").data(),
this);
42 _minPositionCmd->SetGuidance(
43 "If rndm on, Minimum range for uniform generation in [xmin,xmax] [ymin,ymax] [zmin,zmax] Def. units:[cm]");
44 _minPositionCmd->SetParameterName(
"xmin",
"ymin",
"zmin",
false);
45 _minPositionCmd->SetUnitCategory(
"Length");
46 _minPositionCmd->SetDefaultUnit(
"cm");
47 _minPositionCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
49 _maxPositionCmd =
new G4UIcmdWith3VectorAndUnit((gunDir +
"maxPosition").data(),
this);
50 _maxPositionCmd->SetGuidance(
51 "If rndm on, Maximum range for uniform generation in [xmin,xmax] [ymin,ymax] [zmin,zmax] Def. units:[cm]");
52 _maxPositionCmd->SetParameterName(
"xmax",
"ymax",
"zmax",
false);
53 _maxPositionCmd->SetUnitCategory(
"Length");
54 _maxPositionCmd->SetDefaultUnit(
"cm");
55 _maxPositionCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
57 _energyCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"energy").data(),
this);
58 _energyCmd->SetGuidance(
"If rndm off, set beam energy [GeV]");
59 _energyCmd->SetParameterName(
"energy",
false);
60 _energyCmd->SetRange(
"energy>=0.");
61 _energyCmd->SetUnitCategory(
"Energy");
62 _energyCmd->SetDefaultUnit(
"GeV");
63 _energyCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
65 _minEnergyCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"minEnergy").data(),
this);
66 _minEnergyCmd->SetGuidance(
"If rndm on, set minimum simulated energy [GeV]");
67 _minEnergyCmd->SetParameterName(
"minEnergy",
false);
68 _minEnergyCmd->SetRange(
"minEnergy>=0.");
69 _minEnergyCmd->SetUnitCategory(
"Energy");
70 _minEnergyCmd->SetDefaultUnit(
"GeV");
71 _minEnergyCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
73 _maxEnergyCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"maxEnergy").data(),
this);
74 _maxEnergyCmd->SetGuidance(
"If rndm on, set maximum simulated energy [GeV]");
75 _maxEnergyCmd->SetParameterName(
"maxEnergy",
false);
76 _maxEnergyCmd->SetRange(
"maxEnergy>=0.");
77 _maxEnergyCmd->SetUnitCategory(
"Energy");
78 _maxEnergyCmd->SetDefaultUnit(
"GeV");
79 _maxEnergyCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
81 _spectralIndexCmd =
new G4UIcmdWithADouble((gunDir +
"spectralIndex").data(),
this);
82 _spectralIndexCmd->SetGuidance(
83 "If rndm on, set spectral index for energy power law. If not defined then uniform simulation!");
84 _spectralIndexCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
86 _thetaCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"theta").data(),
this);
87 _thetaCmd->SetGuidance(
"If rndm off, set theta angle [deg]");
88 _thetaCmd->SetParameterName(
"theta",
false);
89 _thetaCmd->SetRange(
"theta>=0. && theta<=90.");
90 _thetaCmd->SetUnitCategory(
"Angle");
91 _thetaCmd->SetDefaultUnit(
"deg");
92 _thetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
94 _minThetaCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"minTheta").data(),
this);
95 _minThetaCmd->SetGuidance(
96 "If rndm 'on', set min theta angle for uniform simulation in [minTheta,maxTheta]. Default unit: deg");
97 _minThetaCmd->SetParameterName(
"minTheta",
false);
98 _minThetaCmd->SetUnitCategory(
"Angle");
99 _minThetaCmd->SetDefaultUnit(
"deg");
100 _minThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
102 _maxThetaCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"maxTheta").data(),
this);
103 _maxThetaCmd->SetGuidance(
104 "If rndm 'on', set max theta angle for uniform simulation in [minTheta,maxTheta]. Default unit: deg");
105 _maxThetaCmd->SetParameterName(
"maxTheta",
false);
106 _maxThetaCmd->SetUnitCategory(
"Angle");
107 _maxThetaCmd->SetDefaultUnit(
"deg");
108 _maxThetaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
110 _phiCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"phi").data(),
this);
111 _phiCmd->SetGuidance(
"If rndm off, set phi angle [deg]");
112 _phiCmd->SetParameterName(
"Phi",
false);
114 _phiCmd->SetUnitCategory(
"Angle");
115 _phiCmd->SetDefaultUnit(
"deg");
116 _phiCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
118 _minPhiCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"minPhi").data(),
this);
119 _minPhiCmd->SetGuidance(
120 "If rndm 'on', set min Phi angle for uniform simulation in [minPhi,maxPhi]. Default unit: deg");
121 _minPhiCmd->SetParameterName(
"minPhi",
false);
122 _minPhiCmd->SetUnitCategory(
"Angle");
123 _minPhiCmd->SetDefaultUnit(
"deg");
124 _minPhiCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
126 _maxPhiCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"maxPhi").data(),
this);
127 _maxPhiCmd->SetGuidance(
128 "If rndm 'on', set max Phi angle for uniform simulation in [minPhi,maxPhi]. Default unit: deg");
129 _maxPhiCmd->SetParameterName(
"maxPhi",
false);
130 _maxPhiCmd->SetUnitCategory(
"Angle");
131 _maxPhiCmd->SetDefaultUnit(
"deg");
132 _maxPhiCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
134 _gunParticleCmd =
new G4UIcmdWithAString((gunDir +
"particle").data(),
this);
135 _gunParticleCmd->SetGuidance(
"Particle to shoot.");
136 _gunParticleCmd->SetGuidance(
" Eg. e+, proton, mu-");
137 _gunParticleCmd->SetParameterName(
"GunParticle",
false);
138 _gunParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
140 _sphereCenterCmd =
new G4UIcmdWith3VectorAndUnit((gunDir +
"sphereCenter").data(),
this);
141 _sphereCenterCmd->SetGuidance(
"Center of generation sphere. Default unit: cm");
142 _sphereCenterCmd->SetParameterName(
"sphereCenterX",
"sphereCenterY",
"sphereCenterZ",
false);
143 _sphereCenterCmd->SetUnitCategory(
"Length");
144 _sphereCenterCmd->SetDefaultUnit(
"cm");
145 _sphereCenterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
147 _sphereCapPositionCmd =
new G4UIcmdWith3VectorAndUnit((gunDir +
"sphereCapPosition").data(),
this);
148 _sphereCapPositionCmd->SetGuidance(
149 "Position of the center of the spherical cap particle generator with respect to the sphere center. Default unit: cm");
150 _sphereCapPositionCmd->SetParameterName(
"sphereCapPositionX",
"sphereCapPositionY",
"sphereCapPositionZ",
false);
151 _sphereCapPositionCmd->SetUnitCategory(
"Length");
152 _sphereCapPositionCmd->SetDefaultUnit(
"cm");
153 _sphereCapPositionCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
155 _sphereCapExtensionCmd =
new G4UIcmdWithADoubleAndUnit((gunDir +
"sphereCapExtension").data(),
this);
156 _sphereCapExtensionCmd->SetGuidance(
157 "Angular half-width of the spherical cap particle generator with respect to the sphere center. Default unit: deg");
158 _sphereCapExtensionCmd->SetParameterName(
"sphereCapExtension",
false);
159 _sphereCapExtensionCmd->SetUnitCategory(
"Angle");
160 _sphereCapExtensionCmd->SetDefaultUnit(
"deg");
161 _sphereCapExtensionCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
168 delete _checkAcceptance;
170 delete _minPositionCmd;
171 delete _maxPositionCmd;
173 delete _minEnergyCmd;
174 delete _maxEnergyCmd;
175 delete _spectralIndexCmd;
183 delete _gunParticleCmd;
184 delete _sphereCenterCmd;
185 delete _sphereCapPositionCmd;
186 delete _sphereCapExtensionCmd;
193 if (command == _checkAcceptance) {
194 if (newValue ==
"true") {
202 if (command == _positionCmd) {
203 _gunGenerator->
SetPosition(_positionCmd->GetNew3VectorValue(newValue));
206 if (command == _minPositionCmd) {
207 _gunGenerator->
SetMinPosition(_minPositionCmd->GetNew3VectorValue(newValue));
211 if (command == _maxPositionCmd) {
212 _gunGenerator->
SetMaxPosition(_maxPositionCmd->GetNew3VectorValue(newValue));
215 if (command == _sphereCenterCmd) {
216 _gunGenerator->
SetSphereCenter(_sphereCenterCmd->GetNew3VectorValue(newValue));
219 if (command == _sphereCapPositionCmd) {
223 if (command == _sphereCapExtensionCmd) {
227 if (command == _energyCmd) {
228 _gunGenerator->
SetEnergy(_energyCmd->GetNewDoubleValue(newValue));
231 if (command == _minEnergyCmd) {
232 _gunGenerator->
SetMinEnergy(_minEnergyCmd->GetNewDoubleValue(newValue));
236 if (command == _maxEnergyCmd) {
237 _gunGenerator->
SetMaxEnergy(_maxEnergyCmd->GetNewDoubleValue(newValue));
241 if (command == _spectralIndexCmd) {
242 _gunGenerator->
SetSpectralIndex(_spectralIndexCmd->GetNewDoubleValue(newValue));
246 if (command == _thetaCmd) {
247 _gunGenerator->
SetTheta(_thetaCmd->GetNewDoubleValue(newValue) * rad);
250 if (command == _minThetaCmd) {
251 _gunGenerator->
SetMinTheta(_minThetaCmd->GetNewDoubleValue(newValue) * rad);
254 if (command == _maxThetaCmd) {
255 _gunGenerator->
SetMaxTheta(_maxThetaCmd->GetNewDoubleValue(newValue) * rad);
258 if (command == _phiCmd) {
259 _gunGenerator->
SetPhi(_phiCmd->GetNewDoubleValue(newValue) * rad);
262 if (command == _minPhiCmd) {
263 _gunGenerator->
SetMinPhi(_minPhiCmd->GetNewDoubleValue(newValue) * rad);
266 if (command == _maxPhiCmd) {
267 _gunGenerator->
SetMaxPhi(_maxPhiCmd->GetNewDoubleValue(newValue) * rad);
270 if (command == _gunParticleCmd) {
void SetEnergy(G4double val)
Sets the particle's kinetic energy.
void SetMinTheta(G4double val)
Sets the minimum random value for theta.
void SetPosition(const G4ThreeVector &val)
Sets the particle's generation position.
void SetMinEnergy(G4double val)
Sets the particle's min kinetic energy.
void SetRndmMaxEnergyFlag(G4bool val)
Sets the max energy flag.
void SetNewValue(G4UIcommand *command, G4String newValue)
Concrete implementation of the SetNewValue methd of base class.
void SetRndmMinEnergyFlag(G4bool val)
Sets the min energy flag.
void SetSpectralIndex(G4double val)
Sets the spectral index.
void SetSphereCenter(const G4ThreeVector &val)
Sets the center of the spherical surface.
void SetAcceptanceFlag(G4bool val)
Set the acceptance control.
void SetPhi(G4double val)
Sets the value for phi.
void SetMaxPhi(G4double val)
Sets the maximum value for phi.
virtual ~GGSGunGeneratorActionMessenger()
Destructor.
A single-particle generator.
void SetMaxTheta(G4double val)
Sets the maximum random value for theta.
void SetGunParticle(const G4String &particle)
Sets the particle to be used by G4ParticleGun.
void SetMinPosition(const G4ThreeVector &val)
Sets the particle's minimum generation position.
void SetTheta(G4double val)
Sets the value for theta.
void SetSphereCapPosition(const G4ThreeVector &val)
Sets the position of the spherical cap on the sphere.
void SetMaxPosition(const G4ThreeVector &val)
Sets the particle's maximum generation position.
void SetSphereCapExtension(G4double val)
Sets the extension of the spherical cap.
void SetMaxEnergy(G4double val)
Sets the particle's max kinetic energy.
GGSGunGeneratorActionMessenger(GGSGunGeneratorAction *gunGenerator)
Constructor.
void SetSpectralIndexFlag(G4bool val)
Sets the spectral index geeration.
void SetMinPhi(G4double val)
Sets the minimum value for phi.