Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4ParticleGunMessenger Class Reference

#include <G4ParticleGunMessenger.hh>

Inheritance diagram for G4ParticleGunMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4ParticleGunMessenger (G4ParticleGun *fPtclGun)
 
G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
 ~G4ParticleGunMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

void IonCommand (const G4String &newValues)
 
void IonLevelCommand (const G4String &newValues)
 

Private Attributes

G4UIcmdWith3VectordirectionCmd
 
G4UIcmdWithADoubleAndUnitenergyCmd
 
G4int fAtomicMass = 0
 
G4int fAtomicNumber = 0
 
G4int fIonCharge = 0
 
G4int fIonEnergyLevel = 0
 
G4double fIonExciteEnergy = 0.0
 
char fIonFloatingLevelBase = '\0'
 
G4ParticleGunfParticleGun = nullptr
 
G4bool fShootIon = false
 
G4UIdirectorygunDirectory
 
G4UIcommandionCmd
 
G4UIcommandionLvlCmd
 
G4UIcmdWithoutParameterlistCmd
 
G4UIcmdWithADoubleAndUnitmomAmpCmd
 
G4UIcmdWith3VectorAndUnitmomCmd
 
G4UIcmdWithAnIntegernumberCmd
 
G4UIcmdWithAStringparticleCmd
 
G4ParticleTableparticleTable = nullptr
 
G4UIcmdWith3VectorpolCmd
 
G4UIcmdWith3VectorAndUnitpositionCmd
 
G4UIcmdWithADoubleAndUnittimeCmd
 

Detailed Description

Definition at line 52 of file G4ParticleGunMessenger.hh.

Constructor & Destructor Documentation

◆ G4ParticleGunMessenger()

G4ParticleGunMessenger::G4ParticleGunMessenger ( G4ParticleGun fPtclGun)

Definition at line 49 of file G4ParticleGunMessenger.cc.

