ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimPrimaryGeneratorMessenger.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 11/2004
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimPrimaryGeneratorMessenger
11 /// Messenger for the primary event generator.
12 /////////////////////////////////////////////////////////////////
13 
15 
17 #include "G4UIdirectory.hh"
18 #include "G4UIcommand.hh"
19 #include "G4UIcmdWithoutParameter.hh"
20 #include "G4UIcmdWith3Vector.hh"
21 #include "G4UIcmdWith3VectorAndUnit.hh"
22 #include "G4UIcmdWithAnInteger.hh"
23 #include "G4UIcmdWithAString.hh"
24 #include "G4UIcmdWithADoubleAndUnit.hh"
25 #include "G4UIcmdWithADouble.hh"
26 #include "G4Ions.hh"
27 #include "G4ios.hh"
28 #include "G4Tokenizer.hh"
29 
30 #include "G4PhysicalConstants.hh"
31 #include "G4SystemOfUnits.hh"
32 
33 //////////////////////////////////////////////////////////////////
34 /// Constructor
35 /// command included in this ActarSimPrimaryGeneratorMessenger:
36 /// - /ActarSim/gun/List
37 /// - /ActarSim/gun/particle
38 /// - /ActarSim/gun/realisticBeam
39 /// - /ActarSim/gun/beamInteraction
40 /// - /ActarSim/gun/emittance
41 /// - /ActarSim/gun/beamDirection
42 /// - /ActarSim/gun/beamTheta
43 /// - /ActarSim/gun/beamPhi
44 /// - /ActarSim/gun/beamPosition
45 /// - /ActarSim/gun/beamRadiusAtEntrance
46 /// - /ActarSim/gun/reactionFromEvGen
47 /// - /ActarSim/gun/reactionFromFile
48 /// - /ActarSim/gun/reactionFromCrossSection
49 /// - /ActarSim/gun/reactionFile
50 /// - /ActarSim/gun/reactionFromCine
51 /// - /ActarSim/gun/Cine/randomTheta
52 /// - /ActarSim/gun/randomTheta
53 /// - /ActarSim/gun/randomPhi
54 /// - /ActarSim/gun/alphaSource
55 /// - /ActarSim/gun/randomThetaVal
56 /// - /ActarSim/gun/randomPhiVal
57 /// - /ActarSim/gun/Cine/randomThetaVal
58 /// - /ActarSim/gun/Cine/incidentIon
59 /// - /ActarSim/gun/Cine/targetIon
60 /// - /ActarSim/gun/Cine/scatteredIon
61 /// - /ActarSim/gun/Cine/recoilIon
62 /// - /ActarSim/gun/Cine/reactionQ
63 /// - /ActarSim/gun/Cine/labEnergy
64 /// - /ActarSim/gun/Cine/thetaLabAngle
65 /// - /ActarSim/gun/reactionFromKine
66 /// - /ActarSim/gun/Kine/randomThetaCM
67 /// - /ActarSim/gun/Kine/randomPhiAngle
68 /// - /ActarSim/gun/Kine/randomThetaRange
69 /// - /ActarSim/gun/Kine/incidentIon
70 /// - /ActarSim/gun/Kine/targetIon
71 /// - /ActarSim/gun/Kine/scatteredIon
72 /// - /ActarSim/gun/Kine/recoilIon
73 /// - /ActarSim/gun/Kine/labEnergy
74 /// - /ActarSim/gun/Kine/userThetaCM
75 /// - /ActarSim/gun/Kine/userPhiAngle
76 /// - /ActarSim/gun/Kine/vertexPosition
77 /// - /ActarSim/gun/energy
78 /// - /ActarSim/gun/direction
79 /// - /ActarSim/gun/position
80 /// - /ActarSim/gun/time
81 /// - /ActarSim/gun/randomVertexZPosition
82 /// - /ActarSim/gun/randomVertexZRange
83 /// - /ActarSim/gun/vertexZPosition
84 /// - /ActarSim/gun/polarization
85 /// - /ActarSim/gun/number
86 /// - /ActarSim/gun/ion
88  : actarSimActionGun(actarSimGun) {
89 
90  particleTable = G4ParticleTable::GetParticleTable();
91  ionTable = G4IonTable::GetIonTable();
92 
93  G4bool omitable;
94  G4UIparameter* parameter;
95 
96  gunDir = new G4UIdirectory("/ActarSim/gun/");
97  gunDir->SetGuidance("PrimaryGenerator control");
98 
99  listCmd = new G4UIcmdWithoutParameter("/ActarSim/gun/List",this);
100  listCmd->SetGuidance("List available particles.");
101  listCmd->SetGuidance(" Invoke G4ParticleTable.");
102 
103  particleCmd = new G4UIcmdWithAString("/ActarSim/gun/particle",this);
104  particleCmd->SetGuidance("Select the incident particle.");
105  particleCmd->SetGuidance(" (proton is default)");
106  particleCmd->SetGuidance(" (ion can be specified for shooting ions)");
107  particleCmd->SetParameterName("particle",false);
108  particleCmd->SetDefaultValue("proton");
109  G4String candidateList;
110  G4int nPtcl = particleTable->entries();
111  for(G4int i=0;i<nPtcl;i++) {
112  if(!(particleTable->GetParticle(i)->IsShortLived())) {
113  candidateList += particleTable->GetParticleName(i);
114  candidateList += " ";
115  }
116  }
117  candidateList += "ion ";
118  particleCmd->SetCandidates(candidateList);
119 
120  realisticBeamCmd = new G4UIcmdWithAString("/ActarSim/gun/realisticBeam",this);
121  realisticBeamCmd->SetGuidance("Simulates beam emittance according to emittance parameters.");
122  realisticBeamCmd->SetGuidance(" Choice : on, off(default)");
123  realisticBeamCmd->SetParameterName("choice",true);
124  realisticBeamCmd->SetDefaultValue("off");
125  realisticBeamCmd->SetCandidates("on off");
126  realisticBeamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
127 
128  beamInteractionCmd = new G4UIcmdWithAString("/ActarSim/gun/beamInteraction",this);
129  beamInteractionCmd->SetGuidance("Simulates the beam energy loss in gas.");
130  beamInteractionCmd->SetGuidance(" Choice : on, off(default)");
131  beamInteractionCmd->SetParameterName("choice",true);
132  beamInteractionCmd->SetDefaultValue("off");
133  beamInteractionCmd->SetCandidates("on off");
134  beamInteractionCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
135 
136  emittanceCmd = new G4UIcmdWithADouble("/ActarSim/gun/emittance",this);
137  emittanceCmd->SetGuidance("Selects the value of the emittance [in mm mrad].");
138  emittanceCmd->SetGuidance(" Default value is 1 mm mrad. ");
139  emittanceCmd->SetParameterName("emittance",false);
140  emittanceCmd->SetDefaultValue(1.);
141  emittanceCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
142 
143  beamDirectionCmd = new G4UIcmdWith3Vector("/ActarSim/gun/beamDirection",this);
144  beamDirectionCmd->SetGuidance("Set beam momentum direction.");
145  beamDirectionCmd->SetGuidance("Direction needs not to be a unit vector.");
146  beamDirectionCmd->SetParameterName("Px","Py","Pz",true,true);
147  beamDirectionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
148 
149  beamThetaCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/beamTheta",this);
150  beamThetaCmd->SetGuidance("Sets theta angle for beam (in degrees)");
151  beamThetaCmd->SetParameterName("beamTheta",false);
152  //beamThetaCmd->SetRange("userThetaCM>=0.");
153  beamThetaCmd->SetUnitCategory("Angle");
154  beamThetaCmd->SetDefaultValue(0.);
155  beamThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
156 
157  beamPhiCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/beamPhi",this);
158  beamPhiCmd->SetGuidance("Sets phi angle for beam (in degrees)");
159  beamPhiCmd->SetParameterName("beamPhi",false);
160  //beamPhiCmd->SetRange("userPhiCM>=0.");
161  beamPhiCmd->SetUnitCategory("Angle");
162  beamPhiCmd->SetDefaultValue(0.);
163  beamPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
164 
165  beamPositionCmd = new G4UIcmdWith3VectorAndUnit("/ActarSim/gun/beamPosition",this);
166  beamPositionCmd->SetGuidance("Set beam starting position.");
167  beamPositionCmd->SetParameterName("X","Y","Z",true,true);
168  beamPositionCmd->SetDefaultUnit("mm");
169  //beamPositionCmd->SetUnitCategory("Length");
170  //beamPositionCmd->SetUnitCandidates("microm mm cm m km");
171 
172  beamRadiusAtEntranceCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/beamRadiusAtEntrance",this);
173  beamRadiusAtEntranceCmd->SetGuidance("Selects the beam radius at entrance of ACTAR.");
174  beamRadiusAtEntranceCmd->SetGuidance("Used with the emittance to calculate the position and angle");
175  beamRadiusAtEntranceCmd->SetGuidance("distributions of the beam when a realisticBeam option is set.");
176  beamRadiusAtEntranceCmd->SetParameterName("beamRadius",false);
177  beamRadiusAtEntranceCmd->SetRange("beamRadius>0.");
178  beamRadiusAtEntranceCmd->SetUnitCategory("Length");
179  beamRadiusAtEntranceCmd->SetDefaultValue(1.);
180  beamRadiusAtEntranceCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
181 
182  //HAPOL NOTE: REMOVE OR REBUILT COMPLETELY
183  reactionFromEvGenCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFromEvGen",this);
184  reactionFromEvGenCmd->SetGuidance("DO NOT USE. Simulates beam/target from event generator. DO NOT USE.");
185  reactionFromEvGenCmd->SetGuidance(" Choice : on, off(default)");
186  reactionFromEvGenCmd->SetParameterName("choice",true);
187  reactionFromEvGenCmd->SetDefaultValue("off");
188  reactionFromEvGenCmd->SetCandidates("on off");
189  reactionFromEvGenCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
190 
191  //commands affecting the input file selection for the reaction
192  reactionFromFileCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFromFile",this);
193  reactionFromFileCmd->SetGuidance("Select a reaction from an input file");
194  reactionFromFileCmd->SetGuidance(" Choice : on, off(default)");
195  reactionFromFileCmd->SetParameterName("choice",true);
196  reactionFromFileCmd->SetDefaultValue("off");
197  reactionFromFileCmd->SetCandidates("on off");
198  reactionFromFileCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
199 
200  //HAPOL NOTE: REMOVE OR REBUILT COMPLETELY
201  reactionFromCrossSectionCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFromCrossSection",this);
202  reactionFromCrossSectionCmd->SetGuidance("DO NOT USE. Simulates beam/target from the cross-sections. DO NOT USE.");
203  reactionFromCrossSectionCmd->SetGuidance(" Choice : on, off(default)");
204  reactionFromCrossSectionCmd->SetParameterName("choice",true);
205  reactionFromCrossSectionCmd->SetDefaultValue("off");
206  reactionFromCrossSectionCmd->SetCandidates("on off");
207  reactionFromCrossSectionCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
208 
209  reactionFileCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFile",this);
210  reactionFileCmd->SetGuidance("Select the reaction definition file.");
211  reactionFileCmd->SetParameterName("reactionFile",false);
212  reactionFileCmd->SetDefaultValue("He8onC12Elastic.dat");
213 
214  //commands affecting the Cine kinematic reaction generator
215  reactionFromCineCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFromCine",this);
216  reactionFromCineCmd->SetGuidance("Select a reaction using Cine");
217  reactionFromCineCmd->SetGuidance(" Choice : on, off(default)");
218  reactionFromCineCmd->SetParameterName("choice",true);
219  reactionFromCineCmd->SetDefaultValue("off");
220  reactionFromCineCmd->SetCandidates("on off");
221  reactionFromCineCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
222 
223  CineDir = new G4UIdirectory("/ActarSim/gun/Cine/");
224  CineDir->SetGuidance("Cine generator control");
225 
226  CinerandomThetaCmd = new G4UIcmdWithAString("/ActarSim/gun/Cine/randomTheta",this);
227  CinerandomThetaCmd->SetGuidance("Select a random Theta angle for the scattered particle.");
228  CinerandomThetaCmd->SetGuidance(" Choice : on(default), off");
229  CinerandomThetaCmd->SetParameterName("choice",true);
230  CinerandomThetaCmd->SetDefaultValue("on");
231  CinerandomThetaCmd->SetCandidates("on off");
232  CinerandomThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
233 
234  randomThetaCmd = new G4UIcmdWithAString("/ActarSim/gun/randomTheta",this);
235  randomThetaCmd->SetGuidance("Select a random Theta angle for the scattered particle.");
236  randomThetaCmd->SetGuidance(" Choice : on(default), off");
237  randomThetaCmd->SetParameterName("choice",true);
238  randomThetaCmd->SetDefaultValue("on");
239  randomThetaCmd->SetCandidates("on off");
240  randomThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
241 
242  randomPhiCmd = new G4UIcmdWithAString("/ActarSim/gun/randomPhi",this);
243  randomPhiCmd->SetGuidance("Select a random Phi angle for the scattered particle.");
244  randomPhiCmd->SetGuidance(" Choice : on(default), off");
245  randomPhiCmd->SetParameterName("choice",true);
246  randomPhiCmd->SetDefaultValue("on");
247  randomPhiCmd->SetCandidates("on off");
248  randomPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
249 
250  alphaSourceCmd = new G4UIcmdWithAString("/ActarSim/gun/alphaSource",this);
251  alphaSourceCmd->SetGuidance("CHECK THIS COMMAND!");
252  alphaSourceCmd->SetGuidance(" Choice : on(default), off");
253  alphaSourceCmd->SetParameterName("choice",true);
254  alphaSourceCmd->SetDefaultValue("off");
255  alphaSourceCmd->SetCandidates("on off");
256  alphaSourceCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
257 
258  randomThetaValCmd = new G4UIcommand("/ActarSim/gun/randomThetaVal", this);
259  randomThetaValCmd->SetGuidance("Sets the limits in the Theta angle for the scattered particle.");
260  randomThetaValCmd->SetGuidance("The value is randomly chosen between the limits.");
261  parameter = new G4UIparameter("thetaMin", 'd', omitable = true);
262  parameter->SetDefaultValue(0.);
263  randomThetaValCmd->SetParameter(parameter);
264  parameter = new G4UIparameter("thetaMax", 'd', omitable = true);
265  parameter->SetDefaultValue(180.);
266  randomThetaValCmd->SetParameter(parameter);
267  parameter = new G4UIparameter("unit", 's', omitable = true);
268  parameter->SetDefaultValue("deg");
269  randomThetaValCmd->SetParameter(parameter);
270 
271  randomPhiValCmd = new G4UIcommand("/ActarSim/gun/randomPhiVal", this);
272  randomPhiValCmd->SetGuidance("Sets the limits in the Phi angle for the scattered particle.");
273  randomPhiValCmd->SetGuidance("The value is randomly chosen between the limits.");
274  parameter = new G4UIparameter("phiMin", 'd', omitable = true);
275  parameter->SetDefaultValue(0.);
276  randomPhiValCmd->SetParameter(parameter);
277  parameter = new G4UIparameter("phiMax", 'd', omitable = true);
278  parameter->SetDefaultValue(180.);
279  randomPhiValCmd->SetParameter(parameter);
280  parameter = new G4UIparameter("unit", 's', omitable = true);
281  parameter->SetDefaultValue("deg");
282  randomPhiValCmd->SetParameter(parameter);
283 
284  CinerandomThetaValCmd = new G4UIcommand("/ActarSim/gun/Cine/randomThetaVal", this);
285  CinerandomThetaValCmd->SetGuidance("Sets the limist in the Theta angle for the scattered particle.");
286  CinerandomThetaValCmd->SetGuidance("The value is randomly chosen between the limits.");
287  parameter = new G4UIparameter("thetaMin", 'd', omitable = true);
288  parameter->SetDefaultValue(0.);
289  CinerandomThetaValCmd->SetParameter(parameter);
290  parameter = new G4UIparameter("thetaMax", 'd', omitable = true);
291  parameter->SetDefaultValue(180.);
292  CinerandomThetaValCmd->SetParameter(parameter);
293  parameter = new G4UIparameter("unit", 's', omitable = true);
294  parameter->SetDefaultValue("deg");
295  CinerandomThetaValCmd->SetParameter(parameter);
296 
297  incidentIonCmd = new G4UIcommand("/ActarSim/gun/Cine/incidentIon",this);
298  incidentIonCmd->SetGuidance("Set properties of incident ion to be generated.");
299  incidentIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/incidentIon Z A Q E");
300  incidentIonCmd->SetGuidance(" Z:(int) AtomicNumber");
301  incidentIonCmd->SetGuidance(" A:(int) AtomicMass");
302  incidentIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
303  incidentIonCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
304 
305  G4UIparameter* incidentParam;
306  incidentParam = new G4UIparameter("Z",'i',false);
307  incidentParam->SetDefaultValue("1");
308  incidentIonCmd->SetParameter(incidentParam);
309  incidentParam = new G4UIparameter("A",'i',false);
310  incidentParam->SetDefaultValue("1");
311  incidentIonCmd->SetParameter(incidentParam);
312  incidentParam = new G4UIparameter("Q",'i',false);
313  incidentParam->SetDefaultValue("0");
314  incidentIonCmd->SetParameter(incidentParam);
315  incidentParam = new G4UIparameter("E",'d',true);
316  incidentParam->SetDefaultValue("0.0");
317  incidentIonCmd->SetParameter(incidentParam);
318 
319  targetIonCmd = new G4UIcommand("/ActarSim/gun/Cine/targetIon",this);
320  targetIonCmd->SetGuidance("Set properties of target ion to be generated.");
321  targetIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/targetIon Z A Q E");
322  targetIonCmd->SetGuidance(" Z:(int) AtomicNumber");
323  targetIonCmd->SetGuidance(" A:(int) AtomicMass");
324  targetIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
325  targetIonCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
326 
327  G4UIparameter* targetParam;
328  targetParam = new G4UIparameter("Z",'i',false);
329  targetParam->SetDefaultValue("1");
330  targetIonCmd->SetParameter(targetParam);
331  targetParam = new G4UIparameter("A",'i',false);
332  targetParam->SetDefaultValue("1");
333  targetIonCmd->SetParameter(targetParam);
334  targetParam = new G4UIparameter("Q",'i',false);
335  targetParam->SetDefaultValue("0");
336  targetIonCmd->SetParameter(targetParam);
337  targetParam = new G4UIparameter("E",'d',true);
338  targetParam->SetDefaultValue("0.0");
339  targetIonCmd->SetParameter(targetParam);
340 
341  scatteredIonCmd = new G4UIcommand("/ActarSim/gun/Cine/scatteredIon",this);
342  scatteredIonCmd->SetGuidance("Set properties of scattered ion to be generated.");
343  scatteredIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/scatteredIon Z A Q E");
344  scatteredIonCmd->SetGuidance(" Z:(int) AtomicNumber");
345  scatteredIonCmd->SetGuidance(" A:(int) AtomicMass");
346  scatteredIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
347  scatteredIonCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
348 
349  G4UIparameter* scatteredParam;
350  scatteredParam = new G4UIparameter("Z",'i',false);
351  scatteredParam->SetDefaultValue("1");
352  scatteredIonCmd->SetParameter(scatteredParam);
353  scatteredParam = new G4UIparameter("A",'i',false);
354  scatteredParam->SetDefaultValue("1");
355  scatteredIonCmd->SetParameter(scatteredParam);
356  scatteredParam = new G4UIparameter("Q",'i',false);
357  scatteredParam->SetDefaultValue("0");
358  scatteredIonCmd->SetParameter(scatteredParam);
359  scatteredParam = new G4UIparameter("E",'d',true);
360  scatteredParam->SetDefaultValue("0.0");
361  scatteredIonCmd->SetParameter(scatteredParam);
362 
363  recoilIonCmd = new G4UIcommand("/ActarSim/gun/Cine/recoilIon",this);
364  recoilIonCmd->SetGuidance("Set properties of recoil ion to be generated.");
365  recoilIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/recoilIon Z A Q E");
366  recoilIonCmd->SetGuidance(" Z:(int) AtomicNumber");
367  recoilIonCmd->SetGuidance(" A:(int) AtomicMass");
368  recoilIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
369  recoilIonCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
370 
371  G4UIparameter* recoilParam;
372  recoilParam = new G4UIparameter("Z",'i',false);
373  recoilParam->SetDefaultValue("1");
374  recoilIonCmd->SetParameter(recoilParam);
375  recoilParam = new G4UIparameter("A",'i',false);
376  recoilParam->SetDefaultValue("1");
377  recoilIonCmd->SetParameter(recoilParam);
378  recoilParam = new G4UIparameter("Q",'i',false);
379  recoilParam->SetDefaultValue("0");
380  recoilIonCmd->SetParameter(recoilParam);
381  recoilParam = new G4UIparameter("E",'d',true);
382  recoilParam->SetDefaultValue("0.0");
383  recoilIonCmd->SetParameter(recoilParam);
384 
385  reactionQCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Cine/reactionQ",this);
386  reactionQCmd->SetGuidance("Sets the reaction Q ");
387  reactionQCmd->SetParameterName("reactionQ",false);
388  //reactionQCmd->SetRange("reactionQ>=0.");
389  reactionQCmd->SetUnitCategory("Energy");
390  reactionQCmd->SetDefaultValue(12.);
391  reactionQCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
392 
393  labEnergyCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Cine/labEnergy",this);
394  labEnergyCmd->SetGuidance("Sets the laboratory energy ");
395  labEnergyCmd->SetParameterName("labEnergy",false);
396  labEnergyCmd->SetRange("labEnergy>=0.");
397  labEnergyCmd->SetUnitCategory("Energy");
398  labEnergyCmd->SetDefaultValue(100.);
399  labEnergyCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
400 
401  thetaLabAngleCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Cine/thetaLabAngle",this);
402  thetaLabAngleCmd->SetGuidance("Sets theta lab angle for the scattered particle (degrees)");
403  thetaLabAngleCmd->SetParameterName("thetaLabAngle",false);
404  thetaLabAngleCmd->SetRange("thetaLabAngle>=0.");
405  thetaLabAngleCmd->SetUnitCategory("Angle");
406  thetaLabAngleCmd->SetDefaultValue(0.5);
407  thetaLabAngleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
408 
409  //commands affecting the Cine kinematic reaction generator
410  reactionFromKineCmd = new G4UIcmdWithAString("/ActarSim/gun/reactionFromKine",this);
411  reactionFromKineCmd->SetGuidance("Select a reaction using Kine");
412  reactionFromKineCmd->SetGuidance(" Choice : on(default), off");
413  reactionFromKineCmd->SetParameterName("choice",true);
414  reactionFromKineCmd->SetDefaultValue("on");
415  reactionFromKineCmd->SetCandidates("on off");
416  reactionFromKineCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
417 
418  KineDir = new G4UIdirectory("/ActarSim/gun/Kine/");
419  KineDir->SetGuidance("Kine generator control");
420 
421  KineRandomThetaCmd = new G4UIcmdWithAString("/ActarSim/gun/Kine/randomThetaCM",this);
422  KineRandomThetaCmd->SetGuidance("Randomize Theta_CM of outgoing particles");
423  KineRandomThetaCmd->SetGuidance(" Choice : on(default), off");
424  KineRandomThetaCmd->SetParameterName("choice",true);
425  KineRandomThetaCmd->SetDefaultValue("on");
426  KineRandomThetaCmd->SetCandidates("on off");
427  KineRandomThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
428 
429  KineRandomPhiAngleCmd = new G4UIcmdWithAString("/ActarSim/gun/Kine/randomPhiAngle",this);
430  KineRandomPhiAngleCmd->SetGuidance("Randomize Lab Phi angles of out-going particles");
431  KineRandomPhiAngleCmd->SetGuidance(" Choice : on (default), off");
432  KineRandomPhiAngleCmd->SetParameterName("choice",true);
433  KineRandomPhiAngleCmd->SetDefaultValue("on");
434  KineRandomPhiAngleCmd->SetCandidates("on off");
435  KineRandomPhiAngleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
436 
437  KineRandomThetaRangeCmd = new G4UIcommand("/ActarSim/gun/Kine/randomThetaRange", this);
438  KineRandomThetaRangeCmd->SetGuidance("Sets the limits in the Theta angle for the scattered particle.");
439  KineRandomThetaRangeCmd->SetGuidance("The value is randomly chosen between the limits.");
440  parameter = new G4UIparameter("thetaMin", 'd', omitable = true);
441  parameter->SetDefaultValue(0.);
442  KineRandomThetaRangeCmd->SetParameter(parameter);
443  parameter = new G4UIparameter("thetaMax", 'd', omitable = true);
444  parameter->SetDefaultValue(180.);
445  KineRandomThetaRangeCmd->SetParameter(parameter);
446  parameter = new G4UIparameter("unit", 's', omitable = true);
447  parameter->SetDefaultValue("deg");
448  KineRandomThetaRangeCmd->SetParameter(parameter);
449 
450  KineIncidentIonCmd = new G4UIcommand("/ActarSim/gun/Kine/incidentIon",this);
451  KineIncidentIonCmd->SetGuidance("Set properties of incident ion to be generated.");
452  KineIncidentIonCmd->SetGuidance("[usage] /ActarSim/gun/Kine/incidentIon Z A Q E Mass");
453  KineIncidentIonCmd->SetGuidance(" Z:(int) AtomicNumber");
454  KineIncidentIonCmd->SetGuidance(" A:(int) AtomicMass (in Atomic mass unit u)");
455  KineIncidentIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
456  KineIncidentIonCmd->SetGuidance(" E:(double) Excitation energy (in MeV)");
457  KineIncidentIonCmd->SetGuidance(" Mass:(double) mass in u");
458 
459  G4UIparameter* KineIncidentParam;
460  KineIncidentParam = new G4UIparameter("Z",'i',false);
461  KineIncidentParam->SetDefaultValue("1");
462  KineIncidentIonCmd->SetParameter(KineIncidentParam);
463  KineIncidentParam = new G4UIparameter("A",'i',false);
464  KineIncidentParam->SetDefaultValue("1");
465  KineIncidentIonCmd->SetParameter(KineIncidentParam);
466  KineIncidentParam = new G4UIparameter("Q",'i',false);
467  KineIncidentParam->SetDefaultValue("0");
468  KineIncidentIonCmd->SetParameter(KineIncidentParam);
469  KineIncidentParam = new G4UIparameter("E",'d',true);
470  KineIncidentParam->SetDefaultValue("0.0");
471  KineIncidentIonCmd->SetParameter(KineIncidentParam);
472  KineIncidentParam = new G4UIparameter("Mass",'d',true);
473  KineIncidentParam->SetDefaultValue("1.0");
474  KineIncidentIonCmd->SetParameter(KineIncidentParam);
475 
476  KineTargetIonCmd = new G4UIcommand("/ActarSim/gun/Kine/targetIon",this);
477  KineTargetIonCmd->SetGuidance("Set properties of target ion to be generated.");
478  KineTargetIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/targetIon Z A Q E Mass");
479  KineTargetIonCmd->SetGuidance(" Z:(int) AtomicNumber");
480  KineTargetIonCmd->SetGuidance(" A:(int) AtomicMass in (in u)");
481  KineTargetIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
482  KineTargetIonCmd->SetGuidance(" E:(double) Excitation energy (in MeV)");
483  KineTargetIonCmd->SetGuidance(" Mass:(double) mass in u");
484 
485  G4UIparameter* KineTargetParam;
486  KineTargetParam = new G4UIparameter("Z",'i',false);
487  KineTargetParam->SetDefaultValue("1");
488  KineTargetIonCmd->SetParameter(KineTargetParam);
489  KineTargetParam = new G4UIparameter("A",'i',false);
490  KineTargetParam->SetDefaultValue("1");
491  KineTargetIonCmd->SetParameter(KineTargetParam);
492  KineTargetParam = new G4UIparameter("Q",'i',false);
493  KineTargetParam->SetDefaultValue("0");
494  KineTargetIonCmd->SetParameter(KineTargetParam);
495  KineTargetParam = new G4UIparameter("E",'d',true);
496  KineTargetParam->SetDefaultValue("0.0");
497  KineTargetIonCmd->SetParameter(KineTargetParam);
498  KineTargetParam = new G4UIparameter("Mass",'d',true);
499  KineTargetParam->SetDefaultValue("1.0");
500  KineTargetIonCmd->SetParameter(KineTargetParam);
501 
502  KineScatteredIonCmd = new G4UIcommand("/ActarSim/gun/Kine/scatteredIon",this);
503  KineScatteredIonCmd->SetGuidance("Set properties of scattered ion to be generated.");
504  KineScatteredIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/scatteredIon Z A Q E Mass");
505  KineScatteredIonCmd->SetGuidance(" Z:(int) AtomicNumber");
506  KineScatteredIonCmd->SetGuidance(" A:(int) AtomicMass");
507  KineScatteredIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
508  KineScatteredIonCmd->SetGuidance(" E:(double) Excitation energy (in MeV)");
509  KineScatteredIonCmd->SetGuidance(" Mass:(double) mass in u");
510 
511  G4UIparameter* KineScatteredParam;
512  KineScatteredParam = new G4UIparameter("Z",'i',false);
513  KineScatteredParam->SetDefaultValue("1");
514  KineScatteredIonCmd->SetParameter(KineScatteredParam);
515  KineScatteredParam = new G4UIparameter("A",'i',false);
516  KineScatteredParam->SetDefaultValue("1");
517  KineScatteredIonCmd->SetParameter(KineScatteredParam);
518  KineScatteredParam = new G4UIparameter("Q",'i',false);
519  KineScatteredParam->SetDefaultValue("0");
520  KineScatteredIonCmd->SetParameter(KineScatteredParam);
521  KineScatteredParam = new G4UIparameter("E",'d',true);
522  KineScatteredParam->SetDefaultValue("0.0");
523  KineScatteredIonCmd->SetParameter(KineScatteredParam);
524  KineScatteredParam = new G4UIparameter("Mass",'d',true);
525  KineScatteredParam->SetDefaultValue("1.0");
526  KineScatteredIonCmd->SetParameter(KineScatteredParam);
527 
528  KineRecoilIonCmd = new G4UIcommand("/ActarSim/gun/Kine/recoilIon",this);
529  KineRecoilIonCmd->SetGuidance("Set properties of recoil ion to be generated.");
530  KineRecoilIonCmd->SetGuidance("[usage] /ActarSim/gun/Cine/recoilIon Z A Q E Mass");
531  KineRecoilIonCmd->SetGuidance(" Z:(int) AtomicNumber");
532  KineRecoilIonCmd->SetGuidance(" A:(int) AtomicMass");
533  KineRecoilIonCmd->SetGuidance(" Q:(int) Charge of ion (in unit of e)");
534  KineRecoilIonCmd->SetGuidance(" E:(double) Excitation energy (in MeV)");
535  KineRecoilIonCmd->SetGuidance(" Mass:(double) mass in u");
536 
537  G4UIparameter* KineRecoilParam;
538  KineRecoilParam = new G4UIparameter("Z",'i',false);
539  KineRecoilParam->SetDefaultValue("1");
540  KineRecoilIonCmd->SetParameter(KineRecoilParam);
541  KineRecoilParam = new G4UIparameter("A",'i',false);
542  KineRecoilParam->SetDefaultValue("1.");
543  KineRecoilIonCmd->SetParameter(KineRecoilParam);
544  KineRecoilParam = new G4UIparameter("Q",'i',false);
545  KineRecoilParam->SetDefaultValue("0");
546  KineRecoilIonCmd->SetParameter(KineRecoilParam);
547  KineRecoilParam = new G4UIparameter("E",'d',true);
548  KineRecoilParam->SetDefaultValue("0.0");
549  KineRecoilIonCmd->SetParameter(KineRecoilParam);
550  KineRecoilParam = new G4UIparameter("Mass",'d',true);
551  KineRecoilParam->SetDefaultValue("1.0");
552  KineRecoilIonCmd->SetParameter(KineRecoilParam);
553 
554  KineLabEnergyCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Kine/labEnergy",this);
555  KineLabEnergyCmd->SetGuidance("Sets the laboratory energy.");
556  KineLabEnergyCmd->SetParameterName("labEnergy",false);
557  KineLabEnergyCmd->SetRange("labEnergy>=0.");
558  KineLabEnergyCmd->SetUnitCategory("Energy");
559  KineLabEnergyCmd->SetDefaultValue(100.);
560  KineLabEnergyCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
561 
562  KineUserThetaCMCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Kine/userThetaCM",this);
563  KineUserThetaCMCmd->SetGuidance("Sets theta CM angle for scattered particle (in degrees)");
564  KineUserThetaCMCmd->SetParameterName("userThetaCM",false);
565  KineUserThetaCMCmd->SetRange("userThetaCM>=0.");
566  KineUserThetaCMCmd->SetUnitCategory("Angle");
567  KineUserThetaCMCmd->SetDefaultValue(0.);
568  KineUserThetaCMCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
569 
570  // user set the phi angle of particles, useful when testing the kinematics reconstruction methods
571  KineUserPhiAngleCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/Kine/userPhiAngle",this);
572  KineUserPhiAngleCmd->SetGuidance("User set phi angle for outgoing particle in the Lab system (in degrees)");
573  KineUserPhiAngleCmd->SetParameterName("userPhiAngle",false);
574  KineUserPhiAngleCmd->SetRange("userPhiAngle>=0.");
575  KineUserPhiAngleCmd->SetUnitCategory("Angle");
576  KineUserPhiAngleCmd->SetDefaultValue(0.0);
577  KineUserPhiAngleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
578 
579  vertexPositionCmd = new G4UIcmdWith3VectorAndUnit("/ActarSim/gun/Kine/vertexPosition",this);
580  vertexPositionCmd->SetGuidance("Set the position of the vertex.");
581  vertexPositionCmd->SetParameterName("X","Y","Z",true,true);
582  vertexPositionCmd->SetDefaultUnit("cm");
583 
584  //commands affecting individual particles
585  energyCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/energy",this);
586  energyCmd->SetGuidance("Sets the kinetic energy of the primary particle");
587  energyCmd->SetParameterName("energy",false);
588  energyCmd->SetRange("energy>=0.");
589  energyCmd->SetUnitCategory("Energy");
590  energyCmd->SetDefaultValue(1.);
591  energyCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
592 
593  directionCmd = new G4UIcmdWith3Vector("/ActarSim/gun/direction",this);
594  directionCmd->SetGuidance("Set momentum direction.");
595  directionCmd->SetGuidance("Direction does not need to be a unit vector.");
596  directionCmd->SetParameterName("Px","Py","Pz",true,true);
597  directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
598 
599  positionCmd = new G4UIcmdWith3VectorAndUnit("/ActarSim/gun/position",this);
600  positionCmd->SetGuidance("Set starting position of the particle.");
601  positionCmd->SetParameterName("X","Y","Z",true,true);
602  positionCmd->SetDefaultUnit("cm");
603  //positionCmd->SetUnitCategory("Length");
604  //positionCmd->SetUnitCandidates("microm mm cm m km");
605 
606  timeCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/time",this);
607  timeCmd->SetGuidance("Set initial time of the particle.");
608  timeCmd->SetParameterName("t0",true,true);
609  timeCmd->SetDefaultUnit("ns");
610  //timeCmd->SetUnitCategory("Time");
611  //timeCmd->SetUnitCandidates("ns ms s");
612 
613  randomVertexZPositionCmd = new G4UIcmdWithAString("/ActarSim/gun/randomVertexZPosition",this);
614  randomVertexZPositionCmd->SetGuidance("Randomize the reaction vertex Z position");
615  randomVertexZPositionCmd->SetGuidance("Choice : on(default), off");
616  randomVertexZPositionCmd->SetParameterName("choice",true);
617  randomVertexZPositionCmd->SetDefaultValue("on");
618  randomVertexZPositionCmd->SetCandidates("on off");
619  randomVertexZPositionCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
620 
621  randomVertexZPositionRangeCmd = new G4UIcommand("/ActarSim/gun/randomVertexZRange", this);
622  randomVertexZPositionRangeCmd->SetGuidance("Set the min and max Z-value of random vertex position");
623  randomVertexZPositionRangeCmd->SetGuidance("The value is randomly chosen between the limits.");
624  parameter = new G4UIparameter("randomVertexZMin", 'd', omitable = true);
625  parameter->SetDefaultValue(0.);
626  randomVertexZPositionRangeCmd->SetParameter(parameter);
627  parameter = new G4UIparameter("randomVertexZMax", 'd', omitable = true);
628  parameter->SetDefaultValue(300.);
629  randomVertexZPositionRangeCmd->SetParameter(parameter);
630  parameter = new G4UIparameter("unit", 's', omitable = true);
631  parameter->SetDefaultValue("mm");
632  randomVertexZPositionRangeCmd->SetParameter(parameter);
633 
634  vertexZPositionCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/gun/vertexZPosition",this);
635  vertexZPositionCmd->SetGuidance("Set the Z-value of the reaction vertex.");
636  vertexZPositionCmd->SetParameterName("Z0",true,true);
637  vertexZPositionCmd->SetDefaultUnit("mm");
638  vertexZPositionCmd->SetUnitCategory("Length");
639  vertexZPositionCmd->SetDefaultValue(0.0);
640  vertexZPositionCmd->SetUnitCandidates("mm cm m");
641 
642  polCmd = new G4UIcmdWith3Vector("/ActarSim/gun/polarization",this);
643  polCmd->SetGuidance("Set polarization.");
644  polCmd->SetParameterName("Px","Py","Pz",true,true);
645  polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
646 
647  numberCmd = new G4UIcmdWithAnInteger("/ActarSim/gun/number",this);
648  numberCmd->SetGuidance("Set number of particles to be generated in a single event.");
649  numberCmd->SetParameterName("N",true,true);
650  numberCmd->SetRange("N>0");
651 
652  ionCmd = new G4UIcommand("/ActarSim/gun/ion",this);
653  ionCmd->SetGuidance("Set properties of ion to be generated.");
654  ionCmd->SetGuidance("[usage] /ActarSim/gun/ion Z A Q E");
655  ionCmd->SetGuidance(" Z:(int) AtomicNumber");
656  ionCmd->SetGuidance(" A:(int) AtomicMass");
657  ionCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)");
658  ionCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
659 
660  G4UIparameter* param;
661  param = new G4UIparameter("Z",'i',false);
662  param->SetDefaultValue("1");
663  ionCmd->SetParameter(param);
664  param = new G4UIparameter("A",'i',false);
665  param->SetDefaultValue("1");
666  ionCmd->SetParameter(param);
667  param = new G4UIparameter("Q",'i',true);
668  param->SetDefaultValue("0");
669  ionCmd->SetParameter(param);
670  param = new G4UIparameter("E",'d',true);
671  param->SetDefaultValue("0.0");
672  ionCmd->SetParameter(param);
673 }
674 
675 //////////////////////////////////////////////////////////////////
676 /// Destructor
678  delete gunDir;
679  delete listCmd;
680  delete particleCmd;
681  delete energyCmd;
682  delete directionCmd;
683  delete beamThetaCmd;
684  delete beamPhiCmd;
685  delete positionCmd;
686  delete timeCmd;
689  delete vertexZPositionCmd;
690  delete polCmd;
691  delete numberCmd;
692  delete ionCmd;
693  delete realisticBeamCmd;
694  delete beamInteractionCmd;
695  delete emittanceCmd;
696  delete beamDirectionCmd;
697  delete beamPositionCmd;
699  delete reactionFromEvGenCmd;
701  delete reactionFromFileCmd;
702  delete reactionFileCmd;
703  delete randomThetaCmd;
704  delete randomPhiCmd;
705  delete alphaSourceCmd;
706  delete CinerandomThetaCmd;
707  delete randomThetaValCmd;
708  delete randomPhiValCmd;
709  delete CinerandomThetaValCmd;
710  delete reactionFromCineCmd;
711  delete CineDir;
712  delete incidentIonCmd;
713  delete targetIonCmd;
714  delete scatteredIonCmd;
715  delete recoilIonCmd;
716  delete reactionQCmd;
717  delete labEnergyCmd;
718  delete thetaLabAngleCmd;
719  delete reactionFromKineCmd;
720  delete KineDir;
721  delete KineRandomThetaCmd;
723  delete KineRandomPhiAngleCmd;
724  delete KineIncidentIonCmd;
725  delete KineTargetIonCmd;
726  delete KineScatteredIonCmd;
727  delete KineRecoilIonCmd;
728  delete KineLabEnergyCmd; // in MeV
729  delete KineUserThetaCMCmd; // in degrees
730  delete KineUserPhiAngleCmd; // in degrees
731  delete vertexPositionCmd;
732 }
733 
734 //////////////////////////////////////////////////////////////////
735 /// Setting the values using the interface
737  G4String newValues) {
738  if( command==listCmd )
739  particleTable->DumpTable();
740 
741  if( command == particleCmd ) {
742  if (newValues =="ion") {
743  fShootIon = true;
744  } else {
745  fShootIon = false;
746  G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
747  if(pd != 0)
749  }
750  }
751 
752  if( command == realisticBeamCmd )
754 
755  if( command == beamInteractionCmd )
757 
758  if( command == emittanceCmd)
759  actarSimActionGun->SetEmittance(emittanceCmd->GetNewDoubleValue(newValues));
760 
761  if( command==beamDirectionCmd )
762  actarSimActionGun->SetBeamMomentumDirection(beamDirectionCmd->GetNew3VectorValue(newValues));
763 
764  if( command == beamThetaCmd )
766  SetUserThetaAngle(beamThetaCmd->GetNewDoubleValue(newValues));
767 
768  if( command == beamPhiCmd )
770  SetUserPhiAngle(beamPhiCmd->GetNewDoubleValue(newValues));
771 
772  if( command==beamPositionCmd )
773  actarSimActionGun->SetBeamPosition(beamPositionCmd->GetNew3VectorValue(newValues));
774 
775  if(command == beamRadiusAtEntranceCmd)
776  actarSimActionGun->SetBeamRadiusAtEntrance(beamRadiusAtEntranceCmd->GetNewDoubleValue(newValues));
777 
778  if( command == reactionFromEvGenCmd )
780 
781  if( command == reactionFromCrossSectionCmd )
783 
784  if( command == reactionFromFileCmd )
786 
787  if( command == reactionFromCineCmd )
789 
790  if( command == reactionFileCmd )
792 
793  if( command == randomThetaCmd )
795 
796  if( command == randomPhiCmd )
798 
799  if( command == alphaSourceCmd )
801 
802  if( command == CinerandomThetaCmd )
804 
805  if( command == randomThetaValCmd ){
806  G4double thetaMax, thetaMin;
807  // ConvertToDoublePair(newValues, thetaMin, thetaMax);
808 
809  G4double x, y;
810  char unts[30];
811  std::istringstream is(newValues);
812  is >> x >> y >> unts;
813  G4String unt = unts;
814 
815  thetaMin = x*G4UIcommand::ValueOf(unt);
816  thetaMax = y*G4UIcommand::ValueOf(unt);
817 
818  actarSimActionGun->SetRandomThetaVal(thetaMin,thetaMax);
819  }
820 
821  if( command == randomPhiValCmd ){
822  G4double phiMax, phiMin;
823  // ConvertToDoublePair(newValues, thetaMin, thetaMax);
824 
825  G4double x, y;
826  char unts[30];
827  std::istringstream is(newValues);
828  is >> x >> y >> unts;
829  G4String unt = unts;
830 
831  phiMin = x*G4UIcommand::ValueOf(unt);
832  phiMax = y*G4UIcommand::ValueOf(unt);
833 
834  actarSimActionGun->SetRandomPhiVal(phiMin,phiMax);
835  }
836 
837  if( command == CinerandomThetaValCmd ){
838  G4double thetaMax, thetaMin;
839  // ConvertToDoublePair(newValues, thetaMin, thetaMax);
840 
841  G4double x, y;
842  char unts[30];
843  std::istringstream is(newValues);
844  is >> x >> y >> unts;
845  G4String unt = unts;
846 
847  thetaMin = x*G4UIcommand::ValueOf(unt);
848  thetaMax = y*G4UIcommand::ValueOf(unt);
849 
850  actarSimActionGun->SetRandomThetaVal(thetaMin,thetaMax);
851  }
852 
853  if( command == incidentIonCmd )
854  incidentIonCommand(newValues);
855 
856  if( command == targetIonCmd )
857  targetIonCommand(newValues);
858 
859  if( command == scatteredIonCmd )
860  scatteredIonCommand(newValues);
861 
862  if( command == recoilIonCmd )
863  recoilIonCommand(newValues);
864 
865  if( command == reactionFromKineCmd )
867 
868  if( command == KineRandomThetaCmd )
870 
871  if( command == KineRandomPhiAngleCmd )
873 
874  if( command == KineRandomThetaRangeCmd ){
875  G4double thetaMax, thetaMin;
876 
877  G4double x, y;
878  char unts[30];
879  std::istringstream is(newValues);
880  is >> x >> y >> unts;
881  G4String unt = unts;
882 
883  thetaMin = x*G4UIcommand::ValueOf(unt);
884  thetaMax = y*G4UIcommand::ValueOf(unt);
885 
886  actarSimActionGun->SetRandomThetaVal(thetaMin,thetaMax);
887  }
888 
889  if( command == KineIncidentIonCmd )
890  KineIncidentIonCommand(newValues);
891 
892  if( command == KineTargetIonCmd )
893  KineTargetIonCommand(newValues);
894 
895  if( command == KineScatteredIonCmd )
896  KineScatteredIonCommand(newValues);
897 
898  if( command == KineRecoilIonCmd )
899  KineRecoilIonCommand(newValues);
900 
901  if( command == KineLabEnergyCmd ){
902  G4double incidentEnergyTmp;
903  incidentEnergyTmp=KineLabEnergyCmd->GetNewDoubleValue(newValues);
904  actarSimActionGun->SetLabEnergy(incidentEnergyTmp);
905  actarSimActionGun->SetIncidentEnergy(incidentEnergyTmp);//Piotr: why do we have incident energy and lab energy?
906  }
907 
908  if( command == KineUserThetaCMCmd )
910  SetThetaCMAngle(KineUserThetaCMCmd->GetNewDoubleValue(newValues));
911 
912  if( command == KineUserPhiAngleCmd )
914  SetUserPhiAngle(KineUserPhiAngleCmd->GetNewDoubleValue(newValues));
915 
916  if( command==randomVertexZPositionCmd )
918 
919  if( command==vertexPositionCmd )
920  actarSimActionGun->SetVertexPosition(vertexPositionCmd->GetNew3VectorValue(newValues));
921 
922 
923  if( command == reactionQCmd )
925  SetReactionQ(reactionQCmd->GetNewDoubleValue(newValues));
926 
927  if( command == labEnergyCmd )
929  SetLabEnergy(labEnergyCmd->GetNewDoubleValue(newValues));
930 
931  if( command == thetaLabAngleCmd )
933  SetThetaLabAngle(thetaLabAngleCmd->GetNewDoubleValue(newValues));
934 
935  if( command == energyCmd ){
936  actarSimActionGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues));//Piotr: Doesn't set the energy when modify
937  actarSimActionGun->SetIncidentEnergy(energyCmd->GetNewDoubleValue(newValues));
938  }
939 
940  if( command==directionCmd )
941  actarSimActionGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues));
942 
943  if( command==positionCmd )
944  actarSimActionGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues));
945 
946  if( command==timeCmd )
947  actarSimActionGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues));
948 
949  if( command==vertexZPositionCmd )
950  actarSimActionGun->SetVertexZPosition(vertexZPositionCmd->GetNewDoubleValue(newValues));
951 
952  if( command == randomVertexZPositionRangeCmd ){
953  G4double vertexZMin, vertexZMax;
954 
955  G4double x, y;
956  char unts[30];
957  std::istringstream is(newValues);
958  is >> x >> y >> unts;
959  G4String unt = unts;
960 
961  vertexZMin = x*G4UIcommand::ValueOf(unt);
962  vertexZMax = y*G4UIcommand::ValueOf(unt);
963 
964  actarSimActionGun->SetRandomVertexZPositionVal(vertexZMin,vertexZMax);
965  }
966 
967  if( command==polCmd )
968  actarSimActionGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues));
969 
970  if( command==numberCmd )
971  actarSimActionGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues));
972 
973  if( command==ionCmd )
974  IonCommand(newValues);
975 }
976 
977 //////////////////////////////////////////////////////////////////
978 /// Get current value from commands
980 {
981  G4String cv;
982 
983  if( command==directionCmd) {
985  }
986  else if( command==particleCmd) {
987  cv = actarSimActionGun->GetParticleDefinition()->GetParticleName();
988  }
989  else if( command==energyCmd) {
990  cv = energyCmd->ConvertToString(actarSimActionGun->GetParticleEnergy(),"GeV");
991  }
992  else if( command==positionCmd) {
993  cv = positionCmd->ConvertToString(actarSimActionGun->GetParticlePosition(),"cm");
994  }
995  else if( command==timeCmd) {
996  cv = timeCmd->ConvertToString(actarSimActionGun->GetParticleTime(),"ns");
997  }
998  else if( command==polCmd) {
999  cv = polCmd->ConvertToString(actarSimActionGun->GetParticlePolarization());
1000  }
1001  else if( command==numberCmd) {
1002  cv = numberCmd->ConvertToString(actarSimActionGun->GetNumberOfParticles());
1003  }
1004  else if( command==ionCmd) {
1005  if (fShootIon) {
1006  cv = ItoS(fAtomicNumber) + " " + ItoS(fAtomicMass) + " ";
1007  cv += ItoS(fIonCharge);
1008  } else {
1009  cv = "";
1010  }
1011  }
1012  return cv;
1013 }
1014 
1015 //////////////////////////////////////////////////////////////////
1016 /// Particular behavior of the ion command. Ion state should be selected.
1018  //if (fShootIon) {
1019  G4Tokenizer next( newValues );
1020  // check argument
1021  fAtomicNumber = StoI(next());
1022  fAtomicMass = StoI(next());
1023  G4String sQ = next();
1024  if (sQ.isNull()) {
1026  } else {
1027  fIonCharge = StoI(sQ);
1028  sQ = next();
1029  if (sQ.isNull()) {
1030  fIonExciteEnergy = 0.0;
1031  } else {
1032  fIonExciteEnergy = StoD(sQ) * keV;
1033  }
1034  }
1035 
1036  G4ParticleDefinition* ion;
1038  if (ion==0) {
1039  G4cout << "##################################################################"
1040  << G4endl
1041  << "####### ActarSimPrimaryGeneratorMessenger::IonCommand() #######"
1042  << "Ion with Z=" << fAtomicNumber
1043  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1044  G4cout << "##################################################################"
1045  << G4endl;
1046  } else {
1049  }
1050  /*
1051  } else {
1052  G4cout << "##################################################################"
1053  << G4endl
1054  << "####### ActarSimPrimaryGeneratorMessenger::IonCommand() #######"
1055  << "Set /gun/particle to ion before using /gun/ion command" << G4endl;
1056  G4cout << "##################################################################"
1057  << G4endl;
1058  }
1059  */
1060 }
1061 
1062 //////////////////////////////////////////////////////////////////
1063 /// Particular behavior of the incident ion command. Ion state should be selected.
1065  G4Tokenizer next( newValues );
1066  // check argument
1067  fAtomicNumber = StoI(next());
1068  fAtomicMass = StoI(next());
1069  G4String sQ = next();
1070  if (sQ.isNull()) {
1072  } else {
1073  fIonCharge = StoI(sQ);
1074  sQ = next();
1075  if (sQ.isNull()) {
1076  fIonExciteEnergy = 0.0;
1077  } else {
1078  fIonExciteEnergy = StoD(sQ) * keV;
1079  }
1080  }
1081 
1082  G4Ions* ion;
1083  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1084  fAtomicMass,
1086  if (ion==0) {
1087  G4cout << "##################################################################"
1088  << G4endl
1089  << "#### ActarSimPrimaryGeneratorMessenger::incidentIonCommand() ####"
1090  << "Ion with Z=" << fAtomicNumber
1091  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1092  G4cout << "##################################################################"
1093  << G4endl;
1094  } else {
1097  //actarSimActionGun->SetIncidentIonExcEnergy(fIonExciteEnergy);
1098  }
1099 }
1100 
1101 //////////////////////////////////////////////////////////////////
1102 /// Particular behavior of the (KINE) incident ion command. Ion state should be selected.
1104  G4Tokenizer next( newValues );
1105  // check argument
1106  fAtomicNumber = StoI(next());
1107  fAtomicMass = StoI(next());
1108  fIonCharge = StoI(next());
1109  fIonExciteEnergy = StoD(next());
1110  fIonMass=StoD(next());
1111 
1112  G4Ions* ion;
1113  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1114  fAtomicMass,
1116  if (ion==0) {
1117  G4cout << "##################################################################"
1118  << G4endl
1119  << "#### ActarSimPrimaryGeneratorMessenger::KineIncidentIonCommand() ####"
1120  << "Ion with Z=" << fAtomicNumber
1121  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1122  G4cout << "##################################################################"
1123  << G4endl;
1124  } else {
1129  //actarSimActionGun->SetIncidentIonExcEnergy(fIonExciteEnergy);
1130  }
1131 }
1132 
1133 //////////////////////////////////////////////////////////////////
1134 /// Particular behavior of the target ion command. Ion state should be selected.
1136  G4Tokenizer next( newValues );
1137  // check argument
1138  fAtomicNumber = StoI(next());
1139  fAtomicMass = StoI(next());
1140  G4String sQ = next();
1141  if (sQ.isNull()) {
1143  } else {
1144  fIonCharge = StoI(sQ);
1145  sQ = next();
1146  if (sQ.isNull()) {
1147  fIonExciteEnergy = 0.0;
1148  } else {
1149  fIonExciteEnergy = StoD(sQ) * keV;
1150  }
1151  }
1152 
1153  G4Ions* ion;
1154  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1155  fAtomicMass,
1157  if (ion==0) {
1158  G4cout << "##################################################################"
1159  << G4endl
1160  << "##### ActarSimPrimaryGeneratorMessenger::targetIonCommand() ####"
1161  << "Ion with Z=" << fAtomicNumber
1162  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1163  G4cout << "##################################################################"
1164  << G4endl;
1165  } else {
1168  //actarSimActionGun->SetTargetIonExcEnergy(fIonExciteEnergy);
1169  }
1170 }
1171 
1172 //////////////////////////////////////////////////////////////////
1173 /// Particular behavior of the (KINE) target ion command. Ion state should be selected.
1175  G4Tokenizer next( newValues );
1176  // check argument
1177  fAtomicNumber = StoI(next());
1178  fAtomicMass = StoI(next());
1179  fIonCharge = StoI(next());
1180  fIonExciteEnergy = StoD(next());
1181  fIonMass=StoD(next());
1182 
1183  G4Ions* ion;
1184  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1185  fAtomicMass,
1187  if (ion==0) {
1188  G4cout << "##################################################################"
1189  << G4endl
1190  << "##### ActarSimPrimaryGeneratorMessenger::KineTargetIonCommand() ####"
1191  << "Ion with Z=" << fAtomicNumber
1192  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1193  G4cout << "##################################################################"
1194  << G4endl;
1195  } else {
1200 
1201  //actarSimActionGun->SetTargetIonExcEnergy(fIonExciteEnergy);
1202  }
1203 }
1204 
1205 //////////////////////////////////////////////////////////////////
1206 /// Particular behavior of the scattered ion command. Ion state should be selected.
1208  G4Tokenizer next( newValues );
1209  // check argument
1210  fAtomicNumber = StoI(next());
1211  fAtomicMass = StoI(next());
1212  G4String sQ = next();
1213  if (sQ.isNull()) {
1215  } else {
1216  fIonCharge = StoI(sQ);
1217  sQ = next();
1218  if (sQ.isNull()) {
1219  fIonExciteEnergy = 0.0;
1220  } else {
1221  fIonExciteEnergy = StoD(sQ) * keV;
1222  }
1223  }
1224 
1225  G4Ions* ion;
1226  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1227  fAtomicMass,
1229  if (ion==0) {
1230  G4cout << "##################################################################"
1231  << G4endl
1232  << "### ActarSimPrimaryGeneratorMessenger::scatteredIonCommand() ###"
1233  << "Ion with Z=" << fAtomicNumber
1234  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1235  G4cout << "##################################################################"
1236  << G4endl;
1237  } else {
1240  //actarSimActionGun->SetScatteredIonExcEnergy(fIonExciteEnergy);
1241  }
1242 }
1243 
1244 //////////////////////////////////////////////////////////////////
1245 /// Particular behavior of the (KINE) scattered ion command. Ion state should be selected.
1247  // Selection of scattered ion command. Ion state should be selected.
1248  G4Tokenizer next( newValues );
1249  // check argument
1250  fAtomicNumber = StoI(next());
1251  fAtomicMass = StoI(next());
1252  fIonCharge = StoI(next());
1253  fIonExciteEnergy = StoD(next());
1254  fIonMass=StoD(next());
1255 
1256  G4Ions* ion;
1257  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1258  fAtomicMass,
1260  if (ion==0) {
1261  G4cout << "##################################################################"
1262  << G4endl
1263  << "### ActarSimPrimaryGeneratorMessenger::KineScatteredIonCommand() ###"
1264  << "Ion with Z=" << fAtomicNumber
1265  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1266  G4cout << "##################################################################"
1267  << G4endl;
1268  } else {
1273  // G4cout << "ActarSimPrimaryGeneratorMessenger::KineScatteredIonCommand(): excitation energy=" << fIonExciteEnergy << G4endl;
1274  //actarSimActionGun->SetScatteredIonExcEnergy(fIonExciteEnergy);
1275  }
1276 }
1277 
1278 //////////////////////////////////////////////////////////////////
1279 /// Particular behavior of the recoil ion command. Ion state should be selected.
1281  G4Tokenizer next( newValues );
1282  // check argument
1283  fAtomicNumber = StoI(next());
1284  fAtomicMass = StoI(next());
1285  G4String sQ = next();
1286  if (sQ.isNull()) {
1288  } else {
1289  fIonCharge = StoI(sQ);
1290  sQ = next();
1291  if (sQ.isNull()) {
1292  fIonExciteEnergy = 0.0;
1293  } else {
1294  fIonExciteEnergy = StoD(sQ) * keV;
1295  }
1296  }
1297 
1298  G4Ions* ion;
1299  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1300  fAtomicMass,
1302  if (ion==0) {
1303  G4cout << "##################################################################"
1304  << G4endl
1305  << "##### ActarSimPrimaryGeneratorMessenger::recoilIonCommand() ####"
1306  << "Ion with Z=" << fAtomicNumber
1307  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1308  G4cout << "##################################################################"
1309  << G4endl;
1310  } else {
1313  //actarSimActionGun->SetRecoilIonExcEnergy(fIonExciteEnergy);
1314  }
1315 }
1316 
1317 //////////////////////////////////////////////////////////////////
1318 /// Particular behavior of the (KINE) recoil ion command. Ion state should be selected.
1320  G4Tokenizer next( newValues );
1321  // check argument
1322  fAtomicNumber = StoI(next());
1323  fAtomicMass = StoI(next());
1324  fIonCharge = StoI(next());
1325  fIonExciteEnergy = StoD(next());
1326  fIonMass=StoD(next());
1327 
1328  G4Ions* ion;
1329  ion = (G4Ions*) ionTable->GetIon(fAtomicNumber,
1330  fAtomicMass,
1332  if (ion==0) {
1333  G4cout << "##################################################################"
1334  << G4endl
1335  << "##### ActarSimPrimaryGeneratorMessenger::KineRecoilIonCommand() ####"
1336  << "Ion with Z=" << fAtomicNumber
1337  << " A=" << fAtomicMass << "can not be defined" << G4endl;
1338  G4cout << "##################################################################"
1339  << G4endl;
1340  } else {
1345  }
1346 }
G4UIcommand * KineTargetIonCmd
Set properties of target ion to be generated.
G4bool fShootIon
Internal variables for ion creation.
void SetBeamMomentumDirection(G4ParticleMomentum aMomentumDirection)
G4UIcmdWithADoubleAndUnit * beamPhiCmd
Sets phi angle for beam (in degrees)
G4UIcmdWith3Vector * beamDirectionCmd
Set beam momentum direction.
G4UIcmdWithADoubleAndUnit * timeCmd
Set initial time of the particle.
G4UIcommand * CinerandomThetaValCmd
Sets the limist in the Theta angle for the scattered particle.
G4UIcommand * recoilIonCmd
Set properties of recoil ion to be generated.
G4UIcmdWithAString * reactionFromCineCmd
Select a reaction using Cine.
G4UIcmdWithAnInteger * numberCmd
Set number of particles to be generated in a single event.
G4UIcmdWithAString * reactionFromCrossSectionCmd
DO NOT USE. Simulates beam/target from the cross-sections. DO NOT USE.
G4UIcmdWithADoubleAndUnit * energyCmd
Sets the kinetic energy of the primary particle.
void SetRandomThetaVal(G4double min, G4double max)
G4UIcmdWithAString * KineRandomThetaCmd
Randomize Theta_CM of outgoing particles.
G4UIdirectory * KineDir
Directory for CINE commands.
G4UIcmdWithADoubleAndUnit * vertexZPositionCmd
Set the Z-value of the reaction vertex.
G4UIcommand * randomThetaValCmd
Sets the limits in the Theta angle for the scattered particle.
void KineTargetIonCommand(G4String newValues)
Particular behavior of the (KINE) target ion command. Ion state should be selected.
G4UIcommand * scatteredIonCmd
Set properties of scattered ion to be generated.
G4UIcmdWith3Vector * polCmd
Set polarization.
G4UIcmdWithADoubleAndUnit * KineUserThetaCMCmd
Sets theta CM angle for scattered particle (in degrees)
G4UIcommand * KineRecoilIonCmd
Set properties of recoil ion to be generated.
G4UIcmdWithADoubleAndUnit * labEnergyCmd
Sets the laboratory energy.
void KineRecoilIonCommand(G4String newValues)
Particular behavior of the (KINE) recoil ion command. Ion state should be selected.
G4String GetCurrentValue(G4UIcommand *command)
Get current value from commands.
G4UIcommand * KineScatteredIonCmd
Set properties of scattered ion to be generated.
G4UIcommand * randomVertexZPositionRangeCmd
Set the min and max Z-value of random vertex position.
G4UIcommand * KineRandomThetaRangeCmd
Sets the limits in the Theta angle for the scattered particle.
G4UIcommand * incidentIonCmd
Set properties of incident ion to be generated.
G4IonTable * ionTable
Pointer to the global particle table.
G4int fIonCharge
Internal variables for ion creation: ion charge.
void SetNewValue(G4UIcommand *, G4String)
Setting the values using the interface.
ActarSimPrimaryGeneratorAction * actarSimActionGun
Pointer to main primary generator class.
void KineIncidentIonCommand(G4String newValues)
Particular behavior of the (KINE) incident ion command. Ion state should be selected.
G4UIcmdWithADoubleAndUnit * beamRadiusAtEntranceCmd
Selects the beam radius at entrance of ACTAR.
ActarSimPrimaryGeneratorMessenger(ActarSimPrimaryGeneratorAction *)
G4UIcmdWithADoubleAndUnit * beamThetaCmd
Sets theta angle for beam (in degrees)
void scatteredIonCommand(G4String newValues)
Particular behavior of the scattered ion command. Ion state should be selected.
G4UIcmdWithAString * particleCmd
Select the incident particle.
void recoilIonCommand(G4String newValues)
Particular behavior of the recoil ion command. Ion state should be selected.
G4UIcommand * randomPhiValCmd
Sets the limits in the Phi angle for the scattered particle.
G4UIcmdWithADoubleAndUnit * thetaLabAngleCmd
Sets theta lab angle for the scattered particle (degrees)
G4UIcommand * KineIncidentIonCmd
Set properties of incident ion to be generated.
G4UIcmdWithoutParameter * listCmd
List available particles.
G4UIcmdWithADoubleAndUnit * KineLabEnergyCmd
Sets the laboratory energy.
G4UIcmdWith3VectorAndUnit * vertexPositionCmd
Set the position of the vertex.
void SetRandomVertexZPositionVal(G4double min, G4double max)
G4UIcmdWithADoubleAndUnit * reactionQCmd
Sets the reaction Q.
G4double fIonExciteEnergy
Internal variables for ion creation: ion excitation energy.
G4UIcmdWithAString * realisticBeamCmd
Simulates beam emittance according to emittance parameters.
G4UIcmdWithADouble * emittanceCmd
Selects the value of the emittance [in mm mrad].
void KineScatteredIonCommand(G4String newValues)
Particular behavior of the (KINE) scattered ion command. Ion state should be selected.
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4UIdirectory * CineDir
Directory for CINE commands.
G4UIcmdWithAString * reactionFileCmd
Select the reaction definition file.
G4UIcmdWithAString * beamInteractionCmd
Simulates the beam energy loss in gas.
G4UIcmdWithAString * randomPhiCmd
Select a random Phi angle for the scattered particle.
G4UIcmdWith3Vector * directionCmd
Set momentum direction.
G4UIcommand * targetIonCmd
Set properties of target ion to be generated.
void incidentIonCommand(G4String newValues)
Particular behavior of the incident ion command. Ion state should be selected.
G4UIcmdWithAString * KineRandomPhiAngleCmd
Randomize Lab Phi angles of out-going particles.
G4ParticleTable * particleTable
Pointer to the global particle table.
G4UIcmdWithAString * reactionFromFileCmd
Select a reaction from an input file.
G4UIcmdWithAString * CinerandomThetaCmd
Select a random Theta angle for the scattered particle.
G4UIcmdWithAString * alphaSourceCmd
NOT VALIDATED. CHECK THIS COMMAND!
G4int fAtomicNumber
Internal variables for ion creation: atomic number.
G4UIcmdWithAString * reactionFromKineCmd
Select a reaction using Kine.
G4UIcmdWithAString * reactionFromEvGenCmd
DO NOT USE. Simulates beam/target from event generator. DO NOT USE.
void IonCommand(G4String newValues)
Particular behavior of the ion command. Ion state should be selected.
G4int fAtomicMass
Internal variables for ion creation: atomic mass.
G4UIdirectory * gunDir
Directory for gun commands.
G4double fIonMass
Internal variables for ion creation: ion mass in atomic mass unit u.
void targetIonCommand(G4String newValues)
Particular behavior of the target ion command. Ion state should be selected.
G4UIcmdWith3VectorAndUnit * positionCmd
Set starting position of the particle.
G4UIcommand * ionCmd
Set properties of ion to be generated.
void SetRandomPhiVal(G4double min, G4double max)
G4UIcmdWithAString * randomThetaCmd
Select a random Theta angle for the scattered particle.
void SetParticleEnergy(G4double aKineticEnergy)
G4UIcmdWithADoubleAndUnit * KineUserPhiAngleCmd
User set phi angle for outgoing particle in the Lab system (in degrees)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
G4UIcmdWithAString * randomVertexZPositionCmd
Randomize the reaction vertex Z position.
G4UIcmdWith3VectorAndUnit * beamPositionCmd
Set beam starting position.