#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) |
Definition at line 65 of file G4ProcessTableMessenger.hh.
G4ProcessTableMessenger::G4ProcessTableMessenger | ( | G4ProcessTable * | pTable | ) |
Definition at line 68 of file G4ProcessTableMessenger.cc.
References G4UIcommand::AvailableForStates(), G4ProcessTableMessenger(), G4State_EventProc, G4State_GeomClosed, G4State_Idle, G4State_Init, G4State_PreInit, G4VProcess::GetProcessTypeName(), G4UIcmdWithAString::SetCandidates(), G4UIparameter::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcmdWithAString::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), and G4UIcommand::SetRange().
Referenced by G4ProcessTableMessenger().
00069 :theProcessTable(pTable), 00070 currentProcessTypeName("all"), 00071 currentProcessName("all"), 00072 currentParticleName("all") 00073 { 00074 //Commnad /particle/process 00075 thisDirectory = new G4UIdirectory("/process/"); 00076 thisDirectory->SetGuidance("Process Table control commands."); 00077 00078 00079 //Commnad /particle/process/list 00080 listCmd = new G4UIcmdWithAString("/process/list",this); 00081 listCmd->SetGuidance("List up process names"); 00082 listCmd->SetGuidance(" list [type] "); 00083 listCmd->SetGuidance(" type: process type [all:for all proceeses]"); 00084 listCmd->SetParameterName("type", true); 00085 listCmd->SetDefaultValue("all"); 00086 SetNumberOfProcessType(); 00087 00088 G4String candidates("all"); 00089 for (G4int idx = 0; idx < NumberOfProcessType ; idx ++ ) { 00090 candidates += " " + 00091 G4VProcess::GetProcessTypeName(G4ProcessType(idx)); 00092 } 00093 listCmd->SetCandidates((const char*)(candidates)); 00094 00095 //Commnad /particle/process/Verbose 00096 verboseCmd = new G4UIcmdWithAnInteger("/process/verbose",this); 00097 verboseCmd->SetGuidance("Set Verbose Level for Process Table"); 00098 verboseCmd->SetGuidance(" verbose [level]"); 00099 verboseCmd->SetGuidance(" level: verbose level"); 00100 verboseCmd->SetParameterName("verbose", true); 00101 verboseCmd->SetDefaultValue(1); 00102 verboseCmd->SetRange("verbose >=0"); 00103 verboseCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00104 00105 //Commnad /particle/process/setVerbose 00106 procVerboseCmd = new G4UIcommand("/process/setVerbose",this); 00107 procVerboseCmd->SetGuidance("Set verbose level for processes"); 00108 procVerboseCmd->SetGuidance(" setVerbose level [type or name] "); 00109 procVerboseCmd->SetGuidance(" level: verbose level "); 00110 procVerboseCmd->SetGuidance(" name : process name "); 00111 procVerboseCmd->SetGuidance(" type : process type "); 00112 procVerboseCmd->SetGuidance(" [all] for all proceeses "); 00113 G4UIparameter* param = new G4UIparameter("verbose",'i',false); 00114 procVerboseCmd->SetParameter(param); 00115 param = new G4UIparameter("type",'s',true); 00116 param->SetDefaultValue("all"); 00117 procVerboseCmd->SetParameter(param); 00118 procVerboseCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00119 00120 //Commnad /particle/process/dump 00121 dumpCmd = new G4UIcommand("/process/dump",this); 00122 dumpCmd->SetGuidance("Dump process information"); 00123 dumpCmd->SetGuidance(" dump name [particle]"); 00124 dumpCmd->SetGuidance(" name: process name or type name"); 00125 dumpCmd->SetGuidance(" particle: particle name [all: for all particles]"); 00126 param = new G4UIparameter("procName",'s',false); 00127 dumpCmd->SetParameter(param); 00128 param = new G4UIparameter("particle",'s',true); 00129 param->SetDefaultValue("all"); 00130 dumpCmd->SetParameter(param); 00131 dumpCmd->AvailableForStates(G4State_Init,G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00132 00133 //Commnad /particle/process/activate 00134 activateCmd = new G4UIcommand("/process/activate",this); 00135 activateCmd->SetGuidance("Activate processes "); 00136 activateCmd->SetGuidance(" Activate name [particle]"); 00137 activateCmd->SetGuidance(" name: process name or type name"); 00138 activateCmd->SetGuidance(" particle: particle name [all: for all particles]"); 00139 param = new G4UIparameter("procName",'s',false); 00140 activateCmd->SetParameter(param); 00141 param = new G4UIparameter("particle",'s',true); 00142 param->SetDefaultValue("all"); 00143 activateCmd->SetParameter(param); 00144 activateCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00145 00146 //Commnad /particle/process/inactivate 00147 inactivateCmd = new G4UIcommand("/process/inactivate",this); 00148 inactivateCmd->SetGuidance("Inactivate process "); 00149 inactivateCmd->SetGuidance("Inactivate processes "); 00150 inactivateCmd->SetGuidance(" Inactivate name [particle]"); 00151 inactivateCmd->SetGuidance(" name: process name or type name"); 00152 inactivateCmd->SetGuidance(" particle: particle name [all: for all particles]"); 00153 param = new G4UIparameter("procName",'s',false); 00154 inactivateCmd->SetParameter(param); 00155 param = new G4UIparameter("particle",'s',true); 00156 param->SetDefaultValue("all"); 00157 inactivateCmd->SetParameter(param); 00158 inactivateCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 00159 }
G4ProcessTableMessenger::~G4ProcessTableMessenger | ( | ) | [virtual] |
Definition at line 162 of file G4ProcessTableMessenger.cc.
00163 { 00164 delete activateCmd; 00165 delete inactivateCmd; 00166 delete verboseCmd; 00167 delete dumpCmd; 00168 delete listCmd; 00169 delete procVerboseCmd; 00170 delete thisDirectory; 00171 }
G4String G4ProcessTableMessenger::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 351 of file G4ProcessTableMessenger.cc.
References G4ParticleTable::GetIterator(), G4ProcessTable::GetNameList(), G4UIcommand::GetParameter(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetParticleTable(), G4VProcess::GetProcessTypeName(), G4ProcessTable::GetVerboseLevel(), G4UIcmdWithAString::SetCandidates(), G4UIparameter::SetParameterCandidates(), and G4ParticleTableIterator< K, V >::value().
00352 { 00353 G4ProcessTable::G4ProcNameVector* procNameVector 00354 = theProcessTable->GetNameList(); 00355 00356 G4String candidates; 00357 G4String returnValue('\0'); 00358 00359 std::ostringstream os; 00360 G4UIparameter * param; 00361 00362 G4int idx; 00363 00364 if( command==verboseCmd ){ 00365 //Commnad /process/verbose 00366 os << theProcessTable->GetVerboseLevel(); 00367 returnValue = os.str(); 00368 00369 } else if ( command==listCmd ){ 00370 //Commnad /process/list 00371 candidates = "all"; 00372 for (idx = 0; idx < NumberOfProcessType ; idx ++ ) { 00373 candidates += " " + 00374 G4VProcess::GetProcessTypeName(G4ProcessType(idx)); 00375 } 00376 listCmd->SetCandidates((const char*)(candidates)); 00377 returnValue = currentProcessTypeName; 00378 00379 } else { 00380 //Commnad /process/dump, activate, inactivate 00381 // process name 00382 param = command->GetParameter(0); 00383 candidates = ""; 00384 G4ProcessTable::G4ProcNameVector::iterator itr; 00385 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) { 00386 candidates += " " + (*itr); 00387 } 00388 param->SetParameterCandidates((const char*)(candidates)); 00389 // particle name 00390 param = command->GetParameter(1); 00391 candidates = "all"; 00392 G4ParticleTable::G4PTblDicIterator *piter 00393 = G4ParticleTable::GetParticleTable()->GetIterator(); 00394 piter -> reset(); 00395 while( (*piter)() ){ 00396 G4ParticleDefinition *particle = piter->value(); 00397 candidates += " " + particle->GetParticleName(); 00398 } 00399 param->SetParameterCandidates((const char*)(candidates)); 00400 00401 returnValue = currentProcessName + " " + currentParticleName; 00402 00403 } 00404 00405 return returnValue; 00406 }
void G4ProcessTableMessenger::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValues | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 174 of file G4ProcessTableMessenger.cc.
References G4UImanager::ApplyCommand(), G4ParticleTable::contains(), G4ProcessTable::DumpInfo(), G4ParticleTable::FindParticle(), G4ProcessTable::FindProcesses(), G4cout, G4endl, G4ProcessTable::GetNameList(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ParticleTable::GetParticleTable(), G4VProcess::GetProcessName(), G4VProcess::GetProcessType(), G4UImanager::GetUIpointer(), G4String::isNull(), G4ProcessVector::length(), G4ProcessTable::SetProcessActivation(), G4ProcessTable::SetVerboseLevel(), and G4VProcess::SetVerboseLevel().
00175 { 00176 G4ProcessTable::G4ProcNameVector* procNameVector 00177 = theProcessTable->GetNameList(); 00178 G4int idx; 00179 00180 G4int type = -1; 00181 00182 if( command == listCmd ){ 00183 //Commnad /process/list 00184 type = -1; 00185 if (newValue == "all") { 00186 currentProcessTypeName = newValue; 00187 } else { 00188 type = GetProcessType(newValue); 00189 if (type <0) { 00190 G4cout << " illegal type !!! " << G4endl; 00191 } else { 00192 currentProcessTypeName = newValue; 00193 } 00194 } 00195 G4int counter = 0; 00196 idx =0; 00197 G4ProcessTable::G4ProcNameVector::iterator itr; 00198 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) { 00199 idx +=1; 00200 G4ProcessVector* tmpVector = theProcessTable->FindProcesses(*itr); 00201 if ( (type <0) || ( ((*tmpVector)(0)->GetProcessType()) == type) ) { 00202 if ( counter%4 != 0) G4cout << ","; 00203 G4cout << std::setw(19) <<*itr; 00204 if ((counter++)%4 == 3) { 00205 G4cout << G4endl; 00206 } 00207 } 00208 delete tmpVector; 00209 } 00210 G4cout << G4endl; 00211 //Commnad /process/list 00212 00213 } else if( command==procVerboseCmd ) { 00214 //Commnad /process/setVerbose 00215 G4Tokenizer next( newValue ); 00216 00217 // check 1st argument 00218 G4String tmpS = G4String(next()); 00219 // inputstream for newValues 00220 const char* temp = (const char*)(tmpS); 00221 std::istringstream is((char*)temp); 00222 G4int level; 00223 is >>level; 00224 00225 // check 2nd argument 00226 currentProcessTypeName = G4String(next()); 00227 if (currentProcessTypeName.isNull()) currentProcessTypeName = "all"; 00228 G4bool isProcName = false; 00229 G4bool isAll = false; 00230 type = -1; 00231 00232 if (currentProcessTypeName == "all") { 00233 isAll = true; 00234 } else { 00235 type = GetProcessType(currentProcessTypeName); 00236 if (type<0) { 00237 isProcName = true; 00238 currentProcessName = currentProcessTypeName; 00239 currentProcessTypeName = ""; 00240 } 00241 } 00242 idx =0; 00243 G4ProcessTable::G4ProcNameVector::iterator itr; 00244 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) { 00245 idx +=1; 00246 G4ProcessVector* tmpVector = theProcessTable->FindProcesses(*itr); 00247 G4VProcess* p = (*tmpVector)(0); 00248 if ( isAll || 00249 (!isProcName && ( p->GetProcessType() == type) ) || 00250 ( isProcName && ( p->GetProcessName()== currentProcessName) ) ){ 00251 p->SetVerboseLevel(level); 00252 } 00253 delete tmpVector; 00254 } 00255 //Commnad /process/setVerbose 00256 00257 } else if( command==verboseCmd ) { 00258 //Commnad /process/verbose 00259 theProcessTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); 00260 //Commnad /process/verbose 00261 00262 } else { 00263 G4Tokenizer next( newValue ); 00264 00265 // check 1st argument 00266 currentProcessName = G4String(next()); 00267 G4bool isProcName = false; 00268 G4ProcessTable::G4ProcNameVector::iterator itr; 00269 for (itr=procNameVector->begin(); itr!=procNameVector->end(); ++itr) { 00270 if ( (*itr) == currentProcessName ) { 00271 isProcName = true; 00272 break; 00273 } 00274 } 00275 if (!isProcName) { 00276 type = GetProcessType(currentProcessName); 00277 if (type <0 ) { 00278 // no processes with specifed name 00279 G4cout << " illegal process (or type) name " << G4endl; 00280 currentProcessName = ""; 00281 return; 00282 } 00283 } 00284 00285 // check 2nd argument 00286 currentParticleName = G4String(next()); 00287 G4bool isParticleFound = false; 00288 G4ParticleDefinition* currentParticle = 0; 00289 if ( currentParticleName == "all" ) { 00290 isParticleFound = true; 00291 00292 } else { 00293 isParticleFound = G4ParticleTable::GetParticleTable()->contains(currentParticleName); 00294 if (isParticleFound) { 00295 currentParticle = G4ParticleTable::GetParticleTable()->FindParticle(currentParticleName); 00296 } 00297 00298 } 00299 00300 if ( !isParticleFound ) { 00301 // no particle with specifed name 00302 G4cout << " illegal particle name " << G4endl; 00303 currentParticleName = ""; 00304 return; 00305 } 00306 00307 if( command==dumpCmd ) { 00308 // process/dump 00309 G4ProcessVector* tmpVector; 00310 if (isProcName) { 00311 tmpVector = theProcessTable->FindProcesses(currentProcessName); 00312 } else { 00313 tmpVector = theProcessTable->FindProcesses(G4ProcessType(type)); 00314 } 00315 for (G4int i=0; i<tmpVector->length(); i++) { 00316 theProcessTable->DumpInfo( (*tmpVector)(i), currentParticle ); 00317 } 00318 delete tmpVector; 00319 // process/dump 00320 00321 } else if ( (command==activateCmd) || (command==inactivateCmd)) { 00322 // process/activate , inactivate 00323 G4bool fActive = (command==activateCmd); 00324 if (isProcName) { 00325 if ( currentParticle == 0 ) { 00326 theProcessTable->SetProcessActivation(currentProcessName, 00327 fActive); 00328 } else { 00329 theProcessTable->SetProcessActivation(currentProcessName, 00330 currentParticle, 00331 fActive); 00332 } 00333 } else { 00334 if ( currentParticle == 0 ) { 00335 theProcessTable->SetProcessActivation(G4ProcessType(type), 00336 fActive); 00337 } else { 00338 theProcessTable->SetProcessActivation(G4ProcessType(type), 00339 currentParticle, 00340 fActive); 00341 } 00342 } 00343 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified"); 00344 // process/activate , inactivate 00345 } 00346 } 00347 }