50 : fParticleGun(fPtclGun)
51{
53
54 gunDirectory = new G4UIdirectory("/gun/");
55 gunDirectory->SetGuidance("Particle Gun control commands.");
56
57 listCmd = new G4UIcmdWithoutParameter("/gun/List",this);
58 listCmd->SetGuidance("List available particles.");
59 listCmd->SetGuidance(" Invoke G4ParticleTable.");
60
61 particleCmd = new G4UIcmdWithAString("/gun/particle",this);
62 particleCmd->SetGuidance("Set particle to be generated.");
63 particleCmd->SetGuidance(" (geantino is default)");
64 particleCmd->SetGuidance(" (ion can be specified for shooting ions)");
65 particleCmd->SetParameterName("particleName",true);
66 particleCmd->SetDefaultValue("geantino");
67 G4String candidateList;
69 itr->reset();
70 while( (*itr)() )
71 {
72 G4ParticleDefinition* pd = itr->value();
73 if( !(pd->IsShortLived()) || pd->GetDecayTable() != nullptr )
74 {
75 candidateList += pd->GetParticleName();
76 candidateList += " ";
77 }
78 }
79 candidateList += "ion ";
80 particleCmd->SetCandidates(candidateList);
81
82 directionCmd = new G4UIcmdWith3Vector("/gun/direction",this);
83 directionCmd->SetGuidance("Set momentum direction.");
84 directionCmd->SetGuidance(" Direction needs not to be a unit vector.");
85 directionCmd->SetParameterName("ex","ey","ez",true,true);
86 directionCmd->SetRange("ex != 0 || ey != 0 || ez != 0");
87
88 energyCmd = new G4UIcmdWithADoubleAndUnit("/gun/energy",this);
89 energyCmd->SetGuidance("Set kinetic energy.");
90 energyCmd->SetParameterName("Energy",true,true);
92 //energyCmd->SetUnitCategory("Energy");
93 //energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
94
95 momCmd = new G4UIcmdWith3VectorAndUnit("/gun/momentum",this);
96 momCmd->SetGuidance("Set momentum. This command is equivalent to two commands");
97 momCmd->SetGuidance(" /gun/direction and /gun/momentumAmp");
98 momCmd->SetParameterName("px","py","pz",true,true);
99 momCmd->SetRange("px != 0 || py != 0 || pz != 0");
100 momCmd->SetDefaultUnit("GeV");
101
102 momAmpCmd = new G4UIcmdWithADoubleAndUnit("/gun/momentumAmp",this);
103 momAmpCmd->SetGuidance("Set absolute value of momentum.");
104 momAmpCmd->SetGuidance(" Direction should be set by /gun/direction command.");
105 momAmpCmd->SetGuidance(" This command should be used alternatively with /gun/energy.");
106 momAmpCmd->SetParameterName("Momentum",true,true);
108
109 positionCmd = new G4UIcmdWith3VectorAndUnit("/gun/position",this);
110 positionCmd->SetGuidance("Set starting position of the particle.");
111 positionCmd->SetParameterName("X","Y","Z",true,true);
113 // positionCmd->SetUnitCategory("Length");
114 // positionCmd->SetUnitCandidates("microm mm cm m km");
115
116 timeCmd = new G4UIcmdWithADoubleAndUnit("/gun/time",this);
117 timeCmd->SetGuidance("Set initial time of the particle.");
118 timeCmd->SetParameterName("t0",true,true);
119 timeCmd->SetDefaultUnit("ns");
120 // timeCmd->SetUnitCategory("Time");
121 // timeCmd->SetUnitCandidates("ns ms s");
122
123 polCmd = new G4UIcmdWith3Vector("/gun/polarization",this);
124 polCmd->SetGuidance("Set polarization.");
125 polCmd->SetParameterName("Px","Py","Pz",true,true);
126 polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
127
128 numberCmd = new G4UIcmdWithAnInteger("/gun/number",this);
129 numberCmd->SetGuidance("Set number of particles to be generated.");
130 numberCmd->SetParameterName("N",true,true);
131 numberCmd->SetRange("N>0");
132
133 ionCmd = new G4UIcommand("/gun/ion",this);
134 ionCmd->SetGuidance("Set properties of ion to be generated.");
135 ionCmd->SetGuidance("[usage] /gun/ion Z A [Q E flb]");
136 ionCmd->SetGuidance(" Z:(int) AtomicNumber");
137 ionCmd->SetGuidance(" A:(int) AtomicMass");
138 ionCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)");
139 ionCmd->SetGuidance(" E:(double) Excitation energy (in keV)");
140 ionCmd->SetGuidance(" flb:(char) Floating level base");
141
142 G4UIparameter* param;
143 param = new G4UIparameter("Z",'i',false);
144 ionCmd->SetParameter(param);
145 param = new G4UIparameter("A",'i',false);
146 ionCmd->SetParameter(param);
147 param = new G4UIparameter("Q",'i',true);
148 param->SetDefaultValue(-1);
149 ionCmd->SetParameter(param);
150 param = new G4UIparameter("E",'d',true);
151 param->SetDefaultValue(0.0);
152 ionCmd->SetParameter(param);
153 param = new G4UIparameter("flb",'c',true);
154 param->SetDefaultValue("noFloat");
155 param->SetParameterCandidates("noFloat X Y Z U V W R S T A B C D E");
156 ionCmd->SetParameter(param);
157
158 ionLvlCmd = new G4UIcommand("/gun/ionL",this);
159 ionLvlCmd->SetGuidance("THIS COMMAND IS DEPRECATED and will be removed in future releases.");
160 ionLvlCmd->SetGuidance(" Use /gun/ion instead.");
161 ionLvlCmd->SetGuidance(" Set properties of ion to be generated.");
162 ionLvlCmd->SetGuidance(" [usage] /gun/ionL Z A [Q I]");
163 ionLvlCmd->SetGuidance(" Z:(int) AtomicNumber");
164 ionLvlCmd->SetGuidance(" A:(int) AtomicMass");
165 ionLvlCmd->SetGuidance(" Q:(int) Charge of Ion (in unit of e)");
166 ionLvlCmd->SetGuidance(" I:(int) Level number of metastable state (0 = ground)");
167
168 G4UIparameter* paraml;
169 paraml = new G4UIparameter("Z",'i',false);
170 ionLvlCmd->SetParameter(paraml);
171 paraml = new G4UIparameter("A",'i',false);
172 ionLvlCmd->SetParameter(paraml);
173 paraml = new G4UIparameter("Q",'i',true);
174 paraml->SetDefaultValue(-1);
175 ionLvlCmd->SetParameter(paraml);
176 paraml = new G4UIparameter("I",'i',true);
177 paraml->SetDefaultValue("0");
178 ionLvlCmd->SetParameter(paraml);
179
180 // Set initial value to G4ParticleGun
181 //
187}
static constexpr double GeV
Definition: G4SIunits.hh:203
static constexpr double cm
Definition: G4SIunits.hh:99
CLHEP::Hep3Vector G4ThreeVector
static G4Geantino * Geantino()
Definition: G4Geantino.cc:86
G4DecayTable * GetDecayTable() const
const G4String & GetParticleName() const
G4UIcmdWithAString * particleCmd
G4UIcmdWith3Vector * directionCmd
G4UIcmdWith3VectorAndUnit * positionCmd
G4UIcmdWithoutParameter * listCmd
G4UIcmdWithADoubleAndUnit * timeCmd
G4UIcmdWithADoubleAndUnit * momAmpCmd
G4UIcmdWithAnInteger * numberCmd
G4UIcmdWith3Vector * polCmd
G4UIcmdWithADoubleAndUnit * energyCmd
G4UIcmdWith3VectorAndUnit * momCmd
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
void SetParticleEnergy(G4double aKineticEnergy)
void SetParticleMomentumDirection(G4ParticleMomentum aMomDirection)
void reset(G4bool ifSkipIon=true)
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void SetDefaultValue(const char *theDefaultValue)
void SetParameterCandidates(const char *theString)
void SetParticleTime(G4double aTime)
void SetParticlePosition(G4ThreeVector aPosition)
#define ns
Definition: xmlparse.cc:614

References cm, directionCmd, energyCmd, fParticleGun, G4Geantino::Geantino(), G4ParticleDefinition::GetDecayTable(), G4ParticleTable::GetIterator(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetParticleTable(), GeV, gunDirectory, ionCmd, ionLvlCmd, G4ParticleDefinition::IsShortLived(), listCmd, momAmpCmd, momCmd, ns, numberCmd, particleCmd, particleTable, polCmd, positionCmd, G4ParticleTableIterator< K, V >::reset(), G4UIcmdWithAString::SetCandidates(), G4UIcmdWith3VectorAndUnit::SetDefaultUnit(), G4UIcmdWithADoubleAndUnit::SetDefaultUnit(), G4UIcmdWithAString::SetDefaultValue(), G4UIparameter::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIparameter::SetParameterCandidates(), G4UIcmdWithADoubleAndUnit::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIcmdWith3Vector::SetParameterName(), G4UIcmdWith3VectorAndUnit::SetParameterName(), G4ParticleGun::SetParticleDefinition(), G4ParticleGun::SetParticleEnergy(), G4ParticleGun::SetParticleMomentumDirection(), G4VPrimaryGenerator::SetParticlePosition(), G4VPrimaryGenerator::SetParticleTime(), G4UIcommand::SetRange(), timeCmd, and G4ParticleTableIterator< K, V >::value().

◆ ~G4ParticleGunMessenger()

G4ParticleGunMessenger::~G4ParticleGunMessenger ( )

Definition at line 189 of file G4ParticleGunMessenger.cc.

190{
191 delete listCmd;
192 delete particleCmd;
193 delete directionCmd;
194 delete energyCmd;
195 delete momCmd;
196 delete momAmpCmd;
197 delete positionCmd;
198 delete timeCmd;
199 delete polCmd;
200 delete numberCmd;
201 delete ionCmd;
202 delete ionLvlCmd;
203 delete gunDirectory;
204}

References directionCmd, energyCmd, gunDirectory, ionCmd, ionLvlCmd, listCmd, momAmpCmd, momCmd, numberCmd, particleCmd, polCmd, positionCmd, and timeCmd.

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4ParticleGunMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 283 of file G4ParticleGunMessenger.cc.

284{
285 G4String cv;
286
287 if( command==directionCmd )
289 else if( command==particleCmd )
291 else if( command==energyCmd )
292 {
294 if(ene == 0.)
295 { G4cerr << " G4ParticleGun: was defined in terms of momentum." << G4endl; }
296 else
297 { cv = energyCmd->ConvertToString(ene,"GeV"); }
298 }
299 else if( command==momCmd || command==momAmpCmd )
300 {
302 if(mom == 0.)
303 {
304 G4cerr << " G4ParticleGun: was defined in terms of kinetic energy."
305 << G4endl;
306 }
307 else
308 {
309 if( command==momCmd )
311 else
312 { cv = momAmpCmd->ConvertToString(mom,"GeV"); }
313 }
314 }
315 else if( command==positionCmd )
317 else if( command==timeCmd )
319 else if( command==polCmd )
321 else if( command==numberCmd )
323 else if( command==ionCmd )
324 {
325 if (fShootIon)
326 {
327 cv = ItoS(fAtomicNumber) + " " + ItoS(fAtomicMass) + " ";
328 cv += ItoS(fIonCharge);
329 }
330 else
331 {
332 cv = "";
333 }
334 }
335 return cv;
336}
double G4double
Definition: G4Types.hh:83
G4ThreeVector GetParticlePolarization() const
G4ParticleMomentum GetParticleMomentumDirection() const
G4double GetParticleMomentum() const
G4ParticleDefinition * GetParticleDefinition() const
G4int GetNumberOfParticles() const
G4double GetParticleEnergy() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
G4String ItoS(G4int i)
G4ThreeVector GetParticlePosition()

References G4UIcommand::ConvertToString(), directionCmd, energyCmd, fAtomicMass, fAtomicNumber, fIonCharge, fParticleGun, fShootIon, G4cerr, G4endl, G4ParticleGun::GetNumberOfParticles(), G4ParticleGun::GetParticleDefinition(), G4ParticleGun::GetParticleEnergy(), G4ParticleGun::GetParticleMomentum(), G4ParticleGun::GetParticleMomentumDirection(), G4ParticleDefinition::GetParticleName(), G4ParticleGun::GetParticlePolarization(), G4VPrimaryGenerator::GetParticlePosition(), G4VPrimaryGenerator::GetParticleTime(), ionCmd, G4UImessenger::ItoS(), momAmpCmd, momCmd, numberCmd, particleCmd, polCmd, positionCmd, and timeCmd.

◆ IonCommand()

void G4ParticleGunMessenger::IonCommand ( const G4String newValues)
private

Definition at line 380 of file G4ParticleGunMessenger.cc.

381{
382 G4Tokenizer next( newValues );
383
384 // Check argument
385 //
386 fAtomicNumber = StoI(next());
387 fAtomicMass = StoI(next());
389 fIonExciteEnergy = 0.0;
391 G4String sQ = next();
392 if (!(sQ.empty()))
393 {
394 if (StoI(sQ)>=0)
395 fIonCharge = StoI(sQ);
396
397 sQ = next();
398 if (!(sQ.empty()))
399 {
400 fIonExciteEnergy = StoD(sQ) * keV;
401
402 sQ = next();
403 if (sQ.empty()||sQ=="noFloat")
404 { fIonFloatingLevelBase = '\0'; }
405 else
406 { fIonFloatingLevelBase = sQ[(std::size_t)0]; }
407 }
408 }
411 if (ion==nullptr)
412 {
414 ed << "Ion with Z=" << fAtomicNumber;
415 ed << " A=" << fAtomicMass << "is not defined";
417 }
418 else
419 {
422 }
423}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static constexpr double eplus
Definition: G4SIunits.hh:184
static constexpr double keV
Definition: G4SIunits.hh:202
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:522
static G4IonTable * GetIonTable()
Definition: G4IonTable.cc:170
void SetParticleCharge(G4double aCharge)
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
G4int StoI(G4String s)
G4double StoD(G4String s)

References G4UIcommand::CommandFailed(), eplus, fAtomicMass, fAtomicNumber, fIonCharge, fIonExciteEnergy, fIonFloatingLevelBase, fParticleGun, G4IonTable::GetIon(), G4IonTable::GetIonTable(), ionCmd, keV, G4ParticleGun::SetParticleCharge(), G4ParticleGun::SetParticleDefinition(), G4UImessenger::StoD(), and G4UImessenger::StoI().

Referenced by SetNewValue().

◆ IonLevelCommand()

void G4ParticleGunMessenger::IonLevelCommand ( const G4String newValues)
private

Definition at line 338 of file G4ParticleGunMessenger.cc.

339{
340 G4Tokenizer next( newValues );
341
342 // Check argument
343 //
344 fAtomicNumber = StoI(next());
345 fAtomicMass = StoI(next());
346 G4String sQ = next();
347 if (sQ.empty() || StoI(sQ)<0)
348 {
350 }
351 else
352 {
353 fIonCharge = StoI(sQ);
354 }
355 sQ = next();
356 if (sQ.empty())
357 {
358 fIonEnergyLevel = 0;
359 }
360 else
361 {
362 fIonEnergyLevel = StoI(sQ);
363 }
366 if (ion == nullptr)
367 {
369 ed << "Ion with Z = " << fAtomicNumber << ", A = " << fAtomicMass
370 << ", I = " << fIonEnergyLevel << " is not defined ";
372 }
373 else
374 {
377 }
378}

References G4UIcommand::CommandFailed(), eplus, fAtomicMass, fAtomicNumber, fIonCharge, fIonEnergyLevel, fParticleGun, G4IonTable::GetIon(), G4IonTable::GetIonTable(), ionLvlCmd, G4ParticleGun::SetParticleCharge(), G4ParticleGun::SetParticleDefinition(), and G4UImessenger::StoI().

Referenced by SetNewValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 206 of file G4ParticleGunMessenger.cc.

208{
210 if (command==listCmd)
211 {
213 }
214 else if (command==particleCmd)
215 {
216 if (newValues =="ion")
217 {
218 fShootIon = true;
219 }
220 else
221 {
222 fShootIon = false;
224 if(pd != nullptr)
225 {
227 }
228 else
229 {
230 ed << "Particle [" << newValues << "] is not found.";
231 command->CommandFailed(ed);
232 }
233 }
234
235 } else if( command==directionCmd )
237 else if( command==energyCmd )
239 else if( command==momCmd )
241 else if( command==momAmpCmd )
243 else if( command==positionCmd )
245 else if( command==timeCmd )
247 else if( command==polCmd )
249 else if( command==numberCmd )
251 else if( command==ionCmd )
252 {
253 if (fShootIon)
254 {
255 IonCommand(newValues);
256 }
257 else
258 {
259 ed << "Set /gun/particle to ion before using /gun/ion command";
260 command->CommandFailed(ed);
261 }
262 }
263 else if( command==ionLvlCmd )
264 {
265 G4ExceptionDescription depWarn;
266 depWarn << "\nCommand /gun/ionL is deprecated and will be removed in future releases.\n"
267 << "Use /gun/ion instead.\n";
268 G4Exception("G4ParticleGunMessenger::SetNewValue", "IonLWarn",
269 JustWarning, depWarn);
270
271 if (fShootIon)
272 {
273 IonLevelCommand(newValues);
274 }
275 else
276 {
277 ed << "Set /gun/particle to ion before using /gun/ion command";
278 command->CommandFailed(ed);
279 }
280 }
281}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
void IonLevelCommand(const G4String &newValues)
void IonCommand(const G4String &newValues)
void SetNumberOfParticles(G4int i)
void SetParticlePolarization(G4ThreeVector aVal)
void SetParticleMomentum(G4double aMomentum)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void DumpTable(const G4String &particle_name="ALL")
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)

