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

#include <G4ProcessTableMessenger.hh>

+ Inheritance diagram for G4ProcessTableMessenger:

Public Member Functions

 G4ProcessTableMessenger (G4ProcessTable *pTable)
 
virtual ~G4ProcessTableMessenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual 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 65 of file G4ProcessTableMessenger.hh.

Constructor & Destructor Documentation

◆ G4ProcessTableMessenger()

G4ProcessTableMessenger::G4ProcessTableMessenger ( G4ProcessTable pTable)

Definition at line 68 of file G4ProcessTableMessenger.cc.

69 :theProcessTable(pTable),
70 currentProcessTypeName("all"),
71 currentProcessName("all"),
72 currentParticleName("all")
73{
74 //Commnad /particle/process
75 thisDirectory = new G4UIdirectory("/process/");
76 thisDirectory->SetGuidance("Process Table control commands.");
77
78
79 //Commnad /particle/process/list
80 listCmd = new G4UIcmdWithAString("/process/list",this);
81 listCmd->SetGuidance("List up process names");
82 listCmd->SetGuidance(" list [type] ");
83 listCmd->SetGuidance(" type: process type [all:for all proceeses]");
84 listCmd->SetParameterName("type", true);
85 listCmd->SetDefaultValue("all");
86 SetNumberOfProcessType();
87
88 G4String candidates("all");
89 for (G4int idx = 0; idx < NumberOfProcessType ; idx ++ ) {
90 candidates += " " +
92 }
93 listCmd->SetCandidates((const char*)(candidates));
94
95 //Commnad /particle/process/Verbose
96 verboseCmd = new G4UIcmdWithAnInteger("/process/verbose",this);
97 verboseCmd->SetGuidance("Set Verbose Level for Process Table");
98 verboseCmd->SetGuidance(" verbose [level]");
99 verboseCmd->SetGuidance(" level: verbose level");
100 verboseCmd->SetParameterName("verbose", true);
101 verboseCmd->SetDefaultValue(1);
102 verboseCmd->SetRange("verbose >=0");
104
105 //Commnad /particle/process/setVerbose
106 procVerboseCmd = new G4UIcommand("/process/setVerbose",this);
107 procVerboseCmd->SetGuidance("Set verbose level for processes");
108 procVerboseCmd->SetGuidance(" setVerbose level [type or name] ");
109 procVerboseCmd->SetGuidance(" level: verbose level ");
110 procVerboseCmd->SetGuidance(" name : process name ");
111 procVerboseCmd->SetGuidance(" type : process type ");
112 procVerboseCmd->SetGuidance(" [all] for all proceeses ");
113 G4UIparameter* param = new G4UIparameter("verbose",'i',false);
114 procVerboseCmd->SetParameter(param);
115 param = new G4UIparameter("type",'s',true);
116 param->SetDefaultValue("all");
117 procVerboseCmd->SetParameter(param);
119
120 //Commnad /particle/process/dump
121 dumpCmd = new G4UIcommand("/process/dump",this);
122 dumpCmd->SetGuidance("Dump process information");
123 dumpCmd->SetGuidance(" dump name [particle]");
124 dumpCmd->SetGuidance(" name: process name or type name");
125 dumpCmd->SetGuidance(" particle: particle name [all: for all particles]");
126 param = new G4UIparameter("procName",'s',false);
127 dumpCmd->SetParameter(param);
128 param = new G4UIparameter("particle",'s',true);
129 param->SetDefaultValue("all");
130 dumpCmd->SetParameter(param);
132
133 //Commnad /particle/process/activate
134 activateCmd = new G4UIcommand("/process/activate",this);
135 activateCmd->SetGuidance("Activate processes ");
136 activateCmd->SetGuidance(" Activate name [particle]");
137 activateCmd->SetGuidance(" name: process name or type name");
138 activateCmd->SetGuidance(" particle: particle name [all: for all particles]");
139 param = new G4UIparameter("procName",'s',false);
140 activateCmd->SetParameter(param);
141 param = new G4UIparameter("particle",'s',true);
142 param->SetDefaultValue("all");
143 activateCmd->SetParameter(param);
145
146 //Commnad /particle/process/inactivate
147 inactivateCmd = new G4UIcommand("/process/inactivate",this);
148 inactivateCmd->SetGuidance("Inactivate process ");
149 inactivateCmd->SetGuidance("Inactivate processes ");
150 inactivateCmd->SetGuidance(" Inactivate name [particle]");
151 inactivateCmd->SetGuidance(" name: process name or type name");
152 inactivateCmd->SetGuidance(" particle: particle name [all: for all particles]");
153 param = new G4UIparameter("procName",'s',false);
154 inactivateCmd->SetParameter(param);
155 param = new G4UIparameter("particle",'s',true);
156 param->SetDefaultValue("all");
157 inactivateCmd->SetParameter(param);
159}
@ G4State_EventProc
@ G4State_Init
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
G4ProcessType
int G4int
Definition: G4Types.hh:66
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 SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
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
void SetDefaultValue(const char *theDefaultValue)
static const G4String & GetProcessTypeName(G4ProcessType)
Definition: G4VProcess.cc:150

Referenced by G4ProcessTableMessenger().

◆ ~G4ProcessTableMessenger()

G4ProcessTableMessenger::~G4ProcessTableMessenger ( )
virtual

Definition at line 162 of file G4ProcessTableMessenger.cc.

163{
164 delete activateCmd;
165 delete inactivateCmd;
166 delete verboseCmd;
167 delete dumpCmd;
168 delete listCmd;
169 delete procVerboseCmd;
170 delete thisDirectory;
171}

Member Function Documentation

◆ GetCurrentValue()

G4String G4ProcessTableMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 351 of file G4ProcessTableMessenger.cc.

352{
353 G4ProcessTable::G4ProcNameVector* procNameVector
354 = theProcessTable->GetNameList();
355
356 G4String candidates;
357 G4String returnValue('\0');
358
359 std::ostringstream os;
360 G4UIparameter * param;
361
362 G4int idx;
363
364 if( command==verboseCmd ){
365 //Commnad /process/verbose
366 os << theProcessTable->GetVerboseLevel();
367 returnValue = os.str();
368
369 } else if ( command==listCmd ){
370 //Commnad /process/list
371 candidates = "all";
372 for (idx = 0; idx < NumberOfProcessType ; idx ++ ) {
373 candidates += " " +
375 }
376 listCmd->SetCandidates((const char*)(candidates));
377 returnValue = currentProcessTypeName;
378
379 } else {
380 //Commnad /process/dump, activate, inactivate
381 // process name
382 param = command->GetParameter(0);
383 candidates = "";
384 G4ProcessTable::G4ProcNameVector::iterator itr;
385 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) {
386 candidates += " " + (*itr);
387 }
388 param->SetParameterCandidates((const char*)(candidates));
389 // particle name
390 param = command->GetParameter(1);
391 candidates = "all";
394 piter -> reset();
395 while( (*piter)() ){
396 G4ParticleDefinition *particle = piter->value();
397 candidates += " " + particle->GetParticleName();
398 }
399 param->SetParameterCandidates((const char*)(candidates));
400
401 returnValue = currentProcessName + " " + currentParticleName;
402
403 }
404
405 return returnValue;
406}
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator()
static G4ParticleTable * GetParticleTable()
G4ProcNameVector * GetNameList()
G4int GetVerboseLevel() const
std::vector< G4String > G4ProcNameVector
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:140
void SetParameterCandidates(const char *theString)

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 174 of file G4ProcessTableMessenger.cc.

175{
176 G4ProcessTable::G4ProcNameVector* procNameVector
177 = theProcessTable->GetNameList();
178 G4int idx;
179
180 G4int type = -1;
181
182 if( command == listCmd ){
183 //Commnad /process/list
184 type = -1;
185 if (newValue == "all") {
186 currentProcessTypeName = newValue;
187 } else {
188 type = GetProcessType(newValue);
189 if (type <0) {
190 G4cout << " illegal type !!! " << G4endl;
191 } else {
192 currentProcessTypeName = newValue;
193 }
194 }
195 G4int counter = 0;
196 idx =0;
197 G4ProcessTable::G4ProcNameVector::iterator itr;
198 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) {
199 idx +=1;
200 G4ProcessVector* tmpVector = theProcessTable->FindProcesses(*itr);
201 if ( (type <0) || ( ((*tmpVector)(0)->GetProcessType()) == type) ) {
202 if ( counter%4 != 0) G4cout << ",";
203 G4cout << std::setw(19) <<*itr;
204 if ((counter++)%4 == 3) {
205 G4cout << G4endl;
206 }
207 }
208 delete tmpVector;
209 }
210 G4cout << G4endl;
211 //Commnad /process/list
212
213 } else if( command==procVerboseCmd ) {
214 //Commnad /process/setVerbose
215 G4Tokenizer next( newValue );
216
217 // check 1st argument
218 G4String tmpS = G4String(next());
219 // inputstream for newValues
220 const char* temp = (const char*)(tmpS);
221 std::istringstream is((char*)temp);
222 G4int level;
223 is >>level;
224
225 // check 2nd argument
226 currentProcessTypeName = G4String(next());
227 if (currentProcessTypeName.isNull()) currentProcessTypeName = "all";
228 G4bool isProcName = false;
229 G4bool isAll = false;
230 type = -1;
231
232 if (currentProcessTypeName == "all") {
233 isAll = true;
234 } else {
235 type = GetProcessType(currentProcessTypeName);
236 if (type<0) {
237 isProcName = true;
238 currentProcessName = currentProcessTypeName;
239 currentProcessTypeName = "";
240 }
241 }
242 idx =0;
243 G4ProcessTable::G4ProcNameVector::iterator itr;
244 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) {
245 idx +=1;
246 G4ProcessVector* tmpVector = theProcessTable->FindProcesses(*itr);
247 G4VProcess* p = (*tmpVector)(0);
248 if ( isAll ||
249 (!isProcName && ( p->GetProcessType() == type) ) ||
250 ( isProcName && ( p->GetProcessName()== currentProcessName) ) ){
251 p->SetVerboseLevel(level);
252 }
253 delete tmpVector;
254 }
255 //Commnad /process/setVerbose
256
257 } else if( command==verboseCmd ) {
258 //Commnad /process/verbose
259 theProcessTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
260 //Commnad /process/verbose
261
262 } else {
263 G4Tokenizer next( newValue );
264
265 // check 1st argument
266 currentProcessName = G4String(next());
267 G4bool isProcName = false;
268 G4ProcessTable::G4ProcNameVector::iterator itr;
269 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) {
270 if ( (*itr) == currentProcessName ) {
271 isProcName = true;
272 break;
273 }
274 }
275 if (!isProcName) {
276 type = GetProcessType(currentProcessName);
277 if (type <0 ) {
278 // no processes with specifed name
279 G4cout << " illegal process (or type) name " << G4endl;
280 currentProcessName = "";
281 return;
282 }
283 }
284
285 // check 2nd argument
286 currentParticleName = G4String(next());
287 G4bool isParticleFound = false;
288 G4ParticleDefinition* currentParticle = 0;
289 if ( currentParticleName == "all" ) {
290 isParticleFound = true;
291
292 } else {
293 isParticleFound = G4ParticleTable::GetParticleTable()->contains(currentParticleName);
294 if (isParticleFound) {
295 currentParticle = G4ParticleTable::GetParticleTable()->FindParticle(currentParticleName);
296 }
297
298 }
299
300 if ( !isParticleFound ) {
301 // no particle with specifed name
302 G4cout << " illegal particle name " << G4endl;
303 currentParticleName = "";
304 return;
305 }
306
307 if( command==dumpCmd ) {
308 // process/dump
309 G4ProcessVector* tmpVector;
310 if (isProcName) {
311 tmpVector = theProcessTable->FindProcesses(currentProcessName);
312 } else {
313 tmpVector = theProcessTable->FindProcesses(G4ProcessType(type));
314 }
315 for (G4int i=0; i<tmpVector->length(); i++) {
316 theProcessTable->DumpInfo( (*tmpVector)(i), currentParticle );
317 }
318 delete tmpVector;
319 // process/dump
320
321 } else if ( (command==activateCmd) || (command==inactivateCmd)) {
322 // process/activate , inactivate
323 G4bool fActive = (command==activateCmd);
324 if (isProcName) {
325 if ( currentParticle == 0 ) {
326 theProcessTable->SetProcessActivation(currentProcessName,
327 fActive);
328 } else {
329 theProcessTable->SetProcessActivation(currentProcessName,
330 currentParticle,
331 fActive);
332 }
333 } else {
334 if ( currentParticle == 0 ) {
335 theProcessTable->SetProcessActivation(G4ProcessType(type),
336 fActive);
337 } else {
338 theProcessTable->SetProcessActivation(G4ProcessType(type),
339 currentParticle,
340 fActive);
341 }
342 }
343 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
344 // process/activate , inactivate
345 }
346 }
347}
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4bool contains(const G4ParticleDefinition *particle)
void DumpInfo(G4VProcess *process, G4ParticleDefinition *particle=0)
void SetProcessActivation(const G4String &processName, G4bool fActive)
G4ProcessVector * FindProcesses()
void SetVerboseLevel(G4int value)
G4int length() const
G4bool isNull() const
static G4int GetNewIntValue(const char *paramString)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:369
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:408
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:385
const G4String & GetProcessName() const
Definition: G4VProcess.hh:379

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