Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
DMXParticleSourceMessenger Class Reference

#include <DMXParticleSourceMessenger.hh>

Inheritance diagram for DMXParticleSourceMessenger:
G4UImessenger

Public Member Functions

 DMXParticleSourceMessenger (DMXParticleSource *fPtclGun)
 
 ~DMXParticleSourceMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Detailed Description

Definition at line 69 of file DMXParticleSourceMessenger.hh.

Constructor & Destructor Documentation

DMXParticleSourceMessenger::DMXParticleSourceMessenger ( DMXParticleSource fPtclGun)

Definition at line 71 of file DMXParticleSourceMessenger.cc.

References G4ParticleTable::GetParticleTable(), and G4UIparameter::SetDefaultValue().

71  : fParticleGun(fPtclGun),fShootIon(false) {
72 
73  particleTable = G4ParticleTable::GetParticleTable();
74 
75  // create directory
76  gunDirectory = new G4UIdirectory("/dmx/gun/");
77  gunDirectory->SetGuidance("Particle Source control commands.");
78 
79  // list available particles
80  listCmd = new G4UIcmdWithoutParameter("/dmx/gun/List",this);
81  listCmd->SetGuidance("List available particles.");
82  listCmd->SetGuidance(" Invoke G4ParticleTable.");
83 
84  // set particle
85  particleCmd = new G4UIcmdWithAString("/dmx/gun/particle",this);
86  particleCmd->SetGuidance("Set particle to be generated.");
87  particleCmd->SetGuidance(" (geantino is default)");
88  particleCmd->SetGuidance(" (ion can be specified for shooting ions)");
89  particleCmd->SetParameterName("particleName",true);
90  particleCmd->SetDefaultValue("geantino");
91  G4String candidateList;
92  G4int nPtcl = particleTable->entries();
93  for(G4int i=0;i<nPtcl;i++)
94  {
95  candidateList += particleTable->GetParticleName(i);
96  candidateList += " ";
97  }
98  candidateList += "ion ";
99  particleCmd->SetCandidates(candidateList);
100 
101 
102  // particle direction
103  directionCmd = new G4UIcmdWith3Vector("/dmx/gun/direction",this);
104  directionCmd->SetGuidance("Set momentum direction.");
105  directionCmd->SetGuidance("Direction needs not to be a unit vector.");
106  directionCmd->SetParameterName("Px","Py","Pz",true,true);
107  directionCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
108 
109  // particle energy
110  energyCmd = new G4UIcmdWithADoubleAndUnit("/dmx/gun/energy",this);
111  energyCmd->SetGuidance("Set kinetic energy.");
112  energyCmd->SetParameterName("Energy",true,true);
113  energyCmd->SetDefaultUnit("GeV");
114  //energyCmd->SetUnitCategory("Energy");
115  //energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
116 
117  positionCmd = new G4UIcmdWith3VectorAndUnit("/dmx/gun/position",this);
118  positionCmd->SetGuidance("Set starting position of the particle.");
119  positionCmd->SetParameterName("X","Y","Z",true,true);
120  positionCmd->SetDefaultUnit("cm");
121  //positionCmd->SetUnitCategory("Length");
122  //positionCmd->SetUnitCandidates("microm mm cm m km");
123 
124 
125  // ion
126  ionCmd = new G4UIcommand("/dmx/gun/ion",this);
127  ionCmd->SetGuidance("Set properties of ion to be generated.");
128  ionCmd->SetGuidance("[usage] /gun/ion Z A Q E");
129  ionCmd->SetGuidance(" Z:(int) AtomicNumber");
130  ionCmd->SetGuidance(" A:(int) AtomicMass");
131  ionCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)");
132  ionCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
133 
134  G4UIparameter* param;
135  param = new G4UIparameter("Z",'i',false);
136  param->SetDefaultValue("1");
137  ionCmd->SetParameter(param);
138  param = new G4UIparameter("A",'i',false);
139  param->SetDefaultValue("1");
140  ionCmd->SetParameter(param);
141  param = new G4UIparameter("Q",'i',true);
142  param->SetDefaultValue("0");
143  ionCmd->SetParameter(param);
144  param = new G4UIparameter("E",'d',true);
145  param->SetDefaultValue("0.0");
146  ionCmd->SetParameter(param);
147 
148 
149  // source distribution type
150  typeCmd = new G4UIcmdWithAString("/dmx/gun/type",this);
151  typeCmd->SetGuidance("Sets source distribution type.");
152  typeCmd->SetGuidance("Either Point or Volume");
153  typeCmd->SetParameterName("DisType",true,true);
154  typeCmd->SetDefaultValue("Point");
155  typeCmd->SetCandidates("Point Volume");
156 
157  // source shape
158  shapeCmd = new G4UIcmdWithAString("/dmx/gun/shape",this);
159  shapeCmd->SetGuidance("Sets source shape type.");
160  shapeCmd->SetParameterName("Shape",true,true);
161  shapeCmd->SetDefaultValue("NULL");
162  shapeCmd->SetCandidates("Sphere Cylinder");
163 
164  // centre coordinates
165  centreCmd = new G4UIcmdWith3VectorAndUnit("/dmx/gun/centre",this);
166  centreCmd->SetGuidance("Set centre coordinates of source.");
167  centreCmd->SetParameterName("X","Y","Z",true,true);
168  centreCmd->SetDefaultUnit("cm");
169  centreCmd->SetUnitCandidates("nm um mm cm m km");
170 
171  // half height of source
172  halfzCmd = new G4UIcmdWithADoubleAndUnit("/dmx/gun/halfz",this);
173  halfzCmd->SetGuidance("Set z half length of source.");
174  halfzCmd->SetParameterName("Halfz",true,true);
175  halfzCmd->SetDefaultUnit("cm");
176  halfzCmd->SetUnitCandidates("nm um mm cm m km");
177 
178  // radius of source
179  radiusCmd = new G4UIcmdWithADoubleAndUnit("/dmx/gun/radius",this);
180  radiusCmd->SetGuidance("Set radius of source.");
181  radiusCmd->SetParameterName("Radius",true,true);
182  radiusCmd->SetDefaultUnit("cm");
183  radiusCmd->SetUnitCandidates("nm um mm cm m km");
184 
185  // confine to volume
186  confineCmd = new G4UIcmdWithAString("/dmx/gun/confine",this);
187  confineCmd->SetGuidance("Confine source to volume (NULL to unset).");
188  confineCmd->SetGuidance("usage: confine VolName");
189  confineCmd->SetParameterName("VolName",true,true);
190  confineCmd->SetDefaultValue("NULL");
191 
192  // angular distribution
193  angtypeCmd = new G4UIcmdWithAString("/dmx/gun/angtype",this);
194  angtypeCmd->SetGuidance("Sets angular source distribution type");
195  angtypeCmd->SetGuidance("Possible variables are: iso direction");
196  angtypeCmd->SetParameterName("AngDis",true,true);
197  angtypeCmd->SetDefaultValue("iso");
198  angtypeCmd->SetCandidates("iso direction");
199 
200  // energy distribution
201  energytypeCmd = new G4UIcmdWithAString("/dmx/gun/energytype",this);
202  energytypeCmd->SetGuidance("Sets energy distribution type");
203  energytypeCmd->SetGuidance("Possible variables are: Mono");
204  energytypeCmd->SetParameterName("EnergyDis",true,true);
205  energytypeCmd->SetDefaultValue("Mono");
206  energytypeCmd->SetCandidates("Mono");
207 
208  // verbosity
209  verbosityCmd = new G4UIcmdWithAnInteger("/dmx/gun/verbose",this);
210  verbosityCmd->SetGuidance("Set Verbose level for gun");
211  verbosityCmd->SetGuidance(" 0 : Silent");
212  verbosityCmd->SetGuidance(" 1 : Limited information");
213  verbosityCmd->SetGuidance(" 2 : Detailed information");
214  verbosityCmd->SetParameterName("level",false);
215  verbosityCmd->SetRange("level>=0 && level <=2");
216 
217 }
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
const G4String & GetParticleName(G4int index) const
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *theDefaultValue)
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
static G4ParticleTable * GetParticleTable()
void SetDefaultValue(const char *defVal)
void SetDefaultUnit(const char *defUnit)
void SetCandidates(const char *candidateList)
void SetUnitCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4int entries() const
void SetUnitCandidates(const char *candidateList)
DMXParticleSourceMessenger::~DMXParticleSourceMessenger ( )