References G4UIcommand::CommandFailed(), directionCmd, G4ParticleTable::DumpTable(), energyCmd, G4ParticleTable::FindParticle(), fParticleGun, fShootIon, G4Exception(), G4UIcmdWith3Vector::GetNew3VectorValue(), G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(), G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(), G4UIcmdWithAnInteger::GetNewIntValue(), ionCmd, IonCommand(), IonLevelCommand(), ionLvlCmd, JustWarning, listCmd, momAmpCmd, momCmd, numberCmd, particleCmd, particleTable, polCmd, positionCmd, G4ParticleGun::SetNumberOfParticles(), G4ParticleGun::SetParticleDefinition(), G4ParticleGun::SetParticleEnergy(), G4ParticleGun::SetParticleMomentum(), G4ParticleGun::SetParticleMomentumDirection(), G4ParticleGun::SetParticlePolarization(), G4VPrimaryGenerator::SetParticlePosition(), G4VPrimaryGenerator::SetParticleTime(), and timeCmd.

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ directionCmd

G4UIcmdWith3Vector* G4ParticleGunMessenger::directionCmd
private

◆ energyCmd

G4UIcmdWithADoubleAndUnit* G4ParticleGunMessenger::energyCmd
private

◆ fAtomicMass

G4int G4ParticleGunMessenger::fAtomicMass = 0
private

Definition at line 92 of file G4ParticleGunMessenger.hh.

Referenced by GetCurrentValue(), IonCommand(), and IonLevelCommand().

◆ fAtomicNumber

G4int G4ParticleGunMessenger::fAtomicNumber = 0
private

Definition at line 91 of file G4ParticleGunMessenger.hh.

Referenced by GetCurrentValue(), IonCommand(), and IonLevelCommand().

◆ fIonCharge

G4int G4ParticleGunMessenger::fIonCharge = 0
private

Definition at line 93 of file G4ParticleGunMessenger.hh.

Referenced by GetCurrentValue(), IonCommand(), and IonLevelCommand().

◆ fIonEnergyLevel

G4int G4ParticleGunMessenger::fIonEnergyLevel = 0
private

Definition at line 96 of file G4ParticleGunMessenger.hh.

Referenced by IonLevelCommand().

◆ fIonExciteEnergy

G4double G4ParticleGunMessenger::fIonExciteEnergy = 0.0
private

Definition at line 94 of file G4ParticleGunMessenger.hh.

Referenced by IonCommand().

◆ fIonFloatingLevelBase

char G4ParticleGunMessenger::fIonFloatingLevelBase = '\0'
private

Definition at line 95 of file G4ParticleGunMessenger.hh.

