Geant4 11.2.2
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 ()
 
 G4ProcessTableMessenger (const G4ProcessTableMessenger &)=delete
 
G4ProcessTableMessengeroperator= (const G4ProcessTableMessenger &)=delete
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 55 of file G4ProcessTableMessenger.hh.

Constructor & Destructor Documentation

◆ G4ProcessTableMessenger() [1/2]

G4ProcessTableMessenger::G4ProcessTableMessenger ( G4ProcessTable * pTable)

Definition at line 52 of file G4ProcessTableMessenger.cc.

53 : theProcessTable(pTable)
54{
55 // Command /particle/process
56 thisDirectory = new G4UIdirectory("/process/");
57 thisDirectory->SetGuidance("Process Table control commands.");
58
59 // Command /particle/process/list
60 listCmd = new G4UIcmdWithAString("/process/list",this);
61 listCmd->SetGuidance("List up process names");
62 listCmd->SetGuidance(" list [type] ");
63 listCmd->SetGuidance(" type: process type [all:for all processes]");
64 listCmd->SetParameterName("type", true);
65 listCmd->SetDefaultValue("all");
66 SetNumberOfProcessType();
67
68 G4String candidates("all");
69 for (G4int idx = 0; idx < NumberOfProcessType ; ++idx )
70 {
71 candidates += " " + G4VProcess::GetProcessTypeName(G4ProcessType(idx));
72 }
73 listCmd->SetCandidates((const char*)(candidates));
74
75 // Command /particle/process/verbose
76 verboseCmd = new G4UIcmdWithAnInteger("/process/verbose",this);
77 verboseCmd->SetGuidance("Set Verbose Level for Process Table");
78 verboseCmd->SetGuidance(" verbose [level]");
79 verboseCmd->SetGuidance(" level: verbose level");
80 verboseCmd->SetParameterName("verbose", true);
81 verboseCmd->SetDefaultValue(1);
82 verboseCmd->SetRange("verbose >=0");
84
85 // Command /particle/process/setVerbose
86 procVerboseCmd = new G4UIcommand("/process/setVerbose",this);
87 procVerboseCmd->SetGuidance("Set verbose level for processes");
88 procVerboseCmd->SetGuidance(" setVerbose level [type or name] ");
89 procVerboseCmd->SetGuidance(" level: verbose level ");
90 procVerboseCmd->SetGuidance(" name : process name ");
91 procVerboseCmd->SetGuidance(" type : process type ");
92 procVerboseCmd->SetGuidance(" [all] for all processes ");
93 G4UIparameter* param = new G4UIparameter("verbose",'i',false);
94 procVerboseCmd->SetParameter(param);
95 param = new G4UIparameter("type",'s',true);
96 param->SetDefaultValue("all");
97 procVerboseCmd->SetParameter(param);
99
100 // Command /particle/process/dump
101 dumpCmd = new G4UIcommand("/process/dump",this);
102 dumpCmd->SetGuidance("Dump process information");
103 dumpCmd->SetGuidance(" dump name [particle]");
104 dumpCmd->SetGuidance(" name: process name or type name");
105 dumpCmd->SetGuidance(" particle: particle name [all: for all particles]");
106 param = new G4UIparameter("procName",'s',false);
107 dumpCmd->SetParameter(param);
108 param = new G4UIparameter("particle",'s',true);
109 param->SetDefaultValue("all");
110 dumpCmd->SetParameter(param);
112
113 // Command /process/activate
114 activateCmd = new G4UIcommand("/process/activate",this);
115 activateCmd->SetGuidance("Activate processes ");
116 activateCmd->SetGuidance(" Activate name [particle]");
117 activateCmd->SetGuidance(" name: process name or type name");
118 activateCmd->SetGuidance(" particle: particle name [all: for all particles]");
119 param = new G4UIparameter("procName",'s',false);
120 activateCmd->SetParameter(param);
121 param = new G4UIparameter("particle",'s',true);
122 param->SetDefaultValue("all");
123 activateCmd->SetParameter(param);
124 activateCmd->AvailableForStates(G4State_Idle);
125
126 // Command /process/inactivate
127 inactivateCmd = new G4UIcommand("/process/inactivate",this);
128 inactivateCmd->SetGuidance("Inactivate process ");
129 inactivateCmd->SetGuidance("Inactivate processes ");
130 inactivateCmd->SetGuidance(" Inactivate name [particle]");
131 inactivateCmd->SetGuidance(" name: process name or type name");
132 inactivateCmd->SetGuidance(" particle: particle name [all: for all particles]");
133 param = new G4UIparameter("procName",'s',false);
134 inactivateCmd->SetParameter(param);
135 param = new G4UIparameter("particle",'s',true);
136 param->SetDefaultValue("all");
137 inactivateCmd->SetParameter(param);
138 inactivateCmd->AvailableForStates(G4State_Idle);
139}
@ G4State_EventProc
@ G4State_Init
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
G4ProcessType
int G4int
Definition G4Types.hh:85
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)
void SetGuidance(const char *aGuidance)
void SetRange(const char *rs)
void AvailableForStates(G4ApplicationState s1)
void SetDefaultValue(const char *theDefaultValue)
static const G4String & GetProcessTypeName(G4ProcessType)

Referenced by G4ProcessTableMessenger().

◆ ~G4ProcessTableMessenger()

G4ProcessTableMessenger::~G4ProcessTableMessenger ( )
virtual

Definition at line 142 of file G4ProcessTableMessenger.cc.

143{
144 delete activateCmd;
145 delete inactivateCmd;
146 delete verboseCmd;
147 delete dumpCmd;
148 delete listCmd;
149 delete procVerboseCmd;
150 delete thisDirectory;
151}

◆ G4ProcessTableMessenger() [2/2]

G4ProcessTableMessenger::G4ProcessTableMessenger ( const G4ProcessTableMessenger & )
delete

Member Function Documentation

◆ GetCurrentValue()

G4String G4ProcessTableMessenger::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 364 of file G4ProcessTableMessenger.cc.

365{
366 if( command==verboseCmd )
367 {
368 // Command /process/verbose
369 return verboseCmd->ConvertToString(theProcessTable->GetVerboseLevel());
370 }
371 else if ( command==listCmd )
372 {
373 // Command /process/list
374 return currentProcessTypeName;
375 }
376 else
377 {
378 // Command /process/dump, activate, inactivate
379 return (currentProcessName + " " + currentParticleName);
380 }
381
382 return "";
383}
G4int GetVerboseLevel() const
static G4String ConvertToString(G4bool boolVal)

◆ operator=()

G4ProcessTableMessenger & G4ProcessTableMessenger::operator= ( const G4ProcessTableMessenger & )
delete

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 155 of file G4ProcessTableMessenger.cc.

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

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