Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleMessenger Class Reference

#include <G4ParticleMessenger.hh>

+ Inheritance diagram for G4ParticleMessenger:

Public Member Functions

 G4ParticleMessenger (G4ParticleTable *pTable=0)
 
virtual ~G4ParticleMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
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)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Detailed Description

Definition at line 92 of file G4ParticleMessenger.hh.

Constructor & Destructor Documentation

◆ G4ParticleMessenger()

G4ParticleMessenger::G4ParticleMessenger ( G4ParticleTable pTable = 0)

Definition at line 60 of file G4ParticleMessenger.cc.

61{
62 // get the pointer to ParticleTable
63 if ( pTable == 0) {
64 theParticleTable = G4ParticleTable::GetParticleTable();
65 } else {
66 theParticleTable = pTable;
67 }
68
69 //Directory /particle/
70 thisDirectory = new G4UIdirectory("/particle/");
71 thisDirectory->SetGuidance("Particle control commands.");
72
73 //Commnad /particle/select
74 selectCmd = new G4UIcmdWithAString("/particle/select",this);
75 selectCmd->SetGuidance("Select particle ");
76 selectCmd->SetDefaultValue("none");
77 selectCmd->SetParameterName("particle name", false);
79
80 //Commnad /particle/list
81 listCmd = new G4UIcmdWithAString("/particle/list",this);
82 listCmd->SetGuidance("List name of particles.");
83 listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
84 listCmd->SetParameterName("particle type", true);
85 listCmd->SetDefaultValue("all");
86 listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
88
89 //Commnad /particle/find
90 findCmd = new G4UIcmdWithAnInteger("/particle/find",this);
91 findCmd->SetGuidance("Find particle by encoding");
92 findCmd->SetDefaultValue(0);
93 findCmd->SetParameterName("encoding", false);
95
96 //Commnad /particle/createAllIon
97 createAllCmd = new G4UIcmdWithoutParameter("/particle/createAllIon",this);
98 createAllCmd->SetGuidance("Create All ions");
99 createAllCmd->AvailableForStates(G4State_Idle);
100
101 // -- particle/property/Verbose ---
102 verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose",this);
103 verboseCmd->SetGuidance("Set Verbose level of particle table.");
104 verboseCmd->SetGuidance(" 0 : Silent (default)");
105 verboseCmd->SetGuidance(" 1 : Display warning messages");
106 verboseCmd->SetGuidance(" 2 : Display more");
107 verboseCmd->SetParameterName("verbose_level",true);
108 verboseCmd->SetDefaultValue(0);
109 verboseCmd->SetRange("verbose_level >=0");
110
111 currentParticle = 0;
112
113 //UI messenger for Particle Properties
114 fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
115
116}
@ G4State_Idle
@ G4State_PreInit
static G4ParticleTable * GetParticleTable()
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 SetDefaultValue(G4int defVal)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:219

◆ ~G4ParticleMessenger()

G4ParticleMessenger::~G4ParticleMessenger ( )
virtual

Definition at line 118 of file G4ParticleMessenger.cc.

119{
120 delete fParticlePropertyMessenger;
121
122 delete listCmd;
123 delete selectCmd;
124 delete findCmd;
125 delete createAllCmd;
126 delete verboseCmd;
127
128 delete thisDirectory;
129}

Member Function Documentation

◆ GetCurrentValue()

G4String G4ParticleMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 191 of file G4ParticleMessenger.cc.

192{
193 if( command==selectCmd ){
194 //Command /particle/select
195 // set candidate List
196 G4String candidates("none");
197 G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
198 piter -> reset();
199 while( (*piter)() ){
200 G4ParticleDefinition *particle = piter->value();
201 candidates += " " + particle->GetParticleName();
202 }
203 selectCmd->SetCandidates((const char *)(candidates));
204
205 static G4String noName("none");
206 // current value
207 if(currentParticle == 0) {
208 // no particle is selected. return null
209 return noName;
210 } else {
211 return currentParticle->GetParticleName();
212 }
213 } else if( command==verboseCmd ){
214 //Commnad /particle/verbose
215 return verboseCmd->ConvertToString(theParticleTable->GetVerboseLevel());
216 }
217 return "";
218}
const G4String & GetParticleName() const
G4int GetVerboseLevel() const
G4PTblDicIterator * GetIterator()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 132 of file G4ParticleMessenger.cc.

133{
134 if( command==listCmd ){
135 //Commnad /particle/List
136 G4int counter = 0;
137 G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
138 piter -> reset();
139
140 while( (*piter)() ){
141 G4ParticleDefinition *particle = piter->value();
142 if ((newValues=="all") || (newValues==particle->GetParticleType())) {
143 G4cout << std::setw(19) << particle->GetParticleName();
144 if ((counter++)%4 == 3) {
145 G4cout << G4endl;
146 } else {
147 G4cout << ",";
148 }
149 }
150 }
151 G4cout << G4endl;
152 if (counter == 0) G4cout << newValues << " is not found " << G4endl;
153
154 //Command /particle/select
155 // set candidate List
156 G4String candidates("none");
157 piter -> reset();
158 while( (*piter)() ){
159 G4ParticleDefinition *particle = piter->value();
160 candidates += " " + particle->GetParticleName();
161 }
162 selectCmd->SetCandidates((const char *)(candidates));
163
164 } else if( command==selectCmd ){
165 //Commnad /particle/select
166 currentParticle = theParticleTable->FindParticle(newValues);
167 if(currentParticle == 0) {
168 G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
169 }
170
171 } else if( command==findCmd ){
172 //Commnad /particle/find
173 G4ParticleDefinition* tmp = theParticleTable->FindParticle( findCmd->GetNewIntValue(newValues));
174 if(tmp == 0) {
175 G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
176 } else {
177 G4cout << tmp->GetParticleName() << G4endl;
178 tmp->DumpTable();
179 }
180
181 } else if( command==createAllCmd ) {
182 //Commnad /particle/createAllIon
183 theParticleTable->GetIonTable()->CreateAllIon();
184
185 } else if( command==verboseCmd ) {
186 //Commnad /particle/verbose
187 theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
188 }
189}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void CreateAllIon()
Definition: G4IonTable.cc:996
const G4String & GetParticleType() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetVerboseLevel(G4int value)
G4IonTable * GetIonTable()
static G4int GetNewIntValue(const char *paramString)

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