Referenced by IonCommand().

◆ fParticleGun

G4ParticleGun* G4ParticleGunMessenger::fParticleGun = nullptr
private

◆ fShootIon

G4bool G4ParticleGunMessenger::fShootIon = false
private

Definition at line 90 of file G4ParticleGunMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ gunDirectory

G4UIdirectory* G4ParticleGunMessenger::gunDirectory
private

Definition at line 74 of file G4ParticleGunMessenger.hh.

Referenced by G4ParticleGunMessenger(), and ~G4ParticleGunMessenger().

◆ ionCmd

G4UIcommand* G4ParticleGunMessenger::ionCmd
private

◆ ionLvlCmd

G4UIcommand* G4ParticleGunMessenger::ionLvlCmd
private

◆ listCmd

G4UIcmdWithoutParameter* G4ParticleGunMessenger::listCmd
private

◆ momAmpCmd

G4UIcmdWithADoubleAndUnit* G4ParticleGunMessenger::momAmpCmd
private

◆ momCmd

G4UIcmdWith3VectorAndUnit* G4ParticleGunMessenger::momCmd
private

◆ numberCmd

G4UIcmdWithAnInteger* G4ParticleGunMessenger::numberCmd
private

◆ particleCmd

G4UIcmdWithAString* G4ParticleGunMessenger::particleCmd
private

◆ particleTable

G4ParticleTable* G4ParticleGunMessenger::particleTable = nullptr
private

Definition at line 70 of file G4ParticleGunMessenger.hh.

Referenced by G4ParticleGunMessenger(), and SetNewValue().

◆ polCmd

G4UIcmdWith3Vector* G4ParticleGunMessenger::polCmd
private

◆ positionCmd

G4UIcmdWith3VectorAndUnit* G4ParticleGunMessenger::positionCmd
private

◆ timeCmd

G4UIcmdWithADoubleAndUnit* G4ParticleGunMessenger::timeCmd
private

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