Definition at line 220 of file DMXParticleSourceMessenger.cc.

220  {
221 
222  delete typeCmd;
223  delete shapeCmd;
224  delete centreCmd;
225  delete halfzCmd;
226  delete radiusCmd;
227  delete confineCmd;
228  delete angtypeCmd;
229  delete energytypeCmd;
230  delete verbosityCmd;
231  delete ionCmd;
232  delete particleCmd;
233  delete positionCmd;
234  delete directionCmd;
235  delete energyCmd;
236  delete listCmd;
237 
238  delete gunDirectory;
239 }

Member Function Documentation

void DMXParticleSourceMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 242 of file DMXParticleSourceMessenger.cc.

References python.hepunit::eplus, G4cout, G4endl, G4String::isNull(), and python.hepunit::keV.

242  {
243 
244  if(command == typeCmd)
245  fParticleGun->SetPosDisType(newValues);
246 
247  else if(command == shapeCmd)
248  fParticleGun->SetPosDisShape(newValues);
249 
250  else if(command == centreCmd)
251  fParticleGun->SetCentreCoords(centreCmd->GetNew3VectorValue(newValues));
252 
253  else if(command == halfzCmd)
254  fParticleGun->SetHalfZ(halfzCmd->GetNewDoubleValue(newValues));
255 
256  else if(command == radiusCmd)
257  fParticleGun->SetRadius(radiusCmd->GetNewDoubleValue(newValues));
258 
259  else if(command == angtypeCmd)
260  fParticleGun->SetAngDistType(newValues);
261 
262  else if(command == confineCmd)
263  fParticleGun->ConfineSourceToVolume(newValues);
264 
265  else if(command == energytypeCmd)
266  fParticleGun->SetEnergyDisType(newValues);
267 
268  else if(command == verbosityCmd)
269  fParticleGun->SetVerbosity(verbosityCmd->GetNewIntValue(newValues));
270 
271  else if( command==particleCmd ) {
272  if (newValues =="ion") {
273  fShootIon = true;
274  } else {
275  fShootIon = false;
276  G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
277  if(pd != NULL)
278  { fParticleGun->SetParticleDefinition( pd ); }
279  }
280  }
281 
282  else if( command==ionCmd ) {
283  if (fShootIon) {
284  G4Tokenizer next( newValues );
285  // check argument
286  fAtomicNumber = StoI(next());
287  fAtomicMass = StoI(next());
288  G4String sQ = next();
289  if (sQ.isNull()) {
290  fIonCharge = fAtomicNumber;
291  } else {
292  fIonCharge = StoI(sQ);
293  sQ = next();
294  if (sQ.isNull()) {
295  fIonExciteEnergy = 0.0;
296  } else {
297  fIonExciteEnergy = StoD(sQ) * keV;
298  }
299  }
300 
302  ion = particleTable->GetIon(fAtomicNumber,fAtomicMass,fIonExciteEnergy);
303  if (ion==0) {
304  G4cout << "Ion with Z=" << fAtomicNumber;
305  G4cout << " A=" << fAtomicMass << "is not be defined" << G4endl;
306  } else {
307  fParticleGun->SetParticleDefinition(ion);
308  fParticleGun->SetParticleCharge(fIonCharge*eplus);
309  }
310  } else {
311  G4cout<<"Set /dmx/gun/particle to ion before using /dmx/gun/ion command";
312  G4cout<<G4endl;
313  }
314  }
315 
316  else if( command==listCmd )
317  particleTable->DumpTable();
318 
319  else if( command==directionCmd ) {
320  fParticleGun->SetAngDistType("direction");
321  fParticleGun->SetParticleMomentumDirection
322  (directionCmd->GetNew3VectorValue(newValues));
323  }
324 
325  else if( command==energyCmd ) {
326  fParticleGun->SetEnergyDisType("Mono");
327  fParticleGun->SetMonoEnergy(energyCmd->GetNewDoubleValue(newValues));
328  }
329 
330  else if( command==positionCmd ) {
331  fParticleGun->SetPosDisType("Point");
332  fParticleGun->SetCentreCoords(positionCmd->GetNew3VectorValue(newValues));
333  }
334  else
335  G4cout << "Error entering command" << G4endl;
336 }
void SetCentreCoords(G4ThreeVector)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void DumpTable(const G4String &particle_name="ALL")
void SetAngDistType(G4String)
static G4int GetNewIntValue(const char *paramString)
G4ParticleDefinition * GetIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
void SetHalfZ(G4double)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
void SetParticleMomentumDirection(G4ParticleMomentum)
G4GLOB_DLL std::ostream G4cout
void SetPosDisType(G4String)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParticleCharge(G4double aCharge)
G4int StoI(G4String s)
void SetRadius(G4double)
void SetPosDisShape(G4String)
G4double StoD(G4String s)
#define G4endl
Definition: G4ios.hh:61
void SetEnergyDisType(G4String)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4bool isNull() const
void ConfineSourceToVolume(G4String)
void SetMonoEnergy(G4double)

The documentation for this class was generated from the following files: