Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ProcessTableMessenger.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ProcessTableMessenger.cc 108134 2018-01-09 13:29:12Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4ProcessTableMessenger.cc
33 //
34 // Description:
35 // This is a messenger class to interface to exchange information
36 // between ProcessTable and UI.
37 //
38 //
39 // History:
40 // 15 Aug. 1998, H. Kurashige
41 // Use STL vector instead of RW vector 1. Mar 00 H.Kurashige
42 // 02 June 2006, add physicsModified in activate/inactivate (mma)
43 //
44 //---------------------------------------------------------------
45 
47 
48 #include "G4UImanager.hh"
49 #include "G4UIdirectory.hh"
51 #include "G4UIcmdWithAnInteger.hh"
52 #include "G4UIcmdWithAString.hh"
53 
54 #include "G4VProcess.hh"
55 #include "G4ProcessManager.hh"
56 #include "G4ProcessTable.hh"
57 #include "G4ParticleTable.hh"
58 
59 #include "G4ios.hh"
60 #include "G4Tokenizer.hh"
61 #include <iomanip>
62 #include <sstream>
63 
66 
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");
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);
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);
115  param = new G4UIparameter("type",'s',true);
116  param->SetDefaultValue("all");
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 /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 /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 }
160 
163 {
164  delete activateCmd;
165  delete inactivateCmd;
166  delete verboseCmd;
167  delete dumpCmd;
168  delete listCmd;
169  delete procVerboseCmd;
170  delete thisDirectory;
171 }
172 
175 {
176  G4ProcessTable::G4ProcNameVector* procNameVector
178  G4int idx;
179  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
228  G4bool isProcName = false;
229  G4bool isAll = false;
230  type = -1;
231 
232  if (currentProcessTypeName == "all") {
233  isAll = true;
234  } else {
236  if (type<0) {
237  isProcName = true;
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
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) {
277  if (type <0 ) {
278  // no processes with specifed name
279  ed << " illegal process (or type) name ["
280  << currentProcessName << "]";
281  command->CommandFailed(ed);
282  currentProcessName = "";
283  return;
284  }
285  }
286 
287  // check 2nd argument
288  currentParticleName = G4String(next());
289  G4bool isParticleFound = false;
290  G4ParticleDefinition* currentParticle = 0;
291  if ( currentParticleName == "all" ) {
292  isParticleFound = true;
293 
294  } else {
296  if (isParticleFound) {
298  }
299 
300  }
301 
302  if ( !isParticleFound ) {
303  // no particle with specifed name
304  ed << " illegal particle name [" << currentParticleName << "]";
305  command->CommandFailed(ed);
306  currentParticleName = "";
307  return;
308  }
309 
310  if( command==dumpCmd ) {
311  // process/dump
312  G4ProcessVector* tmpVector;
313  if (isProcName) {
315  } else {
316  tmpVector = theProcessTable->FindProcesses(G4ProcessType(type));
317  }
318  for (G4int i=0; i<tmpVector->length(); i++) {
319  theProcessTable->DumpInfo( (*tmpVector)(i), currentParticle );
320  }
321  delete tmpVector;
322  // process/dump
323 
324  } else if ( (command==activateCmd) || (command==inactivateCmd)) {
325  // process/activate , inactivate
326  G4bool fActive = (command==activateCmd);
327  if (isProcName) {
328  if ( currentParticle == 0 ) {
330  fActive);
331  } else {
333  currentParticle,
334  fActive);
335  }
336  } else {
337  if ( currentParticle == 0 ) {
339  fActive);
340  } else {
342  currentParticle,
343  fActive);
344  }
345  }
346  G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
347  // process/activate , inactivate
348  }
349  }
350 }
351 
352 
355 {
356  if( command==verboseCmd ){
357  //Commnad /process/verbose
359 
360  } else if ( command==listCmd ){
361  //Commnad /process/list
362  return currentProcessTypeName;
363 
364  } else {
365  //Commnad /process/dump, activate, inactivate
366  return (currentProcessName + " " + currentParticleName);
367 
368  }
369 
370  return "";
371 }
372 
375 {
376  return G4VProcess::GetProcessTypeName(aType);
377 }
378 
381 {
382  G4int type = -1;
383  for (G4int idx = 0; idx < NumberOfProcessType ; idx ++ ) {
384  if (aTypeName == G4VProcess::GetProcessTypeName(G4ProcessType(idx)) ) {
385  type = idx;
386  break;
387  }
388  }
389  return type;
390 }
391 
392 
395 {
396  G4bool isFoundEndMark = false;
397  G4int idx;
398  for (idx = 0; idx < 1000 ; idx ++ ) {
400  isFoundEndMark = typeName.contains("---");
401  if ( isFoundEndMark ) break;
402  }
403  if ( isFoundEndMark ) {
404  NumberOfProcessType = idx;
405  } else {
406  G4Exception("G4ProcessTableMessenger::SetNumberOfProcessType()","ProcMan014",
407  FatalException,"No End Mark");
408  }
409 }
410 
411 
412 
413 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4bool isNull() const
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:202
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
static G4ParticleTable * GetParticleTable()
G4bool contains(const G4ParticleDefinition *particle) const
void SetVerboseLevel(G4int value)
void DumpInfo(G4VProcess *process, G4ParticleDefinition *particle=0)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
const char * p
Definition: xmltok.h:285
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
G4String GetProcessTypeName(G4ProcessType aType) const
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetDefaultValue(const char *defVal)
static G4ThreadLocal G4int NumberOfProcessType
#define G4ThreadLocal
Definition: tls.hh:69
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static const G4String & GetProcessTypeName(G4ProcessType)
Definition: G4VProcess.cc:142
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:440
void SetDefaultValue(const char *theDefaultValue)
bool G4bool
Definition: G4Types.hh:79
G4int length() const
G4ProcessType
G4ProcessVector * FindProcesses()
void SetProcessActivation(const G4String &processName, G4bool fActive)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:411
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:417
G4bool contains(const std::string &) const
void SetCandidates(const char *candidateList)
G4int GetVerboseLevel() const
virtual G4String GetCurrentValue(G4UIcommand *command)
G4ProcNameVector * GetNameList()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4GLOB_DLL std::ostream G4cout
std::vector< G4String > G4ProcNameVector
G4int GetProcessType(const G4String &aTypeName) const
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
G4UIcmdWithAnInteger * verboseCmd